diff options
author | fvogel <fvogelnew1@free.fr> | 2023-10-28 11:09:03 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2023-10-28 11:09:03 (GMT) |
commit | aaf23d7f4459807c471c0c183c43298dfae5ad6e (patch) | |
tree | df15e3f4f8c9c0270955bf7ca79b416617990fc5 /generic/ttk | |
parent | ce6721ee9864fc0df797cc68e36377e0cf7c4b4c (diff) | |
parent | 175bd29fa30803f63c3346585344a9f35b63dd17 (diff) | |
download | tk-aaf23d7f4459807c471c0c183c43298dfae5ad6e.zip tk-aaf23d7f4459807c471c0c183c43298dfae5ad6e.tar.gz tk-aaf23d7f4459807c471c0c183c43298dfae5ad6e.tar.bz2 |
Fix [198376af5a]: When moving tab position to different edge of notebook tabs may not appear.
Diffstat (limited to 'generic/ttk')
-rw-r--r-- | generic/ttk/ttkLayout.c | 7 | ||||
-rw-r--r-- | generic/ttk/ttkNotebook.c | 42 | ||||
-rw-r--r-- | generic/ttk/ttkThemeInt.h | 2 |
3 files changed, 33 insertions, 18 deletions
diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c index 948b95f..52a8ec5 100644 --- a/generic/ttk/ttkLayout.c +++ b/generic/ttk/ttkLayout.c @@ -31,6 +31,13 @@ Ttk_BoxContains(Ttk_Box box, int x, int y) && box.y <= y && y < box.y + box.height; } +int +TtkBoxEqual(Ttk_Box box1, Ttk_Box box2) +{ + return box1.x == box2.x && box1.y == box2.y + && box1.width == box2.width && box1.height == box2.height; +} + Tcl_Obj * Ttk_NewBoxObj(Ttk_Box box) { diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 6795dfc..c373587 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -510,6 +510,23 @@ static void PlaceTabs( } } +/* + * NotebookPlaceContent -- + * Set the position and size of a child widget + * based on the current client area and content window options: + */ +static void NotebookPlaceContent(Notebook* nb, Tcl_Size index) +{ + Tab* tab = (Tab*)Ttk_ContentData(nb->notebook.mgr, index); + Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, index); + Ttk_Box box = + Ttk_StickBox(Ttk_PadBox(nb->notebook.clientArea, tab->padding), + Tk_ReqWidth(window), Tk_ReqHeight(window), tab->sticky); + + Ttk_PlaceContent(nb->notebook.mgr, index, + box.x, box.y, box.width, box.height); +} + /* NotebookDoLayout -- * Computes notebook layout and places tabs. * @@ -525,6 +542,7 @@ static void NotebookDoLayout(void *recordPtr) Ttk_Element clientNode = Ttk_FindElement(nb->core.layout, "client"); Ttk_Box tabrowBox; NotebookStyle nbstyle; + Tcl_Size currentIndex = nb->notebook.currentIndex; NotebookStyleOptions(nb, &nbstyle); @@ -564,24 +582,12 @@ static void NotebookDoLayout(void *recordPtr) if (cavity.height <= 0) cavity.height = 1; if (cavity.width <= 0) cavity.width = 1; - nb->notebook.clientArea = cavity; -} - -/* - * NotebookPlaceContent -- - * Set the position and size of a child widget - * based on the current client area and content window options: - */ -static void NotebookPlaceContent(Notebook *nb, Tcl_Size index) -{ - Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); - Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, index); - Ttk_Box box = - Ttk_StickBox(Ttk_PadBox(nb->notebook.clientArea, tab->padding), - Tk_ReqWidth(window), Tk_ReqHeight(window),tab->sticky); - - Ttk_PlaceContent(nb->notebook.mgr, index, - box.x, box.y, box.width, box.height); + if (!TtkBoxEqual(nb->notebook.clientArea, cavity)) { + nb->notebook.clientArea = cavity; + if (currentIndex >= 0) { + NotebookPlaceContent(nb, currentIndex); + } + } } /* NotebookPlaceContents -- diff --git a/generic/ttk/ttkThemeInt.h b/generic/ttk/ttkThemeInt.h index e8d9665..23bbcd6 100644 --- a/generic/ttk/ttkThemeInt.h +++ b/generic/ttk/ttkThemeInt.h @@ -41,6 +41,8 @@ MODULE_SCOPE const char *Ttk_StyleName(Ttk_Style); MODULE_SCOPE void TtkSetBlinkCursorTimes(Tcl_Interp* interp); +MODULE_SCOPE int TtkBoxEqual(Ttk_Box, Ttk_Box); + #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) # define TTK_OPTION_UNDERLINE_DEF(type, field) "-1", offsetof(type, field), TCL_INDEX_NONE, 0, NULL #else |