Commit c3af109e51b4c9e75cb0b29c8598fdd81220369f

Authored by Paul Wisbey
1 parent beef9026

Prefer black text / white backgrounds by default

Change-Id: I192e15bd0127e9b637234eb5525550183abfcf55
demo/dali-table-view.cpp
@@ -86,8 +86,6 @@ const Vector2 POSITION_SWING_3DEFFECT( 0.55f, 0.4f ); ///< Position @@ -86,8 +86,6 @@ const Vector2 POSITION_SWING_3DEFFECT( 0.55f, 0.4f ); ///< Position
86 const Vector3 ANCHOR_3DEFFECT_STYLE0( -105.0f, 30.0f, -240.0f ); ///< Rotation Anchor position for 3D Effect (Style 0) 86 const Vector3 ANCHOR_3DEFFECT_STYLE0( -105.0f, 30.0f, -240.0f ); ///< Rotation Anchor position for 3D Effect (Style 0)
87 const Vector3 ANCHOR_3DEFFECT_STYLE1( 65.0f, -70.0f, -500.0f ); ///< Rotation Anchor position for 3D Effect (Style 1) 87 const Vector3 ANCHOR_3DEFFECT_STYLE1( 65.0f, -70.0f, -500.0f ); ///< Rotation Anchor position for 3D Effect (Style 1)
88 88
89 -const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f);  
90 -  
91 Vector3 ScalePointSize(const Vector3& vec) 89 Vector3 ScalePointSize(const Vector3& vec)
92 { 90 {
93 return Vector3( DemoHelper::ScalePointSize( vec.x ), DemoHelper::ScalePointSize( vec.y ), DemoHelper::ScalePointSize( vec.z ) ); 91 return Vector3( DemoHelper::ScalePointSize( vec.x ), DemoHelper::ScalePointSize( vec.y ), DemoHelper::ScalePointSize( vec.z ) );
@@ -523,7 +521,6 @@ Actor DaliTableView::CreateTile( const std::string&amp; name, const std::string&amp; tit @@ -523,7 +521,6 @@ Actor DaliTableView::CreateTile( const std::string&amp; name, const std::string&amp; tit
523 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); 521 label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
524 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); 522 label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
525 label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); 523 label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
526 - label.SetColor( TABLE_TEXT_STYLE_COLOR );  
527 content.Add( label ); 524 content.Add( label );
528 525
529 // Set the tile to be keyboard focusable 526 // Set the tile to be keyboard focusable
examples/builder/examples.cpp
@@ -275,6 +275,7 @@ public: @@ -275,6 +275,7 @@ public:
275 void EnterSelection() 275 void EnterSelection()
276 { 276 {
277 Stage stage = Stage::GetCurrent(); 277 Stage stage = Stage::GetCurrent();
  278 + stage.SetBackgroundColor( Color::WHITE );
278 279
279 mTapDetector = TapGestureDetector::New(); 280 mTapDetector = TapGestureDetector::New();
280 mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap ); 281 mTapDetector.DetectedSignal().Connect( this, &ExampleApp::OnTap );
examples/hello-world/hello-world-example.cpp
@@ -43,6 +43,7 @@ public: @@ -43,6 +43,7 @@ public:
43 { 43 {
44 // Get a handle to the stage 44 // Get a handle to the stage
45 Stage stage = Stage::GetCurrent(); 45 Stage stage = Stage::GetCurrent();
  46 + stage.SetBackgroundColor( Color::WHITE );
46 47
47 TextLabel textLabel = TextLabel::New( "Hello World" ); 48 TextLabel textLabel = TextLabel::New( "Hello World" );
48 textLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); 49 textLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
examples/text-field/text-field-example.cpp
@@ -25,17 +25,48 @@ @@ -25,17 +25,48 @@
25 #include <dali/public-api/text-abstraction/text-abstraction.h> 25 #include <dali/public-api/text-abstraction/text-abstraction.h>
26 26
27 // INTERNAL INCLUDES 27 // INTERNAL INCLUDES
  28 +#include "shared/multi-language-strings.h"
28 #include "shared/view.h" 29 #include "shared/view.h"
29 30
30 using namespace Dali; 31 using namespace Dali;
31 using namespace Dali::Toolkit; 32 using namespace Dali::Toolkit;
  33 +using namespace MultiLanguageStrings;
32 34
33 namespace 35 namespace
34 { 36 {
35 37
36 -const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "button-up.9.png"; 38 + const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "button-up.9.png";
37 39
38 -const float BORDER_WIDTH = 4.0f; 40 + const float BORDER_WIDTH = 4.0f;
  41 +
  42 + const unsigned int KEY_ZERO = 10;
  43 + const unsigned int KEY_ONE = 11;
  44 + const unsigned int KEY_F = 41;
  45 + const unsigned int KEY_H = 43;
  46 + const unsigned int KEY_V = 55;
  47 + const unsigned int KEY_M = 58;
  48 + const unsigned int KEY_L = 46;
  49 + const unsigned int KEY_S = 39;
  50 + const unsigned int KEY_PLUS = 21;
  51 + const unsigned int KEY_MINUS = 20;
  52 +
  53 + const char* H_ALIGNMENT_STRING_TABLE[] =
  54 + {
  55 + "BEGIN",
  56 + "CENTER",
  57 + "END"
  58 + };
  59 +
  60 + const unsigned int H_ALIGNMENT_STRING_COUNT = sizeof( H_ALIGNMENT_STRING_TABLE ) / sizeof( H_ALIGNMENT_STRING_TABLE[0u] );
  61 +
  62 + const char* V_ALIGNMENT_STRING_TABLE[] =
  63 + {
  64 + "TOP",
  65 + "CENTER",
  66 + "BOTTOM"
  67 + };
  68 +
  69 + const unsigned int V_ALIGNMENT_STRING_COUNT = sizeof( V_ALIGNMENT_STRING_TABLE ) / sizeof( V_ALIGNMENT_STRING_TABLE[0u] );
39 70
40 } // unnamed namespace 71 } // unnamed namespace
41 72
@@ -47,7 +78,9 @@ class TextFieldExample : public ConnectionTracker @@ -47,7 +78,9 @@ class TextFieldExample : public ConnectionTracker
47 public: 78 public:
48 79
49 TextFieldExample( Application& application ) 80 TextFieldExample( Application& application )
50 - : mApplication( application ) 81 + : mApplication( application ),
  82 + mLanguageId( 0u ),
  83 + mAlignment( 0u )
51 { 84 {
52 // Connect to the Application's Init signal 85 // Connect to the Application's Init signal
53 mApplication.InitSignal().Connect( this, &TextFieldExample::Create ); 86 mApplication.InitSignal().Connect( this, &TextFieldExample::Create );
@@ -67,33 +100,41 @@ public: @@ -67,33 +100,41 @@ public:
67 100
68 Stage stage = Stage::GetCurrent(); 101 Stage stage = Stage::GetCurrent();
69 102
  103 + mTapGestureDetector = TapGestureDetector::New();
  104 + mTapGestureDetector.Attach( stage.GetRootLayer() );
  105 + mTapGestureDetector.DetectedSignal().Connect( this, &TextFieldExample::OnTap );
  106 +
70 stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent); 107 stage.KeyEventSignal().Connect(this, &TextFieldExample::OnKeyEvent);
71 108
72 Vector2 stageSize = stage.GetSize(); 109 Vector2 stageSize = stage.GetSize();
73 110
74 - mContainer = Control::New();  
75 - mContainer.SetName( "Container" );  
76 - mContainer.SetParentOrigin( ParentOrigin::CENTER );  
77 - mContainer.SetSize( Vector2(stageSize.width*0.6f, stageSize.width*0.6f) );  
78 - mContainer.SetBackgroundImage( ResourceImage::New( BACKGROUND_IMAGE ) );  
79 - mContainer.GetChildAt(0).SetZ(-1.0f);  
80 - stage.Add( mContainer ); 111 + Control container = Control::New();
  112 + container.SetName( "Container" );
  113 + container.SetParentOrigin( ParentOrigin::CENTER );
  114 + container.SetSize( Vector2(stageSize.width*0.6f, stageSize.width*0.6f) );
  115 + container.SetBackgroundColor( Color::WHITE );
  116 + container.GetChildAt(0).SetZ(-1.0f);
  117 + stage.Add( container );
81 118
82 - TextField field = TextField::New();  
83 - field.SetAnchorPoint( AnchorPoint::TOP_LEFT );  
84 - field.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );  
85 - field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); 119 + mField = TextField::New();
  120 + mField.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  121 + mField.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
  122 + mField.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
  123 + mField.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Unnamed folder" );
  124 + mField.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( BORDER_WIDTH, BORDER_WIDTH, stageSize.width - BORDER_WIDTH*2, stageSize.height - BORDER_WIDTH*2 ) );
86 125
87 - mContainer.Add( field ); 126 + container.Add( mField );
88 127
89 - field.SetProperty( TextField::Property::TEXT, "Hello" );  
90 - field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( BORDER_WIDTH, BORDER_WIDTH, stageSize.width - BORDER_WIDTH*2, stageSize.height - BORDER_WIDTH*2 ) );  
91 -  
92 - Property::Value fieldText = field.GetProperty( TextField::Property::TEXT ); 128 + Property::Value fieldText = mField.GetProperty( TextField::Property::TEXT );
93 129
94 std::cout << "Displaying text: " << fieldText.Get< std::string >() << std::endl; 130 std::cout << "Displaying text: " << fieldText.Get< std::string >() << std::endl;
95 } 131 }
96 132
  133 + void OnTap( Actor actor, const TapGesture& tapGesture )
  134 + {
  135 + mField.ClearKeyInputFocus();
  136 + }
  137 +
