The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: kierongreen on October 21, 2013, 12:35:35 PM

Title: rather large gui translate patch
Post by: kierongreen on October 21, 2013, 12:35:35 PM
http://simutrans-germany.com/files/upload/6844-gui-translate.zip (http://simutrans-germany.com/files/upload/6844-gui-translate.zip)

This arose from my patch to have clipping for scr_coord. However latest gui_theme updates means that adding those meant changing another bit of code and so on... So eventually I ended up with this - all (on screen) koords in gui are now scr_coord, zeichnen is draw, gr(oesse) is size, fenstergroesse is windowsize. The clipping is still buried in there somewhere too :p
Title: Re: rather large gui translate patch
Post by: Dwachs on October 21, 2013, 03:57:03 PM
I also thought of doing this.

One thought: should window size rather translate to scr_size instead of scr_coord? Would make the patch larger as the x and y fields have to change to w and h...
Title: Re: rather large gui translate patch
Post by: kierongreen on October 21, 2013, 04:01:54 PM
Good point! Erm, I'll have a look!
Title: Re: rather large gui translate patch
Post by: prissi on October 21, 2013, 07:31:33 PM
I think it should indeed do size for most groesse and hence w and h instead x and y

Anyway, as most of the dialogue changes are out, please go ahead.
Title: Re: rather large gui translate patch
Post by: kierongreen on October 22, 2013, 09:01:55 PM
Ok new version this uses scr_size for almost all sizes - it's not actually that much bigger as most code was around parts already being patched.

I'm not entirely happy with the resulting code though - whereas scr_coord = scr_coord + scr_coord is fairly obvious, code now has scr_size + scr_coord = scr_size and scr_size + scr_size = scr_size (neither of which seem quite right to me, scr_size + scr_delta_size = scr_size seems most logical but that's yet another type which I'm certainly not suggesting!). There's also some parts where some hacks have to be used to convert back and forth between scr_size and scr coord. In some ways I wonder why scr_size was necessary at all but anyway...

http://simutrans-germany.com/files/upload/6848-gui-translate.zip

If people are happy with this then I'll commit.
Title: Re: rather large gui translate patch
Post by: prissi on October 22, 2013, 09:38:06 PM
If you have a scr_rect, operator magic allows you to extend its size by adding sizes and shift origins by adding coord. That obviously assumes that componenets and frames use scr_rect instead coor and sizes ...
Title: Re: rather large gui translate patch
Post by: Dwachs on October 23, 2013, 06:05:16 AM
Imho These types naturally lend to the following operators

size + size = size
coord + size = coord
coord - coord = size

anything else should be not allowed:

coord + coord = ?? - at least one of them is an offset - aka size
size + coord = coord ???


Edit: I see the difficulty. Technically all the positions of gui elements are just offsets (not actual screen coordinates). In order to get this 'right', the element's positions need to an offset/size type instead of a coord type. But then all the + and - operations are sensible, so changing position to be scr_size does not offer any gain over the current implementation: which would be compiler-side checks whether certain stunts with coordinates are allowed...
Title: Re: rather large gui translate patch
Post by: kierongreen on October 23, 2013, 07:03:57 AM
Quoteso changing position to be scr_size does not offer any gain over the current implementation: which would be compiler-side checks whether certain stunts with coordinates are allowed...
Indeed. However changing pairs of coordinates (pos, size) to rect does offer potential to tidy code.

I think I'll remove the scr_size changes by reverting to my 6844 patch and just add scr_rect instead where appropriate. Another thing I'm interested in is maybe merging clip_dimension with scr_rect. This might mean adding xx and yy to scr_rect but would allow considerable code tidying.
Title: Re: rather large gui translate patch
Post by: Dwachs on October 23, 2013, 09:23:59 AM
Why revert?

I took your patch further to completely get rid of the mix of koord and scr_*, see patch below.

http://simutrans-germany.com/files/upload/6849-gui-translate.zip
Title: Re: rather large gui translate patch
Post by: prissi on October 23, 2013, 12:08:32 PM
Maybe the gui?... stuff should remove pos and groesse in favour of a scr_rect. get_pos() and set_pos() would still work, but think like getroffen would be much easier.
Title: Re: rather large gui translate patch
Post by: kierongreen on October 23, 2013, 04:18:59 PM
Quote from: prissi on October 23, 2013, 12:08:32 PM
Maybe the gui?... stuff should remove pos and groesse in favour of a scr_rect. get_pos() and set_pos() would still work, but think like getroffen would be much easier.
Yes that's what I was thinking. There's a few other places where code could be significantly tidied.

Quote from: Dwachs on October 23, 2013, 09:23:59 AM
Why revert?

I took your patch further to completely get rid of the mix of koord and scr_*, see patch below.

http://simutrans-germany.com/files/upload/6849-gui-translate.zip
Just wasn't especially happy with some bits of scr_size but if you've managed to sort that fantastic :) Will try to complete the rectangle conversion now...
Title: Re: rather large gui translate patch
Post by: Dwachs on November 19, 2013, 07:41:48 AM
any progress?

Should we throw in this patch?
Title: Re: rather large gui translate patch
Post by: kierongreen on November 19, 2013, 08:13:52 AM
I've not made any more changes.
Title: Re: rather large gui translate patch
Post by: Dwachs on November 19, 2013, 09:02:01 AM
Then I would like to update the patch and commit it.

Any opinions?
Title: Re: rather large gui translate patch
Post by: prissi on November 19, 2013, 11:57:45 AM
Well, I think the submission of the scaleable GUI might have broke this patch but no, please go ahead.
Title: Re: rather large gui translate patch
Post by: Dwachs on November 20, 2013, 08:33:09 PM
This is now in r6911. I hope, nothing is broken...
Title: Re: rather large gui translate patch
Post by: prissi on November 20, 2013, 09:53:02 PM
Thank you.
Title: Re: rather large gui translate patch
Post by: kierongreen on November 20, 2013, 11:05:20 PM
Many thanks.