Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 UI_UI_VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ | 5 #ifndef UI_UI_VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ |
| 6 #define UI_UI_VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ | 6 #define UI_UI_VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "ui/aura/window_observer.h" | 9 #include "ui/aura/window_observer.h" |
| 10 #include "ui/base/touch/touch_editing_controller.h" | 10 #include "ui/base/touch/touch_editing_controller.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 bool IsHandleDragInProgress() override; | 41 bool IsHandleDragInProgress() override; |
| 42 void HideHandles(bool quick) override; | 42 void HideHandles(bool quick) override; |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 friend class TouchSelectionControllerImplTest; | 45 friend class TouchSelectionControllerImplTest; |
| 46 friend class test::WidgetTestInteractive; | 46 friend class test::WidgetTestInteractive; |
| 47 | 47 |
| 48 void SetDraggingHandle(EditingHandleView* handle); | 48 void SetDraggingHandle(EditingHandleView* handle); |
| 49 | 49 |
| 50 // Callback to inform the client view that the selection handle has been | 50 // Callback to inform the client view that the selection handle has been |
| 51 // dragged, hence selection may need to be updated. | 51 // dragged, hence selection may need to be updated. |drag_pos| is the new |
| 52 // position for the edge of the selection corresponding to |dragging_handle_|, | |
| 53 // specified in handle's coordinates | |
| 52 void SelectionHandleDragged(const gfx::Point& drag_pos); | 54 void SelectionHandleDragged(const gfx::Point& drag_pos); |
| 53 | 55 |
| 54 // Convenience method to convert a point from a selection handle's coordinate | 56 // Convenience method to convert a point from a selection handle's coordinate |
| 55 // system to that of the client view. | 57 // system to that of the client view. |
| 56 void ConvertPointToClientView(EditingHandleView* source, gfx::Point* point); | 58 void ConvertPointToClientView(EditingHandleView* source, gfx::Point* point); |
| 57 | 59 |
| 58 // Convenience method to set a handle's selection rect and hide it if it is | 60 // Convenience method to set a handle's selection rect and hide it if it is |
|
mohsen
2014/11/07 16:52:27
There are a few comments here and in other files t
mfomitchev
2014/11/10 04:04:12
Done for this file I think. What are the comments
mohsen
2014/11/10 22:25:59
SetHandleSelectionRect() -> SetHandleBound() in to
| |
| 59 // located out of client view. | 61 // located out of client view. |
| 60 void SetHandleSelectionRect(EditingHandleView* handle, const gfx::Rect& rect, | 62 void SetHandleBound(EditingHandleView* handle, |
| 61 const gfx::Rect& rect_in_screen); | 63 const ui::SelectionBound& bound, |
| 64 const ui::SelectionBound& bound_in_screen); | |
| 62 | 65 |
| 63 // Checks if handle should be shown for a selection end-point at |rect|. | 66 // Checks if handle should be shown for a selection end-point at |rect|. |
| 64 // |rect| should be the clipped version of the selection end-point. | 67 // |rect| should be the clipped version of the selection end-point. |
| 65 bool ShouldShowHandleFor(const gfx::Rect& rect) const; | 68 bool ShouldShowHandleFor(const ui::SelectionBound& bound) const; |
| 66 | 69 |
| 67 // Overridden from TouchEditingMenuController. | 70 // Overridden from TouchEditingMenuController. |
| 68 bool IsCommandIdEnabled(int command_id) const override; | 71 bool IsCommandIdEnabled(int command_id) const override; |
| 69 void ExecuteCommand(int command_id, int event_flags) override; | 72 void ExecuteCommand(int command_id, int event_flags) override; |
| 70 void OpenContextMenu() override; | 73 void OpenContextMenu() override; |
| 71 void OnMenuClosed(TouchEditingMenuView* menu) override; | 74 void OnMenuClosed(TouchEditingMenuView* menu) override; |
| 72 | 75 |
| 73 // Overriden from aura::WindowObserver. | 76 // Overriden from aura::WindowObserver. |
| 74 void OnAncestorWindowTransformed(aura::Window* source, | 77 void OnAncestorWindowTransformed(aura::Window* source, |
| 75 aura::Window* window) override; | 78 aura::Window* window) override; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 92 void StartContextMenuTimer(); | 95 void StartContextMenuTimer(); |
| 93 | 96 |
| 94 // Convenience method to update the position/visibility of the context menu. | 97 // Convenience method to update the position/visibility of the context menu. |
| 95 void UpdateContextMenu(); | 98 void UpdateContextMenu(); |
| 96 | 99 |
| 97 // Convenience method for hiding context menu. | 100 // Convenience method for hiding context menu. |
| 98 void HideContextMenu(); | 101 void HideContextMenu(); |
| 99 | 102 |
| 100 // Convenience methods for testing. | 103 // Convenience methods for testing. |
| 101 gfx::NativeView GetCursorHandleNativeView(); | 104 gfx::NativeView GetCursorHandleNativeView(); |
| 102 gfx::Point GetSelectionHandle1Position(); | 105 gfx::Rect GetSelectionHandle1Bounds(); |
| 103 gfx::Point GetSelectionHandle2Position(); | 106 gfx::Rect GetSelectionHandle2Bounds(); |
| 104 gfx::Point GetCursorHandlePosition(); | 107 gfx::Rect GetCursorHandleBounds(); |
| 105 bool IsSelectionHandle1Visible(); | 108 bool IsSelectionHandle1Visible(); |
| 106 bool IsSelectionHandle2Visible(); | 109 bool IsSelectionHandle2Visible(); |
| 107 bool IsCursorHandleVisible(); | 110 bool IsCursorHandleVisible(); |
| 111 gfx::Rect GetExpectedHandleBounds(const ui::SelectionBound& bound); | |
| 112 views::WidgetDelegateView* GetHandle1View(); | |
| 113 views::WidgetDelegateView* GetHandle2View(); | |
| 108 | 114 |
| 109 ui::TouchEditable* client_view_; | 115 ui::TouchEditable* client_view_; |
| 110 Widget* client_widget_; | 116 Widget* client_widget_; |
| 111 scoped_ptr<EditingHandleView> selection_handle_1_; | 117 scoped_ptr<EditingHandleView> selection_handle_1_; |
| 112 scoped_ptr<EditingHandleView> selection_handle_2_; | 118 scoped_ptr<EditingHandleView> selection_handle_2_; |
| 113 scoped_ptr<EditingHandleView> cursor_handle_; | 119 scoped_ptr<EditingHandleView> cursor_handle_; |
| 114 TouchEditingMenuView* context_menu_; | 120 TouchEditingMenuView* context_menu_; |
| 115 | 121 |
| 116 // Timer to trigger |context_menu| (|context_menu| is not shown if the | 122 // Timer to trigger |context_menu| (|context_menu| is not shown if the |
| 117 // selection handles are being updated. It appears only when the handles are | 123 // selection handles are being updated. It appears only when the handles are |
| 118 // stationary for a certain amount of time). | 124 // stationary for a certain amount of time). |
| 119 base::OneShotTimer<TouchSelectionControllerImpl> context_menu_timer_; | 125 base::OneShotTimer<TouchSelectionControllerImpl> context_menu_timer_; |
| 120 | 126 |
| 121 // Pointer to the SelectionHandleView being dragged during a drag session. | 127 // Pointer to the SelectionHandleView being dragged during a drag session. |
| 122 EditingHandleView* dragging_handle_; | 128 EditingHandleView* dragging_handle_; |
| 123 | 129 |
| 124 // Selection end points. In cursor mode, the two end points are the same and | 130 // In cursor mode, the two selection bounds are the same and correspond to |
| 125 // correspond to |cursor_handle_|; otherwise, they correspond to | 131 // |cursor_handle_|; otherwise, they correspond to |selection_handle_1_| and |
| 126 // |selection_handle_1_| and |selection_handle_2_|, respectively. These | 132 // |selection_handle_2_|, respectively. These values should be used when |
| 127 // values should be used when selection end points are needed rather than | 133 // selection bounds needed rather than position of handles which might be |
| 128 // position of handles which might be invalid when handles are hidden. | 134 // invalid when handles are hidden. |
| 129 gfx::Rect selection_end_point_1_; | 135 ui::SelectionBound selection_bound_1_; |
| 130 gfx::Rect selection_end_point_2_; | 136 ui::SelectionBound selection_bound_2_; |
| 131 // Selection end points, clipped to client view's boundaries. | 137 |
| 132 gfx::Rect selection_end_point_1_clipped_; | 138 // Selection bounds, clipped to client view's boundaries. |
| 133 gfx::Rect selection_end_point_2_clipped_; | 139 ui::SelectionBound selection_bound_1_clipped_; |
| 140 ui::SelectionBound selection_bound_2_clipped_; | |
| 134 | 141 |
| 135 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImpl); | 142 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImpl); |
| 136 }; | 143 }; |
| 137 | 144 |
| 138 } // namespace views | 145 } // namespace views |
| 139 | 146 |
| 140 #endif // UI_UI_VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ | 147 #endif // UI_UI_VIEWS_TOUCHUI_TOUCH_SELECTION_CONTROLLER_IMPL_H_ |
| OLD | NEW |