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