The International Simutrans Forum

 

Author Topic: Automatic gui patch  (Read 2021 times)

0 Members and 1 Guest are viewing this topic.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Automatic gui patch
« on: June 03, 2018, 03:30:42 PM »
The idea of this patch is that the gui windows does all positioning and sizing of components themselves:
-- all components define minimal size that is necessary to draw them
-- they also define max_size if they can be drawn larger than minsize
The positioning and sizing is done by table-classes. That is, the windows are defined by nested tables, much like html tables decades ago...

In this way, changes of font and theme can be done without closing windows (in theory). All the theme parameters are only used in the component classes. They define the sizes of the components, everything else is done automatically.

This is all work in progress. Only the following windows are changed: new world, climate settings, settings window, the file selection dialogs (load, save, scenario, font, theme...), display settings, sound settings, go-to-tool, main menu.

Not done:
-- elements in tables that span multiple columns for better alignement of buttons.
-- force table columns to have width relative to each other

Edit: Patch attached.

Edit2: here http://files.simutrans.com/index.php/s/e89716JpNKBvcqr is a compiled file for windows (sim-automatic-gui.exe)
« Last Edit: June 03, 2018, 06:53:28 PM by Dwachs »

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: Automatic gui patch
« Reply #1 on: June 03, 2018, 10:36:07 PM »
It looks very good, I can not wait to see all the windows with their elements aligned correctly, greetings! and great work !.  ;D

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #2 on: June 04, 2018, 11:37:42 PM »
I had the time to check it out today and it's very cool. Here's what I think should be changed.

1) Element heights should be compared to LINESPACE in gui_theme_t when theme is loaded or font-size is changed instead of on every element definition.
2) Elements resizing if their texts are larger than their sizes break layouts unless all other elements resize at the same time. Check image.
3) Elements returning sizes with sums with D_(H|V)_SPACE is wrong. The right margin won't be correct.
4) Some elements have magic numbers. +2, +4 should not be there.
5) Why some places subtract 1 from scr_size::inf and others don't?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #3 on: June 05, 2018, 06:17:12 AM »
Thank you for testing!

1) yes, you are right. This should be done after this patch is committed. One of the points of the patch is to separate all these theme-constants away from the gui objects. Such that changing the component definitions is enough.
2) Will have to test. What did you do to get this picture? Edit: I suspect the screenshot is from current trunk, not patched (?)
3) Which elements you refer to? Some elements use this to define some internal distance to boundary (text in buttons).
4) Which elements? I suppose gui_label_stationname_t, which is a new helper element class, but all the magic is already in the existing code. I have to take what I find. I agree, magic numbers should not be there. But this is not the point of the patch.
5) This is not well documented:
-- min_size == the size this element needs and gets
-- max_size > min_size: if the table cell of the element is larger than min_size, then the element is enlarged up to max-size.
-- max_size == scr_size::inf-1 means the element can be enlarged arbitrarily, but it will only be enlarged up to min-size of surrounding elements (e.g. buttons filling the cell in a  button table)
-- max_size == scr_size::inf means the element can be enlarged arbitrarily (like scroll_panes), and they will be enlarged if possible
« Last Edit: June 05, 2018, 11:46:02 AM by Dwachs »

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #4 on: June 05, 2018, 02:01:49 PM »
2. Nothing, just applied your patch on trunk. The below code shows that width is the width of the text.
Code: [Select]
case box:
case roundbox: {
scr_coord_val w = translated_text ?  2*D_H_SPACE + proportional_string_width( translated_text ) : 0;
scr_size size(gui_theme_t::gui_button_size.w, max(D_BUTTON_HEIGHT,LINESPACE));
size.w = max(size.w, w);
return size;
}

3. gui_label_t is one, it returns text_width + spacing.

4. numberinput, scrollbar, textinput are some.

5. Thanks

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #5 on: June 06, 2018, 06:21:41 AM »
2) I did some last-minute change which breaks the new-world dialog
3) ok, will remove them
4) magic numbers have to be addressed after this patch is committed.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #6 on: June 06, 2018, 12:19:25 PM »
4) Ok, I can do this, I was already doing it anyway before your patch.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #7 on: June 06, 2018, 09:22:22 PM »
Here is a modification: some simple windows like language selection also use new scheme. The broken new-world dialogue should be fixed.

