raven/src/Box.hpp
hippoz 1ceb227165
respect slotted widget rectangle extents in boxlayout
currently thinking of a way to make unslotted widgets respect minimum
and maximum extents.
2022-07-09 20:19:09 +03:00

74 lines
2 KiB
C++

#pragma once
#include "Point.hpp"
namespace Raven {
enum class Direction {
Horizontal,
Vertical
};
class Box {
private:
double m_x {0};
double m_y {0};
double m_width {0};
double m_height {0};
double m_max_width {-1};
double m_max_height {-1};
double m_min_width {-1};
double m_min_height {-1};
public:
Box() {}
Box(double x, double y, double width, double height)
: m_x(x)
, m_y(y)
, m_width(width)
, m_height(height)
{
}
Box max_geometry();
Box min_geometry();
double x() { return m_x; }
double y() { return m_y; }
double width() { return m_width; }
double height() { return m_height; }
double min_width() { return m_min_width; }
double min_height() { return m_min_height; }
double max_width() { return m_max_width; }
double max_height() { return m_max_height; }
double x() const { return m_x; }
double y() const { return m_y; }
double width() const { return m_width; }
double height() const { return m_height; }
double min_width() const { return m_min_width; }
double min_height() const { return m_min_height; }
double max_width() const { return m_max_width; }
double max_height() const { return m_max_height; }
void set_x(double x) { m_x = x; }
void set_y(double y) { m_y = y; }
void set_width(double width);
void set_height(double height);
void set_max_width(double max_width) { m_max_width = max_width; set_width(m_width); }
void set_max_height(double max_height) { m_max_height = max_height; set_height(m_height); }
void set_min_width(double min_width) { m_min_width = min_width; set_width(m_width); }
void set_min_height(double min_height) { m_min_height = min_height; set_height(m_height); }
void update();
bool contains_point(double x, double y) const;
bool contains_point(const Point &point) const;
bool contains_box(const Box &other) const;
Box offset(double x, double y);
};
}