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

Side by Side Diff: ui/native_theme/native_theme_base.h

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 3 years, 12 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
« no previous file with comments | « ui/native_theme/native_theme_aura.cc ('k') | ui/native_theme/native_theme_base.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_NATIVE_THEME_NATIVE_THEME_BASE_H_ 5 #ifndef UI_NATIVE_THEME_NATIVE_THEME_BASE_H_
6 #define UI_NATIVE_THEME_NATIVE_THEME_BASE_H_ 6 #define UI_NATIVE_THEME_NATIVE_THEME_BASE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "skia/ext/platform_canvas.h" 13 #include "skia/ext/platform_canvas.h"
14 #include "ui/native_theme/native_theme.h" 14 #include "ui/native_theme/native_theme.h"
15 15
16 namespace gfx { 16 namespace gfx {
17 class Rect; 17 class Rect;
18 class Size; 18 class Size;
19 } 19 }
20 20
21 namespace ui { 21 namespace ui {
22 22
23 // Theme support for non-Windows toolkits. 23 // Theme support for non-Windows toolkits.
24 class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme { 24 class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme {
25 public: 25 public:
26 // NativeTheme implementation: 26 // NativeTheme implementation:
27 gfx::Size GetPartSize(Part part, 27 gfx::Size GetPartSize(Part part,
28 State state, 28 State state,
29 const ExtraParams& extra) const override; 29 const ExtraParams& extra) const override;
30 void Paint(SkCanvas* canvas, 30 void Paint(CdlCanvas* canvas,
31 Part part, 31 Part part,
32 State state, 32 State state,
33 const gfx::Rect& rect, 33 const gfx::Rect& rect,
34 const ExtraParams& extra) const override; 34 const ExtraParams& extra) const override;
35 35
36 protected: 36 protected:
37 NativeThemeBase(); 37 NativeThemeBase();
38 ~NativeThemeBase() override; 38 ~NativeThemeBase() override;
39 39
40 // Draw the arrow. Used by scrollbar and inner spin button. 40 // Draw the arrow. Used by scrollbar and inner spin button.
41 virtual void PaintArrowButton( 41 virtual void PaintArrowButton(CdlCanvas* gc,
42 SkCanvas* gc, 42 const gfx::Rect& rect,
43 const gfx::Rect& rect, 43 Part direction,
44 Part direction, 44 State state) const;
45 State state) const;
46 // Paint the scrollbar track. Done before the thumb so that it can contain 45 // Paint the scrollbar track. Done before the thumb so that it can contain
47 // alpha. 46 // alpha.
48 virtual void PaintScrollbarTrack( 47 virtual void PaintScrollbarTrack(
49 SkCanvas* canvas, 48 CdlCanvas* canvas,
50 Part part, 49 Part part,
51 State state, 50 State state,
52 const ScrollbarTrackExtraParams& extra_params, 51 const ScrollbarTrackExtraParams& extra_params,
53 const gfx::Rect& rect) const; 52 const gfx::Rect& rect) const;
54 // Draw the scrollbar thumb over the track. 53 // Draw the scrollbar thumb over the track.
55 virtual void PaintScrollbarThumb( 54 virtual void PaintScrollbarThumb(
56 SkCanvas* canvas, 55 CdlCanvas* canvas,
57 Part part, 56 Part part,
58 State state, 57 State state,
59 const gfx::Rect& rect, 58 const gfx::Rect& rect,
60 NativeTheme::ScrollbarOverlayColorTheme theme) const; 59 NativeTheme::ScrollbarOverlayColorTheme theme) const;
61 60
62 virtual void PaintScrollbarCorner(SkCanvas* canvas, 61 virtual void PaintScrollbarCorner(CdlCanvas* canvas,
63 State state, 62 State state,
64 const gfx::Rect& rect) const; 63 const gfx::Rect& rect) const;
65 64
66 virtual void PaintCheckbox( 65 virtual void PaintCheckbox(CdlCanvas* canvas,
67 SkCanvas* canvas, 66 State state,
68 State state, 67 const gfx::Rect& rect,
69 const gfx::Rect& rect, 68 const ButtonExtraParams& button) const;
70 const ButtonExtraParams& button) const;
71 69
72 virtual void PaintRadio( 70 virtual void PaintRadio(CdlCanvas* canvas,
73 SkCanvas* canvas, 71 State state,
74 State state, 72 const gfx::Rect& rect,
75 const gfx::Rect& rect, 73 const ButtonExtraParams& button) const;
76 const ButtonExtraParams& button) const;
77 74
78 virtual void PaintButton( 75 virtual void PaintButton(CdlCanvas* canvas,
79 SkCanvas* canvas, 76 State state,
80 State state, 77 const gfx::Rect& rect,
81 const gfx::Rect& rect, 78 const ButtonExtraParams& button) const;
82 const ButtonExtraParams& button) const;
83 79
84 virtual void PaintTextField( 80 virtual void PaintTextField(CdlCanvas* canvas,
85 SkCanvas* canvas, 81 State state,
86 State state, 82 const gfx::Rect& rect,
87 const gfx::Rect& rect, 83 const TextFieldExtraParams& text) const;
88 const TextFieldExtraParams& text) const;
89 84
90 virtual void PaintMenuList( 85 virtual void PaintMenuList(CdlCanvas* canvas,
91 SkCanvas* canvas, 86 State state,
92 State state, 87 const gfx::Rect& rect,
93 const gfx::Rect& rect, 88 const MenuListExtraParams& menu_list) const;
94 const MenuListExtraParams& menu_list) const;
95 89
96 virtual void PaintMenuPopupBackground( 90 virtual void PaintMenuPopupBackground(
97 SkCanvas* canvas, 91 CdlCanvas* canvas,
98 const gfx::Size& size, 92 const gfx::Size& size,
99 const MenuBackgroundExtraParams& menu_background) const; 93 const MenuBackgroundExtraParams& menu_background) const;
100 94
101 virtual void PaintMenuItemBackground( 95 virtual void PaintMenuItemBackground(
102 SkCanvas* canvas, 96 CdlCanvas* canvas,
103 State state, 97 State state,
104 const gfx::Rect& rect, 98 const gfx::Rect& rect,
105 const MenuItemExtraParams& menu_item) const; 99 const MenuItemExtraParams& menu_item) const;
106 100
107 virtual void PaintSliderTrack( 101 virtual void PaintSliderTrack(CdlCanvas* canvas,
108 SkCanvas* canvas, 102 State state,
109 State state, 103 const gfx::Rect& rect,
110 const gfx::Rect& rect, 104 const SliderExtraParams& slider) const;
111 const SliderExtraParams& slider) const;
112 105
113 virtual void PaintSliderThumb( 106 virtual void PaintSliderThumb(CdlCanvas* canvas,
114 SkCanvas* canvas, 107 State state,
115 State state, 108 const gfx::Rect& rect,
116 const gfx::Rect& rect, 109 const SliderExtraParams& slider) const;
117 const SliderExtraParams& slider) const;
118 110
119 virtual void PaintInnerSpinButton( 111 virtual void PaintInnerSpinButton(
120 SkCanvas* canvas, 112 CdlCanvas* canvas,
121 State state, 113 State state,
122 const gfx::Rect& rect, 114 const gfx::Rect& rect,
123 const InnerSpinButtonExtraParams& spin_button) const; 115 const InnerSpinButtonExtraParams& spin_button) const;
124 116
125 virtual void PaintProgressBar( 117 virtual void PaintProgressBar(
126 SkCanvas* canvas, 118 CdlCanvas* canvas,
127 State state, 119 State state,
128 const gfx::Rect& rect, 120 const gfx::Rect& rect,
129 const ProgressBarExtraParams& progress_bar) const; 121 const ProgressBarExtraParams& progress_bar) const;
130 122
131 // Shrinks checkbox/radio button rect, if necessary, to make room for padding 123 // Shrinks checkbox/radio button rect, if necessary, to make room for padding
132 // and drop shadow. 124 // and drop shadow.
133 // TODO(mohsen): This is needed because checkboxes/radio buttons on Android 125 // TODO(mohsen): This is needed because checkboxes/radio buttons on Android
134 // have different padding from those on desktop Chrome. Get rid of this when 126 // have different padding from those on desktop Chrome. Get rid of this when
135 // crbug.com/530746 is resolved. 127 // crbug.com/530746 is resolved.
136 virtual void AdjustCheckboxRadioRectForPadding(SkRect* rect) const; 128 virtual void AdjustCheckboxRadioRectForPadding(SkRect* rect) const;
137 129
138 void set_scrollbar_button_length(int length) { 130 void set_scrollbar_button_length(int length) {
139 scrollbar_button_length_ = length; 131 scrollbar_button_length_ = length;
140 } 132 }
141 int scrollbar_button_length() const { return scrollbar_button_length_; } 133 int scrollbar_button_length() const { return scrollbar_button_length_; }
142 134
143 SkColor SaturateAndBrighten(SkScalar* hsv, 135 SkColor SaturateAndBrighten(SkScalar* hsv,
144 SkScalar saturate_amount, 136 SkScalar saturate_amount,
145 SkScalar brighten_amount) const; 137 SkScalar brighten_amount) const;
146 138
147 // Paints the arrow used on the scrollbar and spinner. 139 // Paints the arrow used on the scrollbar and spinner.
148 void PaintArrow(SkCanvas* canvas, 140 void PaintArrow(CdlCanvas* canvas,
149 const gfx::Rect& rect, 141 const gfx::Rect& rect,
150 Part direction, 142 Part direction,
151 SkColor color) const; 143 SkColor color) const;
152 144
153 // Returns the color used to draw the arrow. 145 // Returns the color used to draw the arrow.
154 SkColor GetArrowColor(State state) const; 146 SkColor GetArrowColor(State state) const;
155 147
156 int scrollbar_width_; 148 int scrollbar_width_;
157 149
158 private: 150 private:
159 friend class NativeThemeAuraTest; 151 friend class NativeThemeAuraTest;
160 152
161 SkPath PathForArrow(const gfx::Rect& rect, Part direction) const; 153 SkPath PathForArrow(const gfx::Rect& rect, Part direction) const;
162 gfx::Rect BoundingRectForArrow(const gfx::Rect& rect) const; 154 gfx::Rect BoundingRectForArrow(const gfx::Rect& rect) const;
163 155
164 void DrawVertLine(SkCanvas* canvas, 156 void DrawVertLine(CdlCanvas* canvas,
165 int x, 157 int x,
166 int y1, 158 int y1,
167 int y2, 159 int y2,
168 const SkPaint& paint) const; 160 const CdlPaint& paint) const;
169 void DrawHorizLine(SkCanvas* canvas, 161 void DrawHorizLine(CdlCanvas* canvas,
170 int x1, 162 int x1,
171 int x2, 163 int x2,
172 int y, 164 int y,
173 const SkPaint& paint) const; 165 const CdlPaint& paint) const;
174 void DrawBox(SkCanvas* canvas, 166 void DrawBox(CdlCanvas* canvas,
175 const gfx::Rect& rect, 167 const gfx::Rect& rect,
176 const SkPaint& paint) const; 168 const CdlPaint& paint) const;
177 SkScalar Clamp(SkScalar value, 169 SkScalar Clamp(SkScalar value,
178 SkScalar min, 170 SkScalar min,
179 SkScalar max) const; 171 SkScalar max) const;
180 SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const; 172 SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const;
181 173
182 // Paint the common parts of the checkboxes and radio buttons. 174 // Paint the common parts of the checkboxes and radio buttons.
183 // borderRadius specifies how rounded the corners should be. 175 // borderRadius specifies how rounded the corners should be.
184 SkRect PaintCheckboxRadioCommon( 176 SkRect PaintCheckboxRadioCommon(CdlCanvas* canvas,
185 SkCanvas* canvas, 177 State state,
186 State state, 178 const gfx::Rect& rect,
187 const gfx::Rect& rect, 179 const SkScalar borderRadius) const;
188 const SkScalar borderRadius) const;
189 180
190 // The length of the arrow buttons, 0 means no buttons are drawn. 181 // The length of the arrow buttons, 0 means no buttons are drawn.
191 int scrollbar_button_length_; 182 int scrollbar_button_length_;
192 183
193 DISALLOW_COPY_AND_ASSIGN(NativeThemeBase); 184 DISALLOW_COPY_AND_ASSIGN(NativeThemeBase);
194 }; 185 };
195 186
196 } // namespace ui 187 } // namespace ui
197 188
198 #endif // UI_NATIVE_THEME_NATIVE_THEME_BASE_H_ 189 #endif // UI_NATIVE_THEME_NATIVE_THEME_BASE_H_
OLDNEW
« no previous file with comments | « ui/native_theme/native_theme_aura.cc ('k') | ui/native_theme/native_theme_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698