Does anybody need the text-input field in the load-theme window? Without looking in the code, I have no idea, what should be entered there.

Edit: patch is broken. Will post new one later
« Last Edit: June 07, 2018, 06:38:59 PM by Dwachs »

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #8 on: June 06, 2018, 09:48:45 PM »
Does anybody need the text-input field in the load-theme window? Without looking in the code, I have no idea, what should be entered there.
No, that's why current trunk doesn't have one. Your patch introduced it, the same happens on the pakset selector screen.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #9 on: June 07, 2018, 05:47:08 AM »
:) then the solution is easy

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #10 on: June 08, 2018, 06:54:53 AM »
I am currently working on the factory window. This is one of the worst dialogues to put into the new framework. Lots of magic button alignment against text buffers.

I would to convert the window in the following way. Currently, the 'Statistics' button opens a field with charts and many buttons. After button press the button jumps away. The 'Details' buttons opens a new window with some text about the particular factory type. Instead of these two buttons I would like to introduce three tabs:
-- 'Connections' all the connections to other factories, cities, stops
-- 'Statistics' the statistics and colored buttons
-- 'Details' the factory description

What do you think?

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #11 on: June 08, 2018, 01:35:17 PM »
Sounds good, less windows to deal with.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #12 on: June 08, 2018, 05:12:42 PM »
Here is a snapshot of the internally reworked factory window.  The indicators for production boost will be shown with semi-transparent black outline image when not active, full colored when active. Still some way to go. The connection info is now a table with a lot of cells, not produced by magic interplay of a large text buffer and luckily placed images. (Only exception is the halt list, this is still text buffer based but good for now)

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: Automatic gui patch
« Reply #13 on: June 08, 2018, 05:34:40 PM »
Can you send an executable to test?

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #14 on: June 09, 2018, 03:06:32 PM »
Here is an update: factory window is fully reworked

Windows executable
http://files.simutrans.com/index.php/s/e89716JpNKBvcqr

Patch
http://files.simutrans.com/index.php/s/2uJNLjYYnP1wUmS

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9126
  • Languages: De,EN,JP
Re: Automatic gui patch
« Reply #15 on: June 10, 2018, 12:00:21 PM »
I am very much pleased with this design and the idea behind. I will do a release as soon as possible (the stable has really many bad bugs concerning network play and ship routing with channels). Just after this I will try to contribute as well.

At least some of the list windows has been switched to the scrolled list, which woul make those easier as well.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: Automatic gui patch
« Reply #16 on: June 10, 2018, 12:49:03 PM »
@Dwachs
Can you also touch up the screen settings window ?.

https://forum.simutrans.com/index.php/topic,18195.msg172951.html#msg172951

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #17 on: June 18, 2018, 05:59:32 PM »
Here is a new version. Following windows were changed: minimap, enlarge map, convoy info, the small object info windows.

Patch: http://files.simutrans.com/index.php/s/l7867hyVyEXqDbD
Windows Exe: http://files.simutrans.com/index.php/s/e89716JpNKBvcqr

