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 ASH_WM_FRAME_PAINTER_H_ | 5 #ifndef ASH_WM_FRAME_PAINTER_H_ |
6 #define ASH_WM_FRAME_PAINTER_H_ | 6 #define ASH_WM_FRAME_PAINTER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "ui/base/animation/animation_delegate.h" | |
13 #include "ui/gfx/rect.h" | |
11 | 14 |
12 class SkBitmap; | 15 class SkBitmap; |
13 namespace gfx { | 16 namespace gfx { |
14 class Canvas; | 17 class Canvas; |
15 class Font; | 18 class Font; |
16 class Rect; | |
17 class Point; | 19 class Point; |
18 class Size; | 20 class Size; |
19 } | 21 } |
22 namespace ui { | |
23 class SlideAnimation; | |
24 } | |
20 namespace views { | 25 namespace views { |
21 class ImageButton; | 26 class ImageButton; |
22 class NonClientFrameView; | 27 class NonClientFrameView; |
23 class View; | 28 class View; |
24 class Widget; | 29 class Widget; |
25 } | 30 } |
26 | 31 |
27 namespace ash { | 32 namespace ash { |
28 | 33 |
29 // Helper class for painting window frames. Exists to share code between | 34 // Helper class for painting window frames. Exists to share code between |
30 // various implementations of views::NonClientFrameView. Canonical source of | 35 // various implementations of views::NonClientFrameView. Canonical source of |
31 // layout constants for Ash window frames. | 36 // layout constants for Ash window frames. |
32 class ASH_EXPORT FramePainter { | 37 class ASH_EXPORT FramePainter : public ui::AnimationDelegate { |
33 public: | 38 public: |
34 FramePainter(); | 39 FramePainter(); |
35 ~FramePainter(); | 40 ~FramePainter(); |
James Cook
2012/03/19 19:25:58
must be virtual, clang will complain
| |
36 | 41 |
37 // |frame| and buttons are used for layout and are not owned. | 42 // |frame| and buttons are used for layout and are not owned. |
38 void Init(views::Widget* frame, | 43 void Init(views::Widget* frame, |
39 views::View* window_icon, | 44 views::View* window_icon, |
40 views::ImageButton* maximize_button, | 45 views::ImageButton* maximize_button, |
41 views::ImageButton* close_button); | 46 views::ImageButton* close_button); |
42 | 47 |
43 // Helpers for views::NonClientFrameView implementations. | 48 // Helpers for views::NonClientFrameView implementations. |
44 gfx::Rect GetBoundsForClientView(int top_height, | 49 gfx::Rect GetBoundsForClientView(int top_height, |
45 const gfx::Rect& window_bounds) const; | 50 const gfx::Rect& window_bounds) const; |
(...skipping 21 matching lines...) Expand all Loading... | |
67 | 72 |
68 // Paint the title bar, primarily the title string. | 73 // Paint the title bar, primarily the title string. |
69 void PaintTitleBar(views::NonClientFrameView* view, | 74 void PaintTitleBar(views::NonClientFrameView* view, |
70 gfx::Canvas* canvas, | 75 gfx::Canvas* canvas, |
71 const gfx::Font& title_font); | 76 const gfx::Font& title_font); |
72 | 77 |
73 // Performs layout for the header based on whether we want the shorter | 78 // Performs layout for the header based on whether we want the shorter |
74 // |maximized_layout| appearance. | 79 // |maximized_layout| appearance. |
75 void LayoutHeader(views::NonClientFrameView* view, bool maximized_layout); | 80 void LayoutHeader(views::NonClientFrameView* view, bool maximized_layout); |
76 | 81 |
82 // Overridden from ui::AnimationDelegate | |
83 void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | |
84 | |
77 private: | 85 private: |
78 // Sets the images for a button base on IDs from the |frame_| theme provider. | 86 // Sets the images for a button base on IDs from the |frame_| theme provider. |
79 void SetButtonImages(views::ImageButton* button, | 87 void SetButtonImages(views::ImageButton* button, |
80 int normal_bitmap_id, | 88 int normal_bitmap_id, |
81 int hot_bitmap_id, | 89 int hot_bitmap_id, |
82 int pushed_bitmap_id); | 90 int pushed_bitmap_id); |
83 | 91 |
84 // Returns the offset between window left edge and title string. | 92 // Returns the offset between window left edge and title string. |
85 int GetTitleOffsetX() const; | 93 int GetTitleOffsetX() const; |
86 | 94 |
87 // Not owned | 95 // Not owned |
88 views::Widget* frame_; | 96 views::Widget* frame_; |
89 views::View* window_icon_; // May be NULL. | 97 views::View* window_icon_; // May be NULL. |
90 views::ImageButton* maximize_button_; | 98 views::ImageButton* maximize_button_; |
91 views::ImageButton* close_button_; | 99 views::ImageButton* close_button_; |
92 | 100 |
93 // Window frame header/caption parts. | 101 // Window frame header/caption parts. |
94 const SkBitmap* button_separator_; | 102 const SkBitmap* button_separator_; |
95 const SkBitmap* top_left_corner_; | 103 const SkBitmap* top_left_corner_; |
96 const SkBitmap* top_edge_; | 104 const SkBitmap* top_edge_; |
97 const SkBitmap* top_right_corner_; | 105 const SkBitmap* top_right_corner_; |
98 const SkBitmap* header_left_edge_; | 106 const SkBitmap* header_left_edge_; |
99 const SkBitmap* header_right_edge_; | 107 const SkBitmap* header_right_edge_; |
100 | 108 |
109 // The bitmap last used for painting header. | |
110 const SkBitmap* previous_theme_frame_; | |
111 // The bitmap we are crossfading from. | |
112 const SkBitmap* crossfade_theme_frame_; | |
113 | |
114 gfx::Rect header_frame_bounds_; | |
115 scoped_ptr<ui::SlideAnimation> crossfade_animation_; | |
116 | |
101 DISALLOW_COPY_AND_ASSIGN(FramePainter); | 117 DISALLOW_COPY_AND_ASSIGN(FramePainter); |
102 }; | 118 }; |
103 | 119 |
104 } // namespace ash | 120 } // namespace ash |
105 | 121 |
106 #endif // ASH_WM_FRAME_PAINTER_H_ | 122 #endif // ASH_WM_FRAME_PAINTER_H_ |
OLD | NEW |