News:

SimuTranslator
Make Simutrans speak your language.

Automatic gui patch

Started by Dwachs, June 03, 2018, 03:30:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dwachs

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)
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

It looks very good, I can not wait to see all the windows with their elements aligned correctly, greetings! and great work !.  ;D

An_dz

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?

Dwachs

#3
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
Parsley, sage, rosemary, and maggikraut.

An_dz

2. Nothing, just applied your patch on trunk. The below code shows that width is the width of the text.
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

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

An_dz

4) Ok, I can do this, I was already doing it anyway before your patch.

Dwachs

#7
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
Parsley, sage, rosemary, and maggikraut.

An_dz

Quote from: Dwachs on June 06, 2018, 09:22:22 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.

Dwachs

Parsley, sage, rosemary, and maggikraut.

Dwachs

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?
Parsley, sage, rosemary, and maggikraut.

An_dz

Sounds good, less windows to deal with.

Dwachs

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)
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Can you send an executable to test?

Dwachs

Parsley, sage, rosemary, and maggikraut.

prissi

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.


Dwachs

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?
Parsley, sage, rosemary, and maggikraut.

An_dz

Quote from: Dwachs on June 18, 2018, 05:59:32 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.

Yona-TYT

Quote from: Dwachs on June 18, 2018, 05:59:32 PMHere 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.  ;)

An_dz

That's not the scope of this patch, create an extension request thread so we don't forget it.

Yona-TYT

Quote from: An_dz on June 19, 2018, 12:01:04 AMThat'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.

Dwachs

@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?
Parsley, sage, rosemary, and maggikraut.

An_dz

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.

Dwachs

@Yona: have fixed this locally.

@An_dz: Patch compiles for me. Can you post the compile log? How do you compile?
Parsley, sage, rosemary, and maggikraut.

An_dz

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.


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

Dwachs

Thanks! corrected. This check was not active on my system, had to add -std=c++11 to the CFLAGS.
Parsley, sage, rosemary, and maggikraut.

An_dz

You must be on GCC4, all my gcc's are v6.0+, the default since then is C++14.

prissi

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.

Dwachs

#29
@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.
Parsley, sage, rosemary, and maggikraut.

An_dz

It would need for the scrolls components to touch the bottom and right edges but inside them set the margins for the content.

Dwachs

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
Parsley, sage, rosemary, and maggikraut.

prissi

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.

Dwachs

Quote from: prissi on June 23, 2018, 12:21:29 PMbecause 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.
Parsley, sage, rosemary, and maggikraut.

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.