本文整理汇总了C++中Actor::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ Actor::Add方法的具体用法?C++ Actor::Add怎么用?C++ Actor::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actor
的用法示例。
在下文中一共展示了Actor::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPhysicalKeyboardStatusChanged
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;
}
}
示例2: OnPanGesture
// 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));
}
}
示例3: UtcDaliHoverMultipleRenderableActors
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;
}
示例4: UtcDaliTapGestureSignalReceptionChildHit
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;
}
示例5: OnInit
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 );
}
示例6: Initialize
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 );
}
示例7: UtcDaliHoverMultipleRenderTasksWithChildLayer
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;
}
示例8: UtcDaliImageActorDownCast
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;
}
示例9: UtcDaliImageActorDownCast2
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;
}
示例10: OnTimerTick
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
}
示例11: SetFocusIndicatorActor
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;
}
}
示例12: UtcDaliTapGestureSignalReceptionMultipleGestureDetectors
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;
}
示例13: UtcDaliFocusManagerGetCurrentFocusGroup
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;
}
示例14: OnKeyEvent
//.........这里部分代码省略.........
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);
}
}
}
示例15: UtcDaliFocusManagerFocusGroup
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;
}