Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close Button in window bar doesn't show X anymore #3033

Closed
DorpsGek opened this issue Jul 13, 2009 · 5 comments
Closed

Close Button in window bar doesn't show X anymore #3033

DorpsGek opened this issue Jul 13, 2009 · 5 comments
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

planetmaker opened the ticket and wrote:

The "X" string for the close button seems to be too long to fit properly into the close button of windows as shown in the attached screenshot. It goes for all windows. Tested in r16800.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/3033
@DorpsGek
Copy link
Member Author

Rubidium wrote:

Will eventually be fixed once the GUI rework is done.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3033#comment6322

@DorpsGek
Copy link
Member Author

Rubidium wrote:

For what it's worth, it only happens with OpenGFX


This comment was imported from FlySpray: https://bugs.openttd.org/task/3033#comment6325

@DorpsGek
Copy link
Member Author

Alberth wrote:

That was most helpful Rubidium, thank you for finding that out.

An analysis of the problem:
In r16798, the closebox rendering has been changed as follows:
@@ -518,7 +525,7 @@
{
assert(str == STR_BLACK_CROSS || str == STR_SILVER_CROSS); // black or silver cross
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_NONE);
- DrawString(r.left, r.right, r.top + WD_CLOSEBOX_TOP, str, TC_FROMSTRING, SA_CENTER);
+ DrawString(r.left + WD_CLOSEBOX_LEFT, r.right - WD_CLOSEBOX_RIGHT, r.top + WD_CLOSEBOX_TOP, str, TC_FROMSTRING, SA_CENTER);

In other words, the amount of space for the closebox string has been reduced by WD_CLOSEBOX_RIGHT pixels (which has the value 1). This constant has been calculated such that

WD_CLOSEBOX_LEFT + max(width(STR_BLACK_CROSS), width(STR_SILVER_CROSS)) + WD_CLOSEBOX_RIGHT == 11

(computation is near line 1987 in widget.cpp, search for NWidgetLeaf::closebox_dimension). This value 11 comes from the current width of the closebox widgets, see output of "grep WWT_CLOSEBOX src/*.cpp | grep CROSS | grep -v NWidget" (gives the WWT_CLOSEBOX widgets in many hardcoded widget arrays in the game).

When printing NWidgetLeaf::closebox_dimension.width after computing it near line 1987, ttdx graphics gives
Closebox dimension=11x14, STR_BLACK_CROSS=155 STR_SILVER_CROSS=156

while OpenGFX graphics gives
Closebox dimension=12x14, STR_BLACK_CROSS=155 STR_SILVER_CROSS=156

The OpenGFX closebox string is 1 pixel wider, and since r16798 cannot be printed anymore since all additional room for printing has been removed with the WD_CLOSEBOX_* constants. The program replaces the X with "..." to denote that the string was chopped which is what you see in 'close_button.png'. This is confirmed by the fact that the X does get printed with the rail toolbar and the town directory window, which both have dynamically resizing widgets, and by the fact that the X gets printed again after removal of "- WD_CLOSEBOX_RIGHT" around line 528.
For comparison, I have made a closeup of the closebox at r16304 and r16825 for both graphics sets, see 'closebox_overview' (where the bottom right picture was obtained after the hack discussed above.

As for solutions, there seem to exist at least 3 directions which are not mutually exclusive:
- Wait for all windows to be using nested widgets.
- Reduce the width of the X in the opengfx set.
- Remove the " - WD_CLOSEBOX_RIGHT" from the closebox rendering function. In this case however, the closebox does look weirdly placed imho.
Note that the last option does not affect the nested widgets, as around line 1987, the constant does get used to compute the correct width of the closebox.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/3033#comment6327

@DorpsGek
Copy link
Member Author

Ammler wrote:

As of revision r145 of OpenGFX, I reduced the close-x 1px on right and bottom, so it should fit again old windows. (and new)
https://dev.openttdcoop.org/issues/331 (Download: http://mz.openttdcoop.org/bundles/opengfx/nightlies/)
If the new x is ok, no further action is needed in that case. :-)


This comment was imported from FlySpray: https://bugs.openttd.org/task/3033#comment6366

@DorpsGek
Copy link
Member Author

DorpsGek commented Aug 2, 2009

Rubidium closed the ticket.

Reason for closing: Deferred

Will, as described be automatically fixed once #1905 is done. Also OpenGFX has a narrower close sprite.


This comment was imported from FlySpray: https://bugs.openttd.org/task/3033

@DorpsGek DorpsGek closed this as completed Aug 2, 2009
@DorpsGek DorpsGek added component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant