Automatic container resizing when packing widgets.
parent
313f8a61ed
commit
de4987eee1
|
@ -138,6 +138,7 @@ void HBox::Pack(Widget *widget)
|
|||
widget->y = this->y;
|
||||
widget->h = this->h;
|
||||
if (widget->w < 0) widget->w = this->w - (widget->x - this->x);
|
||||
if (this->x + this->w < widget->x + widget->w) this->w = widget->x + widget->w - this->x;
|
||||
Container::Pack(widget);
|
||||
}
|
||||
|
||||
|
@ -148,5 +149,6 @@ void VBox::Pack(Widget *widget)
|
|||
widget->y = (last == NULL) ? this->y : (last->y + last->h + this->padding);
|
||||
widget->w = this->w;
|
||||
if (widget->h < 0) widget->h = this->h - (widget->y - this->y);
|
||||
if (this->y + this->h < widget->y + widget->h) this->h = widget->y + widget->h - this->y;
|
||||
Container::Pack(widget);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,18 @@ enum SliderPart {
|
|||
SP_HRIGHT,
|
||||
};
|
||||
|
||||
HSlider::HSlider(bool big, int h)
|
||||
{
|
||||
this->h = h;
|
||||
this->big = big;
|
||||
}
|
||||
|
||||
VSlider::VSlider(bool big, int w)
|
||||
{
|
||||
this->w = w;
|
||||
this->big = big;
|
||||
}
|
||||
|
||||
float HSlider::GetNewValue(int x, int y)
|
||||
{
|
||||
int x2 = this->x + pad;
|
||||
|
|
|
@ -22,12 +22,16 @@ struct Slider : Widget {
|
|||
};
|
||||
|
||||
struct HSlider : Slider {
|
||||
HSlider(bool big = false, int h = 24);
|
||||
|
||||
/* virtual */ float GetNewValue(int x, int y);
|
||||
|
||||
/* virtual */ void OnPaint(const PUi *pui) const;
|
||||
};
|
||||
|
||||
struct VSlider : Slider {
|
||||
VSlider(bool big = false, int w = 24);
|
||||
|
||||
/* virtual */ float GetNewValue(int x, int y);
|
||||
|
||||
/* virtual */ void OnPaint(const PUi *pui) const;
|
||||
|
|
Loading…
Reference in New Issue