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

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: init 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
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 kScrollbarDownArrow,
sky 2011/11/10 00:41:01 Use CAP_STYLE. The chromium style guide calls this
michaelbai 2011/11/10 22:51:36 These styles were used in all native_theme_{platfo
sky 2011/11/10 23:21:28 See native_theme_win.h
michaelbai 2011/11/11 00:11:47 Done.
21 kScrollbarLeftArrow,
22 kScrollbarRightArrow,
23 kScrollbarUpArrow,
24 kCheckbox,
25 kRadio,
26 kPushButton,
27 kTextField,
28 kMenuList,
29 kSliderTrack,
30 kSliderThumb,
31 kInnerSpinButton,
32 kProgressBar,
33 };
34
35 // The state of the part.
36 enum State {
37 kDisabled,
38 kHovered,
39 kNormal,
40 kPressed,
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 virtual gfx::Size GetPartSize(Part part) const;
sky 2011/11/10 00:41:01 Are there subclasses that warrant this being virtu
michaelbai 2011/11/10 22:51:36 Removed 'virtual', thanks
97 // Paint the part to the canvas.
sky 2011/11/10 00:41:01 newline between 96 and 97.
michaelbai 2011/11/10 22:51:36 Done.
98 virtual void Paint(SkCanvas* canvas,
99 Part part,
100 State state,
101 const gfx::Rect& rect,
102 const ExtraParams& extra);
103
104 protected:
105 NativeThemeAndroid();
106 virtual ~NativeThemeAndroid();
107
108 // Draw the arrow. Used by scrollbar and inner spin button.
109 virtual void PaintArrowButton(
110 SkCanvas* gc,
111 const gfx::Rect& rect,
112 Part direction,
113 State state);
114 // Draw the checkbox.
sky 2011/11/10 00:41:01 newline between methods.
michaelbai 2011/11/10 22:51:36 Done.
115 virtual void PaintCheckbox(SkCanvas* canvas,
sky 2011/11/10 00:41:01 If you can't nicely align all params with the '(',
michaelbai 2011/11/10 22:51:36 Done.
116 State state,
117 const gfx::Rect& rect,
118 const ButtonExtraParams& button);
119 // Draw the radio.
120 virtual void PaintRadio(SkCanvas* canvas,
121 State state,
122 const gfx::Rect& rect,
123 const ButtonExtraParams& button);
124 // Draw the push button.
125 virtual void PaintButton(SkCanvas* canvas,
126 State state,
127 const gfx::Rect& rect,
128 const ButtonExtraParams& button);
129 // Draw the text field.
130 virtual void PaintTextField(SkCanvas* canvas,
131 State state,
132 const gfx::Rect& rect,
133 const TextFieldExtraParams& text);
134 // Draw the menu list.
135 virtual void PaintMenuList(SkCanvas* canvas,
136 State state,
137 const gfx::Rect& rect,
138 const MenuListExtraParams& menu_list);
139 // Draw the slider track.
140 virtual void PaintSliderTrack(SkCanvas* canvas,
141 State state,
142 const gfx::Rect& rect,
143 const SliderExtraParams& slider);
144 // Draw the slider thumb.
145 virtual void PaintSliderThumb(SkCanvas* canvas,
146 State state,
147 const gfx::Rect& rect,
148 const SliderExtraParams& slider);
149 // Draw the inner spin button.
150 virtual void PaintInnerSpinButton(SkCanvas* canvas,
151 State state,
152 const gfx::Rect& rect,
153 const InnerSpinButtonExtraParams& spin_button);
154 // Draw the progress bar.
155 virtual void PaintProgressBar(SkCanvas* canvas,
156 State state,
157 const gfx::Rect& rect,
158 const ProgressBarExtraParams& progress_bar);
159
160 protected:
sky 2011/11/10 00:41:01 remove this since you're already in the protected
michaelbai 2011/11/10 22:51:36 Done.
161 bool IntersectsClipRectInt(SkCanvas* canvas,
sky 2011/11/10 00:41:01 Add descriptions of all your methods.
michaelbai 2011/11/10 22:51:36 Done.
162 int x, int y, int w, int h);
163
164 void DrawBitmapInt(SkCanvas* canvas, const SkBitmap& bitmap,
sky 2011/11/10 00:41:01 wrap bitmap to the next line.
michaelbai 2011/11/10 22:51:36 Done.
165 int src_x, int src_y, int src_w, int src_h,
166 int dest_x, int dest_y, int dest_w, int dest_h);
167
168 void DrawTiledImage(SkCanvas* canvas,
169 const SkBitmap& bitmap,
170 int src_x, int src_y,
171 double tile_scale_x, double tile_scale_y,
172 int dest_x, int dest_y, int w, int h) const;
173
174 SkColor SaturateAndBrighten(SkScalar* hsv,
175 SkScalar saturate_amount,
176 SkScalar brighten_amount) const;
177
178 private:
179 void DrawVertLine(SkCanvas* canvas,
180 int x,
181 int y1,
182 int y2,
183 const SkPaint& paint) const;
184 void DrawHorizLine(SkCanvas* canvas,
185 int x1,
186 int x2,
187 int y,
188 const SkPaint& paint) const;
189 void DrawBox(SkCanvas* canvas,
190 const gfx::Rect& rect,
191 const SkPaint& paint) const;
192 SkScalar Clamp(SkScalar value,
193 SkScalar min,
194 SkScalar max) const;
195 SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const;
196
197 static unsigned int scrollbar_width_;
198 static unsigned int button_length_;
199 static unsigned int thumb_inactive_color_;
200 static unsigned int thumb_active_color_;
201 static unsigned int track_color_;
202
203 DISALLOW_COPY_AND_ASSIGN(NativeThemeAndroid);
204 };
205
206 } // namespace gfx
207
208 #endif // UI_GFX_NATIVE_THEME_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698