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 | c5dc7621226a3234be4280cdc5c6c259e847fa50 (patch) | |
tree | 65e5d6fd51c2e446c4dbec3ecdbb61df142e00ea /generic | |
parent | b067e33b380775ccdb269def17dfb8699f22bf5a (diff) | |
download | tk-c5dc7621226a3234be4280cdc5c6c259e847fa50.zip tk-c5dc7621226a3234be4280cdc5c6c259e847fa50.tar.gz tk-c5dc7621226a3234be4280cdc5c6c259e847fa50.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; } } } |