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_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 // Disconnects the listener so that the listener can go out of scope. | |
| 49 void Disconnect() { listener_ = nullptr; } | |
|
bruthig
2016/09/08 18:32:50
nit: I find it really odd that Button::listener_ i
varkha
2016/09/09 02:25:25
There is no Button::set_listener() (but there is o
| |
| 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 // Disconnects the listener so that the listener can go out of scope. | |
| 71 void Disconnect() { 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; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 void RecomputeWindowTransforms(); | 125 void RecomputeWindowTransforms(); |
| 107 | 126 |
| 108 // Sends an accessibility event indicating that this window became selected | 127 // Sends an accessibility event indicating that this window became selected |
| 109 // so that it's highlighted and announced if accessibility features are | 128 // so that it's highlighted and announced if accessibility features are |
| 110 // enabled. | 129 // enabled. |
| 111 void SendAccessibleSelectionEvent(); | 130 void SendAccessibleSelectionEvent(); |
| 112 | 131 |
| 113 // Closes |transform_window_|. | 132 // Closes |transform_window_|. |
| 114 void CloseWindow(); | 133 void CloseWindow(); |
| 115 | 134 |
| 135 // Hides the original window header and sets shape or mask on a window. | |
| 136 // When masks are used, rounded corner |radius| can be specified. | |
| 137 // TODO(varkha): remove |radius|. | |
| 138 void HideHeaderAndSetShape(int radius); | |
| 139 | |
| 116 // Sets if the item is dimmed in the overview. Changing the value will also | 140 // Sets if the item is dimmed in the overview. Changing the value will also |
| 117 // change the visibility of the transform windows. | 141 // change the visibility of the transform windows. |
| 118 void SetDimmed(bool dimmed); | 142 void SetDimmed(bool dimmed); |
| 119 bool dimmed() const { return dimmed_; } | 143 bool dimmed() const { return dimmed_; } |
| 120 | 144 |
| 121 const gfx::Rect& target_bounds() const { return target_bounds_; } | 145 const gfx::Rect& target_bounds() const { return target_bounds_; } |
| 122 static void set_use_mask(bool use_mask) { use_mask_ = use_mask; } | 146 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; } | 147 static void set_use_shape(bool use_shape) { use_shape_ = use_shape; } |
| 124 | 148 |
| 125 // views::ButtonListener: | 149 // views::ButtonListener: |
| 126 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 150 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 127 | 151 |
| 128 // WmWindowObserver: | 152 // WmWindowObserver: |
| 129 void OnWindowDestroying(WmWindow* window) override; | 153 void OnWindowDestroying(WmWindow* window) override; |
| 130 void OnWindowTitleChanged(WmWindow* window) override; | 154 void OnWindowTitleChanged(WmWindow* window) override; |
| 131 | 155 |
| 132 private: | 156 private: |
| 133 class CaptionContainerView; | 157 class CaptionContainerView; |
| 158 class RoundedContainerView; | |
| 134 friend class WindowSelectorTest; | 159 friend class WindowSelectorTest; |
| 135 | 160 |
| 161 enum HeaderFadeInMode { | |
| 162 Enter, | |
| 163 Update, | |
| 164 Exit, | |
| 165 }; | |
| 166 | |
| 136 // Sets the bounds of this selector's items to |target_bounds| in | 167 // Sets the bounds of this selector's items to |target_bounds| in |
| 137 // |root_window_|. The bounds change will be animated as specified | 168 // |root_window_|. The bounds change will be animated as specified |
| 138 // by |animation_type|. | 169 // by |animation_type|. |
| 139 void SetItemBounds(const gfx::Rect& target_bounds, | 170 void SetItemBounds(const gfx::Rect& target_bounds, |
| 140 OverviewAnimationType animation_type); | 171 OverviewAnimationType animation_type); |
| 141 | 172 |
| 142 // Changes the opacity of all the windows the item owns. | 173 // Changes the opacity of all the windows the item owns. |
| 143 void SetOpacity(float opacity); | 174 void SetOpacity(float opacity); |
| 144 | 175 |
| 145 // Updates the window label bounds. | 176 // Updates the window label bounds. |
| 146 void UpdateWindowLabel(const gfx::Rect& window_bounds, | 177 void UpdateWindowLabel(const gfx::Rect& window_bounds, |
| 147 OverviewAnimationType animation_type); | 178 OverviewAnimationType animation_type); |
| 148 | 179 |
| 149 // Creates the window label. | 180 // Creates the window label. |
| 150 void CreateWindowLabel(const base::string16& title); | 181 void CreateWindowLabel(const base::string16& title); |
| 151 | 182 |
| 152 // Updates the close button's and title label's bounds. Any change in bounds | 183 // 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 | 184 // will be animated from the current bounds to the new bounds as per the |
| 154 // |animation_type|. | 185 // |animation_type|. |mode| allows distinguishing the first time update which |
| 155 void UpdateHeaderLayout(OverviewAnimationType animation_type); | 186 // allows setting the initial bounds properly. |
| 187 void UpdateHeaderLayout(HeaderFadeInMode mode, | |
| 188 OverviewAnimationType animation_type); | |
| 156 | 189 |
| 157 // Animates opacity of the |transform_window_| and its caption to |opacity| | 190 // Animates opacity of the |transform_window_| and its caption to |opacity| |
| 158 // using |animation_type|. | 191 // using |animation_type|. |
| 159 void AnimateOpacity(float opacity, OverviewAnimationType animation_type); | 192 void AnimateOpacity(float opacity, OverviewAnimationType animation_type); |
| 160 | 193 |
| 161 // Updates the close buttons accessibility name. | 194 // Updates the close buttons accessibility name. |
| 162 void UpdateCloseButtonAccessibilityName(); | 195 void UpdateCloseButtonAccessibilityName(); |
| 163 | 196 |
| 197 // Fades out a window caption when exiting overview mode. | |
| 198 void FadeOut(std::unique_ptr<views::Widget> widget); | |
| 199 | |
| 164 static bool hide_header() { return use_mask_ || use_shape_; } | 200 static bool hide_header() { return use_mask_ || use_shape_; } |
| 165 | 201 |
| 166 // True if the item is being shown in the overview, false if it's being | 202 // True if the item is being shown in the overview, false if it's being |
| 167 // filtered. | 203 // filtered. |
| 168 bool dimmed_; | 204 bool dimmed_; |
| 169 | 205 |
| 170 // The root window this item is being displayed on. | 206 // The root window this item is being displayed on. |
| 171 WmWindow* root_window_; | 207 WmWindow* root_window_; |
| 172 | 208 |
| 173 // The contained Window's wrapper. | 209 // The contained Window's wrapper. |
| 174 ScopedTransformOverviewWindow transform_window_; | 210 ScopedTransformOverviewWindow transform_window_; |
| 175 | 211 |
| 176 // The target bounds this selector item is fit within. | 212 // The target bounds this selector item is fit within. |
| 177 gfx::Rect target_bounds_; | 213 gfx::Rect target_bounds_; |
| 178 | 214 |
| 179 // True if running SetItemBounds. This prevents recursive calls resulting from | 215 // True if running SetItemBounds. This prevents recursive calls resulting from |
| 180 // the bounds update when calling ::wm::RecreateWindowLayers to copy | 216 // the bounds update when calling ::wm::RecreateWindowLayers to copy |
| 181 // a window layer for display on another monitor. | 217 // a window layer for display on another monitor. |
| 182 bool in_bounds_update_; | 218 bool in_bounds_update_; |
| 183 | 219 |
| 220 // True when |this| item is visually selected. Item header is made transparent | |
| 221 // when the item is selected. | |
| 222 bool selected_; | |
| 223 | |
| 184 // Label displaying its name (active tab for tabbed windows). | 224 // Label displaying its name (active tab for tabbed windows). |
| 185 // With Material Design this Widget owns |caption_container_view_| and is | 225 // With Material Design this Widget owns |caption_container_view_| and is |
| 186 // shown above the |transform_window_|. | 226 // shown above the |transform_window_|. |
| 187 // Otherwise it is shown under the window. | 227 // Otherwise it is shown under the window. |
| 188 std::unique_ptr<views::Widget> window_label_; | 228 std::unique_ptr<views::Widget> window_label_; |
| 189 | 229 |
| 190 // Shadow around the item in overview. | 230 // Shadow around the item in overview. |
| 191 std::unique_ptr<::wm::Shadow> shadow_; | 231 std::unique_ptr<::wm::Shadow> shadow_; |
| 192 | 232 |
| 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_|. | 233 // Container view that owns |window_label_button_view_| and |close_button_|. |
| 197 // Only used with Material Design. | 234 // Only used with Material Design. |
| 198 CaptionContainerView* caption_container_view_; | 235 CaptionContainerView* caption_container_view_; |
| 199 | 236 |
| 200 // View for the label below the window or (with material design) above it. | 237 // View for the label below the window or (with material design) above it. |
| 201 OverviewLabelButton* window_label_button_view_; | 238 OverviewLabelButton* window_label_button_view_; |
| 202 | 239 |
| 203 // The close buttons widget container. Not used with Material Design. | 240 // The close buttons widget container. Not used with Material Design. |
| 204 std::unique_ptr<views::Widget> close_button_widget_; | 241 std::unique_ptr<views::Widget> close_button_widget_; |
| 205 | 242 |
| 206 // A close button for the window in this item. Owned by the | 243 // A close button for the window in this item. Owned by the |
| 207 // |caption_container_view_| with Material Design or by |close_button_widget_| | 244 // |caption_container_view_| with Material Design or by |close_button_widget_| |
| 208 // otherwise. | 245 // otherwise. |
| 209 views::ImageButton* close_button_; | 246 OverviewCloseButton* close_button_; |
| 210 | 247 |
| 211 // Pointer to the WindowSelector that owns the WindowGrid containing |this|. | 248 // Pointer to the WindowSelector that owns the WindowGrid containing |this|. |
| 212 // Guaranteed to be non-null for the lifetime of |this|. | 249 // Guaranteed to be non-null for the lifetime of |this|. |
| 213 WindowSelector* window_selector_; | 250 WindowSelector* window_selector_; |
| 214 | 251 |
| 252 // Pointer to a view that covers the original header and has rounded top | |
| 253 // corners. This view can have its color and opacity animated. | |
| 254 RoundedContainerView* background_view_; | |
| 255 | |
| 215 // If true, mask the original window header while in overview and make corners | 256 // 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 | 257 // rounded using a mask layer. This has performance implications so it can be |
| 217 // disabled when there are many windows. | 258 // disabled when there are many windows. |
| 218 static bool use_mask_; | 259 static bool use_mask_; |
| 219 | 260 |
| 220 // If true, hide the original window header while in overview using alpha | 261 // 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 | 262 // shape. This has performance implications so it can be disabled when there |
| 222 // are many windows. | 263 // are many windows. |
| 223 static bool use_shape_; | 264 static bool use_shape_; |
| 224 | 265 |
| 225 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); | 266 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); |
| 226 }; | 267 }; |
| 227 | 268 |
| 228 } // namespace ash | 269 } // namespace ash |
| 229 | 270 |
| 230 #endif // ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ | 271 #endif // ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ |
| OLD | NEW |