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

Unified Diff: ui/views/controls/slide_out_controller.h

Issue 2849523005: CrOS: Fix appearance of notification toasts when sliding out via gesture (Closed)
Patch Set: Created 3 years, 8 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: ui/views/controls/slide_out_controller.h
diff --git a/ui/views/controls/slide_out_controller.h b/ui/views/controls/slide_out_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..e5bbaf45cb60111b1f0bd97e2f14b7eedf781e31
--- /dev/null
+++ b/ui/views/controls/slide_out_controller.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 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 UI_VIEWS_CONTROLS_SLIDE_OUT_CONTROLLER_H_
+#define UI_VIEWS_CONTROLS_SLIDE_OUT_CONTROLLER_H_
+
+#include "base/macros.h"
+#include "ui/compositor/layer_animation_observer.h"
+#include "ui/events/scoped_target_handler.h"
+#include "ui/views/view.h"
+#include "ui/views/views_export.h"
+
+namespace views {
+
+// A View that can be closed by a slide-out touch gesture.
sky 2017/04/28 22:35:36 Please update description.
Evan Stade 2017/04/28 23:18:38 Done.
+class VIEWS_EXPORT SlideOutController : public ui::EventHandler,
sky 2017/04/28 22:35:36 I would prefer this code move to where it is used,
Evan Stade 2017/04/28 23:18:38 Done.
+ public ui::ImplicitAnimationObserver {
+ public:
+ class Delegate {
+ public:
+ // Returns the layer to for slide operations.
sky 2017/04/28 22:35:36 'to for' -> 'for' ?
Evan Stade 2017/04/28 23:18:38 Done.
+ virtual ui::Layer* GetSlideOutLayer() = 0;
+
+ // Called when user intends to close the View by sliding it out.
+ virtual void OnSlideOut() = 0;
+ };
+
+ SlideOutController(ui::EventTarget* target, Delegate* delegate);
+ ~SlideOutController() override;
+
+ void set_enabled(bool enabled) { enabled_ = enabled; }
+ bool enabled() { return enabled_; }
+
+ // ui::EventHandler
+ void OnGestureEvent(ui::GestureEvent* event) override;
+
+ // ui::ImplicitAnimationObserver
+ void OnImplicitAnimationsCompleted() override;
+
+ private:
+ enum SlideDirection {
sky 2017/04/28 22:35:36 enum class?
Evan Stade 2017/04/28 23:18:38 removed this.
+ SLIDE_LEFT,
+ SLIDE_RIGHT,
+ };
+
+ // Restores the transform and opacity of the view.
+ void RestoreVisualState();
+
+ // Slides the view out and closes it after the animation.
+ void SlideOutAndClose(SlideDirection direction);
+
+ ui::ScopedTargetHandler target_handling_;
+ Delegate* delegate_;
+
+ float gesture_amount_ = 0.f;
+ bool enabled_ = true;
+
+ DISALLOW_COPY_AND_ASSIGN(SlideOutController);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_CONTROLS_SLIDE_OUT_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698