diff options
author | fvogel <fvogelnew1@free.fr> | 2017-03-31 21:27:49 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2017-03-31 21:27:49 (GMT) |
commit | 0a3a595f7f504259436d0a5e1d3c23245c1409a3 (patch) | |
tree | 65e5d6fd51c2e446c4dbec3ecdbb61df142e00ea /generic | |
parent | e683e17e9cdc17a8133ef73cd858fe8676c6e830 (diff) | |
download | tk-0a3a595f7f504259436d0a5e1d3c23245c1409a3.zip tk-0a3a595f7f504259436d0a5e1d3c23245c1409a3.tar.gz tk-0a3a595f7f504259436d0a5e1d3c23245c1409a3.tar.bz2 |
Fix [3089640fff], [6020ee2d03], [e016579efb] and [6bf197edbf]: ttk::notebook tabs can disappear (tab width incorrectly calculated). Patch from Koen Danckaert.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/ttk/ttkNotebook.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 81a8b64..ac13d5f 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -437,16 +437,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) /* SqueezeTabs -- * Squeeze or stretch tabs to fit within the tab area parcel. * - * All tabs are adjusted by an equal amount, but will not be made - * smaller than the minimum width. (If all the tabs still do - * not fit in the available space, the rightmost ones will - * be further squozen by PlaceTabs()). - * - * The algorithm does not always yield an optimal layout, but does - * have the important property that decreasing the available width - * by one pixel will cause at most one tab to shrink by one pixel; - * this means that tabs resize "smoothly" when the window shrinks - * and grows. + * All tabs are adjusted by an equal amount. * * @@@ <<NOTE-TABPOSITION>> bug: only works for horizontal orientations * @@@ <<NOTE-SQUEEZE-HIDDEN>> does not account for hidden tabs. @@ -458,25 +449,17 @@ static void SqueezeTabs( int nTabs = Ttk_NumberSlaves(nb->notebook.mgr); if (nTabs > 0) { - int difference = available - needed, - delta = difference / nTabs, - remainder = difference % nTabs, - slack = 0; + int difference = available - needed; + double delta = (double)difference / needed; + double slack = 0; int i; - if (remainder < 0) { remainder += nTabs; --delta; } - + /* Ignore minTabWidth; it's ignored in TabRowSize() too. */ for (i = 0; i < nTabs; ++i) { Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i); - int adj = delta + (i < remainder) + slack; - - if (tab->width + adj >= minTabWidth) { - tab->width += adj; - slack = 0; - } else { - slack = adj - (minTabWidth - tab->width); - tab->width = minTabWidth; - } + double ad = slack + tab->width * delta; + tab->width += (int)ad; + slack = ad - (int)ad; } } } |