X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftext-label-multi-language%2Ftext-label-multi-language-example.cpp;h=abe62fe16e23c9c2b3437cd3a53f199d5f65f2b5;hb=1a473d5189ca7e7d55aca3a64a8a4ff2dc3b6c67;hp=27c54225cf2fd9bf6f5709fc7172903c92083370;hpb=bc208134da08d558201015e2f36efa50e718ed4a;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/text-label-multi-language/text-label-multi-language-example.cpp b/examples/text-label-multi-language/text-label-multi-language-example.cpp index 27c5422..abe62fe 100644 --- a/examples/text-label-multi-language/text-label-multi-language-example.cpp +++ b/examples/text-label-multi-language/text-label-multi-language-example.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. @@ -20,13 +20,13 @@ * @brief Basic usage of TextLabel control */ -// INTERNAL INCLUDES -#include "vertical-layout.h" -#include "shared/multi-language-strings.h" - // EXTERNAL INCLUDES #include -#include +#include + +// INTERNAL INCLUDES +#include "shared/multi-language-strings.h" +#include "shared/view.h" using namespace Dali; using namespace Dali::Toolkit; @@ -57,58 +57,53 @@ public: */ void Create( Application& application ) { - Stage stage = Stage::GetCurrent(); + Window window = application.GetWindow(); - stage.KeyEventSignal().Connect(this, &TextLabelMultiLanguageExample::OnKeyEvent); + window.KeyEventSignal().Connect(this, &TextLabelMultiLanguageExample::OnKeyEvent); + window.SetBackgroundColor( Color::WHITE ); - mLayout = VerticalLayout::New(); - mLayout.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mLayout.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - - stage.Add( mLayout ); + 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.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + mTableView.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + mTableView.TouchedSignal().Connect( this, &TextLabelMultiLanguageExample::OnTouch ); + window.Add( mTableView ); for( unsigned int index = 0u; index < NUMBER_OF_LANGUAGES; ++index ) { const Language& language = LANGUAGES[index]; TextLabel label = TextLabel::New(); - label.SetParentOrigin( ParentOrigin::TOP_CENTER ); - label.SetAnchorPoint( AnchorPoint::TOP_CENTER ); - label.SetProperty( TextLabel::Property::MULTI_LINE, true ); const std::string text = language.languageName + " " + language.languageRomanName + " " + language.text; - label.SetProperty( TextLabel::Property::TEXT, text ); - mLayout.AddLabel( label ); - mLayout.TouchedSignal().Connect( this, &TextLabelMultiLanguageExample::OnTouchEvent ); + mTableView.SetFitHeight( index ); + mTableView.AddChild( label, Toolkit::TableView::CellPosition( index, 0 ) ); } - - const Vector2& size = Stage::GetCurrent().GetSize(); - const float height = mLayout.GetHeightForWidth( size.width ); - mLayout.SetSize( Size( size.width, height ) ); } - 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 ) { - 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; } @@ -123,7 +118,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 ) ) { @@ -135,24 +130,15 @@ public: private: Application& mApplication; - VerticalLayout mLayout; + TableView mTableView; Animation mAnimation; float mLastPoint; }; -void RunTest( Application& application ) +int DALI_EXPORT_API main( int argc, char **argv ) { + Application application = Application::New( &argc, &argv, DEMO_THEME_PATH ); TextLabelMultiLanguageExample test( application ); - application.MainLoop(); -} - -/** Entry point for Linux & Tizen applications */ -int main( int argc, char **argv ) -{ - Application application = Application::New( &argc, &argv ); - - RunTest( application ); - return 0; }