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

Side by Side Diff: gfx/native_theme_linux.h

Issue 6254004: Move more web widgets painting from webkit to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for tony's comments #1 Created 9 years, 11 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
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 "base/basictypes.h"
9 #include "skia/ext/platform_canvas.h" 9 #include "skia/ext/platform_canvas.h"
10 10
(...skipping 10 matching lines...) Expand all
21 public: 21 public:
22 // The part to be painted / sized. 22 // The part to be painted / sized.
23 enum Part { 23 enum Part {
24 kScrollbarDownArrow, 24 kScrollbarDownArrow,
25 kScrollbarLeftArrow, 25 kScrollbarLeftArrow,
26 kScrollbarRightArrow, 26 kScrollbarRightArrow,
27 kScrollbarUpArrow, 27 kScrollbarUpArrow,
28 kScrollbarHorizontalThumb, 28 kScrollbarHorizontalThumb,
29 kScrollbarVerticalThumb, 29 kScrollbarVerticalThumb,
30 kScrollbarHorizontalTrack, 30 kScrollbarHorizontalTrack,
31 kScrollbarVerticalTrack 31 kScrollbarVerticalTrack,
32 kCheckbox,
33 kRadio,
34 kPushButton,
35 kTextField,
36 kMenuList,
37 kSliderTrack,
38 kSliderThumb,
39 kInnerSpinButton,
40 kProgressBar,
32 }; 41 };
33 42
34 // The state of the part. 43 // The state of the part.
35 enum State { 44 enum State {
36 kDisabled, 45 kDisabled,
37 kHover, 46 kHover,
38 kNormal, 47 kNormal,
39 kPressed, 48 kPressed,
40 }; 49 };
41 50
42 // Extra data needed to draw scrollbar track correctly. 51 // Extra data needed to draw scrollbar track correctly.
43 struct ScrollbarTrackExtraParams { 52 struct ScrollbarTrackExtraParams {
44 int track_x; 53 int track_x;
45 int track_y; 54 int track_y;
46 int track_width; 55 int track_width;
47 int track_height; 56 int track_height;
48 }; 57 };
49 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.
DaveMoore 2011/01/19 17:04:13 Nit: Line up the comments
xiyuan 2011/01/19 19:06:42 Done.
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
50 union ExtraParams { 96 union ExtraParams {
51 ScrollbarTrackExtraParams scrollbar_track; 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;
52 }; 104 };
53 105
54 // Gets our singleton instance. 106 // Gets our singleton instance.
55 static NativeThemeLinux* instance(); 107 static NativeThemeLinux* instance();
56 108
57 // Return the size of the part. 109 // Return the size of the part.
58 virtual gfx::Size GetSize(Part part) const; 110 virtual gfx::Size GetSize(Part part) const;
59 // Paint the part to the canvas. 111 // Paint the part to the canvas.
60 virtual void Paint(skia::PlatformCanvas* canvas, 112 virtual void Paint(skia::PlatformCanvas* canvas,
61 Part part, 113 Part part,
62 State state, 114 State state,
63 const gfx::Rect& rect, 115 const gfx::Rect& rect,
64 const ExtraParams& extra); 116 const ExtraParams& extra);
65 // Supports theme specific colors. 117 // Supports theme specific colors.
66 void SetScrollbarColors(unsigned inactive_color, 118 void SetScrollbarColors(unsigned inactive_color,
67 unsigned active_color, 119 unsigned active_color,
68 unsigned track_color) const; 120 unsigned track_color) const;
69 121
70 protected: 122 protected:
71 NativeThemeLinux(); 123 NativeThemeLinux();
72 virtual ~NativeThemeLinux(); 124 virtual ~NativeThemeLinux();
73 125
74 // Draw the arrow. 126 // Draw the arrow.
75 virtual void PaintArrowButton( 127 virtual void PaintArrowButton(
DaveMoore 2011/01/19 17:04:13 Now that there are other types drawn in this file
xiyuan 2011/01/19 19:06:42 Done.
76 skia::PlatformCanvas* gc, 128 skia::PlatformCanvas* gc,
77 const gfx::Rect& rect, 129 const gfx::Rect& rect,
78 Part direction, 130 Part direction,
79 State state); 131 State state);
80 // Paint the track. Done before the thumb so that it can contain alpha. 132 // Paint the track. Done before the thumb so that it can contain alpha.
81 virtual void PaintTrack(skia::PlatformCanvas* canvas, 133 virtual void PaintTrack(skia::PlatformCanvas* canvas,
82 Part part, 134 Part part,
DaveMoore 2011/01/19 17:04:13 Nit: The indenting of all the declarations is wron
xiyuan 2011/01/19 19:06:42 Done. I am using the 4-space indent since there ar
83 State state, 135 State state,
84 const ScrollbarTrackExtraParams& extra_params, 136 const ScrollbarTrackExtraParams& extra_params,
85 const gfx::Rect& rect); 137 const gfx::Rect& rect);
86 // Draw the thumb over the track. 138 // Draw the thumb over the track.
87 virtual void PaintThumb(skia::PlatformCanvas* canvas, 139 virtual void PaintThumb(skia::PlatformCanvas* canvas,
88 Part part, 140 Part part,
89 State state, 141 State state,
90 const gfx::Rect& rect); 142 const gfx::Rect& rect);
143 // Draw the checkbox.
144 virtual void PaintCheckbox(skia::PlatformCanvas* canvas,
145 State state,
146 const gfx::Rect& rect,
147 const ButtonExtraParams& button);
148 // Draw the radio.
149 virtual void PaintRadio(skia::PlatformCanvas* canvas,
150 State state,
151 const gfx::Rect& rect,
152 const ButtonExtraParams& button);
153 // Draw the push button.
154 virtual void PaintButton(skia::PlatformCanvas* canvas,
155 State state,
156 const gfx::Rect& rect,
157 const ButtonExtraParams& button);
158 // Draw the text field.
159 virtual void PaintTextField(skia::PlatformCanvas* canvas,
160 State state,
161 const gfx::Rect& rect,
162 const TextFieldExtraParams& text);
163 // Draw the menu list.
164 virtual void PaintMenuList(skia::PlatformCanvas* canvas,
165 State state,
166 const gfx::Rect& rect,
167 const MenuListExtraParams& menu_list);
168 // Draw the slider track.
169 virtual void PaintSliderTrack(skia::PlatformCanvas* canvas,
170 State state,
171 const gfx::Rect& rect,
172 const SliderExtraParams& slider);
173 // Draw the slider thumb.
174 virtual void PaintSliderThumb(skia::PlatformCanvas* canvas,
175 State state,
176 const gfx::Rect& rect,
177 const SliderExtraParams& slider);
178 // Draw the inner spin button.
179 virtual void PaintInnerSpinButton(skia::PlatformCanvas* canvas,
180 State state,
181 const gfx::Rect& rect,
182 const InnerSpinButtonExtraParams& spin_button);
183 // Draw the progress bar.
184 virtual void PaintProgressBar(skia::PlatformCanvas* canvas,
185 State state,
186 const gfx::Rect& rect,
187 const ProgressBarExtraParams& progress_bar);
188
189 protected:
190 void DrawTiledImage(SkCanvas* canvas,
191 const SkBitmap& bitmap,
192 int src_x, int src_y,
193 double tile_scale_x, double tile_scale_y,
194 int dest_x, int dest_y, int w, int h) const;
195
196 SkColor SaturateAndBrighten(SkScalar* hsv,
197 SkScalar saturate_amount,
198 SkScalar brighten_amount) const;
91 199
92 private: 200 private:
93 void DrawVertLine(SkCanvas* canvas, 201 void DrawVertLine(SkCanvas* canvas,
94 int x, 202 int x,
95 int y1, 203 int y1,
96 int y2, 204 int y2,
97 const SkPaint& paint) const; 205 const SkPaint& paint) const;
98 void DrawHorizLine(SkCanvas* canvas, 206 void DrawHorizLine(SkCanvas* canvas,
99 int x1, 207 int x1,
100 int x2, 208 int x2,
101 int y, 209 int y,
102 const SkPaint& paint) const; 210 const SkPaint& paint) const;
103 void DrawBox(SkCanvas* canvas, 211 void DrawBox(SkCanvas* canvas,
104 const gfx::Rect& rect, 212 const gfx::Rect& rect,
105 const SkPaint& paint) const; 213 const SkPaint& paint) const;
106 SkScalar Clamp(SkScalar value, 214 SkScalar Clamp(SkScalar value,
107 SkScalar min, 215 SkScalar min,
108 SkScalar max) const; 216 SkScalar max) const;
109 SkColor SaturateAndBrighten(SkScalar* hsv,
110 SkScalar saturate_amount,
111 SkScalar brighten_amount) const;
112 SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const; 217 SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const;
113 218
114 static unsigned int scrollbar_width_; 219 static unsigned int scrollbar_width_;
115 static unsigned int button_length_; 220 static unsigned int button_length_;
116 static unsigned int thumb_inactive_color_; 221 static unsigned int thumb_inactive_color_;
117 static unsigned int thumb_active_color_; 222 static unsigned int thumb_active_color_;
118 static unsigned int track_color_; 223 static unsigned int track_color_;
119 224
120 DISALLOW_COPY_AND_ASSIGN(NativeThemeLinux); 225 DISALLOW_COPY_AND_ASSIGN(NativeThemeLinux);
121 }; 226 };
122 227
123 } // namespace gfx 228 } // namespace gfx
124 229
125 #endif // GFX_NATIVE_THEME_LINUX_H_ 230 #endif // GFX_NATIVE_THEME_LINUX_H_
OLDNEW
« no previous file with comments | « gfx/gfx_resources.grd ('k') | gfx/native_theme_linux.cc » ('j') | gfx/native_theme_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698