| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SHELF_DIMMER_VIEW_H_ | 5 #ifndef ASH_SHELF_DIMMER_VIEW_H_ |
| 6 #define ASH_SHELF_DIMMER_VIEW_H_ | 6 #define ASH_SHELF_DIMMER_VIEW_H_ |
| 7 | 7 |
| 8 #include "ash/common/shelf/wm_dimmer_view.h" |
| 8 #include "ash/common/wm/background_animator.h" | 9 #include "ash/common/wm/background_animator.h" |
| 9 #include "ash/common/wm_window_observer.h" | 10 #include "ash/common/wm_window_observer.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "ui/events/event_handler.h" | 12 #include "ui/events/event_handler.h" |
| 12 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
| 13 #include "ui/views/widget/widget_delegate.h" | 14 #include "ui/views/widget/widget_delegate.h" |
| 14 | 15 |
| 15 namespace ash { | 16 namespace ash { |
| 16 | 17 |
| 17 class WmShelf; | 18 class WmShelf; |
| 18 | 19 |
| 19 // DimmerView slightly dims shelf items when a window is maximized and visible. | 20 // DimmerView slightly dims shelf items when a window is maximized and visible. |
| 21 // TODO(jamescook): Delete this after material design ships, as MD will not |
| 22 // require shelf dimming. http://crbug.com/614453 |
| 20 class DimmerView : public views::View, | 23 class DimmerView : public views::View, |
| 21 public views::WidgetDelegate, | 24 public views::WidgetDelegate, |
| 22 public BackgroundAnimatorDelegate, | 25 public BackgroundAnimatorDelegate, |
| 26 public WmDimmerView, |
| 23 public WmWindowObserver { | 27 public WmWindowObserver { |
| 24 public: | 28 public: |
| 25 // Creates and shows a DimmerView and its Widget. | 29 // Creates and shows a DimmerView and its Widget. The returned view is owned |
| 26 // If |disable_animations_for_test| is set, all changes apply instantly. | 30 // by its widget. If |disable_animations_for_test| is set, all changes apply |
| 31 // instantly. |
| 27 static DimmerView* Create(WmShelf* shelf, bool disable_animations_for_test); | 32 static DimmerView* Create(WmShelf* shelf, bool disable_animations_for_test); |
| 28 | 33 |
| 29 // Called by |DimmerEventFilter| when the mouse |hovered| state changes. | 34 // Called by |DimmerEventFilter| when the mouse |hovered| state changes. |
| 30 void SetHovered(bool hovered); | 35 void SetHovered(bool hovered); |
| 31 | 36 |
| 32 // Force the dimmer to be undimmed. | |
| 33 void ForceUndimming(bool force); | |
| 34 | |
| 35 // views::View overrides: | 37 // views::View overrides: |
| 36 void OnPaintBackground(gfx::Canvas* canvas) override; | 38 void OnPaintBackground(gfx::Canvas* canvas) override; |
| 37 | 39 |
| 38 // views::WidgetDelegate overrides: | 40 // views::WidgetDelegate overrides: |
| 39 views::Widget* GetWidget() override; | 41 views::Widget* GetWidget() override; |
| 40 const views::Widget* GetWidget() const override; | 42 const views::Widget* GetWidget() const override; |
| 41 | 43 |
| 42 // BackgroundAnimatorDelegate overrides: | 44 // BackgroundAnimatorDelegate overrides: |
| 43 void UpdateBackground(BackgroundAnimator* animator, int alpha) override; | 45 void UpdateBackground(BackgroundAnimator* animator, int alpha) override; |
| 44 void BackgroundAnimationEnded(BackgroundAnimator* animator) override; | 46 void BackgroundAnimationEnded(BackgroundAnimator* animator) override; |
| 45 | 47 |
| 48 // WmDimmerView: |
| 49 views::Widget* GetDimmerWidget() override; |
| 50 void ForceUndimming(bool force) override; |
| 51 int GetDimmingAlphaForTest() override; |
| 52 |
| 46 // WmWindowObserver overrides: | 53 // WmWindowObserver overrides: |
| 47 // This will be called when the shelf itself changes its absolute position. | 54 // This will be called when the shelf itself changes its absolute position. |
| 48 // Since the |dimmer_| panel needs to be placed in screen coordinates it needs | 55 // Since the |dimmer_| panel needs to be placed in screen coordinates it needs |
| 49 // to be repositioned. The difference to the OnBoundsChanged call above is | 56 // to be repositioned. The difference to the OnBoundsChanged call above is |
| 50 // that this gets also triggered when the shelf only moves. | 57 // that this gets also triggered when the shelf only moves. |
| 51 void OnWindowBoundsChanged(WmWindow* window, | 58 void OnWindowBoundsChanged(WmWindow* window, |
| 52 const gfx::Rect& old_bounds, | 59 const gfx::Rect& old_bounds, |
| 53 const gfx::Rect& new_bounds) override; | 60 const gfx::Rect& new_bounds) override; |
| 54 | 61 |
| 55 // A function to test the current alpha used. | |
| 56 int get_dimming_alpha_for_test() { return alpha_; } | |
| 57 | |
| 58 private: | 62 private: |
| 59 DimmerView(WmShelf* shelf, bool disable_animations_for_test); | 63 DimmerView(WmShelf* shelf, bool disable_animations_for_test); |
| 60 ~DimmerView() override; | 64 ~DimmerView() override; |
| 61 | 65 |
| 62 // This class monitors mouse events to see if it is on top of the shelf. | 66 // This class monitors mouse events to see if it is on top of the shelf. |
| 63 class DimmerEventFilter : public ui::EventHandler { | 67 class DimmerEventFilter : public ui::EventHandler { |
| 64 public: | 68 public: |
| 65 explicit DimmerEventFilter(DimmerView* owner); | 69 explicit DimmerEventFilter(DimmerView* owner); |
| 66 ~DimmerEventFilter() override; | 70 ~DimmerEventFilter() override; |
| 67 | 71 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 106 |
| 103 // Notification of entering / exiting of the shelf area by mouse. | 107 // Notification of entering / exiting of the shelf area by mouse. |
| 104 std::unique_ptr<DimmerEventFilter> event_filter_; | 108 std::unique_ptr<DimmerEventFilter> event_filter_; |
| 105 | 109 |
| 106 DISALLOW_COPY_AND_ASSIGN(DimmerView); | 110 DISALLOW_COPY_AND_ASSIGN(DimmerView); |
| 107 }; | 111 }; |
| 108 | 112 |
| 109 } // namespace ash | 113 } // namespace ash |
| 110 | 114 |
| 111 #endif // ASH_SHELF_DIMMER_VIEW_H_ | 115 #endif // ASH_SHELF_DIMMER_VIEW_H_ |
| OLD | NEW |