X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-demo.git;a=blobdiff_plain;f=examples%2Ftext-label-emojis%2Ftext-label-emojis.cpp;h=21f5907ac77101027f2573d9b52d8e19e99b31d2;hp=a9801e422b74a71c65b254acc000177639694514;hb=1b19fd140ff139b5854a1a62447faf31b175d8f6;hpb=b26d446b0cb6a316abc3a79d4fc70d0ae1b7994c diff --git a/examples/text-label-emojis/text-label-emojis.cpp b/examples/text-label-emojis/text-label-emojis.cpp index a9801e4..21f5907 100644 --- a/examples/text-label-emojis/text-label-emojis.cpp +++ b/examples/text-label-emojis/text-label-emojis.cpp @@ -27,7 +27,7 @@ using namespace Dali; using namespace Dali::Toolkit; using namespace EmojiStrings; - // TODO Need to expose Text::RENDER..... +// TODO Need to expose Text::RENDER..... const int ATLAS_RENDERER = 0; // This example shows how to create and display Hello World! using a simple TextActor @@ -35,17 +35,16 @@ const int ATLAS_RENDERER = 0; class EmojiExample : public ConnectionTracker { public: - typedef uint32_t SizeType; - EmojiExample( Application& application ) - : mApplication( application ), - mLastPoint( 0.0f ) + EmojiExample(Application& application) + : mApplication(application), + mLastPoint(0.0f) { std::cout << "EmoticonController::EmoticonController" << std::endl; // Connect to the Application's Init signal - mApplication.InitSignal().Connect( this, &EmojiExample::Create ); + mApplication.InitSignal().Connect(this, &EmojiExample::Create); } ~EmojiExample() @@ -54,54 +53,54 @@ public: } // The Init signal is received once (only) during the Application lifetime - void Create( Application& application ) + void Create(Application& application) { Window window = application.GetWindow(); - window.SetBackgroundColor( Color::WHITE ); + window.SetBackgroundColor(Color::WHITE); window.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.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); - mTableView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); - mTableView.TouchedSignal().Connect( this, &EmojiExample::OnTouch ); - window.Add( mTableView ); + 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.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT); + mTableView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + mTableView.TouchedSignal().Connect(this, &EmojiExample::OnTouch); + window.Add(mTableView); - for( unsigned int index = 0u; index < NUMBER_OF_EMOJIS; ++index ) + for(unsigned int index = 0u; index < NUMBER_OF_EMOJIS; ++index) { - const Emoji& emoji = EMOJIS[index]; - const std::string text = emoji.mUTF8 + " " + emoji.mDescription; + const Emoji& emoji = EMOJIS[index]; + const std::string text = emoji.mUTF8 + " " + emoji.mDescription; - TextLabel label = TextLabel::New( text ); - label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER ); - label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER ); - label.SetProperty( TextLabel::Property::MULTI_LINE, true ); + TextLabel label = TextLabel::New(text); + label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER); + label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER); + label.SetProperty(TextLabel::Property::MULTI_LINE, true); - mTableView.SetFitHeight( index ); - mTableView.AddChild( label, Toolkit::TableView::CellPosition( index, 0 ) ); + mTableView.SetFitHeight(index); + mTableView.AddChild(label, Toolkit::TableView::CellPosition(index, 0)); } } - bool OnTouch( Actor actor, const TouchEvent& event ) + bool OnTouch(Actor actor, const TouchEvent& event) { - if( 1u == event.GetPointCount() ) + if(1u == event.GetPointCount()) { - const PointState::Type state = event.GetState( 0 ); + 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.GetLocalPosition( 0 ).y ) ); + const float localPoint = static_cast(static_cast(event.GetLocalPosition(0).y)); - if( PointState::DOWN == state ) + if(PointState::DOWN == state) { mLastPoint = localPoint; - mAnimation = Animation::New( 0.25f ); + mAnimation = Animation::New(0.25f); } - else if( PointState::MOTION == state ) + else if(PointState::MOTION == state) { - if( mAnimation ) + if(mAnimation) { - mAnimation.AnimateBy( Property(mTableView, Actor::Property::POSITION), Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunction::LINEAR ); + mAnimation.AnimateBy(Property(mTableView, Actor::Property::POSITION), Vector3(0.f, localPoint - mLastPoint, 0.f), AlphaFunction::LINEAR); mAnimation.Play(); mLastPoint = localPoint; } @@ -118,25 +117,24 @@ public: { if(event.GetState() == KeyEvent::DOWN) { - if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) ) + if(IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK)) { mApplication.Quit(); } } } - private: - Application& mApplication; - TableView mTableView; - Animation mAnimation; - float mLastPoint; + Application& mApplication; + TableView mTableView; + Animation mAnimation; + float mLastPoint; }; -int DALI_EXPORT_API main( int argc, char **argv ) +int DALI_EXPORT_API main(int argc, char** argv) { - Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); - EmojiExample test( application ); + Application application = Application::New(&argc, &argv, DEMO_THEME_PATH); + EmojiExample test(application); application.MainLoop(); return 0; }