add resize_fixed() function for widgets

This commit is contained in:
hippoz 2022-06-15 21:15:29 +03:00
parent 88849ea766
commit 0b4b3b1332
No known key found for this signature in database
GPG key ID: 7C52899193467641
2 changed files with 18 additions and 0 deletions

View file

@ -41,6 +41,23 @@ bool Widget::resize(double width, double height) {
return true;
}
bool Widget::resize_fixed(double width, double height) {
if (m_rect.width() == width && m_rect.height() == height)
return false;
if (width < 0 || height < 0)
return false;
m_rect.set_max_width(width);
m_rect.set_max_height(height);
m_rect.set_min_width(width);
m_rect.set_min_height(height);
m_rect.set_width(width);
m_rect.set_height(height);
reflow();
return true;
}
void Widget::move_to(double x, double y) {
if (m_rect.x() == x && m_rect.y() == y)
return;

View file

@ -48,6 +48,7 @@ public:
void move_to(double x, double y);
bool resize(double width, double height);
bool resize_fixed(double width, double height);
bool resize(Point &point) { return resize(point.x(), point.y()); }
std::vector<std::shared_ptr<Widget>> &children() { return m_children; }