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