| 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_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ | 5 #ifndef UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ |
| 6 #define UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ | 6 #define UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ui/base/models/simple_menu_model.h" | 8 #include "ui/base/models/simple_menu_model.h" |
| 9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
| 10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 | 13 |
| 14 // An interface implemented by widget that has text that can be selected/edited | 14 // An interface implemented by widget that has text that can be selected/edited |
| 15 // using touch. | 15 // using touch. |
| 16 class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { | 16 class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { |
| 17 public: | 17 public: |
| 18 // TODO(mohsen): Consider switching from local coordinates to screen |
| 19 // coordinates in this interface and see if it will simplify things. |
| 20 |
| 18 // Select everything between start and end (points are in view's local | 21 // Select everything between start and end (points are in view's local |
| 19 // coordinate system). |start| is the logical start and |end| is the logical | 22 // coordinate system). |start| is the logical start and |end| is the logical |
| 20 // end of selection. Visually, |start| may lie after |end|. | 23 // end of selection. Visually, |start| may lie after |end|. |
| 21 virtual void SelectRect(const gfx::Point& start, const gfx::Point& end) = 0; | 24 virtual void SelectRect(const gfx::Point& start, const gfx::Point& end) = 0; |
| 22 | 25 |
| 23 // Move the caret to |point|. |point| is in local coordinates. | 26 // Move the caret to |point|. |point| is in local coordinates. |
| 24 virtual void MoveCaretTo(const gfx::Point& point) = 0; | 27 virtual void MoveCaretTo(const gfx::Point& point) = 0; |
| 25 | 28 |
| 26 // Gets the end points of the current selection. The end points p1 and p2 must | 29 // Gets the end points of the current selection. The end points p1 and p2 must |
| 27 // be the cursor rect for the start and end of selection: | 30 // be the cursor rect for the start and end of selection (in local |
| 31 // coordinates): |
| 28 // ____________________________________ | 32 // ____________________________________ |
| 29 // | textfield with |selected text| | | 33 // | textfield with |selected text| | |
| 30 // ------------------------------------ | 34 // ------------------------------------ |
| 31 // ^p1 ^p2 | 35 // ^p1 ^p2 |
| 32 // | 36 // |
| 33 // p1 should be the logical start and p2 the logical end of selection. Hence, | 37 // p1 should be the logical start and p2 the logical end of selection. Hence, |
| 34 // visually, p1 could be to the right of p2 in the figure above. | 38 // visually, p1 could be to the right of p2 in the figure above. |
| 35 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) = 0; | 39 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) = 0; |
| 36 | 40 |
| 37 // Gets the bounds of the client view in parent's coordinates. | 41 // Gets the bounds of the client view in its local coordinates. |
| 38 virtual gfx::Rect GetBounds() = 0; | 42 virtual gfx::Rect GetBounds() = 0; |
| 39 | 43 |
| 40 // Gets the NativeView hosting the client. | 44 // Gets the NativeView hosting the client. |
| 41 virtual gfx::NativeView GetNativeView() const = 0; | 45 virtual gfx::NativeView GetNativeView() const = 0; |
| 42 | 46 |
| 43 // Converts a point to/from screen coordinates from/to client view. | 47 // Converts a point to/from screen coordinates from/to client view. |
| 44 virtual void ConvertPointToScreen(gfx::Point* point) = 0; | 48 virtual void ConvertPointToScreen(gfx::Point* point) = 0; |
| 45 virtual void ConvertPointFromScreen(gfx::Point* point) = 0; | 49 virtual void ConvertPointFromScreen(gfx::Point* point) = 0; |
| 46 | 50 |
| 47 // Returns true if the editable draws its own handles (hence, the | 51 // Returns true if the editable draws its own handles (hence, the |
| (...skipping 30 matching lines...) Expand all Loading... |
| 78 | 82 |
| 79 virtual TouchSelectionController* create(TouchEditable* client_view) = 0; | 83 virtual TouchSelectionController* create(TouchEditable* client_view) = 0; |
| 80 | 84 |
| 81 protected: | 85 protected: |
| 82 virtual ~TouchSelectionControllerFactory() {} | 86 virtual ~TouchSelectionControllerFactory() {} |
| 83 }; | 87 }; |
| 84 | 88 |
| 85 } // namespace views | 89 } // namespace views |
| 86 | 90 |
| 87 #endif // UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ | 91 #endif // UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ |
| OLD | NEW |