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 14 matching lines...) Expand all Loading... |
25 class View; | 25 class View; |
26 class Widget; | 26 class Widget; |
27 } | 27 } |
28 | 28 |
29 namespace ash { | 29 namespace ash { |
30 class FrameCaptionButtonContainerView; | 30 class FrameCaptionButtonContainerView; |
31 | 31 |
32 // Helper class for painting the window header. | 32 // Helper class for painting the window header. |
33 class ASH_EXPORT HeaderPainter : public gfx::AnimationDelegate { | 33 class ASH_EXPORT HeaderPainter : public gfx::AnimationDelegate { |
34 public: | 34 public: |
| 35 enum Mode { |
| 36 MODE_ACTIVE, |
| 37 MODE_INACTIVE |
| 38 }; |
| 39 |
35 // TODO(pkotwicz): Move code related to "browser" windows out of ash. | 40 // TODO(pkotwicz): Move code related to "browser" windows out of ash. |
36 enum Style { | 41 enum Style { |
37 // Header style used for browser windows. | 42 // Header style used for browser windows. |
38 STYLE_BROWSER, | 43 STYLE_BROWSER, |
39 | 44 |
40 // Header style used for apps and miscellaneous windows (e.g. task manager). | 45 // Header style used for apps and miscellaneous windows (e.g. task manager). |
41 STYLE_OTHER | 46 STYLE_OTHER |
42 }; | 47 }; |
43 | 48 |
44 HeaderPainter(); | 49 HeaderPainter(); |
(...skipping 30 matching lines...) Expand all Loading... |
75 int GetMinimumHeaderWidth() const; | 80 int GetMinimumHeaderWidth() const; |
76 | 81 |
77 // Returns the inset from the right edge. | 82 // Returns the inset from the right edge. |
78 int GetRightInset() const; | 83 int GetRightInset() const; |
79 | 84 |
80 // Returns the amount that the theme background should be inset. | 85 // Returns the amount that the theme background should be inset. |
81 int GetThemeBackgroundXInset() const; | 86 int GetThemeBackgroundXInset() const; |
82 | 87 |
83 // Paints the header. | 88 // Paints the header. |
84 // |theme_frame_overlay_id| is 0 if no overlay image should be used. | 89 // |theme_frame_overlay_id| is 0 if no overlay image should be used. |
| 90 // |mode| indicates whether the window should be painted as active. |
85 void PaintHeader(gfx::Canvas* canvas, | 91 void PaintHeader(gfx::Canvas* canvas, |
| 92 Mode mode, |
86 int theme_frame_id, | 93 int theme_frame_id, |
87 int theme_frame_overlay_id); | 94 int theme_frame_overlay_id); |
88 | 95 |
89 // Paints the header/content separator line. Exists as a separate function | 96 // Paints the header/content separator line for non-browser windows. |
90 // because some windows with complex headers (e.g. browsers with tab strips) | 97 void PaintHeaderContentSeparator(gfx::Canvas* canvas, Mode mode); |
91 // need to draw their own line. | |
92 void PaintHeaderContentSeparator(gfx::Canvas* canvas); | |
93 | 98 |
94 // Returns size of the header/content separator line in pixels. | 99 // Returns size of the header/content separator line for non-browser windows |
| 100 // in pixels. |
95 int HeaderContentSeparatorSize() const; | 101 int HeaderContentSeparatorSize() const; |
96 | 102 |
97 // Paint the title bar, primarily the title string. | 103 // Paint the title bar, primarily the title string. |
98 void PaintTitleBar(gfx::Canvas* canvas, const gfx::FontList& title_font_list); | 104 void PaintTitleBar(gfx::Canvas* canvas, const gfx::FontList& title_font_list); |
99 | 105 |
100 // Performs layout for the header based on |frame_|'s show state. | 106 // Performs layout for the header based on |frame_|'s show state. |
101 void LayoutHeader(); | 107 void LayoutHeader(); |
102 | 108 |
103 // Sets the height of the header. The height of the header affects painting, | 109 // Sets the height of the header. The height of the header affects painting, |
104 // and non client hit tests. It does not affect layout. | 110 // and non client hit tests. It does not affect layout. |
(...skipping 11 matching lines...) Expand all Loading... |
116 | 122 |
117 // Called when the browser theme changes. | 123 // Called when the browser theme changes. |
118 void OnThemeChanged(); | 124 void OnThemeChanged(); |
119 | 125 |
120 // Overridden from gfx::AnimationDelegate | 126 // Overridden from gfx::AnimationDelegate |
121 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 127 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
122 | 128 |
123 private: | 129 private: |
124 FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, TitleIconAlignment); | 130 FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, TitleIconAlignment); |
125 | 131 |
| 132 // Paints the border around the header. |
| 133 void PaintBorder(gfx::Canvas* canvas, Mode mode); |
| 134 |
126 // Updates the images used for the minimize, restore and close buttons. | 135 // Updates the images used for the minimize, restore and close buttons. |
127 void UpdateCaptionButtonImages(); | 136 void UpdateCaptionButtonImages(); |
128 | 137 |
129 // Returns the header bounds in the coordinates of |header_view_|. The header | 138 // Returns the header bounds in the coordinates of |header_view_|. The header |
130 // is assumed to be positioned at the top left corner of |header_view_| and to | 139 // is assumed to be positioned at the top left corner of |header_view_| and to |
131 // have the same width as |header_view_|. | 140 // have the same width as |header_view_|. |
132 gfx::Rect GetHeaderLocalBounds() const; | 141 gfx::Rect GetHeaderLocalBounds() const; |
133 | 142 |
134 // Returns the offset between window left edge and title string. | 143 // Returns the offset between window left edge and title string. |
135 int GetTitleOffsetX() const; | 144 int GetTitleOffsetX() const; |
(...skipping 13 matching lines...) Expand all Loading... |
149 | 158 |
150 // Not owned | 159 // Not owned |
151 views::Widget* frame_; | 160 views::Widget* frame_; |
152 views::View* header_view_; | 161 views::View* header_view_; |
153 views::View* window_icon_; // May be NULL. | 162 views::View* window_icon_; // May be NULL. |
154 FrameCaptionButtonContainerView* caption_button_container_; | 163 FrameCaptionButtonContainerView* caption_button_container_; |
155 | 164 |
156 // The height of the header. | 165 // The height of the header. |
157 int header_height_; | 166 int header_height_; |
158 | 167 |
159 // Window frame header/caption parts. | |
160 const gfx::ImageSkia* top_left_corner_; | |
161 const gfx::ImageSkia* top_edge_; | |
162 const gfx::ImageSkia* top_right_corner_; | |
163 const gfx::ImageSkia* header_left_edge_; | |
164 const gfx::ImageSkia* header_right_edge_; | |
165 | |
166 // Image ids and opacity last used for painting header. | 168 // Image ids and opacity last used for painting header. |
167 int previous_theme_frame_id_; | 169 int previous_theme_frame_id_; |
168 int previous_theme_frame_overlay_id_; | 170 int previous_theme_frame_overlay_id_; |
169 | 171 |
170 // Image ids and opacity we are crossfading from. | 172 // Image ids and opacity we are crossfading from. |
171 int crossfade_theme_frame_id_; | 173 int crossfade_theme_frame_id_; |
172 int crossfade_theme_frame_overlay_id_; | 174 int crossfade_theme_frame_overlay_id_; |
173 | 175 |
174 scoped_ptr<gfx::SlideAnimation> crossfade_animation_; | 176 scoped_ptr<gfx::SlideAnimation> crossfade_animation_; |
175 | 177 |
176 DISALLOW_COPY_AND_ASSIGN(HeaderPainter); | 178 DISALLOW_COPY_AND_ASSIGN(HeaderPainter); |
177 }; | 179 }; |
178 | 180 |
179 } // namespace ash | 181 } // namespace ash |
180 | 182 |
181 #endif // ASH_WM_HEADER_PAINTER_H_ | 183 #endif // ASH_WM_HEADER_PAINTER_H_ |
OLD | NEW |