TextLabel demo 12/34912/15
authorPaul Wisbey <p.wisbey@samsung.com>
Tue, 27 Jan 2015 09:38:21 +0000 (09:38 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Fri, 13 Feb 2015 14:18:09 +0000 (14:18 +0000)
Change-Id: I6b62f7b114ac959fcec3ab1e9381684c1fad8dff

build/tizen/examples/Makefile.am
demo/dali-table-view.cpp
examples/text/text-label-example.cpp [new file with mode: 0644]

index e098223..f85d06d 100644 (file)
@@ -36,7 +36,8 @@ bin_PROGRAMS = \
                builder.example \
                image-scaling-irregular-grid.example \
                buttons.example \
-               logging.example
+               logging.example \
+               text-label.example
 
 daliimagedir = $(appdatadir)/images/
 dalimodeldir = $(appdatadir)/models/
@@ -169,3 +170,8 @@ logging_example_SOURCES = $(examples_src_dir)/logging/logging-example.cpp
 logging_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS)
 logging_example_DEPENDENCIES = $(EXAMPLE_DEPS)
 logging_example_LDADD = $(EXAMPLE_LDADD)
+
+text_label_example_SOURCES = $(examples_src_dir)/text/text-label-example.cpp
+text_label_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS)
+text_label_example_DEPENDENCIES = $(EXAMPLE_DEPS)
+text_label_example_LDADD = $(EXAMPLE_LDADD)
index fb95d3f..f8755c8 100644 (file)
@@ -521,6 +521,14 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit
     image.Add( stencil );
   }
 
+    TextLabel label = TextLabel::New();
+    label.SetParentOrigin( ParentOrigin::TOP_LEFT );
+    label.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+    label.SetProperty( TextLabel::PROPERTY_MULTI_LINE, true );
+    label.SetProperty( TextLabel::PROPERTY_TEXT, title );
+    label.SetColor( Color::WHITE );
+    content.Add( label );
+
   // Set the tile to be keyboard focusable
   tile.SetKeyboardFocusable(true);
 
diff --git a/examples/text/text-label-example.cpp b/examples/text/text-label-example.cpp
new file mode 100644 (file)
index 0000000..ebb34b7
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file text-label-example.cpp
+ * @brief Basic usage of TextLabel control
+ */
+
+// EXTERNAL INCLUDES
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/public-api/text-abstraction/text-abstraction.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+/**
+ * @brief The main class of the demo.
+ */
+class TextLabelExample : public ConnectionTracker
+{
+public:
+
+  TextLabelExample( Application& application )
+  : mApplication( application )
+  {
+    // Connect to the Application's Init signal
+    mApplication.InitSignal().Connect( this, &TextLabelExample::Create );
+  }
+
+  ~TextLabelExample()
+  {
+    // Nothing to do here.
+  }
+
+  /**
+   * One-time setup in response to Application InitSignal.
+   */
+  void Create( Application& application )
+  {
+    Stage stage = Stage::GetCurrent();
+
+    TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+    fontClient.SetDpi( 96, 96 );
+
+    TextLabel label = TextLabel::New();
+    label.SetParentOrigin( ParentOrigin::CENTER );
+    stage.Add( label );
+
+    label.SetProperty( TextLabel::PROPERTY_MULTI_LINE, true );
+
+    label.SetProperty( TextLabel::PROPERTY_TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog" );
+
+    // TODO
+    //Property::Value labelText = label.GetProperty( TextLabel::PROPERTY_TEXT );
+    //std::cout << "Got text from label: " << labelText.Get< std::string >() << std::endl;
+  }
+
+private:
+
+  Application& mApplication;
+};
+
+void RunTest( Application& application )
+{
+  TextLabelExample 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;
+}