My basic auto resizing is up and running. When the window resizes, widget can change it's position and size.
In my main Gui class (which controlls callbacks etc) I have:
I use it like this inside gui class:
And then when resizing, the widget keeps its position but changes its size according to resize delta.
There is simple code which does this:
It works very well. It's nothing like fancy layouting but it does its job and doesn't force you to write hundreds of onResize functions (I used to do that, meh!). Actually with little effort I have now a nice resizable layout in my gui!
Now my question is if you'd like to see it in TGUI (for example until you write layouting which as you said won't be complete in 0.6). We could discuss how I can change it to integrate it into TGUI in clean way.
Of course I understand that it isn't commonly used way to handle resizing - I created it for my very specific needs. So tell me what you think, if it's worth to implement something like that inside TGUI.
Code (cpp) Select
class ResizeBehaviour
{
public:
bool changeX = false;
bool changeY = false;
bool changeWidth = false;
bool changeHeight = false;
};
In my main Gui class (which controlls callbacks etc) I have:
Code (cpp) Select
std::vector<std::pair<tgui::Widget::Ptr, ResizeBehaviour>> m_widgets;
ResizeBehaviour & addWidget(tgui::Widget::Ptr wptr);
I use it like this inside gui class:
Code (cpp) Select
tgui::Wiget::Ptr widget(tgui);
auto rb = addWiget(widget);
rb.changeWidth = true;
rb.changeHeight = true;
And then when resizing, the widget keeps its position but changes its size according to resize delta.
There is simple code which does this:
Code (cpp) Select
if (m_app.input.isResized())
{
auto delta = m_app.input.getResizeDelta(); //it's vector2i
for (auto &i : m_widgets)
{
auto position = i.first->getPosition();
auto size = i.first->getSize();
if (i.second.changeX)
{
i.first->setPosition(position.x + delta.x, position.y);
position = i.first->getPosition();
}
if (i.second.changeY) i.first->setPosition(position.x, position.y + delta.y);
if (i.second.changeWidth)
{
i.first->setSize(size.x + delta.x, size.y);
size = i.first->getSize();
}
if (i.second.changeHeight) i.first->setSize(size.x, size.y + delta.y);
}
}
It works very well. It's nothing like fancy layouting but it does its job and doesn't force you to write hundreds of onResize functions (I used to do that, meh!). Actually with little effort I have now a nice resizable layout in my gui!
Now my question is if you'd like to see it in TGUI (for example until you write layouting which as you said won't be complete in 0.6). We could discuss how I can change it to integrate it into TGUI in clean way.
Of course I understand that it isn't commonly used way to handle resizing - I created it for my very specific needs. So tell me what you think, if it's worth to implement something like that inside TGUI.