| OLD | NEW |
| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "skia/ext/platform_canvas.h" | 11 #include "skia/ext/platform_canvas.h" |
| 11 #include "ui/native_theme/native_theme.h" | 12 #include "ui/native_theme/native_theme.h" |
| 12 | 13 |
| 13 namespace gfx { | 14 namespace gfx { |
| 15 class Canvas; |
| 14 class ImageSkia; | 16 class ImageSkia; |
| 15 class Rect; | 17 class Rect; |
| 16 class Size; | 18 class Size; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace ui { | 21 namespace ui { |
| 20 | 22 |
| 21 // Theme support for non-Windows toolkits. | 23 // Theme support for non-Windows toolkits. |
| 22 class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme { | 24 class NATIVE_THEME_EXPORT NativeThemeBase : public NativeTheme { |
| 23 public: | 25 public: |
| 24 // NativeTheme implementation: | 26 // NativeTheme implementation: |
| 25 virtual gfx::Size GetPartSize(Part part, | 27 virtual gfx::Size GetPartSize(Part part, |
| 26 State state, | 28 State state, |
| 27 const ExtraParams& extra) const OVERRIDE; | 29 const ExtraParams& extra) const OVERRIDE; |
| 28 virtual void Paint(SkCanvas* canvas, | 30 virtual void Paint(SkCanvas* canvas, |
| 29 Part part, | 31 Part part, |
| 30 State state, | 32 State state, |
| 31 const gfx::Rect& rect, | 33 const gfx::Rect& rect, |
| 32 const ExtraParams& extra) const OVERRIDE; | 34 const ExtraParams& extra) const OVERRIDE; |
| 33 | 35 |
| 34 protected: | 36 protected: |
| 35 NativeThemeBase(); | 37 NativeThemeBase(); |
| 36 virtual ~NativeThemeBase(); | 38 virtual ~NativeThemeBase(); |
| 37 | 39 |
| 40 // Creates a gfx::Canvas wrapping an SkCanvas. |
| 41 static scoped_ptr<gfx::Canvas> CreateCanvas(SkCanvas* sk_canvas); |
| 42 |
| 38 // Draw the arrow. Used by scrollbar and inner spin button. | 43 // Draw the arrow. Used by scrollbar and inner spin button. |
| 39 virtual void PaintArrowButton( | 44 virtual void PaintArrowButton( |
| 40 SkCanvas* gc, | 45 SkCanvas* gc, |
| 41 const gfx::Rect& rect, | 46 const gfx::Rect& rect, |
| 42 Part direction, | 47 Part direction, |
| 43 State state) const; | 48 State state) const; |
| 44 // Paint the scrollbar track. Done before the thumb so that it can contain | 49 // Paint the scrollbar track. Done before the thumb so that it can contain |
| 45 // alpha. | 50 // alpha. |
| 46 virtual void PaintScrollbarTrack( | 51 virtual void PaintScrollbarTrack( |
| 47 SkCanvas* canvas, | 52 SkCanvas* canvas, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 State state, | 119 State state, |
| 115 const gfx::Rect& rect, | 120 const gfx::Rect& rect, |
| 116 const InnerSpinButtonExtraParams& spin_button) const; | 121 const InnerSpinButtonExtraParams& spin_button) const; |
| 117 | 122 |
| 118 virtual void PaintProgressBar( | 123 virtual void PaintProgressBar( |
| 119 SkCanvas* canvas, | 124 SkCanvas* canvas, |
| 120 State state, | 125 State state, |
| 121 const gfx::Rect& rect, | 126 const gfx::Rect& rect, |
| 122 const ProgressBarExtraParams& progress_bar) const; | 127 const ProgressBarExtraParams& progress_bar) const; |
| 123 | 128 |
| 124 protected: | |
| 125 void set_scrollbar_button_length(unsigned int length) { | 129 void set_scrollbar_button_length(unsigned int length) { |
| 126 scrollbar_button_length_ = length; | 130 scrollbar_button_length_ = length; |
| 127 } | 131 } |
| 128 | 132 |
| 129 bool IntersectsClipRectInt(SkCanvas* canvas, | 133 bool IntersectsClipRectInt(SkCanvas* canvas, |
| 130 int x, int y, int w, int h) const; | 134 int x, int y, int w, int h) const; |
| 131 | 135 |
| 132 void DrawImageInt(SkCanvas* canvas, const gfx::ImageSkia& image, | 136 void DrawImageInt(SkCanvas* canvas, const gfx::ImageSkia& image, |
| 133 int src_x, int src_y, int src_w, int src_h, | 137 int src_x, int src_y, int src_w, int src_h, |
| 134 int dest_x, int dest_y, int dest_w, int dest_h) const; | 138 int dest_x, int dest_y, int dest_w, int dest_h) const; |
| 135 | 139 |
| 136 void DrawTiledImage(SkCanvas* canvas, | 140 void DrawTiledImage(SkCanvas* canvas, |
| 137 const gfx::ImageSkia& image, | 141 const gfx::ImageSkia& image, |
| 138 int src_x, int src_y, | 142 int src_x, int src_y, |
| 139 float tile_scale_x, float tile_scale_y, | 143 float tile_scale_x, float tile_scale_y, |
| 140 int dest_x, int dest_y, int w, int h) const; | 144 int dest_x, int dest_y, int w, int h) const; |
| 141 | 145 |
| 142 SkColor SaturateAndBrighten(SkScalar* hsv, | 146 SkColor SaturateAndBrighten(SkScalar* hsv, |
| 143 SkScalar saturate_amount, | 147 SkScalar saturate_amount, |
| 144 SkScalar brighten_amount) const; | 148 SkScalar brighten_amount) const; |
| 149 |
| 150 // Paints the arrow used on the scrollbar and spinner. |
| 151 void PaintArrow(SkCanvas* canvas, |
| 152 const gfx::Rect& rect, |
| 153 Part direction, |
| 154 SkColor color) const; |
| 155 |
| 156 // Returns the color used to draw the arrow. |
| 157 SkColor GetArrowColor(State state) const; |
| 158 |
| 145 private: | 159 private: |
| 146 void DrawVertLine(SkCanvas* canvas, | 160 void DrawVertLine(SkCanvas* canvas, |
| 147 int x, | 161 int x, |
| 148 int y1, | 162 int y1, |
| 149 int y2, | 163 int y2, |
| 150 const SkPaint& paint) const; | 164 const SkPaint& paint) const; |
| 151 void DrawHorizLine(SkCanvas* canvas, | 165 void DrawHorizLine(SkCanvas* canvas, |
| 152 int x1, | 166 int x1, |
| 153 int x2, | 167 int x2, |
| 154 int y, | 168 int y, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 171 | 185 |
| 172 unsigned int scrollbar_width_; | 186 unsigned int scrollbar_width_; |
| 173 unsigned int scrollbar_button_length_; | 187 unsigned int scrollbar_button_length_; |
| 174 | 188 |
| 175 DISALLOW_COPY_AND_ASSIGN(NativeThemeBase); | 189 DISALLOW_COPY_AND_ASSIGN(NativeThemeBase); |
| 176 }; | 190 }; |
| 177 | 191 |
| 178 } // namespace ui | 192 } // namespace ui |
| 179 | 193 |
| 180 #endif // UI_NATIVE_THEME_NATIVE_THEME_BASE_H_ | 194 #endif // UI_NATIVE_THEME_NATIVE_THEME_BASE_H_ |
| OLD | NEW |