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 | 62 | class TextEditorExample : public ConnectionTracker |
| 63 | 63 | { |
| 64 | 64 | public: |
| 65 | - | |
| 66 | 65 | TextEditorExample( Application& application ) |
| 67 | 66 | : mApplication( application ) |
| 68 | 67 | { |
| ... | ... | @@ -152,6 +151,8 @@ public: |
| 152 | 151 | "Asšúm sapěret usu ůť.\n" |
| 153 | 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 | 156 | contents.Add( mEditor ); |
| 156 | 157 | } |
| 157 | 158 | |
| ... | ... | @@ -222,18 +223,36 @@ public: |
| 222 | 223 | { |
| 223 | 224 | const std::string& name = button.GetName(); |
| 224 | 225 | |
| 226 | + Vector4 color; | |
| 225 | 227 | if( "color" == name.substr( 0u, 5u ) ) |
| 226 | 228 | { |
| 227 | 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 | 237 | mButtonContainer.SetVisible( false ); |
| 232 | 238 | mButtonContainer.SetSensitive( false ); |
| 233 | 239 | |
| 234 | 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 | 256 | private: |
| 238 | 257 | |
| 239 | 258 | Application& mApplication; | ... | ... |