| 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 // Bound of a selected region. |
| 15 struct UI_BASE_EXPORT SelectionBound { |
| 16 public: |
| 17 enum Type { |
| 18 LEFT, |
| 19 RIGHT, |
| 20 CENTER, |
| 21 EMPTY, |
| 22 LAST = EMPTY |
| 23 }; |
| 24 |
| 25 SelectionBound(); |
| 26 virtual ~SelectionBound(); |
| 27 |
| 28 int GetHeight() const; |
| 29 |
| 30 Type type; |
| 31 |
| 32 gfx::Point edge_top; |
| 33 gfx::Point edge_bottom; |
| 34 }; |
| 35 |
| 36 UI_BASE_EXPORT bool operator==(const SelectionBound& lhs, |
| 37 const SelectionBound& rhs); |
| 38 UI_BASE_EXPORT bool operator!=(const SelectionBound& lhs, |
| 39 const SelectionBound& rhs); |
| 40 |
| 41 UI_BASE_EXPORT gfx::Rect RectBetweenSelectionBounds(const SelectionBound& b1, |
| 42 const SelectionBound& b2); |
| 43 |
| 14 // An interface implemented by widget that has text that can be selected/edited | 44 // An interface implemented by widget that has text that can be selected/edited |
| 15 // using touch. | 45 // using touch. |
| 16 class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { | 46 class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { |
| 17 public: | 47 public: |
| 18 // TODO(mohsen): Consider switching from local coordinates to screen | 48 // TODO(mohsen): Consider switching from local coordinates to screen |
| 19 // coordinates in this interface and see if it will simplify things. | 49 // coordinates in this interface and see if it will simplify things. |
| 20 | 50 |
| 21 // Select everything between start and end (points are in view's local | 51 // Select everything between start and end (points are in view's local |
| 22 // coordinate system). |start| is the logical start and |end| is the logical | 52 // coordinate system). |start| is the logical start and |end| is the logical |
| 23 // end of selection. Visually, |start| may lie after |end|. | 53 // end of selection. Visually, |start| may lie after |end|. |
| 24 virtual void SelectRect(const gfx::Point& start, const gfx::Point& end) = 0; | 54 virtual void SelectRect(const gfx::Point& start, const gfx::Point& end) = 0; |
| 25 | 55 |
| 26 // Move the caret to |point|. |point| is in local coordinates. | 56 // Move the caret to |point|. |point| is in local coordinates. |
| 27 virtual void MoveCaretTo(const gfx::Point& point) = 0; | 57 virtual void MoveCaretTo(const gfx::Point& point) = 0; |
| 28 | 58 |
| 29 // Gets the end points of the current selection. The end points p1 and p2 must | 59 // Gets the end points of the current selection. The end points |anchor| and |
| 30 // be the cursor rect for the start and end of selection (in local | 60 // |focus| must be the cursor rect for the logical start and logical end of |
| 31 // coordinates): | 61 // selection (in local coordinates): |
| 32 // ____________________________________ | 62 // ____________________________________ |
| 33 // | textfield with |selected text| | | 63 // | textfield with |selected text| | |
| 34 // ------------------------------------ | 64 // ------------------------------------ |
| 35 // ^p1 ^p2 | 65 // ^anchor ^focus |
| 36 // | 66 // |
| 37 // p1 should be the logical start and p2 the logical end of selection. Hence, | 67 // Visually, anchor could be to the right of focus in the figure above - it |
| 38 // visually, p1 could be to the right of p2 in the figure above. | 68 // depends on the selection direction. |
| 39 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) = 0; | 69 virtual void GetSelectionEndPoints(ui::SelectionBound* anchor, |
| 70 ui::SelectionBound* focus) = 0; |
| 40 | 71 |
| 41 // Gets the bounds of the client view in its local coordinates. | 72 // Gets the bounds of the client view in its local coordinates. |
| 42 virtual gfx::Rect GetBounds() = 0; | 73 virtual gfx::Rect GetBounds() = 0; |
| 43 | 74 |
| 44 // Gets the NativeView hosting the client. | 75 // Gets the NativeView hosting the client. |
| 45 virtual gfx::NativeView GetNativeView() const = 0; | 76 virtual gfx::NativeView GetNativeView() const = 0; |
| 46 | 77 |
| 47 // Converts a point to/from screen coordinates from/to client view. | 78 // Converts a point to/from screen coordinates from/to client view. |
| 48 virtual void ConvertPointToScreen(gfx::Point* point) = 0; | 79 virtual void ConvertPointToScreen(gfx::Point* point) = 0; |
| 49 virtual void ConvertPointFromScreen(gfx::Point* point) = 0; | 80 virtual void ConvertPointFromScreen(gfx::Point* point) = 0; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 class UI_BASE_EXPORT TouchSelectionControllerFactory { | 118 class UI_BASE_EXPORT TouchSelectionControllerFactory { |
| 88 public: | 119 public: |
| 89 static void SetInstance(TouchSelectionControllerFactory* instance); | 120 static void SetInstance(TouchSelectionControllerFactory* instance); |
| 90 | 121 |
| 91 virtual TouchSelectionController* create(TouchEditable* client_view) = 0; | 122 virtual TouchSelectionController* create(TouchEditable* client_view) = 0; |
| 92 | 123 |
| 93 protected: | 124 protected: |
| 94 virtual ~TouchSelectionControllerFactory() {} | 125 virtual ~TouchSelectionControllerFactory() {} |
| 95 }; | 126 }; |
| 96 | 127 |
| 97 } // namespace views | 128 } // namespace ui |
| 98 | 129 |
| 99 #endif // UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ | 130 #endif // UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ |
| OLD | NEW |