From efc136204e9a4460a7a2421e673c873e23974a80 Mon Sep 17 00:00:00 2001 From: Chu Hoang Date: Thu, 25 Jun 2015 16:41:58 +0100 Subject: [PATCH] Refactored Button and derived classes, moving state change and transition logic to base class. Added default images for PushButton, CheckBoxButton and RadioButton. Change-Id: I0acd58074bf72eb7d9bc1f809ecc4de6bcc9aeb8 --- dali-toolkit/images/button-disabled.9.png | Bin 0 -> 852 bytes dali-toolkit/images/button-down-disabled.9.png | Bin 0 -> 1759 bytes dali-toolkit/images/button-down.9.png | Bin 0 -> 1030 bytes dali-toolkit/images/button-up.9.png | Bin 0 -> 1013 bytes dali-toolkit/images/checkbox-selected-diabled.png | Bin 0 -> 2162 bytes dali-toolkit/images/checkbox-selected.png | Bin 0 -> 1989 bytes .../images/checkbox-unselected-disabled.png | Bin 0 -> 1461 bytes dali-toolkit/images/checkbox-unselected.png | Bin 0 -> 629 bytes .../images/radio-button-selected-disabled.png | Bin 0 -> 4338 bytes .../images/radio-button-unselected-disabled.png | Bin 0 -> 3936 bytes .../internal/controls/buttons/button-impl.cpp | 1015 ++++++++------------ .../internal/controls/buttons/button-impl.h | 125 ++- .../controls/buttons/check-box-button-impl.cpp | 208 ++-- .../controls/buttons/check-box-button-impl.h | 34 +- .../internal/controls/buttons/push-button-impl.cpp | 452 +-------- .../internal/controls/buttons/push-button-impl.h | 61 +- .../controls/buttons/radio-button-impl.cpp | 36 +- .../internal/controls/buttons/radio-button-impl.h | 2 +- 18 files changed, 649 insertions(+), 1284 deletions(-) create mode 100644 dali-toolkit/images/button-disabled.9.png create mode 100644 dali-toolkit/images/button-down-disabled.9.png create mode 100644 dali-toolkit/images/button-down.9.png create mode 100644 dali-toolkit/images/button-up.9.png create mode 100644 dali-toolkit/images/checkbox-selected-diabled.png create mode 100644 dali-toolkit/images/checkbox-selected.png create mode 100644 dali-toolkit/images/checkbox-unselected-disabled.png create mode 100644 dali-toolkit/images/checkbox-unselected.png create mode 100644 dali-toolkit/images/radio-button-selected-disabled.png create mode 100644 dali-toolkit/images/radio-button-unselected-disabled.png diff --git a/dali-toolkit/images/button-disabled.9.png b/dali-toolkit/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|?4w%!4;_XzWwFr)Ap>;rzT5zmZLGePYB7=%ntz{J24Ttp)$DP^T?|b`xzxR9Zdv7); zJnXAc9uqwT0>LP~P8-R;C-8TW`!N2wJ$vjUmw^k3;})?DmqyrWL9me}X+UowlITd9 zFs@j3kq#0FhO9S7#c^?l1vtf8#DvR7?6lZ;G*33iX(Om)ngd8W$!t}LIxEhJ0JBjg zij^54gH1!5%(`?ty(m2_ib_wWFr#SBY#_*q^8^-}BLJr*#p=MFDp4;l&aYi&i3sR* z;gVINK2dRoa6rS_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r07*qoM6N<$f~?)v A-v9sr literal 0 HcmV?d00001 diff --git a/dali-toolkit/images/button-up.9.png b/dali-toolkit/images/button-up.9.png new file mode 100644 index 0000000000000000000000000000000000000000..7a20d38fbbbb5f88ab5547c8bbaaa750bcc0e184 GIT binary patch literal 1013 zcmVP002A)1^@s6lZX-K0000PbVXQnQ*UN; zcVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU#mq|oHRCwC#n9pw#K@`W|vMdd37bp;E z1#LW3nkHzX2mKGc7_HtsnkJYuX+nCkF}Ag7h@qGE(1Tn&dT7+toAK6*CMI5JL1VF4 zV@vr_3M{|bU1zp|K)1gZSPq7lOc-|e&F9T`-ehMVAqWD6g`NeT(|uiHV7#Y{>llyf+XCjAt?# z`mAV;Mq_$pWMpP)YHIOZ5EQ*G7!0m$Zf@Sh|IHWsp#QcWxGQNWGHKvR4pbZoJsCZa zTY89mNkd{Mi3bCx)457f)Wg}?S^h)_x~W34d_{m8q?&}`Q9H2Lx6z%`){Owhe+j<7 z-+@ZGfvc7ZTkR|@ zEm{43{}bFFeqaOEzAGz>SX)G#IaX$4W8>w@$_gogB$LS(g+f7Nv6&$2{L@srX0L4n z_TS&%?+b^+k0lV4s(0|O^%etYrJ90ZKkSb!7K=TSK;rSZ4gcaSYQ?Jl2L}g^1_(-9 zOR-p_aKE5$4N~>bX0wI{NG_M7YExEmEkUaOrBbO!BA1fZg>)fZNEgzD{QnSqE>avK z_k`Yzsl``j{ZUm=2vTo+TRtU-;~}-#@U0{8SoP{iTN(XIHyEAth^4 zf3Y2M9bH%HOq7zVVV|@Ka%>8BRxZ91a`Byziv#85;w!vz`$X|IY0NH#z%UXv#PO4NHrXHQUszPMiq}JS91;m`tX>VkA3EOAvCe zR~%2T*Z+_}EEda096>5r0HJcYU*tCImkJcbnV_KGNFazjgCr}Z<1Fa5`VU{jG8^{8 z{sw~~X}8;7OCZzJ(|Znw;}wo#_j3w#F|#b0v~jcOhizzR=&8%);*LE*@;vVz931?{ zb38;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_YkO_1Lm1=K?cwYv;w)IH481x5*_av2ev1t=r?-9TB;i_o g;@HQkU)#J-XzN<7k1+b;;SdNyftX(#vggqM04)J)p8x;= literal 0 HcmV?d00001 diff --git a/dali-toolkit/images/checkbox-selected.png b/dali-toolkit/images/checkbox-selected.png new file mode 100644 index 0000000000000000000000000000000000000000..e3a8c43422137832e8e125a5584b169c0d844285 GIT binary patch literal 1989 zcmV;$2RitPP)jX%sLteA+n+jWgWLqub6 zA=wz%jg&=D+ghQp*zz^)bUyC)^*yIE?Va`xOh2?|a&qU+xp&TUpXYs_^WGy^mIY1I zpzAtRRfQl3n9auUxLhuHJRZ2+ZU_uiTU#53hK7P`)~tCVl}fENO>@=&78Ml@T)uqy z-3u2keBaU00g15}i^W3K)zwF7FxuGIh)^grE8uiZM|XEO6h-;{nKNg$#N+WVIly)6 z);$pn2BUlT?nPBq)vQV!mxplZ&3ER=vi!2o=i4T-m`f&;D_5;r#lf){V2#QAb9Auj z=x{E68lMjQ6Y!a6ZfXVrTt-+VDHE86UDm)2;Nj=rspoKf_yhRG zAfBpu4#f!Ly7v}O6h@Y0&mPtc!(fb3JZL`&K$qa+;QF*~oJbr&r~GfM_HD$j(me>f z=8USxAhG#5KsyiyRHP$mKjQ#Bq7Nw}f#Zn}@I~?y4C*%#Eo#N~;&#rfW~%Vg$BtZn-irPzIXP_ap8QV+RNp|)zb1`I^(mn4nrF}#1{uQ-=D#aU$k zKi6G}M=SQgBY2@%>eyTkg5XEUR=NJ9>zj6_WufC2eaxZ+Y08HKBpdYatfG}$2Yps8dq z-OHIvoX5f5KOt!h!%co?8WvPj!F=B$w9S8#a@Qb(vnED3PZnzei#ai9l1X#)Q%Dex ziv=1%ZfxE-^6S!2~|F!2qu7{2roNSVag2*5LZ#{3|`=M{)p_PDv zGffMMCSx8+yRGsu@;|kpVl}VCV}m1;nkcMj^+^F7z4&*W`r%(0E3rnM&@fE=a`A5w z_LU>8r|zhVnNQ-869KZ8=EZ{BPW-}wLi!bgS zU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oOGeowqyr*`@q6Qd6T54-S6+Yb}I0BBxOpyTJy*4zmIfXOZ%drtyaE}?4GOn zmhPA{>7DN7=G8U9WpfKZ>z)yJ_hk9%v&!M^1zWZr?D=8C%@v7dD<5fU`*`LzPiB5( z&gm|{k~-zq+JDXY@!!{L&t_y$8*8`j+_QF?hw(qZsc<0q^5%hAzBkpRKey+$71~of zI*%@x+M2xNKvo|&*pfBxO_U441y)&Dek)G|%L-((kJAZp6DXGEIu)d`1*T5QX zF#Yi%&!aPzcT8j-Gh=gad7V*fFx=g`o$_0_ws z{_<__tfc96H;)yxovSzw9EmLpni@}Ep8B#zt~x!H@HCJYSKV!Y0a-Ls}i+4x9+}vz3Q2+8*KbZ;k^@wo|5x| lWN7y0W}(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/dali-toolkit/images/radio-button-selected-disabled.png b/dali-toolkit/images/radio-button-selected-disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..5c40e4bd54ea10df7834b713ccb98a758d585b2a GIT binary patch literal 4338 zcmaJ_c{o&k`#(lPkC;-*KE|3FGs6sKP_{_M+9at*#u!Xuh8g>kv4upkWNc+GT4c$- zrb3Y|YA{NoEZLH*{l@b=J-_#l_j=EDo%8*k``n+;y2Mqw)C;X@cq8o`0aU{8rJ#?V+bxlwR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$|wQ8}J=;zO$ zOS`lN$tk9F=fp&N=4=&8OpFBv1}0pO7DI(eIFeyZBy= z8&Vz+bXgj6O4{8l9`CegZ(npc=mXDMBr$gX9hnZ9L@t5Q($Yf(F7s1}MKti5O)qKt znWoyd`urz6`CL#st03J52+L3FiLzoot8@IxZ8C*nEao~Nyaf%cxXP66FV}{Q@;q1r zAN71f2~-~Nx|-#EA@1sf(oHwyw)78vNA1|%Q6Qkjha`n+`{He~DJd`Al$0+Rz3?o3 zBW2y@R^~f{{@tMdK+zeqkXiDQ;n*+64;{s*nf&w8{I6fxUlX68-PJl)8v&wDzGn7Z z6S9`WW_#TDr?)I5zW1IF&Uc%3~|B1j&v zH~W$7r=Z@QEmF`&x^Dtl)~vxY<77>>*N;P@W=PLgVqTtEYI}X!3~09)>7SBQQ8t$A zs!R7|Hix2}xvnZ}^nRD`BlCBOAIewU8k_p1*bK0Gt(GjfNz9$U5GE(h4Ik+{g#8~y Ci^XFA literal 0 HcmV?d00001 diff --git a/dali-toolkit/images/radio-button-unselected-disabled.png b/dali-toolkit/images/radio-button-unselected-disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..0c5fa5ffc2cf328d7cdbc8899a157fad6733014b GIT binary patch literal 3936 zcmaJ^c|25m8$Z@$i|irOxFH&|&zP|^j3u&EhK5qc%rFx(!x&4r8B;2;3N7NnA5 zD$3HL>?I{xQZ6D<$Wrl+Zr%6&<9^=r`JD6n{hsrDpZ)oq=OpZObx@GqAPWG1g5!4E z-J+GSddoQ)~kRyu{K;KQL&<=$>rCR`i#4#p` z%pI2w4H704nIFA~6_^C+N5RuDTBA885xDHku=uaco)&`%a#pe6Wk zqsT5hK|~Ih4nmt^AXFFz3&P?|;b<%th2085z~E>o3<*WTAP6KL1;e8dpkEhQq>W4S z$M3ea|D{WGvIH}DykI;O8W9m;8i6$Ba08%l91aJCA)p8ZM8p9JJ;dfwA|dQh{ofL7 z>7i6EGnmKZutBR5DSn(Vo+Vgh>EAA}f?Ztx5zG$#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1WTot@q3%F4>?3W|!$Qp<1uFl^n?@^qiGLFkJv z+FbL=t|Ak!73;Q{4B4r55(_TnL3N_RA=LV{q)VPyqoA>|ky$smB45kYoBEWRloaIS zxZ~yNwV+Derb9=gs?Q}()5h9zu#?N8@#BE#tG}Fnx(?>U6g#?$KaJYI(thjAk<(@P zqhZx~&2v2qhc(AbR9lhaLv>PZb@a-HKzY7+qb-s6z+E(U#De<8#u6ETkD?gmL~K^AK5Z1P<8|O8gDh)!A>!W6YK#fSX0vGtLlrL8RZWy zT;EjBbypQ|($dmu*EGZ?D*Z@c6M1`q+e~=#v9Qbs=1L2HGDdOy&)|b{=tsrji!D0B z0-0mqeN6AWg#{eX+lO#E=*^8yssb9e*^rl|Bv*vAgwoc2O~93$(%LU8nH&Fj(EiKk zK*qSL!9d)S*%__6^37x^NzXZ0#;oUx8;EzTGjMFaPU*H>>ync1{ynr9XUctugWP+8w_DS_T6F3UrFP?p3tXo2a?J^cu%54_>3;2uJoeMvqcxhWVMblW`2auBd{ Jd(FmI@E>YSv=0CP literal 0 HcmV?d00001 diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index a1eb3cf..4072f43 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -32,7 +32,7 @@ /** * Button states and contents * (3) mSelectedContent - * (2) mButtonContent (2) mSelectedBackgroundContent + * (2) mUnselectedContent (2) mSelectedBackgroundContent * (1) mBackgroundContent (1) mBackgroundContent * < unselected > ----------------------- < selected > * | OnSelect() | @@ -45,7 +45,7 @@ * The drawing order of child actors is as follows. * * Top mLabel - * | mButtonContent / mSelectedContent / mDisabledContent / mDisabledSelectedContent + * | mUnselectedContent / mSelectedContent / mDisabledContent / mDisabledSelectedContent * | mSelectedBackgroundContent * Bottom mBackgroundContent / mDisabledBackgroundContent * @@ -117,252 +117,109 @@ Button::Button() Button::~Button() { - if( mAutoRepeatingTimer ) - { - mAutoRepeatingTimer.Reset(); - } } void Button::SetDisabled( bool disabled ) { - if( disabled != mDisabled ) + if( disabled == mDisabled ) { - unsigned int backgroundIndex; - unsigned int buttonIndex; - - bool animationStarted = false; - - mDisabled = disabled; - - switch( mPaintState ) - { - case UnselectedState: - { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mDisabledContent ); - - if( mBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } - - InsertChild( backgroundIndex, mDisabledBackgroundContent ); - - animationStarted = OnDisabled(); - - if( animationStarted ) - { - mPaintState = UnselectedDisabledTransition; - } - else - { - mPaintState = DisabledUnselectedState; - } - break; - } - case SelectedState: - { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mDisabledSelectedContent ); - - if( mBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } - - InsertChild( backgroundIndex, mDisabledBackgroundContent ); - - animationStarted = OnDisabled(); - - if( animationStarted ) - { - mPaintState = SelectedDisabledTransition; - } - else - { - mPaintState = DisabledSelectedState; - } - break; - } - case DisabledUnselectedState: - { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mButtonContent ); - - if( mDisabledBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } - - InsertChild( backgroundIndex, mBackgroundContent ); - - animationStarted = OnDisabled(); - - if( animationStarted ) - { - mPaintState = DisabledUnselectedTransition; - } - else - { - mPaintState = UnselectedState; - } - break; - } - case DisabledSelectedState: - { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mSelectedContent ); - - if( mDisabledBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } - - InsertChild( backgroundIndex, mSelectedBackgroundContent ); - InsertChild( backgroundIndex, mBackgroundContent ); + return; + } - animationStarted = OnDisabled(); + StopTransitionAnimation(); - if( animationStarted ) - { - mPaintState = DisabledSelectedTransition; - } - else - { - mPaintState = SelectedState; - } - break; - } - case UnselectedSelectedTransition: - { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mDisabledSelectedContent ); + mDisabled = disabled; - if( mBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } + // Notifies the derived class the button has been disabled. + OnDisabled(); - InsertChild( backgroundIndex, mDisabledBackgroundContent ); + switch( mPaintState ) + { + case UnselectedState: + { + //Layer Order + //(3) mDisabledContent (Inserted) + //(4) mUnselectedContent + //(2) mDisabledBackgroundContent (Inserted) + //(1) mBackgroundContent - animationStarted = OnDisabled(); + TransitionInBetween( mUnselectedContent, mLabel, mDisabledContent ); + TransitionInAbove( mBackgroundContent, mDisabledBackgroundContent ); - if( animationStarted ) - { - mPaintState = SelectedDisabledTransition; - } - else - { - mPaintState = DisabledSelectedState; - } - break; - } - case SelectedUnselectedTransition: - { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mDisabledContent ); + TransitionOut( mUnselectedContent ); + TransitionOut( mSelectedContent ); + TransitionOut( mBackgroundContent ); + TransitionOut( mSelectedBackgroundContent ); + TransitionOut( mDisabledSelectedContent ); - if( mBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } + mPaintState = DisabledUnselectedState; + break; + } + case SelectedState: + { + //Layer Order + //(5) mDisabledSelectedContent (Inserted) + //(4) mSelectedContent + //(3) mDisabledBackgroundContent (Inserted) + //(2) mSelectedBackgroundContent + //(1) mBackgroundContent + + TransitionInBetween( mSelectedContent, mLabel, mDisabledSelectedContent ); + TransitionInAbove( mSelectedBackgroundContent, mDisabledBackgroundContent ); + + TransitionOut( mUnselectedContent ); + TransitionOut( mSelectedContent ); + TransitionOut( mBackgroundContent ); + TransitionOut( mSelectedBackgroundContent ); + TransitionOut( mDisabledContent ); - InsertChild( backgroundIndex, mDisabledBackgroundContent ); + mPaintState = DisabledSelectedState; + break; + } + case DisabledUnselectedState: + { + //Layer Order + //(3) mUnselectedContent (Inserted) + //(4) mDisabledContent + //(2) mBackgroundContent (Inserted) + //(1) mDisabledBackgroundContent - animationStarted = OnDisabled(); + TransitionInBetween( mDisabledContent, mLabel, mUnselectedContent ); + TransitionInAbove( mDisabledBackgroundContent, mBackgroundContent ); - if( animationStarted ) - { - mPaintState = UnselectedDisabledTransition; - } - else - { - mPaintState = DisabledUnselectedState; - } - break; - } - case UnselectedDisabledTransition: - { - animationStarted = OnDisabled(); + TransitionOut( mSelectedContent ); + TransitionOut( mSelectedBackgroundContent ); + TransitionOut( mDisabledContent ); + TransitionOut( mDisabledSelectedContent ); + TransitionOut( mDisabledBackgroundContent ); - if( animationStarted ) - { - mPaintState = DisabledUnselectedTransition; - } - else - { - mPaintState = UnselectedState; - } - break; - } - case DisabledUnselectedTransition: - { - animationStarted = OnDisabled(); - - if( animationStarted ) - { - mPaintState = UnselectedDisabledTransition; - } - else - { - mPaintState = DisabledUnselectedState; - } - break; - } - case SelectedDisabledTransition: - { - animationStarted = OnDisabled(); - - if( animationStarted ) - { - mPaintState = DisabledSelectedTransition; - } - else - { - mPaintState = SelectedState; - } - break; - } - case DisabledSelectedTransition: - { - animationStarted = OnDisabled(); + mPaintState = UnselectedState; + break; + } + case DisabledSelectedState: + { + //Layer Order + //(4) mSelectedContent (Inserted) + //(5) mDisabledSelectedContent + //(3) mSelectedBackgroundContent (Inserted) + //(2) mBackgroundContent (Inserted) + //(1) mDisabledBackgroundContent + + TransitionInBetween( mDisabledSelectedContent, mLabel, mSelectedContent ); + TransitionInAbove( mDisabledBackgroundContent, mSelectedBackgroundContent ); + TransitionInAbove( mDisabledBackgroundContent, mBackgroundContent ); + + TransitionOut( mUnselectedContent ); + TransitionOut( mDisabledContent ); + TransitionOut( mDisabledSelectedContent ); + TransitionOut( mDisabledBackgroundContent ); - if( animationStarted ) - { - mPaintState = SelectedDisabledTransition; - } - else - { - mPaintState = DisabledSelectedState; - } - break; - } + mPaintState = SelectedState; + break; } } + + StartTransitionAnimation(); } bool Button::IsDisabled() const @@ -440,154 +297,64 @@ void Button::SetSelected( bool selected ) void Button::SetSelected( bool selected, bool emitSignal ) { - unsigned int buttonIndex, backgroundIndex; - bool animationStarted = false; + StopTransitionAnimation(); mSelected = selected; + // Notifies the derived class the button has been selected. + OnSelected(); + switch( mPaintState ) { case UnselectedState: { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mSelectedContent ); + //Layer Order + //(3) mSelectedContent (Inserted) + //(4) mUnselectedContent + //(2) mSelectedBackgroundContent (Inserted) + //(1) mBackgroundContent - if( mBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } - - InsertChild( backgroundIndex, mSelectedBackgroundContent ); + TransitionInBetween( mUnselectedContent, mLabel, mSelectedContent ); + TransitionInAbove( mBackgroundContent, mSelectedBackgroundContent ); + TransitionInAtIndex( 0, mBackgroundContent ); - // Notifies the derived class the button has been selected. - animationStarted = OnSelected(); + TransitionOut( mUnselectedContent ); + TransitionOut( mDisabledContent ); + TransitionOut( mDisabledSelectedContent ); + TransitionOut( mDisabledBackgroundContent ); - if( animationStarted ) - { - mPaintState = UnselectedSelectedTransition; - } - else - { - mPaintState = SelectedState; - } + mPaintState = SelectedState; break; } case SelectedState: { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mButtonContent ); + //Layer Order + //(3) mUnselectedContent (Inserted) + //(2) mSelectedContent + //(1) mBackgroundContent - // Notifies the derived class the button has been selected. - animationStarted = OnSelected(); + TransitionInBetween( mSelectedContent, mLabel, mUnselectedContent ); + TransitionInAtIndex( 0, mBackgroundContent ); - if( animationStarted ) - { - mPaintState = SelectedUnselectedTransition; - } - else - { - mPaintState = UnselectedState; - } - break; - } - case UnselectedSelectedTransition: - { - // Notifies the derived class the button has been selected. - animationStarted = OnSelected(); + TransitionOut( mSelectedContent ); + TransitionOut( mSelectedBackgroundContent ); + TransitionOut( mDisabledContent ); + TransitionOut( mDisabledSelectedContent ); + TransitionOut( mDisabledBackgroundContent ); - if( animationStarted ) - { - mPaintState = SelectedUnselectedTransition; - } - else - { - mPaintState = UnselectedState; - } - break; - } - case SelectedUnselectedTransition: - { - // Notifies the derived class the button has been selected. - animationStarted = OnSelected(); - - if( animationStarted ) - { - mPaintState = UnselectedSelectedTransition; - } - else - { - mPaintState = SelectedState; - } - break; - } - case DisabledUnselectedTransition: - { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mSelectedContent ); - - if( mDisabledBackgroundContent ) - { - if( mBackgroundContent ) - { - backgroundIndex = 2; - } - else - { - backgroundIndex = 1; - } - } - else if( mBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } - - InsertChild( backgroundIndex, mSelectedBackgroundContent ); - - // Notifies the derived class the button has been selected. - animationStarted = OnSelected(); - - if( animationStarted ) - { - mPaintState = UnselectedSelectedTransition; - } - else - { - mPaintState = SelectedState; - } - break; - } - case DisabledSelectedTransition: - { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mButtonContent ); - - // Notifies the derived class the button has been selected. - animationStarted = OnSelected(); - - if( animationStarted ) - { - mPaintState = SelectedUnselectedTransition; - } - else - { - mPaintState = UnselectedState; - } + mPaintState = UnselectedState; break; } - default: + case DisabledUnselectedState: + case DisabledSelectedState: { + DALI_ASSERT_DEBUG( 0 && "Shouldn't be able to change paint state if the button is disabled." ); break; } } + StartTransitionAnimation(); + if( emitSignal ) { Toolkit::Button handle( GetOwner() ); @@ -653,26 +420,21 @@ Actor& Button::GetLabel() void Button::SetButtonImage( Actor image ) { - StopAllAnimations(); + StopTransitionAnimation(); - if( mButtonContent && mButtonContent.GetParent() ) + if( mUnselectedContent && mUnselectedContent.GetParent() ) { - Self().Remove( mButtonContent ); + Self().Remove( mUnselectedContent ); } - mButtonContent = image; - - mButtonContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mButtonContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mButtonContent.SetPosition( 0.f, 0.f ); - - if( mPaintState == UnselectedState ) + mUnselectedContent = image; + if( mUnselectedContent ) { - unsigned int index = FindChildIndex( mLabel ); - - Self().Insert( index, mButtonContent ); + mUnselectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mUnselectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mUnselectedContent.SetPosition( 0.f, 0.f ); } - + ResetImageLayers(); OnButtonImageSet(); RelayoutRequest(); @@ -680,17 +442,17 @@ void Button::SetButtonImage( Actor image ) Actor Button::GetButtonImage() const { - return mButtonContent; + return mUnselectedContent; } Actor& Button::GetButtonImage() { - return mButtonContent; + return mUnselectedContent; } void Button::SetSelectedImage( Actor image ) { - StopAllAnimations(); + StopTransitionAnimation(); if( mSelectedContent && mSelectedContent.GetParent() ) { @@ -698,18 +460,13 @@ void Button::SetSelectedImage( Actor image ) } mSelectedContent = image; - - mSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mSelectedContent.SetPosition( 0.f, 0.f ); - - if( mPaintState == SelectedState ) + if( mSelectedContent ) { - unsigned int index = FindChildIndex( mLabel ); - - Self().Insert( index, mSelectedContent ); + mSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mSelectedContent.SetPosition( 0.f, 0.f ); } - + ResetImageLayers(); OnSelectedImageSet(); RelayoutRequest(); @@ -727,7 +484,7 @@ Actor& Button::GetSelectedImage() void Button::SetBackgroundImage( Actor image ) { - StopAllAnimations(); + StopTransitionAnimation(); if( mBackgroundContent && mBackgroundContent.GetParent() ) { @@ -735,16 +492,13 @@ void Button::SetBackgroundImage( Actor image ) } mBackgroundContent = image; - - mBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mBackgroundContent.SetPosition( 0.f, 0.f ); - - if( mPaintState == UnselectedState || mPaintState == SelectedState ) + if( mBackgroundContent ) { - Self().Insert( 0, mBackgroundContent ); + mBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mBackgroundContent.SetPosition( 0.f, 0.f ); } - + ResetImageLayers(); OnBackgroundImageSet(); RelayoutRequest(); @@ -762,7 +516,7 @@ Actor& Button::GetBackgroundImage() void Button::SetSelectedBackgroundImage( Actor image ) { - StopAllAnimations(); + StopTransitionAnimation(); if( mSelectedBackgroundContent && mSelectedBackgroundContent.GetParent() ) { @@ -770,23 +524,13 @@ void Button::SetSelectedBackgroundImage( Actor image ) } mSelectedBackgroundContent = image; - - mSelectedBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mSelectedBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mSelectedBackgroundContent.SetPosition( 0.f, 0.f ); - - if( mPaintState == SelectedState ) + if( mSelectedBackgroundContent ) { - if( mBackgroundContent ) - { - Self().Insert( 1, mSelectedBackgroundContent ); - } - else - { - Self().Insert( 0, mSelectedBackgroundContent ); - } + mSelectedBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mSelectedBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mSelectedBackgroundContent.SetPosition( 0.f, 0.f ); } - + ResetImageLayers(); OnSelectedBackgroundImageSet(); RelayoutRequest(); @@ -804,7 +548,7 @@ Actor& Button::GetSelectedBackgroundImage() void Button::SetDisabledImage( Actor image ) { - StopAllAnimations(); + StopTransitionAnimation(); if( mDisabledContent && mDisabledContent.GetParent() ) { @@ -812,18 +556,14 @@ void Button::SetDisabledImage( Actor image ) } mDisabledContent = image; - - mDisabledContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mDisabledContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mDisabledContent.SetPosition( 0.f, 0.f ); - - if( mPaintState == DisabledUnselectedState || mPaintState == DisabledSelectedState ) + if( mDisabledContent ) { - unsigned int index = FindChildIndex( mLabel ); - - Self().Insert( index, mDisabledContent ); + mDisabledContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mDisabledContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mDisabledContent.SetPosition( 0.f, 0.f ); } + ResetImageLayers(); OnDisabledImageSet(); } @@ -839,7 +579,7 @@ Actor& Button::GetDisabledImage() void Button::SetDisabledSelectedImage( Actor image ) { - StopAllAnimations(); + StopTransitionAnimation(); if( mDisabledSelectedContent && mDisabledSelectedContent.GetParent() ) { @@ -847,18 +587,14 @@ void Button::SetDisabledSelectedImage( Actor image ) } mDisabledSelectedContent = image; - - mDisabledSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mDisabledSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mDisabledSelectedContent.SetPosition( 0.f, 0.f ); - - if( mPaintState == DisabledSelectedState ) + if( mDisabledSelectedContent ) { - unsigned int index = FindChildIndex( mLabel ); - - Self().Insert( index, mDisabledSelectedContent ); + mDisabledSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mDisabledSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mDisabledSelectedContent.SetPosition( 0.f, 0.f ); } + ResetImageLayers(); OnDisabledSelectedImageSet(); } @@ -874,7 +610,7 @@ Actor& Button::GetDisabledSelectedImage() void Button::SetDisabledBackgroundImage( Actor image ) { - StopAllAnimations(); + StopTransitionAnimation(); if( mDisabledBackgroundContent && mDisabledBackgroundContent.GetParent() ) { @@ -882,16 +618,13 @@ void Button::SetDisabledBackgroundImage( Actor image ) } mDisabledBackgroundContent = image; - - mDisabledBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mDisabledBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mDisabledBackgroundContent.SetPosition( 0.f, 0.f ); - - if( mPaintState == DisabledUnselectedState || mPaintState == DisabledSelectedState ) + if( mDisabledBackgroundContent ) { - Self().Insert( 0, mDisabledBackgroundContent ); + mDisabledBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mDisabledBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mDisabledBackgroundContent.SetPosition( 0.f, 0.f ); } - + ResetImageLayers(); OnDisabledBackgroundImageSet(); } @@ -941,59 +674,6 @@ bool Button::DoClickAction( const Property::Map& attributes ) return false; } -void Button::UpdatePaintTransitionState() -{ - switch( mPaintState ) - { - case UnselectedSelectedTransition: - { - RemoveChild( mButtonContent ); - mPaintState = SelectedState; - break; - } - case SelectedUnselectedTransition: - { - RemoveChild( mSelectedBackgroundContent ); - RemoveChild( mSelectedContent ); - mPaintState = UnselectedState; - break; - } - case UnselectedDisabledTransition: - { - RemoveChild( mBackgroundContent ); - RemoveChild( mButtonContent ); - mPaintState = DisabledUnselectedState; - break; - } - case DisabledUnselectedTransition: - { - RemoveChild( mDisabledBackgroundContent ); - RemoveChild( mDisabledContent ); - mPaintState = UnselectedState; - break; - } - case SelectedDisabledTransition: - { - RemoveChild( mBackgroundContent ); - RemoveChild( mSelectedBackgroundContent ); - RemoveChild( mSelectedContent ); - mPaintState = DisabledSelectedState; - break; - } - case DisabledSelectedTransition: - { - RemoveChild( mDisabledBackgroundContent ); - RemoveChild( mDisabledSelectedContent ); - mPaintState = SelectedState; - break; - } - default: - { - break; - } - } -} - void Button::OnButtonStageDisconnection() { if( ButtonDown == mState ) @@ -1264,206 +944,297 @@ bool Button::AutoRepeatingSlot() void Button::Pressed() { - unsigned int buttonIndex, backgroundIndex; - bool animationStarted = false; + if( mPaintState == UnselectedState ) + { + StopTransitionAnimation(); - switch( mPaintState ) + // Notifies the derived class the button has been pressed. + OnPressed(); + + //Layer Order + //(4) mSelectedContent (Inserted) + //(3) mUnselectedContent + //(2) mSelectedBackgroundContent (Inserted) + //(1) mBackgroundContent + + TransitionInBetween( mUnselectedContent, mLabel, mSelectedContent ); + TransitionInAbove( mBackgroundContent, mSelectedBackgroundContent ); + TransitionInAtIndex( 0, mBackgroundContent ); + + TransitionOut( mUnselectedContent ); + TransitionOut( mDisabledContent ); + TransitionOut( mDisabledSelectedContent ); + TransitionOut( mDisabledBackgroundContent ); + + mPaintState = SelectedState; + + StartTransitionAnimation(); + } +} + +void Button::Released() +{ + if( mPaintState == SelectedState ) { - case UnselectedState: - { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mSelectedContent ); + StopTransitionAnimation(); - if( mBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } + // Notifies the derived class the button has been released. + OnReleased(); - InsertChild( backgroundIndex, mSelectedBackgroundContent ); + //Layer Order + //(3) mUnselectedContent (Inserted) + //(2) mSelectedContent + //(1) mBackgroundContent - // Notifies the derived class the button has been pressed. - animationStarted = OnPressed(); + TransitionInBetween( mSelectedContent, mLabel, mUnselectedContent ); + TransitionInAtIndex( 0, mBackgroundContent ); - if( animationStarted ) - { - mPaintState = UnselectedSelectedTransition; - } - else - { - mPaintState = SelectedState; - } - break; - } - case SelectedUnselectedTransition: - { - // Notifies the derived class the button has been pressed. - animationStarted = OnPressed(); + TransitionOut( mSelectedContent ); + TransitionOut( mSelectedBackgroundContent ); + TransitionOut( mDisabledContent ); + TransitionOut( mDisabledSelectedContent ); + TransitionOut( mDisabledBackgroundContent ); - if( animationStarted ) - { - mPaintState = UnselectedSelectedTransition; - } - else - { - mPaintState = SelectedState; - } - break; + mPaintState = UnselectedState; + + StartTransitionAnimation(); + } +} + +Button::ButtonState Button::GetState() +{ + return mState; +} + +Button::PaintState Button::GetPaintState() +{ + return mPaintState; +} + +bool Button::InsertButtonImage( unsigned int index, Actor& actor ) +{ + if( actor ) + { + Self().Insert( index, actor ); + PrepareForTranstionOut( actor ); + return true; + } + + return false; +} + +void Button::RemoveButtonImage( Actor& actor ) +{ + if( actor ) + { + if( actor.GetParent() ) + { + Self().Remove( actor ); } - case DisabledUnselectedTransition: + PrepareForTranstionIn( actor ); + } +} + +unsigned int Button::FindChildIndex( Actor& actor ) +{ + Actor self = Self(); + unsigned int childrenNum = self.GetChildCount(); + + for( unsigned int i = 0; i < childrenNum; i++ ) + { + Actor child = self.GetChildAt( i ); + if( child == actor ) { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mSelectedContent ); + return i; + } + } - if( mDisabledBackgroundContent ) - { - if( mBackgroundContent ) - { - backgroundIndex = 2; - } - else - { - backgroundIndex = 1; - } - } - else if( mBackgroundContent ) - { - backgroundIndex = 1; - } - else - { - backgroundIndex = 0; - } + return childrenNum; +} - InsertChild( backgroundIndex, mSelectedBackgroundContent ); +void Button::TransitionInBetween( Actor childLower, Actor childUpper, Actor actor ) +{ + unsigned int index = childLower ? FindChildIndex( childLower ) + 1 : FindChildIndex( childUpper ); + TransitionInAtIndex( index, actor ); +} - // Notifies the derived class the button has been pressed. - animationStarted = OnPressed(); +void Button::TransitionInAbove( Actor child, Actor actor ) +{ + unsigned int index = child ? FindChildIndex( child ) + 1 : 0; + TransitionInAtIndex( index, actor ); +} - if( animationStarted ) - { - mPaintState = UnselectedSelectedTransition; - } - else - { - mPaintState = SelectedState; - } - break; +void Button::TransitionInAtIndex( unsigned int index, Actor actor ) +{ + if( actor ) + { + if( !actor.GetParent() ) + { + Self().Insert( index, actor ); } - default: - break; + + OnTransitionIn( actor ); } } -void Button::Released() +void Button::TransitionOut( Actor actor ) +{ + OnTransitionOut( actor ); +} + +void Button::ResetImageLayers() { - unsigned int buttonIndex; - bool animationStarted = false; + //ensure that all layers are in the correct order and state according to the paint state + int index = 0; switch( mPaintState ) { - case SelectedState: + case UnselectedState: { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mButtonContent ); + //Layer Order + //(2) mUnselectedContent + //(1) mBackgroundContent - // Notifies the derived class the button has been released. - animationStarted = OnReleased(); + RemoveButtonImage( mSelectedContent ); + RemoveButtonImage( mSelectedBackgroundContent ); + RemoveButtonImage( mDisabledContent ); + RemoveButtonImage( mDisabledSelectedContent ); + RemoveButtonImage( mDisabledBackgroundContent ); - if( animationStarted ) + if( InsertButtonImage( index, mBackgroundContent ) ) { - mPaintState = SelectedUnselectedTransition; + ++index; } - else + if( InsertButtonImage( index, mUnselectedContent ) ) { - mPaintState = UnselectedState; + ++index; } break; } - case UnselectedSelectedTransition: + case SelectedState: { - // Notifies the derived class the button has been released. - animationStarted = OnReleased(); + //Layer Order + //(3) mSelectedContent + //(2) mSelectedBackgroundContent + //(1) mBackgroundContent - if( animationStarted ) + RemoveButtonImage( mUnselectedContent ); + RemoveButtonImage( mDisabledContent ); + RemoveButtonImage( mDisabledSelectedContent ); + RemoveButtonImage( mDisabledBackgroundContent ); + + if( InsertButtonImage( index, mBackgroundContent ) ) { - mPaintState = SelectedUnselectedTransition; + ++index; } - else + if( InsertButtonImage( index, mSelectedBackgroundContent ) ) + { + ++index; + } + if( InsertButtonImage( index, mSelectedContent ) ) { - mPaintState = UnselectedState; + ++index; } break; } - case DisabledSelectedTransition: + case DisabledUnselectedState: { - buttonIndex = FindChildIndex( mLabel ); - InsertChild( buttonIndex, mButtonContent ); + //Layer Order + //(2) mDisabledContent + //(1) mDisabledBackgroundContent - // Notifies the derived class the button has been released. - animationStarted = OnReleased(); + RemoveButtonImage( mUnselectedContent ); + RemoveButtonImage( mBackgroundContent ); + RemoveButtonImage( mSelectedContent ); + RemoveButtonImage( mDisabledSelectedContent ); + RemoveButtonImage( mSelectedBackgroundContent ); - if( animationStarted ) + if( InsertButtonImage( index, mDisabledBackgroundContent ? mDisabledBackgroundContent : mBackgroundContent ) ) { - mPaintState = SelectedUnselectedTransition; + ++index; } - else + if( InsertButtonImage( index, mDisabledContent ? mDisabledContent : mUnselectedContent ) ) { - mPaintState = UnselectedState; + ++index; } break; } - default: + case DisabledSelectedState: { + //Layer Order + // (2) mDisabledSelectedContent + // (1) mDisabledBackgroundContent + + RemoveButtonImage( mUnselectedContent ); + RemoveButtonImage( mSelectedContent ); + RemoveButtonImage( mBackgroundContent ); + RemoveButtonImage( mSelectedBackgroundContent ); + RemoveButtonImage( mDisabledContent ); + + if( mDisabledBackgroundContent ) + { + if( InsertButtonImage( index, mDisabledBackgroundContent) ) + { + ++index; + } + } + else + { + if( InsertButtonImage( index, mBackgroundContent ) ) + { + ++index; + } + if( InsertButtonImage( index, mSelectedBackgroundContent ) ) + { + ++index; + } + } + + if( InsertButtonImage( index, mDisabledSelectedContent ? mDisabledSelectedContent : mSelectedContent) ) + { + ++index; + } break; } } } -Button::ButtonState Button::GetState() -{ - return mState; -} - -Button::PaintState Button::GetPaintState() -{ - return mPaintState; -} - -void Button::InsertChild( unsigned int index, Actor& actor ) +void Button::StartTransitionAnimation() { - if( actor ) + if( mTransitionAnimation ) { - Self().Insert( index, actor); + mTransitionAnimation.Play(); + } + else + { + ResetImageLayers(); } } -void Button::RemoveChild( Actor& actor ) +void Button::StopTransitionAnimation() { - if( actor && actor.GetParent() ) + if( mTransitionAnimation ) { - Self().Remove( actor ); + mTransitionAnimation.Clear(); + mTransitionAnimation.Reset(); } } -unsigned int Button::FindChildIndex( Actor& actor ) +Dali::Animation Button::GetTransitionAnimation() { - Actor self = Self(); - unsigned int childrenNum = self.GetChildCount(); - - for( unsigned int i = 0; i < childrenNum; i++ ) + if( !mTransitionAnimation ) { - Actor child = self.GetChildAt( i ); - if( child == actor ) - { - return i; - } + mTransitionAnimation = Dali::Animation::New( GetAnimationTime() ); + mTransitionAnimation.FinishedSignal().Connect( this, &Button::TransitionAnimationFinished ); } - return childrenNum; + return mTransitionAnimation; +} + +void Button::TransitionAnimationFinished( Dali::Animation& source ) +{ + StopTransitionAnimation(); + ResetImageLayers(); } void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ) @@ -1476,7 +1247,7 @@ void Button::SetProperty( BaseObject* object, Property::Index index, const Prope { case Toolkit::Button::Property::DISABLED: { - GetImplementation( button ).SetDisabled( value.Get() ); + GetImplementation( button ).SetDisabled( value.Get< bool >() ); break; } @@ -1586,7 +1357,7 @@ Property::Value Button::GetProperty( BaseObject* object, Property::Index propert case Toolkit::Button::Property::NORMAL_STATE_ACTOR: { Property::Map map; - Scripting::CreatePropertyMap( GetImplementation( button ).mButtonContent, map ); + Scripting::CreatePropertyMap( GetImplementation( button ).mUnselectedContent, map ); value = map; break; } diff --git a/dali-toolkit/internal/controls/buttons/button-impl.h b/dali-toolkit/internal/controls/buttons/button-impl.h index e4d49d7..89f0591 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.h +++ b/dali-toolkit/internal/controls/buttons/button-impl.h @@ -20,6 +20,7 @@ // EXTERNAL INCLUDES #include +#include // INTERNAL INCLUDES #include @@ -269,11 +270,6 @@ protected: */ Actor& GetLabel(); - /** - * It changes the transition state of the push button. - */ - void UpdatePaintTransitionState(); - private: /** @@ -362,32 +358,23 @@ private: /** * This method is called when the \e selected property is changed. - * @return true if the transition animation is started. */ - virtual bool OnSelected() { return false; } + virtual void OnSelected() {} /** * This method is called when the \e disabled property is changed. - * @return true if the transition animation is started. */ - virtual bool OnDisabled() { return false; } + virtual void OnDisabled() {} /** * This method is called when the button is pressed. - * @return true if the transition animation is started. */ - virtual bool OnPressed() { return false; } + virtual void OnPressed() {} /** * This method is called when the button is released. - * @return true if the transition animation is started. */ - virtual bool OnReleased() { return false; } - - /** - * This method stops all animations - */ - virtual void StopAllAnimations() {} + virtual void OnReleased() {} public: @@ -527,26 +514,102 @@ protected: SelectedState, ///< The button is selected. DisabledUnselectedState, ///< The button is disabled and unselected. DisabledSelectedState, ///< The button is disabled and selected. - UnselectedSelectedTransition, ///< The button is in transition from unselected to selected. - SelectedUnselectedTransition, ///< The button is in transition from selected to unselected. - UnselectedDisabledTransition, ///< The button is in transition from unselected to disabled. - DisabledUnselectedTransition, ///< The button is in transition from disabled to unselected. - SelectedDisabledTransition, ///< The button is in transition from selected to disabled. - DisabledSelectedTransition ///< The button is in transition from disabled to selected. }; ButtonState GetState(); PaintState GetPaintState(); /** - * Inserts the actor to the button. + * Returns the animation to be used for transitioning creating the animation if needed. + * @return The initialised transition animation. + */ + Dali::Animation GetTransitionAnimation(); + + /** + * Prepares the actor to be transitioned in. + * @param[in] actor The actor that will be transitioned in. + */ + virtual void PrepareForTranstionIn( Actor actor ) {} + + /** + * Prepares the actor to be transitioned in. + * @param[in] actor The actor that will be transitioned out. + */ + virtual void PrepareForTranstionOut( Actor actor ) {} + + /** + * Transitions the actor in, allowing derived classes to configure + * the GetTransitionAnimation() animation ready. + * Button is in charge of calling Dali::Animation::Play and so derived classes + * only need to add the animation. + */ + virtual void OnTransitionIn( Actor actor ) {} + + /** + * Transitions the actor out, allowing derived classes to configure + * the GetTransitionAnimation() animation ready. + * Button is in charge of calling Dali::Animation::Play and so derived classes + * only need to add the animation. + */ + virtual void OnTransitionOut( Actor actor ) {} + +private: + /** + * Starts the transition animation. + * Button::TransitionFinished is called when the animation finishes. + */ + void StartTransitionAnimation(); + + /** + * This method stops all transition animations */ - void InsertChild( unsigned int index, Actor& actor ); + void StopTransitionAnimation(); /** - * Removes the actor from the button. + * Called when the transition animation finishes. */ - void RemoveChild( Actor& actor ); + void TransitionAnimationFinished( Dali::Animation& source ); + + /** + * Resets the Button to the base state for the current paint state. + * Any additionally inserted images needed for transitions that are + * no longer needed and the removed. + */ + void ResetImageLayers(); + + /** + * Transitions in the actor, inserting the actor above childLower below the childUpper. + * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor) + */ + void TransitionInBetween( Actor childLower, Actor childUpper, Actor actor ); + + /** + * Transitions in the actor, inserting the actor above the child if the child exists or at the bottom otherwise + * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor) + */ + void TransitionInAbove( Actor child, Actor actor ); + + /** + * Transitions in the actor, inserting the actor at the index + * Will not insert the actor if it is already attached to a parent (and so will not reorder the actor) + */ + void TransitionInAtIndex( unsigned int index, Actor actor ); + + /** + * Transitions out the actor + */ + void TransitionOut( Actor actor ); + + /** + * Inserts the actor to the button and prepares it to be transitioned out + * @return true if the child was inserted, false otherwise + */ + bool InsertButtonImage( unsigned int index, Actor& actor ); + + /** + * Removes the actor from the button and prepares it to be transitioned out + */ + void RemoveButtonImage( Actor& actor ); /** * Finds the index of the actor. @@ -554,7 +617,6 @@ protected: */ unsigned int FindChildIndex( Actor& actor ); -private: // Undefined Button( const Button& ); @@ -574,7 +636,7 @@ private: Actor mLabel; ///< Stores the button label. - Actor mButtonContent; ///< Stores the unselected content. + Actor mUnselectedContent; ///< Stores the unselected content. Actor mSelectedContent; ///< Stores the selected content. Actor mBackgroundContent; ///< Stores the background content. Actor mSelectedBackgroundContent; ///< Stores the selected background content. @@ -582,6 +644,8 @@ private: Actor mDisabledSelectedContent; ///< Stores the disabled selected content. Actor mDisabledBackgroundContent; ///< Stores the disabled background content. + Animation mTransitionAnimation; ///< Animation used in the state transitions. + TapGestureDetector mTapDetector; bool mDisabled; ///< Stores the disabled property. @@ -590,6 +654,7 @@ private: bool mSelected; ///< Stores the selected state. float mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds. float mNextAutoRepeatingDelay; ///< Stores the next autorepeating delay in seconds. + float mAnimationTime; ///< The animation time. // Actions diff --git a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp index f5c908d..b1f7474 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include //INTERNAL INCLUDES #include @@ -47,6 +48,10 @@ BaseHandle Create() TypeRegistration mType( typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create ); +const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-unselected.png"; +const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-selected.png"; +const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-unselected-disabled.png"; +const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-selected-diabled.png"; } Dali::Toolkit::CheckBoxButton CheckBoxButton::New() @@ -74,16 +79,22 @@ CheckBoxButton::CheckBoxButton() CheckBoxButton::~CheckBoxButton() { - if( mTransitionAnimation ) - { - mTransitionAnimation.Clear(); - } } void CheckBoxButton::OnButtonInitialize() { // Wrap around all children Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); + + Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + Image disabledImage = Dali::ResourceImage::New( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + Image disabledSelectedImage = Dali::ResourceImage::New( DISABLED_SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + + SetButtonImage( ImageActor::New( buttonImage ) ); + SetSelectedImage( ImageActor::New( selectedImage ) ); + SetDisabledImage( ImageActor::New( disabledImage ) ); + SetDisabledSelectedImage( ImageActor::New( disabledSelectedImage ) ); } void CheckBoxButton::OnLabelSet() @@ -103,103 +114,30 @@ void CheckBoxButton::OnLabelSet() { label.SetX( GetBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } - else + else if( IsSelected() && GetSelectedImage()) { - label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL ); + label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } - } -} - -bool CheckBoxButton::OnSelected() -{ - Actor& selectedImage = GetSelectedImage(); - - PaintState paintState = GetPaintState(); - - switch( paintState ) - { - case UnselectedState: - { - StartTransitionAnimation( selectedImage ); - break; - } - case SelectedState: + else if( GetButtonImage() ) { - RemoveChild( selectedImage ); - break; + label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } - case UnselectedSelectedTransition: - { - StopTransitionAnimation( false ); - RemoveChild( selectedImage ); - break; - } - default: + else { - break; + label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } } - - if( mTransitionAnimation ) - { - return true; - } - - return false; } -bool CheckBoxButton::OnDisabled() +void CheckBoxButton::OnDisabled() { Actor& backgroundImage = GetBackgroundImage(); - Actor& selectedImage = GetSelectedImage(); Actor& disabledBackgroundImage = GetDisabledBackgroundImage(); - Actor& disabledSelectedImage = GetDisabledSelectedImage(); - - PaintState paintState = GetPaintState(); - - switch( paintState ) - { - case UnselectedState: - { - RemoveChild( backgroundImage ); - break; - } - case SelectedState: - { - RemoveChild( backgroundImage ); - RemoveChild( selectedImage ); - break; - } - case DisabledUnselectedState: - { - RemoveChild( disabledBackgroundImage ); - break; - } - case DisabledSelectedState: - { - RemoveChild( disabledBackgroundImage ); - RemoveChild( disabledSelectedImage ); - break; - } - case UnselectedSelectedTransition: - { - StopTransitionAnimation(); - - RemoveChild( backgroundImage ); - RemoveChild( selectedImage ); - break; - } - default: - { - break; - } - } Actor& label = GetLabel(); - if( label ) { - if( IsDisabled() && disabledBackgroundImage) + if( IsDisabled() && disabledBackgroundImage ) { label.SetX( disabledBackgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } @@ -207,73 +145,93 @@ bool CheckBoxButton::OnDisabled() { label.SetX( backgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } + else if( IsSelected() && GetSelectedImage()) + { + label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); + } + else if( GetButtonImage() ) + { + label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); + } else { label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } } - - if( mTransitionAnimation ) - { - return true; - } - - return false; } -void CheckBoxButton::StopAllAnimations() +void CheckBoxButton::PrepareForTranstionIn( Actor actor ) { - StopTransitionAnimation(); -} - -void CheckBoxButton::StartTransitionAnimation( Actor& actor ) -{ - if( actor ) + Actor& selectedImage = GetSelectedImage(); + if( actor == selectedImage ) { + actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) ); + if( !mTickUVEffect ) { - ImageActor imageActor = ImageActor::DownCast( actor ); mTickUVEffect = CreateImageRegionEffect(); - imageActor.SetShaderEffect( mTickUVEffect ); } - - actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) ); - mTickUVEffect.SetUniform("uBottomRight", Vector2( 0.0f, 1.0f ) ); - if( !mTransitionAnimation ) + ImageActor imageActor = ImageActor::DownCast( actor ); + if( imageActor ) { - mTransitionAnimation = Dali::Animation::New( GetAnimationTime() ); + imageActor.SetShaderEffect( mTickUVEffect ); } - - // UV anim - mTransitionAnimation.AnimateTo( Property( mTickUVEffect, "uBottomRight" ), Vector2( 1.0f, 1.0f ) ); - - // Actor size anim - mTransitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f ); - - mTransitionAnimation.FinishedSignal().Connect( this, &CheckBoxButton::TransitionAnimationFinished ); - mTransitionAnimation.Play(); } } -void CheckBoxButton::StopTransitionAnimation( bool remove ) +void CheckBoxButton::PrepareForTranstionOut( Actor actor ) { - if( mTransitionAnimation ) + Actor& selectedImage = GetSelectedImage(); + if( actor == selectedImage ) { - mTransitionAnimation.Clear(); - mTransitionAnimation.Reset(); - } + actor.SetScale( Vector3::ONE ); - if( remove ) - { - UpdatePaintTransitionState(); + if( !mTickUVEffect ) + { + mTickUVEffect = CreateImageRegionEffect(); + } + mTickUVEffect.SetUniform("uBottomRight", Vector2::ONE ); + + ImageActor imageActor = ImageActor::DownCast( actor ); + if( imageActor ) + { + imageActor.SetShaderEffect( mTickUVEffect ); + } } } -void CheckBoxButton::TransitionAnimationFinished( Dali::Animation& source ) +void CheckBoxButton::OnTransitionIn( Actor actor ) { - StopTransitionAnimation(); + Actor& selectedImage = GetSelectedImage(); + if( actor && actor == selectedImage ) + { + if( GetPaintState() == UnselectedState ) + { + Dali::Animation transitionAnimation = GetTransitionAnimation(); + if( transitionAnimation ) + { + DALI_ASSERT_DEBUG( mTickUVEffect ); + if( mTickUVEffect ) + { + // UV anim + transitionAnimation.AnimateTo( Property( mTickUVEffect, "uBottomRight" ), Vector2::ONE ); + } + // Actor size anim + transitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f ); + } + } + else + { + //explicitly end the swipe animation + actor.SetScale( Vector3::ONE ); + if( mTickUVEffect ) + { + mTickUVEffect.SetUniform("uBottomRight", Vector2::ONE ); + } + } + } } } // namespace Internal diff --git a/dali-toolkit/internal/controls/buttons/check-box-button-impl.h b/dali-toolkit/internal/controls/buttons/check-box-button-impl.h index 0135e6b..25945d2 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.h @@ -20,10 +20,8 @@ // EXTERNAL INCLUDES #include -#include #include - // INTERNAL INCLUDES #include #include @@ -80,41 +78,24 @@ private: // From Button virtual void OnLabelSet(); /** - * @copydoc Toolkit::Internal::Button::OnSelected() - */ - virtual bool OnSelected(); - - /** * @copydoc Toolkit::Internal::Button::OnDisabled() */ - virtual bool OnDisabled(); - - /** - * @copydoc Toolkit::Internal::Button::StopAllAnimations() - */ - virtual void StopAllAnimations(); - -private: + virtual void OnDisabled(); /** - * Adds the actor to the transition animation. - * It creates a transition animation if needed and starts the animation. - * @param[in] actor The actor. + * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor ) */ - void StartTransitionAnimation( Actor& actor ); + virtual void PrepareForTranstionIn( Actor actor ); /** - * Stops the transition animation. - * @param[in] remove If true, removes the fadeout actor from root. + * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor ) */ - void StopTransitionAnimation( bool remove = true ); - - // slots + virtual void PrepareForTranstionOut( Actor actor ); /** - * Called when the transition animation finishes. + * @copydoc Toolkit::Internal::Button::OnTransitionInImage( Actor actor ) */ - void TransitionAnimationFinished( Dali::Animation& source ); + virtual void OnTransitionIn( Actor actor ); private: @@ -125,7 +106,6 @@ private: CheckBoxButton& operator=( const CheckBoxButton& ); private: - Animation mTransitionAnimation; ///< Animation used in the state transitions. ShaderEffect mTickUVEffect; ///< ImageRegionEffect to expand the tick across }; diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index a63b861..1ee6b92 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include // INTERNAL INCLUDES #include @@ -47,6 +48,11 @@ BaseHandle Create() TypeRegistration typeRegistration( typeid(Toolkit::PushButton), typeid(Toolkit::Button), Create ); +const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-up.9.png"; +const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-down.9.png"; +const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-disabled.9.png"; +const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-down-disabled.9.png"; + } // unnamed namespace namespace @@ -103,6 +109,16 @@ void PushButton::OnButtonInitialize() // Set resize policy to natural size so that buttons will resize to background images self.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); + + Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + Image disabledImage = Dali::ResourceImage::New( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + Image disabledSelectedImage = Dali::ResourceImage::New( DISABLED_SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + + SetButtonImage( ImageActor::New( buttonImage ) ); + SetSelectedImage( ImageActor::New( selectedImage ) ); + SetDisabledImage( ImageActor::New( disabledImage ) ); + SetDisabledSelectedImage( ImageActor::New( disabledSelectedImage ) ); } void PushButton::OnLabelSet() @@ -156,386 +172,16 @@ void PushButton::OnDisabledImageSet() RelayoutRequest(); } -void PushButton::OnDisabledBackgroundImageSet() +void PushButton::OnDisabledSelectedImageSet() { ConfigureSizeNegotiation(); RelayoutRequest(); } -bool PushButton::OnSelected() -{ - Actor& buttonImage = GetButtonImage(); - Actor& selectedImage = GetSelectedImage(); - Actor& selectedBackgroundImage = GetSelectedBackgroundImage(); - - PaintState paintState = GetPaintState(); - - switch( paintState ) - { - case UnselectedState: - { - FadeOutImage( buttonImage ); - FadeInImage( selectedBackgroundImage ); - FadeInImage( selectedImage ); - StartTransitionAnimation(); - break; - } - case SelectedState: - { - FadeOutImage( selectedBackgroundImage ); - FadeOutImage( selectedImage ); - FadeInImage( buttonImage ); - StartTransitionAnimation(); - break; - } - case UnselectedSelectedTransition: - { - float opacity = 1.f; - if( selectedImage ) - { - opacity = selectedImage.GetCurrentOpacity(); - } - - StopTransitionAnimation( false ); - FadeOutImage( selectedBackgroundImage, opacity ); - FadeOutImage( selectedImage, opacity ); - FadeInImage( buttonImage, 1.f - opacity ); - StartTransitionAnimation(); - break; - } - case SelectedUnselectedTransition: - { - float opacity = 0.f; - if( selectedImage ) - { - opacity = selectedImage.GetCurrentOpacity(); - } - - StopTransitionAnimation( false ); - FadeOutImage( buttonImage, 1.f - opacity ); - FadeInImage( selectedBackgroundImage, opacity ); - FadeInImage( selectedImage, opacity ); - StartTransitionAnimation(); - break; - } - case DisabledUnselectedTransition: - { - StopTransitionAnimation(); - FadeOutImage( buttonImage ); - FadeInImage( selectedBackgroundImage ); - FadeInImage( selectedImage ); - StartTransitionAnimation(); - break; - } - case DisabledSelectedTransition: - { - StopTransitionAnimation(); - FadeOutImage( selectedBackgroundImage ); - FadeOutImage( selectedImage ); - FadeInImage( buttonImage ); - StartTransitionAnimation(); - break; - } - default: - { - break; - } - } - - if( mTransitionAnimation ) - { - return true; - } - - return false; -} - -bool PushButton::OnDisabled() -{ - Actor& buttonImage = GetButtonImage(); - Actor& selectedImage = GetSelectedImage(); - Actor& selectedBackgroundImage = GetSelectedBackgroundImage(); - Actor& backgroundImage = GetBackgroundImage(); - Actor& disabledImage = GetDisabledImage(); - Actor& disabledSelectedImage = GetDisabledSelectedImage(); - Actor& disabledBackgroundImage = GetDisabledBackgroundImage(); - - PaintState paintState = GetPaintState(); - - switch( paintState ) - { - case UnselectedState: - { - FadeOutImage( backgroundImage ); - FadeOutImage( buttonImage ); - FadeInImage( disabledBackgroundImage ); - FadeInImage( disabledImage ); - StartTransitionAnimation(); - break; - } - case SelectedState: - { - FadeOutImage( backgroundImage ); - FadeOutImage( selectedBackgroundImage ); - FadeOutImage( selectedImage ); - FadeInImage( disabledBackgroundImage ); - FadeInImage( disabledSelectedImage ); - StartTransitionAnimation(); - break; - } - case DisabledUnselectedState: - { - FadeOutImage( disabledBackgroundImage ); - FadeOutImage( disabledImage ); - FadeInImage( backgroundImage ); - FadeInImage( buttonImage ); - StartTransitionAnimation(); - break; - } - case DisabledSelectedState: - { - FadeOutImage( disabledBackgroundImage ); - FadeOutImage( disabledSelectedImage ); - FadeInImage( backgroundImage ); - FadeInImage( selectedBackgroundImage ); - FadeInImage( selectedImage ); - StartTransitionAnimation(); - break; - } - case UnselectedSelectedTransition: - { - float opacity = 1.f; - if( selectedImage ) - { - opacity = selectedImage.GetCurrentOpacity(); - } - - StopTransitionAnimation(); - FadeOutImage( backgroundImage ); - FadeOutImage( selectedBackgroundImage, opacity ); - FadeOutImage( selectedImage, opacity ); - FadeInImage( disabledBackgroundImage ); - FadeInImage( disabledSelectedImage ); - StartTransitionAnimation(); - break; - } - case SelectedUnselectedTransition: - { - float opacity = 1.f; - if( buttonImage ) - { - opacity = buttonImage.GetCurrentOpacity(); - } - - StopTransitionAnimation(); - FadeOutImage( backgroundImage ); - FadeOutImage( buttonImage, opacity ); - FadeInImage( disabledBackgroundImage ); - FadeInImage( disabledImage ); - StartTransitionAnimation(); - break; - } - case UnselectedDisabledTransition: - { - float opacity = 1.f; - if( disabledImage ) - { - opacity = disabledImage.GetCurrentOpacity(); - } - - StopTransitionAnimation( false ); - FadeOutImage( disabledBackgroundImage, opacity ); - FadeOutImage( disabledImage, opacity ); - FadeInImage( backgroundImage, 1.f - opacity ); - FadeInImage( buttonImage, 1.f - opacity ); - StartTransitionAnimation(); - break; - } - case DisabledUnselectedTransition: - { - float opacity = 1.f; - if( buttonImage ) - { - opacity = buttonImage.GetCurrentOpacity(); - } - - StopTransitionAnimation( false ); - FadeOutImage( backgroundImage, opacity ); - FadeOutImage( buttonImage, opacity ); - FadeInImage( disabledBackgroundImage, 1.f - opacity ); - FadeInImage( disabledImage, 1.f - opacity ); - StartTransitionAnimation(); - break; - } - case SelectedDisabledTransition: - { - float opacity = 1.f; - if( disabledSelectedImage ) - { - opacity = disabledSelectedImage.GetCurrentOpacity(); - } - - StopTransitionAnimation( false ); - FadeOutImage( disabledBackgroundImage, opacity ); - FadeOutImage( disabledSelectedImage, opacity ); - FadeInImage( backgroundImage, 1.f - opacity ); - FadeInImage( selectedBackgroundImage, 1.f - opacity ); - FadeInImage( selectedImage, 1.f - opacity ); - StartTransitionAnimation(); - break; - } - case DisabledSelectedTransition: - { - float opacity = 1.f; - if( selectedImage ) - { - opacity = selectedImage.GetCurrentOpacity(); - } - - StopTransitionAnimation( false ); - FadeOutImage( backgroundImage, opacity ); - FadeOutImage( selectedBackgroundImage, opacity ); - FadeOutImage( selectedImage, opacity ); - FadeInImage( disabledBackgroundImage, 1.f - opacity ); - FadeInImage( disabledSelectedImage, 1.f - opacity ); - StartTransitionAnimation(); - break; - } - } - - if( mTransitionAnimation ) - { - return true; - } - - return false; -} - -bool PushButton::OnPressed() -{ - Actor& buttonImage = GetButtonImage(); - Actor& selectedImage = GetSelectedImage(); - Actor& selectedBackgroundImage = GetSelectedBackgroundImage(); - - PaintState paintState = GetPaintState(); - - switch( paintState ) - { - case UnselectedState: - { - FadeOutImage( buttonImage ); - FadeInImage( selectedBackgroundImage ); - FadeInImage( selectedImage ); - StartTransitionAnimation(); - break; - } - case SelectedUnselectedTransition: - { - float opacity = 1.f; - if( buttonImage ) - { - opacity = buttonImage.GetCurrentOpacity(); - } - - StopTransitionAnimation( false ); - FadeOutImage( buttonImage, opacity ); - FadeInImage( selectedBackgroundImage, 1.f - opacity ); - FadeInImage( selectedImage, 1.f - opacity ); - StartTransitionAnimation(); - break; - } - case DisabledUnselectedTransition: - { - float opacity = 1.f; - if( buttonImage ) - { - opacity = buttonImage.GetCurrentOpacity(); - } - - StopTransitionAnimation(); - FadeOutImage( buttonImage, opacity ); - FadeInImage( selectedBackgroundImage ); - FadeInImage( selectedImage ); - StartTransitionAnimation(); - break; - } - default: - break; - } - - if( mTransitionAnimation ) - { - return true; - } - - return false; -} - -bool PushButton::OnReleased() -{ - Actor& buttonImage = GetButtonImage(); - Actor& selectedImage = GetSelectedImage(); - Actor& selectedBackgroundImage = GetSelectedBackgroundImage(); - - PaintState paintState = GetPaintState(); - - switch( paintState ) - { - case SelectedState: - { - FadeOutImage( selectedBackgroundImage ); - FadeOutImage( selectedImage ); - FadeInImage( buttonImage ); - StartTransitionAnimation(); - break; - } - case UnselectedSelectedTransition: - { - float opacity = 1.f; - if( selectedImage ) - { - opacity = selectedImage.GetCurrentOpacity(); - } - - StopTransitionAnimation( false ); - FadeOutImage( selectedBackgroundImage, opacity ); - FadeOutImage( selectedImage, opacity ); - FadeInImage( buttonImage, 1.f - opacity ); - StartTransitionAnimation(); - break; - } - case DisabledSelectedTransition: - { - float opacity = 1.f; - if( selectedImage ) - { - opacity = selectedImage.GetCurrentOpacity(); - } - - StopTransitionAnimation(); - FadeOutImage( selectedBackgroundImage, opacity ); - FadeOutImage( selectedImage, opacity ); - FadeInImage( buttonImage ); - StartTransitionAnimation(); - break; - } - default: - { - break; - } - } - - if( mTransitionAnimation ) - { - return true; - } - - return false; -} - -void PushButton::StopAllAnimations() +void PushButton::OnDisabledBackgroundImageSet() { - StopTransitionAnimation(); + ConfigureSizeNegotiation(); + RelayoutRequest(); } void PushButton::OnSizeSet( const Vector3& targetSize ) @@ -553,66 +199,40 @@ void PushButton::OnSizeSet( const Vector3& targetSize ) } } -void PushButton::StartTransitionAnimation() +void PushButton::PrepareForTranstionIn( Actor actor ) { - if( mTransitionAnimation ) - { - mTransitionAnimation.FinishedSignal().Connect( this, &PushButton::TransitionAnimationFinished ); - mTransitionAnimation.Play(); - } + actor.SetOpacity( 0.0f ); } -void PushButton::StopTransitionAnimation( bool remove ) +void PushButton::PrepareForTranstionOut( Actor actor ) { - if( mTransitionAnimation ) - { - mTransitionAnimation.Clear(); - mTransitionAnimation.Reset(); - } - - if( remove ) - { - UpdatePaintTransitionState(); - } + actor.SetOpacity( 1.0f ); } -void PushButton::FadeInImage( Actor& image, float opacity, Vector3 scale ) +void PushButton::OnTransitionIn( Actor actor ) { - if( image ) - { - image.SetOpacity( opacity ); - image.SetScale( scale ); - - if( !mTransitionAnimation ) - { - mTransitionAnimation = Dali::Animation::New( GetAnimationTime() ); - } + FadeImageTo( actor, 1.f ); +} - mTransitionAnimation.AnimateTo( Property( image, Actor::Property::COLOR_ALPHA ), 1.f ); - } +void PushButton::OnTransitionOut( Actor actor ) +{ + FadeImageTo( actor, 0.0f ); } -void PushButton::FadeOutImage( Actor& image, float opacity, Vector3 scale ) +void PushButton::FadeImageTo( Actor actor, float opacity ) { - if( image ) + if( actor ) { - image.SetOpacity( opacity ); - image.SetScale( scale ); + Dali::Animation transitionAnimation = GetTransitionAnimation(); + DALI_ASSERT_DEBUG( transitionAnimation ); - if( !mTransitionAnimation ) + if( transitionAnimation ) { - mTransitionAnimation = Dali::Animation::New( GetAnimationTime() ); + transitionAnimation.AnimateTo( Property( actor, Actor::Property::COLOR_ALPHA ), opacity ); } - - mTransitionAnimation.AnimateTo( Property( image, Actor::Property::COLOR_ALPHA ), 0.f ); } } -void PushButton::TransitionAnimationFinished( Dali::Animation& source ) -{ - StopTransitionAnimation(); -} - Vector3 PushButton::GetNaturalSize() { Vector3 size; diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.h b/dali-toolkit/internal/controls/buttons/push-button-impl.h index da49f13..51164b5 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.h @@ -20,7 +20,6 @@ // EXTERNAL INCLUDES #include -#include // INTERNAL INCLUDES #include @@ -100,34 +99,34 @@ private: // From Button virtual void OnDisabledImageSet(); /** - * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet() + * @copydoc Toolkit::Internal::Button::OnDisabledSelectedImageSet() */ - virtual void OnDisabledBackgroundImageSet(); + virtual void OnDisabledSelectedImageSet(); /** - * @copydoc Toolkit::Internal::Button::OnSelected() + * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet() */ - virtual bool OnSelected(); + virtual void OnDisabledBackgroundImageSet(); /** - * @copydoc Toolkit::Internal::Button::OnDisabled() + * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor ) */ - virtual bool OnDisabled(); + virtual void PrepareForTranstionIn( Actor actor ); /** - * @copydoc Toolkit::Internal::Button::OnPressed() + * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor ) */ - virtual bool OnPressed(); + virtual void PrepareForTranstionOut( Actor actor ); /** - * @copydoc Toolkit::Internal::Button::OnReleased() + * @copydoc Toolkit::Internal::Button::OnTransitionIn( Actor actor ) */ - virtual bool OnReleased(); + virtual void OnTransitionIn( Actor actor ); /** - * @copydoc Toolkit::Internal::Button::StopAllAnimations() + * @copydoc Toolkit::Internal::Button::OnTransitionOut( Actor actor ) */ - virtual void StopAllAnimations(); + virtual void OnTransitionOut( Actor actor ); private: // From Control @@ -149,33 +148,11 @@ private: // From Control private: /** - * Starts the transition animation. - * PushButton::TransitionAnimationFinished slot is called when the animation finishes. - */ - void StartTransitionAnimation(); - - /** - * Stops the transition animation. - * @param[in] remove If true, removes the fadeout actor from root. - */ - void StopTransitionAnimation( bool remove = true ); - - /** * It adds the actor to the root actor and to the fade in animation. - * @param[inout] image The actor. - * @param[in] opacity The initial opacity. - * @param[in] scale The initial scale. - */ - void FadeInImage( Actor& image, float opacity = 0.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) ); - - /** - * It adds the actor fade out animation and stores it to be removed when the animation finishes. - * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutCheckedImage member. - * @param[inout] image The actor. - * @param[in] opacity The initial opacity. - * @param[in] scale The initial scale. + * @param[inout] actor The actor. + * @param[in] opacity The opacity to fade to */ - void FadeOutImage( Actor& image, float opacity = 1.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) ); + void FadeImageTo( Actor actor, float opacity ); /** * @brief Custom configuration for size negotiation @@ -191,13 +168,6 @@ private: */ void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label ); - // slots - - /** - * Called when the transition animation finishes. - */ - void TransitionAnimationFinished( Dali::Animation& source ); - private: // Undefined @@ -208,7 +178,6 @@ private: private: - Animation mTransitionAnimation; ///< Animation used in the state transitions. Vector3 mSize; ///< The button's size. }; diff --git a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp index 81b6a5d..1e51ce3 100644 --- a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp @@ -44,6 +44,8 @@ TypeRegistration typeRegistration( typeid( Toolkit::RadioButton ), typeid( Toolk const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected.png"; const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected.png"; +const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected-disabled.png"; +const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected-disabled.png"; const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f ); } @@ -79,11 +81,15 @@ void RadioButton::OnButtonInitialize() // Wrap size of radio button around all its children self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); - Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR ); - Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR ); + Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + Image disabledImage = Dali::ResourceImage::New( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); + Image disabledSelectedImage = Dali::ResourceImage::New( DISABLED_SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER ); SetButtonImage( ImageActor::New( buttonImage ) ); SetSelectedImage( ImageActor::New( selectedImage ) ); + SetDisabledImage( ImageActor::New( disabledImage ) ); + SetDisabledSelectedImage( ImageActor::New( disabledSelectedImage ) ); RelayoutRequest(); } @@ -115,25 +121,26 @@ void RadioButton::OnLabelSet() label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH ); } - if( IsSelected() ) + if( IsSelected() && GetSelectedImage() ) { label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } - else + else if( GetButtonImage() ) { label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } + else + { + label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL ); + } } } -bool RadioButton::OnSelected() +void RadioButton::OnSelected() { - Actor& buttonImage = GetButtonImage(); - Actor& selectedImage = GetSelectedImage(); Actor& label = GetLabel(); PaintState paintState = GetPaintState(); - switch( paintState ) { case UnselectedState: @@ -151,9 +158,8 @@ bool RadioButton::OnSelected() } } - RemoveChild( buttonImage ); - - if( label ) + Actor& selectedImage = GetSelectedImage(); + if( label && selectedImage ) { label.SetX( selectedImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } @@ -161,9 +167,8 @@ bool RadioButton::OnSelected() } case SelectedState: { - RemoveChild( selectedImage ); - - if( label ) + Actor& buttonImage = GetButtonImage(); + if( label && buttonImage ) { label.SetX( buttonImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL ); } @@ -174,9 +179,6 @@ bool RadioButton::OnSelected() break; } } - - // there is no animation - return false; } } // namespace Internal diff --git a/dali-toolkit/internal/controls/buttons/radio-button-impl.h b/dali-toolkit/internal/controls/buttons/radio-button-impl.h index d525a43..e7703a0 100644 --- a/dali-toolkit/internal/controls/buttons/radio-button-impl.h +++ b/dali-toolkit/internal/controls/buttons/radio-button-impl.h @@ -77,7 +77,7 @@ private: // From Button /** * @copydoc Toolkit::Internal::Button::OnSelected() */ - virtual bool OnSelected(); + virtual void OnSelected(); /** * @copydoc Toolkit::Internal::Button::OnLabelSet() -- 2.7.4