| 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 "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/wm/overview/scoped_transform_overview_window.h" | 9 #include "ash/wm/overview/scoped_transform_overview_window.h" |
| 10 #include "ash/wm/overview/transparent_activate_window_button.h" | 10 #include "ash/wm/overview/transparent_activate_window_button.h" |
| 11 #include "ash/wm/overview/transparent_activate_window_button_delegate.h" | 11 #include "ash/wm/overview/transparent_activate_window_button_delegate.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
| 17 #include "ui/views/controls/button/image_button.h" | 17 #include "ui/views/controls/button/image_button.h" |
| 18 | 18 |
| 19 namespace aura { | 19 namespace aura { |
| 20 class Window; | 20 class Window; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace views { | 23 namespace views { |
| 24 class Label; | 24 class Label; |
| 25 class Widget; | 25 class Widget; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace ash { | 28 namespace ash { |
| 29 | 29 |
| 30 // This class represents an item in overview mode. An item can have one or more | 30 // This class represents an item in overview mode. |
| 31 // windows, of which only one can be activated by keyboard (i.e. alt+tab) but | |
| 32 // any can be selected with a pointer (touch or mouse). | |
| 33 class ASH_EXPORT WindowSelectorItem | 31 class ASH_EXPORT WindowSelectorItem |
| 34 : public views::ButtonListener, | 32 : public views::ButtonListener, |
| 35 public aura::WindowObserver, | 33 public aura::WindowObserver, |
| 36 public TransparentActivateWindowButtonDelegate { | 34 public TransparentActivateWindowButtonDelegate { |
| 37 public: | 35 public: |
| 38 explicit WindowSelectorItem(aura::Window* root_window); | 36 WindowSelectorItem(aura::Window* root_window, aura::Window* window); |
| 39 ~WindowSelectorItem() override; | 37 ~WindowSelectorItem() override; |
| 40 | 38 |
| 39 aura::Window* GetWindow() const; |
| 40 |
| 41 // Returns the root window on which this item is shown. | 41 // Returns the root window on which this item is shown. |
| 42 aura::Window* root_window() { return root_window_; } | 42 aura::Window* root_window() { return root_window_; } |
| 43 | 43 |
| 44 // Adds a window to this selector item. Windows should be added in reverse | |
| 45 // visible order so that the transparent overlay ordering matches the visible | |
| 46 // ordering. Each |window| should have the same root window as |this| was | |
| 47 // instantiated with. | |
| 48 void AddWindow(aura::Window* window); | |
| 49 | |
| 50 // Returns true if the window selector item has |window| as a selectable | |
| 51 // window. | |
| 52 bool HasSelectableWindow(const aura::Window* window) const; | |
| 53 | |
| 54 // Returns true if |target| is contained in this WindowSelectorItem. | 44 // Returns true if |target| is contained in this WindowSelectorItem. |
| 55 bool Contains(const aura::Window* target) const; | 45 bool Contains(const aura::Window* target) const; |
| 56 | 46 |
| 57 // Restores |window| on exiting window overview rather than returning it | 47 // Restores and animates the managed window to it's non overview mode state. |
| 58 // to its previous state. | 48 void RestoreWindow(); |
| 59 void RestoreWindowOnExit(aura::Window* window); | |
| 60 | 49 |
| 61 // Returns the |window| to activate on selecting of this item. | 50 // Forces the managed window to be shown (ie not hidden or minimized) when |
| 62 aura::Window* SelectionWindow() const; | 51 // calling RestoreWindow(). |
| 63 | 52 void ShowWindowOnExit(); |
| 64 // Removes |window| from this item. Check empty() after calling this to see | |
| 65 // if the entire item is now empty. | |
| 66 void RemoveWindow(const aura::Window* window); | |
| 67 | |
| 68 // Returns true if this item has no more selectable windows (i.e. after | |
| 69 // calling RemoveWindow for the last contained window). | |
| 70 bool empty() const; | |
| 71 | 53 |
| 72 // Dispatched before beginning window overview. This will do any necessary | 54 // Dispatched before beginning window overview. This will do any necessary |
| 73 // one time actions such as restoring minimized windows. | 55 // one time actions such as restoring minimized windows. |
| 74 void PrepareForOverview(); | 56 void PrepareForOverview(); |
| 75 | 57 |
| 76 // Sets the bounds of this window selector item to |target_bounds| in the | 58 // Sets the bounds of this window selector item to |target_bounds| in the |
| 77 // |root_window| root window. The bounds change will be animated as specified | 59 // |root_window_| root window. The bounds change will be animated as specified |
| 78 // by |animation_type|. | 60 // by |animation_type|. |
| 79 void SetBounds(aura::Window* root_window, | 61 void SetBounds(const gfx::Rect& target_bounds, |
| 80 const gfx::Rect& target_bounds, | |
| 81 OverviewAnimationType animation_type); | 62 OverviewAnimationType animation_type); |
| 82 | 63 |
| 83 // Recomputes the positions for the windows in this selection item. This is | 64 // Recomputes the positions for the windows in this selection item. This is |
| 84 // dispatched when the bounds of a window change. | 65 // dispatched when the bounds of a window change. |
| 85 void RecomputeWindowTransforms(); | 66 void RecomputeWindowTransforms(); |
| 86 | 67 |
| 87 // Sends an a11y focus alert so that, if chromevox is enabled, the window | 68 // Sends an a11y focus alert so that, if chromevox is enabled, the window |
| 88 // label is read. | 69 // label is read. |
| 89 void SendFocusAlert() const; | 70 void SendFocusAlert() const; |
| 90 | 71 |
| 91 // Sets if the item is dimmed in the overview. Changing the value will also | 72 // Sets if the item is dimmed in the overview. Changing the value will also |
| 92 // change the visibility of the transform windows. | 73 // change the visibility of the transform windows. |
| 93 void SetDimmed(bool dimmed); | 74 void SetDimmed(bool dimmed); |
| 94 bool dimmed() const { return dimmed_; } | 75 bool dimmed() const { return dimmed_; } |
| 95 | 76 |
| 96 const gfx::Rect& target_bounds() const { return target_bounds_; } | 77 const gfx::Rect& target_bounds() const { return target_bounds_; } |
| 97 | 78 |
| 98 // views::ButtonListener: | 79 // views::ButtonListener: |
| 99 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 80 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 100 | 81 |
| 101 // aura::WindowObserver: | 82 // aura::WindowObserver: |
| 83 void OnWindowDestroying(aura::Window* window) override; |
| 102 void OnWindowTitleChanged(aura::Window* window) override; | 84 void OnWindowTitleChanged(aura::Window* window) override; |
| 103 | 85 |
| 104 // ash::TransparentActivateWindowButtonDelegate: | 86 // ash::TransparentActivateWindowButtonDelegate: |
| 105 void Select() override; | 87 void Select() override; |
| 106 | 88 |
| 107 private: | 89 private: |
| 108 friend class WindowSelectorTest; | 90 friend class WindowSelectorTest; |
| 109 | 91 |
| 110 typedef ScopedVector<ScopedTransformOverviewWindow> TransformWindows; | |
| 111 | |
| 112 // Sets the bounds of this selector's items to |target_bounds| in | 92 // Sets the bounds of this selector's items to |target_bounds| in |
| 113 // |root_window|. The bounds change will be animated as specified | 93 // |root_window_|. The bounds change will be animated as specified |
| 114 // by |animation_type|. | 94 // by |animation_type|. |
| 115 void SetItemBounds(aura::Window* root_window, | 95 void SetItemBounds(const gfx::Rect& target_bounds, |
| 116 const gfx::Rect& target_bounds, | |
| 117 OverviewAnimationType animation_type); | 96 OverviewAnimationType animation_type); |
| 118 | 97 |
| 119 // Changes the opacity of all the windows the item owns. | 98 // Changes the opacity of all the windows the item owns. |
| 120 void SetOpacity(float opacity); | 99 void SetOpacity(float opacity); |
| 121 | 100 |
| 122 // Updates the window label's bounds to |target_bounds|. Will create a new | 101 // Updates the window label's bounds to |target_bounds|. Will create a new |
| 123 // window label and fade it in if it doesn't exist. The bounds change is | 102 // window label and fade it in if it doesn't exist. The bounds change is |
| 124 // animated as specified by the |animation_type|. | 103 // animated as specified by the |animation_type|. |
| 125 void UpdateWindowLabels(const gfx::Rect& target_bounds, | 104 void UpdateWindowLabels(const gfx::Rect& target_bounds, |
| 126 OverviewAnimationType animation_type); | 105 OverviewAnimationType animation_type); |
| 127 | 106 |
| 128 // Initializes window_label_. | 107 // Initializes window_label_. |
| 129 void CreateWindowLabel(const base::string16& title); | 108 void CreateWindowLabel(const base::string16& title); |
| 130 | 109 |
| 131 // Updates the bounds and accessibility names for all the transparent | 110 // Updates the bounds and accessibility names for all the transparent |
| 132 // overlays. | 111 // overlays. |
| 133 void UpdateSelectorButtons(); | 112 void UpdateSelectorButtons(); |
| 134 | 113 |
| 135 // Updates the close button's bounds. Any change in bounds will be animated | 114 // Updates the close button's bounds. Any change in bounds will be animated |
| 136 // from the current bounds to the new bounds as per the |animation_type|. | 115 // from the current bounds to the new bounds as per the |animation_type|. |
| 137 void UpdateCloseButtonLayout(OverviewAnimationType animation_type); | 116 void UpdateCloseButtonLayout(OverviewAnimationType animation_type); |
| 138 | 117 |
| 139 // Updates the close buttons accessibility name. | 118 // Updates the close buttons accessibility name. |
| 140 void UpdateCloseButtonAccessibilityName(); | 119 void UpdateCloseButtonAccessibilityName(); |
| 141 | 120 |
| 142 // Returns the ScopedTransformOverviewWindow to activate or close. | |
| 143 ScopedTransformOverviewWindow* SelectionTransformWindow() const; | |
| 144 | |
| 145 // True if the item is being shown in the overview, false if it's being | 121 // True if the item is being shown in the overview, false if it's being |
| 146 // filtered. | 122 // filtered. |
| 147 bool dimmed_; | 123 bool dimmed_; |
| 148 | 124 |
| 149 // The root window this item is being displayed on. | 125 // The root window this item is being displayed on. |
| 150 aura::Window* root_window_; | 126 aura::Window* root_window_; |
| 151 | 127 |
| 128 // The contained Window's wrapper. |
| 129 ScopedTransformOverviewWindow transform_window_; |
| 130 |
| 152 // The target bounds this selector item is fit within. | 131 // The target bounds this selector item is fit within. |
| 153 gfx::Rect target_bounds_; | 132 gfx::Rect target_bounds_; |
| 154 | 133 |
| 155 // True if running SetItemBounds. This prevents recursive calls resulting from | 134 // True if running SetItemBounds. This prevents recursive calls resulting from |
| 156 // the bounds update when calling ::wm::RecreateWindowLayers to copy | 135 // the bounds update when calling ::wm::RecreateWindowLayers to copy |
| 157 // a window layer for display on another monitor. | 136 // a window layer for display on another monitor. |
| 158 bool in_bounds_update_; | 137 bool in_bounds_update_; |
| 159 | 138 |
| 160 // Label under the window displaying its active tab name. | 139 // Label under the window displaying its active tab name. |
| 161 scoped_ptr<views::Widget> window_label_; | 140 scoped_ptr<views::Widget> window_label_; |
| 162 | 141 |
| 163 // View for the label under the window. | 142 // View for the label under the window. |
| 164 views::Label* window_label_view_; | 143 views::Label* window_label_view_; |
| 165 | 144 |
| 166 // The close buttons widget container. | 145 // The close buttons widget container. |
| 167 views::Widget close_button_widget_; | 146 views::Widget close_button_widget_; |
| 168 | 147 |
| 169 // An easy to access close button for the window in this item. Owned by the | 148 // An easy to access close button for the window in this item. Owned by the |
| 170 // close_button_widget_. | 149 // close_button_widget_. |
| 171 views::ImageButton* close_button_; | 150 views::ImageButton* close_button_; |
| 172 | 151 |
| 173 // Transparent overlay that covers the entire bounds of the | 152 // Transparent overlay that covers the entire bounds of the |
| 174 // WindowSelectorItem and is stacked in front of all windows but behind each | 153 // WindowSelectorItem and is stacked in front of all windows but behind each |
| 175 // Windows' own TransparentActivateWindowButton. | 154 // Windows' own TransparentActivateWindowButton. |
| 176 scoped_ptr<TransparentActivateWindowButton> | 155 scoped_ptr<TransparentActivateWindowButton> |
| 177 selector_item_activate_window_button_; | 156 selector_item_activate_window_button_; |
| 178 | 157 |
| 179 // List of all Windows added to this and their associated helper classes. | |
| 180 TransformWindows transform_windows_; | |
| 181 | |
| 182 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); | 158 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); |
| 183 }; | 159 }; |
| 184 | 160 |
| 185 } // namespace ash | 161 } // namespace ash |
| 186 | 162 |
| 187 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ | 163 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ |
| OLD | NEW |