The International Simutrans Forum

 

Author Topic: [patch] Ellipsis & Button Text Offset  (Read 3411 times)

0 Members and 1 Guest are viewing this topic.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2920
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
[patch] Ellipsis & Button Text Offset
« 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

« Last Edit: March 07, 2016, 03:16:34 AM by An_dz »

Offline Max-Max

  • Coder/patcher
  • *
  • Posts: 670
    • MK Development
  • Languages: SV,EN
Re: [patch] Ellipsis & Button Text Offset
« Reply #1 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...

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10828
  • Languages: De,EN,JP
Re: [patch] Ellipsis & Button Text Offset
« Reply #2 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

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2920
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [patch] Ellipsis & Button Text Offset
« Reply #3 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.
« Last Edit: May 05, 2014, 01:39:54 AM by An_dz »

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2920
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: Ellipsis & Button Text Offset
« Reply #4 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.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2920
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [patch] Ellipsis & Button Text Offset
« Reply #5 on: August 03, 2014, 12:49:26 AM »
Let me be boring here, anything against these patches?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10828
  • Languages: De,EN,JP
Re: [patch] Ellipsis & Button Text Offset
« Reply #6 on: August 06, 2014, 10:34:33 PM »
Sorry, was on holiday. Will check tomorrow.

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2920
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [patch] Ellipsis & Button Text Offset
« Reply #7 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10828
  • Languages: De,EN,JP
Re: [patch] Ellipsis & Button Text Offset
« Reply #8 on: August 11, 2014, 09:41:26 PM »
in r7290, thanks

Offline An_dz

  • Web Admin
  • Administrator
  • *
  • Posts: 2920
  • D'oh
    • by An_dz
  • Languages: pt, en, it, (de)
Re: [patch] Ellipsis & Button Text Offset
« Reply #9 on: August 23, 2014, 10:19:05 PM »
BTW, what about the triple offset?
« Last Edit: August 24, 2014, 06:59:04 PM by An_dz »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10828
  • Languages: De,EN,JP
Re: [patch] Ellipsis & Button Text Offset
« Reply #10 on: September 01, 2014, 02:49:47 PM »
I though that was all included. I have to check again.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10828
  • Languages: De,EN,JP
Re: [patch] Ellipsis & Button Text Offset
« Reply #11 on: September 16, 2014, 09:21:43 PM »
Ok, now also added then right bottom offsets in r7328. Back to other backlogs ...