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

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

Issue 2836313002: BoxLayout now suports per-view margins. (Closed)
Patch Set: Added unit tests. Fixed GetPreferredSize() calculations. Refactored some code. Created 3 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
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/i18n/rtl.h" 18 #include "base/i18n/rtl.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "ui/accessibility/ax_enums.h" 22 #include "ui/accessibility/ax_enums.h"
23 #include "ui/base/accelerators/accelerator.h" 23 #include "ui/base/accelerators/accelerator.h"
24 #include "ui/base/class_property.h"
24 #include "ui/base/dragdrop/drag_drop_types.h" 25 #include "ui/base/dragdrop/drag_drop_types.h"
25 #include "ui/base/dragdrop/drop_target_event.h" 26 #include "ui/base/dragdrop/drop_target_event.h"
26 #include "ui/base/dragdrop/os_exchange_data.h" 27 #include "ui/base/dragdrop/os_exchange_data.h"
27 #include "ui/base/ui_base_types.h" 28 #include "ui/base/ui_base_types.h"
28 #include "ui/compositor/layer_delegate.h" 29 #include "ui/compositor/layer_delegate.h"
29 #include "ui/compositor/layer_owner.h" 30 #include "ui/compositor/layer_owner.h"
30 #include "ui/compositor/paint_cache.h" 31 #include "ui/compositor/paint_cache.h"
31 #include "ui/events/event.h" 32 #include "ui/events/event.h"
32 #include "ui/events/event_target.h" 33 #include "ui/events/event_target.h"
33 #include "ui/gfx/geometry/insets.h" 34 #include "ui/gfx/geometry/insets.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // specific properties and functionality. 109 // specific properties and functionality.
109 // 110 //
110 // Unless otherwise documented, views is not thread safe and should only be 111 // Unless otherwise documented, views is not thread safe and should only be
111 // accessed from the main thread. 112 // accessed from the main thread.
112 // 113 //
113 ///////////////////////////////////////////////////////////////////////////// 114 /////////////////////////////////////////////////////////////////////////////
114 class VIEWS_EXPORT View : public ui::LayerDelegate, 115 class VIEWS_EXPORT View : public ui::LayerDelegate,
115 public ui::LayerOwner, 116 public ui::LayerOwner,
116 public ui::AcceleratorTarget, 117 public ui::AcceleratorTarget,
117 public ui::EventTarget, 118 public ui::EventTarget,
118 public ui::EventHandler { 119 public ui::EventHandler,
120 public ui::PropertyHandler {
119 public: 121 public:
120 using Views = std::vector<View*>; 122 using Views = std::vector<View*>;
121 123
122 enum class FocusBehavior { 124 enum class FocusBehavior {
123 // Use when the View is never focusable. Default. 125 // Use when the View is never focusable. Default.
124 NEVER, 126 NEVER,
125 127
126 // Use when the View is to be focusable both in regular and accessibility 128 // Use when the View is to be focusable both in regular and accessibility
127 // mode. 129 // mode.
128 ALWAYS, 130 ALWAYS,
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 // The accessibility element used to represent this View. 1692 // The accessibility element used to represent this View.
1691 std::unique_ptr<NativeViewAccessibility> native_view_accessibility_; 1693 std::unique_ptr<NativeViewAccessibility> native_view_accessibility_;
1692 1694
1693 // Observers ------------------------------------------------------------- 1695 // Observers -------------------------------------------------------------
1694 1696
1695 base::ObserverList<ViewObserver> observers_; 1697 base::ObserverList<ViewObserver> observers_;
1696 1698
1697 DISALLOW_COPY_AND_ASSIGN(View); 1699 DISALLOW_COPY_AND_ASSIGN(View);
1698 }; 1700 };
1699 1701
1702 // A property to store margins around the outer perimeter of the view. Margins
1703 // are outside the bounds of the view. This is used by various layout managers
1704 // to position views with the proper spacing between them.
1705 VIEWS_EXPORT extern const ui::ClassProperty<gfx::Insets*>* const kMarginsKey;
sky 2017/05/15 20:29:10 Please move this into a separate file (I commented
kylix_rd 2017/05/16 18:45:48 Oops. My bad. I completely missed that comment.
1706
1700 } // namespace views 1707 } // namespace views
1701 1708
1702 #endif // UI_VIEWS_VIEW_H_ 1709 #endif // UI_VIEWS_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698