97 /** 138 /**
98 * Main key event handler 139 * Main key event handler
99 */ 140 */
@@ -105,6 +146,73 @@ public: @@ -105,6 +146,73 @@ public:
105 { 146 {
106 mApplication.Quit(); 147 mApplication.Quit();
107 } 148 }
  149 + else if( event.IsCtrlModifier() )
  150 + {
  151 + switch( event.keyCode )
  152 + {
  153 + // Select rendering back-end
  154 + case KEY_ZERO: // fall through
  155 + case KEY_ONE:
  156 + {
  157 + mField.SetProperty( TextField::Property::RENDERING_BACKEND, event.keyCode - 10 );
  158 + break;
  159 + }
  160 + case KEY_H: // Horizontal alignment
  161 + {
  162 + if( ++mAlignment >= H_ALIGNMENT_STRING_COUNT )
  163 + {
  164 + mAlignment = 0u;
  165 + }
  166 +
  167 + mField.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, H_ALIGNMENT_STRING_TABLE[ mAlignment ] );
  168 + break;
  169 + }
  170 + case KEY_V: // Vertical alignment
  171 + {
  172 + if( ++mAlignment >= V_ALIGNMENT_STRING_COUNT )
  173 + {
  174 + mAlignment = 0u;
  175 + }
  176 +
  177 + mField.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, V_ALIGNMENT_STRING_TABLE[ mAlignment ] );
  178 + break;
  179 + }
  180 + case KEY_L: // Language
  181 + {
  182 + const Language& language = LANGUAGES[ mLanguageId ];
  183 +
  184 + mField.SetProperty( TextField::Property::TEXT, language.text );
  185 +
  186 + if( ++mLanguageId >= NUMBER_OF_LANGUAGES )
  187 + {
  188 + mLanguageId = 0u;
  189 + }
  190 + break;
  191 + }
  192 + case KEY_S: // Shadow color
  193 + {
  194 + if( Color::BLACK == mField.GetProperty<Vector4>( TextField::Property::SHADOW_COLOR ) )
  195 + {
  196 + mField.SetProperty( TextField::Property::SHADOW_COLOR, Color::RED );
  197 + }
  198 + else
  199 + {
  200 + mField.SetProperty( TextField::Property::SHADOW_COLOR, Color::BLACK );
  201 + }
  202 + break;
  203 + }
  204 + case KEY_PLUS: // Increase shadow offset
  205 + {
  206 + mField.SetProperty( TextField::Property::SHADOW_OFFSET, mField.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) );
  207 + break;
  208 + }
  209 + case KEY_MINUS: // Decrease shadow offset
  210 + {
  211 + mField.SetProperty( TextField::Property::SHADOW_OFFSET, mField.GetProperty<Vector2>( TextField::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) );
  212 + break;
  213 + }
  214 + }
  215 + }
