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

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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/ash.gyp ('k') | ash/shelf/dimmer_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0a4ff07a1c7b5b0b2ef4a7bb3a780dae36fa7611
--- /dev/null
+++ b/ash/shelf/dimmer_view.h
@@ -0,0 +1,111 @@
+// 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.
+
+#ifndef ASH_SHELF_DIMMER_VIEW_H_
+#define ASH_SHELF_DIMMER_VIEW_H_
+
+#include "ash/common/wm/background_animator.h"
+#include "ash/common/wm_window_observer.h"
+#include "base/macros.h"
+#include "ui/events/event_handler.h"
+#include "ui/views/view.h"
+#include "ui/views/widget/widget_delegate.h"
+
+namespace ash {
+
+class WmShelf;
+
+// DimmerView slightly dims shelf items when a window is maximized and visible.
+class DimmerView : public views::View,
+ public views::WidgetDelegate,
+ public BackgroundAnimatorDelegate,
+ public WmWindowObserver {
+ public:
+ // Creates and shows a DimmerView and its Widget.
+ // If |disable_animations_for_test| is set, all changes apply instantly.
+ static DimmerView* Create(WmShelf* shelf, bool disable_animations_for_test);
+
+ // Called by |DimmerEventFilter| when the mouse |hovered| state changes.
+ void SetHovered(bool hovered);
+
+ // Force the dimmer to be undimmed.
+ void ForceUndimming(bool force);
+
+ // views::View overrides:
+ void OnPaintBackground(gfx::Canvas* canvas) override;
+
+ // 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;
+
+ // 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:
+ DimmerView(WmShelf* shelf, bool disable_animations_for_test);
+ ~DimmerView() override;
+
+ // 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.
+ 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
+
+#endif // ASH_SHELF_DIMMER_VIEW_H_
« 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