Esempio n. 1
0
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;
}
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;
}
Esempio n. 3
0
  /**
   * 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 );
  }
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;
}
Esempio n. 5
0
  // 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 ) );
    }
  }
Esempio n. 6
0
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;
}
Esempio n. 7
0
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;
}
Esempio n. 8
0
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;
}
Esempio n. 9
0
  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 );
  }
  /**
   * 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 ) );
    }
  }
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));
}
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 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;
}
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;
}
Esempio n. 15
0
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;
}
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 UtcDaliHoverStencilNonRenderableActor(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);

  Actor stencil = Actor::New();
  stencil.SetSize(50.0f, 50.0f);
  stencil.SetAnchorPoint(AnchorPoint::TOP_LEFT);
  stencil.SetDrawMode( DrawMode::STENCIL );
  stage.Add(stencil);

  // Render and notify
  application.SendNotification();
  application.Render();

  // Connect to actor's hovered signal
  SignalData data;
  HoverEventFunctor functor( data );
  actor.HoveredSignal().Connect( &application, functor );

  // Emit an event within stencil area
  application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) );
  DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
  data.Reset();

  // Emit an event outside the stencil area but within the actor area, we should have a hit!
  application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 60.0f, 60.0f ) ) );
  DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
  data.Reset();

  END_TEST;
}
Esempio n. 18
0
int UtcDaliStageGetLayerCountP(void)
{
  TestApplication application;

  Stage stage = Stage::GetCurrent();

  // Initially we have a default layer
  DALI_TEST_EQUALS( stage.GetLayerCount(), 1u, TEST_LOCATION );

  Layer layer = Layer::New();
  stage.Add( layer );

  DALI_TEST_EQUALS( stage.GetLayerCount(), 2u, TEST_LOCATION );
  END_TEST;
}
Esempio n. 19
0
int UtcDaliStageGetLayerP(void)
{
  TestApplication application;

  Stage stage = Stage::GetCurrent();

  Layer rootLayer = stage.GetLayer( 0 );
  DALI_TEST_CHECK( rootLayer );

  Layer layer = Layer::New();
  stage.Add( layer );

  Layer sameLayer = stage.GetLayer( 1 );
  DALI_TEST_CHECK( layer == sameLayer );
  END_TEST;
}
static void UtcDaliKeyInputFocusManagerSetFocus()
{
  ToolkitTestApplication application;
  Stage stage = Stage::GetCurrent();

  tet_infoline(" UtcDaliKeyInputFocusManagerSetFocus");

  KeyInputFocusManager manager = KeyInputFocusManager::Get();
  DALI_TEST_CHECK(manager);

  PushButton pushButton1 = PushButton::New();
  stage.Add( pushButton1 );

  manager.SetFocus(pushButton1);
  DALI_TEST_CHECK(pushButton1.HasKeyInputFocus());
}
Esempio n. 21
0
int UtcDaliStageEventProcessingFinishedN(void)
{
  TestApplication application;
  Stage stage = Stage::GetCurrent();

  bool eventProcessingFinished = false;
  EventProcessingFinishedFunctor functor( eventProcessingFinished );
  stage.EventProcessingFinishedSignal().Connect( &application, functor );

  Actor actor( Actor::New() );
  stage.Add( actor );

  // Do not complete event processing and confirm the signal has not been emitted.
  DALI_TEST_CHECK( !eventProcessingFinished );

  END_TEST;
}
Esempio n. 22
0
int UtcDaliStageEventProcessingFinishedP(void)
{
  TestApplication application;
  Stage stage = Stage::GetCurrent();

  bool eventProcessingFinished = false;
  EventProcessingFinishedFunctor functor( eventProcessingFinished );
  stage.EventProcessingFinishedSignal().Connect( &application, functor );

  Actor actor( Actor::New() );
  stage.Add( actor );

  application.SendNotification();
  application.Render();

  DALI_TEST_CHECK( eventProcessingFinished );

  END_TEST;
}
Esempio n. 23
0
void Magnifier::InitializeRenderTask()
{
  Stage stage = Stage::GetCurrent();

  RenderTaskList taskList = stage.GetRenderTaskList();

  mTask = taskList.CreateTask();
  mTask.SetInputEnabled(false);
  mTask.SetClearColor(Vector4(0.5f, 0.5f, 0.5f, 1.0f));
  mTask.SetClearEnabled(true);

  mCameraActor = CameraActor::New();
  mCameraActor.SetType(Camera::FREE_LOOK);
  mCameraActor.SetRotation(Quaternion(M_PI, Vector3::YAXIS)); // Look at stage

  stage.Add(mCameraActor);
  mTask.SetCameraActor( mCameraActor );

  SetFrameVisibility(true);
}
static void UtcDaliKeyInputFocusManagerSignalKeyInputFocusChanged()
{
  ToolkitTestApplication application;
  KeyInputFocusManager manager = KeyInputFocusManager::Get();
  Stage stage = Stage::GetCurrent();

  tet_infoline(" UtcDaliKeyInputFocusManagerSignalKeyInputFocusChanged");

  PushButton pushButton1 = PushButton::New();
  PushButton pushButton2 = PushButton::New();

  stage.Add( pushButton1 );
  stage.Add( pushButton2 );

  PushButton gainActor, lostActor;
  KeyInputFocusChangedCallback callback( gainActor, lostActor );
  manager.KeyInputFocusChangedSignal().Connect( &callback, &KeyInputFocusChangedCallback::Callback );

  manager.SetFocus(pushButton1);

  DALI_TEST_CHECK( gainActor == pushButton1 );
  DALI_TEST_CHECK( lostActor == Control() );

  gainActor = lostActor = NULL;

  manager.SetFocus(pushButton2);

  DALI_TEST_CHECK( gainActor == pushButton2 );
  DALI_TEST_CHECK( lostActor == pushButton1 );

  gainActor = lostActor = NULL;

  // Removing the focus actor from the stage would also result in signal emission.
  stage.Remove( pushButton1 );
  stage.Remove( pushButton2 );

  DALI_TEST_CHECK( gainActor == Control() );
  DALI_TEST_CHECK( lostActor == Control() );
}
Esempio n. 25
0
int UtcDaliStageAddN(void)
{
  TestApplication application;

  Stage stage = Stage::GetCurrent();
  Actor actor;

  bool asserted = false;
  try
  {
    stage.Add( actor );
  }
  catch( Dali::DaliException& e )
  {
    DALI_TEST_PRINT_ASSERT( e );
    DALI_TEST_ASSERT( e, "actor && \"Actor handle is empty\"", TEST_LOCATION );
    asserted = true;
  }

  DALI_TEST_CHECK( asserted );

  END_TEST;
}
Esempio n. 26
0
  bool OnButtonClicked( Toolkit::Button button )
  {
    if ( mLabel4 )
    {
      UnparentAndReset( mLabel4 );
    }

    if ( !mContainer4 )
    {
      CreateContainer ( mContainer4 , mLayoutSize);
      Stage stage = Stage::GetCurrent();
      Vector2 stageSize = stage.GetSize();
      mContainer4.SetPosition( 0, stageSize.height*0.25f*3 );
      stage.Add( mContainer4 );
      // Info
      CreateContainer ( mContainer4Info , mLayoutSize );
      mContainer4Info.SetParentOrigin( ParentOrigin::TOP_RIGHT );
      mContainer4.Add( mContainer4Info );
      CreateTextLabel ( mLabel4Info, "system free", Color::BLACK, true  );
      mContainer4Info.Add ( mLabel4Info );
    }

    if ( mToggle )
    {
      CreateTextLabel ( mLabel4, LABEL_TEXT_KOREAN, Color::WHITE );
      mToggle = false;
    }
    else
    {
      CreateTextLabel ( mLabel4, LABEL_TEXT_MIXED, Color::WHITE );
      mToggle = true;
    }

    mContainer4.Add( mLabel4 );

    return true;
  }
Esempio n. 27
0
void BubbleEmitter::OnInitialize()
{
  // Create the root actor, all the meshActor should be its children
  mBubbleRoot = Actor::New();
  mBubbleRoot.SetSize(mMovementArea);

  // Prepare the frame buffer to store the color adjusted background image
  mEffectImage = FrameBufferImage::New( mMovementArea.width/4.f, mMovementArea.height/4.f, Pixel::RGBA8888, Dali::Image::UNUSED );

  // Generate the geometry, which is used by all bubbleActors
  mMeshGeometry =  CreateGeometry( mNumBubblePerActor*mDensity );

  Shader bubbleShader = CreateBubbleShader (mNumBubblePerActor );

  mMaterial = Material::New( bubbleShader );
  mMaterial.AddTexture( mEffectImage, "sBackground" );
  mMaterial.AddTexture( mShapeImage,  "sBubbleShape" );

  mBubbleActors.resize( mNumActor );

  // Create the meshActor group and bubbleEffect group to emit bubbles following the given track, such as finger touch track.
  for(unsigned int i=0; i < mNumActor; i++ )
  {
    mBubbleActors[i] = new BubbleActor( mNumBubblePerActor, mMovementArea );
    (mBubbleActors[i])->MakeRenderable( mMeshGeometry, mMaterial );
    mBubbleRoot.Add( (mBubbleActors[i])->GetMeshActor() );
  }

  // Create a cameraActor for the off screen render task.
  mCameraActor = CameraActor::New(mMovementArea);
  mCameraActor.SetParentOrigin(ParentOrigin::CENTER);

  Stage stage = Stage::GetCurrent();

  stage.Add(mCameraActor);
  stage.ContextRegainedSignal().Connect(this, &BubbleEmitter::OnContextRegained);
}
// Positive test case for a method
int UtcDaliHitTestAlgorithmWithFunctor(void)
{
  TestApplication application;
  tet_infoline("Testing Dali::HitTestAlgorithm functor");

  Stage stage = Stage::GetCurrent();

  Actor actor = Actor::New();
  actor.SetSize(100.0f, 100.0f);
  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
  actor.SetName("NonHittableActor");
  stage.Add(actor);

  // Render and notify
  application.SendNotification();
  application.Render();

  Vector2 screenCoordinates( 10.0f, 10.0f );
  Vector2 localCoordinates;
  actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );

  // Perform a hit-test at the given screen coordinates
  Dali::HitTestAlgorithm::Results results;
  Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
  DALI_TEST_CHECK( results.actor != actor );

  actor.SetName("HittableActor");

  results.actor = Actor();
  results.actorCoordinates = Vector2::ZERO;

  // Perform a hit-test at the given screen coordinates
  Dali::HitTestAlgorithm::HitTest( stage, screenCoordinates, results, IsActorHittableFunction );
  DALI_TEST_CHECK( results.actor == actor );
  DALI_TEST_EQUALS( localCoordinates, results.actorCoordinates, 0.1f, TEST_LOCATION );
  END_TEST;
}
Esempio n. 29
0
int UtcDaliStageGetRootLayerN(void)
{
  TestApplication application;

  Stage stage = Stage::GetCurrent();

  Layer rootLayer = stage.GetLayer( 0 );
  DALI_TEST_CHECK( rootLayer );
  DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );

  // Create a new layer and attempt to lower it below the root layer.
  Layer layer = Layer::New();
  stage.Add( layer );
  layer.LowerToBottom();

  // Check that GetRootLayer still retrieves the same original layer.
  DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );

  // Check modifying the root layer is also blocked.
  rootLayer.RaiseToTop();
  DALI_TEST_CHECK( stage.GetRootLayer() == rootLayer );

  END_TEST;
}
Esempio n. 30
0
  // The Init signal is received once (only) during the Application lifetime
  void Create( Application& application )
  {
    //std::cout << "HelloWorldController::Create" << std::endl;

    // Get a handle to the stage
    Stage stage = Stage::GetCurrent();

    //ImageActor bgActor = ImageActor::New(CreateBitmapImage(480, 800));
    Control  bgActor = Control::New();
    bgActor.SetSize(64 * STAGE_COL, 64 * STAGE_ROW);
    //bgActor.SetBackgroundColor(Vector4(.125f, .125f, .125f, 1.f));
    bgActor.SetBackgroundColor(Vector4(1.f, 1.f, 1.f, 1.f));
    bgActor.SetParentOrigin(ParentOrigin::CENTER);
    bgActor.SetAnchorPoint(AnchorPoint::CENTER);
    bgActor.SetZ(0.1f);
    //stage.Add(bgActor);

    ResourceImage spriteImage = ResourceImage::New(PUYO_IMAGE);

    // background
    {
      ResourceImage image = ResourceImage::New(BACKGROUND_IMAGE);
      ImageActor actor = ImageActor::New(image);
      actor.SetParentOrigin(ParentOrigin::BOTTOM_LEFT);
      actor.SetAnchorPoint(AnchorPoint::BOTTOM_LEFT);
      stage.Add(actor);
    }

    // sprites
    {
      ImageActor actor[STAGE_COL * STAGE_ROW];

      for (int i = 0; i < STAGE_ROW; i++)
      {
        for (int j = 0; j < STAGE_COL; j++)
        {
          actor[i * STAGE_COL + j] = ImageActor::New(spriteImage, PUYO_OFFSET[int(Random::Range(0.f, NUM_PUYO))]);
          actor[i * STAGE_COL + j].SetParentOrigin(ParentOrigin::BOTTOM_LEFT);
          actor[i * STAGE_COL + j].SetAnchorPoint(AnchorPoint::BOTTOM_LEFT);
          actor[i * STAGE_COL + j].SetX(i * 60.f);
          actor[i * STAGE_COL + j].SetY(j * -1.f * 60.f);
          actor[i * STAGE_COL + j].SetZ(0.1f);
          stage.Add(actor[i * STAGE_COL + j]);
        }
      }

#if 0
      Animation anim = Animation::New(1.f);

      for (int i = 0; i < STAGE_ROW; i++)
      {
        for (int j = 0; j < STAGE_COL; j++)
        {
          anim.MoveBy(actor[i * STAGE_COL + j], Vector3(0.f, j * _(7), 0.1f), AlphaFunctions::Bounce);
          anim.Resize(actor[i * STAGE_COL + j], _(32), _(25), AlphaFunctions::Bounce);
          anim.SetLooping(true);
        }
      }
      anim.Play();
#endif
    }

    {
      ImageActor actor = ImageActor::New(spriteImage, ImageActor::PixelArea(0, 224, 64, 64));
      actor.SetParentOrigin(ParentOrigin::CENTER);
      actor.SetAnchorPoint(AnchorPoint::CENTER);
      actor.SetSize(_(32), _(32));
      actor.SetZ(0.1f);
      //stage.Add(actor);
    }

    // Respond to a click anywhere on the stage
    stage.GetRootLayer().TouchedSignal().Connect( this, &HelloWorldController::OnTouch );
  }