diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index cb56cd5..8175c94 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -86,8 +86,6 @@ const Vector2 POSITION_SWING_3DEFFECT( 0.55f, 0.4f ); ///< Position const Vector3 ANCHOR_3DEFFECT_STYLE0( -105.0f, 30.0f, -240.0f ); ///< Rotation Anchor position for 3D Effect (Style 0) const Vector3 ANCHOR_3DEFFECT_STYLE1( 65.0f, -70.0f, -500.0f ); ///< Rotation Anchor position for 3D Effect (Style 1) -const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); - Vector3 ScalePointSize(const Vector3& vec) { return Vector3( DemoHelper::ScalePointSize( vec.x ), DemoHelper::ScalePointSize( vec.y ), DemoHelper::ScalePointSize( vec.z ) ); @@ -523,7 +521,6 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); - label.SetColor( TABLE_TEXT_STYLE_COLOR ); content.Add( label ); // Set the tile to be keyboard focusable diff --git a/examples/builder/examples.cpp b/examples/builder/examples.cpp index 2dad74c..65964dc 100644 --- a/examples/builder/examples.cpp +++ b/examples/builder/examples.cpp @@ -275,6 +275,7 @@ public: void EnterSelection() { Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); mTapDetector = TapGestureDetector::New(); mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap ); diff --git a/examples/hello-world/hello-world-example.cpp b/examples/hello-world/hello-world-example.cpp index 9dea8ac..3a944fa 100644 --- a/examples/hello-world/hello-world-example.cpp +++ b/examples/hello-world/hello-world-example.cpp @@ -43,6 +43,7 @@ public: { // Get a handle to the stage Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); TextLabel textLabel = TextLabel::New( "Hello World" ); textLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); diff --git a/examples/text-field/text-field-example.cpp b/examples/text-field/text-field-example.cpp index dfcd06a..d99d0ec 100644 --- a/examples/text-field/text-field-example.cpp +++ b/examples/text-field/text-field-example.cpp @@ -25,17 +25,48 @@ #include // 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 char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "button-up.9.png"; -const float BORDER_WIDTH = 4.0f; + const float BORDER_WIDTH = 4.0f; + + const unsigned int KEY_ZERO = 10; + const unsigned int KEY_ONE = 11; + const unsigned int KEY_F = 41; + 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] ); } // unnamed namespace @@ -47,7 +78,9 @@ class TextFieldExample : public ConnectionTracker public: TextFieldExample( Application& application ) - : mApplication( application ) + : mApplication( application ), + mLanguageId( 0u ), + mAlignment( 0u ) { // Connect to the Application's Init signal mApplication.InitSignal().Connect( this, &TextFieldExample::Create ); @@ -67,33 +100,41 @@ public: Stage stage = Stage::GetCurrent(); + mTapGestureDetector = TapGestureDetector::New(); + mTapGestureDetector.Attach( stage.GetRootLayer() ); + mTapGestureDetector.DetectedSignal().Connect( this, &TextFieldExample::OnTap ); + stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent); Vector2 stageSize = stage.GetSize(); - mContainer = Control::New(); - mContainer.SetName( "Container" ); - mContainer.SetParentOrigin( ParentOrigin::CENTER ); - 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 ); + Control container = Control::New(); + container.SetName( "Container" ); + container.SetParentOrigin( ParentOrigin::CENTER ); + container.SetSize( Vector2(stageSize.width*0.6f, stageSize.width*0.6f) ); + container.SetBackgroundColor( Color::WHITE ); + container.GetChildAt(0).SetZ(-1.0f); + stage.Add( container ); - TextField field = TextField::New(); - field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - field.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + mField = TextField::New(); + mField.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mField.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + mField.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); + mField.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Unnamed folder" ); + mField.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( BORDER_WIDTH, BORDER_WIDTH, stageSize.width - BORDER_WIDTH*2, stageSize.height - BORDER_WIDTH*2 ) ); - mContainer.Add( field ); + container.Add( mField ); - field.SetProperty( TextField::Property::TEXT, "Hello" ); - field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( BORDER_WIDTH, BORDER_WIDTH, stageSize.width - BORDER_WIDTH*2, stageSize.height - BORDER_WIDTH*2 ) ); - - Property::Value fieldText = field.GetProperty( TextField::Property::TEXT ); + Property::Value fieldText = mField.GetProperty( TextField::Property::TEXT ); std::cout << "Displaying text: " << fieldText.Get< std::string >() << std::endl; } + void OnTap( Actor actor, const TapGesture& tapGesture ) + { + mField.ClearKeyInputFocus(); + } + /** * Main key event handler */ @@ -105,6 +146,73 @@ public: { mApplication.Quit(); } + else if( event.IsCtrlModifier() ) + { + switch( event.keyCode ) + { + // Select rendering back-end + case KEY_ZERO: // fall through + case KEY_ONE: + { + mField.SetProperty( TextField::Property::RENDERING_BACKEND, event.keyCode - 10 ); + break; + } + case KEY_H: // Horizontal alignment + { + if( ++mAlignment >= H_ALIGNMENT_STRING_COUNT ) + { + mAlignment = 0u; + } + + mField.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, H_ALIGNMENT_STRING_TABLE[ mAlignment ] ); + break; + } + case KEY_V: // Vertical alignment + { + if( ++mAlignment >= V_ALIGNMENT_STRING_COUNT ) + { + mAlignment = 0u; + } + + mField.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, V_ALIGNMENT_STRING_TABLE[ mAlignment ] ); + break; + } + case KEY_L: // Language + { + const Language& language = LANGUAGES[ mLanguageId ]; + + mField.SetProperty( TextField::Property::TEXT, language.text ); + + if( ++mLanguageId >= NUMBER_OF_LANGUAGES ) + { + mLanguageId = 0u; + } + break; + } + case KEY_S: // Shadow color + { + if( Color::BLACK == mField.GetProperty( TextField::Property::SHADOW_COLOR ) ) + { + mField.SetProperty( TextField::Property::SHADOW_COLOR, Color::RED ); + } + else + { + mField.SetProperty( TextField::Property::SHADOW_COLOR, Color::BLACK ); + } + break; + } + case KEY_PLUS: // Increase shadow offset + { + mField.SetProperty( TextField::Property::SHADOW_OFFSET, mField.GetProperty( TextField::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) ); + break; + } + case KEY_MINUS: // Decrease shadow offset + { + mField.SetProperty( TextField::Property::SHADOW_OFFSET, mField.GetProperty( TextField::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) ); + break; + } + } + } } } @@ -112,7 +220,12 @@ private: Application& mApplication; - Control mContainer; + TextField mField; + + TapGestureDetector mTapGestureDetector; + + unsigned int mLanguageId; + unsigned int mAlignment; }; void RunTest( Application& application ) diff --git a/examples/text-label-emojis/text-label-emojis.cpp b/examples/text-label-emojis/text-label-emojis.cpp index 3023974..751cb26 100644 --- a/examples/text-label-emojis/text-label-emojis.cpp +++ b/examples/text-label-emojis/text-label-emojis.cpp @@ -56,6 +56,7 @@ public: void Create( Application& application ) { Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor( Color::WHITE ); stage.KeyEventSignal().Connect(this, &EmojiExample::OnKeyEvent); mTableView = Toolkit::TableView::New( NUMBER_OF_EMOJIS, 1 ); 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 78ded00..3706b81 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 @@ -62,6 +62,7 @@ public: Stage stage = Stage::GetCurrent(); stage.KeyEventSignal().Connect(this, &TextLabelMultiLanguageExample::OnKeyEvent); + stage.SetBackgroundColor( Color::WHITE ); mTableView = Toolkit::TableView::New( NUMBER_OF_LANGUAGES, 1 ); mTableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); diff --git a/examples/text-label/text-label-example.cpp b/examples/text-label/text-label-example.cpp index 4816737..a24e3aa 100644 --- a/examples/text-label/text-label-example.cpp +++ b/examples/text-label/text-label-example.cpp @@ -131,9 +131,10 @@ public: mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true ); + mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE ); mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); - mLabel.SetBackgroundColor( Vector4(0.3f,0.3f,0.6f,1.0f) ); + mLabel.SetBackgroundColor( Color::WHITE ); mContainer.Add( mLabel ); Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT ); diff --git a/shared/view.h b/shared/view.h index 930511e..44b6663 100644 --- a/shared/view.h +++ b/shared/view.h @@ -46,7 +46,6 @@ const ViewStyle DEFAULT_VIEW_STYLE( 0.1f, 0.7f, 80.f, 4.f ); const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue"); const char* DEFAULT_TEXT_STYLE_FONT_STYLE("Regular"); const float DEFAULT_TEXT_STYLE_POINT_SIZE( 8.0f ); -const Dali::Vector4 DEFAULT_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); const Dali::Toolkit::Alignment::Padding DEFAULT_PLAY_PADDING(12.0f, 12.0f, 12.0f, 12.0f); const Dali::Toolkit::Alignment::Padding DEFAULT_MODE_SWITCH_PADDING(8.0f, 8.0f, 8.0f, 8.0f); @@ -109,7 +108,6 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT ); - label.SetColor( DEFAULT_TEXT_STYLE_COLOR ); // Add title to the tool bar. const float padding( style.mToolBarPadding ); @@ -174,7 +172,6 @@ Dali::Toolkit::TextLabel CreateToolBarLabel( const std::string& text ) label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT ); - label.SetColor( DEFAULT_TEXT_STYLE_COLOR ); return label; }