108 } 216 }
109 } 217 }
110 218
@@ -112,7 +220,12 @@ private: @@ -112,7 +220,12 @@ private:
112 220
113 Application& mApplication; 221 Application& mApplication;
114 222
115 - Control mContainer; 223 + TextField mField;
  224 +
  225 + TapGestureDetector mTapGestureDetector;
  226 +
  227 + unsigned int mLanguageId;
  228 + unsigned int mAlignment;
116 }; 229 };
117 230
118 void RunTest( Application& application ) 231 void RunTest( Application& application )
examples/text-label-emojis/text-label-emojis.cpp
@@ -56,6 +56,7 @@ public: @@ -56,6 +56,7 @@ public:
56 void Create( Application& application ) 56 void Create( Application& application )
57 { 57 {
58 Stage stage = Stage::GetCurrent(); 58 Stage stage = Stage::GetCurrent();
  59 + stage.SetBackgroundColor( Color::WHITE );
59 stage.KeyEventSignal().Connect(this, &EmojiExample::OnKeyEvent); 60 stage.KeyEventSignal().Connect(this, &EmojiExample::OnKeyEvent);
60 61
61 mTableView = Toolkit::TableView::New( NUMBER_OF_EMOJIS, 1 ); 62 mTableView = Toolkit::TableView::New( NUMBER_OF_EMOJIS, 1 );
examples/text-label-multi-language/text-label-multi-language-example.cpp
@@ -62,6 +62,7 @@ public: @@ -62,6 +62,7 @@ public:
62 Stage stage = Stage::GetCurrent(); 62 Stage stage = Stage::GetCurrent();
63 63
64 stage.KeyEventSignal().Connect(this, &TextLabelMultiLanguageExample::OnKeyEvent); 64 stage.KeyEventSignal().Connect(this, &TextLabelMultiLanguageExample::OnKeyEvent);
  65 + stage.SetBackgroundColor( Color::WHITE );
65 66
66 mTableView = Toolkit::TableView::New( NUMBER_OF_LANGUAGES, 1 ); 67 mTableView = Toolkit::TableView::New( NUMBER_OF_LANGUAGES, 1 );
67 mTableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); 68 mTableView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
examples/text-label/text-label-example.cpp
@@ -131,9 +131,10 @@ public: @@ -131,9 +131,10 @@ public:
131 mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); 131 mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
132 mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); 132 mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
133 mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true ); 133 mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true );
  134 + mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
