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

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

Issue 15912007: WIP - loop in LayoutManager for preferred size changes (2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix LabelTest Created 7 years, 7 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
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>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "ui/base/accelerators/accelerator.h" 20 #include "ui/base/accelerators/accelerator.h"
20 #include "ui/base/accessibility/accessibility_types.h" 21 #include "ui/base/accessibility/accessibility_types.h"
21 #include "ui/base/dragdrop/drag_drop_types.h" 22 #include "ui/base/dragdrop/drag_drop_types.h"
22 #include "ui/base/dragdrop/os_exchange_data.h" 23 #include "ui/base/dragdrop/os_exchange_data.h"
23 #include "ui/base/events/event.h" 24 #include "ui/base/events/event.h"
24 #include "ui/base/events/event_target.h" 25 #include "ui/base/events/event_target.h"
25 #include "ui/compositor/layer_delegate.h" 26 #include "ui/compositor/layer_delegate.h"
26 #include "ui/compositor/layer_owner.h" 27 #include "ui/compositor/layer_owner.h"
27 #include "ui/gfx/native_widget_types.h" 28 #include "ui/gfx/native_widget_types.h"
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 // Whether the press may generate a drag. 969 // Whether the press may generate a drag.
969 bool possible_drag; 970 bool possible_drag;
970 971
971 // Coordinates of the mouse press. 972 // Coordinates of the mouse press.
972 gfx::Point start_pt; 973 gfx::Point start_pt;
973 }; 974 };
974 975
975 // Size and disposition ------------------------------------------------------ 976 // Size and disposition ------------------------------------------------------
976 977
977 // Override to be notified when the bounds of the view have changed. 978 // Override to be notified when the bounds of the view have changed.
978 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds); 979 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) {}
979 980
980 // Called when the preferred size of a child view changed. This gives the 981 // Called when the preferred size of a child view changed. This gives the
981 // parent an opportunity to do a fresh layout if that makes sense. 982 // parent an opportunity to do a fresh layout if that makes sense.
982 virtual void ChildPreferredSizeChanged(View* child) {} 983 virtual void ChildPreferredSizeChanged(View* child);
983 984
984 // Called when the visibility of a child view changed. This gives the parent 985 // Called when the visibility of a child view changed. This gives the parent
985 // an opportunity to do a fresh layout if that makes sense. 986 // an opportunity to do a fresh layout if that makes sense.
986 virtual void ChildVisibilityChanged(View* child) {} 987 virtual void ChildVisibilityChanged(View* child) {}
987 988
988 // Invalidates the layout and calls ChildPreferredSizeChanged on the parent 989 // Invalidates the layout and calls ChildPreferredSizeChanged on the parent
989 // if there is one. Be sure to call View::PreferredSizeChanged when 990 // if there is one. Be sure to call View::PreferredSizeChanged when
990 // overriding such that the layout is properly invalidated. 991 // overriding such that the layout is properly invalidated.
991 virtual void PreferredSizeChanged(); 992 virtual void PreferredSizeChanged();
992 993
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 // the views hierarchy. The above function gives the class the flexibility to 1192 // the views hierarchy. The above function gives the class the flexibility to
1192 // decide which object should be used to obtain the children, but this 1193 // decide which object should be used to obtain the children, but this
1193 // function makes the decision explicit. 1194 // function makes the decision explicit.
1194 std::string DoPrintViewGraph(bool first, View* view_with_children); 1195 std::string DoPrintViewGraph(bool first, View* view_with_children);
1195 #endif 1196 #endif
1196 1197
1197 private: 1198 private:
1198 friend class internal::PostEventDispatchHandler; 1199 friend class internal::PostEventDispatchHandler;
1199 friend class internal::RootView; 1200 friend class internal::RootView;
1200 friend class FocusManager; 1201 friend class FocusManager;
1202 friend class LayoutManager;
1201 friend class Widget; 1203 friend class Widget;
1202 1204
1203 // Painting ----------------------------------------------------------------- 1205 // Painting -----------------------------------------------------------------
1204 1206
1205 enum SchedulePaintType { 1207 enum SchedulePaintType {
1206 // Indicates the size is the same (only the origin changed). 1208 // Indicates the size is the same (only the origin changed).
1207 SCHEDULE_PAINT_SIZE_SAME, 1209 SCHEDULE_PAINT_SIZE_SAME,
1208 1210
1209 // Indicates the size changed (and possibly the origin). 1211 // Indicates the size changed (and possibly the origin).
1210 SCHEDULE_PAINT_SIZE_CHANGED 1212 SCHEDULE_PAINT_SIZE_CHANGED
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 // Takes care of registering/unregistering accelerators if 1253 // Takes care of registering/unregistering accelerators if
1252 // |register_accelerators| true and calls ViewHierarchyChanged(). 1254 // |register_accelerators| true and calls ViewHierarchyChanged().
1253 void ViewHierarchyChangedImpl(bool register_accelerators, 1255 void ViewHierarchyChangedImpl(bool register_accelerators,
1254 const ViewHierarchyChangedDetails& details); 1256 const ViewHierarchyChangedDetails& details);
1255 1257
1256 // Invokes OnNativeThemeChanged() on this and all descendants. 1258 // Invokes OnNativeThemeChanged() on this and all descendants.
1257 void PropagateNativeThemeChanged(const ui::NativeTheme* theme); 1259 void PropagateNativeThemeChanged(const ui::NativeTheme* theme);
1258 1260
1259 // Size and disposition ------------------------------------------------------ 1261 // Size and disposition ------------------------------------------------------
1260 1262
1263 // FIXME
1264 void LayoutIfNeeded();
1265
1261 // Call VisibilityChanged() recursively for all children. 1266 // Call VisibilityChanged() recursively for all children.
1262 void PropagateVisibilityNotifications(View* from, bool is_visible); 1267 void PropagateVisibilityNotifications(View* from, bool is_visible);
1263 1268
1264 // Registers/unregisters accelerators as necessary and calls 1269 // Registers/unregisters accelerators as necessary and calls
1265 // VisibilityChanged(). 1270 // VisibilityChanged().
1266 void VisibilityChangedImpl(View* starting_from, bool is_visible); 1271 void VisibilityChangedImpl(View* starting_from, bool is_visible);
1267 1272
1268 // Responsible for propagating bounds change notifications to relevant 1273 // Responsible for propagating bounds change notifications to relevant
1269 // views. 1274 // views.
1270 void BoundsChanged(const gfx::Rect& previous_bounds); 1275 void BoundsChanged(const gfx::Rect& previous_bounds);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 1392
1388 // Starts a drag and drop operation originating from this view. This invokes 1393 // Starts a drag and drop operation originating from this view. This invokes
1389 // WriteDragData to write the data and GetDragOperations to determine the 1394 // WriteDragData to write the data and GetDragOperations to determine the
1390 // supported drag operations. When done, OnDragDone is invoked. |press_pt| is 1395 // supported drag operations. When done, OnDragDone is invoked. |press_pt| is
1391 // in the view's coordinate system. 1396 // in the view's coordinate system.
1392 // Returns true if a drag was started. 1397 // Returns true if a drag was started.
1393 bool DoDrag(const ui::LocatedEvent& event, 1398 bool DoDrag(const ui::LocatedEvent& event,
1394 const gfx::Point& press_pt, 1399 const gfx::Point& press_pt,
1395 ui::DragDropTypes::DragEventSource source); 1400 ui::DragDropTypes::DragEventSource source);
1396 1401
1402
1397 ////////////////////////////////////////////////////////////////////////////// 1403 //////////////////////////////////////////////////////////////////////////////
1398 1404
1399 // Creation and lifetime ----------------------------------------------------- 1405 // Creation and lifetime -----------------------------------------------------
1400 1406
1401 // False if this View is owned by its parent - i.e. it will be deleted by its 1407 // False if this View is owned by its parent - i.e. it will be deleted by its
1402 // parent during its parents destruction. False is the default. 1408 // parent during its parents destruction. False is the default.
1403 bool owned_by_client_; 1409 bool owned_by_client_;
1404 1410
1411 base::WeakPtrFactory<View> weak_ptr_factory_;
1412
1405 // Attributes ---------------------------------------------------------------- 1413 // Attributes ----------------------------------------------------------------
1406 1414
1407 // The id of this View. Used to find this View. 1415 // The id of this View. Used to find this View.
1408 int id_; 1416 int id_;
1409 1417
1410 // The group of this view. Some view subclasses use this id to find other 1418 // The group of this view. Some view subclasses use this id to find other
1411 // views of the same group. For example radio button uses this information 1419 // views of the same group. For example radio button uses this information
1412 // to find other radio buttons. 1420 // to find other radio buttons.
1413 int group_; 1421 int group_;
1414 1422
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 // Belongs to this view, but it's reference-counted on some platforms 1546 // Belongs to this view, but it's reference-counted on some platforms
1539 // so we can't use a scoped_ptr. It's dereferenced in the destructor. 1547 // so we can't use a scoped_ptr. It's dereferenced in the destructor.
1540 NativeViewAccessibility* native_view_accessibility_; 1548 NativeViewAccessibility* native_view_accessibility_;
1541 1549
1542 DISALLOW_COPY_AND_ASSIGN(View); 1550 DISALLOW_COPY_AND_ASSIGN(View);
1543 }; 1551 };
1544 1552
1545 } // namespace views 1553 } // namespace views
1546 1554
1547 #endif // UI_VIEWS_VIEW_H_ 1555 #endif // UI_VIEWS_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698