OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 ASH_WM_HEADER_PAINTER_H_ | 5 #ifndef ASH_WM_HEADER_PAINTER_H_ |
6 #define ASH_WM_HEADER_PAINTER_H_ | 6 #define ASH_WM_HEADER_PAINTER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" // OVERRIDE | 10 #include "base/compiler_specific.h" // OVERRIDE |
(...skipping 19 matching lines...) Expand all Loading... |
30 class Widget; | 30 class Widget; |
31 } | 31 } |
32 | 32 |
33 namespace ash { | 33 namespace ash { |
34 class FrameCaptionButtonContainerView; | 34 class FrameCaptionButtonContainerView; |
35 | 35 |
36 // Helper class for painting the window header. | 36 // Helper class for painting the window header. |
37 class ASH_EXPORT HeaderPainter : public aura::WindowObserver, | 37 class ASH_EXPORT HeaderPainter : public aura::WindowObserver, |
38 public gfx::AnimationDelegate { | 38 public gfx::AnimationDelegate { |
39 public: | 39 public: |
40 // Opacity values for the window header in various states, from 0 to 255. | |
41 static int kActiveWindowOpacity; | |
42 static int kInactiveWindowOpacity; | |
43 static int kSoloWindowOpacity; | |
44 | |
45 enum HeaderMode { | |
46 ACTIVE, | |
47 INACTIVE | |
48 }; | |
49 | |
50 HeaderPainter(); | 40 HeaderPainter(); |
51 virtual ~HeaderPainter(); | 41 virtual ~HeaderPainter(); |
52 | 42 |
53 // None of the parameters are owned. | 43 // None of the parameters are owned. |
54 void Init(views::Widget* frame, | 44 void Init(views::Widget* frame, |
55 views::View* header_view, | 45 views::View* header_view, |
56 views::View* window_icon, | 46 views::View* window_icon, |
57 FrameCaptionButtonContainerView* caption_button_container); | 47 FrameCaptionButtonContainerView* caption_button_container); |
58 | 48 |
59 // Returns the bounds of the client view for a window with |header_height| | 49 // Returns the bounds of the client view for a window with |header_height| |
(...skipping 21 matching lines...) Expand all Loading... |
81 | 71 |
82 // Returns the inset from the right edge. | 72 // Returns the inset from the right edge. |
83 int GetRightInset() const; | 73 int GetRightInset() const; |
84 | 74 |
85 // Returns the amount that the theme background should be inset. | 75 // Returns the amount that the theme background should be inset. |
86 int GetThemeBackgroundXInset() const; | 76 int GetThemeBackgroundXInset() const; |
87 | 77 |
88 // Paints the header. | 78 // Paints the header. |
89 // |theme_frame_overlay_id| is 0 if no overlay image should be used. | 79 // |theme_frame_overlay_id| is 0 if no overlay image should be used. |
90 void PaintHeader(gfx::Canvas* canvas, | 80 void PaintHeader(gfx::Canvas* canvas, |
91 HeaderMode header_mode, | |
92 int theme_frame_id, | 81 int theme_frame_id, |
93 int theme_frame_overlay_id); | 82 int theme_frame_overlay_id); |
94 | 83 |
95 // Paints the header/content separator line. Exists as a separate function | 84 // Paints the header/content separator line. Exists as a separate function |
96 // because some windows with complex headers (e.g. browsers with tab strips) | 85 // because some windows with complex headers (e.g. browsers with tab strips) |
97 // need to draw their own line. | 86 // need to draw their own line. |
98 void PaintHeaderContentSeparator(gfx::Canvas* canvas); | 87 void PaintHeaderContentSeparator(gfx::Canvas* canvas); |
99 | 88 |
100 // Returns size of the header/content separator line in pixels. | 89 // Returns size of the header/content separator line in pixels. |
101 int HeaderContentSeparatorSize() const; | 90 int HeaderContentSeparatorSize() const; |
(...skipping 26 matching lines...) Expand all Loading... |
128 // aura::WindowObserver overrides: | 117 // aura::WindowObserver overrides: |
129 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 118 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
130 virtual void OnWindowBoundsChanged(aura::Window* window, | 119 virtual void OnWindowBoundsChanged(aura::Window* window, |
131 const gfx::Rect& old_bounds, | 120 const gfx::Rect& old_bounds, |
132 const gfx::Rect& new_bounds) OVERRIDE; | 121 const gfx::Rect& new_bounds) OVERRIDE; |
133 | 122 |
134 // Overridden from gfx::AnimationDelegate | 123 // Overridden from gfx::AnimationDelegate |
135 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 124 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
136 | 125 |
137 private: | 126 private: |
138 FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, GetHeaderOpacity); | |
139 FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, TitleIconAlignment); | 127 FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, TitleIconAlignment); |
140 | 128 |
141 // Returns the header bounds in the coordinates of |header_view_|. The header | 129 // Returns the header bounds in the coordinates of |header_view_|. The header |
142 // is assumed to be positioned at the top left corner of |header_view_| and to | 130 // is assumed to be positioned at the top left corner of |header_view_| and to |
143 // have the same width as |header_view_|. | 131 // have the same width as |header_view_|. |
144 gfx::Rect GetHeaderLocalBounds() const; | 132 gfx::Rect GetHeaderLocalBounds() const; |
145 | 133 |
146 // Returns the offset between window left edge and title string. | 134 // Returns the offset between window left edge and title string. |
147 int GetTitleOffsetX() const; | 135 int GetTitleOffsetX() const; |
148 | 136 |
149 // Returns the vertical center of the caption button container in window | 137 // Returns the vertical center of the caption button container in window |
150 // coordinates. | 138 // coordinates. |
151 int GetCaptionButtonContainerCenterY() const; | 139 int GetCaptionButtonContainerCenterY() const; |
152 | 140 |
153 // Returns the opacity value used to paint the header. | |
154 // |theme_frame_overlay_id| is 0 if no overlay image is used. | |
155 int GetHeaderOpacity(HeaderMode header_mode, | |
156 int theme_frame_id, | |
157 int theme_frame_overlay_id) const; | |
158 | |
159 // Returns the radius of the header's top corners. | 141 // Returns the radius of the header's top corners. |
160 int GetHeaderCornerRadius() const; | 142 int GetHeaderCornerRadius() const; |
161 | 143 |
162 // Schedules a paint for the header. Used when transitioning from no header to | 144 // Schedules a paint for the header. Used when transitioning from no header to |
163 // a header (or other way around). | 145 // a header (or other way around). |
164 void SchedulePaintForHeader(); | 146 void SchedulePaintForHeader(); |
165 | 147 |
166 // Get the bounds for the title. The provided |title_font| is used to | 148 // Get the bounds for the title. The provided |title_font| is used to |
167 // determine the correct dimensions. | 149 // determine the correct dimensions. |
168 gfx::Rect GetTitleBounds(const gfx::Font& title_font); | 150 gfx::Rect GetTitleBounds(const gfx::Font& title_font); |
(...skipping 11 matching lines...) Expand all Loading... |
180 // Window frame header/caption parts. | 162 // Window frame header/caption parts. |
181 const gfx::ImageSkia* top_left_corner_; | 163 const gfx::ImageSkia* top_left_corner_; |
182 const gfx::ImageSkia* top_edge_; | 164 const gfx::ImageSkia* top_edge_; |
183 const gfx::ImageSkia* top_right_corner_; | 165 const gfx::ImageSkia* top_right_corner_; |
184 const gfx::ImageSkia* header_left_edge_; | 166 const gfx::ImageSkia* header_left_edge_; |
185 const gfx::ImageSkia* header_right_edge_; | 167 const gfx::ImageSkia* header_right_edge_; |
186 | 168 |
187 // Image ids and opacity last used for painting header. | 169 // Image ids and opacity last used for painting header. |
188 int previous_theme_frame_id_; | 170 int previous_theme_frame_id_; |
189 int previous_theme_frame_overlay_id_; | 171 int previous_theme_frame_overlay_id_; |
190 int previous_opacity_; | |
191 | 172 |
192 // Image ids and opacity we are crossfading from. | 173 // Image ids and opacity we are crossfading from. |
193 int crossfade_theme_frame_id_; | 174 int crossfade_theme_frame_id_; |
194 int crossfade_theme_frame_overlay_id_; | 175 int crossfade_theme_frame_overlay_id_; |
195 int crossfade_opacity_; | |
196 | 176 |
197 scoped_ptr<gfx::SlideAnimation> crossfade_animation_; | 177 scoped_ptr<gfx::SlideAnimation> crossfade_animation_; |
198 | 178 |
199 DISALLOW_COPY_AND_ASSIGN(HeaderPainter); | 179 DISALLOW_COPY_AND_ASSIGN(HeaderPainter); |
200 }; | 180 }; |
201 | 181 |
202 } // namespace ash | 182 } // namespace ash |
203 | 183 |
204 #endif // ASH_WM_HEADER_PAINTER_H_ | 184 #endif // ASH_WM_HEADER_PAINTER_H_ |
OLD | NEW |