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/compiler_specific.h" // OVERRIDE | 11 #include "base/compiler_specific.h" // OVERRIDE |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "ui/base/animation/animation_delegate.h" | |
14 #include "ui/gfx/rect.h" | |
15 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
16 | 13 |
17 class SkBitmap; | 14 class SkBitmap; |
18 namespace aura { | 15 namespace aura { |
19 class Window; | 16 class Window; |
20 } | 17 } |
21 namespace gfx { | 18 namespace gfx { |
22 class Canvas; | 19 class Canvas; |
23 class Font; | 20 class Font; |
| 21 class Rect; |
24 class Point; | 22 class Point; |
25 class Size; | 23 class Size; |
26 } | 24 } |
27 namespace ui { | |
28 class SlideAnimation; | |
29 } | |
30 namespace views { | 25 namespace views { |
31 class ImageButton; | 26 class ImageButton; |
32 class NonClientFrameView; | 27 class NonClientFrameView; |
33 class View; | 28 class View; |
34 class Widget; | 29 class Widget; |
35 } | 30 } |
36 | 31 |
37 namespace ash { | 32 namespace ash { |
38 | 33 |
39 // Helper class for painting window frames. Exists to share code between | 34 // Helper class for painting window frames. Exists to share code between |
40 // various implementations of views::NonClientFrameView. Canonical source of | 35 // various implementations of views::NonClientFrameView. Canonical source of |
41 // layout constants for Ash window frames. | 36 // layout constants for Ash window frames. |
42 class ASH_EXPORT FramePainter : public aura::WindowObserver, | 37 class ASH_EXPORT FramePainter : public aura::WindowObserver { |
43 public ui::AnimationDelegate { | |
44 public: | 38 public: |
45 FramePainter(); | 39 FramePainter(); |
46 virtual ~FramePainter(); | 40 virtual ~FramePainter(); |
47 | 41 |
48 // |frame| and buttons are used for layout and are not owned. | 42 // |frame| and buttons are used for layout and are not owned. |
49 void Init(views::Widget* frame, | 43 void Init(views::Widget* frame, |
50 views::View* window_icon, | 44 views::View* window_icon, |
51 views::ImageButton* maximize_button, | 45 views::ImageButton* maximize_button, |
52 views::ImageButton* close_button); | 46 views::ImageButton* close_button); |
53 | 47 |
(...skipping 30 matching lines...) Expand all Loading... |
84 // 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 |
85 // |maximized_layout| appearance. | 79 // |maximized_layout| appearance. |
86 void LayoutHeader(views::NonClientFrameView* view, bool maximized_layout); | 80 void LayoutHeader(views::NonClientFrameView* view, bool maximized_layout); |
87 | 81 |
88 // aura::WindowObserver overrides: | 82 // aura::WindowObserver overrides: |
89 virtual void OnWindowPropertyChanged(aura::Window* window, | 83 virtual void OnWindowPropertyChanged(aura::Window* window, |
90 const void* key, | 84 const void* key, |
91 intptr_t old) OVERRIDE; | 85 intptr_t old) OVERRIDE; |
92 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 86 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
93 | 87 |
94 // Overridden from ui::AnimationDelegate | |
95 void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | |
96 | |
97 private: | 88 private: |
98 // Sets the images for a button base on IDs from the |frame_| theme provider. | 89 // Sets the images for a button base on IDs from the |frame_| theme provider. |
99 void SetButtonImages(views::ImageButton* button, | 90 void SetButtonImages(views::ImageButton* button, |
100 int normal_bitmap_id, | 91 int normal_bitmap_id, |
101 int hot_bitmap_id, | 92 int hot_bitmap_id, |
102 int pushed_bitmap_id); | 93 int pushed_bitmap_id); |
103 | 94 |
104 // Returns the offset between window left edge and title string. | 95 // Returns the offset between window left edge and title string. |
105 int GetTitleOffsetX() const; | 96 int GetTitleOffsetX() const; |
106 | 97 |
107 // Not owned | 98 // Not owned |
108 views::Widget* frame_; | 99 views::Widget* frame_; |
109 views::View* window_icon_; // May be NULL. | 100 views::View* window_icon_; // May be NULL. |
110 views::ImageButton* maximize_button_; | 101 views::ImageButton* maximize_button_; |
111 views::ImageButton* close_button_; | 102 views::ImageButton* close_button_; |
112 aura::Window* window_; | 103 aura::Window* window_; |
113 | 104 |
114 // Window frame header/caption parts. | 105 // Window frame header/caption parts. |
115 const SkBitmap* button_separator_; | 106 const SkBitmap* button_separator_; |
116 const SkBitmap* top_left_corner_; | 107 const SkBitmap* top_left_corner_; |
117 const SkBitmap* top_edge_; | 108 const SkBitmap* top_edge_; |
118 const SkBitmap* top_right_corner_; | 109 const SkBitmap* top_right_corner_; |
119 const SkBitmap* header_left_edge_; | 110 const SkBitmap* header_left_edge_; |
120 const SkBitmap* header_right_edge_; | 111 const SkBitmap* header_right_edge_; |
121 | 112 |
122 // The bitmap last used for painting header. | |
123 const SkBitmap* previous_theme_frame_; | |
124 // The bitmap we are crossfading from. | |
125 const SkBitmap* crossfade_theme_frame_; | |
126 | |
127 gfx::Rect header_frame_bounds_; | |
128 scoped_ptr<ui::SlideAnimation> crossfade_animation_; | |
129 | |
130 DISALLOW_COPY_AND_ASSIGN(FramePainter); | 113 DISALLOW_COPY_AND_ASSIGN(FramePainter); |
131 }; | 114 }; |
132 | 115 |
133 } // namespace ash | 116 } // namespace ash |
134 | 117 |
135 #endif // ASH_WM_FRAME_PAINTER_H_ | 118 #endif // ASH_WM_FRAME_PAINTER_H_ |
OLD | NEW |