From 72c6ee5a66b52cadbd97c9b3d2aa59762a98069e Mon Sep 17 00:00:00 2001 From: Kingsley Stephens Date: Wed, 10 Sep 2014 13:29:49 +0100 Subject: [PATCH] Radio button example Change-Id: If745c02e307876871cf8cbbdeb97d464cc021fef --- build/tizen/examples/Makefile.am | 8 +- com.samsung.dali-demo.xml | 3 + demo/images/button-disabled.9.png | Bin 0 -> 852 bytes demo/images/button-down.9.png | Bin 0 -> 1030 bytes demo/images/button-up.9.png | Bin 0 -> 1013 bytes demo/images/checkbox-checked.png | Bin 0 -> 1989 bytes demo/images/checkbox-unchecked.png | Bin 0 -> 629 bytes examples/buttons/buttons-example.cpp | 521 +++++++++++++++++++++++++++ 8 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 demo/images/button-disabled.9.png create mode 100644 demo/images/button-down.9.png create mode 100644 demo/images/button-up.9.png create mode 100644 demo/images/checkbox-checked.png create mode 100644 demo/images/checkbox-unchecked.png create mode 100644 examples/buttons/buttons-example.cpp diff --git a/build/tizen/examples/Makefile.am b/build/tizen/examples/Makefile.am index f30f9227..0a358e66 100644 --- a/build/tizen/examples/Makefile.am +++ b/build/tizen/examples/Makefile.am @@ -32,7 +32,8 @@ bin_PROGRAMS = \ shadow-bone-lighting.example \ dali-builder \ builder.example \ - image-scaling-irregular-grid.example + image-scaling-irregular-grid.example \ + buttons.example daliimagedir = $(appdatadir)/images/ @@ -146,3 +147,8 @@ image_scaling_irregular_grid_example_SOURCES = $(examples_src_dir)/image/image-s image_scaling_irregular_grid_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) image_scaling_irregular_grid_example_DEPENDENCIES = $(EXAMPLE_DEPS) image_scaling_irregular_grid_example_LDADD = $(EXAMPLE_LDADD) + +buttons_example_SOURCES = $(examples_src_dir)/buttons/buttons-example.cpp +buttons_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) +buttons_example_DEPENDENCIES = $(EXAMPLE_DEPS) +buttons_example_LDADD = $(EXAMPLE_LDADD) diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index 7a632d61..2c079338 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -61,4 +61,7 @@ + + + diff --git a/demo/images/button-disabled.9.png b/demo/images/button-disabled.9.png new file mode 100644 index 0000000000000000000000000000000000000000..d9286e28d90234e0036ad6dfa33e2efce6e15191 GIT binary patch literal 852 zcmV-a1FQUrP)P002A)1^@s6lZX-K0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!_DMuRRCwC#n7ymoP!zzE_>nKQRupuw zL+RMRq5nYXXba^PHwOo?mAX86ICQZ^=-|{vc+{bl(y8#~{tboFrK2Ahs`wd=(VlZL z5>1{OH4YCCgqy^3?(d#+PpUgqJ;7(E(@6<}Kye&LIUEi&qR?hKol-CWYB(H{dysh~5~{v?pWPZR_>l<)g9Lz``FuVC!27k)Q7)H@To5V(>UO&{04@N8$`^WlM*k3vM&D_G zKp;RmSO=JdgXp0?-UI06_4Tzm1i}=8IY{F@dcd-*r7S{yv_mfR^8xyE7$D$oR#6mQ zn}dA>?a&^=7aom9FU%lMHN|Zq+7vo%fc<{|xdAd53?5>OS#*eK_Tb6m6$r#H0BJ}j z0n_vl(d^;Fy}tqhfJ^W4fy)SKVPz0ZQ`jy!L(Y&h}8!3viRNM!E_8iAGz>_ZqNHUph zg+if^i@FGL+lrt*+Tq*>gTc4ZpKAK|TdUP_e!u@GW>}}w+1Vr1Lw&S^fmSk^%;$|Y z$Wp1qOOkZcZnu}^K`hF+-R_n0AZ8(s9uq|?4P002A)1^@s6lZX-K0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#s7XXYRCwC#m~TiEVHm*Q_jddL=iDFD zHv5NE7Lu5h^sPSh&4`4Mf(Qz!Koq0|%L=LwSq3FpNFYHFS>Tt%K13fQDA62hLTPSo zQ`6e?^tRh=cinqa*>>vOb`yd<$H9#~&-;6yKkv)K138WZ$q0myH{oDXHpxPg6|^aQ zErsf9XL3F6i6@ip$-{F#(%`3PIU5Q?48u6JP8Bj)j5GPRydI<3So^&B6_vCn$Icz? z9JY^C`pE#EXtz2-8!Rr}+t$_IQ@@fYBFKg7XASoL!6C;FX94=HP|1OYPyt+p0}KjQ z0Pr>}%YhIb2Gnc-1Op6!{8Lo2tIw2|bMQ@TcX(CE$=V8;Yiz>718n@CfXLGUg+`t* z?m>SD%ubPjz1UCz;8Hpp+;R6qcwR)LffzDj;0CK~~e-H84B z{;Hbex1!fwhMaFay?wBMxB`9W8A|MU?@CF z&H6kLd!!J;JLe^p?&0e?D@y%^%cZG>TX}OF?2}qN`_;RGEGrrFcKV!^ebZ^6uqDVi|b+-O!poU!o@I* zECv!Co^(PLchW%|Bq~A}lmHM{-th_;l>R1OguskaGM1CI!zGgl0)aU38TSO8&}9;o zq<#~G3&SLe7F@l$GMacOx|b!%d4>}Y*T@OPHsG9O;8xk_6AvYH1;$^8d|wowlXPFv z*%LZ+n2AiR(064aSx6R=g=8UF$bSLRs&xUW7F?R5DCF{R45az;L$^YyV9|G&38w{N zLlJweUPFt*W!_{Wh55=HofgDTM(oYGW|s)EWm~}~VQAnX(}H;25qqo6+9`rqt(z|? zRZ5nc^@9bkKP3RNL-vH3pm!GTz9WLPHa#0JEidU7<}BZSgCNBu1wi`94t1ah%FFIG zR^JS*Si%~ey0WlnhZ{}h9A7=__6X@Y1}21Q-oCQpzK**uZ^Sf=@#DdUmRiG?&%HyV zBV)n#)erT$tVXXM92dKc-!&5Ea41tNlw+B=p5*^SI(0Q z2?w19LLV$GFKv6#@_K!P&S<%Ezb4n^azA!DTu1&+|1nbY0i5GlAj2?DtJj7sd6sG0 zR_i;9#Zvp|YCE;cjD_2{;d6XvFQuS{{+|E?0AIdQfJO^1iU0rr07*qoM6N<$f~?)v A-v9sr literal 0 HcmV?d00001 diff --git a/demo/images/button-up.9.png b/demo/images/button-up.9.png new file mode 100644 index 0000000000000000000000000000000000000000..7a20d38fbbbb5f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rKnJ0$5Yr2lDD|aH~E#d45nR;b1Jzoqu zOYG3nY6{!$c^uK&7QS*Y+h z(Cn@jb#WA6C=|NU-`|gPIt`!CciU{X$Lj-2o2YuxX5?L36vffr*VhNH*BhhnhQtu} z^z;7y0W}(9IxjVn8Wjqq z^9l|OI84AF-#6dP;|aEHgK3(uTCHHYT!J77z;hsvBuNkq1|bj#fQ)d3LIEa|iJD5K zinG})v0ksa0fxij_u+8(+-|qus@3Wj;CMXNqS5FJ+stM%8PGJ13mmd^yIoi;7I)2N z^IF&SR|hbiP8U^G&6Y|fh(sb>EoN{~E|<>@!+1~>NgrtDtw`Zjw|GH!$Ah6!e}!DheJ{%;KuB? zC1W41*Xvc-=54)RKa0oXP6PX|l|(oc2I2bsK6E;rN5e2|0b8!ISPY4;^7;HdTVJw| zZBEvTjN_fbJ=JQpN~6&L0jXQ97U;U}*y{}r50{y(CR5Jouwq;KQ-A>g*ThuSh|35n P00000NkvXXu0mjfy&Muu literal 0 HcmV?d00001 diff --git a/examples/buttons/buttons-example.cpp b/examples/buttons/buttons-example.cpp new file mode 100644 index 00000000..bbdeab1b --- /dev/null +++ b/examples/buttons/buttons-example.cpp @@ -0,0 +1,521 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "../shared/view.h" +#include +#include + +using namespace Dali; + +namespace +{ +// Used to produce visually same dimensions on desktop and device builds +float ScalePointSize( int pointSize ) +{ + Dali::Vector2 dpi = Dali::Stage::GetCurrent().GetDpi(); + float meanDpi = (dpi.height + dpi.width) * 0.5f; + return pointSize * meanDpi / 220.0f; +} + +} // namespace + +// Define this so that it is interchangeable +// "DP" stands for Device independent Pixels +#define DP(x) ScalePointSize(x) + + +namespace +{ + +const char* const BACKGROUND_IMAGE = DALI_IMAGE_DIR "background-gradient.jpg"; +const char* const TOOLBAR_IMAGE = DALI_IMAGE_DIR "top-bar.png"; + +const char* const TOOLBAR_TITLE = "Buttons"; + +const char* const SMALL_IMAGE_1 = DALI_IMAGE_DIR "gallery-small-14.jpg"; +const char* const BIG_IMAGE_1 = DALI_IMAGE_DIR "gallery-large-4.jpg"; + +const char* const SMALL_IMAGE_2 = DALI_IMAGE_DIR "gallery-small-20.jpg"; +const char* const BIG_IMAGE_2 = DALI_IMAGE_DIR "gallery-large-11.jpg"; + +const char* const SMALL_IMAGE_3 = DALI_IMAGE_DIR "gallery-small-25.jpg"; +const char* const BIG_IMAGE_3 = DALI_IMAGE_DIR "gallery-large-13.jpg"; + +const char* const ENABLED_IMAGE = DALI_IMAGE_DIR "item-select-check.png"; + +const char* const PUSHBUTTON_PRESS_IMAGE = DALI_IMAGE_DIR "button-down.9.png"; +const char* const PUSHBUTTON_DIM_IMAGE = DALI_IMAGE_DIR "button-disabled.9.png"; +const char* const PUSHBUTTON_BUTTON_IMAGE = DALI_IMAGE_DIR "button-up.9.png"; + +const char* const CHECKBOX_UNCHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-unchecked.png"; +const char* const CHECKBOX_CHECKED_IMAGE = DALI_IMAGE_DIR "checkbox-checked.png"; + +const Vector4 BACKGROUND_COLOUR( 1.0f, 1.0f, 1.0f, 0.15f ); + +// Layout sizes +const int RADIO_LABEL_THUMBNAIL_SIZE = 48; +const int RADIO_IMAGE_SPACING = 8; +const int BUTTON_HEIGHT = 48; + +const int MARGIN_SIZE = 10; +const int TOP_MARGIN = 85; +const int GROUP2_HEIGHT = 238; +const int GROUP1_HEIGHT = 120; +const int GROUP3_HEIGHT = 190; +const int GROUP4_HEIGHT = BUTTON_HEIGHT + MARGIN_SIZE * 2; + +} // namespace + +/** This example shows how to create and use different buttons. + * + * 1. First group of radio buttons with image actor labels selects an image to load + * 2. A push button loads the selected thumbnail image into the larger image pane + * 3. Second group of radio buttons with a table view label containing a text view and image view, and a normal text view. + * Selecting one of these will enable/disable the image loading push button + * 4. A group of check boxes + */ +class ButtonsController: public ConnectionTracker +{ + public: + + ButtonsController( Application& application ) + : mApplication( application ) + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &ButtonsController::Create ); + } + + ~ButtonsController() + { + // Nothing to do here + } + + void Create( Application& application ) + { + // The Init signal is received once (only) during the Application lifetime + + // Respond to key events + Stage::GetCurrent().KeyEventSignal().Connect(this, &ButtonsController::OnKeyEvent); + + // Creates a default view with a default tool bar. + // The view is added to the stage. + mContentLayer = DemoHelper::CreateView( application, + mView, + mToolBar, + BACKGROUND_IMAGE, + TOOLBAR_IMAGE, + TOOLBAR_TITLE ); + + int yPos = TOP_MARGIN + MARGIN_SIZE; + + // Image selector radio group + Actor radioGroup2Background = Toolkit::CreateSolidColorActor( BACKGROUND_COLOUR ); + radioGroup2Background.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + radioGroup2Background.SetParentOrigin( ParentOrigin::TOP_LEFT ); + radioGroup2Background.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); + radioGroup2Background.SetSize( DP(348), DP(GROUP2_HEIGHT) ); + mContentLayer.Add( radioGroup2Background ); + + Actor radioButtonsGroup2 = Actor::New(); + radioButtonsGroup2.SetParentOrigin( ParentOrigin::TOP_LEFT ); + radioButtonsGroup2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + radioButtonsGroup2.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) ); + radioButtonsGroup2.SetSize( DP(100), DP(160) ); + + radioGroup2Background.Add( radioButtonsGroup2 ); + + int radioY = 0; + + // Radio 1 + { + ImageActor imageActor = ImageActor::New( Image::New( SMALL_IMAGE_1 ) ); + imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + mRadioButtonImage1 = Dali::Toolkit::RadioButton::New( imageActor ); + mRadioButtonImage1.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mRadioButtonImage1.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mRadioButtonImage1.SetPosition( 0, DP(radioY) ); + mRadioButtonImage1.SetActive( true ); + + radioButtonsGroup2.Add( mRadioButtonImage1 ); + } + + // Radio 2 + { + radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING; + + ImageActor imageActor = ImageActor::New( Image::New( SMALL_IMAGE_2 ) ); + imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + + mRadioButtonImage2 = Dali::Toolkit::RadioButton::New( imageActor ); + mRadioButtonImage2.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mRadioButtonImage2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mRadioButtonImage2.SetPosition( 0, DP(radioY) ); + + radioButtonsGroup2.Add( mRadioButtonImage2 ); + } + + // Radio 3 + { + radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING; + + ImageActor imageActor = ImageActor::New( Image::New( SMALL_IMAGE_3 ) ); + imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + + mRadioButtonImage3 = Dali::Toolkit::RadioButton::New( imageActor ); + mRadioButtonImage3.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mRadioButtonImage3.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mRadioButtonImage3.SetPosition( 0, DP(radioY) ); + + radioButtonsGroup2.Add( mRadioButtonImage3 ); + } + + // Create select button + mUpdateButton = Toolkit::PushButton::New(); + mUpdateButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); + mUpdateButton.SetAnchorPoint( AnchorPoint::TOP_CENTER ); + mUpdateButton.SetPosition( 0, DP(MARGIN_SIZE) ); + mUpdateButton.SetLabelText("Select"); + mUpdateButton.SetSize( DP(100), DP(BUTTON_HEIGHT) ); + + mUpdateButton.SetPressedImage( Dali::Image::New( PUSHBUTTON_PRESS_IMAGE ) ); + mUpdateButton.SetDimmedImage( Dali::Image::New( PUSHBUTTON_DIM_IMAGE ) ); + mUpdateButton.SetButtonImage( Dali::Image::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + mUpdateButton.ClickedSignal().Connect( this, &ButtonsController::OnButtonClicked ); + + radioButtonsGroup2.Add(mUpdateButton); + + // ImageActor to display selected image + mBigImage1 = Image::New( BIG_IMAGE_1 ); + mBigImage2 = Image::New( BIG_IMAGE_2 ); + mBigImage3 = Image::New( BIG_IMAGE_3 ); + + mImage = ImageActor::New( mBigImage1 ); + mImage.SetParentOrigin( ParentOrigin::TOP_RIGHT ); + mImage.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mImage.SetPosition( DP(MARGIN_SIZE), 0 ); + mImage.SetSize( DP(218), DP(218) ); + radioButtonsGroup2.Add( mImage ); + + // The enable/disable radio group + yPos += GROUP2_HEIGHT + MARGIN_SIZE; + + Actor radioGroup1Background = Toolkit::CreateSolidColorActor( BACKGROUND_COLOUR ); + radioGroup1Background.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + radioGroup1Background.SetParentOrigin( ParentOrigin::TOP_LEFT ); + radioGroup1Background.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); + radioGroup1Background.SetSize( DP(348), DP(GROUP1_HEIGHT) ); + mContentLayer.Add( radioGroup1Background ); + + // Radio group + Actor radioButtonsGroup1 = Actor::New(); + radioButtonsGroup1.SetParentOrigin( ParentOrigin::TOP_LEFT ); + radioButtonsGroup1.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + radioButtonsGroup1.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) ); + + radioGroup1Background.Add( radioButtonsGroup1 ); + + // First radio button + { + Toolkit::TableView tableView = Toolkit::TableView::New( 1, 2 ); + tableView.SetSize( DP(260), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + + Toolkit::TextView textView = Toolkit::TextView::New( "Select enabled" ); + Toolkit::Alignment alignment = Toolkit::Alignment::New( Toolkit::Alignment::HorizontalLeft ); + alignment.Add( textView ); + tableView.AddChild( alignment, Toolkit::TableView::CellPosition( 0, 0 ) ); + + ImageActor imageActor = ImageActor::New( Image::New( ENABLED_IMAGE ) ); + imageActor.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + tableView.AddChild( imageActor, Toolkit::TableView::CellPosition( 0, 1 ) ); + tableView.SetFixedWidth( 1, DP(RADIO_LABEL_THUMBNAIL_SIZE) ); + + Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( tableView ); + radioButton.SetName( "radio-select-enable" ); + radioButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); + radioButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + radioButton.SetPosition( 0, 0 ); + radioButton.SetActive( true ); + + radioButton.ToggledSignal().Connect( this, &ButtonsController::EnableSelectButtonToggle ); + + radioButtonsGroup1.Add( radioButton ); + } + + // Second radio button + { + Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( "Select disabled" ); + radioButton.SetName( "radio-select-disable" ); + radioButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); + radioButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + radioButton.SetPosition( 0, DP(50) ); + + radioButton.ToggledSignal().Connect( this, &ButtonsController::EnableSelectButtonToggle ); + + radioButtonsGroup1.Add( radioButton ); + } + + // CheckBoxes + yPos += GROUP1_HEIGHT + MARGIN_SIZE; + + Actor checkBoxBackground = Toolkit::CreateSolidColorActor( BACKGROUND_COLOUR ); + checkBoxBackground.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + checkBoxBackground.SetParentOrigin( ParentOrigin::TOP_LEFT ); + checkBoxBackground.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); + checkBoxBackground.SetSize( DP(430), DP(GROUP3_HEIGHT) ); + mContentLayer.Add( checkBoxBackground ); + + Dali::Image unchecked = Dali::Image::New( CHECKBOX_UNCHECKED_IMAGE ); + Dali::Image checked = Dali::Image::New( CHECKBOX_CHECKED_IMAGE ); + + int checkYPos = MARGIN_SIZE; + + { + Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New(); + checkBox.SetName( "checkbox1" ); + checkBox.SetPosition( DP(MARGIN_SIZE), DP(checkYPos) ); + checkBox.SetParentOrigin( ParentOrigin::TOP_LEFT ); + checkBox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + checkBox.SetBackgroundImage( unchecked ); + checkBox.SetCheckedImage( checked ); + checkBox.SetSize( DP(48), DP(48) ); + checkBox.ToggledSignal().Connect( this, &ButtonsController::OnCheckBoxesToggled ); + + checkBoxBackground.Add( checkBox ); + } + + mCheckBox1State = Toolkit::TextView::New( "CheckBox1 is unchecked" ); + + mCheckBox1State.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mCheckBox1State.SetPosition( DP(80), DP(checkYPos) ); + + checkBoxBackground.Add( mCheckBox1State ); + + checkYPos += 60; + + { + Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New(); + checkBox.SetName( "checkbox2" ); + checkBox.SetPosition( DP(MARGIN_SIZE), DP(checkYPos) ); + checkBox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + checkBox.SetBackgroundImage( unchecked ); + checkBox.SetCheckedImage( checked ); + checkBox.SetSize( DP(48), DP(48) ); + checkBox.SetChecked( true ); + checkBox.ToggledSignal().Connect( this, &ButtonsController::OnCheckBoxesToggled ); + + checkBoxBackground.Add( checkBox ); + } + + mCheckBox2State = Toolkit::TextView::New( "CheckBox2 is checked" ); + mCheckBox2State.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mCheckBox2State.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mCheckBox2State.SetPosition( DP(80), DP(checkYPos) ); + + checkBoxBackground.Add( mCheckBox2State ); + + checkYPos += 60; + + { + Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New(); + checkBox.SetName( "checkbox3" ); + checkBox.SetPosition( DP(MARGIN_SIZE), DP(checkYPos) ); + checkBox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + checkBox.SetBackgroundImage( unchecked ); + checkBox.SetCheckedImage( checked ); + checkBox.SetSize( DP(48), DP(48) ); + checkBox.ToggledSignal().Connect( this, &ButtonsController::OnCheckBoxesToggled ); + + checkBoxBackground.Add( checkBox ); + } + + mCheckBox3State = Toolkit::TextView::New( "CheckBox3 is unchecked" ); + + mCheckBox3State.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mCheckBox3State.SetPosition( DP(80), DP(checkYPos) ); + + checkBoxBackground.Add( mCheckBox3State ); + + // Create toggle button + yPos += GROUP3_HEIGHT + MARGIN_SIZE; + + Actor toggleBackground = Toolkit::CreateSolidColorActor( BACKGROUND_COLOUR ); + toggleBackground.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + toggleBackground.SetParentOrigin( ParentOrigin::TOP_LEFT ); + toggleBackground.SetPosition( DP(MARGIN_SIZE), DP(yPos) ); + toggleBackground.SetSize( DP(150 + MARGIN_SIZE * 2), DP(GROUP4_HEIGHT) ); + mContentLayer.Add( toggleBackground ); + + Toolkit::PushButton toggleButton = Toolkit::PushButton::New(); + toggleButton.SetToggleButton( true ); + toggleButton.SetParentOrigin( ParentOrigin::TOP_LEFT ); + toggleButton.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + toggleButton.SetPosition( DP(MARGIN_SIZE), DP(MARGIN_SIZE) ); + toggleButton.SetLabelText( "Toggle OFF" ); + toggleButton.SetSize( DP(150), DP(BUTTON_HEIGHT) ); + + toggleButton.SetPressedImage( Dali::Image::New( PUSHBUTTON_PRESS_IMAGE ) ); + toggleButton.SetDimmedImage( Dali::Image::New( PUSHBUTTON_DIM_IMAGE ) ); + toggleButton.SetButtonImage( Dali::Image::New( PUSHBUTTON_BUTTON_IMAGE ) ); + + toggleButton.ToggledSignal().Connect( this, &ButtonsController::OnButtonToggled ); + + toggleBackground.Add( toggleButton ); + } + + void OnKeyEvent( const KeyEvent& event ) + { + if( event.state == KeyEvent::Down ) + { + if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + { + // Exit application when click back or escape. + mApplication.Quit(); + } + } + } + + bool OnButtonToggled( Toolkit::Button button, bool state ) + { + Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( button ); + if( pushButton ) + { + if( state ) + { + pushButton.SetLabelText( "Toggle ON" ); + } + else + { + pushButton.SetLabelText( "Toggle OFF" ); + } + } + + return true; + } + + bool EnableSelectButtonToggle( Toolkit::Button button, bool state ) + { + if( button.GetName() == "radio-select-enable" && state == true ) + { + mUpdateButton.SetDimmed( false ); + } + else if( button.GetName() == "radio-select-disable" && state == true ) + { + mUpdateButton.SetDimmed( true ); + } + + return true; + } + + bool OnButtonClicked(Toolkit::Button button) + { + if( mRadioButtonImage1.IsActive() ) + { + mImage.SetImage( mBigImage1 ); + } + else if( mRadioButtonImage2.IsActive() ) + { + mImage.SetImage( mBigImage2 ); + } + else if( mRadioButtonImage3.IsActive() ) + { + mImage.SetImage( mBigImage3 ); + } + return true; + } + + bool OnCheckBoxesToggled( Toolkit::Button button, bool state ) + { + if( button.GetName() == "checkbox1" ) + { + if( state ) + { + mCheckBox1State.SetText("CheckBox1 is checked"); + } + else + { + mCheckBox1State.SetText("CheckBox1 is unchecked"); + } + } + + if( button.GetName() == "checkbox2" ) + { + if( state ) + { + mCheckBox2State.SetText("CheckBox2 is checked"); + } + else + { + mCheckBox2State.SetText("CheckBox2 is unchecked"); + } + } + + if( button.GetName() == "checkbox3" ) + { + if( state ) + { + mCheckBox3State.SetText("CheckBox3 is checked"); + } + else + { + mCheckBox3State.SetText("CheckBox3 is unchecked"); + } + } + + return true; + } + + private: + + Application& mApplication; + Toolkit::View mView; ///< The View instance. + Toolkit::ToolBar mToolBar; ///< The View's Toolbar. + Layer mContentLayer; ///< Content layer + + Toolkit::RadioButton mRadioButtonImage1; + Toolkit::RadioButton mRadioButtonImage2; + Toolkit::RadioButton mRadioButtonImage3; + + Toolkit::PushButton mUpdateButton; + + Image mBigImage1; + Image mBigImage2; + Image mBigImage3; + ImageActor mImage; + + Toolkit::TextView mCheckBox1State; + Toolkit::TextView mCheckBox2State; + Toolkit::TextView mCheckBox3State; +}; + +void RunTest( Application& application ) +{ + ButtonsController test( application ); + + application.MainLoop(); +} + +// Entry point for Linux & SLP applications +// +int main( int argc, char **argv ) +{ + Application application = Application::New( &argc, &argv ); + + RunTest( application ); + + return 0; +} -- 2.34.1