From ad152b24a36e1873442ddc4a81f2e35485329527 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Fri, 2 Sep 2022 12:09:56 +0200 Subject: [PATCH] fixed and simplified toggle_fullscreen() --- src/xinit.c | 36 ++++++++++++++---------------------- src/xschem.tcl | 27 ++++++++++++++------------- 2 files changed, 28 insertions(+), 35 deletions(-) diff --git a/src/xinit.c b/src/xinit.c index 67265c1c..54cf77cd 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -602,7 +602,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path) xctx->draw_single_layer = -1; xctx->draw_dots = 1; xctx->only_probes = 0; - xctx->menu_removed = 0; /* fullscreen pervious setting */ + xctx->menu_removed = 0; /* fullscreen previous setting */ xctx->save_lw = 0.0; /* used to save linewidth when selecting 'only_probes' view */ xctx->onetime = 0; /* callback() static var */ xctx->save_netlist_type = 0; @@ -1030,35 +1030,27 @@ void toggle_fullscreen(const char *topwin) XQueryTree(display, topwin_id, &rootwindow, &parent_id, &framewin_child_ptr, &framewindow_nchildren); fs = tclgetintvar("fullscreen"); fs = (fs+1)%3; - if(fs==1) tclsetvar("fullscreen","1"); - else if(fs==2) tclsetvar("fullscreen","2"); - else tclsetvar("fullscreen","0"); + if(fs==1) tclsetvar("fullscreen","1"); /* full screen with menubar, toolbar, tabs, statusbar */ + else if(fs==2) tclsetvar("fullscreen","2"); /* full screen with only drawing area */ + else tclsetvar("fullscreen","0"); /* normal view */ dbg(1, "toggle_fullscreen(): fullscreen=%d\n", fs); if(fs==2) { if(tclgetboolvar("toolbar_visible")) { - xctx->menu_removed |= 2; + xctx->menu_removed |= 2; /* menu_removed bit 1 == 1: toolbar was removed */ tclvareval("toolbar_hide ", xctx->top_path, NULL); } tclvareval("pack forget ", xctx->top_path, ".tabs", NULL); - tclvareval("pack forget ", xctx->top_path, ".menubar ", - xctx->top_path, ".statusbar; update", NULL); - xctx->menu_removed |= 1; - } - if(fs !=2 && xctx->menu_removed ) { + tclvareval("pack forget ", xctx->top_path, ".menubar", NULL); + tclvareval("pack forget ", xctx->top_path, ".statusbar", NULL); + xctx->menu_removed |= 1; /* menu_removed bit 0 == 1: other bars were removed */ + } else if(xctx->menu_removed) { /* bars were removed so pack them back */ + tclvareval("pack forget ", xctx->top_path, ".drw", NULL); + tclvareval("pack ", xctx->top_path, ".menubar -side top -fill x", NULL); + tclvareval("pack ", xctx->top_path, ".statusbar -side bottom -fill x", NULL); + tclvareval("pack ", xctx->top_path, ".drw -side right -fill both -expand true", NULL); if(tclgetboolvar("tabbed_interface")) { - tclvareval("pack ", xctx->top_path, - ".tabs -fill x -side top -expand false -side top -before ", - xctx->top_path, ".drw", NULL); - tclvareval("pack ", xctx->top_path, - ".menubar -anchor n -side top -fill x -before ", xctx->top_path, ".tabs; pack ", - xctx->top_path, ".statusbar -after ", xctx->top_path, - ".drw -anchor sw -fill x; update", NULL); - } else { - tclvareval("pack ", xctx->top_path, - ".menubar -anchor n -side top -fill x -before ", xctx->top_path, ".drw; pack ", - xctx->top_path, ".statusbar -after ", xctx->top_path, - ".drw -anchor sw -fill x; update", NULL); + tclvareval("pack_tabs", NULL); } if(xctx->menu_removed & 2) tclvareval("toolbar_show ", xctx->top_path, NULL); xctx->menu_removed=0; diff --git a/src/xschem.tcl b/src/xschem.tcl index 1db9d920..1a64b313 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -4372,6 +4372,19 @@ proc toolbar_hide { { topwin {} } } { set toolbar_visible 0 } +proc pack_tabs {} { + global toolbar_horiz + if {[winfo exists .toolbar] && [winfo ismapped .toolbar] } { + if { $toolbar_horiz == 1 } { + pack .tabs -fill x -side top -after .toolbar + } else { + pack .tabs -fill x -side top -before .toolbar + } + } else { + pack .tabs -fill x -side top -before .drw + } +} + proc setup_tabbed_interface {} { global tabbed_interface toolbar_horiz @@ -4383,16 +4396,7 @@ proc setup_tabbed_interface {} { bind .tabs.x0 {swap_tabs %X %Y release} button .tabs.add -padx 0 -pady 0 -text { + } -command "xschem new_schematic create" pack .tabs.x0 .tabs.add -side left - - if {[winfo exists .toolbar] && [winfo ismapped .toolbar] } { - if { $toolbar_horiz == 1 } { - pack .tabs -fill x -side top -after .toolbar - } else { - pack .tabs -fill x -side top -before .toolbar - } - } else { - pack .tabs -fill x -side top -before .drw - } + pack_tabs } } else { destroy .tabs @@ -4819,9 +4823,6 @@ proc pack_widgets { { topwin {} } } { pack $topwin.statusbar -side bottom -fill x pack $topwin.drw -side right -fill both -expand true setup_tabbed_interface - if {$tabbed_interface} { - pack $topwin.tabs -fill x -side top - } if {$toolbar_visible} {toolbar_show $topwin} bind $topwin.statusbar.5 \