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