Commit 6a6fbb2bcd3abcc68bd240fa803a95ac577cee95
Committed by
Tom Robinson
1 parent
6c11f68c
Button refactoring phase 1
Change-Id: I5e4b8689b21deca3fea0019d024bd2d98e52d3d8
Showing
6 changed files
with
56 additions
and
56 deletions
demo/images/checkbox-checked.png renamed to demo/images/checkbox-selected.png
1.94 KB
demo/images/checkbox-unchecked.png renamed to demo/images/checkbox-unselected.png
629 Bytes
demo/scripts/button.json
| ... | ... | @@ -32,7 +32,7 @@ |
| 32 | 32 | "filename": "{DALI_IMAGE_DIR}blocks-brick-1.png" |
| 33 | 33 | } |
| 34 | 34 | }, |
| 35 | - "pressed-state-actor": { | |
| 35 | + "selected-state-actor": { | |
| 36 | 36 | "type": "ImageActor", |
| 37 | 37 | "image": { |
| 38 | 38 | "filename": "{DALI_IMAGE_DIR}blocks-brick-2.png" |
| ... | ... | @@ -53,22 +53,22 @@ |
| 53 | 53 | "size": [0, 200, 0], |
| 54 | 54 | "label-actor": { |
| 55 | 55 | "type": "TextView", |
| 56 | - "text": "Dimmed" | |
| 56 | + "text": "Disabled" | |
| 57 | 57 | }, |
| 58 | - "dimmed": true, | |
| 58 | + "disabled": true, | |
| 59 | 59 | "normal-state-actor": { |
| 60 | 60 | "type": "ImageActor", |
| 61 | 61 | "image": { |
| 62 | 62 | "filename": "{DALI_IMAGE_DIR}blocks-brick-1.png" |
| 63 | 63 | } |
| 64 | 64 | }, |
| 65 | - "pressed-state-actor": { | |
| 65 | + "selected-state-actor": { | |
| 66 | 66 | "type": "ImageActor", |
| 67 | 67 | "image": { |
| 68 | 68 | "filename": "{DALI_IMAGE_DIR}blocks-brick-2.png" |
| 69 | 69 | } |
| 70 | 70 | }, |
| 71 | - "dimmed-state-actor": { | |
| 71 | + "disabled-state-actor": { | |
| 72 | 72 | "type": "ImageActor", |
| 73 | 73 | "image": { |
| 74 | 74 | "filename": "{DALI_IMAGE_DIR}blocks-brick-3.png" |
| ... | ... | @@ -97,7 +97,7 @@ |
| 97 | 97 | "filename": "{DALI_IMAGE_DIR}blocks-brick-1.png" |
| 98 | 98 | } |
| 99 | 99 | }, |
| 100 | - "pressed-state-actor": { | |
| 100 | + "selected-state-actor": { | |
| 101 | 101 | "type": "ImageActor", |
| 102 | 102 | "style": "STYLE_NINE_PATCH", |
| 103 | 103 | "border": [26, 24, 26, 23], |
| ... | ... | @@ -106,7 +106,7 @@ |
| 106 | 106 | } |
| 107 | 107 | }, |
| 108 | 108 | "signals": [{ |
| 109 | - "name": "toggled", | |
| 109 | + "name": "selected", | |
| 110 | 110 | "action": "set", |
| 111 | 111 | "actor": "toggle-button", |
| 112 | 112 | "property": "label-actor", | ... | ... |
demo/scripts/super-blur-view.json
examples/buttons/buttons-example.cpp
| ... | ... | @@ -61,8 +61,8 @@ const char* const PUSHBUTTON_PRESS_IMAGE = DALI_IMAGE_DIR "button-down.9.png"; |
| 61 | 61 | const char* const PUSHBUTTON_DISABLED_IMAGE = DALI_IMAGE_DIR "button-disabled.9.png"; |
| 62 | 62 | const char* const PUSHBUTTON_BUTTON_IMAGE = DALI_IMAGE_DIR "button-up.9.png"; |
| 63 | 63 | |
| 64 | -const char* const CHECKBOX_UNCHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-unchecked.png"; | |
| 65 | -const char* const CHECKBOX_CHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-checked.png"; | |
| 64 | +const char* const CHECKBOX_UNSELECTED_IMAGE = DALI_IMAGE_DIR "checkbox-unselected.png"; | |
| 65 | +const char* const CHECKBOX_SELECTED_IMAGE = DALI_IMAGE_DIR "checkbox-selected.png"; | |
| 66 | 66 | |
| 67 | 67 | const Vector4 BACKGROUND_COLOUR( 1.0f, 1.0f, 1.0f, 0.15f ); |
| 68 | 68 | |
| ... | ... | @@ -251,7 +251,7 @@ class ButtonsController: public ConnectionTracker |
| 251 | 251 | radioButton.SetPosition( 0, 0 ); |
| 252 | 252 | radioButton.SetSelected( true ); |
| 253 | 253 | |
| 254 | - radioButton.StateChangedSignal().Connect( this, &ButtonsController::EnableSelectButtonToggle ); | |
| 254 | + radioButton.StateChangedSignal().Connect( this, &ButtonsController::EnableSelectButton ); | |
| 255 | 255 | |
| 256 | 256 | radioButtonsGroup1.Add( radioButton ); |
| 257 | 257 | } |
| ... | ... | @@ -264,7 +264,7 @@ class ButtonsController: public ConnectionTracker |
| 264 | 264 | radioButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 265 | 265 | radioButton.SetPosition( 0, DP(50) ); |
| 266 | 266 | |
| 267 | - radioButton.StateChangedSignal().Connect( this, &ButtonsController::EnableSelectButtonToggle ); | |
| 267 | + radioButton.StateChangedSignal().Connect( this, &ButtonsController::EnableSelectButton ); | |
| 268 | 268 | |
| 269 | 269 | radioButtonsGroup1.Add( radioButton ); |
| 270 | 270 | } |
| ... | ... | @@ -279,8 +279,8 @@ class ButtonsController: public ConnectionTracker |
| 279 | 279 | checkBoxBackground.SetSize( DP(430), DP(GROUP3_HEIGHT) ); |
| 280 | 280 | mContentLayer.Add( checkBoxBackground ); |
| 281 | 281 | |
| 282 | - Dali::Image unchecked = Dali::Image::New( CHECKBOX_UNCHECKED_IMAGE ); | |
| 283 | - Dali::Image checked = Dali::Image::New( CHECKBOX_CHECKED_IMAGE ); | |
| 282 | + Dali::Image unselected = Dali::Image::New( CHECKBOX_UNSELECTED_IMAGE ); | |
| 283 | + Dali::Image selected = Dali::Image::New( CHECKBOX_SELECTED_IMAGE ); | |
| 284 | 284 | |
| 285 | 285 | int checkYPos = MARGIN_SIZE; |
| 286 | 286 | |
| ... | ... | @@ -290,15 +290,15 @@ class ButtonsController: public ConnectionTracker |
| 290 | 290 | checkBox.SetPosition( DP(MARGIN_SIZE), DP(checkYPos) ); |
| 291 | 291 | checkBox.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 292 | 292 | checkBox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 293 | - checkBox.SetBackgroundImage( unchecked ); | |
| 294 | - checkBox.SetCheckedImage( checked ); | |
| 293 | + checkBox.SetBackgroundImage( unselected ); | |
| 294 | + checkBox.SetSelectedImage( selected ); | |
| 295 | 295 | checkBox.SetSize( DP(48), DP(48) ); |
| 296 | - checkBox.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesToggled ); | |
| 296 | + checkBox.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected ); | |
| 297 | 297 | |
| 298 | 298 | checkBoxBackground.Add( checkBox ); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - mCheckBox1State = Toolkit::TextView::New( "CheckBox1 is unchecked" ); | |
| 301 | + mCheckBox1State = Toolkit::TextView::New( "CheckBox1 is unselected" ); | |
| 302 | 302 | |
| 303 | 303 | mCheckBox1State.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 304 | 304 | mCheckBox1State.SetPosition( DP(80), DP(checkYPos) ); |
| ... | ... | @@ -312,16 +312,16 @@ class ButtonsController: public ConnectionTracker |
| 312 | 312 | checkBox.SetName( "checkbox2" ); |
| 313 | 313 | checkBox.SetPosition( DP(MARGIN_SIZE), DP(checkYPos) ); |
| 314 | 314 | checkBox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 315 | - checkBox.SetBackgroundImage( unchecked ); | |
| 316 | - checkBox.SetCheckedImage( checked ); | |
| 315 | + checkBox.SetBackgroundImage( unselected ); | |
| 316 | + checkBox.SetSelectedImage( selected ); | |
| 317 | 317 | checkBox.SetSize( DP(48), DP(48) ); |
| 318 | - checkBox.SetChecked( true ); | |
| 319 | - checkBox.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesToggled ); | |
| 318 | + checkBox.SetSelected( true ); | |
| 319 | + checkBox.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected ); | |
| 320 | 320 | |
| 321 | 321 | checkBoxBackground.Add( checkBox ); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - mCheckBox2State = Toolkit::TextView::New( "CheckBox2 is checked" ); | |
| 324 | + mCheckBox2State = Toolkit::TextView::New( "CheckBox2 is selected" ); | |
| 325 | 325 | mCheckBox2State.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 326 | 326 | mCheckBox2State.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 327 | 327 | mCheckBox2State.SetPosition( DP(80), DP(checkYPos) ); |
| ... | ... | @@ -335,22 +335,22 @@ class ButtonsController: public ConnectionTracker |
| 335 | 335 | checkBox.SetName( "checkbox3" ); |
| 336 | 336 | checkBox.SetPosition( DP(MARGIN_SIZE), DP(checkYPos) ); |
| 337 | 337 | checkBox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 338 | - checkBox.SetBackgroundImage( unchecked ); | |
| 339 | - checkBox.SetCheckedImage( checked ); | |
| 338 | + checkBox.SetBackgroundImage( unselected ); | |
| 339 | + checkBox.SetSelectedImage( selected ); | |
| 340 | 340 | checkBox.SetSize( DP(48), DP(48) ); |
| 341 | - checkBox.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesToggled ); | |
| 341 | + checkBox.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected ); | |
| 342 | 342 | |
| 343 | 343 | checkBoxBackground.Add( checkBox ); |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - mCheckBox3State = Toolkit::TextView::New( "CheckBox3 is unchecked" ); | |
| 346 | + mCheckBox3State = Toolkit::TextView::New( "CheckBox3 is unselected" ); | |
| 347 | 347 | |
| 348 | 348 | mCheckBox3State.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 349 | 349 | mCheckBox3State.SetPosition( DP(80), DP(checkYPos) ); |
| 350 | 350 | |
| 351 | 351 | checkBoxBackground.Add( mCheckBox3State ); |
| 352 | 352 | |
| 353 | - // Create toggle button | |
| 353 | + // Create togglabe button | |
| 354 | 354 | yPos += GROUP3_HEIGHT + MARGIN_SIZE; |
| 355 | 355 | |
| 356 | 356 | Actor toggleBackground = Toolkit::CreateSolidColorActor( BACKGROUND_COLOUR ); |
| ... | ... | @@ -361,18 +361,18 @@ class ButtonsController: public ConnectionTracker |
| 361 | 361 | mContentLayer.Add( toggleBackground ); |
| 362 | 362 | |
| 363 | 363 | Toolkit::PushButton toggleButton = Toolkit::PushButton::New(); |
| 364 | - toggleButton.SetToggleButton( true ); | |
| 364 | + toggleButton.SetTogglableButton( true ); | |
| 365 | 365 | toggleButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); |
| 366 | 366 | toggleButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 367 | 367 | toggleButton.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) ); |
| 368 | - toggleButton.SetLabel( "Toggle OFF" ); | |
| 368 | + toggleButton.SetLabel( "Unselected" ); | |
| 369 | 369 | toggleButton.SetSize( DP(150), DP(BUTTON_HEIGHT) ); |
| 370 | 370 | |
| 371 | 371 | toggleButton.SetSelectedImage( Dali::Image::New( PUSHBUTTON_PRESS_IMAGE ) ); |
| 372 | 372 | toggleButton.SetDisabledImage( Dali::Image::New( PUSHBUTTON_DISABLED_IMAGE ) ); |
| 373 | 373 | toggleButton.SetButtonImage( Dali::Image::New( PUSHBUTTON_BUTTON_IMAGE ) ); |
| 374 | 374 | |
| 375 | - toggleButton.StateChangedSignal().Connect( this, &ButtonsController::OnButtonToggled ); | |
| 375 | + toggleButton.StateChangedSignal().Connect( this, &ButtonsController::OnButtonSelected ); | |
| 376 | 376 | |
| 377 | 377 | toggleBackground.Add( toggleButton ); |
| 378 | 378 | } |
| ... | ... | @@ -389,31 +389,31 @@ class ButtonsController: public ConnectionTracker |
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - bool OnButtonToggled( Toolkit::Button button, bool state ) | |
| 392 | + bool OnButtonSelected( Toolkit::Button button ) | |
| 393 | 393 | { |
| 394 | 394 | Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( button ); |
| 395 | 395 | if( pushButton ) |
| 396 | 396 | { |
| 397 | - if( state ) | |
| 397 | + if( button.IsSelected() ) | |
| 398 | 398 | { |
| 399 | - pushButton.SetLabel( "Toggle ON" ); | |
| 399 | + pushButton.SetLabel( "Selected" ); | |
| 400 | 400 | } |
| 401 | 401 | else |
| 402 | 402 | { |
| 403 | - pushButton.SetLabel( "Toggle OFF" ); | |
| 403 | + pushButton.SetLabel( "Unselected" ); | |
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | return true; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - bool EnableSelectButtonToggle( Toolkit::Button button, bool state ) | |
| 410 | + bool EnableSelectButton( Toolkit::Button button ) | |
| 411 | 411 | { |
| 412 | - if( button.GetName() == "radio-select-enable" && state == true ) | |
| 412 | + if( button.GetName() == "radio-select-enable" && button.IsSelected() == true ) | |
| 413 | 413 | { |
| 414 | 414 | mUpdateButton.SetDisabled( false ); |
| 415 | 415 | } |
| 416 | - else if( button.GetName() == "radio-select-disable" && state == true ) | |
| 416 | + else if( button.GetName() == "radio-select-disable" && button.IsSelected() == true ) | |
| 417 | 417 | { |
| 418 | 418 | mUpdateButton.SetDisabled( true ); |
| 419 | 419 | } |
| ... | ... | @@ -438,41 +438,41 @@ class ButtonsController: public ConnectionTracker |
| 438 | 438 | return true; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - bool OnCheckBoxesToggled( Toolkit::Button button, bool state ) | |
| 441 | + bool OnCheckBoxesSelected( Toolkit::Button button ) | |
| 442 | 442 | { |
| 443 | 443 | if( button.GetName() == "checkbox1" ) |
| 444 | 444 | { |
| 445 | - if( state ) | |
| 445 | + if( button.IsSelected() ) | |
| 446 | 446 | { |
| 447 | - mCheckBox1State.SetText("CheckBox1 is checked"); | |
| 447 | + mCheckBox1State.SetText("CheckBox1 is selected"); | |
| 448 | 448 | } |
| 449 | 449 | else |
| 450 | 450 | { |
| 451 | - mCheckBox1State.SetText("CheckBox1 is unchecked"); | |
| 451 | + mCheckBox1State.SetText("CheckBox1 is unselected"); | |
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | if( button.GetName() == "checkbox2" ) |
| 456 | 456 | { |
| 457 | - if( state ) | |
| 457 | + if( button.IsSelected() ) | |
| 458 | 458 | { |
| 459 | - mCheckBox2State.SetText("CheckBox2 is checked"); | |
| 459 | + mCheckBox2State.SetText("CheckBox2 is selected"); | |
| 460 | 460 | } |
| 461 | 461 | else |
| 462 | 462 | { |
| 463 | - mCheckBox2State.SetText("CheckBox2 is unchecked"); | |
| 463 | + mCheckBox2State.SetText("CheckBox2 is unselected"); | |
| 464 | 464 | } |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | if( button.GetName() == "checkbox3" ) |
| 468 | 468 | { |
| 469 | - if( state ) | |
| 469 | + if( button.IsSelected() ) | |
| 470 | 470 | { |
| 471 | - mCheckBox3State.SetText("CheckBox3 is checked"); | |
| 471 | + mCheckBox3State.SetText("CheckBox3 is selected"); | |
| 472 | 472 | } |
| 473 | 473 | else |
| 474 | 474 | { |
| 475 | - mCheckBox3State.SetText("CheckBox3 is unchecked"); | |
| 475 | + mCheckBox3State.SetText("CheckBox3 is unselected"); | |
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | 478 | ... | ... |
examples/logging/logging-example.cpp
| ... | ... | @@ -554,17 +554,17 @@ class LoggingController: public ConnectionTracker |
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - bool LoggingRadioSelect( Toolkit::Button button, bool state ) | |
| 557 | + bool LoggingRadioSelect( Toolkit::Button button ) | |
| 558 | 558 | { |
| 559 | - if( button.GetName() == LOGGER_1_RADIO_ID && state == true ) | |
| 559 | + if( button.GetName() == LOGGER_1_RADIO_ID && button.IsSelected() == true ) | |
| 560 | 560 | { |
| 561 | 561 | mCurrentLogger = 0; |
| 562 | 562 | } |
| 563 | - else if( button.GetName() == LOGGER_2_RADIO_ID && state == true ) | |
| 563 | + else if( button.GetName() == LOGGER_2_RADIO_ID && button.IsSelected() == true ) | |
| 564 | 564 | { |
| 565 | 565 | mCurrentLogger = 1; |
| 566 | 566 | } |
| 567 | - else if( button.GetName() == LOGGER_3_RADIO_ID && state == true ) | |
| 567 | + else if( button.GetName() == LOGGER_3_RADIO_ID && button.IsSelected() == true ) | |
| 568 | 568 | { |
| 569 | 569 | mCurrentLogger = 2; |
| 570 | 570 | } |
| ... | ... | @@ -592,9 +592,9 @@ class LoggingController: public ConnectionTracker |
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - bool FrequencyRadioSelect( Toolkit::Button button, bool state ) | |
| 595 | + bool FrequencyRadioSelect( Toolkit::Button button ) | |
| 596 | 596 | { |
| 597 | - if( button.GetName() == FREQUENCY_1_RADIO_ID && state == true ) | |
| 597 | + if( button.GetName() == FREQUENCY_1_RADIO_ID && button.IsSelected() == true ) | |
| 598 | 598 | { |
| 599 | 599 | if( mPerformanceLoggers[mCurrentLogger] ) |
| 600 | 600 | { |
| ... | ... | @@ -605,7 +605,7 @@ class LoggingController: public ConnectionTracker |
| 605 | 605 | mLoggerStates[mCurrentLogger].frequency = HIGH_FREQUENCY; |
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | - else if( button.GetName() == FREQUENCY_2_RADIO_ID && state == true ) | |
| 608 | + else if( button.GetName() == FREQUENCY_2_RADIO_ID && button.IsSelected() == true ) | |
| 609 | 609 | { |
| 610 | 610 | if( mPerformanceLoggers[mCurrentLogger] ) |
| 611 | 611 | { |
| ... | ... | @@ -616,7 +616,7 @@ class LoggingController: public ConnectionTracker |
| 616 | 616 | mLoggerStates[mCurrentLogger].frequency = MEDIUM_FREQUENCY; |
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | - else if( button.GetName() == FREQUENCY_3_RADIO_ID && state == true ) | |
| 619 | + else if( button.GetName() == FREQUENCY_3_RADIO_ID && button.IsSelected() == true ) | |
| 620 | 620 | { |
| 621 | 621 | if( mPerformanceLoggers[mCurrentLogger] ) |
| 622 | 622 | { | ... | ... |