Make sure webrtc::VideoSource is released when WebRtcVideoTrackAdapter is destroyed.
[chromium-blink-merge.git] / ui / views / layout / box_layout.h
blobd58dabf9735211f2f796cffc9ca186600f053254
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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_LAYOUT_BOX_LAYOUT_H_
6 #define UI_VIEWS_LAYOUT_BOX_LAYOUT_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "ui/gfx/insets.h"
11 #include "ui/views/layout/layout_manager.h"
13 namespace gfx {
14 class Rect;
15 class Size;
18 namespace views {
20 class View;
22 // A Layout manager that arranges child views vertically or horizontally in a
23 // side-by-side fashion with spacing around and between the child views. The
24 // child views are always sized according to their preferred size. If the
25 // host's bounds provide insufficient space, child views will be clamped.
26 // Excess space will not be distributed.
27 class VIEWS_EXPORT BoxLayout : public LayoutManager {
28 public:
29 enum Orientation {
30 kHorizontal,
31 kVertical,
34 // This specifies where along the main axis the children should be laid out.
35 // e.g. a horizontal layout of MAIN_AXIS_ALIGNMENT_END will result in the
36 // child views being right-aligned.
37 enum MainAxisAlignment {
38 MAIN_AXIS_ALIGNMENT_START,
39 MAIN_AXIS_ALIGNMENT_CENTER,
40 MAIN_AXIS_ALIGNMENT_END,
42 // This distributes extra space among the child views. This increases the
43 // size of child views along the main axis rather than the space between
44 // them.
45 MAIN_AXIS_ALIGNMENT_FILL,
46 // TODO(calamity): Add MAIN_AXIS_ALIGNMENT_JUSTIFY which spreads blank space
47 // in-between the child views.
50 // TODO(calamity): Add CrossAxisAlignment property to allow cross axis
51 // alignment.
53 // Use |inside_border_horizontal_spacing| and
54 // |inside_border_vertical_spacing| to add additional space between the child
55 // view area and the host view border. |between_child_spacing| controls the
56 // space in between child views.
57 BoxLayout(Orientation orientation,
58 int inside_border_horizontal_spacing,
59 int inside_border_vertical_spacing,
60 int between_child_spacing);
61 virtual ~BoxLayout();
63 void set_main_axis_alignment(MainAxisAlignment main_axis_alignment) {
64 main_axis_alignment_ = main_axis_alignment;
67 // Overridden from views::LayoutManager:
68 virtual void Layout(View* host) OVERRIDE;
69 virtual gfx::Size GetPreferredSize(const View* host) const OVERRIDE;
70 virtual int GetPreferredHeightForWidth(const View* host,
71 int width) const OVERRIDE;
73 private:
74 // Returns the size and position along the main axis of |child_area|.
75 int MainAxisSize(const gfx::Rect& child_area) const;
76 int MainAxisPosition(const gfx::Rect& child_area) const;
78 // Sets the size and position along the main axis of |child_area|.
79 void SetMainAxisSize(int size, gfx::Rect* child_area) const;
80 void SetMainAxisPosition(int position, gfx::Rect* child_area) const;
82 // The preferred size for the dialog given the width of the child area.
83 gfx::Size GetPreferredSizeForChildWidth(const View* host,
84 int child_area_width) const;
86 // The amount of space the layout requires in addition to any space for the
87 // child views.
88 gfx::Size NonChildSize(const View* host) const;
90 const Orientation orientation_;
92 // Spacing between child views and host view border.
93 gfx::Insets inside_border_insets_;
95 // Spacing to put in between child views.
96 const int between_child_spacing_;
98 // The alignment of children in the main axis. This is
99 // MAIN_AXIS_ALIGNMENT_START by default.
100 MainAxisAlignment main_axis_alignment_;
102 DISALLOW_IMPLICIT_CONSTRUCTORS(BoxLayout);
105 } // namespace views
107 #endif // UI_VIEWS_LAYOUT_BOX_LAYOUT_H_