{
int result = EXIT_STATUS_TESTCASE_FAILED;
- try
+// dont want to catch exception as we want to be able to get
+// gdb stack trace from the first error
+// by default tests should all always pass with no exceptions
+ if( testCase.startup )
{
- if( testCase.startup )
- {
- testCase.startup();
- }
- result = testCase.function();
- if( testCase.cleanup )
- {
- testCase.cleanup();
- }
+ testCase.startup();
}
- catch (...)
+ result = testCase.function();
+ if( testCase.cleanup )
{
- printf("Caught exception in test case.\n");
- result = EXIT_STATUS_TESTCASE_ABORTED;
+ testCase.cleanup();
}
return result;
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/hover-event-integ.h>
+#include <dali-toolkit/devel-api/styling/style-manager.h>
+
#include "dummy-control.h"
using namespace Dali;
{
DummyControl dummy = DummyControl::New( true );
- DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
dummy.SetSize( Vector2( 100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
}
END_TEST;
}
+
+int UtcDaliControlImplOnStyleChangeP(void)
+{
+ ToolkitTestApplication application;
+ DummyControl dummy = DummyControl::New( true );
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( dummy );
+
+ Dali::Toolkit::StyleManager styleManager;
+ controlImpl.OnStyleChange( styleManager, StyleChange::THEME_CHANGE );
+
+ // unfortunately OnStyleChange does not return anything
+ DALI_TEST_CHECK( true );
+
+ END_TEST;
+}
+
+
+int UtcDaliControlImplOnAccessibilityPanP(void)
+{
+ ToolkitTestApplication application;
+ DummyControl dummy = DummyControl::New( true );
+ DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ PanGesture pan;
+ DALI_TEST_EQUALS( false, dummyImpl.OnAccessibilityPan( pan ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplOnAccessibilityTouchP(void)
+{
+ ToolkitTestApplication application;
+ DummyControl dummy = DummyControl::New( true );
+ DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+ TouchEvent touch;
+ DALI_TEST_EQUALS( false, dummyImpl.OnAccessibilityTouch( touch ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliControlImplGetNextKeyboardFocusableActorP(void)
+{
+ ToolkitTestApplication application;
+ DummyControl dummy = DummyControl::New( true );
+ DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
+
+ Actor currentFocusedActor;
+ Actor result = dummyImpl.GetNextKeyboardFocusableActor( currentFocusedActor, Control::Left, false );
+
+ DALI_TEST_EQUALS( result, currentFocusedActor, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+
+
END_TEST;
}
-int UtcDaliToolBarSetBackground(void)
-{
- ToolkitTestApplication application;
- tet_infoline(" UtcDaliToolBarSetBackground");
-
- try
- {
- ImageActor toolBarBackground = CreateSolidColorActor( Color::RED );
-
- ToolBar toolbar = ToolBar::New();
- toolbar.SetBackground( toolBarBackground );
-
- Stage::GetCurrent().Add( toolbar );
- }
- catch( ... )
- {
- tet_result(TET_FAIL);
- }
-
- tet_result(TET_PASS);
-
- application.SendNotification(); // VCC To be removed!!
- application.Render(); // VCC To be removed!!
- END_TEST;
-}
-
int UtcDaliToolBarAddControl01(void)
{
ToolkitTestApplication application;
return Control::DownCast<ToolBar, Internal::ToolBar>(handle);
}
-void ToolBar::SetBackground( Actor background )
-{
- GetImpl( *this ).SetBackground( background );
-}
-
void ToolBar::AddControl( Actor control, float relativeSize, Toolkit::Alignment::Type alignment, const Toolkit::Alignment::Padding& padding )
{
GetImpl( *this ).AddControl( control, relativeSize, alignment, padding );
static ToolBar DownCast( BaseHandle handle );
/**
- * Sets a background image.
- * @param background Actor with the tool bar background.
- */
- void SetBackground( Actor background );
-
- /**
* Adds an additional control to the tool bar.
* @pre The tool bar needs to be initialized.
* @pre The alignment needs to be horizontal.
SetupProperties();
}
-void BloomView::OnControlSizeSet(const Vector3& targetSize)
+void BloomView::OnSizeSet(const Vector3& targetSize)
{
mTargetSize = Vector2(targetSize);
mChildrenRoot.SetSize(targetSize);
taskList.RemoveTask(mCompositeTask);
}
-void BloomView::OnStageDisconnection()
-{
- // TODO: can't call this here, since SetImage() calls fails similarly to above
- // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate()
- //Deactivate();
-}
-
-void BloomView::OnControlStageConnection()
-{
- // TODO: can't call this here, since SetImage() calls fail to connect images to stage, since parent chain not fully on stage yet
- // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate()
- //Activate();
-}
-
void BloomView::Activate()
{
// make sure resources are allocated and start the render tasks processing
private:
virtual void OnInitialize();
- virtual void OnControlSizeSet(const Vector3& targetSize);
- virtual void OnStageDisconnection();
-
- virtual void OnControlStageConnection();
+ virtual void OnSizeSet(const Vector3& targetSize);
void AllocateResources();
void CreateRenderTasks();
StopTransitionAnimation();
}
-void PushButton::OnControlSizeSet( const Vector3& targetSize )
+void PushButton::OnSizeSet( const Vector3& targetSize )
{
if( targetSize != mSize )
{
private: // From Control
/**
- * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+ * @copydoc CustomActorImpl::OnSizeSet( const Vector3& targetSize )
*/
- virtual void OnControlSizeSet( const Vector3& targetSize );
+ virtual void OnSizeSet( const Vector3& targetSize );
/**
* @copydoc Toolkit::Control::GetNaturalSize
*/
- Vector3 GetNaturalSize();
+ virtual Vector3 GetNaturalSize();
/**
* @copydoc Toolkit::Control::OnSetResizePolicy
SetupProperties();
}
-void EffectsView::OnControlSizeSet(const Vector3& targetSize)
+void EffectsView::OnSizeSet(const Vector3& targetSize)
{
mTargetSize = Vector2(targetSize);
virtual void OnInitialize();
/**
- * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+ * @copydoc CustomActorImpl::OnSizeSet( const Vector3& targetSize )
*/
- virtual void OnControlSizeSet( const Vector3& targetSize );
+ virtual void OnSizeSet( const Vector3& targetSize );
private:
float mScale;
};
-void GaussianBlurView::OnControlSizeSet(const Vector3& targetSize)
+void GaussianBlurView::OnSizeSet(const Vector3& targetSize)
{
mTargetSize = Vector2(targetSize);
taskList.RemoveTask(mCompositeTask);
}
-void GaussianBlurView::OnStageDisconnection()
-{
- // TODO: can't call this here, since SetImage() calls fails similarly to above
- // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate()
- //Deactivate();
-}
-
-void GaussianBlurView::OnControlStageConnection()
-{
- // TODO: can't call this here, since SetImage() calls fail to connect images to stage, since parent chain not fully on stage yet
- // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate()
- //Activate();
-}
-
void GaussianBlurView::Activate()
{
// make sure resources are allocated and start the render tasks processing
private:
virtual void OnInitialize();
- virtual void OnControlSizeSet(const Vector3& targetSize);
- virtual void OnStageDisconnection();
-
- virtual void OnControlStageConnection();
+ virtual void OnSizeSet(const Vector3& targetSize);
void SetBlurBellCurveWidth(float blurBellCurveWidth);
float CalcGaussianWeight(float x);
}
}
-void Magnifier::OnControlSizeSet(const Vector3& targetSize)
+void Magnifier::OnSizeSet(const Vector3& targetSize)
{
// TODO: Once Camera/CameraActor properties function as proper animatable properties
// this code can disappear.
private:
- virtual void OnControlSizeSet(const Vector3& targetSize);
+ virtual void OnSizeSet(const Vector3& targetSize);
private:
mShadowView.Activate();
}
-void PageTurnView::OnControlStageConnection()
+void PageTurnView::OnStageConnection()
{
SetupShadowView();
mTurningPageLayer.RaiseToTop();
}
-void PageTurnView::OnControlStageDisconnection()
+void PageTurnView::OnStageDisconnection()
{
if(mShadowView)
{
}
}
-void PageTurnView::OnControlSizeSet( const Vector3& size )
-{
-}
-
void PageTurnView::SetSpineShadowParameter( const Vector2& spineShadowParameter )
{
mSpineShadowParameter = spineShadowParameter;
virtual void OnInitialize();
/**
- * @copydoc Toolkit::Control::OnControlStageConncection
+ * @copydoc CustomActorImpl::OnStageConnection()
*/
- virtual void OnControlStageConnection();
+ virtual void OnStageConnection();
/**
- * @copydoc Toolkit::Control::OnControlStageDisConnection
+ * @copydoc CustomActorImpl::OnStageDisconnection()
*/
- virtual void OnControlStageDisconnection();
-
- /**
- * @copydoc Toolkit::Control::OnControlSizeSet
- */
- virtual void OnControlSizeSet( const Vector3& size );
+ virtual void OnStageDisconnection();
private: // implemented differently by PageTurnLandscapeView and PageTurnPortraitView
}
}
-void ScrollBar::OnControlSizeSet( const Vector3& size )
+void ScrollBar::OnSizeSet( const Vector3& size )
{
if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
{
virtual void OnInitialize();
/**
- * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& size )
+ * @copydoc CustomActorImpl::OnSizeSet( const Vector3& size )
*/
- virtual void OnControlSizeSet( const Vector3& size );
+ virtual void OnSizeSet( const Vector3& size );
private:
SetInternalConstraints();
}
-void ScrollView::OnControlStageConnection()
+void ScrollView::OnStageConnection()
{
DALI_LOG_SCROLL_STATE("[0x%X]", this);
}
}
-void ScrollView::OnControlStageDisconnection()
+void ScrollView::OnStageDisconnection()
{
DALI_LOG_SCROLL_STATE("[0x%X]", this);
UpdatePropertyDomain();
}
-void ScrollView::OnControlSizeSet( const Vector3& size )
+void ScrollView::OnSizeSet( const Vector3& size )
{
// need to update domain properties for new size
if( mDefaultMaxOvershoot )
virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
/**
- * @copydoc Dali::Control::OnControlSizeSet(const Vector3&)
+ * @copydoc CustomActorImpl::OnSizeSet(const Vector3&)
*/
- virtual void OnControlSizeSet( const Vector3& size );
+ virtual void OnSizeSet( const Vector3& size );
/**
* From CustomActorImpl; called after a child has been added to the owning actor.
virtual void OnInitialize();
/**
- * @copydoc Toolkit::Control::OnControlStageConnection()
+ * @copydoc CustomActorImpl::OnStageConnection()
*/
- virtual void OnControlStageConnection();
+ virtual void OnStageConnection();
/**
- * @copydoc Toolkit::Control::OnControlStageConnection()
+ * @copydoc CustomActorImpl::OnStageDisconnection()
*/
- virtual void OnControlStageDisconnection();
+ virtual void OnStageDisconnection();
/**
* @copydoc Toolkit::Control::OnAccessibilityPan()
self.SetSize( DEFAULT_HIT_REGION.x, DEFAULT_HIT_REGION.y );
}
-void Slider::OnControlSizeSet( const Vector3& size )
+void Slider::OnSizeSet( const Vector3& size )
{
// Factor in handle overshoot into size of backing
SetHitRegion( Vector2( size.x, GetHitRegion().y ) );
virtual ~Slider();
/**
- * @copydoc Control::OnControlSizeSet( const Vector3& size )
+ * @copydoc CustomActorImpl::OnSizeSet( const Vector3& size )
*/
- virtual void OnControlSizeSet( const Vector3& size );
+ virtual void OnSizeSet( const Vector3& size );
private:
}
}
-void SuperBlurView::OnControlSizeSet( const Vector3& targetSize )
+void SuperBlurView::OnSizeSet( const Vector3& targetSize )
{
if( mTargetSize != Vector2(targetSize) )
{
virtual void OnInitialize();
/**
- * @copydoc Toolkit::Control::OnControlSizeSet
+ * @copydoc CustomActorImpl::OnSizeSet()
*/
- virtual void OnControlSizeSet(const Vector3& targetSize);
+ virtual void OnSizeSet(const Vector3& targetSize);
private:
return toolBar;
}
-void ToolBar::SetBackground( Actor background )
-{
- Lock lock( mInitializing );
-
- // ToolBar image
- background.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
- background.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
- background.SetSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
-
- RenderableActor renderableActor = RenderableActor::DownCast( background );
- if ( renderableActor )
- {
- renderableActor.SetSortModifier( 1.f );
- }
-
- Self().Add( background );
- mBackground = background;
-}
-
void ToolBar::AddControl( Actor control, float relativeSize, Toolkit::Alignment::Type alignment, const Toolkit::Alignment::Padding& padding )
{
// Work out index and update bases and offsets for further insertions.
// actor is in mLayout not in Self().
}
-void ToolBar::OnControlSizeSet( const Vector3& targetSize )
-{
- mToolBarSize = targetSize;
- mBackground.SetSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
-}
-
} // namespace Internal
} // namespace Toolkit
static Toolkit::ToolBar New();
/**
- * @copydoc Dali::Toolkit::ToolBar::SetBackground()
- */
- void SetBackground( Actor background );
-
- /**
* @copydoc Dali::Toolkit::ToolBar::AddControl()
*/
void AddControl( Dali::Actor control, float relativeSize, Toolkit::Alignment::Type alignment, const Toolkit::Alignment::Padding& padding );
*/
virtual void OnControlChildAdd(Actor& child);
- /**
- *
- * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
- */
- virtual void OnControlSizeSet( const Vector3& targetSize );
-
private:
/**
*/
float mRightRelativeSpace; ///< Relative space between center and right groups of controls.
float mAccumulatedRelativeSpace; ///< Stores the total percentage space used by controls.
bool mInitializing; ///< Allows the use of Actor's API to add controls.
- Vector3 mToolBarSize; ///< The size of tool bar
- Actor mBackground; ///< The background of the tool bar
std::map<Actor/*control*/,Toolkit::Alignment> mControls; ///< Stores a relationship between controls and their alignments used to place them inside the table view.
};
if(control)
{
// Notify the control that it is activated
- GetImplementation( control ).Activate();
+ GetImplementation( control ).AccessibilityActivate();
}
// Send notification for the activation of focused actor
if(control)
{
// Notify the control that it is activated
- GetImplementation( control ).Activate();
+ GetImplementation( control ).AccessibilityActivate();
}
// Send notification for the activation of focused actor
const float BACKGROUND_ACTOR_Z_POSITION( -0.1f );
+/**
+ * Creates control through type registry
+ */
BaseHandle Create()
{
return Internal::Control::New();
}
+/**
+ * Performs actions as requested using the action name.
+ * @param[in] object The object on which to perform the action.
+ * @param[in] actionName The action to perform.
+ * @param[in] attributes The attributes with which to perfrom this action.
+ * @return true if action has been accepted by this control
+ */
+const char* ACTION_CONTROL_ACTIVATED = "control-activated";
+static bool DoAction( BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes )
+{
+ bool ret = false;
+
+ if( object && ( 0 == strcmp( actionName.c_str(), ACTION_CONTROL_ACTIVATED ) ) )
+ {
+ Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
+ if( control )
+ {
+ // if cast succeeds there is an implementation so no need to check
+ Internal::GetImplementation( control ).OnAccessibilityActivated();
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+ */
+const char* SIGNAL_KEY_EVENT = "key-event";
+const char* SIGNAL_KEY_INPUT_FOCUS_GAINED = "key-input-focus-gained";
+const char* SIGNAL_KEY_INPUT_FOCUS_LOST = "key-input-focus-lost";
+const char* SIGNAL_TAPPED = "tapped";
+const char* SIGNAL_PANNED = "panned";
+const char* SIGNAL_PINCHED = "pinched";
+const char* SIGNAL_LONG_PRESSED = "long-pressed";
+static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+ Dali::BaseHandle handle( object );
+
+ bool connected( false );
+ Toolkit::Control control = Toolkit::Control::DownCast( handle );
+ if ( control )
+ {
+ Internal::Control& controlImpl( Internal::GetImplementation( control ) );
+ connected = true;
+
+ if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
+ {
+ controlImpl.KeyEventSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
+ {
+ controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
+ {
+ controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
+ {
+ controlImpl.EnableGestureDetection( Gesture::Tap );
+ controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
+ {
+ controlImpl.EnableGestureDetection( Gesture::Pan );
+ controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
+ {
+ controlImpl.EnableGestureDetection( Gesture::Pinch );
+ controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
+ }
+ else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
+ {
+ controlImpl.EnableGestureDetection( Gesture::LongPress );
+ controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+ }
+ return connected;
+}
+
// Setup signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Control, CustomActor, Create );
// Note: Properties are registered separately below.
-DALI_SIGNAL_REGISTRATION( Toolkit, Control, "key-event", SIGNAL_KEY_EVENT )
-DALI_SIGNAL_REGISTRATION( Toolkit, Control, "key-input-focus-gained", SIGNAL_KEY_INPUT_FOCUS_GAINED )
-DALI_SIGNAL_REGISTRATION( Toolkit, Control, "key-input-focus-lost", SIGNAL_KEY_INPUT_FOCUS_LOST )
-DALI_SIGNAL_REGISTRATION( Toolkit, Control, "tapped", SIGNAL_TAPPED )
-DALI_SIGNAL_REGISTRATION( Toolkit, Control, "panned", SIGNAL_PANNED )
-DALI_SIGNAL_REGISTRATION( Toolkit, Control, "pinched", SIGNAL_PINCHED )
-DALI_SIGNAL_REGISTRATION( Toolkit, Control, "long-pressed", SIGNAL_LONG_PRESSED )
+SignalConnectorType registerSignal1( typeRegistration, SIGNAL_KEY_EVENT, &DoConnectSignal );
+SignalConnectorType registerSignal2( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_GAINED, &DoConnectSignal );
+SignalConnectorType registerSignal3( typeRegistration, SIGNAL_KEY_INPUT_FOCUS_LOST, &DoConnectSignal );
+SignalConnectorType registerSignal4( typeRegistration, SIGNAL_TAPPED, &DoConnectSignal );
+SignalConnectorType registerSignal5( typeRegistration, SIGNAL_PANNED, &DoConnectSignal );
+SignalConnectorType registerSignal6( typeRegistration, SIGNAL_PINCHED, &DoConnectSignal );
+SignalConnectorType registerSignal7( typeRegistration, SIGNAL_LONG_PRESSED, &DoConnectSignal );
-DALI_ACTION_REGISTRATION( Toolkit, Control, "control-activated", ACTION_CONTROL_ACTIVATED )
+TypeAction registerAction( typeRegistration, ACTION_CONTROL_ACTIVATED, &DoAction );
DALI_TYPE_REGISTRATION_END()
delete mImpl;
}
-void Control::SetKeyInputFocus()
-{
- if( Self().OnStage() )
- {
- Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
- }
-}
-
-bool Control::HasKeyInputFocus()
-{
- bool result = false;
- if( Self().OnStage() )
- {
- result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
- }
- return result;
-}
-
-void Control::ClearKeyInputFocus()
-{
- if( Self().OnStage() )
- {
- Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
- }
-}
-
-PinchGestureDetector Control::GetPinchGestureDetector() const
-{
- return mImpl->mPinchGestureDetector;
-}
-
-PanGestureDetector Control::GetPanGestureDetector() const
-{
- return mImpl->mPanGestureDetector;
-}
-
-TapGestureDetector Control::GetTapGestureDetector() const
-{
- return mImpl->mTapGestureDetector;
-}
-
-LongPressGestureDetector Control::GetLongPressGestureDetector() const
-{
- return mImpl->mLongPressGestureDetector;
-}
-
void Control::SetStyleName( const std::string& styleName )
{
if( styleName != mImpl->mStyleName )
}
}
-void Control::SetKeyboardNavigationSupport(bool isSupported)
+void Control::EnableGestureDetection(Gesture::Type type)
{
- mImpl->mIsKeyboardNavigationSupported = isSupported;
+ if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
+ {
+ mImpl->mPinchGestureDetector = PinchGestureDetector::New();
+ mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
+ mImpl->mPinchGestureDetector.Attach(Self());
+ }
+
+ if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
+ {
+ mImpl->mPanGestureDetector = PanGestureDetector::New();
+ mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
+ mImpl->mPanGestureDetector.Attach(Self());
+ }
+
+ if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
+ {
+ mImpl->mTapGestureDetector = TapGestureDetector::New();
+ mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
+ mImpl->mTapGestureDetector.Attach(Self());
+ }
+
+ if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
+ {
+ mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
+ mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
+ mImpl->mLongPressGestureDetector.Attach(Self());
+ }
}
-bool Control::IsKeyboardNavigationSupported()
+void Control::DisableGestureDetection(Gesture::Type type)
{
- return mImpl->mIsKeyboardNavigationSupported;
+ if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
+ {
+ mImpl->mPinchGestureDetector.Detach(Self());
+ mImpl->mPinchGestureDetector.Reset();
+ }
+
+ if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
+ {
+ mImpl->mPanGestureDetector.Detach(Self());
+ mImpl->mPanGestureDetector.Reset();
+ }
+
+ if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
+ {
+ mImpl->mTapGestureDetector.Detach(Self());
+ mImpl->mTapGestureDetector.Reset();
+ }
+
+ if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
+ {
+ mImpl->mLongPressGestureDetector.Detach(Self());
+ mImpl->mLongPressGestureDetector.Reset();
+ }
}
-void Control::Activate()
+PinchGestureDetector Control::GetPinchGestureDetector() const
{
- // Inform deriving classes
- OnAccessibilityActivated();
+ return mImpl->mPinchGestureDetector;
}
-void Control::OnAccessibilityActivated()
+PanGestureDetector Control::GetPanGestureDetector() const
{
+ return mImpl->mPanGestureDetector;
}
-bool Control::OnAccessibilityPan(PanGesture gesture)
+TapGestureDetector Control::GetTapGestureDetector() const
{
- return false; // Accessibility pan gesture is not handled by default
+ return mImpl->mTapGestureDetector;
}
-bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
+LongPressGestureDetector Control::GetLongPressGestureDetector() const
{
- return false; // Accessibility touch event is not handled by default
+ return mImpl->mLongPressGestureDetector;
}
-bool Control::OnAccessibilityValueChange(bool isIncrease)
+void Control::SetKeyboardNavigationSupport(bool isSupported)
{
- return false; // Accessibility value change action is not handled by default
+ mImpl->mIsKeyboardNavigationSupported = isSupported;
+}
+
+bool Control::IsKeyboardNavigationSupported()
+{
+ return mImpl->mIsKeyboardNavigationSupported;
+}
+
+void Control::SetKeyInputFocus()
+{
+ if( Self().OnStage() )
+ {
+ Toolkit::KeyInputFocusManager::Get().SetFocus(Toolkit::Control::DownCast(Self()));
+ }
+}
+
+bool Control::HasKeyInputFocus()
+{
+ bool result = false;
+ if( Self().OnStage() )
+ {
+ result = Toolkit::KeyInputFocusManager::Get().IsKeyboardListener(Toolkit::Control::DownCast(Self()));
+ }
+ return result;
+}
+
+void Control::ClearKeyInputFocus()
+{
+ if( Self().OnStage() )
+ {
+ Toolkit::KeyInputFocusManager::Get().RemoveFocus(Toolkit::Control::DownCast(Self()));
+ }
}
void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
return Toolkit::KeyboardFocusManager::Get().IsFocusGroup(Self());
}
-Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled)
+void Control::AccessibilityActivate()
{
- return Actor();
+ // Inform deriving classes
+ OnAccessibilityActivated();
}
-void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
+void Control::OnAccessibilityActivated()
{
}
-bool Control::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
+bool Control::OnAccessibilityPan(PanGesture gesture)
{
- bool ret = false;
-
- if( object && ( 0 == strcmp( actionName.c_str(), ACTION_CONTROL_ACTIVATED ) ) )
- {
- Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
- if( control )
- {
- // if cast succeeds there is an implementation so no need to check
- GetImplementation( control ).OnAccessibilityActivated();
- }
- }
+ return false; // Accessibility pan gesture is not handled by default
+}
- return ret;
+bool Control::OnAccessibilityTouch(const TouchEvent& touchEvent)
+{
+ return false; // Accessibility touch event is not handled by default
}
-bool Control::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+bool Control::OnAccessibilityValueChange(bool isIncrease)
{
- Dali::BaseHandle handle( object );
+ return false; // Accessibility value change action is not handled by default
+}
- bool connected( false );
- Toolkit::Control control = Toolkit::Control::DownCast( handle );
- if ( control )
- {
- Control& controlImpl( GetImplementation( control ) );
- connected = true;
+Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled)
+{
+ return Actor();
+}
- if ( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
- {
- controlImpl.KeyEventSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_GAINED ) )
- {
- controlImpl.KeyInputFocusGainedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_INPUT_FOCUS_LOST ) )
- {
- controlImpl.KeyInputFocusLostSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_TAPPED ) )
- {
- controlImpl.EnableGestureDetection( Gesture::Tap );
- controlImpl.GetTapGestureDetector().DetectedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_PANNED ) )
- {
- controlImpl.EnableGestureDetection( Gesture::Pan );
- controlImpl.GetPanGestureDetector().DetectedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_PINCHED ) )
- {
- controlImpl.EnableGestureDetection( Gesture::Pinch );
- controlImpl.GetPinchGestureDetector().DetectedSignal().Connect( tracker, functor );
- }
- else if( 0 == strcmp( signalName.c_str(), SIGNAL_LONG_PRESSED ) )
- {
- controlImpl.EnableGestureDetection( Gesture::LongPress );
- controlImpl.GetLongPressGestureDetector().DetectedSignal().Connect( tracker, functor );
- }
- else
- {
- // signalName does not match any signal
- connected = false;
- }
- }
- return connected;
+void Control::OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor)
+{
}
Toolkit::Control::KeyEventSignalType& Control::KeyEventSignal()
OnInitialize();
}
-void Control::EnableGestureDetection(Gesture::Type type)
-{
- if ( (type & Gesture::Pinch) && !mImpl->mPinchGestureDetector )
- {
- mImpl->mPinchGestureDetector = PinchGestureDetector::New();
- mImpl->mPinchGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PinchDetected);
- mImpl->mPinchGestureDetector.Attach(Self());
- }
-
- if ( (type & Gesture::Pan) && !mImpl->mPanGestureDetector )
- {
- mImpl->mPanGestureDetector = PanGestureDetector::New();
- mImpl->mPanGestureDetector.DetectedSignal().Connect(mImpl, &Impl::PanDetected);
- mImpl->mPanGestureDetector.Attach(Self());
- }
-
- if ( (type & Gesture::Tap) && !mImpl->mTapGestureDetector )
- {
- mImpl->mTapGestureDetector = TapGestureDetector::New();
- mImpl->mTapGestureDetector.DetectedSignal().Connect(mImpl, &Impl::TapDetected);
- mImpl->mTapGestureDetector.Attach(Self());
- }
-
- if ( (type & Gesture::LongPress) && !mImpl->mLongPressGestureDetector )
- {
- mImpl->mLongPressGestureDetector = LongPressGestureDetector::New();
- mImpl->mLongPressGestureDetector.DetectedSignal().Connect(mImpl, &Impl::LongPressDetected);
- mImpl->mLongPressGestureDetector.Attach(Self());
- }
-}
-
-void Control::DisableGestureDetection(Gesture::Type type)
-{
- if ( (type & Gesture::Pinch) && mImpl->mPinchGestureDetector )
- {
- mImpl->mPinchGestureDetector.Detach(Self());
- mImpl->mPinchGestureDetector.Reset();
- }
-
- if ( (type & Gesture::Pan) && mImpl->mPanGestureDetector )
- {
- mImpl->mPanGestureDetector.Detach(Self());
- mImpl->mPanGestureDetector.Reset();
- }
-
- if ( (type & Gesture::Tap) && mImpl->mTapGestureDetector )
- {
- mImpl->mTapGestureDetector.Detach(Self());
- mImpl->mTapGestureDetector.Reset();
- }
-
- if ( (type & Gesture::LongPress) && mImpl->mLongPressGestureDetector)
- {
- mImpl->mLongPressGestureDetector.Detach(Self());
- mImpl->mLongPressGestureDetector.Reset();
- }
-}
-
void Control::OnInitialize()
{
}
-void Control::OnControlStageConnection()
-{
-}
-
-void Control::OnControlStageDisconnection()
-{
-}
-
void Control::OnControlChildAdd( Actor& child )
{
}
{
}
-void Control::OnControlSizeSet( const Vector3& size )
-{
-}
-
void Control::EmitKeyInputFocusSignal( bool focusGained )
{
Dali::Toolkit::Control handle( GetOwner() );
}
}
-void Control::OnKeyInputFocusGained()
+void Control::OnStageConnection()
{
- EmitKeyInputFocusSignal( true );
}
-void Control::OnKeyInputFocusLost()
+void Control::OnStageDisconnection()
{
- EmitKeyInputFocusSignal( false );
}
-void Control::OnStageConnection()
+void Control::OnKeyInputFocusGained()
{
- // Notify derived classes.
- OnControlStageConnection();
+ EmitKeyInputFocusSignal( true );
}
-void Control::OnStageDisconnection()
+void Control::OnKeyInputFocusLost()
{
- // Notify derived classes
- OnControlStageDisconnection();
+ EmitKeyInputFocusSignal( false );
}
void Control::OnChildAdd(Actor& child)
void Control::OnSizeSet(const Vector3& targetSize)
{
// Background is resized through size negotiation
-
- // Notify derived classes.
- OnControlSizeSet( targetSize );
}
void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
*/
virtual ~Control();
- // Key Input
+ // Styling
/**
- * @copydoc Toolkit::Control::SetKeyInputFocus()
+ * @copydoc Dali::Toolkit::Control::SetStyleName
*/
- void SetKeyInputFocus();
+ void SetStyleName( const std::string& styleName );
/**
- * @copydoc Toolkit::Control::HasKeyInputFocus()
+ * @copydoc Dali::Toolkit::Control::GetStyleName
*/
- bool HasKeyInputFocus();
+ const std::string& GetStyleName() const;
+
+ // Background
/**
- * @copydoc Toolkit::Control::ClearKeyInputFocus()
+ * @copydoc Dali::Toolkit::Control::SetBackgroundColor
*/
- void ClearKeyInputFocus();
+ void SetBackgroundColor( const Vector4& color );
+
+ /**
+ * @copydoc Dali::Toolkit::Control::GetBackgroundColor
+ */
+ Vector4 GetBackgroundColor() const;
+
+ /**
+ * @copydoc Dali::Toolkit::Control::SetBackgroundImage
+ */
+ void SetBackgroundImage( Image image );
+
+ /**
+ * @copydoc Dali::Toolkit::Control::ClearBackground
+ */
+ void ClearBackground();
// Gesture Detection
/**
+ * @brief Allows deriving classes to enable any of the gesture detectors that are available.
+ *
+ * Gesture detection can be enabled one at a time or in bitwise format as shown:
+ * @code
+ * EnableGestureDetection(Gesture::Type(Gesture::Pinch | Gesture::Tap | Gesture::Pan));
+ * @endcode
+ * @param[in] type The gesture type(s) to enable.
+ */
+ void EnableGestureDetection( Gesture::Type type );
+
+ /**
+ * @brief Allows deriving classes to disable any of the gesture detectors.
+ *
+ * Like EnableGestureDetection, this can also be called using bitwise or.
+ * @param[in] type The gesture type(s) to disable.
+ * @see EnableGetureDetection
+ */
+ void DisableGestureDetection( Gesture::Type type );
+
+ /**
* @brief If deriving classes wish to fine tune pinch gesture
* detection then they can access the gesture detector through this
* API and modify the detection.
*/
LongPressGestureDetector GetLongPressGestureDetector() const;
- // Styling
-
- /**
- * @copydoc Dali::Toolkit::Control::SetStyleName
- */
- void SetStyleName( const std::string& styleName );
-
- /**
- * @copydoc Dali::Toolkit::Control::GetStyleName
- */
- const std::string& GetStyleName() const;
-
- // Background
-
- /**
- * @copydoc Dali::Toolkit::Control::SetBackgroundColor
- */
- void SetBackgroundColor( const Vector4& color );
-
- /**
- * @copydoc Dali::Toolkit::Control::GetBackgroundColor
- */
- Vector4 GetBackgroundColor() const;
-
- /**
- * @copydoc Dali::Toolkit::Control::SetBackgroundImage
- */
- void SetBackgroundImage( Image image );
-
- /**
- * @copydoc Dali::Toolkit::Control::ClearBackground
- */
- void ClearBackground();
-
// Keyboard Navigation
/**
* The control doesn't support it by default.
* @param[in] isSupported Whether this control supports two dimensional keyboard navigation.
*/
- void SetKeyboardNavigationSupport(bool isSupported);
+ void SetKeyboardNavigationSupport( bool isSupported );
/**
* @brief Gets whether this control supports two dimensional keyboard navigation.
*/
bool IsKeyboardNavigationSupported();
- // Called by Focus Managers
+ // Key Input
/**
- * @brief Called by the focus manager and keyboard focus manager to Activate the Control
+ * @copydoc Toolkit::Control::SetKeyInputFocus()
+ */
+ void SetKeyInputFocus();
+
+ /**
+ * @copydoc Toolkit::Control::HasKeyInputFocus()
+ */
+ bool HasKeyInputFocus();
+
+ /**
+ * @copydoc Toolkit::Control::ClearKeyInputFocus()
*/
- DALI_INTERNAL void Activate();
+ void ClearKeyInputFocus();
// Keyboard Focus
* can be limitied to its child actors). The control is not a focus group by default.
* @param[in] isFocusGroup Whether this control is set as a focus group for keyboard navigation.
*/
- void SetAsKeyboardFocusGroup(bool isFocusGroup);
+ void SetAsKeyboardFocusGroup( bool isFocusGroup );
/**
* @brief Gets whether this control is a focus group for keyboard navigation.
*/
bool IsKeyboardFocusGroup();
- /**
- * @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal
- *
- * Should be called last by the control after it acts on the Input Focus change.
- *
- * @param[in] focusGained True if gained, False if lost
- */
- void EmitKeyInputFocusSignal( bool focusGained );
-
- // Actions & Signals
+ // Called by Focus Manager
/**
- * @brief Performs actions as requested using the action name.
- *
- * @param[in] object The object on which to perform the action.
- * @param[in] actionName The action to perform.
- * @param[in] attributes The attributes with which to perfrom this action.
- * @return true if action has been accepted by this control
+ * @brief Called by the focus manager and keyboard focus manager to Activate the Control
*/
- static bool DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes);
+ DALI_INTERNAL void AccessibilityActivate();
- /**
- * Connects a callback function with the object's signals.
- * @param[in] object The object providing the signal.
- * @param[in] tracker Used to disconnect the signal.
- * @param[in] signalName The signal to connect to.
- * @param[in] functor A newly allocated FunctorDelegate.
- * @return True if the signal was connected.
- * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
- */
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ // Signals
/**
* @copydoc Dali::Toolkit::Control::KeyEventSignal()
* @param[in] event The key event.
* @return True if the event was consumed.
*/
- DALI_INTERNAL bool EmitKeyEventSignal(const KeyEvent& event);
+ DALI_INTERNAL bool EmitKeyEventSignal( const KeyEvent& event );
+
+protected: // For derived classes to call
+
+ /**
+ * @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal
+ *
+ * Should be called last by the control after it acts on the Input Focus change.
+ *
+ * @param[in] focusGained True if gained, False if lost
+ */
+ void EmitKeyInputFocusSignal( bool focusGained );
protected: // From CustomActorImpl, not to be used by application developers
/**
* @copydoc CustomActorImpl::OnChildAdd()
*/
- virtual void OnChildAdd(Actor& child);
+ virtual void OnChildAdd( Actor& child );
/**
* @copydoc CustomActorImpl::OnChildRemove()
*/
- virtual void OnChildRemove(Actor& child);
+ virtual void OnChildRemove( Actor& child );
/**
* @copydoc CustomActorImpl::OnSizeSet()
*/
- virtual void OnSizeSet(const Vector3& targetSize);
+ virtual void OnSizeSet( const Vector3& targetSize );
/**
* @copydoc CustomActorImpl::OnSizeAnimation()
*/
- virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
+ virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize );
/**
* @copydoc CustomActorImpl::OnTouchEvent()
*/
- virtual bool OnTouchEvent(const TouchEvent& event);
+ virtual bool OnTouchEvent( const TouchEvent& event );
/**
* @copydoc CustomActorImpl::OnHoverEvent()
*/
- virtual bool OnHoverEvent(const HoverEvent& event);
+ virtual bool OnHoverEvent( const HoverEvent& event );
/**
* @copydoc CustomActorImpl::OnKeyEvent()
*/
- virtual bool OnKeyEvent(const KeyEvent& event);
+ virtual bool OnKeyEvent( const KeyEvent& event );
/**
* @copydoc CustomActorImpl::OnMouseWheelEvent()
*/
- virtual bool OnMouseWheelEvent(const MouseWheelEvent& event);
+ virtual bool OnMouseWheelEvent( const MouseWheelEvent& event );
/**
* @copydoc CustomActorImpl::OnRelayout()
*/
void Initialize();
- // Gesture Detection
-
- /**
- * @brief Allows deriving classes to enable any of the gesture detectors that are available.
- *
- * Gesture detection can be enabled one at a time or in bitwise format as shown:
- * @code
- * EnableGestureDetection(Gesture::Type(Gesture::Pinch | Gesture::Tap | Gesture::Pan));
- * @endcode
- * @param[in] type The gesture type(s) to enable.
- */
- void EnableGestureDetection( Gesture::Type type );
-
- /**
- * @brief Allows deriving classes to disable any of the gesture detectors.
- *
- * Like EnableGestureDetection, this can also be called using bitwise or.
- * @param[in] type The gesture type(s) to disable.
- * @see EnableGetureDetection
- */
- void DisableGestureDetection( Gesture::Type type );
-
public: // API for derived classes to override
// Lifecycle
virtual void OnInitialize();
/**
- * @brief Called whenever the control is added to the stage.
- *
- * Could be overridden by derived classes.
- */
- virtual void OnControlStageConnection();
-
- /**
- * @brief Called whenever the control is removed from the stage.
- *
- * Could be overridden by derived classes.
- */
- virtual void OnControlStageDisconnection();
-
- /**
* @brief Called whenever an Actor is added to the control.
*
* Could be overridden by derived classes.
*/
virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
- // Size negotiation
-
- /**
- * @brief Called whenever the Control's size is set.
- *
- * @param[in] size The new size.
- */
- virtual void OnControlSizeSet( const Vector3& size );
-
// Accessibility
/**
* @param[in] gesture The pan gesture.
* @return true if the pan gesture has been consumed by this control
*/
- virtual bool OnAccessibilityPan(PanGesture gesture);
+ virtual bool OnAccessibilityPan( PanGesture gesture );
/**
* @brief This method should be overridden by deriving classes when they wish to respond the accessibility
* @param[in] touchEvent The touch event.
* @return true if the touch event has been consumed by this control
*/
- virtual bool OnAccessibilityTouch(const TouchEvent& touchEvent);
+ virtual bool OnAccessibilityTouch( const TouchEvent& touchEvent );
/**
* @brief This method should be overridden by deriving classes when they wish to respond
* @param[in] isIncrease Whether the value should be increased or decreased
* @return true if the value changed action has been consumed by this control
*/
- virtual bool OnAccessibilityValueChange(bool isIncrease);
+ virtual bool OnAccessibilityValueChange( bool isIncrease );
// Keyboard focus
* @param[in] loopEnabled Whether the focus movement should be looped within the control.
* @return the next keyboard focusable actor in this control or an empty handle if no actor can be focused.
*/
- virtual Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
+ virtual Actor GetNextKeyboardFocusableActor( Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled );
/**
* @brief Informs this control that its chosen focusable actor will be focused.
*
* @param[in] commitedFocusableActor The commited focusable actor.
*/
- virtual void OnKeyboardFocusChangeCommitted(Actor commitedFocusableActor);
+ virtual void OnKeyboardFocusChangeCommitted( Actor commitedFocusableActor );
// Gestures
* @param[in] pinch The pinch gesture.
* @see EnableGestureDetection
*/
- virtual void OnPinch(const PinchGesture& pinch);
+ virtual void OnPinch( const PinchGesture& pinch );
/**
* @brief Called whenever a pan gesture is detected on this control.
private:
// Undefined
- DALI_INTERNAL Control(const Control&);
- DALI_INTERNAL Control& operator=(const Control&);
+ DALI_INTERNAL Control( const Control& );
+ DALI_INTERNAL Control& operator=( const Control& );
class Impl;
Impl* mImpl;