Commit 328d390cb723c3bdc5ba126539cbdf76813ca1ae
Committed by
Paul Wisbey
1 parent
a5a2cbec
Add shadow toggle and displacement function to text-label example
Change-Id: Ie7dcdc64bf70fea8ab68af85b729fa5a9de0b652 Signed-off-by: Richard Underhill <r.underhill@partner.samsung.com>
Showing
2 changed files
with
58 additions
and
12 deletions
examples/text-label/center-layout-impl.cpp
| ... | ... | @@ -104,10 +104,8 @@ void CenterLayout::OnRelayout( const Vector2& size, ActorSizeContainer& containe |
| 104 | 104 | child.SetParentOrigin( ParentOrigin::TOP_CENTER ); |
| 105 | 105 | child.SetAnchorPoint( AnchorPoint::TOP_CENTER ); |
| 106 | 106 | |
| 107 | - float height = child.GetHeightForWidth( size.width ); | |
| 108 | - | |
| 109 | - const Size childSize( size.width, std::min( height, size.height ) ); | |
| 110 | - child.SetSize( childSize ); | |
| 107 | + const Size childSize( size ); | |
| 108 | + child.SetSize( size ); | |
| 111 | 109 | |
| 112 | 110 | container.push_back( ActorSizePair( child, childSize ) ); |
| 113 | 111 | } | ... | ... |
examples/text-label/text-label-example.cpp
| ... | ... | @@ -36,18 +36,31 @@ namespace |
| 36 | 36 | { |
| 37 | 37 | const unsigned int KEY_ZERO = 10; |
| 38 | 38 | const unsigned int KEY_ONE = 11; |
| 39 | - const unsigned int KEY_A = 38; | |
| 39 | + const unsigned int KEY_H = 43; | |
| 40 | + const unsigned int KEY_V = 55; | |
| 40 | 41 | const unsigned int KEY_M = 58; |
| 41 | 42 | const unsigned int KEY_L = 46; |
| 43 | + const unsigned int KEY_S = 39; | |
| 44 | + const unsigned int KEY_PLUS = 21; | |
| 45 | + const unsigned int KEY_MINUS = 20; | |
| 42 | 46 | |
| 43 | - const char* ALIGNMENT_STRING_TABLE[] = | |
| 47 | + const char* H_ALIGNMENT_STRING_TABLE[] = | |
| 44 | 48 | { |
| 45 | 49 | "BEGIN", |
| 46 | 50 | "CENTER", |
| 47 | 51 | "END" |
| 48 | 52 | }; |
| 49 | 53 | |
| 50 | - const unsigned int ALIGNMENT_STRING_COUNT = sizeof( ALIGNMENT_STRING_TABLE ) / sizeof( ALIGNMENT_STRING_TABLE[0u] ); | |
| 54 | + const unsigned int H_ALIGNMENT_STRING_COUNT = sizeof( H_ALIGNMENT_STRING_TABLE ) / sizeof( H_ALIGNMENT_STRING_TABLE[0u] ); | |
| 55 | + | |
| 56 | + const char* V_ALIGNMENT_STRING_TABLE[] = | |
| 57 | + { | |
| 58 | + "TOP", | |
| 59 | + "CENTER", | |
| 60 | + "BOTTOM" | |
| 61 | + }; | |
| 62 | + | |
| 63 | + const unsigned int V_ALIGNMENT_STRING_COUNT = sizeof( V_ALIGNMENT_STRING_TABLE ) / sizeof( V_ALIGNMENT_STRING_TABLE[0u] ); | |
| 51 | 64 | } |
| 52 | 65 | |
| 53 | 66 | /** |
| ... | ... | @@ -78,7 +91,7 @@ public: |
| 78 | 91 | { |
| 79 | 92 | Stage stage = Stage::GetCurrent(); |
| 80 | 93 | |
| 81 | - stage.SetBackgroundColor( Color::BLUE ); | |
| 94 | + stage.SetBackgroundColor( Color::BLACK ); | |
| 82 | 95 | stage.KeyEventSignal().Connect(this, &TextLabelExample::OnKeyEvent); |
| 83 | 96 | Vector2 stageSize = stage.GetSize(); |
| 84 | 97 | |
| ... | ... | @@ -88,11 +101,13 @@ public: |
| 88 | 101 | stage.Add( centerLayout ); |
| 89 | 102 | |
| 90 | 103 | mLabel = TextLabel::New(); |
| 91 | - mLabel.SetBackgroundColor( Color::BLACK ); | |
| 104 | + mLabel.SetBackgroundColor( Vector4(0.3f,0.3f,0.6f,1.0f) ); | |
| 92 | 105 | centerLayout.Add( mLabel ); |
| 93 | 106 | |
| 94 | 107 | mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true ); |
| 95 | 108 | mLabel.SetProperty( TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog" ); |
| 109 | + mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); | |
| 110 | + mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); | |
| 96 | 111 | |
| 97 | 112 | Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT ); |
| 98 | 113 | std::cout << "Displaying text: \"" << labelText.Get< std::string >() << "\"" << std::endl; |
| ... | ... | @@ -119,14 +134,24 @@ public: |
| 119 | 134 | mLabel.SetProperty( TextLabel::Property::RENDERING_BACKEND, event.keyCode - 10 ); |
| 120 | 135 | break; |
| 121 | 136 | } |
| 122 | - case KEY_A: | |
| 137 | + case KEY_H: | |
| 123 | 138 | { |
| 124 | - if( ++mAlignment >= ALIGNMENT_STRING_COUNT ) | |
| 139 | + if( ++mAlignment >= H_ALIGNMENT_STRING_COUNT ) | |
| 125 | 140 | { |
| 126 | 141 | mAlignment = 0u; |
| 127 | 142 | } |
| 128 | 143 | |
| 129 | - mLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, ALIGNMENT_STRING_TABLE[ mAlignment ] ); | |
| 144 | + mLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, H_ALIGNMENT_STRING_TABLE[ mAlignment ] ); | |
| 145 | + break; | |
| 146 | + } | |
| 147 | + case KEY_V: | |
| 148 | + { | |
| 149 | + if( ++mAlignment >= V_ALIGNMENT_STRING_COUNT ) | |
| 150 | + { | |
| 151 | + mAlignment = 0u; | |
| 152 | + } | |
| 153 | + | |
| 154 | + mLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, V_ALIGNMENT_STRING_TABLE[ mAlignment ] ); | |
| 130 | 155 | break; |
| 131 | 156 | } |
| 132 | 157 | case KEY_M: |
| ... | ... | @@ -147,6 +172,29 @@ public: |
| 147 | 172 | } |
| 148 | 173 | break; |
| 149 | 174 | } |
| 175 | + case KEY_S: | |
| 176 | + { | |
| 177 | + if( Color::BLACK == mLabel.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ) ) | |
| 178 | + { | |
| 179 | + mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::RED ); | |
| 180 | + } | |
| 181 | + else | |
| 182 | + { | |
| 183 | + mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); | |
| 184 | + } | |
| 185 | + break; | |
| 186 | + } | |
| 187 | + case KEY_PLUS: | |
| 188 | + { | |
| 189 | + mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) ); | |
| 190 | + break; | |
| 191 | + } | |
| 192 | + case KEY_MINUS: | |
| 193 | + { | |
| 194 | + mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) - Vector2( 1.0f, 1.0f ) ); | |
| 195 | + break; | |
| 196 | + } | |
| 197 | + | |
| 150 | 198 | } |
| 151 | 199 | } |
| 152 | 200 | } | ... | ... |