FS#1950 - More flexible toolbar

Attached to Project: OpenTTD
Opened by Dominik (Dominik) - Thursday, 24 April 2008, 16:50 GMT
Type Patch
Category Interface
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


This patch makes the main toolbar a bit more flexible for small screens. For any screen width greater then 440 pixels (20 [icons] x 22 [pixel width]) it behaves as usual. Below that, it splits the toolbar in two parts. You can switch between those two parts with the (new) last button. It always tries to find a good setup of the buttons so that important buttons (pause, zoom, ...) are available on both toolbars and so that similar buttons are grouped (build rail, build road, ...).

This works down to a width of 280 (14 [icons] x 22 [pixels]). Below that it shuffles the buttons on the split toolbar together again.

Caveat: Not all toolbar sizes are perfect regarding the button setup. It works pretty well with 16 buttons (NDS, small icons) and also 20 buttons (PPC, small icons). What could be done is replacing the awkward priority/order algorithm with a simple table for all seven (14..20) possible sizes.

Missing: I didn't add a new sprite for the "switch screen" button yet. And there's no string for the tooltip.
This task depends upon

Closed by  Remko Bijker (Rubidium)
Thursday, 29 May 2008, 23:33 GMT
Reason for closing:  Implemented
Additional comments about closing:  In r13339.
Comment by Remko Bijker (Rubidium) - Thursday, 24 April 2008, 17:42 GMT
Why does the company league button need to go?
Comment by Dominik (Dominik) - Thursday, 24 April 2008, 18:19 GMT
Well, that kinda carried over from the NDS port...
With the Company League button there are 27 standard buttons. Plus 2 buttons to switch the toolbar. That's a total of 29 buttons. When you spread them over the both toolbars (32 buttons) you'll end up with 3 spare buttons that you can assign to both toolbars. But I wanted to have pause, fast forward, zoom in and zoom out on both toolbars.
And when you think about it, both menu entries from the company league button fit very well under the graphs button. At least I think so. :)
Comment by Dominik (Dominik) - Thursday, 08 May 2008, 23:33 GMT
Ok, here's a new version of my diff. I made static lists for all reasonable sizes. Should be easier to maintain. I think it integrates very nicely and non-intrusive into the current code.
Comment by Dominik (Dominik) - Thursday, 08 May 2008, 23:50 GMT
Add( GrainOf( _coding_style ) );
Comment by Dominik (Dominik) - Tuesday, 27 May 2008, 08:48 GMT
Updated to r13280.
Trunk inclusion and/or comments would be much appreciated.