本文整理汇总了C++中Stage::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ Stage::Add方法的具体用法?C++ Stage::Add怎么用?C++ Stage::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stage
的用法示例。
在下文中一共展示了Stage::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UtcDaliMagnifierSetSourceActorP
int UtcDaliMagnifierSetSourceActorP(void)
{
ToolkitTestApplication application;
Stage stage = Stage::GetCurrent();
Magnifier view = Magnifier::New();
stage.Add( view );
application.SendNotification();
application.Render();
RenderTaskList renderTaskList = stage.GetRenderTaskList();
DALI_TEST_CHECK( renderTaskList.GetTaskCount() > 1 );
Actor actor = Actor::New();
stage.Add( actor );
DALI_TEST_CHECK( stage.GetRenderTaskList().GetTask( 1 ).GetSourceActor() != actor );
view.SetSourceActor( actor );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTask( 1 ).GetSourceActor(), actor, TEST_LOCATION );
END_TEST;
}
示例2: UtcDaliHitTestAlgorithmOrtho02
int UtcDaliHitTestAlgorithmOrtho02(void)
{
TestApplication application;
tet_infoline("Testing Dali::HitTestAlgorithm with offset Ortho camera()");
Stage stage = Stage::GetCurrent();
RenderTaskList renderTaskList = stage.GetRenderTaskList();
RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();
Vector2 stageSize ( stage.GetSize() );
cameraActor.SetOrthographicProjection(-stageSize.x * 0.3f, stageSize.x * 0.7f,
stageSize.y * 0.3f, -stageSize.y * 0.7f,
800.0f, 4895.0f);
cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);
Vector2 actorSize( stageSize * 0.5f );
// Create two actors with half the size of the stage and set them to be partially overlapping
Actor blue = Actor::New();
blue.SetName( "Blue" );
blue.SetAnchorPoint( AnchorPoint::TOP_LEFT );
blue.SetParentOrigin( Vector3(0.2f, 0.2f, 0.5f) );
blue.SetSize( actorSize );
blue.SetZ(30.0f);
Actor green = Actor::New( );
green.SetName( "Green" );
green.SetAnchorPoint( AnchorPoint::TOP_LEFT );
green.SetParentOrigin( Vector3(0.4f, 0.4f, 0.5f) );
green.SetSize( actorSize );
// Add the actors to the view
stage.Add( blue );
stage.Add( green );
// Render and notify
application.SendNotification();
application.Render(0);
application.Render(10);
HitTestAlgorithm::Results results;
HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction);
DALI_TEST_CHECK( results.actor == green );
DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.6f, TEST_LOCATION );
HitTest(stage, Vector2::ZERO, results, &DefaultIsActorTouchableFunction);
DALI_TEST_CHECK( results.actor == blue );
DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION );
HitTest(stage, stageSize, results, &DefaultIsActorTouchableFunction);
DALI_TEST_CHECK( ! results.actor );
DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION );
// Just inside green
HitTest(stage, stageSize*0.69f, results, &DefaultIsActorTouchableFunction);
DALI_TEST_CHECK( results.actor == green );
DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.98f, TEST_LOCATION );
END_TEST;
}
示例3: Create
/**
* One-time setup in response to Application InitSignal.
*/
void Create( Application& application )
{
Stage stage = Stage::GetCurrent();
Vector2 stageSize = stage.GetSize();
stage.KeyEventSignal().Connect(this, &TextFontsExample::OnKeyEvent);
CreateFolderButton ( mButton );
mButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
mButton.ClickedSignal().Connect( this, &TextFontsExample::OnButtonClicked );
stage.Add( mButton );
mLayoutSize = Vector2( stageSize.width*0.5f, stageSize.height*0.10f );
CreateContainer ( mContainer , mLayoutSize);
CreateContainer ( mContainer2 , mLayoutSize );
CreateContainer ( mContainer3 , mLayoutSize );
// Info about Text Label and if font should be fixed or free to change with system
CreateContainer ( mContainerInfo , mLayoutSize );
CreateContainer ( mContainer2Info , mLayoutSize );
CreateContainer ( mContainer3Info , mLayoutSize );
mContainerInfo.SetParentOrigin( ParentOrigin::TOP_RIGHT );
mContainer2Info.SetParentOrigin( ParentOrigin::TOP_RIGHT );
mContainer3Info.SetParentOrigin( ParentOrigin::TOP_RIGHT );
mContainer.Add( mContainerInfo );
mContainer2.Add( mContainer2Info );
mContainer3.Add( mContainer3Info );
CreateTextLabel ( mLabelInfo, "system free", Color::BLACK, true );
CreateTextLabel ( mLabel2Info, "json fixed", Color::BLACK, true );
CreateTextLabel ( mLabel3Info, "SetProp fixed", Color::BLACK, true );
mContainerInfo.Add( mLabelInfo );
mContainer2Info.Add( mLabel2Info );
mContainer3Info.Add( mLabel3Info );
stage.Add( mContainer );
stage.Add( mContainer2 );
stage.Add( mContainer3 );
CreateTextLabel ( mLabel, LABEL_TEXT, Color::WHITE );
CreateTextLabel ( mLabel2, LABEL_TEXT, Color::WHITE );
mLabel2.SetStyleName("textlabel-Rosemary");
CreateTextLabel ( mLabel3, LABEL_TEXT, Color::WHITE );
mLabel3.SetProperty( TextLabel::Property::FONT_FAMILY, "SamsungOneUI" );
mContainer.SetPosition( 0, 0 );
mContainer2.SetPosition( 0, stageSize.height*0.25f );
mContainer3.SetPosition( 0, stageSize.height*0.25f*2 );
mContainer.Add( mLabel );
mContainer2.Add( mLabel2 );
mContainer3.Add( mLabel3 );
}
示例4: UtcDaliHoverOffscreenRenderTasks
int UtcDaliHoverOffscreenRenderTasks(void)
{
TestApplication application;
Stage stage ( Stage::GetCurrent() );
Vector2 stageSize ( stage.GetSize() );
// FrameBufferImage for offscreen RenderTask
FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
// Create a renderable actor to display the FrameBufferImage
Actor renderableActor = CreateRenderableActor( frameBufferImage );
renderableActor.SetParentOrigin(ParentOrigin::CENTER);
renderableActor.SetSize( stageSize.x, stageSize.y );
renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
stage.Add( renderableActor );
Actor actor = Actor::New();
actor.SetSize(100.0f, 100.0f);
actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
stage.Add( actor );
application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
// Create a RenderTask
RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
renderTask.SetSourceActor( actor );
renderTask.SetTargetFrameBuffer( frameBufferImage );
renderTask.SetInputEnabled( true );
// Create another RenderTask
RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
renderTask2.SetInputEnabled( true );
// Render and notify
application.SendNotification();
application.Render();
// Connect to actor's hovered signal
SignalData data;
HoverEventFunctor functor( data );
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 );
data.Reset();
END_TEST;
}
示例5: Create
// The Init signal is received once (only) during the Application lifetime
void Create( Application& application )
{
Stage stage = Stage::GetCurrent();
stage.SetBackgroundColor( Color::WHITE );
stage.KeyEventSignal().Connect(this, &EmojiExample::OnKeyEvent);
mTableView = Toolkit::TableView::New( NUMBER_OF_EMOJIS, 1 );
mTableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
mTableView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
mTableView.SetParentOrigin( ParentOrigin::TOP_LEFT );
mTableView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
mTableView.TouchedSignal().Connect( this, &EmojiExample::OnTouchEvent );
stage.Add( mTableView );
for( unsigned int index = 0u; index < NUMBER_OF_EMOJIS; ++index )
{
const Emoji& emoji = EMOJIS[index];
const std::string text = emoji.mUTF8 + " " + emoji.mDescription;
TextLabel label = TextLabel::New( text );
label.SetParentOrigin( ParentOrigin::TOP_CENTER );
label.SetAnchorPoint( AnchorPoint::TOP_CENTER );
label.SetProperty( TextLabel::Property::MULTI_LINE, true );
mTableView.SetFitHeight( index );
mTableView.AddChild( label, Toolkit::TableView::CellPosition( index, 0 ) );
}
}
示例6: UtcDaliMagnifierFrameVisibility
int UtcDaliMagnifierFrameVisibility(void)
{
ToolkitTestApplication application;
Stage stage = Stage::GetCurrent();
Magnifier view = Magnifier::New();
stage.Add( view );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), true, TEST_LOCATION );
view.SetProperty( Magnifier::Property::FRAME_VISIBILITY, false );
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), false, TEST_LOCATION );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), false, TEST_LOCATION );
view.SetProperty( Magnifier::Property::FRAME_VISIBILITY, true );
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), true, TEST_LOCATION );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), true, TEST_LOCATION );
END_TEST;
}
示例7: UtcDaliMagnifierMagnificationFactor
int UtcDaliMagnifierMagnificationFactor(void)
{
ToolkitTestApplication application;
Stage stage = Stage::GetCurrent();
Magnifier view = Magnifier::New();
stage.Add( view );
application.SendNotification();
application.Render();
float magnificationFactor( 200.0f );
DALI_TEST_CHECK( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >() != magnificationFactor );
view.SetProperty( Magnifier::Property::MAGNIFICATION_FACTOR, magnificationFactor );
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), magnificationFactor, TEST_LOCATION );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), magnificationFactor, TEST_LOCATION );
view.SetProperty( Magnifier::Property::MAGNIFICATION_FACTOR, 1.0f );
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), 1.0f, TEST_LOCATION );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), 1.0f, TEST_LOCATION );
END_TEST;
}
示例8: UtcDaliMagnifierSourcePosition
int UtcDaliMagnifierSourcePosition(void)
{
ToolkitTestApplication application;
Stage stage = Stage::GetCurrent();
Magnifier view = Magnifier::New();
stage.Add( view );
application.SendNotification();
application.Render();
Vector3 position( 100.0f, 200.0f, 300.0f );
DALI_TEST_CHECK( view.GetProperty( Magnifier::Property::SOURCE_POSITION ).Get< Vector3 >() != position );
view.SetProperty( Magnifier::Property::SOURCE_POSITION, position );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::SOURCE_POSITION ).Get< Vector3 >(), position, TEST_LOCATION );
view.SetProperty( Magnifier::Property::SOURCE_POSITION, Vector3::ONE );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::SOURCE_POSITION ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );
END_TEST;
}
示例9: OnInit
void OnInit( Application& application )
{
// Create a ScrollView instance
ScrollView scrollView = ScrollView::New();
scrollView.SetParentOrigin( ParentOrigin::CENTER );
Stage stage = Stage::GetCurrent();
stage.Add(scrollView);
// Set the size of scrollView; it covers the entire stage
Size size = stage.GetSize();
scrollView.SetSize(size);
// Add actors to the ScrollView
for( int i = 0; i < NUM_IMAGES; ++i )
{
AddImage( scrollView, size, i );
}
// The ScrollView contents are now draggable
// To enforce horizontal-only scrolling, the Y axis ruler can be disabled
RulerPtr rulerY = new DefaultRuler();
rulerY->Disable();
scrollView.SetRulerY( rulerY );
// A domain can be applied to rulers to prevent scrolling beyond this boundary
// In this case, to 4 times the width of the stage, allowing for 4 pages to be scrolled
RulerPtr rulerX2 = new FixedRuler( size.width );
rulerX2->SetDomain( RulerDomain( 0.0f, size.width*NUM_IMAGES ) );
scrollView.SetRulerX( rulerX2 );
// Connect key event signal
stage.KeyEventSignal().Connect( this, &ScrollViewSample::OnKeyEvent );
}
示例10: Create
/**
* One-time setup in response to Application InitSignal.
*/
void Create( Application& application )
{
Stage stage = Stage::GetCurrent();
stage.KeyEventSignal().Connect(this, &TextLabelMultiLanguageExample::OnKeyEvent);
stage.SetBackgroundColor( Color::WHITE );
mTableView = Toolkit::TableView::New( NUMBER_OF_LANGUAGES, 1 );
mTableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
mTableView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
mTableView.SetParentOrigin( ParentOrigin::TOP_LEFT );
mTableView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
mTableView.TouchSignal().Connect( this, &TextLabelMultiLanguageExample::OnTouch );
stage.Add( mTableView );
for( unsigned int index = 0u; index < NUMBER_OF_LANGUAGES; ++index )
{
const Language& language = LANGUAGES[index];
TextLabel label = TextLabel::New();
label.SetProperty( TextLabel::Property::MULTI_LINE, true );
const std::string text = language.languageName + " " + language.languageRomanName + " " + language.text;
label.SetProperty( TextLabel::Property::TEXT, text );
mTableView.SetFitHeight( index );
mTableView.AddChild( label, Toolkit::TableView::CellPosition( index, 0 ) );
}
}
示例11: UtcDaliKeyInputFocusManagerIsKeyboardListener
static void UtcDaliKeyInputFocusManagerIsKeyboardListener()
{
ToolkitTestApplication application;
Stage stage = Stage::GetCurrent();
tet_infoline(" UtcDaliKeyInputFocusManagerIsKeyboardListener");
KeyInputFocusManager manager = KeyInputFocusManager::Get();
DALI_TEST_CHECK(manager);
PushButton pushButton1 = PushButton::New();
PushButton pushButton2 = PushButton::New();
stage.Add( pushButton1 );
stage.Add( pushButton2 );
manager.SetFocus(pushButton1);
DALI_TEST_CHECK(pushButton1 == manager.GetCurrentFocusControl());
manager.SetFocus(pushButton2);
DALI_TEST_CHECK(pushButton2 == manager.GetCurrentFocusControl());
DALI_TEST_CHECK(manager.IsKeyboardListener(pushButton1));
DALI_TEST_CHECK(manager.IsKeyboardListener(pushButton2));
manager.RemoveFocus(pushButton2);
DALI_TEST_CHECK(!manager.IsKeyboardListener(pushButton2));
manager.RemoveFocus(pushButton1);
DALI_TEST_CHECK(!manager.IsKeyboardListener(pushButton1));
manager.SetFocus(pushButton2);
DALI_TEST_CHECK(manager.IsKeyboardListener(pushButton2));
pushButton2.ClearKeyInputFocus();
DALI_TEST_CHECK(!manager.IsKeyboardListener(pushButton2));
}
示例12: 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;
}
示例13: UtcDaliHoverLeaveActorReadded
int UtcDaliHoverLeaveActorReadded(void)
{
TestApplication application;
Stage stage = Stage::GetCurrent();
Actor actor = Actor::New();
actor.SetSize(100.0f, 100.0f);
actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
stage.Add(actor);
// Set actor to receive hover-events
actor.SetLeaveRequired( true );
// Render and notify
application.SendNotification();
application.Render();
// Connect to actor's hovered signal
SignalData data;
HoverEventFunctor functor( data );
actor.HoveredSignal().Connect( &application, functor );
// Emit a started and motion
application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) );
application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 11.0f, 10.0f ) ) );
DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
data.Reset();
// Remove actor from stage and add again
stage.Remove( actor );
stage.Add( actor );
// Emit a motion within the actor's bounds
application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 12.0f, 10.0f ) ) );
DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
data.Reset();
// Emit a motion outside the actor's bounds
application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, Vector2( 200.0f, 200.0f ) ) );
DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
DALI_TEST_EQUALS( TouchPoint::Leave, data.hoverEvent.points[0].state, TEST_LOCATION );
data.Reset();
END_TEST;
}
示例14: UtcDaliHitTestAlgorithmStencil
int UtcDaliHitTestAlgorithmStencil(void)
{
TestApplication application;
tet_infoline("Testing Dali::HitTestAlgorithm with a stencil");
Stage stage = Stage::GetCurrent();
Actor rootLayer = stage.GetRootLayer();
rootLayer.SetName( "RootLayer" );
// Create a layer
Layer layer = Layer::New();
layer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
layer.SetParentOrigin( ParentOrigin::TOP_LEFT );
layer.SetName( "layer" );
stage.Add( layer );
// Create a stencil and add that to the layer
Actor stencil = ImageActor::New(Dali::BitmapImage::WHITE() );
stencil.SetAnchorPoint( AnchorPoint::TOP_LEFT );
stencil.SetParentOrigin( ParentOrigin::TOP_LEFT );
stencil.SetSize( 50.0f, 50.0f );
stencil.SetDrawMode( DrawMode::STENCIL );
stencil.SetName( "stencil" );
layer.Add( stencil );
// Create an actor and add that to the layer
Actor layerHitActor = Actor::New();
layerHitActor.SetSize( 100.0f, 100.0f );
layerHitActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
layerHitActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
layerHitActor.SetName( "layerHitActor" );
layer.Add( layerHitActor );
// Render and notify
application.SendNotification();
application.Render();
// Hit within stencil and actor
{
HitTestAlgorithm::Results results;
HitTest(stage, Vector2( 10.0f, 10.0f ), results, &DefaultIsActorTouchableFunction);
DALI_TEST_CHECK( results.actor == layerHitActor );
tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
}
// Hit within actor but outside of stencil, should hit the root-layer
{
HitTestAlgorithm::Results results;
HitTest(stage, Vector2( 60.0f, 60.0f ), results, &DefaultIsActorTouchableFunction);
DALI_TEST_CHECK( results.actor == rootLayer );
tet_printf( "Hit: %s\n", ( results.actor ? results.actor.GetName().c_str() : "NULL" ) );
}
END_TEST;
}
示例15: UtcDaliStageAddP
int UtcDaliStageAddP(void)
{
TestApplication application;
Stage stage = Stage::GetCurrent();
Actor actor = Actor::New();
DALI_TEST_CHECK( !actor.OnStage() );
stage.Add( actor );
DALI_TEST_CHECK( actor.OnStage() );
END_TEST;
}