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

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

Issue 12212117: views: Dispatch mouse events using EventDispatch interface too. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/views/view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_VIEW_H_ 5 #ifndef UI_VIEWS_VIEW_H_
6 #define UI_VIEWS_VIEW_H_ 6 #define UI_VIEWS_VIEW_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 // to scroll by a default amount. 899 // to scroll by a default amount.
900 // 900 //
901 // See VariableRowHeightScrollHelper and FixedRowHeightScrollHelper for 901 // See VariableRowHeightScrollHelper and FixedRowHeightScrollHelper for
902 // implementations of common cases. 902 // implementations of common cases.
903 virtual int GetPageScrollIncrement(ScrollView* scroll_view, 903 virtual int GetPageScrollIncrement(ScrollView* scroll_view,
904 bool is_horizontal, bool is_positive); 904 bool is_horizontal, bool is_positive);
905 virtual int GetLineScrollIncrement(ScrollView* scroll_view, 905 virtual int GetLineScrollIncrement(ScrollView* scroll_view,
906 bool is_horizontal, bool is_positive); 906 bool is_horizontal, bool is_positive);
907 907
908 protected: 908 protected:
909 // Used to track a drag. RootView passes this into
910 // ProcessMousePressed/Dragged.
911 struct DragInfo {
912 // Sets possible_drag to false and start_x/y to 0. This is invoked by
913 // RootView prior to invoke ProcessMousePressed.
914 void Reset();
915
916 // Sets possible_drag to true and start_pt to the specified point.
917 // This is invoked by the target view if it detects the press may generate
918 // a drag.
919 void PossibleDrag(const gfx::Point& p);
920
921 // Whether the press may generate a drag.
922 bool possible_drag;
923
924 // Coordinates of the mouse press.
925 gfx::Point start_pt;
926 };
927
909 // Size and disposition ------------------------------------------------------ 928 // Size and disposition ------------------------------------------------------
910 929
911 // Override to be notified when the bounds of the view have changed. 930 // Override to be notified when the bounds of the view have changed.
912 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds); 931 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds);
913 932
914 // Called when the preferred size of a child view changed. This gives the 933 // Called when the preferred size of a child view changed. This gives the
915 // parent an opportunity to do a fresh layout if that makes sense. 934 // parent an opportunity to do a fresh layout if that makes sense.
916 virtual void ChildPreferredSizeChanged(View* child) {} 935 virtual void ChildPreferredSizeChanged(View* child) {}
917 936
918 // Called when the visibility of a child view changed. This gives the parent 937 // Called when the visibility of a child view changed. This gives the parent
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 // Called by HitTestRect() to see if this View has a custom hit test mask. If 1062 // Called by HitTestRect() to see if this View has a custom hit test mask. If
1044 // the return value is true, GetHitTestMask() will be called to obtain the 1063 // the return value is true, GetHitTestMask() will be called to obtain the
1045 // mask. Default value is false, in which case the View will hit-test against 1064 // mask. Default value is false, in which case the View will hit-test against
1046 // its bounds. 1065 // its bounds.
1047 virtual bool HasHitTestMask() const; 1066 virtual bool HasHitTestMask() const;
1048 1067
1049 // Called by HitTestRect() to retrieve a mask for hit-testing against. 1068 // Called by HitTestRect() to retrieve a mask for hit-testing against.
1050 // Subclasses override to provide custom shaped hit test regions. 1069 // Subclasses override to provide custom shaped hit test regions.
1051 virtual void GetHitTestMask(gfx::Path* mask) const; 1070 virtual void GetHitTestMask(gfx::Path* mask) const;
1052 1071
1072 virtual DragInfo* GetDragInfo();
1073
1053 // Focus --------------------------------------------------------------------- 1074 // Focus ---------------------------------------------------------------------
1054 1075
1055 // Override to be notified when focus has changed either to or from this View. 1076 // Override to be notified when focus has changed either to or from this View.
1056 virtual void OnFocus(); 1077 virtual void OnFocus();
1057 virtual void OnBlur(); 1078 virtual void OnBlur();
1058 1079
1059 // Handle view focus/blur events for this view. 1080 // Handle view focus/blur events for this view.
1060 void Focus(); 1081 void Focus();
1061 void Blur(); 1082 void Blur();
1062 1083
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 // function makes the decision explicit. 1148 // function makes the decision explicit.
1128 std::string DoPrintViewGraph(bool first, View* view_with_children); 1149 std::string DoPrintViewGraph(bool first, View* view_with_children);
1129 #endif 1150 #endif
1130 1151
1131 private: 1152 private:
1132 friend class internal::PostEventDispatchHandler; 1153 friend class internal::PostEventDispatchHandler;
1133 friend class internal::RootView; 1154 friend class internal::RootView;
1134 friend class FocusManager; 1155 friend class FocusManager;
1135 friend class Widget; 1156 friend class Widget;
1136 1157
1137 // Used to track a drag. RootView passes this into
1138 // ProcessMousePressed/Dragged.
1139 struct DragInfo {
1140 // Sets possible_drag to false and start_x/y to 0. This is invoked by
1141 // RootView prior to invoke ProcessMousePressed.
1142 void Reset();
1143
1144 // Sets possible_drag to true and start_pt to the specified point.
1145 // This is invoked by the target view if it detects the press may generate
1146 // a drag.
1147 void PossibleDrag(const gfx::Point& p);
1148
1149 // Whether the press may generate a drag.
1150 bool possible_drag;
1151
1152 // Coordinates of the mouse press.
1153 gfx::Point start_pt;
1154 };
1155
1156 // Painting ----------------------------------------------------------------- 1158 // Painting -----------------------------------------------------------------
1157 1159
1158 enum SchedulePaintType { 1160 enum SchedulePaintType {
1159 // Indicates the size is the same (only the origin changed). 1161 // Indicates the size is the same (only the origin changed).
1160 SCHEDULE_PAINT_SIZE_SAME, 1162 SCHEDULE_PAINT_SIZE_SAME,
1161 1163
1162 // Indicates the size changed (and possibly the origin). 1164 // Indicates the size changed (and possibly the origin).
1163 SCHEDULE_PAINT_SIZE_CHANGED 1165 SCHEDULE_PAINT_SIZE_CHANGED
1164 }; 1166 };
1165 1167
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 // Orphans the layers in this subtree that are parented to layers outside of 1287 // Orphans the layers in this subtree that are parented to layers outside of
1286 // this subtree. 1288 // this subtree.
1287 void OrphanLayers(); 1289 void OrphanLayers();
1288 1290
1289 // Destroys the layer associated with this view, and reparents any descendants 1291 // Destroys the layer associated with this view, and reparents any descendants
1290 // to the destroyed layer's parent. 1292 // to the destroyed layer's parent.
1291 void DestroyLayer(); 1293 void DestroyLayer();
1292 1294
1293 // Input --------------------------------------------------------------------- 1295 // Input ---------------------------------------------------------------------
1294 1296
1295 // RootView invokes these. These in turn invoke the appropriate OnMouseXXX 1297 bool ProcessMousePressed(const ui::MouseEvent& event);
1296 // method. If a drag is detected, DoDrag is invoked. 1298 bool ProcessMouseDragged(const ui::MouseEvent& event);
1297 bool ProcessMousePressed(const ui::MouseEvent& event, DragInfo* drop_info);
1298 bool ProcessMouseDragged(const ui::MouseEvent& event, DragInfo* drop_info);
1299 void ProcessMouseReleased(const ui::MouseEvent& event); 1299 void ProcessMouseReleased(const ui::MouseEvent& event);
1300 1300
1301 // Accelerators -------------------------------------------------------------- 1301 // Accelerators --------------------------------------------------------------
1302 1302
1303 // Registers this view's keyboard accelerators that are not registered to 1303 // Registers this view's keyboard accelerators that are not registered to
1304 // FocusManager yet, if possible. 1304 // FocusManager yet, if possible.
1305 void RegisterPendingAccelerators(); 1305 void RegisterPendingAccelerators();
1306 1306
1307 // Unregisters all the keyboard accelerators associated with this view. 1307 // Unregisters all the keyboard accelerators associated with this view.
1308 // |leave_data_intact| if true does not remove data from accelerators_ array, 1308 // |leave_data_intact| if true does not remove data from accelerators_ array,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 base::win::ScopedComPtr<NativeViewAccessibilityWin> 1491 base::win::ScopedComPtr<NativeViewAccessibilityWin>
1492 native_view_accessibility_win_; 1492 native_view_accessibility_win_;
1493 #endif 1493 #endif
1494 1494
1495 DISALLOW_COPY_AND_ASSIGN(View); 1495 DISALLOW_COPY_AND_ASSIGN(View);
1496 }; 1496 };
1497 1497
1498 } // namespace views 1498 } // namespace views
1499 1499
1500 #endif // UI_VIEWS_VIEW_H_ 1500 #endif // UI_VIEWS_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698