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

Side by Side Diff: ui/views/scoped_target_handler.h

Issue 1411833006: Refactoring to make adding ink drop animations easier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor ink drop animations (nits in ui/views/ Created 5 years 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 | « ui/views/controls/button/menu_button.cc ('k') | ui/views/scoped_target_handler.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 2015 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 UI_VIEWS_SCOPED_TARGET_HANDLER_H_
6 #define UI_VIEWS_SCOPED_TARGET_HANDLER_H_
7
8 #include "base/macros.h"
9 #include "ui/events/event_handler.h"
10 #include "ui/views/views_export.h"
11
12 namespace views {
13
14 class View;
15
16 // An EventHandler that replaces an View's target handler with itself to pass
17 // events first to the original handlers and second to an additional new
18 // EventHandler. The new handler gets called after the original handlers even
19 // if they call SetHandled() or StopPropagation() on the event.
20 class VIEWS_EXPORT ScopedTargetHandler : public ui::EventHandler {
21 public:
22 ScopedTargetHandler(View* view, ui::EventHandler* new_handler);
23 ~ScopedTargetHandler() override;
24
25 // ui::EventHandler:
26 void OnEvent(ui::Event* event) override;
27 void OnKeyEvent(ui::KeyEvent* event) override;
28 void OnMouseEvent(ui::MouseEvent* event) override;
29 void OnScrollEvent(ui::ScrollEvent* event) override;
30 void OnTouchEvent(ui::TouchEvent* event) override;
31 void OnGestureEvent(ui::GestureEvent* event) override;
32 void OnCancelMode(ui::CancelModeEvent* event) override;
33
34 private:
35 // If non-null the destructor sets this to true. This is set while handling
36 // an event and used to detect if |this| has been deleted.
37 bool* destroyed_flag_;
38
39 // An View that has its target handler replaced with |this| for a life time of
40 // |this|.
41 View* view_;
42
43 // An EventHandler that gets restored on |view_| when |this| is destroyed.
44 ui::EventHandler* original_handler_;
45
46 // A new handler that gets events in addition to the |original_handler_| or
47 // |view_|.
48 ui::EventHandler* new_handler_;
49
50 DISALLOW_COPY_AND_ASSIGN(ScopedTargetHandler);
51 };
52
53 } // namespace views
54
55 #endif // UI_VIEWS_SCOPED_TARGET_HANDLER_H_
OLDNEW
« no previous file with comments | « ui/views/controls/button/menu_button.cc ('k') | ui/views/scoped_target_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698