// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_VIEWS_LAYOUT_FLEX_LAYOUT_H_ #define UI_VIEWS_LAYOUT_FLEX_LAYOUT_H_ #include <list> #include <map> #include <memory> #include <optional> #include <set> #include <utility> #include <vector> #include "base/memory/raw_ptr.h" #include "ui/base/class_property.h" #include "ui/gfx/geometry/insets.h" #include "ui/views/layout/flex_layout_types.h" #include "ui/views/layout/layout_manager_base.h" #include "ui/views/view_class_properties.h" #include "ui/views/views_export.h" namespace views { class NormalizedSize; class NormalizedSizeBounds; class View; // Provides CSS-like layout for a one-dimensional (vertical or horizontal) // arrangement of child views. Independent alignment can be specified for the // main and cross axes. // // Per-View margins (provided by view property kMarginsKey) specify how much // space to leave around each child view. The |interior_margin| says how much // empty space to leave at the edges of the parent view. If |collapse_margins| // is false, these values are additive; if true, the greater of the two values // is used. The |default_child_margins| provides a fallback for views without // kMarginsKey set. // // collapse_margins = false: // // | interior margin> <margin [view]... // | <margin [view] margin> // // collapse_margins = true: // // | interior margin> <margin [view] // | <margin [view] margin> ... // // Views can have their own internal padding, using the kInternalPaddingKey // property, which is subtracted from the margin space between child views. // // Calling SetVisible(false) on a child view outside of the FlexLayout will // result in the child view being hidden until SetVisible(true) is called. This // is irrespective of whether the FlexLayout has set the child view to be // visible or not based on, for example, flex rules. // // If you want the host view to maintain control over a child view, you can // exclude it from the layout. Excluded views are completely ignored during // layout and do not have their properties modified. // // FlexSpecification objects determine how child views are sized. You can set // individual flex rules for each child view, or a default for any child views // without individual flex rules set. If you don't set anything, each view will // take up its preferred size in the layout. // // The core function of this class is contained in // GetPreferredSize(maximum_size) and Layout(). In both cases, a layout will be // cached and typically not recalculated as long as none of the layout's // properties or the preferred size or visibility of any of its children has // changed. class VIEWS_EXPORT FlexLayout : public LayoutManagerBase { … }; } // namespace views #endif // UI_VIEWS_LAYOUT_FLEX_LAYOUT_H_