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_AURA_H_ | 5 #ifndef UI_NATIVE_THEME_NATIVE_THEME_AURA_H_ |
6 #define UI_NATIVE_THEME_NATIVE_THEME_AURA_H_ | 6 #define UI_NATIVE_THEME_NATIVE_THEME_AURA_H_ |
7 | 7 |
8 #include <stdint.h> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "base/macros.h" | 8 #include "base/macros.h" |
12 #include "ui/native_theme/native_theme_base.h" | 9 #include "ui/native_theme/native_theme_base.h" |
13 | 10 |
14 namespace gfx { | |
15 class NineImagePainter; | |
16 } | |
17 | |
18 namespace ui { | 11 namespace ui { |
19 | 12 |
20 // Aura implementation of native theme support. | 13 // Aura implementation of native theme support. |
21 class NATIVE_THEME_EXPORT NativeThemeAura : public NativeThemeBase { | 14 class NATIVE_THEME_EXPORT NativeThemeAura : public NativeThemeBase { |
22 public: | 15 public: |
23 static NativeThemeAura* instance(); | 16 static NativeThemeAura* instance(); |
24 | 17 |
25 protected: | 18 protected: |
26 NativeThemeAura(); | 19 NativeThemeAura(); |
27 ~NativeThemeAura() override; | 20 ~NativeThemeAura() override; |
28 | 21 |
29 // Overridden from NativeThemeBase: | 22 // Overridden from NativeThemeBase: |
30 SkColor GetSystemColor(ColorId color_id) const override; | 23 SkColor GetSystemColor(ColorId color_id) const override; |
31 void PaintMenuPopupBackground( | 24 void PaintMenuPopupBackground( |
32 SkCanvas* canvas, | 25 SkCanvas* canvas, |
33 const gfx::Size& size, | 26 const gfx::Size& size, |
34 const MenuBackgroundExtraParams& menu_background) const override; | 27 const MenuBackgroundExtraParams& menu_background) const override; |
35 void PaintMenuItemBackground( | 28 void PaintMenuItemBackground( |
36 SkCanvas* canvas, | 29 SkCanvas* canvas, |
37 State state, | 30 State state, |
38 const gfx::Rect& rect, | 31 const gfx::Rect& rect, |
39 const MenuListExtraParams& menu_list) const override; | 32 const MenuListExtraParams& menu_list) const override; |
40 void PaintArrowButton(SkCanvas* gc, | 33 void PaintArrowButton(SkCanvas* gc, |
41 const gfx::Rect& rect, | 34 const gfx::Rect& rect, |
42 Part direction, | 35 Part direction, |
43 State state) const override; | 36 State state) const override; |
44 void PaintScrollbarTrack(SkCanvas* sk_canvas, | 37 void PaintScrollbarTrack(SkCanvas* canvas, |
45 Part part, | 38 Part part, |
46 State state, | 39 State state, |
47 const ScrollbarTrackExtraParams& extra_params, | 40 const ScrollbarTrackExtraParams& extra_params, |
48 const gfx::Rect& rect) const override; | 41 const gfx::Rect& rect) const override; |
49 void PaintScrollbarThumb(SkCanvas* sk_canvas, | 42 void PaintScrollbarThumb(SkCanvas* canvas, |
50 Part part, | 43 Part part, |
51 State state, | 44 State state, |
52 const gfx::Rect& rect) const override; | 45 const gfx::Rect& rect) const override; |
53 void PaintScrollbarCorner(SkCanvas* canvas, | 46 void PaintScrollbarCorner(SkCanvas* canvas, |
54 State state, | 47 State state, |
55 const gfx::Rect& rect) const override; | 48 const gfx::Rect& rect) const override; |
56 | 49 |
57 void PaintScrollbarThumbStateTransition(SkCanvas* canvas, | 50 void PaintScrollbarThumbStateTransition(SkCanvas* canvas, |
| 51 Part part, |
58 State startState, | 52 State startState, |
59 State endState, | 53 State endState, |
60 double progress, | 54 double progress, |
61 const gfx::Rect& rect) const override; | 55 const gfx::Rect& rect) const override; |
62 | 56 |
63 // Returns the NineImagePainter used to paint the specified state, creating if | |
64 // necessary. If no image is provided for the specified state the normal state | |
65 // images are used. | |
66 gfx::NineImagePainter* GetOrCreatePainter( | |
67 const int image_ids[kNumStates][9], | |
68 State state, | |
69 scoped_ptr<gfx::NineImagePainter> painters[kNumStates]) const; | |
70 | |
71 // Paints |painter| into the canvas using |rect|. | |
72 void PaintPainter(gfx::NineImagePainter* painter, | |
73 SkCanvas* sk_canvas, | |
74 const gfx::Rect& rect) const; | |
75 | |
76 mutable scoped_ptr<gfx::NineImagePainter> scrollbar_track_painter_; | |
77 | |
78 mutable scoped_ptr<gfx::NineImagePainter> | |
79 scrollbar_thumb_painters_[kNumStates]; | |
80 | |
81 mutable scoped_ptr<gfx::NineImagePainter> | |
82 scrollbar_arrow_button_painters_[kNumStates]; | |
83 | |
84 private: | 57 private: |
85 struct DualPainter { | |
86 // For overlay scrollbar thumbs, fill and stroke are controlled separately, | |
87 // and each state is achieved by painting with different opacity. This | |
88 // struct bundles information of painter generated using assets and alpha | |
89 // value associated with each state, so that a DualPainter for overlay | |
90 // scrollbar thumb would only need state as input to paint correctly. | |
91 DualPainter(scoped_ptr<gfx::NineImagePainter> fill_painter, | |
92 const uint8_t fill_alphas[kNumStates], | |
93 scoped_ptr<gfx::NineImagePainter> stroke_painter, | |
94 const uint8_t stroke_alphas[kNumStates]); | |
95 ~DualPainter(); | |
96 | |
97 scoped_ptr<gfx::NineImagePainter> fill_painter; | |
98 const uint8_t* const fill_alphas; | |
99 scoped_ptr<gfx::NineImagePainter> stroke_painter; | |
100 const uint8_t* const stroke_alphas; | |
101 }; | |
102 | |
103 // Returns DualPainter from specific fill and stroke, creating if necessary. | |
104 scoped_ptr<DualPainter> CreateDualPainter( | |
105 const int fill_image_ids[9], | |
106 const uint8_t fill_alphas[kNumStates], | |
107 const int stroke_image_ids[9], | |
108 const uint8_t stroke_alphas[kNumStates]) const; | |
109 | |
110 // Paints |dualPainter| into the canvas using |rect| and specific alpha. | |
111 void PaintDualPainter(DualPainter* dual_painter, | |
112 SkCanvas* sk_canvas, | |
113 const gfx::Rect& rect, | |
114 State state) const; | |
115 | |
116 void PaintDualPainterTransition(DualPainter* dual_painter, | |
117 SkCanvas* sk_canvas, | |
118 const gfx::Rect& rect, | |
119 State startState, | |
120 State endState, | |
121 double progress) const; | |
122 | |
123 mutable scoped_ptr<DualPainter> scrollbar_overlay_thumb_painter_; | |
124 | |
125 DISALLOW_COPY_AND_ASSIGN(NativeThemeAura); | 58 DISALLOW_COPY_AND_ASSIGN(NativeThemeAura); |
126 }; | 59 }; |
127 | 60 |
128 } // namespace ui | 61 } // namespace ui |
129 | 62 |
130 #endif // UI_NATIVE_THEME_NATIVE_THEME_AURA_H_ | 63 #endif // UI_NATIVE_THEME_NATIVE_THEME_AURA_H_ |
OLD | NEW |