Commit 9c0583f85a9024bdf989764832d2adc2dcf0386e
Committed by
Gerrit Code Review
Merge "Use the input style changed signal to update the gui." into devel/master
Showing
1 changed file
with
21 additions
and
2 deletions
examples/text-editor/text-editor-example.cpp
| @@ -62,7 +62,6 @@ const unsigned int NUMBER_OF_COLORS = sizeof( COLORS ) / sizeof( Vector4 ); | @@ -62,7 +62,6 @@ const unsigned int NUMBER_OF_COLORS = sizeof( COLORS ) / sizeof( Vector4 ); | ||
| 62 | class TextEditorExample : public ConnectionTracker | 62 | class TextEditorExample : public ConnectionTracker |
| 63 | { | 63 | { |
| 64 | public: | 64 | public: |
| 65 | - | ||
| 66 | TextEditorExample( Application& application ) | 65 | TextEditorExample( Application& application ) |
| 67 | : mApplication( application ) | 66 | : mApplication( application ) |
| 68 | { | 67 | { |
| @@ -152,6 +151,8 @@ public: | @@ -152,6 +151,8 @@ public: | ||
| 152 | "Asšúm sapěret usu ůť.\n" | 151 | "Asšúm sapěret usu ůť.\n" |
| 153 | "Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n" ); | 152 | "Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n" ); |
| 154 | 153 | ||
| 154 | + mEditor.InputStyleChangedSignal().Connect( this, &TextEditorExample::OnTextInputStyleChanged ); | ||
| 155 | + | ||
| 155 | contents.Add( mEditor ); | 156 | contents.Add( mEditor ); |
| 156 | } | 157 | } |
| 157 | 158 | ||
| @@ -222,18 +223,36 @@ public: | @@ -222,18 +223,36 @@ public: | ||
| 222 | { | 223 | { |
| 223 | const std::string& name = button.GetName(); | 224 | const std::string& name = button.GetName(); |
| 224 | 225 | ||
| 226 | + Vector4 color; | ||
| 225 | if( "color" == name.substr( 0u, 5u ) ) | 227 | if( "color" == name.substr( 0u, 5u ) ) |
| 226 | { | 228 | { |
| 227 | const unsigned int index = strtoul( name.substr( 5u, 1u ).c_str(), NULL, 10u ); | 229 | const unsigned int index = strtoul( name.substr( 5u, 1u ).c_str(), NULL, 10u ); |
| 228 | - mEditor.SetProperty( TextEditor::Property::INPUT_COLOR, COLORS[index] ); | 230 | + color = COLORS[index]; |
| 231 | + mEditor.SetProperty( TextEditor::Property::INPUT_COLOR, color ); | ||
| 229 | } | 232 | } |
| 230 | 233 | ||
| 234 | + mColorButtonOption.SetProperty( Button::Property::UNSELECTED_COLOR, color ); | ||
| 235 | + mColorButtonOption.SetProperty( Button::Property::SELECTED_COLOR, color ); | ||
| 236 | + | ||
| 231 | mButtonContainer.SetVisible( false ); | 237 | mButtonContainer.SetVisible( false ); |
| 232 | mButtonContainer.SetSensitive( false ); | 238 | mButtonContainer.SetSensitive( false ); |
| 233 | 239 | ||
| 234 | return true; | 240 | return true; |
| 235 | } | 241 | } |
| 236 | 242 | ||
| 243 | + void OnTextInputStyleChanged( TextEditor editor, TextEditor::InputStyle::Mask mask ) | ||
| 244 | + { | ||
| 245 | + if( TextEditor::InputStyle::NONE != static_cast<TextEditor::InputStyle::Mask>( mask & TextEditor::InputStyle::COLOR ) ) | ||
| 246 | + { | ||
| 247 | + const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>(); | ||
| 248 | + | ||
| 249 | + mColorButtonOption.SetProperty( Button::Property::UNSELECTED_COLOR, color ); | ||
| 250 | + mColorButtonOption.SetProperty( Button::Property::SELECTED_COLOR, color ); | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + editor.Reset(); | ||
| 254 | + } | ||
| 255 | + | ||
| 237 | private: | 256 | private: |
| 238 | 257 | ||
| 239 | Application& mApplication; | 258 | Application& mApplication; |