Index: ui/base/touch/touch_editing_controller.h |
diff --git a/ui/base/touch/touch_editing_controller.h b/ui/base/touch/touch_editing_controller.h |
index 00d8d496388c4b916c280115ff598b6e171de3eb..2e4c56b13e6275d6192d6dcb91c8672485c14990 100644 |
--- a/ui/base/touch/touch_editing_controller.h |
+++ b/ui/base/touch/touch_editing_controller.h |
@@ -9,8 +9,44 @@ |
#include "ui/gfx/point.h" |
#include "ui/gfx/rect.h" |
+namespace cc { |
+struct ViewportSelectionBound; |
+} |
+ |
namespace ui { |
+// Bound of a selected region. |
+struct UI_BASE_EXPORT SelectionBound { |
mohsen
2014/11/07 16:52:27
Can you make fields private and add setter/getters
mfomitchev
2014/11/10 04:04:12
I thought it would be good to keep this similar to
|
+ public: |
+ enum Type { |
+ LEFT, |
+ RIGHT, |
+ CENTER, |
+ EMPTY, |
+ LAST = EMPTY |
+ }; |
+ |
+ SelectionBound(); |
+ virtual ~SelectionBound(); |
+ |
+ int GetHeight() const; |
+ |
+ Type type; |
+ |
+ // A valid selection bound should have the same y-coordinate for |edge_top| |
+ // and |edge_bottom|. |
+ gfx::Point edge_top; |
+ gfx::Point edge_bottom; |
+}; |
+ |
+UI_BASE_EXPORT bool operator==(const SelectionBound& lhs, |
+ const SelectionBound& rhs); |
+UI_BASE_EXPORT bool operator!=(const SelectionBound& lhs, |
+ const SelectionBound& rhs); |
+ |
+UI_BASE_EXPORT gfx::Rect RectBetweenSelectionBounds(const SelectionBound& b1, |
+ const SelectionBound& b2); |
+ |
// An interface implemented by widget that has text that can be selected/edited |
// using touch. |
class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { |
@@ -26,17 +62,18 @@ class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { |
// Move the caret to |point|. |point| is in local coordinates. |
virtual void MoveCaretTo(const gfx::Point& point) = 0; |
- // Gets the end points of the current selection. The end points p1 and p2 must |
- // be the cursor rect for the start and end of selection (in local |
- // coordinates): |
+ // Gets the end points of the current selection. The end points |anchor| and |
+ // |focus| must be the cursor rect for the logical start and logical end of |
+ // selection (in local coordinates): |
// ____________________________________ |
// | textfield with |selected text| | |
// ------------------------------------ |
- // ^p1 ^p2 |
+ // ^anchor ^focus |
// |
- // p1 should be the logical start and p2 the logical end of selection. Hence, |
- // visually, p1 could be to the right of p2 in the figure above. |
- virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) = 0; |
+ // Visually, anchor could be to the right of focus in the figure above - it |
+ // depends on the selection direction. |
+ virtual void GetSelectionEndPoints(ui::SelectionBound* anchor, |
+ ui::SelectionBound* focus) = 0; |
// Gets the bounds of the client view in its local coordinates. |
virtual gfx::Rect GetBounds() = 0; |
@@ -94,6 +131,6 @@ class UI_BASE_EXPORT TouchSelectionControllerFactory { |
virtual ~TouchSelectionControllerFactory() {} |
}; |
-} // namespace views |
+} // namespace ui |
#endif // UI_BASE_TOUCH_TOUCH_EDITING_CONTROLLER_H_ |