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

Side by Side Diff: gfx/native_theme_linux.h

Issue 6246027: Move src/gfx/ to src/ui/gfx... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months 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 | « gfx/insets_unittest.cc ('k') | gfx/native_theme_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GFX_NATIVE_THEME_LINUX_H_ 5 #ifndef GFX_NATIVE_THEME_LINUX_H_
6 #define GFX_NATIVE_THEME_LINUX_H_ 6 #define GFX_NATIVE_THEME_LINUX_H_
7 7
8 #include "base/basictypes.h" 8 #include "ui/gfx/native_theme_linux.h"
9 #include "skia/ext/platform_canvas.h" 9 // TODO(sail): remove this file once all includes have been updated.
10
11 namespace skia {
12 class PlatformCanvas;
13 }
14
15 namespace gfx {
16 class Rect;
17 class Size;
18
19 // Linux theming API.
20 class NativeThemeLinux {
21 public:
22 // The part to be painted / sized.
23 enum Part {
24 kScrollbarDownArrow,
25 kScrollbarLeftArrow,
26 kScrollbarRightArrow,
27 kScrollbarUpArrow,
28 kScrollbarHorizontalThumb,
29 kScrollbarVerticalThumb,
30 kScrollbarHorizontalTrack,
31 kScrollbarVerticalTrack,
32 kCheckbox,
33 kRadio,
34 kPushButton,
35 kTextField,
36 kMenuList,
37 kSliderTrack,
38 kSliderThumb,
39 kInnerSpinButton,
40 kProgressBar,
41 };
42
43 // The state of the part.
44 enum State {
45 kDisabled,
46 kHovered,
47 kNormal,
48 kPressed,
49 };
50
51 // Extra data needed to draw scrollbar track correctly.
52 struct ScrollbarTrackExtraParams {
53 int track_x;
54 int track_y;
55 int track_width;
56 int track_height;
57 };
58
59 struct ButtonExtraParams {
60 bool checked;
61 bool indeterminate; // Whether the button state is indeterminate.
62 bool is_default; // Whether the button is default button.
63 SkColor background_color;
64 };
65
66 struct TextFieldExtraParams {
67 bool is_text_area;
68 bool is_listbox;
69 SkColor background_color;
70 };
71
72 struct MenuListExtraParams {
73 int arrow_x;
74 int arrow_y;
75 SkColor background_color;
76 };
77
78 struct SliderExtraParams {
79 bool vertical;
80 bool in_drag;
81 };
82
83 struct InnerSpinButtonExtraParams {
84 bool spin_up;
85 bool read_only;
86 };
87
88 struct ProgressBarExtraParams {
89 bool determinate;
90 int value_rect_x;
91 int value_rect_y;
92 int value_rect_width;
93 int value_rect_height;
94 };
95
96 union ExtraParams {
97 ScrollbarTrackExtraParams scrollbar_track;
98 ButtonExtraParams button;
99 MenuListExtraParams menu_list;
100 SliderExtraParams slider;
101 TextFieldExtraParams text_field;
102 InnerSpinButtonExtraParams inner_spin;
103 ProgressBarExtraParams progress_bar;
104 };
105
106 // Gets our singleton instance.
107 static NativeThemeLinux* instance();
108
109 // Return the size of the part.
110 virtual gfx::Size GetPartSize(Part part) const;
111 // Paint the part to the canvas.
112 virtual void Paint(skia::PlatformCanvas* canvas,
113 Part part,
114 State state,
115 const gfx::Rect& rect,
116 const ExtraParams& extra);
117 // Supports theme specific colors.
118 void SetScrollbarColors(unsigned inactive_color,
119 unsigned active_color,
120 unsigned track_color) const;
121
122 protected:
123 NativeThemeLinux();
124 virtual ~NativeThemeLinux();
125
126 // Draw the arrow. Used by scrollbar and inner spin button.
127 virtual void PaintArrowButton(
128 skia::PlatformCanvas* gc,
129 const gfx::Rect& rect,
130 Part direction,
131 State state);
132 // Paint the scrollbar track. Done before the thumb so that it can contain
133 // alpha.
134 virtual void PaintScrollbarTrack(skia::PlatformCanvas* canvas,
135 Part part,
136 State state,
137 const ScrollbarTrackExtraParams& extra_params,
138 const gfx::Rect& rect);
139 // Draw the scrollbar thumb over the track.
140 virtual void PaintScrollbarThumb(skia::PlatformCanvas* canvas,
141 Part part,
142 State state,
143 const gfx::Rect& rect);
144 // Draw the checkbox.
145 virtual void PaintCheckbox(skia::PlatformCanvas* canvas,
146 State state,
147 const gfx::Rect& rect,
148 const ButtonExtraParams& button);
149 // Draw the radio.
150 virtual void PaintRadio(skia::PlatformCanvas* canvas,
151 State state,
152 const gfx::Rect& rect,
153 const ButtonExtraParams& button);
154 // Draw the push button.
155 virtual void PaintButton(skia::PlatformCanvas* canvas,
156 State state,
157 const gfx::Rect& rect,
158 const ButtonExtraParams& button);
159 // Draw the text field.
160 virtual void PaintTextField(skia::PlatformCanvas* canvas,
161 State state,
162 const gfx::Rect& rect,
163 const TextFieldExtraParams& text);
164 // Draw the menu list.
165 virtual void PaintMenuList(skia::PlatformCanvas* canvas,
166 State state,
167 const gfx::Rect& rect,
168 const MenuListExtraParams& menu_list);
169 // Draw the slider track.
170 virtual void PaintSliderTrack(skia::PlatformCanvas* canvas,
171 State state,
172 const gfx::Rect& rect,
173 const SliderExtraParams& slider);
174 // Draw the slider thumb.
175 virtual void PaintSliderThumb(skia::PlatformCanvas* canvas,
176 State state,
177 const gfx::Rect& rect,
178 const SliderExtraParams& slider);
179 // Draw the inner spin button.
180 virtual void PaintInnerSpinButton(skia::PlatformCanvas* canvas,
181 State state,
182 const gfx::Rect& rect,
183 const InnerSpinButtonExtraParams& spin_button);
184 // Draw the progress bar.
185 virtual void PaintProgressBar(skia::PlatformCanvas* canvas,
186 State state,
187 const gfx::Rect& rect,
188 const ProgressBarExtraParams& progress_bar);
189
190 protected:
191 bool IntersectsClipRectInt(skia::PlatformCanvas* canvas,
192 int x, int y, int w, int h);
193
194 void DrawBitmapInt(skia::PlatformCanvas* canvas, const SkBitmap& bitmap,
195 int src_x, int src_y, int src_w, int src_h,
196 int dest_x, int dest_y, int dest_w, int dest_h);
197
198 void DrawTiledImage(SkCanvas* canvas,
199 const SkBitmap& bitmap,
200 int src_x, int src_y,
201 double tile_scale_x, double tile_scale_y,
202 int dest_x, int dest_y, int w, int h) const;
203
204 SkColor SaturateAndBrighten(SkScalar* hsv,
205 SkScalar saturate_amount,
206 SkScalar brighten_amount) const;
207
208 private:
209 void DrawVertLine(SkCanvas* canvas,
210 int x,
211 int y1,
212 int y2,
213 const SkPaint& paint) const;
214 void DrawHorizLine(SkCanvas* canvas,
215 int x1,
216 int x2,
217 int y,
218 const SkPaint& paint) const;
219 void DrawBox(SkCanvas* canvas,
220 const gfx::Rect& rect,
221 const SkPaint& paint) const;
222 SkScalar Clamp(SkScalar value,
223 SkScalar min,
224 SkScalar max) const;
225 SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const;
226
227 static unsigned int scrollbar_width_;
228 static unsigned int button_length_;
229 static unsigned int thumb_inactive_color_;
230 static unsigned int thumb_active_color_;
231 static unsigned int track_color_;
232
233 DISALLOW_COPY_AND_ASSIGN(NativeThemeLinux);
234 };
235
236 } // namespace gfx
237 10
238 #endif // GFX_NATIVE_THEME_LINUX_H_ 11 #endif // GFX_NATIVE_THEME_LINUX_H_
OLDNEW
« no previous file with comments | « gfx/insets_unittest.cc ('k') | gfx/native_theme_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698