X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftext-label-emojis%2Ftext-label-emojis.cpp;h=f5415b28d0628c87d1803a071b8b6eed0a20def6;hb=ddab1b8fbe52f9223389e36d764d6ef8112c42a6;hp=8f0dd67b3c33609d87d6ba2a07ecc3d91535dd5f;hpb=d6ad9aff913e3d14eb832c105d29cd179e40ae60;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/text-label-emojis/text-label-emojis.cpp b/examples/text-label-emojis/text-label-emojis.cpp index 8f0dd67..f5415b2 100644 --- a/examples/text-label-emojis/text-label-emojis.cpp +++ b/examples/text-label-emojis/text-label-emojis.cpp @@ -15,16 +15,13 @@ * */ -// INTERNAL INCLUDES - -#include "vertical-layout.h" -#include "emoji-strings.h" - // EXTERNAL INCLUDES #include -#include #include +// INTERNAL INCLUDES +#include "emoji-strings.h" + using namespace Dali; using namespace Dali::Toolkit; using namespace EmojiStrings; @@ -57,53 +54,52 @@ public: // The Init signal is received once (only) during the Application lifetime void Create( Application& application ) { - - mLayout = VerticalLayout::New(); - mLayout.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mLayout.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage stage = Stage::GetCurrent(); - stage.Add( mLayout ); + 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.TouchSignal().Connect( this, &EmojiExample::OnTouch ); + 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(); + + TextLabel label = TextLabel::New( text ); label.SetParentOrigin( ParentOrigin::TOP_CENTER ); label.SetAnchorPoint( AnchorPoint::TOP_CENTER ); label.SetProperty( TextLabel::Property::MULTI_LINE, true ); - label.SetProperty( TextLabel::Property::TEXT, text ); - mLayout.AddLabel( label ); - mLayout.TouchedSignal().Connect( this, &EmojiExample::OnTouchEvent ); - } - - const Vector2& size = stage.GetSize(); - const float height = mLayout.GetHeightForWidth( size.width ); - mLayout.SetSize( Size( size.width, height ) ); - mLayout.TouchedSignal().Connect( this, &EmojiExample::OnTouchEvent ); + mTableView.SetFitHeight( index ); + mTableView.AddChild( label, Toolkit::TableView::CellPosition( index, 0 ) ); + } } - bool OnTouchEvent( Actor actor, const TouchEvent& event ) + bool OnTouch( Actor actor, const TouchData& event ) { if( 1u == event.GetPointCount() ) { - const TouchPoint::State state = event.GetPoint(0u).state; + const PointState::Type state = event.GetState( 0 ); // Clamp to integer values; this is to reduce flicking due to pixel misalignment - const float localPoint = static_cast( static_cast( event.GetPoint( 0 ).local.y ) ); + const float localPoint = static_cast( static_cast( event.GetLocalPosition( 0 ).y ) ); - if( TouchPoint::Down == state ) + if( PointState::DOWN == state ) { mLastPoint = localPoint; mAnimation = Animation::New( 0.25f ); } - else if( TouchPoint::Motion == state ) + else if( PointState::MOTION == state ) { if( mAnimation ) { - mAnimation.MoveBy( mLayout, Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunctions::Linear ); + mAnimation.AnimateBy( Property(mTableView, Actor::Property::POSITION), Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunction::LINEAR ); mAnimation.Play(); mLastPoint = localPoint; } @@ -130,7 +126,7 @@ public: private: Application& mApplication; - VerticalLayout mLayout; + TableView mTableView; Animation mAnimation; float mLastPoint; }; @@ -144,9 +140,9 @@ void RunTest( Application& application ) // Entry point for Linux & SLP applications // -int main( int argc, char **argv ) +int DALI_EXPORT_API main( int argc, char **argv ) { - Application application = Application::New( &argc, &argv ); + Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); RunTest( application );