Discussion:
Proportional tab sizes (ugly patch).
ebik
2009-03-15 11:56:49 UTC
Permalink
Here I send patch for proportional tab sizes.

The patch itself is not acceptable because of two (interdependent)
issues:
1.) I haven't time to examine source code to optimize for speed, and
correct flow. (See using of 'complete' flag of
grbrush_draw_textboxes, etc.)
2.) It is the 'first shot' programming, i.e. it just works, but the
code itself is rather ugly (e.g., I haven't put the new function
in header file.)

But I haven't time for cleaning the code for next month or two, so I
send the patch as is.

--------------------------------------------------------------------

The algorithm now works in following way (I omit some border
widths here in the description as well as rounding errors.):

* There are two constants:
- float_tab_min_w (former tab_min_w, default 100)
... that is soft minimum width
- propor_tab_min_w (new, default 30, I did not write code for
redefinig) ... that is hard minimum width
Let "n" be number of tabs.

* If n*propor_tab_min_w is greater than space allocated to tabs
( ~ width of the frame in tiled workspace ), then tabs get sizes
proportionaly like it was before this patch.

|<--->| ... propor_tab_min_w
_____________________________________________
|T|A|B|S|_|T|H|A|T|_|A|R|E|_|T|O|O|_|M|A|N|Y|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* Else each tab gets at least propor_tab_min_w (even if it contains
shorter label).

* Now we set max_width to propor_tab_min_w, and we keep incrementing
max_width until all tabs have their width or we use all the space
reserved for tabs. In the latter case we stop and assign the widths
to the tabs.

|<--->| ... propor_tab_min_w
|<-------------->| ... float_tab_min_w
_____________________________________________
| tab | x |a long ta...|another l...| xx |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* At this point all tabs have sizes of their labels (but at least
propor_tab_min_w), but we may have some space left, now
flow_tab_min_w comes to play. We set min_width to propor_tab_min_w
and again we increment it until float_tab_min_w or all the space
reserved for tabs is used. In the latter case we again stop and
assign the widths.

|<-------------->| ... float_tab_min_w
_____________________________________________
|here is a long tab| tab | x |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


* Now, each tab has at least float_tab_min_w width. If the frame is
floating, then the tab sizes are used. If not, then remaining space
is distributed among tabs, where we want padded space to be same
for all tabs (but we don't shorten tabs that have float_tab_min_w
width)

|<-------------->| ... float_tab_min_w
tiled:
_____________________________________________
| tab | here is a long tab |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
float:
_______________________________________
| tab | here is a long tab |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


--

Loading...