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

Side by Side Diff: ui/base/touch/touch_editing_controller.h

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

Powered by Google App Engine
This is Rietveld 408576698