// First radio button
{
Toolkit::TableView tableView = Toolkit::TableView::New( 1, 2 );
- tableView.SetPreferredSize( Vector2( DP(260), 0.0f ) );
+ tableView.SetSize( DP(260), 0.0f );
tableView.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
- Toolkit::TextView textView = Toolkit::TextView::New( "Select enabled" );
- tableView.AddChild( textView, Toolkit::TableView::CellPosition( 0, 0 ) );
+ Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( "Select enabled" );
+ tableView.AddChild( textLabel, Toolkit::TableView::CellPosition( 0, 0 ) );
ImageActor imageActor = ImageActor::New( ResourceImage::New( ENABLED_IMAGE ) );
- imageActor.SetPreferredSize( Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) );
+ imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
imageActor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
imageActor.SetPadding( Padding( DP(20.0f), 0.0f, 0.0f, 0.0f ) );
tableView.AddChild( imageActor, Toolkit::TableView::CellPosition( 0, 1 ) );
slider.ValueChangedSignal().Connect( this, &ItemViewExample::SliderValueChange );
tableView.AddChild( slider, TableView::CellPosition( 0, 0 ) );
- TextStyle defaultTextStyle;
- defaultTextStyle.SetFontName(DEFAULT_TEXT_STYLE_FONT_FAMILY);
- defaultTextStyle.SetFontStyle(DEFAULT_TEXT_STYLE_FONT_STYLE);
- defaultTextStyle.SetFontPointSize(DEFAULT_TEXT_STYLE_POINT_SIZE);
- defaultTextStyle.SetWeight(DEFAULT_TEXT_STYLE_WEIGHT);
- defaultTextStyle.SetTextColor(DEFAULT_TEXT_STYLE_COLOR);
-
- TextView text = TextView::New( "Duration" );
+ TextLabel text = TextLabel::New( "Duration" );
text.SetAnchorPoint( ParentOrigin::TOP_LEFT );
text.SetParentOrigin( ParentOrigin::TOP_LEFT );
- text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft );
- text.SetStyleToCurrentText( defaultTextStyle );
text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y );
- text.SetZ( -0.9f );
+ text.SetResizePolicy( FIXED, HEIGHT );
- text.SetPreferredSize( Vector2( 0.0f, LABEL_TEXT_SIZE_Y ) );
++ text.SetSize( Vector2( 0.0f, LABEL_TEXT_SIZE_Y ) );
slider.Add( text );
Actor textContainer = Actor::New();
mTapDetector.Attach(mAlphaFunctionText);
mTapDetector.DetectedSignal().Connect( this, &ItemViewExample::ChangeAlphaFunctionOnTap );
- text = TextView::New( "Alpha Function" );
+ text = TextLabel::New( "Alpha Function" );
text.SetAnchorPoint( ParentOrigin::TOP_LEFT );
text.SetParentOrigin( ParentOrigin::TOP_LEFT );
- text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft );
- text.SetStyleToCurrentText( defaultTextStyle );
text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- text.SetResizePolicy( FIXED, HEIGHT );
- text.SetPreferredSize( Vector2( 0.0f, LABEL_TEXT_SIZE_Y ) );
+ text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y );
textContainer.Add( text );
mMenu.MarkDirtyForRelayout();
mPopup = CreatePopup();
mPopup.SetTitle( "Popup!" );
- Toolkit::TextView text = Toolkit::TextView::New();
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT );
text.SetName( "POPUP_CONTENT_TEXT" );
- text.SetText( CONTENT_TEXT );
- text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- text.SetWidthExceedPolicy( Toolkit::TextView::Split );
- text.SetLineJustification( Toolkit::TextView::Center );
text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- text.SetDimensionDependency( HEIGHT, WIDTH );
+ text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
text.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 20.0f ) );
mPopup.Add( text );
mPopup = CreatePopup();
mPopup.SetTitle( "Popup!" );
- Toolkit::TextView text = Toolkit::TextView::New();
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( CONTENT_TEXT );
text.SetName( "POPUP_CONTENT_TEXT" );
- text.SetText( CONTENT_TEXT );
- text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- text.SetWidthExceedPolicy( Toolkit::TextView::Split );
- text.SetLineJustification( Toolkit::TextView::Left );
text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- text.SetDimensionDependency( HEIGHT, WIDTH );
+ text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
text.SetPadding( Padding( 10.0f, 10.0f, 20.0f, 0.0f ) );
mPopup.Add( text );
// Text
{
- Toolkit::TextView text = Toolkit::TextView::New();
- text.SetText( "Do you really want to quit?" );
- text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- text.SetWidthExceedPolicy( Toolkit::TextView::Split );
- text.SetLineJustification( Toolkit::TextView::Left );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Do you really want to quit?" );
text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- text.SetDimensionDependency( HEIGHT, WIDTH );
+ text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
}
{
Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- backing.SetResizePolicy( FIXED, HEIGHT );
- backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
+ backing.SetSize( 0.0f, 100.0f );
- TextActor text = TextActor::New( "Fit" );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
text.SetAnchorPoint( AnchorPoint::CENTER );
text.SetParentOrigin( ParentOrigin::CENTER );
backing.Add( text );
{
Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- backing.SetResizePolicy( FIXED, HEIGHT );
- backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
+ backing.SetSize( 0.0f, 100.0f );
- TextActor text = TextActor::New( "Fit" );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
text.SetAnchorPoint( AnchorPoint::CENTER );
text.SetParentOrigin( ParentOrigin::CENTER );
backing.Add( text );
{
Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- backing.SetResizePolicy( FIXED, HEIGHT );
- backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
+ backing.SetSize( 0.0f, 200.0f );
- TextActor text = TextActor::New( "Fit" );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
text.SetAnchorPoint( AnchorPoint::CENTER );
text.SetParentOrigin( ParentOrigin::CENTER );
backing.Add( text );
{
Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- backing.SetResizePolicy( FIXED, HEIGHT );
- backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
+ backing.SetSize( 0.0f, 100.0f );
- TextActor text = TextActor::New( "Fit" );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
text.SetAnchorPoint( AnchorPoint::CENTER );
text.SetParentOrigin( ParentOrigin::CENTER );
backing.Add( text );
{
Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) );
backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- backing.SetResizePolicy( FIXED, HEIGHT );
- backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
+ backing.SetSize( 0.0f, 200.0f );
- TextActor text = TextActor::New( "Fit" );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
text.SetAnchorPoint( AnchorPoint::CENTER );
text.SetParentOrigin( ParentOrigin::CENTER );
backing.Add( text );
{
Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- backing.SetResizePolicy( FIXED, HEIGHT );
- backing.SetPreferredSize( Vector2( 0.0f, 300.0f ) );
+ backing.SetSize( 0.0f, 300.0f );
- TextActor text = TextActor::New( "Fit" );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
text.SetAnchorPoint( AnchorPoint::CENTER );
text.SetParentOrigin( ParentOrigin::CENTER );
backing.Add( text );
Actor backing = Toolkit::CreateSolidColorActor( Vector4( 1.0f, 0.0f, 0.0f, 1.0f ) );
backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
backing.SetResizePolicy( FIXED, HEIGHT );
- backing.SetPreferredSize( Vector2( 0.0f, 100.0f ) );
+ backing.SetSize( 0.0f, 100.0f );
- TextActor text = TextActor::New( "Fit" );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
text.SetAnchorPoint( AnchorPoint::CENTER );
text.SetParentOrigin( ParentOrigin::CENTER );
backing.Add( text );
{
Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- backing.SetResizePolicy( FIXED, HEIGHT );
- backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
+ backing.SetSize( 0.0f, 200.0f );
- TextActor text = TextActor::New( "Fit" );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
text.SetAnchorPoint( AnchorPoint::CENTER );
text.SetParentOrigin( ParentOrigin::CENTER );
backing.Add( text );
{
Actor backing = Toolkit::CreateSolidColorActor( Vector4( 0.0f, 1.0f, 0.0f, 1.0f ) );
backing.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- backing.SetResizePolicy( FIXED, HEIGHT );
- backing.SetPreferredSize( Vector2( 0.0f, 200.0f ) );
+ backing.SetSize( 0.0f, 200.0f );
- TextActor text = TextActor::New( "Fit" );
+ Toolkit::TextLabel text = Toolkit::TextLabel::New( "Fit" );
text.SetAnchorPoint( AnchorPoint::CENTER );
text.SetParentOrigin( ParentOrigin::CENTER );
backing.Add( text );
--- /dev/null
- mContainer.SetPreferredSize( Vector2(stageSize.width*0.6f, stageSize.width*0.6f) );
+/*
+ * 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-field-example.cpp
+ * @brief Basic usage of TextField control
+ */
+
+// EXTERNAL INCLUDES
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/public-api/text-abstraction/text-abstraction.h>
+
+// INTERNAL INCLUDES
+#include "shared/view.h"
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+namespace
+{
+
+const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "button-up.9.png";
+
+const float BORDER_WIDTH = 4.0f;
+
+} // unnamed namespace
+
+/**
+ * @brief The main class of the demo.
+ */
+class TextFieldExample : public ConnectionTracker
+{
+public:
+
+ TextFieldExample( Application& application )
+ : mApplication( application )
+ {
+ // Connect to the Application's Init signal
+ mApplication.InitSignal().Connect( this, &TextFieldExample::Create );
+ }
+
+ ~TextFieldExample()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * One-time setup in response to Application InitSignal.
+ */
+ void Create( Application& application )
+ {
+ DemoHelper::RequestThemeChange();
+
+ Stage stage = Stage::GetCurrent();
+
+ stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent);
+
+ Vector2 stageSize = stage.GetSize();
+
+ mContainer = Control::New();
+ mContainer.SetName( "Container" );
+ mContainer.SetParentOrigin( ParentOrigin::CENTER );
+ mContainer.SetResizePolicy( FIXED, ALL_DIMENSIONS );
- field.SetDimensionDependency( HEIGHT, WIDTH );
++ mContainer.SetSize( Vector2(stageSize.width*0.6f, stageSize.width*0.6f) );
+ mContainer.SetBackgroundImage( ResourceImage::New( BACKGROUND_IMAGE ) );
+ mContainer.GetChildAt(0).SetZ(-1.0f);
+ stage.Add( mContainer );
+
+ TextField field = TextField::New();
+ field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ field.SetResizePolicy( FILL_TO_PARENT, WIDTH );
++ field.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
+
+ mContainer.Add( field );
+
+ field.SetProperty( TextField::Property::TEXT, "Hello" );
+
+ Property::Value fieldText = field.GetProperty( TextField::Property::TEXT );
+ std::cout << "Displaying text: " << fieldText.Get< std::string >() << std::endl;
+ }
+
+ /**
+ * Main key event handler
+ */
+ void OnKeyEvent(const KeyEvent& event)
+ {
+ if(event.state == KeyEvent::Down)
+ {
+ if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) )
+ {
+ mApplication.Quit();
+ }
+ }
+ }
+
+private:
+
+ Application& mApplication;
+
+ Control mContainer;
+};
+
+void RunTest( Application& application )
+{
+ TextFieldExample 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;
+}
--- /dev/null
- mAnimation.MoveBy( mTableView, Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunctions::Linear );
+/*
+ * 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>
+
+// INTERNAL INCLUDES
+#include "shared/multi-language-strings.h"
+#include "shared/view.h"
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+using namespace MultiLanguageStrings;
+
+/**
+ * @brief The main class of the demo.
+ */
+class TextLabelMultiLanguageExample : public ConnectionTracker
+{
+public:
+
+ TextLabelMultiLanguageExample( Application& application )
+ : mApplication( application ),
+ mLastPoint( 0.f )
+ {
+ // Connect to the Application's Init signal
+ mApplication.InitSignal().Connect( this, &TextLabelMultiLanguageExample::Create );
+ }
+
+ ~TextLabelMultiLanguageExample()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * One-time setup in response to Application InitSignal.
+ */
+ void Create( Application& application )
+ {
+ DemoHelper::RequestThemeChange();
+
+ Stage stage = Stage::GetCurrent();
+
+ stage.KeyEventSignal().Connect(this, &TextLabelMultiLanguageExample::OnKeyEvent);
+
+ mTableView = Toolkit::TableView::New( NUMBER_OF_LANGUAGES, 1 );
+ mTableView.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+ mTableView.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
+ mTableView.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mTableView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mTableView.TouchedSignal().Connect( this, &TextLabelMultiLanguageExample::OnTouchEvent );
+ stage.Add( mTableView );
+
+ for( unsigned int index = 0u; index < NUMBER_OF_LANGUAGES; ++index )
+ {
+ const Language& language = LANGUAGES[index];
+
+ TextLabel label = TextLabel::New();
+ label.SetProperty( TextLabel::Property::MULTI_LINE, true );
+
+ const std::string text = language.languageName + " " + language.languageRomanName + " " + language.text;
+ label.SetProperty( TextLabel::Property::TEXT, text );
+
+ mTableView.SetFitHeight( index );
+ mTableView.AddChild( label, Toolkit::TableView::CellPosition( index, 0 ) );
+ }
+ }
+
+ bool OnTouchEvent( Actor actor, const TouchEvent& event )
+ {
+ if( 1u == event.GetPointCount() )
+ {
+ const TouchPoint::State state = event.GetPoint(0u).state;
+
+ // Clamp to integer values; this is to reduce flicking due to pixel misalignment
+ const float localPoint = static_cast<float>( static_cast<int>( event.GetPoint( 0 ).local.y ) );
+
+ if( TouchPoint::Down == state )
+ {
+ mLastPoint = localPoint;
+ mAnimation = Animation::New( 0.25f );
+ }
+ else if( TouchPoint::Motion == state )
+ {
+ if( mAnimation )
+ {
++ mAnimation.AnimateBy( Property(mTableView, Actor::Property::POSITION), Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunctions::Linear );
+ mAnimation.Play();
+ mLastPoint = localPoint;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Main key event handler
+ */
+ void OnKeyEvent(const KeyEvent& event)
+ {
+ if(event.state == KeyEvent::Down)
+ {
+ if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) )
+ {
+ mApplication.Quit();
+ }
+ }
+ }
+
+private:
+
+ Application& mApplication;
+ TableView mTableView;
+ Animation mAnimation;
+ float mLastPoint;
+};
+
+void RunTest( Application& application )
+{
+ 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;
+}
--- /dev/null
- mContainer.SetPreferredSize( mLayoutSize );
+/*
+ * 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>
+
+// INTERNAL INCLUDES
+#include "shared/multi-language-strings.h"
+#include "shared/view.h"
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+using namespace MultiLanguageStrings;
+
+namespace
+{
+ const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "button-up.9.png";
+
+ const unsigned int KEY_ZERO = 10;
+ const unsigned int KEY_ONE = 11;
+ const unsigned int KEY_H = 43;
+ const unsigned int KEY_V = 55;
+ const unsigned int KEY_M = 58;
+ const unsigned int KEY_L = 46;
+ const unsigned int KEY_S = 39;
+ const unsigned int KEY_PLUS = 21;
+ const unsigned int KEY_MINUS = 20;
+
+ const char* H_ALIGNMENT_STRING_TABLE[] =
+ {
+ "BEGIN",
+ "CENTER",
+ "END"
+ };
+
+ const unsigned int H_ALIGNMENT_STRING_COUNT = sizeof( H_ALIGNMENT_STRING_TABLE ) / sizeof( H_ALIGNMENT_STRING_TABLE[0u] );
+
+ const char* V_ALIGNMENT_STRING_TABLE[] =
+ {
+ "TOP",
+ "CENTER",
+ "BOTTOM"
+ };
+
+ const unsigned int V_ALIGNMENT_STRING_COUNT = sizeof( V_ALIGNMENT_STRING_TABLE ) / sizeof( V_ALIGNMENT_STRING_TABLE[0u] );
+
+ int ConvertToEven(int value)
+ {
+ return (value % 2 == 0) ? value : (value + 1);
+ }
+}
+
+/**
+ * @brief The main class of the demo.
+ */
+class TextLabelExample : public ConnectionTracker
+{
+public:
+
+ TextLabelExample( Application& application )
+ : mApplication( application ),
+ mLanguageId( 0u ),
+ mAlignment( 0u )
+ {
+ // 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 )
+ {
+ DemoHelper::RequestThemeChange();
+
+ Stage stage = Stage::GetCurrent();
+
+ stage.KeyEventSignal().Connect(this, &TextLabelExample::OnKeyEvent);
+ Vector2 stageSize = stage.GetSize();
+
+ mContainer = Control::New();
+ mContainer.SetName( "Container" );
+ mContainer.SetParentOrigin( ParentOrigin::CENTER );
+ mContainer.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ mLayoutSize = Vector2(stageSize.width*0.6f, stageSize.width*0.6f);
- mGrabCorner.SetPreferredSize( Vector2(stageSize.width*0.1f, stageSize.width*0.1f) );
++ mContainer.SetSize( mLayoutSize );
+ mContainer.SetBackgroundImage( ResourceImage::New( BACKGROUND_IMAGE ) );
+ mContainer.GetChildAt(0).SetZ(-1.0f);
+ stage.Add( mContainer );
+
+ // Resize the center layout when the corner is grabbed
+ mGrabCorner = Control::New();
+ mGrabCorner.SetName( "GrabCorner" );
+ mGrabCorner.SetAnchorPoint( AnchorPoint::BOTTOM_RIGHT );
+ mGrabCorner.SetParentOrigin( ParentOrigin::BOTTOM_RIGHT );
+ mGrabCorner.SetResizePolicy( FIXED, ALL_DIMENSIONS );
- mLabel.SetDimensionDependency( HEIGHT, WIDTH );
++ mGrabCorner.SetSize( Vector2(stageSize.width*0.1f, stageSize.width*0.1f) );
+ mGrabCorner.SetZ(1.0f);
+ mContainer.Add( mGrabCorner );
+
+ mPanGestureDetector = PanGestureDetector::New();
+ mPanGestureDetector.Attach( mGrabCorner );
+ mPanGestureDetector.DetectedSignal().Connect( this, &TextLabelExample::OnPan );
+
+ mLabel = TextLabel::New( "A Quick Brown Fox Jumps Over The Lazy Dog" );
+ mLabel.SetName( "TextLabel" );
+ mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mContainer.SetPreferredSize( clampedSize );
+ mLabel.SetResizePolicy( FILL_TO_PARENT, WIDTH );
++ mLabel.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
+ mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true );
+ mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
+ mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
+ mContainer.Add( mLabel );
+
+ Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT );
+ std::cout << "Displaying text: \"" << labelText.Get< std::string >() << "\"" << std::endl;
+ }
+
+ // Resize the text-label with pan gesture
+ void OnPan( Actor actor, const PanGesture& gesture )
+ {
+ mLayoutSize.x += gesture.displacement.x * 2.0f;
+ mLayoutSize.y += gesture.displacement.y * 2.0f;
+
+ if( mLayoutSize.x >= 2.0f &&
+ mLayoutSize.y >= 2.0f )
+ {
+ // Avoid pixel mis-alignment issue
+ Vector2 clampedSize = Vector2( ConvertToEven(static_cast<int>(mLayoutSize.x)),
+ ConvertToEven(static_cast<int>(mLayoutSize.y)) );
+
++ mContainer.SetSize( clampedSize );
+ }
+ }
+
+ /**
+ * Main key event handler
+ */
+ void OnKeyEvent(const KeyEvent& event)
+ {
+ if(event.state == KeyEvent::Down)
+ {
+ if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) )
+ {
+ mApplication.Quit();
+ }
+ else if( event.IsCtrlModifier() )
+ {
+ switch( event.keyCode )
+ {
+ case KEY_ZERO: // fall through
+ case KEY_ONE:
+ {
+ mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 );
+ break;
+ }
+ case KEY_H:
+ {
+ if( ++mAlignment >= H_ALIGNMENT_STRING_COUNT )
+ {
+ mAlignment = 0u;
+ }
+
+ mLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, H_ALIGNMENT_STRING_TABLE[ mAlignment ] );
+ break;
+ }
+ case KEY_V:
+ {
+ if( ++mAlignment >= V_ALIGNMENT_STRING_COUNT )
+ {
+ mAlignment = 0u;
+ }
+
+ mLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, V_ALIGNMENT_STRING_TABLE[ mAlignment ] );
+ break;
+ }
+ case KEY_M:
+ {
+ bool multiLine = mLabel.GetProperty<bool>( TextLabel::Property::MULTI_LINE );
+ mLabel.SetProperty( TextLabel::Property::MULTI_LINE, !multiLine );
+ break;
+ }
+ case KEY_L:
+ {
+ const Language& language = LANGUAGES[ mLanguageId ];
+
+ mLabel.SetProperty( TextLabel::Property::TEXT, language.text );
+
+ if( ++mLanguageId >= NUMBER_OF_LANGUAGES )
+ {
+ mLanguageId = 0u;
+ }
+ break;
+ }
+ case KEY_S:
+ {
+ if( Color::BLACK == mLabel.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ) )
+ {
+ mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::RED );
+ }
+ else
+ {
+ mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
+ }
+ break;
+ }
+ case KEY_PLUS:
+ {
+ mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) );
+ break;
+ }
+ case KEY_MINUS:
+ {
+ mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) );
+ break;
+ }
+
+ }
+ }
+ }
+ }
+
+private:
+
+ Application& mApplication;
+
+ TextLabel mLabel;
+
+ Control mContainer;
+ Actor mGrabCorner;
+
+ PanGestureDetector mPanGestureDetector;
+
+ Vector2 mLayoutSize;
+
+ unsigned int mLanguageId;
+ unsigned int mAlignment;
+};
+
+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;
+}