The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: An_dz on April 11, 2014, 12:49:23 AM

Title: [patch] Ellipsis & Button Text Offset
Post by: An_dz on April 11, 2014, 12:49:23 AM
Two patches, one complements the other.

The ellipsis_fix patch will check if the last character is smaller than the ellipsis and if true will remove another one so the ellipsis will fit inside the area. It may still fail if the ellipsis is still bigger than three "i" for example, but still is the best and fastest option without using temp array to store the last 3~4 characters width and do the checking.

The button_text_offset patch will apply the gui_button_text_offset you define in your theme.tab file to roundbox and box buttons by using the x value in both left and right borders and y only in top. This way the text is always centralized at horizontal.

This picture shows how both patches work, the first image is unpatched (how it's now), the second with the ellipsis_fix, and the third with button_text_offset and gui_button_text_offset=5,0 set in themes.tab

(http://i.imgur.com/QzALvsD.png)
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: Max-Max on April 11, 2014, 01:34:12 AM
I remember that I had fixed this in one of my original patches. To bad it never got implemented the way I wrote it. It would have saved us all the extra work.

Maybe I should have been harder when I noticed differences from my patches and Prissi's implementation of it, but I just didn't had the strength to bother anymore...
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: prissi on May 04, 2014, 10:03:09 PM
The patch is not very unicode like. Since we have anyway calculated the last matching character above, one should use it anyway, and even use the remaining space to center the text within the button. But thanks for pointing this out.

There are two kinds of different buttons offsets needed, so the existing one I renamed to gui_color_button_text_offset

Check -7192
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: An_dz on May 04, 2014, 10:32:27 PM
It doesn't compile. Error in gui_button.cc, must remove (scr_coord) in both area_text.set_pos. And you are using gui_button_text_offset in both, while it should use gui_color_button_text_offset in the box button.

Edit:
After testing I found the ellipses sometimes is over the last character, and so one of the dots sometimes disappear over the text.

And I think we need an offset in the right as well to prevent the last character from being over the border, like the second screen in the first post. And because you may create a theme where the right side of the button has some kind of graphic which should not be overlapped.

Edit 2:
Attached is a patch with a triple value offset. Just set the offsets as "left, top, right", parameter names were not changed.
Title: Re: Ellipsis & Button Text Offset
Post by: An_dz on May 21, 2014, 08:05:28 PM
Here's the patch that fixes the ellipsis again. I also added a check if we really want it to center align.
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: An_dz on August 03, 2014, 12:49:26 AM
Let me be boring here, anything against these patches?
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: prissi on August 06, 2014, 10:34:33 PM
Sorry, was on holiday. Will check tomorrow.
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: An_dz on August 07, 2014, 02:59:07 AM
Enjoy your holidays, I was looking for anyone that tested and found something wrong at first place.
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: prissi on August 11, 2014, 09:41:26 PM
in r7290, thanks
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: An_dz on August 23, 2014, 10:19:05 PM
BTW, what about the triple offset?
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: prissi on September 01, 2014, 02:49:47 PM
I though that was all included. I have to check again.
Title: Re: [patch] Ellipsis & Button Text Offset
Post by: prissi on September 16, 2014, 09:21:43 PM
Ok, now also added then right bottom offsets in r7328. Back to other backlogs ...