Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: ui/gfx/native_theme_android.h

Issue 8497054: Upstream: ui implementation in Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments and sync Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/canvas_skia_android.cc ('k') | ui/gfx/native_theme_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_GFX_NATIVE_THEME_ANDROID_H_
6 #define UI_GFX_NATIVE_THEME_ANDROID_H_
7
8 #include "base/basictypes.h"
9 #include "skia/ext/platform_canvas.h"
10
11 namespace gfx {
12 class Rect;
13 class Size;
14
15 // Android theming API.
16 class NativeThemeAndroid {
17 public:
18 // The part to be painted / sized.
19 enum Part {
20 SCROLLBAR_DOWN_ARROW,
21 SCROLLBAR_LEFT_ARROW,
22 SCROLLBAR_RIGHT_ARROW,
23 SCROLLBAR_UP_ARROW,
24 CHECKBOX,
25 RADIO,
26 PUSH_BUTTON,
27 TEXTFIELD,
28 MENU_LIST,
29 SLIDER_TRACK,
30 SLIDER_TNUMB,
31 INNER_SPIN_BUTTON,
32 PROGRESS_BAR,
33 };
34
35 // The state of the part.
36 enum State {
37 DISABLED,
38 HOVERED,
39 NORMAL,
40 PRESSED,
41 };
42
43 struct ButtonExtraParams {
44 bool checked;
45 bool indeterminate; // Whether the button state is indeterminate.
46 bool is_default; // Whether the button is default button.
47 bool has_border;
48 SkColor background_color;
49 };
50
51 struct TextFieldExtraParams {
52 bool is_text_area;
53 bool is_listbox;
54 SkColor background_color;
55 };
56
57 struct MenuListExtraParams {
58 bool has_border;
59 bool has_border_radius;
60 int arrow_x;
61 int arrow_y;
62 SkColor background_color;
63 };
64
65 struct SliderExtraParams {
66 bool vertical;
67 bool in_drag;
68 };
69
70 struct InnerSpinButtonExtraParams {
71 bool spin_up;
72 bool read_only;
73 };
74
75 struct ProgressBarExtraParams {
76 bool determinate;
77 int value_rect_x;
78 int value_rect_y;
79 int value_rect_width;
80 int value_rect_height;
81 };
82
83 union ExtraParams {
84 ButtonExtraParams button;
85 MenuListExtraParams menu_list;
86 SliderExtraParams slider;
87 TextFieldExtraParams text_field;
88 InnerSpinButtonExtraParams inner_spin;
89 ProgressBarExtraParams progress_bar;
90 };
91
92 // Gets our singleton instance.
93 static NativeThemeAndroid* instance();
94
95 // Return the size of the part.
96 gfx::Size GetPartSize(Part part) const;
97
98 // Paint the part to the canvas.
99 void Paint(SkCanvas* canvas,
100 Part part,
101 State state,
102 const gfx::Rect& rect,
103 const ExtraParams& extra);
104
105 private:
106 NativeThemeAndroid();
107 virtual ~NativeThemeAndroid();
108
109 // Draw the arrow. Used by scrollbar and inner spin button.
110 void PaintArrowButton(SkCanvas* gc,
111 const gfx::Rect& rect,
112 Part direction,
113 State state);
114
115 // Draw the checkbox.
116 void PaintCheckbox(SkCanvas* canvas,
117 State state,
118 const gfx::Rect& rect,
119 const ButtonExtraParams& button);
120
121 // Draw the radio.
122 void PaintRadio(SkCanvas* canvas,
123 State state,
124 const gfx::Rect& rect,
125 const ButtonExtraParams& button);
126
127 // Draw the push button.
128 void PaintButton(SkCanvas* canvas,
129 State state,
130 const gfx::Rect& rect,
131 const ButtonExtraParams& button);
132
133 // Draw the text field.
134 void PaintTextField(SkCanvas* canvas,
135 State state,
136 const gfx::Rect& rect,
137 const TextFieldExtraParams& text);
138
139 // Draw the menu list.
140 void PaintMenuList(SkCanvas* canvas,
141 State state,
142 const gfx::Rect& rect,
143 const MenuListExtraParams& menu_list);
144
145 // Draw the slider track.
146 void PaintSliderTrack(SkCanvas* canvas,
147 State state,
148 const gfx::Rect& rect,
149 const SliderExtraParams& slider);
150
151 // Draw the slider thumb.
152 void PaintSliderThumb(SkCanvas* canvas,
153 State state,
154 const gfx::Rect& rect,
155 const SliderExtraParams& slider);
156
157 // Draw the inner spin button.
158 void PaintInnerSpinButton(
159 SkCanvas* canvas,
160 State state,
161 const gfx::Rect& rect,
162 const InnerSpinButtonExtraParams& spin_button);
163
164 // Draw the progress bar.
165 void PaintProgressBar(
166 SkCanvas* canvas,
167 State state,
168 const gfx::Rect& rect,
169 const ProgressBarExtraParams& progress_bar);
170
171 // Return true if there is intersection between the |canvas| and the given
172 // rectangle.
173 bool IntersectsClipRectInt(SkCanvas* canvas,
174 int x,
175 int y,
176 int w,
177 int h);
178
179 // Draw the dest rectangle with the given bitmap which might be scaled if its
180 // size is not same as target rectangle.
181 void DrawBitmapInt(SkCanvas* canvas,
182 const SkBitmap& bitmap,
183 int src_x,
184 int src_y,
185 int src_w,
186 int src_h,
187 int dest_x,
188 int dest_y,
189 int dest_w,
190 int dest_h);
191
192 // Draw the target rectangle with the |bitmap| accroding the given
193 // |tile_scale_x| and |tile_scale_y|
194 void DrawTiledImage(SkCanvas* canvas,
195 const SkBitmap& bitmap,
196 int src_x,
197 int src_y,
198 double tile_scale_x,
199 double tile_scale_y,
200 int dest_x,
201 int dest_y,
202 int w,
203 int h) const;
204
205 // Return a new color which comes from the |hsv| by adjusting saturate and
206 // brighten according |saturate_amount| and |brighten_amount|
207 SkColor SaturateAndBrighten(SkScalar* hsv,
208 SkScalar saturate_amount,
209 SkScalar brighten_amount) const;
210
211 void DrawVertLine(SkCanvas* canvas,
212 int x,
213 int y1,
214 int y2,
215 const SkPaint& paint) const;
216
217 void DrawHorizLine(SkCanvas* canvas,
218 int x1,
219 int x2,
220 int y,
221 const SkPaint& paint) const;
222
223 void DrawBox(SkCanvas* canvas,
224 const gfx::Rect& rect,
225 const SkPaint& paint) const;
226
227 // Return the |value| if it is between |min| and |max|, otherwise the |min|
228 // or |max| is returned dependent on which is mostly near the |value|.
229 SkScalar Clamp(SkScalar value, SkScalar min, SkScalar max) const;
230
231 // Used to return the color of scrollbar based on the color of thumb and
232 // track.
233 SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const;
234
235 DISALLOW_COPY_AND_ASSIGN(NativeThemeAndroid);
236 };
237
238 } // namespace gfx
239
240 #endif // UI_GFX_NATIVE_THEME_ANDROID_H_
OLDNEW
« no previous file with comments | « ui/gfx/canvas_skia_android.cc ('k') | ui/gfx/native_theme_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698