Chromium Code Reviews| 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" | |
| 11 #include "ash/wm/overview/transparent_activate_window_button_delegate.h" | |
| 12 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ui/aura/scoped_window_targeter.h" | |
| 14 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
| 17 #include "ui/views/controls/button/image_button.h" | 16 #include "ui/views/controls/button/image_button.h" |
| 17 #include "ui/views/controls/button/label_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 LabelButton; |
| 25 class Widget; | 25 class Widget; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace ash { | 28 namespace ash { |
| 29 | 29 |
| 30 class OverviewWindowTargeter; | |
| 31 | |
| 30 // This class represents an item in overview mode. | 32 // This class represents an item in overview mode. |
| 31 class ASH_EXPORT WindowSelectorItem | 33 class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, |
| 32 : public views::ButtonListener, | 34 public aura::WindowObserver { |
| 33 public aura::WindowObserver, | |
| 34 public TransparentActivateWindowButtonDelegate { | |
| 35 public: | 35 public: |
| 36 explicit WindowSelectorItem(aura::Window* window); | 36 explicit WindowSelectorItem(aura::Window* window); |
| 37 ~WindowSelectorItem() override; | 37 ~WindowSelectorItem() override; |
| 38 | 38 |
| 39 aura::Window* GetWindow(); | 39 aura::Window* GetWindow(); |
| 40 | 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 // Returns true if |target| is contained in this WindowSelectorItem. | 44 // Returns true if |target| is contained in this WindowSelectorItem. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 | 76 |
| 77 const gfx::Rect& target_bounds() const { return target_bounds_; } | 77 const gfx::Rect& target_bounds() const { return target_bounds_; } |
| 78 | 78 |
| 79 // views::ButtonListener: | 79 // views::ButtonListener: |
| 80 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 80 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 81 | 81 |
| 82 // aura::WindowObserver: | 82 // aura::WindowObserver: |
| 83 void OnWindowDestroying(aura::Window* window) override; | 83 void OnWindowDestroying(aura::Window* window) override; |
| 84 void OnWindowTitleChanged(aura::Window* window) override; | 84 void OnWindowTitleChanged(aura::Window* window) override; |
| 85 | 85 |
| 86 // ash::TransparentActivateWindowButtonDelegate: | |
| 87 void Select() override; | |
| 88 | |
| 89 private: | 86 private: |
| 90 friend class WindowSelectorTest; | 87 friend class WindowSelectorTest; |
| 91 | 88 |
| 89 // LabelButton shown under each of the windows. | |
| 90 class OverviewLabelButton; | |
| 91 | |
| 92 // 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 |
| 93 // |root_window_|. The bounds change will be animated as specified | 93 // |root_window_|. The bounds change will be animated as specified |
| 94 // by |animation_type|. | 94 // by |animation_type|. |
| 95 void SetItemBounds(const gfx::Rect& target_bounds, | 95 void SetItemBounds(const gfx::Rect& target_bounds, |
| 96 OverviewAnimationType animation_type); | 96 OverviewAnimationType animation_type); |
| 97 | 97 |
| 98 // Changes the opacity of all the windows the item owns. | 98 // Changes the opacity of all the windows the item owns. |
| 99 void SetOpacity(float opacity); | 99 void SetOpacity(float opacity); |
| 100 | 100 |
| 101 // Updates the window label's bounds to |target_bounds|. Will create a new | 101 // Updates the window label's bounds to |target_bounds|. The bounds change is |
| 102 // window label and fade it in if it doesn't exist. The bounds change is | |
| 103 // animated as specified by the |animation_type|. | 102 // animated as specified by the |animation_type|. |
| 104 void UpdateWindowLabels(const gfx::Rect& target_bounds, | 103 void UpdateWindowLabels(const gfx::Rect& target_bounds, |
| 105 OverviewAnimationType animation_type); | 104 OverviewAnimationType animation_type); |
| 106 | 105 |
| 107 // Initializes window_label_. | 106 // Initializes window_label_. |
| 108 void CreateWindowLabel(const base::string16& title); | 107 void CreateWindowLabel(); |
| 109 | |
| 110 // Updates the bounds and accessibility names for all the transparent | |
| 111 // overlays. | |
| 112 void UpdateSelectorButtons(); | |
| 113 | 108 |
| 114 // Updates the close button's bounds. Any change in bounds will be animated | 109 // Updates the close button's bounds. Any change in bounds will be animated |
| 115 // from the current bounds to the new bounds as per the |animation_type|. | 110 // from the current bounds to the new bounds as per the |animation_type|. |
| 116 void UpdateCloseButtonLayout(OverviewAnimationType animation_type); | 111 void UpdateCloseButtonLayout(OverviewAnimationType animation_type); |
| 117 | 112 |
| 118 // Updates the close buttons accessibility name. | 113 // Updates the close buttons accessibility name. |
| 119 void UpdateCloseButtonAccessibilityName(); | 114 void UpdateCloseButtonAccessibilityName(); |
| 120 | 115 |
| 121 // True if the item is being shown in the overview, false if it's being | 116 // True if the item is being shown in the overview, false if it's being |
| 122 // filtered. | 117 // filtered. |
| 123 bool dimmed_; | 118 bool dimmed_; |
| 124 | 119 |
| 125 // The root window this item is being displayed on. | 120 // The root window this item is being displayed on. |
| 126 aura::Window* root_window_; | 121 aura::Window* root_window_; |
| 127 | 122 |
| 128 // The contained Window's wrapper. | 123 // The contained Window's wrapper. |
| 129 ScopedTransformOverviewWindow transform_window_; | 124 ScopedTransformOverviewWindow transform_window_; |
| 130 | 125 |
| 131 // The target bounds this selector item is fit within. | 126 // The target bounds this selector item is fit within. |
| 132 gfx::Rect target_bounds_; | 127 gfx::Rect target_bounds_; |
| 133 | 128 |
| 134 // True if running SetItemBounds. This prevents recursive calls resulting from | 129 // True if running SetItemBounds. This prevents recursive calls resulting from |
| 135 // the bounds update when calling ::wm::RecreateWindowLayers to copy | 130 // the bounds update when calling ::wm::RecreateWindowLayers to copy |
| 136 // a window layer for display on another monitor. | 131 // a window layer for display on another monitor. |
| 137 bool in_bounds_update_; | 132 bool in_bounds_update_; |
| 138 | 133 |
| 139 // Label under the window displaying its active tab name. | 134 // Label under the window displaying its active tab name. |
| 140 scoped_ptr<views::Widget> window_label_; | 135 scoped_ptr<views::Widget> window_label_; |
| 141 | 136 |
| 142 // View for the label under the window. | 137 // View for the label button under the window. |
| 143 views::Label* window_label_view_; | 138 OverviewLabelButton* window_label_button_view_; |
| 144 | 139 |
| 145 // The close buttons widget container. | 140 // The close buttons widget container. |
| 146 views::Widget close_button_widget_; | 141 views::Widget close_button_widget_; |
| 147 | 142 |
| 148 // An easy to access close button for the window in this item. Owned by the | 143 // An easy to access close button for the window in this item. Owned by the |
| 149 // close_button_widget_. | 144 // close_button_widget_. |
| 150 views::ImageButton* close_button_; | 145 views::ImageButton* close_button_; |
| 151 | 146 |
| 152 // Transparent overlay that covers the entire bounds of the | 147 // Reference to the targeter implemented by the scoped window targeter. |
| 153 // WindowSelectorItem and is stacked in front of all windows but behind each | 148 OverviewWindowTargeter* overview_window_targeter_; |
| 154 // Windows' own TransparentActivateWindowButton. | 149 |
| 155 scoped_ptr<TransparentActivateWindowButton> | 150 // Stores and restores on exit the actual window targeter. |
| 156 selector_item_activate_window_button_; | 151 scoped_ptr<aura::ScopedWindowTargeter> scoped_window_targeter_; |
|
flackr
2015/01/22 23:21:17
Just a thought, if you make the OverviewLabelButto
Nina
2015/01/23 18:38:58
I went forward and refactored the code this way, a
| |
| 157 | 152 |
| 158 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); | 153 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); |
| 159 }; | 154 }; |
| 160 | 155 |
| 161 } // namespace ash | 156 } // namespace ash |
| 162 | 157 |
| 163 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ | 158 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ |
| OLD | NEW |