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

Unified 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: Sync and rebase. 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 side-by-side diff with in-line comments
Download patch
Index: ash/shelf/dimmer_view.h
diff --git a/ash/shelf/dimmer_view.h b/ash/shelf/dimmer_view.h
new file mode 100644
index 0000000000000000000000000000000000000000..cc3405624585c1d079c3e03084cd06e4b96078ad
--- /dev/null
+++ b/ash/shelf/dimmer_view.h
@@ -0,0 +1,104 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
James Cook 2016/08/03 03:09:11 header guards please
msw 2016/08/03 16:48:24 Done.
+#include "ash/common/wm/background_animator.h"
+#include "ash/common/wm_window_observer.h"
+#include "ui/views/view.h"
+#include "ui/views/widget/widget_delegate.h"
James Cook 2016/08/03 03:09:11 base/macros.h too
msw 2016/08/03 16:48:24 Done.
+
James Cook 2016/08/03 03:09:10 event_handler.h too
msw 2016/08/03 16:48:24 Done.
+namespace ash {
+
+class WmShelf;
+
+// Class used to slightly dim shelf items when maximized and visible.
James Cook 2016/08/03 03:09:11 nit: "when a window is maximized and visible"
msw 2016/08/03 16:48:24 Done.
+class DimmerView : public views::View,
+ public views::WidgetDelegate,
+ public BackgroundAnimatorDelegate,
+ public WmWindowObserver {
+ public:
+ // Creates and shows a DimmerView and its Widget.
+ static DimmerView* Create(WmShelf* shelf, bool disable_animations_for_test);
+
+ // If |disable_animations_for_test| is set, all changes apply instantly.
+ DimmerView(WmShelf* shelf, bool disable_animations_for_test);
James Cook 2016/08/03 03:09:11 Could these be private, or are they accessed from
msw 2016/08/03 16:48:24 Done.
+ ~DimmerView() override;
+
+ // Called by |DimmerEventFilter| when the mouse |hovered| state changes.
+ void SetHovered(bool hovered);
+
+ // Force the dimmer to be undimmed.
+ void ForceUndimming(bool force);
+
+ // views::WidgetDelegate overrides:
+ views::Widget* GetWidget() override;
+ const views::Widget* GetWidget() const override;
+
+ // BackgroundAnimatorDelegate overrides:
+ void UpdateBackground(BackgroundAnimator* animator, int alpha) override;
+ void BackgroundAnimationEnded(BackgroundAnimator* animator) override;
+
+ // views::View overrides:
James Cook 2016/08/03 03:09:10 nit: make the overridden function declaration orde
msw 2016/08/03 16:48:24 Done.
+ void OnPaintBackground(gfx::Canvas* canvas) override;
+
+ // WmWindowObserver overrides:
+ // This will be called when the shelf itself changes its absolute position.
+ // Since the |dimmer_| panel needs to be placed in screen coordinates it needs
+ // to be repositioned. The difference to the OnBoundsChanged call above is
+ // that this gets also triggered when the shelf only moves.
+ void OnWindowBoundsChanged(WmWindow* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override;
+
+ // A function to test the current alpha used.
+ int get_dimming_alpha_for_test() { return alpha_; }
+
+ private:
+ // This class monitors mouse events to see if it is on top of the shelf.
+ class DimmerEventFilter : public ui::EventHandler {
+ public:
+ explicit DimmerEventFilter(DimmerView* owner);
+ ~DimmerEventFilter() override;
+
+ // Overridden from ui::EventHandler:
+ void OnMouseEvent(ui::MouseEvent* event) override;
+ void OnTouchEvent(ui::TouchEvent* event) override;
+
+ private:
+ // The owning class.
+ DimmerView* owner_;
+
+ // TRUE if the mouse is inside the shelf.
James Cook 2016/08/03 03:09:11 nit: TRUE -> True, and below. Some previous code a
msw 2016/08/03 16:48:24 Done.
+ bool mouse_inside_;
+
+ // TRUE if a touch event is inside the shelf.
+ bool touch_inside_;
+
+ DISALLOW_COPY_AND_ASSIGN(DimmerEventFilter);
+ };
+
+ // The shelf that uses this dimmer.
+ WmShelf* shelf_;
+
+ // The alpha to use for covering the shelf.
+ int alpha_;
+
+ // True if the event filter claims that we should not be dimmed.
+ bool is_hovered_;
+
+ // True if someone forces us not to be dimmed (e.g. a menu is open).
+ bool force_hovered_;
+
+ // True if animations should be suppressed for a test.
+ bool disable_animations_for_test_;
+
+ // The animator for the background transitions.
+ BackgroundAnimator background_animator_;
+
+ // Notification of entering / exiting of the shelf area by mouse.
+ std::unique_ptr<DimmerEventFilter> event_filter_;
+
+ DISALLOW_COPY_AND_ASSIGN(DimmerView);
+};
+
+} // namespace ash
« no previous file with comments | « ash/ash.gyp ('k') | ash/shelf/dimmer_view.cc » ('j') | ash/shelf/dimmer_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698