/*
- * Copyright (c) 2019 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.
// EXTERNAL INCLUDES
#include <dali-toolkit/dali-toolkit.h>
-#include <dali/devel-api/text-abstraction/font-client.h>
-#include <dali/devel-api/text-abstraction/bitmap-font.h>
#include <dali-toolkit/devel-api/text/bitmap-font.h>
+#include <dali/devel-api/text-abstraction/bitmap-font.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
using namespace Dali;
using namespace Dali::Toolkit;
class SimpleTextLabelExample : public ConnectionTracker
{
public:
-
- SimpleTextLabelExample( Application& application )
- : mApplication( application )
+ SimpleTextLabelExample(Application& application)
+ : mApplication(application)
{
// Connect to the Application's Init signal
- mApplication.InitSignal().Connect( this, &SimpleTextLabelExample::Create );
+ mApplication.InitSignal().Connect(this, &SimpleTextLabelExample::Create);
}
~SimpleTextLabelExample()
/**
* One-time setup in response to Application InitSignal.
*/
- void Create( Application& application )
+ void Create(Application& application)
{
- Stage stage = Stage::GetCurrent();
+ Window window = application.GetWindow();
- stage.KeyEventSignal().Connect(this, &SimpleTextLabelExample::OnKeyEvent);
+ window.KeyEventSignal().Connect(this, &SimpleTextLabelExample::OnKeyEvent);
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
DevelText::BitmapFontDescription fontDescription;
- fontDescription.name = "Digits";
- fontDescription.underlinePosition = 0.f;
+ fontDescription.name = "Digits";
+ fontDescription.underlinePosition = 0.f;
fontDescription.underlineThickness = 0.f;
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0030.png", "0", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0031.png", "1", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0032.png", "2", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0033.png", "3", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0034.png", "4", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0035.png", "5", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0036.png", "6", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0037.png", "7", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0038.png", "8", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0039.png", "9", 34.f, 0.f } );
- fontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u003a.png", ":", 34.f, 0.f } );
-
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0030.png", "0", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0031.png", "1", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0032.png", "2", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0033.png", "3", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0034.png", "4", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0035.png", "5", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0036.png", "6", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0037.png", "7", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0038.png", "8", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0039.png", "9", 34.f, 0.f});
+ fontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u003a.png", ":", 34.f, 0.f});
DevelText::BitmapFontDescription colorFontDescription;
- colorFontDescription.name = "DigitsColor";
- colorFontDescription.underlinePosition = 0.f;
+ colorFontDescription.name = "DigitsColor";
+ colorFontDescription.underlinePosition = 0.f;
colorFontDescription.underlineThickness = 0.f;
- colorFontDescription.isColorFont = true;
-
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0030_color.png", "0", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0031_color.png", "1", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0032_color.png", "2", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0033_color.png", "3", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0034_color.png", "4", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0035_color.png", "5", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0036_color.png", "6", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0037_color.png", "7", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0038_color.png", "8", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u0039_color.png", "9", 34.f, 0.f } );
- colorFontDescription.glyphs.push_back( { DEMO_IMAGE_DIR "u003a_color.png", ":", 34.f, 0.f } );
+ colorFontDescription.isColorFont = true;
+
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0030_color.png", "0", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0031_color.png", "1", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0032_color.png", "2", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0033_color.png", "3", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0034_color.png", "4", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0035_color.png", "5", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0036_color.png", "6", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0037_color.png", "7", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0038_color.png", "8", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u0039_color.png", "9", 34.f, 0.f});
+ colorFontDescription.glyphs.push_back({DEMO_IMAGE_DIR "u003a_color.png", ":", 34.f, 0.f});
TextAbstraction::BitmapFont bitmapFont;
TextAbstraction::BitmapFont bitmapColorFont;
- DevelText::CreateBitmapFont( fontDescription, bitmapFont );
- DevelText::CreateBitmapFont( colorFontDescription, bitmapColorFont );
+ DevelText::CreateBitmapFont(fontDescription, bitmapFont);
+ DevelText::CreateBitmapFont(colorFontDescription, bitmapColorFont);
- fontClient.GetFontId( bitmapFont );
- fontClient.GetFontId( bitmapColorFont );
+ fontClient.GetFontId(bitmapFont);
+ fontClient.GetFontId(bitmapColorFont);
TextLabel label01 = TextLabel::New();
- label01.SetAnchorPoint( AnchorPoint::CENTER );
- label01.SetParentOrigin( ParentOrigin::CENTER );
- label01.SetSize( 400.f, 50.f );
- label01.SetPosition( 0.f, -100.f );
- label01.SetProperty( TextLabel::Property::MULTI_LINE, true );
-
- label01.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
- label01.SetProperty( TextLabel::Property::TEXT, "012<color 'value'='green'>345</color>6789:" );
- label01.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
- label01.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
+ label01.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ label01.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ label01.SetProperty(Actor::Property::SIZE, Vector2(400.f, 50.f));
+ label01.SetProperty(Actor::Property::POSITION, Vector2(0.f, -100.f));
+ label01.SetProperty(TextLabel::Property::MULTI_LINE, true);
- label01.SetBackgroundColor( Color::BLACK );
+ label01.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
+ label01.SetProperty(TextLabel::Property::TEXT, "012<color 'value'='green'>345</color>6789:");
+ label01.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
+ label01.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
- stage.Add( label01 );
+ label01.SetBackgroundColor(Color::BLACK);
+ window.Add(label01);
- TextLabel label02 = TextLabel::New();
- label02.SetAnchorPoint( AnchorPoint::CENTER );
- label02.SetParentOrigin( ParentOrigin::CENTER );
- label02.SetSize( 400.f, 50.f );
- label02.SetPosition( 0.f, -50.f );
- label02.SetProperty( TextLabel::Property::MULTI_LINE, true );
+ TextLabel label02 = TextLabel::New();
+ label02.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ label02.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ label02.SetProperty(Actor::Property::SIZE, Vector2(400.f, 50.f));
+ label02.SetProperty(Actor::Property::POSITION, Vector2(0.f, -50.f));
+ label02.SetProperty(TextLabel::Property::MULTI_LINE, true);
- label02.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
- label02.SetProperty( TextLabel::Property::TEXT_COLOR, Color::WHITE );
- label02.SetProperty( TextLabel::Property::FONT_FAMILY, "DigitsColor" );
+ label02.SetProperty(TextLabel::Property::TEXT, "0123456789:");
+ label02.SetProperty(TextLabel::Property::TEXT_COLOR, Color::WHITE);
+ label02.SetProperty(TextLabel::Property::FONT_FAMILY, "DigitsColor");
- label02.SetBackgroundColor( Color::BLACK );
+ label02.SetBackgroundColor(Color::BLACK);
- stage.Add( label02 );
+ window.Add(label02);
- TextLabel label03 = TextLabel::New();
- label03.SetAnchorPoint( AnchorPoint::CENTER );
- label03.SetParentOrigin( ParentOrigin::CENTER );
- label03.SetSize( 400.f, 50.f );
- label03.SetPosition( 0.f, 0.f );
- label03.SetProperty( TextLabel::Property::MULTI_LINE, true );
+ TextLabel label03 = TextLabel::New();
+ label03.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ label03.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ label03.SetProperty(Actor::Property::SIZE, Vector2(400.f, 50.f));
+ label03.SetProperty(Actor::Property::POSITION, Vector2(0.f, 0.f));
+ label03.SetProperty(TextLabel::Property::MULTI_LINE, true);
- label03.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
- label03.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
+ label03.SetProperty(TextLabel::Property::TEXT, "0123456789:");
+ label03.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
- label03.SetBackgroundColor( Color::WHITE );
+ label03.SetBackgroundColor(Color::WHITE);
- stage.Add( label03 );
+ window.Add(label03);
- TextLabel label04 = TextLabel::New();
- label04.SetAnchorPoint( AnchorPoint::CENTER );
- label04.SetParentOrigin( ParentOrigin::CENTER );
- label04.SetSize( 400.f, 50.f );
- label04.SetPosition( 0.f, 50.f );
- label04.SetProperty( TextLabel::Property::MULTI_LINE, true );
+ TextLabel label04 = TextLabel::New();
+ label04.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
+ label04.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+ label04.SetProperty(Actor::Property::SIZE, Vector2(400.f, 50.f));
+ label04.SetProperty(Actor::Property::POSITION, Vector2(0.f, 50.f));
+ label04.SetProperty(TextLabel::Property::MULTI_LINE, true);
- label04.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
- label04.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
- label04.SetProperty( TextLabel::Property::TEXT_COLOR, Color::WHITE );
+ label04.SetProperty(TextLabel::Property::TEXT, "0123456789:");
+ label04.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
+ label04.SetProperty(TextLabel::Property::TEXT_COLOR, Color::WHITE);
- label04.SetBackgroundColor( Color::BLACK );
+ label04.SetBackgroundColor(Color::BLACK);
- stage.Add( label04 );
- }
+ window.Add(label04);
+ }
/**
* Main key event handler
*/
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 ) )
+ if(IsKey(event, DALI_KEY_ESCAPE) || IsKey(event, DALI_KEY_BACK))
{
mApplication.Quit();
}
}
private:
-
Application& mApplication;
};
-void RunTest( Application& application )
+void RunTest(Application& application)
{
- SimpleTextLabelExample test( application );
+ SimpleTextLabelExample test(application);
application.MainLoop();
}
/** Entry point for Linux & Tizen applications */
-int DALI_EXPORT_API 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);
- RunTest( application );
+ RunTest(application);
return 0;
}