Question: I would like to put the conoy details in an extra tab (not an extra window). What do you think?

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #18 on: June 18, 2018, 08:12:59 PM »
Question: I would like to put the conoy details in an extra tab (not an extra window). What do you think?
Yes, please. It's more consistent and you hardly need to see that info with the data from the other tabs.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: Automatic gui patch
« Reply #19 on: June 18, 2018, 11:49:53 PM »
Here is a new version. Following windows were changed: minimap, enlarge map, convoy info, the small object info windows. Patch: http://files.simutrans.com/index.php/s/l7867hyVyEXqDbD Windows Exe: http://files.simutrans.com/index.php/s/e89716JpNKBvcqr Question: I would like to put the conoy details in an extra tab (not an extra window). What do you think?
I would like the mini-map window to zoom in on the position of the cursor, that would be more intuitive in my humble opinion.  ;)

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #20 on: June 19, 2018, 12:01:04 AM »
That's not the scope of this patch, create an extension request thread so we don't forget it.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: Automatic gui patch
« Reply #21 on: June 19, 2018, 12:15:33 AM »
That's not the scope of this patch, create an extension request thread so we don't forget it.
I am sorry.  :-[


This work looks great !!.

Two details here:

The buttons are not stretched when enlarging the convoys window.




Here the image says everything.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #22 on: June 19, 2018, 06:04:02 AM »
@Yona: Why should these buttons stretch?

Second image: this is indeed a bug. Did you change the size of the window to be smaller than the image?

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #23 on: June 19, 2018, 10:59:13 AM »
The patch file seems to be broken, I did not take a close look for what it could be but it's not compiling, clean branch.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #24 on: June 19, 2018, 05:22:44 PM »
@Yona: have fixed this locally.

@An_dz: Patch compiles for me. Can you post the compile log? How do you compile?

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #25 on: June 19, 2018, 07:46:46 PM »
Ok, checked what was the problem and it's complaining at OVERRIDE on speedbar component. You forgot to remove it on the definition and you're using it both in the declaration and definition, the spec says it must be at the declaration, and in definition only if inside the class itself.

Code: [Select]
In file included from gui/components/../../display/../dataobj/loadsave.h:14:0,
                 from gui/components/../../display/scr_coord.h:5,
                 from gui/components/gui_komponente.h:11,
                 from gui/components/gui_speedbar.h:11,
                 from gui/components/gui_speedbar.cc:10:
gui/components/../../display/../dataobj/../simtypes.h:63:19: error: virt-specifiers in 'get_min_size' not allowed outside a class definition
 # define OVERRIDE override
                   ^
gui/components/gui_speedbar.cc:30:47: note: in expansion of macro 'OVERRIDE'
 scr_size gui_speedbar_t::get_min_size() const OVERRIDE
                                               ^~~~~~~~
gui/components/../../display/../dataobj/../simtypes.h:63:19: error: virt-specifiers in 'get_max_size' not allowed outside a class definition
 # define OVERRIDE override
                   ^
gui/components/gui_speedbar.cc:35:47: note: in expansion of macro 'OVERRIDE'
 scr_size gui_speedbar_t::get_max_size() const OVERRIDE
                                               ^~~~~~~~
make: *** [common.mk:51: build/default/gui/components/gui_speedbar.o] Error 1

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #26 on: June 19, 2018, 08:39:06 PM »
Thanks! corrected. This check was not active on my system, had to add -std=c++11 to the CFLAGS.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #27 on: June 20, 2018, 04:17:57 AM »
You must be on GCC4, all my gcc's are v6.0+, the default since then is C++14.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9126
  • Languages: De,EN,JP
Re: Automatic gui patch
« Reply #28 on: June 20, 2018, 12:27:52 PM »
I think the tab element (like in convoi info) should have full width, so that the scrollbar is at the right side. A scrollbar shortly away from the border is strange to me.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #29 on: June 20, 2018, 02:09:37 PM »
@prissi: This is hard to change with the patch, as the scroll-pane is not a component of the window, but deeper in a tree of nested tables and components. Edit: should be possible with some play with margins.
« Last Edit: June 20, 2018, 04:37:51 PM by Dwachs »

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2804
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Automatic gui patch
« Reply #30 on: June 20, 2018, 06:20:15 PM »
It would need for the scrolls components to touch the bottom and right edges but inside them set the margins for the content.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #31 on: June 23, 2018, 11:26:49 AM »
Here is a new version. New windows patched: schedule edit and stop info. I also would like to put stop details in a tab instead into new window.

patch: http://files.simutrans.com/index.php/s/NiTP9evFFdRRRFP
exe: http://files.simutrans.com/index.php/s/e89716JpNKBvcqr

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9126
  • Languages: De,EN,JP
Re: Automatic gui patch
« Reply #32 on: June 23, 2018, 12:21:29 PM »
I am really looking forward on this 4th(!) iteration of new GUI code. I still have to look into the patch, because I think the must be a way to have the tab filling the entire window.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #33 on: June 23, 2018, 12:38:33 PM »
because I think the must be a way to have the tab filling the entire window.

You want this to force the scroll-bars to the edge of the window? As the scroll-bars do not scroll the entire window, it makes sense that they are not attached to the window border, imho.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: Automatic gui patch
« Reply #34 on: June 24, 2018, 10:15:27 AM »
I am currently working on the finance window. I would like to get rid of the headquarter-stuff there. I would like to implement the following changes:
-- finance window: add button 'Show headquater' (if there is one) 'Build headquarter' (if there is none).
-- new headquarter object window: when clicked on the headquarter, open a new window with the information about the headquarter. Add button 'Upgrade' to this window.