| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_VIEW_H_ | 5 #ifndef VIEWS_VIEW_H_ |
| 6 #define VIEWS_VIEW_H_ | 6 #define VIEWS_VIEW_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 gfx::Rect GetBounds(PositionMirroringSettings settings) const; | 171 gfx::Rect GetBounds(PositionMirroringSettings settings) const; |
| 172 | 172 |
| 173 // Set the bounds in the parent's coordinate system. | 173 // Set the bounds in the parent's coordinate system. |
| 174 void SetBounds(const gfx::Rect& bounds); | 174 void SetBounds(const gfx::Rect& bounds); |
| 175 void SetBounds(int x, int y, int width, int height) { | 175 void SetBounds(int x, int y, int width, int height) { |
| 176 SetBounds(gfx::Rect(x, y, std::max(0, width), std::max(0, height))); | 176 SetBounds(gfx::Rect(x, y, std::max(0, width), std::max(0, height))); |
| 177 } | 177 } |
| 178 void SetX(int x) { SetBounds(x, y(), width(), height()); } | 178 void SetX(int x) { SetBounds(x, y(), width(), height()); } |
| 179 void SetY(int y) { SetBounds(x(), y, width(), height()); } | 179 void SetY(int y) { SetBounds(x(), y, width(), height()); } |
| 180 | 180 |
| 181 // Registers this view for mouse near events (OnMouseNear and |
| 182 // OnMouseExitedNear). Mouse near events are sent for the extended rectangle |
| 183 // defined by the bounds of this view + |insets|. |
| 184 void RegisterForMouseNearEvents(const gfx::Insets& insets); |
| 185 |
| 181 // Returns the left coordinate of the View, relative to the parent View, | 186 // Returns the left coordinate of the View, relative to the parent View, |
| 182 // which is the value of bounds_.x(). | 187 // which is the value of bounds_.x(). |
| 183 // | 188 // |
| 184 // This is the function subclasses should use whenever they need to obtain | 189 // This is the function subclasses should use whenever they need to obtain |
| 185 // the left position of one of their child views (for example, when | 190 // the left position of one of their child views (for example, when |
| 186 // implementing View::Layout()). | 191 // implementing View::Layout()). |
| 187 // This is equivalent to GetX(IGNORE_MIRRORING_TRANSFORMATION), but | 192 // This is equivalent to GetX(IGNORE_MIRRORING_TRANSFORMATION), but |
| 188 // inlinable. | 193 // inlinable. |
| 189 int x() const { return bounds_.x(); } | 194 int x() const { return bounds_.x(); } |
| 190 int y() const { return bounds_.y(); } | 195 int y() const { return bounds_.y(); } |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 // This method is invoked when the mouse enters this control. | 684 // This method is invoked when the mouse enters this control. |
| 680 // | 685 // |
| 681 // Default implementation does nothing. Override as needed. | 686 // Default implementation does nothing. Override as needed. |
| 682 virtual void OnMouseEntered(const MouseEvent& event); | 687 virtual void OnMouseEntered(const MouseEvent& event); |
| 683 | 688 |
| 684 // This method is invoked when the mouse exits this control | 689 // This method is invoked when the mouse exits this control |
| 685 // The provided event location is always (0, 0) | 690 // The provided event location is always (0, 0) |
| 686 // Default implementation does nothing. Override as needed. | 691 // Default implementation does nothing. Override as needed. |
| 687 virtual void OnMouseExited(const MouseEvent& event); | 692 virtual void OnMouseExited(const MouseEvent& event); |
| 688 | 693 |
| 694 // Sent when the mouse enters the rectangle defined by this views bounds and |
| 695 // the insets passed to RegisterForMouseNearEvents. This is only sent for |
| 696 // views that have explicitly registered for near notification |
| 697 // (RegisterForMouseNearEvents). |
| 698 virtual void OnMouseNear(const MouseEvent& event) {} |
| 699 |
| 700 // Sent when the mouse exits the rectangle defined by this views bounds and |
| 701 // the insets passed to RegisterForMouseNearEvents. This is only sent for |
| 702 // views that have explicitly registered for near notification |
| 703 // (RegisterForMouseNearEvents). |
| 704 virtual void OnMouseExitedNear(const MouseEvent& event) {} |
| 705 |
| 689 // Set the MouseHandler for a drag session. | 706 // Set the MouseHandler for a drag session. |
| 690 // | 707 // |
| 691 // A drag session is a stream of mouse events starting | 708 // A drag session is a stream of mouse events starting |
| 692 // with a MousePressed event, followed by several MouseDragged | 709 // with a MousePressed event, followed by several MouseDragged |
| 693 // events and finishing with a MouseReleased event. | 710 // events and finishing with a MouseReleased event. |
| 694 // | 711 // |
| 695 // This method should be only invoked while processing a | 712 // This method should be only invoked while processing a |
| 696 // MouseDragged or MouseReleased event. | 713 // MouseDragged or MouseReleased event. |
| 697 // | 714 // |
| 698 // All further mouse dragged and mouse up events will be sent | 715 // All further mouse dragged and mouse up events will be sent |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 | 1186 |
| 1170 // Propagates UpdateTooltip() to the TooltipManager for the Widget. | 1187 // Propagates UpdateTooltip() to the TooltipManager for the Widget. |
| 1171 // This must be invoked any time the View hierarchy changes in such a way | 1188 // This must be invoked any time the View hierarchy changes in such a way |
| 1172 // the view under the mouse differs. For example, if the bounds of a View is | 1189 // the view under the mouse differs. For example, if the bounds of a View is |
| 1173 // changed, this is invoked. Similarly, as Views are added/removed, this | 1190 // changed, this is invoked. Similarly, as Views are added/removed, this |
| 1174 // is invoked. | 1191 // is invoked. |
| 1175 void UpdateTooltip(); | 1192 void UpdateTooltip(); |
| 1176 | 1193 |
| 1177 // Recursively descends through all descendant views, | 1194 // Recursively descends through all descendant views, |
| 1178 // registering/unregistering all views that want visible bounds in root | 1195 // registering/unregistering all views that want visible bounds in root |
| 1179 // view notification. | 1196 // view notification and/or mouse near events. |
| 1180 static void RegisterChildrenForVisibleBoundsNotification(RootView* root, | 1197 static void RegisterChildrenForRootNotifications(RootView* root, View* view); |
| 1181 View* view); | 1198 static void UnregisterChildrenForRootNotifications(RootView* root, |
| 1182 static void UnregisterChildrenForVisibleBoundsNotification(RootView* root, | 1199 View* view); |
| 1183 View* view); | 1200 |
| 1184 | 1201 |
| 1185 // Adds/removes view to the list of descendants that are notified any time | 1202 // Adds/removes view to the list of descendants that are notified any time |
| 1186 // this views location and possibly size are changed. | 1203 // this views location and possibly size are changed. |
| 1187 void AddDescendantToNotify(View* view); | 1204 void AddDescendantToNotify(View* view); |
| 1188 void RemoveDescendantToNotify(View* view); | 1205 void RemoveDescendantToNotify(View* view); |
| 1189 | 1206 |
| 1190 // Initialize the previous/next focusable views of the specified view relative | 1207 // Initialize the previous/next focusable views of the specified view relative |
| 1191 // to the view at the specified index. | 1208 // to the view at the specified index. |
| 1192 void InitFocusSiblings(View* view, int index); | 1209 void InitFocusSiblings(View* view, int index); |
| 1193 | 1210 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 scoped_ptr<ViewAccessibilityWrapper> accessibility_; | 1290 scoped_ptr<ViewAccessibilityWrapper> accessibility_; |
| 1274 #endif | 1291 #endif |
| 1275 | 1292 |
| 1276 DragController* drag_controller_; | 1293 DragController* drag_controller_; |
| 1277 | 1294 |
| 1278 // Indicates whether or not the gfx::Canvas object passed to View::Paint() | 1295 // Indicates whether or not the gfx::Canvas object passed to View::Paint() |
| 1279 // is going to be flipped horizontally (using the appropriate transform) on | 1296 // is going to be flipped horizontally (using the appropriate transform) on |
| 1280 // right-to-left locales for this View. | 1297 // right-to-left locales for this View. |
| 1281 bool flip_canvas_on_paint_for_rtl_ui_; | 1298 bool flip_canvas_on_paint_for_rtl_ui_; |
| 1282 | 1299 |
| 1300 // Insets passed to RegisterForMouseNearEvents. |
| 1301 scoped_ptr<gfx::Insets> near_insets_; |
| 1302 |
| 1283 // The default value for how long to wait (in ms) before showing a menu | 1303 // The default value for how long to wait (in ms) before showing a menu |
| 1284 // button on hover. This value is used if the OS doesn't supply one. | 1304 // button on hover. This value is used if the OS doesn't supply one. |
| 1285 static const int kShowFolderDropMenuDelay; | 1305 static const int kShowFolderDropMenuDelay; |
| 1286 | 1306 |
| 1287 DISALLOW_COPY_AND_ASSIGN(View); | 1307 DISALLOW_COPY_AND_ASSIGN(View); |
| 1288 }; | 1308 }; |
| 1289 | 1309 |
| 1290 } // namespace views | 1310 } // namespace views |
| 1291 | 1311 |
| 1292 #endif // VIEWS_VIEW_H_ | 1312 #endif // VIEWS_VIEW_H_ |
| OLD | NEW |