| Index: ui/views/layout/align_layout_state.h
|
| diff --git a/ui/views/layout/align_layout_state.h b/ui/views/layout/align_layout_state.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e4f18739bad66b3c76bf0c44137d5a2b4d7f5112
|
| --- /dev/null
|
| +++ b/ui/views/layout/align_layout_state.h
|
| @@ -0,0 +1,84 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef UI_VIEWS_LAYOUT_ALIGN_LAYOUT_STATE_H_
|
| +#define UI_VIEWS_LAYOUT_ALIGN_LAYOUT_STATE_H_
|
| +
|
| +#include <stddef.h>
|
| +
|
| +#include <algorithm>
|
| +#include <initializer_list>
|
| +#include <map>
|
| +#include <vector>
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#include "base/macros.h"
|
| +#include "ui/gfx/geometry/point.h"
|
| +#include "ui/gfx/geometry/rect.h"
|
| +#include "ui/views/align_attribute.h"
|
| +#include "ui/views/anchor_attribute.h"
|
| +#include "ui/views/layout/layout_manager.h"
|
| +#include "ui/views/view.h"
|
| +
|
| +namespace views {
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +//
|
| +// AlignLayout
|
| +// A LayoutManager that causes the associated view's children to be aligned
|
| +// and/or anchored within the bounds of their parent based on the value of the
|
| +// views' align or anchor attributes.
|
| +//
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +class VIEWS_EXPORT AlignLayoutState : public LayoutManager {
|
| + public:
|
| + AlignLayoutState();
|
| + ~AlignLayoutState() override;
|
| +
|
| + // Overridden from LayoutManager:
|
| + void Installed(View* host) override;
|
| + void Layout(View* host) override;
|
| + gfx::Size GetPreferredSize(const View* host) const override;
|
| + int GetPreferredHeightForWidth(const View* host, int width) const override;
|
| + void ViewAdded(View* host, View* view) override;
|
| + void ViewRemoved(View* host, View* view) override;
|
| +
|
| + void AlignView(View* view, Align align);
|
| + void AnchorView(View* view, Anchors anchors);
|
| + void AnchorView(View* view, const std::initializer_list<Anchor>& anchors);
|
| + void NoAlignView(View* view);
|
| + void NoAnchorView(View* view);
|
| +
|
| + void SetViewBounds(View* view, int x, int y, int width, int height);
|
| +
|
| + private:
|
| + struct AnchorState {
|
| + AnchorState();
|
| + AnchorState(Anchors anchors);
|
| + AnchorState(const AnchorState& state);
|
| + ~AnchorState();
|
| + Anchors anchors;
|
| + gfx::Point anchor_basis;
|
| + };
|
| + using AlignMap = std::map<const View*, Align>;
|
| + using AnchorMap = std::map<const View*, AnchorState>;
|
| + void AlignViews(View* host, Align align, gfx::Rect& contents);
|
| + bool FindAlign(View* view, Align* align);
|
| + bool FindAlign(const View* view, Align* align) const;
|
| + bool FindAnchorState(View* view, AnchorState** state);
|
| + void InternalUpdateAnchorBasis(View* view, AnchorMap::iterator pos);
|
| + void PlaceView(View* view, Align align, gfx::Rect& contents);
|
| + bool ShouldAlign(View* host);
|
| + bool ShouldInsert(View* child1, View* child2, Align align);
|
| + void UpdateAnchorAlign(View *view, Align align);
|
| + void UpdateAnchorBasis(View* view);
|
| + AlignMap align_map_;
|
| + AnchorMap anchor_map_;
|
| + gfx::Size last_host_size_;
|
| + DISALLOW_COPY_AND_ASSIGN(AlignLayoutState);
|
| +};
|
| +
|
| +} // namespace views
|
| +
|
| +#endif // UI_VIEWS_LAYOUT_FILL_LAYOUT_STATE_H_
|
|
|