Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_VIEWS_SELECTION_CONTROLLER_HOST_H_ | |
| 6 #define UI_VIEWS_SELECTION_CONTROLLER_HOST_H_ | |
| 7 | |
| 8 #include "ui/gfx/selection_model.h" | |
| 9 namespace gfx { | |
| 10 class RenderText; | |
| 11 class Point; | |
| 12 class Range; | |
| 13 } | |
| 14 | |
| 15 namespace views { | |
| 16 | |
| 17 class SelectionController; | |
| 18 | |
| 19 // An interface implemented/managed by a view which uses a SelectionController. | |
| 20 class SelectionControllerHost { | |
|
tapted
2016/10/11 04:42:09
in views parlance, this would probably be a Select
karandeepb
2016/10/14 09:27:34
Done. Also made it an inner class of SelectionCont
| |
| 21 public: | |
| 22 // Returns the associated RenderText instance to be used for selection. | |
| 23 // Todo(karandeepb): Modify RenderText so that this can return a pointer to a | |
| 24 // const RenderText. | |
| 25 virtual gfx::RenderText* GetRenderTextForSelection() = 0; | |
| 26 | |
| 27 // Methods related to properties of the associated view | |
| 28 | |
| 29 // Returns true if the associated text view is read only. | |
| 30 virtual bool IsReadOnly() const = 0; | |
| 31 // Returns whether there is a drag operation originating from the associated | |
| 32 // view. | |
| 33 virtual bool HasTextBeingDragged() const = 0; | |
| 34 // Sets whether text is being dragged from the associated view. | |
| 35 virtual void SetTextBeingDragged(bool value) = 0; | |
| 36 // Returns the height of the associated view. | |
| 37 virtual int GetViewHeight() const = 0; | |
| 38 // Returns the width of the associated view. | |
| 39 virtual int GetViewWidth() const = 0; | |
| 40 // Returns the drag selection timer delay. This is the duration after which a | |
| 41 // drag selection is updated when the event location is outside the text | |
| 42 // bounds. | |
| 43 virtual int GetDragSelectionDelay() const = 0; | |
| 44 | |
| 45 // Methods called to notify a mouse action which may change the associated | |
| 46 // view's text and/or selection. | |
| 47 | |
| 48 // Called before performing a mouse action which may change the associated | |
| 49 // text or selection. Should not be called in succession and must always be | |
| 50 // followed by an OnAfterMouseAction call. | |
| 51 virtual void OnBeforeMouseAction() = 0; | |
| 52 // Called after the mouse action is performed. |text_changed| and | |
| 53 // |selection_changed| can be used by subclasses to make any necessary updates | |
| 54 // like redraw the text. Must always be preceeded by a OnBeforeMouseAction | |
| 55 // call. | |
| 56 virtual void OnAfterMouseAction(bool text_changed, | |
| 57 bool selection_changed) = 0; | |
| 58 | |
| 59 // Selection related methods. Called only when a mouse action is in progress. | |
| 60 // Subclasses can defer making updates till the OnAfterMouseAction call. | |
| 61 | |
| 62 // Select the entire text range. If |reversed| is true, the range will end at | |
| 63 // the logical beginning of the text; this generally shows the leading portion | |
| 64 // of text that overflows its display area. | |
| 65 virtual void SelectAll(bool reversed) = 0; | |
| 66 // Selects the word closest to |point|. | |
| 67 virtual void SelectWordAt(const gfx::Point& point) = 0; | |
| 68 // Selects the word at the current cursor position. If there is a non-empty | |
| 69 // selection, the selection bounds are extended to their nearest word | |
| 70 // boundaries. | |
| 71 virtual void SelectWord() = 0; | |
| 72 // Selects the specified logical text range. The range is truncated to lie | |
| 73 // within the text range. If the |range| start or end is not a cursorable | |
| 74 // position (not on grapheme boundary), it is a NO-OP. | |
| 75 virtual void SelectRange(const gfx::Range& range) = 0; | |
| 76 // Moves the cursor to the text index corresponding to |point|. |point| is in | |
| 77 // the coordinates of the associated view. If |select| is true, a selection is | |
| 78 // made with the current selection start index. | |
| 79 virtual void MoveCursorTo(const gfx::Point& point, bool select) = 0; | |
| 80 // Clears the existing selection keeping the current cursor position and caret | |
| 81 // affinity. | |
| 82 virtual void ClearSelection() = 0; | |
| 83 // Select till the beginning/end of line keeping the current selection start. | |
| 84 // Todo should this say something about only supporting single line. | |
| 85 virtual void SelectTillEdge(gfx::VisualCursorDirection direction) = 0; | |
| 86 | |
| 87 // Selection clipboard related methods. Called only when a mouse action is in | |
| 88 // progress. | |
| 89 | |
| 90 // Pastes the text in the selection clipboard at the current cursor position. | |
| 91 // NO-OP if the associated text view is read-only. | |
| 92 virtual void PasteSelectionClipboard() = 0; | |
| 93 // Updates the selection clipboard with the currently selected text. Should | |
| 94 // empty the selection clipboard if no text is currently selected. | |
| 95 virtual void UpdateSelectionClipboard() = 0; | |
| 96 | |
| 97 protected: | |
| 98 virtual ~SelectionControllerHost() {} | |
| 99 }; | |
| 100 | |
| 101 } // namespace views | |
| 102 | |
| 103 #endif // UI_VIEWS_SELECTION_CONTROLLER_HOST_H_ | |
| OLD | NEW |