Commit 9ba541629612ab01fee02cafac61be7870d37cfc
1 parent
82ce98f2
Revert to using SetBackgroundColor in text-label.example
Change-Id: I9ef0e8248dac3acdb0bb2b37625b5081739cb1df
Showing
1 changed file
with
25 additions
and
11 deletions
examples/text-label/text-label-example.cpp
| @@ -38,6 +38,7 @@ namespace | @@ -38,6 +38,7 @@ namespace | ||
| 38 | 38 | ||
| 39 | const unsigned int KEY_ZERO = 10; | 39 | const unsigned int KEY_ZERO = 10; |
| 40 | const unsigned int KEY_ONE = 11; | 40 | const unsigned int KEY_ONE = 11; |
| 41 | + const unsigned int KEY_F = 41; | ||
| 41 | const unsigned int KEY_H = 43; | 42 | const unsigned int KEY_H = 43; |
| 42 | const unsigned int KEY_V = 55; | 43 | const unsigned int KEY_V = 55; |
| 43 | const unsigned int KEY_M = 58; | 44 | const unsigned int KEY_M = 58; |
| @@ -108,8 +109,6 @@ public: | @@ -108,8 +109,6 @@ public: | ||
| 108 | mContainer.SetParentOrigin( ParentOrigin::CENTER ); | 109 | mContainer.SetParentOrigin( ParentOrigin::CENTER ); |
| 109 | mLayoutSize = Vector2(stageSize.width*0.6f, stageSize.width*0.6f); | 110 | mLayoutSize = Vector2(stageSize.width*0.6f, stageSize.width*0.6f); |
| 110 | mContainer.SetSize( mLayoutSize ); | 111 | mContainer.SetSize( mLayoutSize ); |
| 111 | - mContainer.SetBackgroundImage( ResourceImage::New( BACKGROUND_IMAGE ) ); | ||
| 112 | - mContainer.GetChildAt(0).SetZ(-1.0f); | ||
| 113 | stage.Add( mContainer ); | 112 | stage.Add( mContainer ); |
| 114 | 113 | ||
| 115 | // Resize the center layout when the corner is grabbed | 114 | // Resize the center layout when the corner is grabbed |
| @@ -119,6 +118,7 @@ public: | @@ -119,6 +118,7 @@ public: | ||
| 119 | mGrabCorner.SetParentOrigin( ParentOrigin::BOTTOM_RIGHT ); | 118 | mGrabCorner.SetParentOrigin( ParentOrigin::BOTTOM_RIGHT ); |
| 120 | mGrabCorner.SetSize( Vector2(stageSize.width*0.1f, stageSize.width*0.1f) ); | 119 | mGrabCorner.SetSize( Vector2(stageSize.width*0.1f, stageSize.width*0.1f) ); |
| 121 | mGrabCorner.SetZ(1.0f); | 120 | mGrabCorner.SetZ(1.0f); |
| 121 | + mGrabCorner.SetBackgroundColor( Color::YELLOW ); | ||
| 122 | mContainer.Add( mGrabCorner ); | 122 | mContainer.Add( mGrabCorner ); |
| 123 | 123 | ||
| 124 | mPanGestureDetector = PanGestureDetector::New(); | 124 | mPanGestureDetector = PanGestureDetector::New(); |
| @@ -129,10 +129,11 @@ public: | @@ -129,10 +129,11 @@ public: | ||
| 129 | mLabel.SetName( "TextLabel" ); | 129 | mLabel.SetName( "TextLabel" ); |
| 130 | mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | 130 | mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 131 | mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | 131 | mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); |
| 132 | - mLabel.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, 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::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); | 134 | mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); |
| 135 | mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); | 135 | mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); |
| 136 | + mLabel.SetBackgroundColor( Vector4(0.3f,0.3f,0.6f,1.0f) ); | ||
| 136 | mContainer.Add( mLabel ); | 137 | mContainer.Add( mLabel ); |
| 137 | 138 | ||
| 138 | Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT ); | 139 | Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT ); |
| @@ -171,13 +172,26 @@ public: | @@ -171,13 +172,26 @@ public: | ||
| 171 | { | 172 | { |
| 172 | switch( event.keyCode ) | 173 | switch( event.keyCode ) |
| 173 | { | 174 | { |
| 175 | + // Select rendering back-end | ||
| 174 | case KEY_ZERO: // fall through | 176 | case KEY_ZERO: // fall through |
| 175 | case KEY_ONE: | 177 | case KEY_ONE: |
| 176 | { | 178 | { |
| 177 | mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 ); | 179 | mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 ); |
| 178 | break; | 180 | break; |
| 179 | } | 181 | } |
| 180 | - case KEY_H: | 182 | + case KEY_F: // Fill vertically |
| 183 | + { | ||
| 184 | + if( ResizePolicy::DIMENSION_DEPENDENCY == mLabel.GetResizePolicy(Dimension::HEIGHT) ) | ||
| 185 | + { | ||
| 186 | + mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); | ||
| 187 | + } | ||
| 188 | + else | ||
| 189 | + { | ||
| 190 | + mLabel.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); | ||
| 191 | + } | ||
| 192 | + break; | ||
| 193 | + } | ||
| 194 | + case KEY_H: // Horizontal alignment | ||
| 181 | { | 195 | { |
| 182 | if( ++mAlignment >= H_ALIGNMENT_STRING_COUNT ) | 196 | if( ++mAlignment >= H_ALIGNMENT_STRING_COUNT ) |
| 183 | { | 197 | { |
| @@ -187,7 +201,7 @@ public: | @@ -187,7 +201,7 @@ public: | ||
| 187 | mLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, H_ALIGNMENT_STRING_TABLE[ mAlignment ] ); | 201 | mLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, H_ALIGNMENT_STRING_TABLE[ mAlignment ] ); |
| 188 | break; | 202 | break; |
| 189 | } | 203 | } |
| 190 | - case KEY_V: | 204 | + case KEY_V: // Vertical alignment |
| 191 | { | 205 | { |
| 192 | if( ++mAlignment >= V_ALIGNMENT_STRING_COUNT ) | 206 | if( ++mAlignment >= V_ALIGNMENT_STRING_COUNT ) |
| 193 | { | 207 | { |
| @@ -197,13 +211,13 @@ public: | @@ -197,13 +211,13 @@ public: | ||
| 197 | mLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, V_ALIGNMENT_STRING_TABLE[ mAlignment ] ); | 211 | mLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, V_ALIGNMENT_STRING_TABLE[ mAlignment ] ); |
| 198 | break; | 212 | break; |
| 199 | } | 213 | } |
| 200 | - case KEY_M: | 214 | + case KEY_M: // Multi-line |
| 201 | { | 215 | { |
| 202 | bool multiLine = mLabel.GetProperty<bool>( TextLabel::Property::MULTI_LINE ); | 216 | bool multiLine = mLabel.GetProperty<bool>( TextLabel::Property::MULTI_LINE ); |
| 203 | mLabel.SetProperty( TextLabel::Property::MULTI_LINE, !multiLine ); | 217 | mLabel.SetProperty( TextLabel::Property::MULTI_LINE, !multiLine ); |
| 204 | break; | 218 | break; |
| 205 | } | 219 | } |
| 206 | - case KEY_L: | 220 | + case KEY_L: // Language |
| 207 | { | 221 | { |
| 208 | const Language& language = LANGUAGES[ mLanguageId ]; | 222 | const Language& language = LANGUAGES[ mLanguageId ]; |
| 209 | 223 | ||
| @@ -215,7 +229,7 @@ public: | @@ -215,7 +229,7 @@ public: | ||
| 215 | } | 229 | } |
| 216 | break; | 230 | break; |
| 217 | } | 231 | } |
| 218 | - case KEY_S: | 232 | + case KEY_S: // Shadow color |
| 219 | { | 233 | { |
| 220 | if( Color::BLACK == mLabel.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ) ) | 234 | if( Color::BLACK == mLabel.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ) ) |
| 221 | { | 235 | { |
| @@ -227,12 +241,12 @@ public: | @@ -227,12 +241,12 @@ public: | ||
| 227 | } | 241 | } |
| 228 | break; | 242 | break; |
| 229 | } | 243 | } |
| 230 | - case KEY_PLUS: | 244 | + case KEY_PLUS: // Increase shadow offset |
| 231 | { | 245 | { |
| 232 | mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) ); | 246 | mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) ); |
| 233 | break; | 247 | break; |
| 234 | } | 248 | } |
| 235 | - case KEY_MINUS: | 249 | + case KEY_MINUS: // Decrease shadow offset |
| 236 | { | 250 | { |
| 237 | mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) ); | 251 | mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) ); |
| 238 | break; | 252 | break; |
| @@ -250,7 +264,7 @@ private: | @@ -250,7 +264,7 @@ private: | ||
| 250 | TextLabel mLabel; | 264 | TextLabel mLabel; |
| 251 | 265 | ||
| 252 | Control mContainer; | 266 | Control mContainer; |
| 253 | - Actor mGrabCorner; | 267 | + Control mGrabCorner; |
| 254 | 268 | ||
| 255 | PanGestureDetector mPanGestureDetector; | 269 | PanGestureDetector mPanGestureDetector; |
| 256 | 270 |