void KeyboardFocusManager::OnPhysicalKeyboardStatusChanged(PhysicalKeyboard keyboard) { mIsKeyboardFocusEnabled = keyboard.IsAttached(); if(mIsKeyboardFocusEnabled) { // Show indicator when keyboard focus turned on if there is focused actor. Actor actor = GetCurrentFocusActor(); if(actor) { if(mFocusIndicatorActor) { actor.Add(mFocusIndicatorActor); } } mIsFocusIndicatorEnabled = true; } else { // Hide indicator when keyboard focus turned off Actor actor = GetCurrentFocusActor(); if(actor) { actor.Remove(mFocusIndicatorActor); } mIsFocusIndicatorEnabled = false; } }
// signal handler, called when the pan gesture is detected void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture ) { // does not response when the animation has not finished if( mIsTransiting || mSlideshow ) { return; } if( gesture.state == Gesture::Continuing ) { if( gesture.displacement.x < 0) { mIndex = (mIndex + 1)%NUM_IMAGES; } else { mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES; } mNextImage = CreateStageFillingImageView( IMAGES[ mIndex ] ); mNextImage.SetParentOrigin( ParentOrigin::CENTER ); mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); mNextImage.SetZ(INITIAL_DEPTH); mParent.Add( mNextImage ); Vector2 size = Vector2( mCurrentImage.GetCurrentSize() ); StartTransition( gesture.position / size, gesture.displacement * Vector2(1.0, size.x/size.y)); } }
int UtcDaliHoverMultipleRenderableActors(void) { TestApplication application; Stage stage ( Stage::GetCurrent() ); Vector2 stageSize ( stage.GetSize() ); Actor parent = CreateRenderableActor(); parent.SetSize( 100.0f, 100.0f ); parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(parent); Actor actor = CreateRenderableActor(); actor.SetSize( 100.0f, 100.0f ); actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); parent.Add(actor); // Render and notify application.SendNotification(); application.Render(); // Connect to layer's hovered signal SignalData data; HoverEventFunctor functor( data ); parent.HoveredSignal().Connect( &application, functor ); actor.HoveredSignal().Connect( &application, functor ); // Emit a started signal application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); DALI_TEST_CHECK( actor == data.hoveredActor ); END_TEST; }
int UtcDaliTapGestureSignalReceptionChildHit(void) { TestApplication application; Actor parent = Actor::New(); parent.SetSize(100.0f, 100.0f); parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(parent); // Set child to completely cover parent. // Change rotation of child to be different from parent so that we can check if our local coordinate // conversion of the parent actor is correct. Actor child = Actor::New(); child.SetSize(100.0f, 100.0f); child.SetAnchorPoint(AnchorPoint::CENTER); child.SetParentOrigin(ParentOrigin::CENTER); child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS); parent.Add(child); TouchEventFunctor touchFunctor; child.TouchedSignal().Connect(&application, touchFunctor); // Render and notify application.SendNotification(); application.Render(); SignalData data; GestureReceivedFunctor functor(data); TapGestureDetector detector = TapGestureDetector::New(); detector.Attach(parent); detector.DetectedSignal().Connect(&application, functor); // Do tap - hits child area but parent should still receive it application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 50.0f))); application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 50.0f))); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, parent == data.tappedActor, TEST_LOCATION); DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); // Attach child and generate same touch points // (Also proves that you can detach and then re-attach another actor) detector.Attach(child); detector.Detach(parent); // Do an entire tap, only check finished value data.Reset(); application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(51.0f, 51.0f))); application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(51.0f, 51.0f))); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, child == data.tappedActor, TEST_LOCATION); DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION); END_TEST; }
void DissolveEffectApp::OnInit( Application& application ) { Stage::GetCurrent().KeyEventSignal().Connect(this, &DissolveEffectApp::OnKeyEvent); // Creates a default view with a default tool bar, the view is added to the stage. mContent = DemoHelper::CreateView( application, mView,mToolBar, "", TOOLBAR_IMAGE, "" ); // Add an effect-changing button on the right of the tool bar. mEffectChangeButton = Toolkit::PushButton::New(); mEffectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE ); mEffectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE_SELECTED ); mEffectChangeButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnEffectButtonClicked ); mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Add title to the tool bar. mTitleActor = DemoHelper::CreateToolBarLabel( APPLICATION_TITLE_HIGHP ); mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter ); // Add an slide-show button on the right of the title mPlayStopButton = Toolkit::PushButton::New(); mPlayStopButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, PLAY_ICON ); mPlayStopButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, PLAY_ICON_SELECTED ); mPlayStopButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnSildeshowButtonClicked ); mToolBar.AddControl( mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); // use pan gesture to detect the cursor or finger movement mPanGestureDetector = PanGestureDetector::New(); mPanGestureDetector.DetectedSignal().Connect( this, &DissolveEffectApp::OnPanGesture ); mViewTimer = Timer::New( VIEWINGTIME ); mViewTimer.TickSignal().Connect( this, &DissolveEffectApp::OnTimerTick ); mTimerReady = true; // Set size to stage size to avoid seeing a black border on transition mParent = Actor::New(); mParent.SetSize( Stage::GetCurrent().GetSize() ); mParent.SetParentOrigin( ParentOrigin::CENTER ); mContent.Add( mParent ); // show the first image mCurrentImage = CreateStageFillingImageView( IMAGES[mIndex] ); mCurrentImage.SetParentOrigin( ParentOrigin::CENTER ); mCurrentImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mCurrentImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); mParent.Add( mCurrentImage ); mPanGestureDetector.Attach( mCurrentImage ); mDissolveEffect = Dali::Toolkit::CreateDissolveEffect( mUseHighPrecision ); Property::Map emptyShaderMap; mEmptyEffect.Insert( "shader", emptyShaderMap ); }
void ImageView::Initialize() { Actor self = Self(); // Register property that represents the level of detail. mPropertyDetail = self.RegisterProperty(Toolkit::ImageView::DETAIL_PROPERTY_NAME, 0.0f); // Create an empty image actor, filling the entire size of this ImageView. Image emptyImage; mImageActor = ImageActor::New( emptyImage ); self.Add( mImageActor ); mImageActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); mImageActor.SetParentOrigin( ParentOrigin::CENTER ); }
int UtcDaliHoverMultipleRenderTasksWithChildLayer(void) { TestApplication application; Stage stage ( Stage::GetCurrent() ); Vector2 stageSize ( stage.GetSize() ); Actor actor = Actor::New(); actor.SetSize(100.0f, 100.0f); actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(actor); Layer layer = Layer::New(); layer.SetSize(100.0f, 100.0f); layer.SetAnchorPoint(AnchorPoint::TOP_LEFT); actor.Add(layer); // Create render task Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f ); RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() ); renderTask.SetViewport( viewport ); renderTask.SetInputEnabled( true ); renderTask.SetSourceActor( actor ); // Render and notify application.SendNotification(); application.Render(); // Connect to layer's hovered signal SignalData data; HoverEventFunctor functor( data ); actor.HoveredSignal().Connect( &application, functor ); layer.HoveredSignal().Connect( &application, functor ); // Emit a started signal application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Ensure renderTask actor can be hit too. application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION ); data.Reset(); // Disable input on renderTask, should not be hittable renderTask.SetInputEnabled( false ); application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) ); DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION ); data.Reset(); END_TEST; }
int UtcDaliImageActorDownCast(void) { TestApplication application; tet_infoline("Testing Dali::ImageActor::DownCast()"); Image image = Image::New("IncorrectImageName"); ImageActor actor1 = ImageActor::New(image); Actor anActor = Actor::New(); anActor.Add(actor1); Actor child = anActor.GetChildAt(0); ImageActor imageActor = DownCast< ImageActor >(child); DALI_TEST_CHECK(imageActor); END_TEST; }
int UtcDaliImageActorDownCast2(void) { TestApplication application; tet_infoline("Testing Dali::ImageActor::DownCast()"); Actor actor1 = Actor::New(); Actor anActor = Actor::New(); anActor.Add(actor1); Actor child = anActor.GetChildAt(0); ImageActor imageActor = ImageActor::DownCast(child); DALI_TEST_CHECK(!imageActor); Actor unInitialzedActor; imageActor = ImageActor::DownCast( unInitialzedActor ); DALI_TEST_CHECK(!imageActor); END_TEST; }
bool DissolveEffectApp::OnTimerTick() { mTimerReady = true; if(mSlideshow) { mIndex = (mIndex + 1)%NUM_IMAGES; mNextImage = CreateStageFillingImageView( IMAGES[ mIndex ] ); mNextImage.SetParentOrigin( ParentOrigin::CENTER ); mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); mNextImage.SetZ(INITIAL_DEPTH); mParent.Add( mNextImage ); switch( mCentralLineIndex%4 ) { case 0: { StartTransition(Vector2(1.0f,0.5f), Vector2(-1.0f, 0.0f)); break; } case 1: { StartTransition(Vector2(0.5f,0.0f), Vector2(0.0f, 1.0f)); break; } case 2: { StartTransition(Vector2(0.0f,0.5f), Vector2(1.0f, 0.0f)); break; } default: { StartTransition(Vector2(0.5f,1.0f), Vector2(0.0f, -1.0f)); break; } } mCentralLineIndex++; } return false; //return false to stop the timer }
void KeyboardFocusManager::SetFocusIndicatorActor(Actor indicator) { if(mFocusIndicatorActor != indicator) { Actor currentFocusActor = GetCurrentFocusActor(); if(currentFocusActor) { // The new focus indicator should be added to the current focused actor immediately if(mFocusIndicatorActor) { currentFocusActor.Remove(mFocusIndicatorActor); } if(indicator) { currentFocusActor.Add(indicator); } } mFocusIndicatorActor = indicator; } }
int UtcDaliTapGestureSignalReceptionMultipleGestureDetectors(void) { TestApplication application; Dali::TestGestureManager& gestureManager = application.GetGestureManager(); Actor first = Actor::New(); first.SetSize(100.0f, 100.0f); first.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(first); Actor second = Actor::New(); second.SetSize(100.0f, 100.0f); second.SetAnchorPoint(AnchorPoint::TOP_LEFT); second.SetX(100.0f); first.Add(second); // Render and notify application.SendNotification(); application.Render(); SignalData data; GestureReceivedFunctor functor(data); TapGestureDetector firstDetector = TapGestureDetector::New(); firstDetector.Attach(first); firstDetector.DetectedSignal().Connect(&application, functor); // secondDetector is scoped { // Reset gestureManager statistics gestureManager.Initialize(); TapGestureDetector secondDetector = TapGestureDetector::New( 2 ); secondDetector.Attach(second); secondDetector.DetectedSignal().Connect(&application, functor); DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); // Tap within second actor's area application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 1u, Vector2(150.0f, 10.0f))); application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 1u, Vector2(150.0f, 10.0f))); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, second == data.tappedActor, TEST_LOCATION); // Tap continues as single touch gesture - we should not receive any gesture data.Reset(); application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(150.0f, 10.0f))); application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(150.0f, 10.0f))); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); // Single touch tap starts - first actor should be panned data.Reset(); application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f))); application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f))); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, first == data.tappedActor, TEST_LOCATION); // Pan changes to double-touch - we shouldn't receive event data.Reset(); application.ProcessEvent(GenerateTap(Gesture::Possible, 2u, 2u, Vector2(50.0f, 10.0f))); application.ProcessEvent(GenerateTap(Gesture::Started, 2u, 2u, Vector2(50.0f, 10.0f))); DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); // Reset gesture manager statistics gestureManager.Initialize(); } // secondDetector has now been deleted. Gesture detection should have been updated only DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UpdateType), TEST_LOCATION); DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::RegisterType), TEST_LOCATION); DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION); END_TEST; }
int UtcDaliFocusManagerGetCurrentFocusGroup(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliFocusManagerGetCurrentFocusGroup"); FocusManager manager = FocusManager::Get(); DALI_TEST_CHECK(manager); // Create an actor with two child actors and add it to the stage Actor parent = Actor::New(); Actor firstChild = Actor::New(); Actor secondChild = Actor::New(); parent.Add(firstChild); parent.Add(secondChild); Stage::GetCurrent().Add(parent); // Create three actors and add them as the children of the first child actor Actor firstGrandChild = Actor::New(); Actor secondGrandChild = Actor::New(); Actor thirdGrandChild = Actor::New(); firstChild.Add(firstGrandChild); firstChild.Add(secondGrandChild); firstChild.Add(thirdGrandChild); // Set focus order to the actors manager.SetFocusOrder(parent, 1); manager.SetFocusOrder(firstChild, 2); manager.SetFocusOrder(firstGrandChild, 3); manager.SetFocusOrder(secondGrandChild, 4); manager.SetFocusOrder(thirdGrandChild, 5); manager.SetFocusOrder(secondChild, 6); // Set the parent and the first child actor as focus groups manager.SetFocusGroup(parent, true); DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true); // Set focus to the first grand child actor DALI_TEST_CHECK(manager.SetCurrentFocusActor(firstGrandChild) == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild); // The current focus group should be the parent, As it is the immediate parent which is also a focus group. DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == parent); manager.SetFocusGroup(firstChild, true); DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true); // The current focus group should be the firstChild, As it is the immediate parent which is also a focus group. DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild); manager.SetFocusGroup(firstGrandChild, true); DALI_TEST_CHECK(manager.IsFocusGroup(firstGrandChild) == true); // The current focus group should be itself, As it is also a focus group. DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstGrandChild); // Set focus to the second grand child actor DALI_TEST_CHECK(manager.SetCurrentFocusActor(secondGrandChild) == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild); // The current focus group should be the firstChild, As it is the immediate parent which is also a // focus group for the current focus actor. DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild); END_TEST; }
void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event) { if(!mIsKeyboardFocusEnabled) { return; } AccessibilityAdaptor accessibilityAdaptor = AccessibilityAdaptor::Get(); bool isAccessibilityEnabled = accessibilityAdaptor.IsEnabled(); Toolkit::AccessibilityManager accessibilityManager = Toolkit::AccessibilityManager::Get(); std::string keyName = event.keyPressedName; bool isFocusStartableKey = false; if(event.state == KeyEvent::Down) { if (keyName == "Left") { if(!isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // Move the focus towards left MoveFocus(Toolkit::Control::KeyboardFocus::LEFT); } isFocusStartableKey = true; } else { // Move the accessibility focus backward accessibilityManager.MoveFocusBackward(); } } else if (keyName == "Right") { if(!isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // Move the focus towards right MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT); } } else { // Move the accessibility focus forward accessibilityManager.MoveFocusForward(); } isFocusStartableKey = true; } else if (keyName == "Up" && !isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // Move the focus towards up MoveFocus(Toolkit::Control::KeyboardFocus::UP); } isFocusStartableKey = true; } else if (keyName == "Down" && !isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // Move the focus towards down MoveFocus(Toolkit::Control::KeyboardFocus::DOWN); } isFocusStartableKey = true; } else if (keyName == "Tab" && !isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // "Tab" key changes the focus group in the forward direction and // "Shift-Tab" key changes it in the backward direction. DoMoveFocusToNextFocusGroup(!event.IsShiftModifier()); } isFocusStartableKey = true; } else if (keyName == "space" && !isAccessibilityEnabled) { if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } isFocusStartableKey = true; } else if (keyName == "" && !isAccessibilityEnabled) { // Check the fake key event for evas-plugin case if(!mIsFocusIndicatorEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } isFocusStartableKey = true; } else if (keyName == "Backspace" && !isAccessibilityEnabled) { // Emit signal to go back to the previous view??? } } else if(event.state == KeyEvent::Up) { if (keyName == "Return") { if(!mIsFocusIndicatorEnabled && !isAccessibilityEnabled) { // Show focus indicator mIsFocusIndicatorEnabled = true; } else { // The focused actor has enter pressed on it Actor actor; if( !isAccessibilityEnabled ) { actor = GetCurrentFocusActor(); } else { actor = accessibilityManager.GetCurrentFocusActor(); } if( actor ) { DoKeyboardEnter( actor ); } } isFocusStartableKey = true; } } if(isFocusStartableKey && mIsFocusIndicatorEnabled && !isAccessibilityEnabled) { Actor actor = GetCurrentFocusActor(); if( !actor ) { // No actor is focused but keyboard focus is activated by the key press // Let's try to move the initial focus MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT); } else if(mFocusIndicatorActor) { // Make sure the focused actor is highlighted actor.Add(mFocusIndicatorActor); } } }
int UtcDaliFocusManagerFocusGroup(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliFocusManagerFocusGroup"); FocusManager manager = FocusManager::Get(); DALI_TEST_CHECK(manager); // Create an actor with two child actors and add it to the stage Actor parent = Actor::New(); Actor firstChild = Actor::New(); Actor secondChild = Actor::New(); parent.Add(firstChild); parent.Add(secondChild); Stage::GetCurrent().Add(parent); // Create three actors and add them as the children of the first child actor Actor firstGrandChild = Actor::New(); Actor secondGrandChild = Actor::New(); Actor thirdGrandChild = Actor::New(); firstChild.Add(firstGrandChild); firstChild.Add(secondGrandChild); firstChild.Add(thirdGrandChild); // Set focus order to the actors manager.SetFocusOrder(parent, 1); manager.SetFocusOrder(firstChild, 2); manager.SetFocusOrder(firstGrandChild, 3); manager.SetFocusOrder(secondGrandChild, 4); manager.SetFocusOrder(thirdGrandChild, 5); manager.SetFocusOrder(secondChild, 6); // Set the parent and the first child actor as focus groups manager.SetFocusGroup(parent, true); DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true); // The focus group of the parent should be itself, as it is set to be a focus group. DALI_TEST_CHECK(manager.GetFocusGroup(parent) == parent); // The focus group of the firstChild should be its parent, as it is the immediate parent which is also a group. DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == parent); manager.SetFocusGroup(firstChild, true); DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true); // The focus group of the firstChild should be itself, as it is set to be a focus group now. DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == firstChild); // Enable wrap mode for focus movement. manager.SetWrapMode(true); DALI_TEST_CHECK(manager.GetWrapMode() == true); // Check that no actor is being focused yet. DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor()); // Check that the focus is set on the parent actor. DALI_TEST_CHECK(manager.SetCurrentFocusActor(parent) == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent); // Check that group mode is disabled. DALI_TEST_CHECK(manager.GetGroupMode() == false); // Check that the focus movement is wrapped as normal. DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondChild); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild); // Enable the group mode. manager.SetGroupMode(true); DALI_TEST_CHECK(manager.GetGroupMode() == true); // Check that the focus movement is now limited to the current focus group. DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild); DALI_TEST_CHECK(manager.MoveFocusForward() == true); DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild); END_TEST; }
int UtcDaliConfirmationPopupDynamicSignalGenerationP(void) { ToolkitTestApplication application; tet_infoline( " UtcDaliConfirmationPopupDynamicSignalGenerationP" ); ConfirmationPopup popup = ConfirmationPopup::New(); TextLabel titleActor = TextLabel::New( "Title" ); popup.SetTitle( titleActor ); TextLabel contentActor = TextLabel::New( "Content" ); popup.SetContent( contentActor ); Actor footerActor = Actor::New(); // The confirmation popup can use any control type for the ok or cancel buttons. // It requires that the name is "control-ok" to provide the "control-signal-ok" signal. PushButton buttonOK = PushButton::New(); buttonOK.SetName( "control-ok" ); footerActor.Add( buttonOK ); PushButton buttonCancel = PushButton::New(); buttonCancel.SetName( "control-cancel" ); footerActor.Add( buttonCancel ); popup.SetFooter( footerActor ); // Tell the confirmation popup to connect to the signal in our button called "on-stage". popup.SetProperty( Toolkit::ConfirmationPopup::Property::CONNECT_SIGNAL_OK_SELECTED, "on-stage" ); std::string resultProperty; DALI_TEST_CHECK( popup.GetProperty( Toolkit::ConfirmationPopup::Property::CONNECT_SIGNAL_OK_SELECTED ).Get( resultProperty ) ); DALI_TEST_EQUALS( resultProperty, "on-stage", TEST_LOCATION ); // Connect to the confirmation popup's OK signal. This signal is dynamically created upon connection. gSignalReceivedOK = false; gSignalReceivedCancel = false; TestConnectionTrackerObject* testTracker = new TestConnectionTrackerObject(); popup.ConnectSignal( testTracker, "control-signal-ok", ConfirmationPopupOKTestFunctor() ); // Check no signal has occurred yet. DALI_TEST_CHECK( !gSignalReceivedOK ); DALI_TEST_CHECK( !gSignalReceivedCancel ); // Provoke the signal. Stage::GetCurrent().Add( popup ); // Check the signal has occurred. DALI_TEST_CHECK( gSignalReceivedOK ); DALI_TEST_CHECK( !gSignalReceivedCancel ); // Remove the popup from the stage, and connect the cancel signal. popup.Unparent(); popup.SetProperty( Toolkit::ConfirmationPopup::Property::CONNECT_SIGNAL_CANCEL_SELECTED, "on-stage" ); DALI_TEST_CHECK( popup.GetProperty( Toolkit::ConfirmationPopup::Property::CONNECT_SIGNAL_CANCEL_SELECTED ).Get( resultProperty ) ); DALI_TEST_EQUALS( resultProperty, "on-stage", TEST_LOCATION ); popup.ConnectSignal( testTracker, "control-signal-cancel", ConfirmationPopupCancelTestFunctor() ); // Check the cancel signal has not occurred yet. DALI_TEST_CHECK( gSignalReceivedOK ); DALI_TEST_CHECK( !gSignalReceivedCancel ); // Provoke the signal. Stage::GetCurrent().Add( popup ); // Check the cancel signal has occurred. DALI_TEST_CHECK( gSignalReceivedOK ); DALI_TEST_CHECK( gSignalReceivedCancel ); END_TEST; }
int UtcDaliScriptingCreatePropertyMapActor(void) { TestApplication application; // Actor Type { Actor actor = Actor::New(); Property::Map map; CreatePropertyMap( actor, map ); DALI_TEST_CHECK( !map.Empty() ); DALI_TEST_CHECK( NULL != map.Find( "type" ) ); DALI_TEST_EQUALS( map.Find( "type")->Get< std::string >(), "Actor", TEST_LOCATION ); Stage::GetCurrent().Remove( actor ); } // ImageActor Type { Actor actor = ImageActor::New(); Property::Map map; CreatePropertyMap( actor, map ); DALI_TEST_CHECK( !map.Empty() ); DALI_TEST_CHECK( NULL != map.Find( "type" ) ); DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "ImageActor", TEST_LOCATION ); Stage::GetCurrent().Remove( actor ); } // Default properties { Actor actor = Actor::New(); actor.SetSize( Vector3::ONE ); actor.SetPosition( Vector3::XAXIS ); actor.SetScale( Vector3::ZAXIS ); actor.SetVisible( false ); actor.SetColor( Color::MAGENTA ); actor.SetName( "MyActor" ); actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); actor.SetParentOrigin( ParentOrigin::TOP_RIGHT ); actor.SetSensitive( false ); actor.SetLeaveRequired( true ); actor.SetInheritOrientation( false ); actor.SetInheritScale( false ); actor.SetSizeModeFactor( Vector3::ONE ); Stage::GetCurrent().Add( actor ); application.SendNotification(); application.Render(); Property::Map map; CreatePropertyMap( actor, map ); DALI_TEST_CHECK( !map.Empty() ); DALI_TEST_CHECK( NULL != map.Find( "size" ) ); DALI_TEST_EQUALS( map.Find( "size" )->Get< Vector3 >(), Vector3::ONE, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "position" ) ); DALI_TEST_EQUALS( map.Find( "position" )->Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "scale" ) ); DALI_TEST_EQUALS( map.Find( "scale" )->Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "visible" ) ); DALI_TEST_EQUALS( map.Find( "visible" )->Get< bool >(), false, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "color" ) ); DALI_TEST_EQUALS( map.Find( "color" )->Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "name" ) ); DALI_TEST_EQUALS( map.Find( "name")->Get< std::string >(), "MyActor", TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "anchor-point" ) ); DALI_TEST_EQUALS( map.Find( "anchor-point" )->Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "parent-origin" ) ); DALI_TEST_EQUALS( map.Find( "parent-origin" )->Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "sensitive" ) ); DALI_TEST_EQUALS( map.Find( "sensitive" )->Get< bool >(), false, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "leave-required" ) ); DALI_TEST_EQUALS( map.Find( "leave-required" )->Get< bool >(), true, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "inherit-orientation" ) ); DALI_TEST_EQUALS( map.Find( "inherit-orientation" )->Get< bool >(), false, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "inherit-scale" ) ); DALI_TEST_EQUALS( map.Find( "inherit-scale" )->Get< bool >(), false, TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "size-mode-factor" ) ); DALI_TEST_EQUALS( map.Find( "size-mode-factor" )->Get< Vector3 >(), Vector3::ONE, TEST_LOCATION ); Stage::GetCurrent().Remove( actor ); } // ColorMode TestEnumStrings< ColorMode >( "color-mode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode ); // PositionInheritanceMode TestEnumStrings< PositionInheritanceMode >( "position-inheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode ); // DrawMode TestEnumStrings< DrawMode::Type >( "draw-mode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode ); // Children { Actor actor = Actor::New(); Actor child = ImageActor::New(); actor.Add( child ); Stage::GetCurrent().Add( actor ); application.SendNotification(); application.Render(); Property::Map map; CreatePropertyMap( actor, map ); DALI_TEST_CHECK( !map.Empty() ); DALI_TEST_CHECK( NULL != map.Find( "type" ) ); DALI_TEST_EQUALS( map.Find( "type" )->Get< std::string >(), "Actor", TEST_LOCATION ); DALI_TEST_CHECK( NULL != map.Find( "actors" ) ); Property::Array children( map.Find( "actors")->Get< Property::Array >() ); DALI_TEST_CHECK( !children.Empty() ); Property::Map childMap( children[0].Get< Property::Map >() ); DALI_TEST_CHECK( !childMap.Empty() ); DALI_TEST_CHECK( childMap.Find( "type" ) ); DALI_TEST_EQUALS( childMap.Find( "type" )->Get< std::string >(), "ImageActor", TEST_LOCATION ); Stage::GetCurrent().Remove( actor ); } END_TEST; }
static void UtcDaliPushButtonInterruptEventWhenInsensitive() { ToolkitTestApplication application; tet_infoline(" UtcDaliPushButtonInterruptEventWhenInsensitive"); // * Creates an actor which contains a button. // * The size of the actor is bigger than the button. // * The button's boundary is contained in the actor's one. Actor actor = Actor::New(); TETButton tetButton= Toolkit::TETButton::New(); actor.SetName( "Actor" ); tetButton.SetName( "TETButton" ); actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); actor.SetParentOrigin( ParentOrigin::TOP_LEFT ); actor.SetPosition( 0, 0 ); actor.SetSize( 400, 800 ); tetButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); tetButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); tetButton.SetPosition( 240, 400 ); tetButton.SetSize( 100, 100 ); actor.Add( tetButton ); Stage::GetCurrent().Add( actor ); // * Actor's touch event is connected to a callback function // and this callback function consumes the event. actor.TouchedSignal().Connect( &TestCallback ); // * Button's pressed signal is connected to a callback function // which also consumes the event. // * Changes the sensitiveness of the button to false. TETButtonPressed tetButtonPressed( actor, TETButtonPressed::SENSITIVENESS ); tetButton.PressedSignal().Connect( &tetButtonPressed, &TETButtonPressed::Callback ); // Initializes TET state. gOnTouchPointInterrupted = false; tetButton.SetSensitive( true ); Dali::Integration::TouchEvent event; // TET starts. // Test a down point inside the button which is also consumed by the actor, and an up point // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an // interrupt event. application.SendNotification(); application.Render(); // A down event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); event.AddPoint( pointDownInside ); // flush the queue and render once application.SendNotification(); application.Render(); application.ProcessEvent( event ); // An up event is sent outside the button's boundary but inside the actor's one. event = Dali::Integration::TouchEvent(); event.AddPoint( pointUpOutside ); // flush the queue and render once application.SendNotification(); application.Render(); application.ProcessEvent( event ); DALI_TEST_CHECK( gOnTouchPointInterrupted ); // Test a down point inside the button which is also consumed by the actor, and a motion point // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an // interrupt event. // Initializes TET state. gOnTouchPointInterrupted = false; actor.SetSensitive( true ); tetButton.SetSensitive( true ); application.SendNotification(); application.Render(); // A down event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); event.AddPoint( pointDownInside ); // flush the queue and render once application.SendNotification(); application.Render(); application.ProcessEvent( event ); // A motion event is sent outside the button's boundary but inside the actor's one. event = Dali::Integration::TouchEvent(); event.AddPoint( pointMotionOut ); // flush the queue and render once application.SendNotification(); application.Render(); application.ProcessEvent( event ); DALI_TEST_CHECK( gOnTouchPointInterrupted ); // Test a down point inside the button which is also consumed by the actor, and an up point // also inside the button and consumed by the actor. gOnTouchPointInterrupted should be false. // Initializes TET state. gOnTouchPointInterrupted = false; actor.SetSensitive( true ); tetButton.SetSensitive( true ); // A down event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); event.AddPoint( pointDownInside ); // flush the queue and render once application.SendNotification(); application.Render(); application.ProcessEvent( event ); actor.SetSensitive( true ); // An up event is sent inside the button's boundary. event = Dali::Integration::TouchEvent(); event.AddPoint( pointUpInside ); // flush the queue and render once application.SendNotification(); application.Render(); application.ProcessEvent( event ); DALI_TEST_CHECK( !gOnTouchPointInterrupted ); }