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_DELEGATE_H_ | |
| 6 #define UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_ | |
| 7 | |
| 8 #include "ui/views/views_export.h" | |
| 9 | |
| 10 namespace ui { | |
| 11 class MouseEvent; | |
| 12 } | |
| 13 | |
| 14 namespace views { | |
| 15 | |
| 16 // An interface implemented/managed by a view which uses the | |
| 17 // SelectionController. | |
| 18 class VIEWS_EXPORT SelectionControllerDelegate { | |
| 19 public: | |
| 20 // Returns the associated RenderText instance to be used for selection. | |
| 21 virtual gfx::RenderText* GetRenderTextForSelectionController() = 0; | |
| 22 | |
| 23 // Methods related to properties of the associated view. | |
| 24 | |
| 25 // Returns true if the associated text view is read only. | |
| 26 virtual bool IsReadOnly() const = 0; | |
| 27 // Returns whether there is a drag operation originating from the associated | |
| 28 // view. | |
| 29 virtual bool HasTextBeingDragged() const = 0; | |
| 30 // Sets whether text is being dragged from the associated view. | |
| 31 virtual void SetTextBeingDragged(bool value) = 0; | |
| 32 // Returns the height of the associated view. | |
| 33 virtual int GetViewHeight() const = 0; | |
| 34 // Returns the width of the associated view. | |
| 35 virtual int GetViewWidth() const = 0; | |
| 36 // Returns the drag selection timer delay. This is the duration after which a | |
| 37 // drag selection is updated when the event location is outside the text | |
| 38 // bounds. | |
| 39 virtual int GetDragSelectionDelay() const = 0; | |
| 40 | |
| 41 // Methods called to notify a mouse action which may change the associated | |
| 42 // view's text and/or selection. | |
| 43 | |
| 44 // Called before performing a mouse action. Should not be called in succession | |
| 45 // and must always be followed by an OnAfterMouseAction call. | |
| 46 virtual void OnBeforeMouseAction() = 0; | |
| 47 // Called after the mouse action is performed. |text_changed| and | |
| 48 // |selection_changed| can be used by subclasses to make any necessary updates | |
| 49 // like redraw the text. Must always be preceeded by a OnBeforeMouseAction | |
| 50 // call. | |
| 51 virtual void OnAfterMouseAction(bool text_changed, | |
| 52 bool selection_changed) = 0; | |
| 53 | |
| 54 // Called to notify when the current selection is updated. Must always be | |
| 55 // called during a mouse action. | |
| 56 | |
| 57 // 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.
| |
| 58 // followed by an OnAfterSelectionUpdated call. | |
| 59 virtual void OnBeforeSelectionUpdated() = 0; | |
| 60 // Called after the selection is updated. Not called in succession and always | |
| 61 // preceeded by an OnBeforeSelectionUpdated call. | |
| 62 virtual void OnAfterSelectionUpdated() = 0; | |
| 63 | |
| 64 // Selection clipboard related methods. Called only when a mouse action is in | |
| 65 // progress. | |
| 66 | |
| 67 // Moves the cursor to the event location and pastes the text from the | |
| 68 // selection clipboard. The view may also request focus. NO-OP if the | |
| 69 // associated text view is read-only or the event is not a middle click. | |
| 70 virtual void PasteSelectionClipboard(const ui::MouseEvent& event) = 0; | |
| 71 // Updates the selection clipboard with the currently selected text. Should | |
| 72 // empty the selection clipboard if no text is currently selected. NO-OP if | |
| 73 // the associated text view is obscured. | |
| 74 virtual void UpdateSelectionClipboard() = 0; | |
| 75 | |
| 76 protected: | |
| 77 virtual ~SelectionControllerDelegate() {} | |
| 78 }; | |
| 79 | |
| 80 } // namespace views | |
| 81 | |
| 82 #endif // UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_ | |
| OLD | NEW |