Add ui::asymmetric element that supports width_first() reshaping
This commit is contained in:
parent
0b3ef5f4f5
commit
9a2c562eec
6 changed files with 34 additions and 14 deletions
18
libs/ui/include/psemek/ui/asymmetric.hpp
Normal file
18
libs/ui/include/psemek/ui/asymmetric.hpp
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <psemek/ui/element.hpp>
|
||||||
|
|
||||||
|
namespace psemek::ui
|
||||||
|
{
|
||||||
|
|
||||||
|
struct asymmetric
|
||||||
|
: element
|
||||||
|
{
|
||||||
|
virtual void set_width_first(bool value);
|
||||||
|
virtual bool width_first() const { return width_first_; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool width_first_ = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <psemek/ui/element.hpp>
|
#include <psemek/ui/asymmetric.hpp>
|
||||||
|
|
||||||
namespace psemek::ui
|
namespace psemek::ui
|
||||||
{
|
{
|
||||||
|
|
||||||
struct container
|
struct container
|
||||||
: element
|
: asymmetric
|
||||||
{
|
{
|
||||||
virtual bool add_child(std::shared_ptr<element> c) = 0;
|
virtual bool add_child(std::shared_ptr<element> c) = 0;
|
||||||
virtual bool has_child(element * c) const = 0;
|
virtual bool has_child(element * c) const = 0;
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,6 @@ namespace psemek::ui
|
||||||
virtual void set_outer_margin(bool value);
|
virtual void set_outer_margin(bool value);
|
||||||
virtual bool outer_margin() const { return outer_margin_; }
|
virtual bool outer_margin() const { return outer_margin_; }
|
||||||
|
|
||||||
virtual void set_width_first(bool value);
|
|
||||||
virtual bool width_first() const { return width_first_; }
|
|
||||||
|
|
||||||
geom::box<float, 2> size_constraints() const override;
|
geom::box<float, 2> size_constraints() const override;
|
||||||
|
|
||||||
geom::interval<float> width_constraints(float height) const override;
|
geom::interval<float> width_constraints(float height) const override;
|
||||||
|
|
@ -70,7 +67,6 @@ namespace psemek::ui
|
||||||
std::vector<float> column_weight_;
|
std::vector<float> column_weight_;
|
||||||
|
|
||||||
bool outer_margin_ = true;
|
bool outer_margin_ = true;
|
||||||
bool width_first_ = true;
|
|
||||||
|
|
||||||
box_shape shape_;
|
box_shape shape_;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <psemek/ui/element.hpp>
|
#include <psemek/ui/asymmetric.hpp>
|
||||||
|
|
||||||
namespace psemek::ui
|
namespace psemek::ui
|
||||||
{
|
{
|
||||||
|
|
||||||
struct single_container
|
struct single_container
|
||||||
: element
|
: asymmetric
|
||||||
{
|
{
|
||||||
children_range children() const override { return children_; }
|
children_range children() const override { return children_; }
|
||||||
|
|
||||||
|
|
|
||||||
12
libs/ui/source/asymmetric.cpp
Normal file
12
libs/ui/source/asymmetric.cpp
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include <psemek/ui/asymmetric.hpp>
|
||||||
|
|
||||||
|
namespace psemek::ui
|
||||||
|
{
|
||||||
|
|
||||||
|
void asymmetric::set_width_first(bool value)
|
||||||
|
{
|
||||||
|
width_first_ = value;
|
||||||
|
post_reshape();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -149,12 +149,6 @@ namespace psemek::ui
|
||||||
post_reshape();
|
post_reshape();
|
||||||
}
|
}
|
||||||
|
|
||||||
void grid_layout::set_width_first(bool value)
|
|
||||||
{
|
|
||||||
width_first_ = value;
|
|
||||||
post_reshape();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <int Dimension>
|
template <int Dimension>
|
||||||
static std::vector<geom::interval<float>> cell_sizes(util::array<std::shared_ptr<element>, 2> const & children)
|
static std::vector<geom::interval<float>> cell_sizes(util::array<std::shared_ptr<element>, 2> const & children)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue