Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: ash/shelf/dimmer_view.h

Issue 2204843003: mash: Move the shelf DimmerView out of shelf_widget.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/ash.gyp ('k') | ash/shelf/dimmer_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_SHELF_DIMMER_VIEW_H_
6 #define ASH_SHELF_DIMMER_VIEW_H_
7
8 #include "ash/common/wm/background_animator.h"
9 #include "ash/common/wm_window_observer.h"
10 #include "base/macros.h"
11 #include "ui/events/event_handler.h"
12 #include "ui/views/view.h"
13 #include "ui/views/widget/widget_delegate.h"
14
15 namespace ash {
16
17 class WmShelf;
18
19 // DimmerView slightly dims shelf items when a window is maximized and visible.
20 class DimmerView : public views::View,
21 public views::WidgetDelegate,
22 public BackgroundAnimatorDelegate,
23 public WmWindowObserver {
24 public:
25 // Creates and shows a DimmerView and its Widget.
26 // If |disable_animations_for_test| is set, all changes apply instantly.
27 static DimmerView* Create(WmShelf* shelf, bool disable_animations_for_test);
28
29 // Called by |DimmerEventFilter| when the mouse |hovered| state changes.
30 void SetHovered(bool hovered);
31
32 // Force the dimmer to be undimmed.
33 void ForceUndimming(bool force);
34
35 // views::View overrides:
36 void OnPaintBackground(gfx::Canvas* canvas) override;
37
38 // views::WidgetDelegate overrides:
39 views::Widget* GetWidget() override;
40 const views::Widget* GetWidget() const override;
41
42 // BackgroundAnimatorDelegate overrides:
43 void UpdateBackground(BackgroundAnimator* animator, int alpha) override;
44 void BackgroundAnimationEnded(BackgroundAnimator* animator) override;
45
46 // WmWindowObserver overrides:
47 // 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
49 // to be repositioned. The difference to the OnBoundsChanged call above is
50 // that this gets also triggered when the shelf only moves.
51 void OnWindowBoundsChanged(WmWindow* window,
52 const gfx::Rect& old_bounds,
53 const gfx::Rect& new_bounds) override;
54
55 // A function to test the current alpha used.
56 int get_dimming_alpha_for_test() { return alpha_; }
57
58 private:
59 DimmerView(WmShelf* shelf, bool disable_animations_for_test);
60 ~DimmerView() override;
61
62 // This class monitors mouse events to see if it is on top of the shelf.
63 class DimmerEventFilter : public ui::EventHandler {
64 public:
65 explicit DimmerEventFilter(DimmerView* owner);
66 ~DimmerEventFilter() override;
67
68 // Overridden from ui::EventHandler:
69 void OnMouseEvent(ui::MouseEvent* event) override;
70 void OnTouchEvent(ui::TouchEvent* event) override;
71
72 private:
73 // The owning class.
74 DimmerView* owner_;
75
76 // True if the mouse is inside the shelf.
77 bool mouse_inside_;
78
79 // True if a touch event is inside the shelf.
80 bool touch_inside_;
81
82 DISALLOW_COPY_AND_ASSIGN(DimmerEventFilter);
83 };
84
85 // The shelf that uses this dimmer.
86 WmShelf* shelf_;
87
88 // The alpha to use for covering the shelf.
89 int alpha_;
90
91 // True if the event filter claims that we should not be dimmed.
92 bool is_hovered_;
93
94 // True if someone forces us not to be dimmed (e.g. a menu is open).
95 bool force_hovered_;
96
97 // True if animations should be suppressed for a test.
98 bool disable_animations_for_test_;
99
100 // The animator for the background transitions.
101 BackgroundAnimator background_animator_;
102
103 // Notification of entering / exiting of the shelf area by mouse.
104 std::unique_ptr<DimmerEventFilter> event_filter_;
105
106 DISALLOW_COPY_AND_ASSIGN(DimmerView);
107 };
108
109 } // namespace ash
110
111 #endif // ASH_SHELF_DIMMER_VIEW_H_
OLDNEW
« no previous file with comments | « ash/ash.gyp ('k') | ash/shelf/dimmer_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698