The International Simutrans Forum

 

Author Topic: New theme parameters and size changes  (Read 760 times)

0 Members and 1 Guest are viewing this topic.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
New theme parameters and size changes
« on: May 27, 2018, 09:49:32 PM »
This is more of a proposition than a patch but I would like to propose the following new parameters for themes:

Code: [Select]
gui_statusbar_height
gui_ticker_height
gui_window_controls_width
gui_window_controls_height

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 gui_theme_t.cc so when changing font size all elements that have text resize accordingly:
Code: [Select]
// 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4494
  • Languages: EN, DE, AT
Re: New theme parameters and size changes
« Reply #1 on: May 28, 2018, 06:12:43 AM »
Please go ahead :)

Offline Leartin

  • Devotee
  • *
  • Posts: 1088
  • PAK-DEV P192C
  • Languages: DE, EN
Re: New theme parameters and size changes
« Reply #2 on: May 28, 2018, 01:09:13 PM »
Is it yet possible to set the vertical alignment of text if the height defined in the gui exceeds the linespace? (top, middle, bottom)

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: New theme parameters and size changes
« Reply #3 on: May 28, 2018, 02:30:56 PM »
Are you asking for a parameter to set the vertical alignment as top, middle, bottom?

Offline Leartin

  • Devotee
  • *
  • Posts: 1088
  • PAK-DEV P192C
  • Languages: DE, EN
Re: New theme parameters and size changes
« Reply #4 on: May 29, 2018, 04:53:10 AM »
Yes.
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.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: New theme parameters and size changes
« Reply #5 on: May 29, 2018, 07:26:02 PM »
By default everything is middle aligned, except gadgets that are top aligned.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: New theme parameters and size changes
« Reply #6 on: June 02, 2018, 06:40:06 AM »
Update

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.

Online Yona-TYT ve

  • Devotee
  • *
  • Posts: 1156
    • Simutrans-BLOG
  • Languages: ES
Re: New theme parameters and size changes
« Reply #7 on: June 02, 2018, 12:21:52 PM »
Maybe one day this will be achieved.  ;D

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9313
  • Languages: De,EN,JP
Re: New theme parameters and size changes
« Reply #8 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.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4494
  • Languages: EN, DE, AT
Re: New theme parameters and size changes
« Reply #9 on: June 02, 2018, 01:31:25 PM »
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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9313
  • Languages: De,EN,JP
Re: New theme parameters and size changes
« Reply #10 on: June 02, 2018, 02:26:58 PM »
That sounds awesome, especially considering how many different GUI elements we have.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2836
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: New theme parameters and size changes
« Reply #11 on: June 02, 2018, 02:42:20 PM »
Well, then I'll pause my code to see what your code can do.

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.
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.
« Last Edit: June 02, 2018, 03:53:31 PM by An_dz »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9313
  • Languages: De,EN,JP
Re: New theme parameters and size changes
« Reply #12 on: June 03, 2018, 12:15:16 AM »
Agree on that too.