diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 21:45:28 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 21:45:28 +0000 |
commit | da4aa75358a0fbfb7a060bc60cf6deee055b71dc (patch) | |
tree | 332b985ab124d43073bb13e47a927e8dccac57ed /ui/base/touch | |
parent | 0a04f794c875e442a7101cf50298cd54341283f0 (diff) | |
download | chromium_src-da4aa75358a0fbfb7a060bc60cf6deee055b71dc.zip chromium_src-da4aa75358a0fbfb7a060bc60cf6deee055b71dc.tar.gz chromium_src-da4aa75358a0fbfb7a060bc60cf6deee055b71dc.tar.bz2 |
Enable touch editing controller for views textfields behind a flag.
BUG=115237
Review URL: https://chromiumcodereview.appspot.com/12210154
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182542 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/touch')
-rw-r--r-- | ui/base/touch/touch_editing_controller.cc | 12 | ||||
-rw-r--r-- | ui/base/touch/touch_editing_controller.h | 41 |
2 files changed, 41 insertions, 12 deletions
diff --git a/ui/base/touch/touch_editing_controller.cc b/ui/base/touch/touch_editing_controller.cc index 8afb740..1b84ed9 100644 --- a/ui/base/touch/touch_editing_controller.cc +++ b/ui/base/touch/touch_editing_controller.cc @@ -6,9 +6,21 @@ namespace ui { +namespace { +TouchSelectionControllerFactory* g_shared_instance = NULL; +} // namespace + TouchSelectionController* TouchSelectionController::create( TouchEditable* client_view) { + if (g_shared_instance) + return g_shared_instance->create(client_view); return NULL; } +// static +void TouchSelectionControllerFactory::SetInstance( + TouchSelectionControllerFactory* instance) { + g_shared_instance = instance; +} + } // namespace ui diff --git a/ui/base/touch/touch_editing_controller.h b/ui/base/touch/touch_editing_controller.h index 999c2ad..e7985ce 100644 --- a/ui/base/touch/touch_editing_controller.h +++ b/ui/base/touch/touch_editing_controller.h @@ -20,6 +20,17 @@ class UI_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { // end of selection. Visually, |start| may lie after |end|. virtual void SelectRect(const gfx::Point& start, const gfx::Point& end) = 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: + // ____________________________________ + // | textfield with |selected text| | + // ------------------------------------ + // ^p1 ^p2 + // + // 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; + // Gets the bounds of the client view in parent's coordinates. virtual const gfx::Rect& GetBounds() = 0; @@ -30,6 +41,13 @@ class UI_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate { virtual void ConvertPointToScreen(gfx::Point* point) = 0; virtual void ConvertPointFromScreen(gfx::Point* point) = 0; + // Returns true if the editable draws its own handles (hence, the + // TouchSelectionController need not draw handles). + virtual bool DrawsHandles() = 0; + + // Tells the editable to open context menu. + virtual void OpenContextMenu(const gfx::Point anchor) = 0; + protected: virtual ~TouchEditable() {} }; @@ -44,19 +62,18 @@ class UI_EXPORT TouchSelectionController { static TouchSelectionController* create( TouchEditable* client_view); - // Notification that the text selection in TouchEditable has - // changed. p1 and p2 are lower corners of the start and end of selection: - // ____________________________________ - // | textfield with |selected text| | - // ------------------------------------ - // ^p1 ^p2 - // - // p1 is always the start and p2 is always the end of selection. Hence, - // p1 could be to the right of p2 in the figure above. - virtual void SelectionChanged(const gfx::Point& p1, const gfx::Point& p2) = 0; + // Notifies the controller that the selection has changed. + virtual void SelectionChanged() = 0; +}; - // Notification that the TouchEditable has lost focus. - virtual void ClientViewLostFocus() = 0; +class UI_EXPORT TouchSelectionControllerFactory { + public: + static void SetInstance(TouchSelectionControllerFactory* instance); + + virtual TouchSelectionController* create(TouchEditable* client_view) = 0; + + protected: + virtual ~TouchSelectionControllerFactory() {} }; } // namespace views |