#ifndef ASH_BUBBLE_SIMPLE_GRID_LAYOUT_H_
#define ASH_BUBBLE_SIMPLE_GRID_LAYOUT_H_
#include <optional>
#include "ash/ash_export.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/layout/layout_manager_base.h"
#include "ui/views/layout/proposed_layout.h"
namespace ash {
class ASH_EXPORT SimpleGridLayout : public views::LayoutManagerBase {
public:
explicit SimpleGridLayout(int column_count,
std::optional<int> column_spacing = std::nullopt,
std::optional<int> row_spacing = std::nullopt);
SimpleGridLayout(const SimpleGridLayout&) = delete;
SimpleGridLayout& operator=(const SimpleGridLayout&) = delete;
~SimpleGridLayout() override;
protected:
views::ProposedLayout CalculateProposedLayout(
const views::SizeBounds& size_bounds) const override;
void OnLayoutChanged() override;
gfx::Size GetPreferredSize(
const views::View* host,
const views::SizeBounds& available_size) const override;
private:
gfx::Size GetChildPreferredSize() const;
gfx::Size CalculatePreferredSize(int row_spacing, int column_spacing) const;
mutable std::optional<gfx::Size> cached_child_preferred_size_;
const int column_count_;
const std::optional<int> column_spacing_;
const std::optional<int> row_spacing_;
};
}
#endif