Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

New theme parameters and size changes

Started by An_dz, May 27, 2018, 09:49:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


This is more of a proposition than a patch but I would like to propose the following new parameters for themes:


Windows controls is what internally the code calls gadget, which are the window control buttons like close, help, pin.

And also I'll change the height of most elements to be at least the font height. The following is added to so when changing font size all elements that have text resize accordingly:

// check if text can fit
gui_theme_t::gui_titlebar_height     = max(LINESPACE, gui_theme_t::gui_titlebar_height);
gui_theme_t::gui_statusbar_height    = max(LINESPACE, gui_theme_t::gui_statusbar_height);
gui_theme_t::gui_ticker_height       = max(LINESPACE, gui_theme_t::gui_ticker_height);
gui_theme_t::gui_button_size.h       = max(LINESPACE, gui_theme_t::gui_button_size.h);
gui_theme_t::gui_color_button_size.h = max(LINESPACE, gui_theme_t::gui_color_button_size.h);
gui_theme_t::gui_checkbox_size.h     = max(LINESPACE, gui_theme_t::gui_checkbox_size.h);
gui_theme_t::gui_edit_size.h         = max(LINESPACE, gui_theme_t::gui_edit_size.h);
gui_theme_t::gui_pos_button_size.h   = max(LINESPACE, gui_theme_t::gui_pos_button_size.h);
gui_theme_t::gui_gadget_size = (gui_theme_t::gui_titlebar_height, gui_theme_t::gui_titlebar_height);

With those, changing the dialogues to have correct sizes will be less complex as there'll have no need to constantly check if LINESPACE is higher than the element size.

If anyone has any objection for the changes or wants to add another parameter tell me now so I can add those as I edit the dialogues.


Parsley, sage, rosemary, and maggikraut.


Is it yet possible to set the vertical alignment of text if the height defined in the gui exceeds the linespace? (top, middle, bottom)


Are you asking for a parameter to set the vertical alignment as top, middle, bottom?


Since font settings were implemented seperately from themes, you can't make sure that linespace and height of elements fits together. I think what Simutrans would do is use a "top"-alignment, simply because stuff is drawn top to bottom so it's the easiest to do (and it's what happened before, eg. if your checkboxes exceeded linespace). The default should probably be "middle", but I can also see situations where "top" or even "bottom" could be prefered.
For example, gadgets could be designed to be level with the bottom of the titlebar to seem like extensions of window below (same color, texture), but if they were center-aligned like most gadgets would want to be, this would not work at all.
Another example: Arrows, if two-sided (→, ▶).would want to be centered, but one-sided arrows (⇁,◤) might want to be aligned top or bottom.

Note that it would go both ways, since the user decides on the font size - so while most often the text would align to the elements, if the user chooses a large font, elements would need to align to the font.


By default everything is middle aligned, except gadgets that are top aligned.



I'm changing variable and function names, mostly translating and fixing typos but also renaming some to make the names clearer.

I'm getting rid of the theme macros, now I'm using gui_theme_t::gui_option everywhere. The macros can abstract too much and we may miss optimisations that can be done.

The colours of the little bars that show the vehicle's speed, loaded status or the bars in depot showing the current convoy size and tile size can be changed by the theme.

I'm not going to implement alignment control right now as I want to see where would be all possible uses and the best implementation.

I also want to make some questions about the coding style, and those are asked here.


Maybe one day this will be achieved.  ;D


Imho the uppercase macros tells me immediately that this is a constant I should/can not change. Also this is less letters for most entires, which is a point given that many position statesments are already quite long.


I am currently working on the gui as well. My idea was to write some code such that the gui elements position themselves, i.e., to get rid of all these magic calculations of positions and sizes. I will post a patch later this weekend.
Parsley, sage, rosemary, and maggikraut.


That sounds awesome, especially considering how many different GUI elements we have.


Well, then I'll pause my code to see what your code can do.

Quote from: prissi on June 02, 2018, 01:06:50 PM
Imho the uppercase macros tells me immediately that this is a constant I should/can not change. Also this is less letters for most entires, which is a point given that many position statesments are already quite long.
Quote from: prissi on June 02, 2018, 01:01:24 PM
About the magic D_MARGIN_... macros versus gui_theme_t..magin_... well, I think I like the macros. Any decent IDE can point me to the definition, and having six times gui_theme_t::xxx in a single line will not help increase readabilitz either. Having D_XXX+xpos makes immediately clear which is constant (UPPERCASE) and which is variable.
Good point, but the macros that have calculations should be removed as you think it just returns one thing, but it's actually a sum, with multiplication and two divisions.