Tabbed windows interface option added

This commit is contained in:
Stefan Frederik 2022-01-09 22:19:58 +01:00
parent 84662451ae
commit 1360641d75
6 changed files with 39 additions and 30 deletions

View File

@ -1368,7 +1368,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
if(key=='q' && state == ControlMask) /* exit */
{
if(xctx->semaphore >= 2) break;
if(!strcmp(winpath, ".drw")) {
if(!strcmp(xctx->current_win_path, ".drw")) {
int remaining;
/* tcleval("new_window destroy_all"); */ /* close child schematics */
remaining = new_schematic("destroy_all", NULL, NULL);
@ -1383,7 +1383,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
}
} else {
/* xschem new_schematic destroy asks user confirmation if schematic changed */
new_schematic("destroy", winpath, NULL);
new_schematic("destroy", xctx->current_win_path, NULL);
}
break;
}

View File

@ -646,7 +646,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else if(!strcmp(argv[1],"exit"))
{
cmd_found = 1;
if(!strcmp(xctx->top_path, "")) {
if(!strcmp(xctx->current_win_path, ".drw")) {
if(has_x) {
int remaining;
remaining = new_schematic("destroy_all", NULL, NULL);

View File

@ -2116,7 +2116,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
load_schematic(1, filename, !do_netlist);
}
tclsetintvar("max_new_windows", MAX_NEW_WINDOWS);
tclsetintvar("tctx::max_new_windows", MAX_NEW_WINDOWS);
zoom_full(0, 0, 1, 0.97); /* Necessary to tell xschem the initial area to display */
xctx->pending_fullzoom=1;

View File

@ -3641,14 +3641,15 @@ proc setup_toolbar {} {
# Toolbar constructor
#
proc toolbar_toolbar { {topwin {} } } {
frame $topwin.toolbar -relief raised -bd 1 -bg white
frame $topwin.toolbar -relief raised -bd 0 -bg white
}
#
# Create a tool button which may be displayed
#
proc toolbar_create {name cmd { help "" } {topwin {} } } {
button $topwin.toolbar.b$name -image img$name -relief flat -bd 3 -bg white -fg white -command $cmd
button $topwin.toolbar.b$name -image img$name -relief flat -bd 1 -bg white -fg white \
-padx 0 -pady 0 -command $cmd
if { $help == "" } { balloon $topwin.toolbar.b$name $name } else { balloon $topwin.toolbar.b$name $help }
}
@ -3676,10 +3677,10 @@ proc toolbar_show { { topwin {} } } {
if { $b == "---" } {
if { $toolbar_horiz } {
frame $topwin.toolbar.sep$toolbar_sepn -bg lightgrey -width 2
pack $topwin.toolbar.sep$toolbar_sepn -side $pos -padx 1 -pady 1 -fill y
pack $topwin.toolbar.sep$toolbar_sepn -side $pos -padx 1 -pady 0 -fill y
} else {
frame $topwin.toolbar.sep$toolbar_sepn -bg lightgrey -height 2
pack $topwin.toolbar.sep$toolbar_sepn -side $pos -padx 1 -pady 1 -fill x
pack $topwin.toolbar.sep$toolbar_sepn -side $pos -padx 0 -pady 1 -fill x
}
incr toolbar_sepn
} else {
@ -3749,15 +3750,16 @@ proc delete_tab {path} {
}
proc create_new_tab {} {
global max_new_windows
set top_path [xschem get top_path]
for { set i 1} { $i < $max_new_windows} { incr i} {
for { set i 1} { $i < $tctx::max_new_windows} { incr i} {
if { ![winfo exists ${top_path}.tabs.x$i] } {
button $top_path.tabs.x$i -padx 2 -pady 0 -text Tab2 -command "xschem new_schematic switch .x$i.drw"
if {![info exists tctx::tab_bg] } {set tctx::tab_bg [$top_path.tabs.x$i cget -bg]}
pack $top_path.tabs.x$i -before .tabs.add -side left
xschem new_schematic create .x$i.drw
break
} else {
}
}
}
@ -3767,13 +3769,15 @@ proc set_tab_names {} {
if {[info exists has_x] && $tabbed_interface } {
set currwin [xschem get current_win_path]
regsub {\.drw} $currwin {} tabname
set top_path [xschem get top_path]
if {$tabname eq {}} { set tabname .x0}
# puts "set_tab_names : currwin=$currwin"
if { $currwin eq {.drw}} {
${top_path}.tabs.x0 configure -text [file rootname [file tail [xschem get schname]]]
} else {
regsub {\.drw} $currwin {} tabname
${top_path}.tabs$tabname configure -text [file rootname [file tail [xschem get schname]]]
${top_path}.tabs$tabname configure -text [file rootname [file tail [xschem get schname]]] -bg Palegreen
for { set i 0} { $i < $tctx::max_new_windows} { incr i} {
if { [winfo exists ${top_path}.tabs.x$i] && ($tabname ne ".x$i")} {
${top_path}.tabs.x$i configure -bg $tctx::tab_bg
}
}
}
}
@ -3811,6 +3815,8 @@ namespace eval tctx {
variable global_list
variable global_array_list
variable dialog_list
variable tab_bg
variable max_new_windows
}
## list of dialogs: when open do not perform context switching
@ -3834,7 +3840,6 @@ proc no_open_dialogs {} {
## "viewdata_wcounter" should be kept unique as it is the number of open viewdatas
## "measure_id" should be kept unique since we allow only one measure tooltip in graphs
## "tabbed_interface"
## "max_new_windows"
set tctx::global_list {
@ -4133,13 +4138,13 @@ proc build_widgets { {topwin {} } } {
}
$topwin.menubar.file.menu add command -label "Open" -command "xschem load" -accelerator {Ctrl+O}
$topwin.menubar.file.menu add cascade -label "Open Recent" -menu $topwin.menubar.file.menu.recent
$topwin.menubar.file.menu add cascade -label {Open Recent in new window [exp]} \
$topwin.menubar.file.menu add cascade -label {Open Recent in new window} \
-menu $topwin.menubar.file.menu.recent_new_window
menu $topwin.menubar.file.menu.recent_new_window -tearoff 0
menu $topwin.menubar.file.menu.recent -tearoff 0
setup_recent_menu 0 $topwin
setup_recent_menu 1 $topwin
$topwin.menubar.file.menu add command -label {Open new window [exp]} -command "xschem load_new_window"
$topwin.menubar.file.menu add command -label {Open new window} -command "xschem load_new_window"
if {$tabbed_interface} {
$topwin.menubar.file.menu entryconfigure 6 -state disabled
$topwin.menubar.file.menu entryconfigure 7 -state disabled
@ -4819,8 +4824,6 @@ set_ne undo_type disk
## show tab bar (tabbed interface)
set_ne tabbed_interface 0
## max number of windows (including main) a single xschem process can handle
set_ne max_new_windows -1 ;# this is set by xinit.c
## remember edit_prop widget size
set_ne edit_prop_size 80x12
set_ne text_line_default_geometry 80x12

View File

@ -326,3 +326,9 @@
set toolbar_visible 1
# set toolbar_horiz 1
###########################################################################
#### TABBED WINDOWS
###########################################################################
# default: not enabled. Interface can be changed runtime if only one window
# or tab is open.
# set tabbed_interface 1

View File

@ -5,13 +5,13 @@ V {}
S {
}
E {}
L 4 250 -300 270 -320 {}
L 4 250 -300 290 -300 {}
L 4 270 -320 290 -300 {}
L 4 270 -220 290 -240 {}
L 4 250 -240 290 -240 {}
L 4 250 -240 270 -220 {}
L 4 270 -300 270 -240 {}
L 4 210 -300 230 -320 {}
L 4 210 -300 250 -300 {}
L 4 230 -320 250 -300 {}
L 4 230 -220 250 -240 {}
L 4 210 -240 250 -240 {}
L 4 210 -240 230 -220 {}
L 4 230 -300 230 -240 {}
L 4 350 -580 370 -560 {dash=3}
L 4 370 -600 370 -560 {dash=3}
L 4 350 -580 370 -600 {dash=3}
@ -42,7 +42,7 @@ color="4 6 8"
sweep="v(z) v(a)"}
P 4 5 560 -700 560 -510 1350 -510 1350 -700 560 -700 {dash=3}
P 4 5 820 -920 820 -730 1350 -730 1350 -920 820 -920 {dash=3}
T {These 2 instances are equivalent} 290 -280 0 0 0.4 0.4 {}
T {These 2 instances are equivalent} 260 -310 0 0 0.4 0.4 {}
T {Example of using a schematic as a component instance
instead of the usual symbol. LCC: Local Custom Cell.
@ -70,7 +70,7 @@ N 650 -860 650 -770 { lab=A}
C {vsource.sym} 50 -140 0 0 {name=V1 value="pwl 0 0 1u 0 5u 3"}
C {lab_pin.sym} 50 -170 0 0 {name=p4 lab=A}
C {lab_pin.sym} 50 -110 0 0 {name=p5 lab=0}
C {code_shown.sym} 520 -190 0 0 {name=STIMULI
C {code_shown.sym} 510 -250 0 0 {name=STIMULI
only_toplevel=true
tclcommand="xschem edit_vi_prop"
value=".control