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

Side by Side Diff: views/touchui/touch_selection_controller_impl.h

Issue 7740024: Implement touch selection menu. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: changed SetBounds to Layout Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ 5 #ifndef VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_
6 #define VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ 6 #define VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/timer.h"
9 #include "ui/gfx/point.h" 10 #include "ui/gfx/point.h"
10 #include "views/touchui/touch_selection_controller.h" 11 #include "views/touchui/touch_selection_controller.h"
11 #include "views/view.h" 12 #include "views/view.h"
12 13
13 namespace views { 14 namespace views {
14 15
15 // Touch specific implementation of TouchSelectionController. Responsible for 16 // Touch specific implementation of TouchSelectionController. Responsible for
16 // displaying selection handles and menu elements relevant in a touch interface. 17 // displaying selection handles and menu elements relevant in a touch interface.
17 class TouchSelectionControllerImpl : public TouchSelectionController { 18 class TouchSelectionControllerImpl : public TouchSelectionController {
18 public: 19 public:
19 // Use TextSelectionController::create(). 20 // Use TextSelectionController::create().
20 explicit TouchSelectionControllerImpl(TouchSelectionClientView* client_view); 21 explicit TouchSelectionControllerImpl(TouchSelectionClientView* client_view);
21 22
22 virtual ~TouchSelectionControllerImpl(); 23 virtual ~TouchSelectionControllerImpl();
23 24
24 // TextSelectionController. 25 // TextSelectionController.
25 virtual void SelectionChanged(const gfx::Point& p1, 26 virtual void SelectionChanged(const gfx::Point& p1,
26 const gfx::Point& p2) OVERRIDE; 27 const gfx::Point& p2) OVERRIDE;
27 28
28 virtual void ClientViewLostFocus() OVERRIDE; 29 virtual void ClientViewLostFocus() OVERRIDE;
29 30
30 private: 31 private:
31 friend class TouchSelectionControllerImplTest; 32 friend class TouchSelectionControllerImplTest;
32 class SelectionHandleView; 33 class SelectionHandleView;
34 class TouchContextMenuView;
33 35
34 // Callback to inform the client view that the selection handle has been 36 // Callback to inform the client view that the selection handle has been
35 // dragged, hence selection may need to be updated. 37 // dragged, hence selection may need to be updated.
36 void SelectionHandleDragged(const gfx::Point& drag_pos); 38 void SelectionHandleDragged(const gfx::Point& drag_pos);
37 39
38 // Convenience method to convert a point from a selection handle's coordinate 40 // Convenience method to convert a point from a selection handle's coordinate
39 // system to that of the client view. 41 // system to that of the client view.
40 void ConvertPointToClientView(SelectionHandleView* source, gfx::Point* point); 42 void ConvertPointToClientView(SelectionHandleView* source, gfx::Point* point);
41 43
44 // Checks if the client view supports a context menu command.
45 bool IsCommandIdEnabled(int command_id) const;
46
47 // Sends a context menu command to the client view.
48 void ExecuteCommand(int command_id);
49
50 // Time to show context menu.
51 void ContextMenuTimerFired();
52
53 // Convenience method to update the position/visibility of the context menu.
54 void UpdateContextMenu(const gfx::Point& p1, const gfx::Point& p2);
55
56 // Convenience method for hiding context menu.
57 void HideContextMenu();
58
42 // Convenience methods for testing. 59 // Convenience methods for testing.
43 gfx::Point GetSelectionHandle1Position(); 60 gfx::Point GetSelectionHandle1Position();
44 gfx::Point GetSelectionHandle2Position(); 61 gfx::Point GetSelectionHandle2Position();
45 bool IsSelectionHandle1Visible(); 62 bool IsSelectionHandle1Visible();
46 bool IsSelectionHandle2Visible(); 63 bool IsSelectionHandle2Visible();
47 64
48 TouchSelectionClientView* client_view_; 65 TouchSelectionClientView* client_view_;
49 scoped_ptr<SelectionHandleView> selection_handle_1_; 66 scoped_ptr<SelectionHandleView> selection_handle_1_;
50 scoped_ptr<SelectionHandleView> selection_handle_2_; 67 scoped_ptr<SelectionHandleView> selection_handle_2_;
68 scoped_ptr<TouchContextMenuView> context_menu_;
69
70 // Timer to trigger |context_menu| (|context_menu| is not shown if the
71 // selection handles are being updated. It appears only when the handles are
72 // stationary for a certain amount of time).
73 base::OneShotTimer<TouchSelectionControllerImpl> context_menu_timer_;
51 74
52 // Pointer to the SelectionHandleView being dragged during a drag session. 75 // Pointer to the SelectionHandleView being dragged during a drag session.
53 SelectionHandleView* dragging_handle_; 76 SelectionHandleView* dragging_handle_;
54 77
55 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImpl); 78 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImpl);
56 }; 79 };
57 80
58 } // namespace views 81 } // namespace views
59 82
60 #endif // VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ 83 #endif // VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_views.cc ('k') | views/touchui/touch_selection_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698