| 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_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| 6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 6 #define ASH_COMMON_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" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 // views::View: | 72 // views::View: |
| 73 void SetVisible(bool visible) override; | 73 void SetVisible(bool visible) override; |
| 74 const char* GetClassName() const override; | 74 const char* GetClassName() const override; |
| 75 void ChildPreferredSizeChanged(views::View* child) override; | 75 void ChildPreferredSizeChanged(views::View* child) override; |
| 76 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 76 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 77 void AboutToRequestFocusFromTabTraversal(bool reverse) override; | 77 void AboutToRequestFocusFromTabTraversal(bool reverse) override; |
| 78 void OnPaint(gfx::Canvas* canvas) override; | 78 void OnPaint(gfx::Canvas* canvas) override; |
| 79 | 79 |
| 80 // ActionableView: | 80 // ActionableView: |
| 81 bool PerformAction(const ui::Event& event) override; | 81 std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override; |
| 82 gfx::Rect GetFocusBounds() override; | 82 std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight() |
| 83 const override; |
| 83 void OnGestureEvent(ui::GestureEvent* event) override; | 84 void OnGestureEvent(ui::GestureEvent* event) override; |
| 84 | 85 |
| 85 // Called whenever the shelf alignment changes. | 86 // Called whenever the shelf alignment changes. |
| 86 virtual void SetShelfAlignment(ShelfAlignment alignment); | 87 virtual void SetShelfAlignment(ShelfAlignment alignment); |
| 87 | 88 |
| 88 // Called when the anchor (tray or bubble) may have moved or changed. | 89 // Called when the anchor (tray or bubble) may have moved or changed. |
| 89 virtual void AnchorUpdated() {} | 90 virtual void AnchorUpdated() {} |
| 90 | 91 |
| 91 // Called from GetAccessibleNodeData, must return a valid accessible name. | 92 // Called from GetAccessibleNodeData, must return a valid accessible name. |
| 92 virtual base::string16 GetAccessibleNameForTray() = 0; | 93 virtual base::string16 GetAccessibleNameForTray() = 0; |
| 93 | 94 |
| 94 // Called when the bubble is resized. | 95 // Called when the bubble is resized. |
| 95 virtual void BubbleResized(const views::TrayBubbleView* bubble_view) {} | 96 virtual void BubbleResized(const views::TrayBubbleView* bubble_view) {} |
| 96 | 97 |
| 97 // Hides the bubble associated with |bubble_view|. Called when the widget | 98 // Hides the bubble associated with |bubble_view|. Called when the widget |
| 98 // is closed. | 99 // is closed. |
| 99 virtual void HideBubbleWithView(const views::TrayBubbleView* bubble_view) = 0; | 100 virtual void HideBubbleWithView(const views::TrayBubbleView* bubble_view) = 0; |
| 100 | 101 |
| 101 // Called by the bubble wrapper when a click event occurs outside the bubble. | 102 // Called by the bubble wrapper when a click event occurs outside the bubble. |
| 102 // May close the bubble. | 103 // May close the bubble. |
| 103 virtual void ClickedOutsideBubble() = 0; | 104 virtual void ClickedOutsideBubble() = 0; |
| 104 | 105 |
| 105 // Sets |contents| as a child. | 106 // Sets |contents| as a child. |
| 106 void SetContents(views::View* contents); | 107 void SetContents(views::View* contents); |
| 107 | 108 |
| 108 // Creates and sets contents background to |background_|. | 109 // Creates and sets contents background to |background_|. |draws_active| |
| 109 void SetContentsBackground(); | 110 // determines if the view's background should be drawn as active when the view |
| 111 // is in the active state. |
| 112 void SetContentsBackground(bool draws_active); |
| 110 | 113 |
| 111 // Returns the anchor rect for the bubble. | 114 // Returns the anchor rect for the bubble. |
| 112 gfx::Rect GetBubbleAnchorRect( | 115 gfx::Rect GetBubbleAnchorRect( |
| 113 views::Widget* anchor_widget, | 116 views::Widget* anchor_widget, |
| 114 views::TrayBubbleView::AnchorType anchor_type, | 117 views::TrayBubbleView::AnchorType anchor_type, |
| 115 views::TrayBubbleView::AnchorAlignment anchor_alignment) const; | 118 views::TrayBubbleView::AnchorAlignment anchor_alignment) const; |
| 116 | 119 |
| 117 // Returns the bubble anchor alignment based on |shelf_alignment_|. | 120 // Returns the bubble anchor alignment based on |shelf_alignment_|. |
| 118 views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() const; | 121 views::TrayBubbleView::AnchorAlignment GetAnchorAlignment() const; |
| 119 | 122 |
| 120 // Forces the background to be drawn active if set to true. | 123 void SetIsActive(bool is_active); |
| 121 void SetDrawBackgroundAsActive(bool visible); | 124 bool is_active() const { return is_active_; } |
| 122 | |
| 123 // Returns true when the the background was overridden to be drawn as active. | |
| 124 bool draw_background_as_active() const { return draw_background_as_active_; } | |
| 125 | 125 |
| 126 TrayContainer* tray_container() const { return tray_container_; } | 126 TrayContainer* tray_container() const { return tray_container_; } |
| 127 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } | 127 ShelfAlignment shelf_alignment() const { return shelf_alignment_; } |
| 128 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } | 128 TrayEventFilter* tray_event_filter() { return tray_event_filter_.get(); } |
| 129 WmShelf* shelf() { return wm_shelf_; } | 129 WmShelf* shelf() { return wm_shelf_; } |
| 130 | 130 |
| 131 // Updates the arrow visibility based on the launcher visibility. | 131 // Updates the arrow visibility based on the launcher visibility. |
| 132 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); | 132 void UpdateBubbleViewArrow(views::TrayBubbleView* bubble_view); |
| 133 | 133 |
| 134 // ShelfBackgroundAnimatorObserver: | 134 // ShelfBackgroundAnimatorObserver: |
| 135 void UpdateShelfItemBackground(int alpha) override; | 135 void UpdateShelfItemBackground(int alpha) override; |
| 136 | 136 |
| 137 // Updates the visibility of this tray's separator. | 137 // Updates the visibility of this tray's separator. |
| 138 void SetSeparatorVisibility(bool is_show); | 138 void SetSeparatorVisibility(bool is_show); |
| 139 | 139 |
| 140 protected: |
| 141 // ActionableView: |
| 142 bool ShouldEnterPushedState(const ui::Event& event) override; |
| 143 bool PerformAction(const ui::Event& event) override; |
| 144 void HandlePerformActionResult(bool action_performed, |
| 145 const ui::Event& event) override; |
| 146 gfx::Rect GetFocusBounds() override; |
| 147 |
| 140 private: | 148 private: |
| 141 class TrayWidgetObserver; | 149 class TrayWidgetObserver; |
| 142 | 150 |
| 143 // ui::ImplicitAnimationObserver: | 151 // ui::ImplicitAnimationObserver: |
| 144 void OnImplicitAnimationsCompleted() override; | 152 void OnImplicitAnimationsCompleted() override; |
| 145 bool RequiresNotificationWhenAnimatorDestroyed() const override; | 153 bool RequiresNotificationWhenAnimatorDestroyed() const override; |
| 146 | 154 |
| 147 // Applies transformations to the |layer()| to animate the view when | 155 // Applies transformations to the |layer()| to animate the view when |
| 148 // SetVisible(false) is called. | 156 // SetVisible(false) is called. |
| 149 void HideTransformation(); | 157 void HideTransformation(); |
| 150 | 158 |
| 151 // The shelf containing the system tray for this view. | 159 // The shelf containing the system tray for this view. |
| 152 WmShelf* wm_shelf_; | 160 WmShelf* wm_shelf_; |
| 153 | 161 |
| 154 // Convenience pointer to the contents view. | 162 // Convenience pointer to the contents view. |
| 155 TrayContainer* tray_container_; | 163 TrayContainer* tray_container_; |
| 156 | 164 |
| 157 // Shelf alignment. | 165 // Shelf alignment. |
| 158 // TODO(jamescook): Don't cache this, get it from WmShelf. | 166 // TODO(jamescook): Don't cache this, get it from WmShelf. |
| 159 ShelfAlignment shelf_alignment_; | 167 ShelfAlignment shelf_alignment_; |
| 160 | 168 |
| 161 // Owned by the view passed to SetContents(). | 169 // Owned by the view passed to SetContents(). |
| 162 TrayBackground* background_; | 170 TrayBackground* background_; |
| 163 | 171 |
| 164 // This variable stores the activation override which will tint the background | 172 // Determines if the view is active. This changes how the background is drawn |
| 165 // differently if set to true. | 173 // in non-MD version and how the ink drop ripples behave in MD version. |
| 166 bool draw_background_as_active_; | 174 bool is_active_; |
| 167 | 175 |
| 168 // Visibility of this tray's separator which is a line of 1x32px and 4px to | 176 // Visibility of this tray's separator which is a line of 1x32px and 4px to |
| 169 // right of tray. | 177 // right of tray. |
| 170 bool is_separator_visible_; | 178 bool is_separator_visible_; |
| 171 | 179 |
| 172 std::unique_ptr<TrayWidgetObserver> widget_observer_; | 180 std::unique_ptr<TrayWidgetObserver> widget_observer_; |
| 173 std::unique_ptr<TrayEventFilter> tray_event_filter_; | 181 std::unique_ptr<TrayEventFilter> tray_event_filter_; |
| 174 | 182 |
| 175 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); | 183 DISALLOW_COPY_AND_ASSIGN(TrayBackgroundView); |
| 176 }; | 184 }; |
| 177 | 185 |
| 178 } // namespace ash | 186 } // namespace ash |
| 179 | 187 |
| 180 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ | 188 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_BACKGROUND_VIEW_H_ |
| OLD | NEW |