Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 5 #ifndef ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| 6 #define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 6 #define ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_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/shelf/shelf_background_animator_observer.h" | 11 #include "ash/shelf/shelf_background_animator_observer.h" |
| 12 #include "ash/system/tray/actionable_view.h" | 12 #include "ash/system/tray/actionable_view.h" |
| 13 #include "ash/system/tray_drag_controller.h" | |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "ui/compositor/layer_animation_observer.h" | 15 #include "ui/compositor/layer_animation_observer.h" |
| 15 #include "ui/gfx/geometry/insets.h" | 16 #include "ui/gfx/geometry/insets.h" |
| 16 #include "ui/views/bubble/tray_bubble_view.h" | 17 #include "ui/views/bubble/tray_bubble_view.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 class Shelf; | 20 class Shelf; |
| 20 class TrayBackground; | 21 class TrayBackground; |
| 21 class TrayContainer; | 22 class TrayContainer; |
| 22 class TrayEventFilter; | 23 class TrayEventFilter; |
| 23 | 24 |
| 24 // Base class for some children of StatusAreaWidget. This class handles setting | 25 // Base class for some children of StatusAreaWidget. This class handles setting |
| 25 // and animating the background when the Launcher is shown/hidden. It also | 26 // and animating the background when the Launcher is shown/hidden. It also |
| 26 // inherits from ActionableView so that the tray items can override | 27 // inherits from ActionableView so that the tray items can override |
| 27 // PerformAction when clicked on. | 28 // PerformAction when clicked on. |
| 28 class ASH_EXPORT TrayBackgroundView : public ActionableView, | 29 class ASH_EXPORT TrayBackgroundView : public ActionableView, |
| 29 public ui::ImplicitAnimationObserver, | 30 public ui::ImplicitAnimationObserver, |
| 30 public ShelfBackgroundAnimatorObserver { | 31 public ShelfBackgroundAnimatorObserver, |
| 32 public views::TrayBubbleView::Delegate { | |
| 31 public: | 33 public: |
| 32 static const char kViewClassName[]; | 34 static const char kViewClassName[]; |
| 33 | 35 |
| 34 explicit TrayBackgroundView(Shelf* shelf); | 36 explicit TrayBackgroundView(Shelf* shelf); |
| 35 ~TrayBackgroundView() override; | 37 ~TrayBackgroundView() override; |
| 36 | 38 |
| 37 // Called after the tray has been added to the widget containing it. | 39 // Called after the tray has been added to the widget containing it. |
| 38 virtual void Initialize(); | 40 virtual void Initialize(); |
| 39 | 41 |
| 40 // Initializes animations for the bubble. | 42 // Initializes animations for the bubble. |
| 41 static void InitializeBubbleAnimations(views::Widget* bubble_widget); | 43 static void InitializeBubbleAnimations(views::Widget* bubble_widget); |
| 42 | 44 |
| 43 // views::View: | 45 // views::View: |
| 44 void SetVisible(bool visible) override; | 46 void SetVisible(bool visible) override; |
| 45 const char* GetClassName() const override; | 47 const char* GetClassName() const override; |
| 46 void ChildPreferredSizeChanged(views::View* child) override; | 48 void ChildPreferredSizeChanged(views::View* child) override; |
| 47 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 49 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 48 void AboutToRequestFocusFromTabTraversal(bool reverse) override; | 50 void AboutToRequestFocusFromTabTraversal(bool reverse) override; |
| 51 void OnGestureEvent(ui::GestureEvent* event) override; | |
|
msw
2017/07/17 19:28:01
nit: reorder this and the definition to match view
minch1
2017/07/17 20:41:11
Done.
| |
| 49 | 52 |
| 50 // ActionableView: | 53 // ActionableView: |
| 51 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; | 54 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; |
| 52 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() | 55 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
| 53 const override; | 56 const override; |
| 54 void PaintButtonContents(gfx::Canvas* canvas) override; | 57 void PaintButtonContents(gfx::Canvas* canvas) override; |
| 55 | 58 |
| 59 // TrayBubbleView::Delegate: | |
| 60 bool ProcessGestureEventForBubble(ui::GestureEvent* event) override; | |
| 61 | |
| 62 // Gets the associated tray bubble view. | |
| 63 virtual views::TrayBubbleView* GetBubbleView(); | |
| 64 | |
| 65 // Closes the associated tray bubble view if it is currently showing. | |
| 66 virtual void CloseBubble() {} | |
| 67 | |
| 68 // Shows the associated tray bubble. | |
| 69 virtual void ShowBubble() {} | |
| 70 | |
| 56 // Called whenever the shelf alignment changes. | 71 // Called whenever the shelf alignment changes. |
| 57 virtual void UpdateAfterShelfAlignmentChange(); | 72 virtual void UpdateAfterShelfAlignmentChange(); |
| 58 | 73 |
| 59 // Called when the anchor (tray or bubble) may have moved or changed. | 74 // Called when the anchor (tray or bubble) may have moved or changed. |
| 60 virtual void AnchorUpdated() {} | 75 virtual void AnchorUpdated() {} |
| 61 | 76 |
| 62 // Called from GetAccessibleNodeData, must return a valid accessible name. | 77 // Called from GetAccessibleNodeData, must return a valid accessible name. |
| 63 virtual base::string16 GetAccessibleNameForTray() = 0; | 78 virtual base::string16 GetAccessibleNameForTray() = 0; |
| 64 | 79 |
| 65 // Called when the bubble is resized. | 80 // Called when the bubble is resized. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 93 void set_separator_visibility(bool visible) { separator_visible_ = visible; } | 108 void set_separator_visibility(bool visible) { separator_visible_ = visible; } |
| 94 | 109 |
| 95 // Gets the anchor for bubbles, which is tray_container(). | 110 // Gets the anchor for bubbles, which is tray_container(). |
| 96 views::View* GetBubbleAnchor() const; | 111 views::View* GetBubbleAnchor() const; |
| 97 | 112 |
| 98 // Gets additional insets for positioning bubbles relative to | 113 // Gets additional insets for positioning bubbles relative to |
| 99 // tray_container(). | 114 // tray_container(). |
| 100 gfx::Insets GetBubbleAnchorInsets() const; | 115 gfx::Insets GetBubbleAnchorInsets() const; |
| 101 | 116 |
| 102 // Returns the container window for the bubble (on the proper display). | 117 // Returns the container window for the bubble (on the proper display). |
| 103 aura::Window* GetBubbleWindowContainer() const; | 118 aura::Window* GetBubbleWindowContainer(); |
| 119 | |
| 120 // Update the bounds of the associated tray bubble. Close the bubble if | |
| 121 // |close_bubble| is set. | |
| 122 void AnimateToTargetBounds(const gfx::Rect& target_bounds, bool close_bubble); | |
| 104 | 123 |
| 105 protected: | 124 protected: |
| 106 // ActionableView: | 125 // ActionableView: |
| 107 std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override; | 126 std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override; |
| 108 bool ShouldEnterPushedState(const ui::Event& event) override; | 127 bool ShouldEnterPushedState(const ui::Event& event) override; |
| 109 bool PerformAction(const ui::Event& event) override; | 128 bool PerformAction(const ui::Event& event) override; |
| 110 void HandlePerformActionResult(bool action_performed, | 129 void HandlePerformActionResult(bool action_performed, |
| 111 const ui::Event& event) override; | 130 const ui::Event& event) override; |
| 112 | 131 |
| 113 private: | 132 private: |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 138 TrayBackground* background_; | 157 TrayBackground* background_; |
| 139 | 158 |
| 140 // Determines if the view is active. This changes how the ink drop ripples | 159 // Determines if the view is active. This changes how the ink drop ripples |
| 141 // behave. | 160 // behave. |
| 142 bool is_active_; | 161 bool is_active_; |
| 143 | 162 |
| 144 // Visibility of this tray's separator which is a line of 1x32px and 4px to | 163 // Visibility of this tray's separator which is a line of 1x32px and 4px to |
| 145 // right of tray. | 164 // right of tray. |
| 146 bool separator_visible_; | 165 bool separator_visible_; |
| 147 | 166 |
| 167 // Handles touch drag gestures on the tray area and its associated bubble. | |
| 168 std::unique_ptr<TrayDragController> drag_controller_; | |
| 169 | |
| 170 // Used in maximize mode to make sure the system tray bubble only be shown in | |
| 171 // work area. | |
| 172 std::unique_ptr<aura::Window> clipping_window_; | |
| 173 | |
| 148 std::unique_ptr<TrayWidgetObserver> widget_observer_; | 174 std::unique_ptr<TrayWidgetObserver> widget_observer_; |
| 149 std::unique_ptr<TrayEventFilter> tray_event_filter_; | 175 std::unique_ptr<TrayEventFilter> tray_event_filter_; |
| 150 | 176 |
| 151 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); | 177 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); |
| 152 }; | 178 }; |
| 153 | 179 |
| 154 } // namespace ash | 180 } // namespace ash |
| 155 | 181 |
| 156 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 182 #endif // ASH_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| OLD | NEW |