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

Side by Side Diff: ui/views/selection_controller_delegate.h

Issue 2408623002: Views: Extract text selection code from Textfield. (Closed)
Patch Set: Removed On[Before|After]SelectionUpdated. 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 unified diff | Download patch
OLDNEW
(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 selection and/or text.
43
44 // Should not be called in succession and must always be followed by an
45 // 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 // Selection clipboard related methods.
55
56 // Moves the cursor to the event location and pastes the text from the
57 // selection clipboard. The view may also request focus. Since this modifies
58 // the text, always called within a mouse action. |event| will correspond to a
59 // middle click. Will only be called for a non-readonly view.
60 virtual void PasteSelectionClipboard(const ui::MouseEvent& event) = 0;
61 // Updates the selection clipboard with the currently selected text. Should
62 // empty the selection clipboard if no text is currently selected. NO-OP if
63 // the associated text view is obscured. Since this does not modify the render
64 // text instance, it may not be called within a mouse action.
65 virtual void UpdateSelectionClipboard() = 0;
66
67 protected:
68 virtual ~SelectionControllerDelegate() {}
69 };
70
71 } // namespace views
72
73 #endif // UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_
OLDNEW
« ui/views/controls/textfield/textfield.h ('K') | « ui/views/selection_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698