X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftext-label-emojis%2Ftext-label-emojis.cpp;h=9ec53d231ca03535862871ce8c3a0843386d0418;hb=4f818cd12c9bf2773d44e5cfdc2fc0a344abf7f5;hp=30239741de45b5270aa60254065af3e9d687f57c;hpb=c9273e4023e21144a0b609aa090fe51ec706a45f;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 3023974..9ec53d2 100644 --- a/examples/text-label-emojis/text-label-emojis.cpp +++ b/examples/text-label-emojis/text-label-emojis.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ // EXTERNAL INCLUDES #include -#include +#include #include // INTERNAL INCLUDES @@ -39,7 +39,8 @@ public: typedef uint32_t SizeType; EmojiExample( Application& application ) - : mApplication( application ) + : mApplication( application ), + mLastPoint( 0.0f ) { std::cout << "EmoticonController::EmoticonController" << std::endl; @@ -55,16 +56,17 @@ public: // The Init signal is received once (only) during the Application lifetime void Create( Application& application ) { - Stage stage = Stage::GetCurrent(); - stage.KeyEventSignal().Connect(this, &EmojiExample::OnKeyEvent); + Window window = application.GetWindow(); + 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.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mTableView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mTableView.TouchedSignal().Connect( this, &EmojiExample::OnTouchEvent ); - stage.Add( mTableView ); + mTableView.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + mTableView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + mTableView.TouchSignal().Connect( this, &EmojiExample::OnTouch ); + window.Add( mTableView ); for( unsigned int index = 0u; index < NUMBER_OF_EMOJIS; ++index ) { @@ -72,8 +74,8 @@ public: 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( 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 ); @@ -81,21 +83,21 @@ public: } } - bool OnTouchEvent( Actor actor, const TouchEvent& event ) + bool OnTouch( Actor actor, const TouchEvent& 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 ) { @@ -114,7 +116,7 @@ public: */ void OnKeyEvent(const KeyEvent& event) { - if(event.state == KeyEvent::Down) + if(event.GetState() == KeyEvent::DOWN) { if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) ) { @@ -131,20 +133,10 @@ private: float mLastPoint; }; -void RunTest( Application& application ) +int DALI_EXPORT_API main( int argc, char **argv ) { + Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); EmojiExample test( application ); - application.MainLoop(); -} - -// Entry point for Linux & SLP applications -// -int main( int argc, char **argv ) -{ - Application application = Application::New( &argc, &argv ); - - RunTest( application ); - return 0; }