Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_ColorPickerPresenter.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FUiCtrl_ColorPickerPresenter.h
19  * @brief               This is the header file for the _ColorPicker class.
20  *
21  * This header file contains the declarations of the %_ColorPicker class.
22  */
23
24 #ifndef _FUI_CTRL_INTERNAL_COLORPICKER_PRESENTER_H_
25 #define _FUI_CTRL_INTERNAL_COLORPICKER_PRESENTER_H_
26
27 #include <FBaseObject.h>
28 #include "FUiCtrl_ColorPicker.h"
29
30 namespace Tizen { namespace Graphics
31 {
32 class Point;
33 class Rectangle;
34 class Canvas;
35 class Color;
36 }} //Tizen::Graphics
37
38 namespace Tizen {namespace Ui
39 {
40 class _TouchInfo;
41 }} //Tizen::Ui
42
43 namespace Tizen { namespace Ui { namespace Animations
44 {
45 class _VisualElement;
46 }}} // Tizen::Ui::Animations
47
48 namespace Tizen {namespace Ui { namespace Controls
49 {
50
51 enum _ColorPickerComponentType
52 {
53         HSL_NOT = -1,
54         HUE_HANDLER = 0,
55         SAT_HANDLER,
56         LUM_HANDLER,
57         HUE_BAR,
58         SAT_BAR,
59         LUM_BAR,
60         HUE_ARROWLEFT,
61         HUE_ARROWRIGHT,
62         SAT_ARROWLEFT,
63         SAT_ARROWRIGHT,
64         LUM_ARROWLEFT,
65         LUM_ARROWRIGHT,
66         COMPONENT_TYPE_MAX
67 };
68
69 class _ColorPickerModel;
70
71 class _ColorPickerPresenter
72         : public Tizen::Base::Object
73         , public Tizen::Base::Runtime::ITimerEventListener
74         , virtual public Tizen::Base::Runtime::IEventListener
75 {
76 public:
77         result Draw(void);
78
79         Tizen::Graphics::Color GetColor(void) const;
80
81         int GetHue(void) const;
82
83         int GetSaturation(void) const;
84
85         int GetLuminance(void) const;
86
87         void SetColor(const Tizen::Graphics::Color& color);
88
89         result SetHue(int hue);
90
91         result SetSaturation(int saturation);
92
93         result SetLuminance(int luminance);
94
95         void LoadDrawingProperties(const Tizen::Graphics::Rectangle& controlBounds);
96
97         void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
98
99         bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
100
101         bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
102
103         bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
104
105         bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
106
107         virtual ~_ColorPickerPresenter(void);
108
109         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
110
111         static _ColorPickerPresenter* CreateInstanceN(_ColorPicker& colorPicker);
112
113         Tizen::Ui::Animations::_VisualElement* CreateHandlerN(Tizen::Ui::Animations::_VisualElement& rootElement, _ColorPickerComponentType handlerType);
114
115 private:
116
117         result LoadResource(void);
118
119         result DrawHueSlider(Tizen::Graphics::Canvas& canvas);
120
121         result DrawLuminanceSlider(Tizen::Graphics::Canvas& canvas);
122
123         result DrawSaturationSlider(Tizen::Graphics::Canvas& canvas);
124
125         result DrawLine(Tizen::Graphics::Canvas& canvas);
126
127         result DrawArrowButton(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& rcButton, bool isSelected, bool drawLeftButton);
128
129         result DrawArrowButtons(Tizen::Graphics::Canvas& canvas);
130
131         result MoveHandler(_ColorPickerComponentType handlerType);
132
133         result TouchButton(void);
134
135         result TouchHandler(int x);
136
137         result SetHandlerPosition(_ColorPickerComponentType handlerType, int position);
138
139         result SetHandlerPositionByRatio(_ColorPickerComponentType handlerType, double ratio);
140
141         result ChangeColorFromCurrentHandlerPosition(_ColorPickerComponentType handlerType);
142
143         bool IsLeftButton(_ColorPickerComponentType buttonType);
144
145         Tizen::Graphics::Rectangle& GetBarBoundsFromHandler(_ColorPickerComponentType handlerType);
146
147         _ColorPickerComponentType GetTouchActionType(const Tizen::Graphics::Point& position) const;
148
149         result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::Rectangle& bounds, Tizen::Graphics::Bitmap* pBitmap);
150
151         _ColorPickerPresenter(_ColorPicker& colorPicker);
152
153         _ColorPickerPresenter(const _ColorPickerPresenter&);
154
155         _ColorPickerPresenter& operator =(const _ColorPickerPresenter&);
156
157 private:
158
159         static const double _MAX_COLOR_VALUE = 255.0;
160         static const double _MIN_COLOR_VALUE = 0.0;
161         static const double _HUE_SPACE_RANGE = 6.0;
162         static const byte _ZERO_SATURATION_RGB_VALUE = 127;
163
164         _ColorPicker* __pColorPicker;
165
166         _ColorPickerModel* __pColorPickerModel;
167
168         _ColorPickerComponentType __eventType;
169
170         int __topMargin;
171
172         int __blockMargin;
173
174         int __blockHeight;
175         int __dividerMargin;
176         int __dividerWidth;
177
178         Tizen::Graphics::Rectangle __componentBounds[COMPONENT_TYPE_MAX];
179
180         Tizen::Graphics::Color __hueColor;
181
182         Tizen::Graphics::Color __saturationColor;
183
184         Tizen::Base::Runtime::Timer* __pSlideTimer;
185         Tizen::Graphics::Bitmap* __pHueSliderBgBitmap;
186         Tizen::Graphics::Bitmap* __pCustomBitmap;
187         Tizen::Graphics::Bitmap* __pLuminanceSliderBgBitmap;
188         Tizen::Graphics::Bitmap* __pSaturationSliderBgBitmap;
189         Tizen::Graphics::Bitmap* __pColorNormalReplacementBgBitmap;
190         Tizen::Graphics::Bitmap* __pColorPressedReplacementBgBitmap;
191         Tizen::Graphics::Bitmap* __pColorDisabledReplacementBgBitmap;
192         Tizen::Graphics::Bitmap* __pColorNormalEffectReplacementBgBitmap;
193         Tizen::Graphics::Bitmap* __pColorPressedEffectReplacementBgBitmap;
194         Tizen::Graphics::Bitmap* __pColorDisabledEffectReplacementBgBitmap;
195         Tizen::Graphics::Bitmap* __pLeftArrowNormalBitmap;
196         Tizen::Graphics::Bitmap* __pLeftArrowPressedBitmap;
197         Tizen::Graphics::Bitmap* __pLeftArrowDisabledBitmap;
198         Tizen::Graphics::Bitmap* __pRightArrowNormalBitmap;
199         Tizen::Graphics::Bitmap* __pRightArrowPressedBitmap;
200         Tizen::Graphics::Bitmap* __pRightArrowDisabledBitmap;
201         Tizen::Graphics::Bitmap* __pHandlerBitmap;
202         Tizen::Graphics::Bitmap* __pLandscapeHueSliderBgBitmap;
203         Tizen::Graphics::Bitmap* __pLandscapeCustomBitmap;
204         Tizen::Graphics::Bitmap* __pLandscapeLuminanceSliderBgBitmap;
205         Tizen::Graphics::Bitmap* __pLandscapeSaturationSliderBgBitmap;
206 };      // _ColorPickerPresenter
207
208 }}}     // Tizen::Ui::Controls
209
210 #endif  // _FUI_CTRL_INTERNAL_COLORPICKER_PRESENTER_H_