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

Unified Diff: ui/views/selection_controller_delegate.h

Issue 2408623002: Views: Extract text selection code from Textfield. (Closed)
Patch Set: Rebase. Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« ui/views/selection_controller.cc ('K') | « ui/views/selection_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/selection_controller_delegate.h
diff --git a/ui/views/selection_controller_delegate.h b/ui/views/selection_controller_delegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..10f9f9132bdcf5bae4835b90225c2bbf5166cf46
--- /dev/null
+++ b/ui/views/selection_controller_delegate.h
@@ -0,0 +1,82 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_
+#define UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_
+
+#include "ui/views/views_export.h"
+
+namespace ui {
+class MouseEvent;
+}
+
+namespace views {
+
+// An interface implemented/managed by a view which uses the
+// SelectionController.
+class VIEWS_EXPORT SelectionControllerDelegate {
+ public:
+ // Returns the associated RenderText instance to be used for selection.
+ virtual gfx::RenderText* GetRenderTextForSelectionController() = 0;
+
+ // Methods related to properties of the associated view.
+
+ // Returns true if the associated text view is read only.
+ virtual bool IsReadOnly() const = 0;
+ // Returns whether there is a drag operation originating from the associated
+ // view.
+ virtual bool HasTextBeingDragged() const = 0;
+ // Sets whether text is being dragged from the associated view.
+ virtual void SetTextBeingDragged(bool value) = 0;
+ // Returns the height of the associated view.
+ virtual int GetViewHeight() const = 0;
+ // Returns the width of the associated view.
+ virtual int GetViewWidth() const = 0;
+ // Returns the drag selection timer delay. This is the duration after which a
+ // drag selection is updated when the event location is outside the text
+ // bounds.
+ virtual int GetDragSelectionDelay() const = 0;
+
+ // Methods called to notify a mouse action which may change the associated
+ // view's text and/or selection.
+
+ // Called before performing a mouse action. Should not be called in succession
+ // and must always be followed by an OnAfterMouseAction call.
+ virtual void OnBeforeMouseAction() = 0;
+ // Called after the mouse action is performed. |text_changed| and
+ // |selection_changed| can be used by subclasses to make any necessary updates
+ // like redraw the text. Must always be preceeded by a OnBeforeMouseAction
+ // call.
+ virtual void OnAfterMouseAction(bool text_changed,
+ bool selection_changed) = 0;
+
+ // Called to notify when the current selection is updated. Must always be
+ // called during a mouse action.
+
+ // Called before the selection is updated. Not called in succession and always
msw 2016/10/18 23:15:05 nit: normalize phrases here and below with those a
karandeepb 2016/10/20 04:12:57 Obsolete.
+ // followed by an OnAfterSelectionUpdated call.
+ virtual void OnBeforeSelectionUpdated() = 0;
+ // Called after the selection is updated. Not called in succession and always
+ // preceeded by an OnBeforeSelectionUpdated call.
+ virtual void OnAfterSelectionUpdated() = 0;
+
+ // Selection clipboard related methods. Called only when a mouse action is in
+ // progress.
+
+ // Moves the cursor to the event location and pastes the text from the
+ // selection clipboard. The view may also request focus. NO-OP if the
+ // associated text view is read-only or the event is not a middle click.
+ virtual void PasteSelectionClipboard(const ui::MouseEvent& event) = 0;
+ // Updates the selection clipboard with the currently selected text. Should
+ // empty the selection clipboard if no text is currently selected. NO-OP if
+ // the associated text view is obscured.
+ virtual void UpdateSelectionClipboard() = 0;
+
+ protected:
+ virtual ~SelectionControllerDelegate() {}
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_
« ui/views/selection_controller.cc ('K') | « ui/views/selection_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698