Updated demos to use DALi clang-format
[platform/core/uifw/dali-demo.git] / examples / simple-bitmap-font-text-label / simple-text-label-example.cpp
index a7f6ff0..1e7cdf3 100644 (file)
@@ -23,9 +23,9 @@
 // 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;
@@ -36,12 +36,11 @@ 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()
@@ -52,7 +51,7 @@ public:
   /**
    * One-time setup in response to Application InitSignal.
    */
-  void Create( Application& application )
+  void Create(Application& application)
   {
     Window window = application.GetWindow();
 
@@ -61,111 +60,109 @@ public:
     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.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.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");
 
-    window.Add( label01 );
+    label01.SetBackgroundColor(Color::BLACK);
 
+    window.Add(label01);
 
-    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 );
+    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);
 
-    window.Add( label02 );
+    window.Add(label02);
 
-    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 );
+    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);
 
-    window.Add( label03 );
+    window.Add(label03);
 
-    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 );
+    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);
 
-    window.Add( label04 );
- }
+    window.Add(label04);
 }
 
   /**
    * Main key event handler
@@ -174,7 +171,7 @@ 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();
       }
@@ -182,23 +179,22 @@ public:
   }
 
 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;
 }