| 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_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ | 5 #ifndef ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ |
| 6 #define ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ | 6 #define ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/common/wm/overview/scoped_transform_overview_window.h" | 11 #include "ash/common/wm/overview/scoped_transform_overview_window.h" |
| 12 #include "ash/common/wm_window_observer.h" | 12 #include "ash/common/wm_window_observer.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "ui/gfx/geometry/insets.h" | 14 #include "ui/gfx/geometry/insets.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/label_button.h" | 18 #include "ui/views/controls/button/label_button.h" |
| 18 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 class ImageButton; | 22 class ImageButton; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace wm { | 25 namespace wm { |
| 25 class Shadow; | 26 class Shadow; |
| 26 } | 27 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 37 class OverviewLabelButton : public views::LabelButton { | 38 class OverviewLabelButton : public views::LabelButton { |
| 38 public: | 39 public: |
| 39 OverviewLabelButton(views::ButtonListener* listener, | 40 OverviewLabelButton(views::ButtonListener* listener, |
| 40 const base::string16& text); | 41 const base::string16& text); |
| 41 | 42 |
| 42 ~OverviewLabelButton() override; | 43 ~OverviewLabelButton() override; |
| 43 | 44 |
| 44 // Makes sure that text is readable with |background_color|. | 45 // Makes sure that text is readable with |background_color|. |
| 45 void SetBackgroundColorHint(SkColor background_color); | 46 void SetBackgroundColorHint(SkColor background_color); |
| 46 | 47 |
| 48 // Resets the listener so that the listener can go out of scope. |
| 49 void ResetListener() { listener_ = nullptr; } |
| 50 |
| 47 void set_padding(const gfx::Insets& padding) { padding_ = padding; } | 51 void set_padding(const gfx::Insets& padding) { padding_ = padding; } |
| 48 | 52 |
| 49 protected: | 53 protected: |
| 50 // views::LabelButton: | 54 // views::LabelButton: |
| 51 gfx::Rect GetChildAreaBounds() override; | 55 gfx::Rect GetChildAreaBounds() override; |
| 52 | 56 |
| 53 private: | 57 private: |
| 54 // Padding on all sides to correctly place the text inside the view. | 58 // Padding on all sides to correctly place the text inside the view. |
| 55 gfx::Insets padding_; | 59 gfx::Insets padding_; |
| 56 | 60 |
| 57 DISALLOW_COPY_AND_ASSIGN(OverviewLabelButton); | 61 DISALLOW_COPY_AND_ASSIGN(OverviewLabelButton); |
| 58 }; | 62 }; |
| 59 | 63 |
| 64 // An image button with a close window icon. |
| 65 class OverviewCloseButton : public views::ImageButton { |
| 66 public: |
| 67 explicit OverviewCloseButton(views::ButtonListener* listener); |
| 68 ~OverviewCloseButton() override; |
| 69 |
| 70 // Resets the listener so that the listener can go out of scope. |
| 71 void ResetListener() { listener_ = nullptr; } |
| 72 |
| 73 private: |
| 74 gfx::ImageSkia icon_image_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(OverviewCloseButton); |
| 77 }; |
| 78 |
| 60 WindowSelectorItem(WmWindow* window, WindowSelector* window_selector); | 79 WindowSelectorItem(WmWindow* window, WindowSelector* window_selector); |
| 61 ~WindowSelectorItem() override; | 80 ~WindowSelectorItem() override; |
| 62 | 81 |
| 63 WmWindow* GetWindow(); | 82 WmWindow* GetWindow(); |
| 64 | 83 |
| 65 // Returns the root window on which this item is shown. | 84 // Returns the root window on which this item is shown. |
| 66 WmWindow* root_window() { return root_window_; } | 85 WmWindow* root_window() { return root_window_; } |
| 67 | 86 |
| 68 // Returns true if |target| is contained in this WindowSelectorItem. | 87 // Returns true if |target| is contained in this WindowSelectorItem. |
| 69 bool Contains(const WmWindow* target) const; | 88 bool Contains(const WmWindow* target) const; |
| 70 | 89 |
| 71 // Restores and animates the managed window to it's non overview mode state. | 90 // Restores and animates the managed window to its non overview mode state. |
| 72 void RestoreWindow(); | 91 void RestoreWindow(); |
| 73 | 92 |
| 93 // Restores stacking of window captions above the windows, then fades out. |
| 94 void Shutdown(); |
| 95 |
| 74 // Forces the managed window to be shown (ie not hidden or minimized) when | 96 // Forces the managed window to be shown (ie not hidden or minimized) when |
| 75 // calling RestoreWindow(). | 97 // calling RestoreWindow(). |
| 76 void ShowWindowOnExit(); | 98 void ShowWindowOnExit(); |
| 77 | 99 |
| 78 // Dispatched before beginning window overview. This will do any necessary | 100 // Dispatched before beginning window overview. This will do any necessary |
| 79 // one time actions such as restoring minimized windows. | 101 // one time actions such as restoring minimized windows. |
| 80 void PrepareForOverview(); | 102 void PrepareForOverview(); |
| 81 | 103 |
| 82 // Calculates and returns an optimal scale ratio. With MD this is only | 104 // Calculates and returns an optimal scale ratio. With MD this is only |
| 83 // taking into account |size.height()| as the width can vary. Without MD this | 105 // taking into account |size.height()| as the width can vary. Without MD this |
| (...skipping 22 matching lines...) Expand all Loading... |
| 106 void RecomputeWindowTransforms(); | 128 void RecomputeWindowTransforms(); |
| 107 | 129 |
| 108 // Sends an accessibility event indicating that this window became selected | 130 // Sends an accessibility event indicating that this window became selected |
| 109 // so that it's highlighted and announced if accessibility features are | 131 // so that it's highlighted and announced if accessibility features are |
| 110 // enabled. | 132 // enabled. |
| 111 void SendAccessibleSelectionEvent(); | 133 void SendAccessibleSelectionEvent(); |
| 112 | 134 |
| 113 // Closes |transform_window_|. | 135 // Closes |transform_window_|. |
| 114 void CloseWindow(); | 136 void CloseWindow(); |
| 115 | 137 |
| 138 // Hides the original window header and sets shape or mask on a window. |
| 139 // When masks are used, rounded corner |radius| can be specified. |
| 140 // TODO(varkha): remove |radius|. |
| 141 void HideHeaderAndSetShape(int radius); |
| 142 |
| 116 // Sets if the item is dimmed in the overview. Changing the value will also | 143 // Sets if the item is dimmed in the overview. Changing the value will also |
| 117 // change the visibility of the transform windows. | 144 // change the visibility of the transform windows. |
| 118 void SetDimmed(bool dimmed); | 145 void SetDimmed(bool dimmed); |
| 119 bool dimmed() const { return dimmed_; } | 146 bool dimmed() const { return dimmed_; } |
| 120 | 147 |
| 121 const gfx::Rect& target_bounds() const { return target_bounds_; } | 148 const gfx::Rect& target_bounds() const { return target_bounds_; } |
| 122 static void set_use_mask(bool use_mask) { use_mask_ = use_mask; } | 149 static void set_use_mask(bool use_mask) { use_mask_ = use_mask; } |
| 123 static void set_use_shape(bool use_shape) { use_shape_ = use_shape; } | 150 static void set_use_shape(bool use_shape) { use_shape_ = use_shape; } |
| 124 | 151 |
| 125 // views::ButtonListener: | 152 // views::ButtonListener: |
| 126 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 153 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 127 | 154 |
| 128 // WmWindowObserver: | 155 // WmWindowObserver: |
| 129 void OnWindowDestroying(WmWindow* window) override; | 156 void OnWindowDestroying(WmWindow* window) override; |
| 130 void OnWindowTitleChanged(WmWindow* window) override; | 157 void OnWindowTitleChanged(WmWindow* window) override; |
| 131 | 158 |
| 132 private: | 159 private: |
| 133 class CaptionContainerView; | 160 class CaptionContainerView; |
| 161 class RoundedContainerView; |
| 134 friend class WindowSelectorTest; | 162 friend class WindowSelectorTest; |
| 135 | 163 |
| 164 enum class HeaderFadeInMode { |
| 165 ENTER, |
| 166 UPDATE, |
| 167 EXIT, |
| 168 }; |
| 169 |
| 136 // Sets the bounds of this selector's items to |target_bounds| in | 170 // Sets the bounds of this selector's items to |target_bounds| in |
| 137 // |root_window_|. The bounds change will be animated as specified | 171 // |root_window_|. The bounds change will be animated as specified |
| 138 // by |animation_type|. | 172 // by |animation_type|. |
| 139 void SetItemBounds(const gfx::Rect& target_bounds, | 173 void SetItemBounds(const gfx::Rect& target_bounds, |
| 140 OverviewAnimationType animation_type); | 174 OverviewAnimationType animation_type); |
| 141 | 175 |
| 142 // Changes the opacity of all the windows the item owns. | 176 // Changes the opacity of all the windows the item owns. |
| 143 void SetOpacity(float opacity); | 177 void SetOpacity(float opacity); |
| 144 | 178 |
| 145 // Updates the window label bounds. | 179 // Updates the window label bounds. |
| 146 void UpdateWindowLabel(const gfx::Rect& window_bounds, | 180 void UpdateWindowLabel(const gfx::Rect& window_bounds, |
| 147 OverviewAnimationType animation_type); | 181 OverviewAnimationType animation_type); |
| 148 | 182 |
| 149 // Creates the window label. | 183 // Creates the window label. |
| 150 void CreateWindowLabel(const base::string16& title); | 184 void CreateWindowLabel(const base::string16& title); |
| 151 | 185 |
| 152 // Updates the close button's and title label's bounds. Any change in bounds | 186 // Updates the close button's and title label's bounds. Any change in bounds |
| 153 // will be animated from the current bounds to the new bounds as per the | 187 // will be animated from the current bounds to the new bounds as per the |
| 154 // |animation_type|. | 188 // |animation_type|. |mode| allows distinguishing the first time update which |
| 155 void UpdateHeaderLayout(OverviewAnimationType animation_type); | 189 // allows setting the initial bounds properly or exiting overview to fade out |
| 190 // gradually. |
| 191 void UpdateHeaderLayout(HeaderFadeInMode mode, |
| 192 OverviewAnimationType animation_type); |
| 156 | 193 |
| 157 // Animates opacity of the |transform_window_| and its caption to |opacity| | 194 // Animates opacity of the |transform_window_| and its caption to |opacity| |
| 158 // using |animation_type|. | 195 // using |animation_type|. |
| 159 void AnimateOpacity(float opacity, OverviewAnimationType animation_type); | 196 void AnimateOpacity(float opacity, OverviewAnimationType animation_type); |
| 160 | 197 |
| 161 // Updates the close buttons accessibility name. | 198 // Updates the close buttons accessibility name. |
| 162 void UpdateCloseButtonAccessibilityName(); | 199 void UpdateCloseButtonAccessibilityName(); |
| 163 | 200 |
| 201 // Fades out a window caption when exiting overview mode. |
| 202 void FadeOut(std::unique_ptr<views::Widget> widget); |
| 203 |
| 164 static bool hide_header() { return use_mask_ || use_shape_; } | 204 static bool hide_header() { return use_mask_ || use_shape_; } |
| 165 | 205 |
| 166 // True if the item is being shown in the overview, false if it's being | 206 // True if the item is being shown in the overview, false if it's being |
| 167 // filtered. | 207 // filtered. |
| 168 bool dimmed_; | 208 bool dimmed_; |
| 169 | 209 |
| 170 // The root window this item is being displayed on. | 210 // The root window this item is being displayed on. |
| 171 WmWindow* root_window_; | 211 WmWindow* root_window_; |
| 172 | 212 |
| 173 // The contained Window's wrapper. | 213 // The contained Window's wrapper. |
| 174 ScopedTransformOverviewWindow transform_window_; | 214 ScopedTransformOverviewWindow transform_window_; |
| 175 | 215 |
| 176 // The target bounds this selector item is fit within. | 216 // The target bounds this selector item is fit within. |
| 177 gfx::Rect target_bounds_; | 217 gfx::Rect target_bounds_; |
| 178 | 218 |
| 179 // True if running SetItemBounds. This prevents recursive calls resulting from | 219 // True if running SetItemBounds. This prevents recursive calls resulting from |
| 180 // the bounds update when calling ::wm::RecreateWindowLayers to copy | 220 // the bounds update when calling ::wm::RecreateWindowLayers to copy |
| 181 // a window layer for display on another monitor. | 221 // a window layer for display on another monitor. |
| 182 bool in_bounds_update_; | 222 bool in_bounds_update_; |
| 183 | 223 |
| 224 // True when |this| item is visually selected. Item header is made transparent |
| 225 // when the item is selected. |
| 226 bool selected_; |
| 227 |
| 184 // Label displaying its name (active tab for tabbed windows). | 228 // Label displaying its name (active tab for tabbed windows). |
| 185 // With Material Design this Widget owns |caption_container_view_| and is | 229 // With Material Design this Widget owns |caption_container_view_| and is |
| 186 // shown above the |transform_window_|. | 230 // shown above the |transform_window_|. |
| 187 // Otherwise it is shown under the window. | 231 // Otherwise it is shown under the window. |
| 188 std::unique_ptr<views::Widget> window_label_; | 232 std::unique_ptr<views::Widget> window_label_; |
| 189 | 233 |
| 190 // Shadow around the item in overview. | 234 // Shadow around the item in overview. |
| 191 std::unique_ptr<::wm::Shadow> shadow_; | 235 std::unique_ptr<::wm::Shadow> shadow_; |
| 192 | 236 |
| 193 // Label background widget used to fade in opacity when moving selection. | |
| 194 std::unique_ptr<views::Widget> window_label_selector_; | |
| 195 | |
| 196 // Container view that owns |window_label_button_view_| and |close_button_|. | 237 // Container view that owns |window_label_button_view_| and |close_button_|. |
| 197 // Only used with Material Design. | 238 // Only used with Material Design. |
| 198 CaptionContainerView* caption_container_view_; | 239 CaptionContainerView* caption_container_view_; |
| 199 | 240 |
| 200 // View for the label below the window or (with material design) above it. | 241 // View for the label below the window or (with material design) above it. |
| 201 OverviewLabelButton* window_label_button_view_; | 242 OverviewLabelButton* window_label_button_view_; |
| 202 | 243 |
| 203 // The close buttons widget container. Not used with Material Design. | 244 // The close buttons widget container. Not used with Material Design. |
| 204 std::unique_ptr<views::Widget> close_button_widget_; | 245 std::unique_ptr<views::Widget> close_button_widget_; |
| 205 | 246 |
| 206 // A close button for the window in this item. Owned by the | 247 // A close button for the window in this item. Owned by the |
| 207 // |caption_container_view_| with Material Design or by |close_button_widget_| | 248 // |caption_container_view_| with Material Design or by |close_button_widget_| |
| 208 // otherwise. | 249 // otherwise. |
| 209 views::ImageButton* close_button_; | 250 OverviewCloseButton* close_button_; |
| 210 | 251 |
| 211 // Pointer to the WindowSelector that owns the WindowGrid containing |this|. | 252 // Pointer to the WindowSelector that owns the WindowGrid containing |this|. |
| 212 // Guaranteed to be non-null for the lifetime of |this|. | 253 // Guaranteed to be non-null for the lifetime of |this|. |
| 213 WindowSelector* window_selector_; | 254 WindowSelector* window_selector_; |
| 214 | 255 |
| 256 // Pointer to a view that covers the original header and has rounded top |
| 257 // corners. This view can have its color and opacity animated. |
| 258 RoundedContainerView* background_view_; |
| 259 |
| 215 // If true, mask the original window header while in overview and make corners | 260 // If true, mask the original window header while in overview and make corners |
| 216 // rounded using a mask layer. This has performance implications so it can be | 261 // rounded using a mask layer. This has performance implications so it can be |
| 217 // disabled when there are many windows. | 262 // disabled when there are many windows. |
| 218 static bool use_mask_; | 263 static bool use_mask_; |
| 219 | 264 |
| 220 // If true, hide the original window header while in overview using alpha | 265 // If true, hide the original window header while in overview using alpha |
| 221 // shape. This has performance implications so it can be disabled when there | 266 // shape. This has performance implications so it can be disabled when there |
| 222 // are many windows. | 267 // are many windows. |
| 223 static bool use_shape_; | 268 static bool use_shape_; |
| 224 | 269 |
| 225 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); | 270 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); |
| 226 }; | 271 }; |
| 227 | 272 |
| 228 } // namespace ash | 273 } // namespace ash |
| 229 | 274 |
| 230 #endif // ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ | 275 #endif // ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ |
| OLD | NEW |