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_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ | 5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ |
6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ | 6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "ui/aura/window_observer.h" |
10 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
11 #include "ui/views/controls/button/button.h" | 12 #include "ui/views/controls/button/button.h" |
12 | 13 |
13 namespace aura { | 14 namespace aura { |
14 class Window; | 15 class Window; |
15 } | 16 } |
16 | 17 |
17 namespace views { | 18 namespace views { |
| 19 class Label; |
18 class Widget; | 20 class Widget; |
19 } | 21 } |
20 | 22 |
21 namespace ash { | 23 namespace ash { |
22 class TransparentActivateWindowButton; | 24 class TransparentActivateWindowButton; |
23 | 25 |
24 // This class represents an item in overview mode. An item can have one or more | 26 // This class represents an item in overview mode. An item can have one or more |
25 // windows, of which only one can be activated by keyboard (i.e. alt+tab) but | 27 // windows, of which only one can be activated by keyboard (i.e. alt+tab) but |
26 // any can be selected with a pointer (touch or mouse). | 28 // any can be selected with a pointer (touch or mouse). |
27 class WindowSelectorItem : public views::ButtonListener { | 29 class WindowSelectorItem : public views::ButtonListener, |
| 30 public aura::WindowObserver { |
28 public: | 31 public: |
29 WindowSelectorItem(); | 32 WindowSelectorItem(); |
30 virtual ~WindowSelectorItem(); | 33 virtual ~WindowSelectorItem(); |
31 | 34 |
32 // The time for the close buttons and labels to fade in when initially shown | 35 // The time for the close buttons and labels to fade in when initially shown |
33 // on entering overview mode. | 36 // on entering overview mode. |
34 static const int kFadeInMilliseconds; | 37 static const int kFadeInMilliseconds; |
35 | 38 |
36 // Returns the root window on which this item is shown. | 39 // Returns the root window on which this item is shown. |
37 virtual aura::Window* GetRootWindow() = 0; | 40 virtual aura::Window* GetRootWindow() = 0; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // label is read. | 79 // label is read. |
77 void SendFocusAlert() const; | 80 void SendFocusAlert() const; |
78 | 81 |
79 const gfx::Rect& bounds() const { return bounds_; } | 82 const gfx::Rect& bounds() const { return bounds_; } |
80 const gfx::Rect& target_bounds() const { return target_bounds_; } | 83 const gfx::Rect& target_bounds() const { return target_bounds_; } |
81 | 84 |
82 // views::ButtonListener: | 85 // views::ButtonListener: |
83 virtual void ButtonPressed(views::Button* sender, | 86 virtual void ButtonPressed(views::Button* sender, |
84 const ui::Event& event) OVERRIDE; | 87 const ui::Event& event) OVERRIDE; |
85 | 88 |
| 89 // aura::WindowObserver: |
| 90 virtual void OnWindowTitleChanged(aura::Window* window) OVERRIDE; |
| 91 |
86 protected: | 92 protected: |
87 // Sets the bounds of this selector's items to |target_bounds| in | 93 // Sets the bounds of this selector's items to |target_bounds| in |
88 // |root_window|. If |animate| the windows are animated from their current | 94 // |root_window|. If |animate| the windows are animated from their current |
89 // location. | 95 // location. |
90 virtual void SetItemBounds(aura::Window* root_window, | 96 virtual void SetItemBounds(aura::Window* root_window, |
91 const gfx::Rect& target_bounds, | 97 const gfx::Rect& target_bounds, |
92 bool animate) = 0; | 98 bool animate) = 0; |
93 | 99 |
94 // Sets the bounds used by the selector item's windows. | 100 // Sets the bounds used by the selector item's windows. |
95 void set_bounds(const gfx::Rect& bounds) { bounds_ = bounds; } | 101 void set_bounds(const gfx::Rect& bounds) { bounds_ = bounds; } |
96 | 102 |
97 private: | 103 private: |
98 friend class WindowSelectorTest; | 104 friend class WindowSelectorTest; |
99 | 105 |
100 // Creates |close_button_| if it does not exist and updates the bounds based | 106 // Creates |close_button_| if it does not exist and updates the bounds based |
101 // on GetCloseButtonTargetBounds() | 107 // on GetCloseButtonTargetBounds() |
102 void UpdateCloseButtonBounds(aura::Window* root_window, bool animate); | 108 void UpdateCloseButtonBounds(aura::Window* root_window, bool animate); |
103 | 109 |
104 // Creates a label to display under the window selector item. | 110 // Creates a label to display under the window selector item. |
105 void UpdateWindowLabels(const gfx::Rect& target_bounds, | 111 void UpdateWindowLabels(const gfx::Rect& target_bounds, |
106 aura::Window* root_window, | 112 aura::Window* root_window, |
107 bool animate); | 113 bool animate); |
108 | 114 |
| 115 // Initializes window_label_. |
| 116 void CreateWindowLabel(const base::string16& title); |
| 117 |
109 // The root window this item is being displayed on. | 118 // The root window this item is being displayed on. |
110 aura::Window* root_window_; | 119 aura::Window* root_window_; |
111 | 120 |
112 // The target bounds this selector item is fit within. | 121 // The target bounds this selector item is fit within. |
113 gfx::Rect target_bounds_; | 122 gfx::Rect target_bounds_; |
114 | 123 |
115 // The actual bounds of the window(s) for this item. The aspect ratio of | 124 // The actual bounds of the window(s) for this item. The aspect ratio of |
116 // window(s) are maintained so they may not fill the target_bounds_. | 125 // window(s) are maintained so they may not fill the target_bounds_. |
117 gfx::Rect bounds_; | 126 gfx::Rect bounds_; |
118 | 127 |
119 // True if running SetItemBounds. This prevents recursive calls resulting from | 128 // True if running SetItemBounds. This prevents recursive calls resulting from |
120 // the bounds update when calling ::wm::RecreateWindowLayers to copy | 129 // the bounds update when calling ::wm::RecreateWindowLayers to copy |
121 // a window layer for display on another monitor. | 130 // a window layer for display on another monitor. |
122 bool in_bounds_update_; | 131 bool in_bounds_update_; |
123 | 132 |
124 // Label under the window displaying its active tab name. | 133 // Label under the window displaying its active tab name. |
125 scoped_ptr<views::Widget> window_label_; | 134 scoped_ptr<views::Widget> window_label_; |
126 | 135 |
| 136 // View for the label under the window. |
| 137 views::Label* window_label_view_; |
| 138 |
127 // An easy to access close button for the window in this item. | 139 // An easy to access close button for the window in this item. |
128 scoped_ptr<views::Widget> close_button_; | 140 scoped_ptr<views::Widget> close_button_; |
129 | 141 |
130 // Transparent window on top of the real windows in the overview that | 142 // Transparent window on top of the real windows in the overview that |
131 // activates them on click or tap. | 143 // activates them on click or tap. |
132 scoped_ptr<TransparentActivateWindowButton> activate_window_button_; | 144 scoped_ptr<TransparentActivateWindowButton> activate_window_button_; |
133 | 145 |
134 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); | 146 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); |
135 }; | 147 }; |
136 | 148 |
137 } // namespace ash | 149 } // namespace ash |
138 | 150 |
139 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ | 151 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ |
OLD | NEW |