Hierarchical widgets

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Hierarchical widgets

Post by Alberth »

In the past months, I have been busy re-writing the widgets system.
Instead of a flat array of Widget structs, I have made a tree of widgets, based on the 'is contained in' relation.

The new widgets know their own minimal size from their contents, and their resize step size. Together with the tree, the new widgets can compute the minimal size of the window they are kept in, and how the window can be resized.
This means eg that switching to another language will cause all the windows to get resized, so the new strings fit again in the windows.

The new widgets are more OO, which means that extending widgets with your own custom behavior is now possible.


With respect to the actual implementation, there are 3 currently windows implemented as a demo against revision 13920, the airport picker window (to show nested widgets), the intro-screen window (has lots of spacing around the widgets), and the news-history window (has a scrollbar). Of the latter, the mouse-wheel doesn't work yet.

(due to attachment limit, see next post for the widget implementation)
Attachments
airport_gui.patch
(19.4 KiB) Downloaded 155 times
intro_gui.patch
(9.86 KiB) Downloaded 154 times
news_gui.patch
(5.92 KiB) Downloaded 157 times
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: Hierarchical widgets

Post by Alberth »

The widgets are defined in window_gui.h (in the widget_defs.patch), and implemented in widget.cpp (widget_impl.patch). Other (mostly window interfacing) are in the final other_changes.patch

I consider this a proof of concept.
I'd like to know what the devs think, and whether (and if yes, how/in what direction) to proceed.


PS There are Doxygen doc strings everywhere, an overview of available widgets is in the widget_impl.patch
Attachments
widget_defs.patch
(29.68 KiB) Downloaded 189 times
widget_implementation.patch
(79.47 KiB) Downloaded 199 times
other_changes.patch
(17.98 KiB) Downloaded 150 times
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: Hierarchical widgets

Post by Alberth »

For those of you that expected pictures, the differences are very small, some widgets just moved a few pixels, really not worth putting a picture up.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Hierarchical widgets

Post by Zuu »

Without having read your patch, I suppose you have made quite a decent change to the widgets and widgets definition. Have you been in touch with the devs to get their thoughts on your idea? (easiest way to get in touch with the devs for discussion is on #openttd at irc.oftc.net)
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: Hierarchical widgets

Post by Alberth »

Zuu:
I am regularly at IRC, and have shown the intro-screen gui code there to several devs, so they know.
There is also FS1905 where I have been throwing windowing system code changes in, where most have been put into trunk already.

With respect to these changes, I haven't yet had a reaction, but they seem pretty much busy with convincing trains to share track with each other, and teach cargo about where it wants to go to, so I will wait a while longer before I ask.
In addition, starting this week, I went back to work so I have no time any way outside the weekend.


None the less, thank you for pointing it out.
Albert
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 12 guests