raven/src/BoxLayout.hpp
2022-07-28 18:54:06 +03:00

47 lines
934 B
C++

#pragma once
#include "Layout.hpp"
#include "Widget.hpp"
#include "Box.hpp"
#include <memory>
#include <vector>
namespace Raven {
class BoxLayout : public Layout {
public:
enum class SlotType {
No,
Percent,
Pixel,
Auto
};
struct Slot {
double percent, pixel;
SlotType type;
};
public:
BoxLayout(Direction direction)
: Layout()
, m_direction(direction) {}
~BoxLayout() {}
void run();
void slot_percent(double percent);
void slot_pixel(double pixel);
void slot_pixel(double pixel, double times);
void set_margin(double margin) { m_margin = margin; }
double &margin() { return m_margin; }
void set_spacing(double spacing) { m_spacing = spacing; }
double &spacing() { return m_spacing; }
private:
double m_margin { 0.0 };
double m_spacing { 0.0 };
std::vector<Slot> m_slots;
Direction m_direction { Direction::Horizontal };
};
}