134 mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); 135 mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
135 mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); 136 mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
136 - mLabel.SetBackgroundColor( Vector4(0.3f,0.3f,0.6f,1.0f) ); 137 + mLabel.SetBackgroundColor( Color::WHITE );
137 mContainer.Add( mLabel ); 138 mContainer.Add( mLabel );
138 139
139 Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT ); 140 Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT );
shared/view.h
@@ -46,7 +46,6 @@ const ViewStyle DEFAULT_VIEW_STYLE( 0.1f, 0.7f, 80.f, 4.f ); @@ -46,7 +46,6 @@ const ViewStyle DEFAULT_VIEW_STYLE( 0.1f, 0.7f, 80.f, 4.f );
46 const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue"); 46 const char* DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNue");
47 const char* DEFAULT_TEXT_STYLE_FONT_STYLE("Regular"); 47 const char* DEFAULT_TEXT_STYLE_FONT_STYLE("Regular");
48 const float DEFAULT_TEXT_STYLE_POINT_SIZE( 8.0f ); 48 const float DEFAULT_TEXT_STYLE_POINT_SIZE( 8.0f );
49 -const Dali::Vector4 DEFAULT_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f);  
50 49
51 const Dali::Toolkit::Alignment::Padding DEFAULT_PLAY_PADDING(12.0f, 12.0f, 12.0f, 12.0f); 50 const Dali::Toolkit::Alignment::Padding DEFAULT_PLAY_PADDING(12.0f, 12.0f, 12.0f, 12.0f);
52 const Dali::Toolkit::Alignment::Padding DEFAULT_MODE_SWITCH_PADDING(8.0f, 8.0f, 8.0f, 8.0f); 51 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&amp; toolBar, @@ -109,7 +108,6 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar&amp; toolBar,
109 label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); 108 label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
110 label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); 109 label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
111 label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT ); 110 label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT );
112 - label.SetColor( DEFAULT_TEXT_STYLE_COLOR );  
113 111
114 // Add title to the tool bar. 112 // Add title to the tool bar.
115 const float padding( style.mToolBarPadding ); 113 const float padding( style.mToolBarPadding );
@@ -174,7 +172,6 @@ Dali::Toolkit::TextLabel CreateToolBarLabel( const std::string&amp; text ) @@ -174,7 +172,6 @@ Dali::Toolkit::TextLabel CreateToolBarLabel( const std::string&amp; text )
174 label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); 172 label.SetProperty( Dali::Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
175 label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); 173 label.SetProperty( Dali::Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
176 label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT ); 174 label.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::HEIGHT );
177 - label.SetColor( DEFAULT_TEXT_STYLE_COLOR );  
178 175
179 return label; 176 return label;
180 } 177 }