Buttons to use Visuals
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / check-box-button-impl.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "check-box-button-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/type-registry.h>
24 #include <dali/public-api/images/resource-image.h>
25
26 //INTERNAL INCLUDES
27 #include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
28 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
29 #include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
30 #include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
31
32 #if defined(DEBUG_ENABLED)
33   extern Debug::Filter* gLogButtonFilter;
34 #endif
35
36 namespace Dali
37 {
38
39 namespace Toolkit
40 {
41
42 namespace Internal
43 {
44
45 namespace
46 {
47
48 const float ANIMATION_TIME( 0.26f );  // EFL checkbox tick time - Will be replaced by stylable tranisitions
49
50 BaseHandle Create()
51 {
52   return Toolkit::CheckBoxButton::New();
53 }
54
55 TypeRegistration mType( typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create );
56
57
58
59 }
60
61 Dali::Toolkit::CheckBoxButton CheckBoxButton::New()
62 {
63   // Create the implementation, temporarily owned on stack
64   IntrusivePtr< CheckBoxButton > internalCheckBoxButton = new CheckBoxButton();
65
66   // Pass ownership to CustomActor
67   Dali::Toolkit::CheckBoxButton checkBoxButton( *internalCheckBoxButton );
68
69   // Second-phase init of the implementation
70   // This can only be done after the CustomActor connection has been made...
71   internalCheckBoxButton->Initialize();
72
73   return checkBoxButton;
74 }
75
76 CheckBoxButton::CheckBoxButton()
77 : Button()
78 {
79   SetTogglableButton( true );
80
81   SetAnimationTime( ANIMATION_TIME );
82 }
83
84 CheckBoxButton::~CheckBoxButton()
85 {
86 }
87
88 void CheckBoxButton::FadeImageTo( Actor actor , float opacity )
89 {
90   if( actor )
91   {
92     Dali::Animation transitionAnimation = GetTransitionAnimation();
93
94     if( transitionAnimation )
95     {
96       transitionAnimation.AnimateTo( Property( actor, Actor::Property::COLOR_ALPHA ), opacity );
97     }
98   }
99 }
100
101 void CheckBoxButton::OnInitialize()
102 {
103   Button::OnInitialize();
104 }
105
106 void CheckBoxButton::PrepareForTransitionIn( Actor actor )
107 {
108   // Set Toolkit::Button::Property::SELECTED_VISUAL and Toolkit::Button::Property::UNSELECTED_VISUAL to opacity 0
109   // Then get and start animation
110 }
111
112 void CheckBoxButton::PrepareForTransitionOut( Actor actor )
113 {
114   // Set Toolkit::Button::Property::SELECTED_VISUAL and Toolkit::Button::Property::UNSELECTED_VISUAL to opacity 1
115   // Then get and start animation
116 }
117
118 void CheckBoxButton::OnTransitionIn( Actor actor )
119 {
120   // Only transition selected and unselected visual, background doesn't change.
121   // Start Fade animation to 1
122 }
123
124 void CheckBoxButton::OnTransitionOut( Actor actor )
125 {
126   // Only transition selected and unselected visual, background doesn't change.
127   // Start Fade animation to 0
128 }
129
130 } // namespace Internal
131
132 } // namespace Toolkit
133
134 } // namespace Dali