| 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 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/aura/window_observer.h" | |
| 14 #include "ui/gfx/animation/animation_delegate.h" | 13 #include "ui/gfx/animation/animation_delegate.h" |
| 15 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 16 | 15 |
| 17 namespace aura { | |
| 18 class Window; | |
| 19 } | |
| 20 namespace gfx { | 16 namespace gfx { |
| 21 class Canvas; | 17 class Canvas; |
| 22 class Font; | 18 class Font; |
| 23 class ImageSkia; | 19 class ImageSkia; |
| 24 class Point; | 20 class Point; |
| 25 class Size; | 21 class Size; |
| 26 class SlideAnimation; | 22 class SlideAnimation; |
| 27 } | 23 } |
| 28 namespace views { | 24 namespace views { |
| 29 class View; | 25 class View; |
| 30 class Widget; | 26 class Widget; |
| 31 } | 27 } |
| 32 | 28 |
| 33 namespace ash { | 29 namespace ash { |
| 34 class FrameCaptionButtonContainerView; | 30 class FrameCaptionButtonContainerView; |
| 35 | 31 |
| 36 // Helper class for painting the window header. | 32 // Helper class for painting the window header. |
| 37 class ASH_EXPORT HeaderPainter : public aura::WindowObserver, | 33 class ASH_EXPORT HeaderPainter : public gfx::AnimationDelegate { |
| 38 public gfx::AnimationDelegate { | |
| 39 public: | 34 public: |
| 40 HeaderPainter(); | 35 HeaderPainter(); |
| 41 virtual ~HeaderPainter(); | 36 virtual ~HeaderPainter(); |
| 42 | 37 |
| 43 // None of the parameters are owned. | 38 // None of the parameters are owned. |
| 44 void Init(views::Widget* frame, | 39 void Init(views::Widget* frame, |
| 45 views::View* header_view, | 40 views::View* header_view, |
| 46 views::View* window_icon, | 41 views::View* window_icon, |
| 47 FrameCaptionButtonContainerView* caption_button_container); | 42 FrameCaptionButtonContainerView* caption_button_container); |
| 48 | 43 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 int header_height() const { | 102 int header_height() const { |
| 108 return header_height_; | 103 return header_height_; |
| 109 } | 104 } |
| 110 | 105 |
| 111 // Schedule a re-paint of the entire title. | 106 // Schedule a re-paint of the entire title. |
| 112 void SchedulePaintForTitle(const gfx::Font& title_font); | 107 void SchedulePaintForTitle(const gfx::Font& title_font); |
| 113 | 108 |
| 114 // Called when the browser theme changes. | 109 // Called when the browser theme changes. |
| 115 void OnThemeChanged(); | 110 void OnThemeChanged(); |
| 116 | 111 |
| 117 // aura::WindowObserver overrides: | |
| 118 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | |
| 119 virtual void OnWindowBoundsChanged(aura::Window* window, | |
| 120 const gfx::Rect& old_bounds, | |
| 121 const gfx::Rect& new_bounds) OVERRIDE; | |
| 122 | |
| 123 // Overridden from gfx::AnimationDelegate | 112 // Overridden from gfx::AnimationDelegate |
| 124 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 113 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 125 | 114 |
| 126 private: | 115 private: |
| 127 FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, TitleIconAlignment); | 116 FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, TitleIconAlignment); |
| 128 | 117 |
| 129 // Returns the header bounds in the coordinates of |header_view_|. The header | 118 // 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 | 119 // is assumed to be positioned at the top left corner of |header_view_| and to |
| 131 // have the same width as |header_view_|. | 120 // have the same width as |header_view_|. |
| 132 gfx::Rect GetHeaderLocalBounds() const; | 121 gfx::Rect GetHeaderLocalBounds() const; |
| 133 | 122 |
| 134 // Returns the offset between window left edge and title string. | 123 // Returns the offset between window left edge and title string. |
| 135 int GetTitleOffsetX() const; | 124 int GetTitleOffsetX() const; |
| 136 | 125 |
| 137 // Returns the vertical center of the caption button container in window | 126 // Returns the vertical center of the caption button container in window |
| 138 // coordinates. | 127 // coordinates. |
| 139 int GetCaptionButtonContainerCenterY() const; | 128 int GetCaptionButtonContainerCenterY() const; |
| 140 | 129 |
| 141 // Returns the radius of the header's top corners. | 130 // Returns the radius of the header's top corners. |
| 142 int GetHeaderCornerRadius() const; | 131 int GetHeaderCornerRadius() const; |
| 143 | 132 |
| 144 // Schedules a paint for the header. Used when transitioning from no header to | |
| 145 // a header (or other way around). | |
| 146 void SchedulePaintForHeader(); | |
| 147 | |
| 148 // Get the bounds for the title. The provided |title_font| is used to | 133 // Get the bounds for the title. The provided |title_font| is used to |
| 149 // determine the correct dimensions. | 134 // determine the correct dimensions. |
| 150 gfx::Rect GetTitleBounds(const gfx::Font& title_font); | 135 gfx::Rect GetTitleBounds(const gfx::Font& title_font); |
| 151 | 136 |
| 152 // Not owned | 137 // Not owned |
| 153 views::Widget* frame_; | 138 views::Widget* frame_; |
| 154 views::View* header_view_; | 139 views::View* header_view_; |
| 155 views::View* window_icon_; // May be NULL. | 140 views::View* window_icon_; // May be NULL. |
| 156 FrameCaptionButtonContainerView* caption_button_container_; | 141 FrameCaptionButtonContainerView* caption_button_container_; |
| 157 aura::Window* window_; | |
| 158 | 142 |
| 159 // The height of the header. | 143 // The height of the header. |
| 160 int header_height_; | 144 int header_height_; |
| 161 | 145 |
| 162 // Window frame header/caption parts. | 146 // Window frame header/caption parts. |
| 163 const gfx::ImageSkia* top_left_corner_; | 147 const gfx::ImageSkia* top_left_corner_; |
| 164 const gfx::ImageSkia* top_edge_; | 148 const gfx::ImageSkia* top_edge_; |
| 165 const gfx::ImageSkia* top_right_corner_; | 149 const gfx::ImageSkia* top_right_corner_; |
| 166 const gfx::ImageSkia* header_left_edge_; | 150 const gfx::ImageSkia* header_left_edge_; |
| 167 const gfx::ImageSkia* header_right_edge_; | 151 const gfx::ImageSkia* header_right_edge_; |
| 168 | 152 |
| 169 // Image ids and opacity last used for painting header. | 153 // Image ids and opacity last used for painting header. |
| 170 int previous_theme_frame_id_; | 154 int previous_theme_frame_id_; |
| 171 int previous_theme_frame_overlay_id_; | 155 int previous_theme_frame_overlay_id_; |
| 172 | 156 |
| 173 // Image ids and opacity we are crossfading from. | 157 // Image ids and opacity we are crossfading from. |
| 174 int crossfade_theme_frame_id_; | 158 int crossfade_theme_frame_id_; |
| 175 int crossfade_theme_frame_overlay_id_; | 159 int crossfade_theme_frame_overlay_id_; |
| 176 | 160 |
| 177 scoped_ptr<gfx::SlideAnimation> crossfade_animation_; | 161 scoped_ptr<gfx::SlideAnimation> crossfade_animation_; |
| 178 | 162 |
| 179 DISALLOW_COPY_AND_ASSIGN(HeaderPainter); | 163 DISALLOW_COPY_AND_ASSIGN(HeaderPainter); |
| 180 }; | 164 }; |
| 181 | 165 |
| 182 } // namespace ash | 166 } // namespace ash |
| 183 | 167 |
| 184 #endif // ASH_WM_HEADER_PAINTER_H_ | 168 #endif // ASH_WM_HEADER_PAINTER_H_ |
| OLD | NEW |