rewritten the menu system using a menubar vs the menubuttons

This commit is contained in:
stefan schippers 2024-12-31 03:51:05 +01:00
parent 2c8468ee1c
commit b23b162f2c
6 changed files with 326 additions and 345 deletions

View File

@ -159,26 +159,26 @@ int set_modify(int mod)
/* Do not configure buttons if displaying in preview window */
if(has_x && (xctx->top_path[0] == '\0' || strstr(xctx->top_path, ".x") == xctx->top_path)) {
char s[256];
tclvareval(xctx->top_path, ".menubar.netlist configure -bg $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background $simulate_bg", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist $simulate_bg", NULL);
my_snprintf(s, S(s), "tctx::%s_simulate_id", xctx->current_win_path);
if(tclgetvar(s)) {
tclvareval(xctx->top_path, ".menubar.simulate configure -bg ", tclresult(), NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Simulate -background ", tclresult(), NULL);
tclvareval("set tctx::", xctx->current_win_path, "_simulate ", tclresult(), NULL);
} else {
tclvareval(xctx->top_path, ".menubar.simulate configure -bg $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Simulate -background $simulate_bg", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_simulate $simulate_bg", NULL);
}
}
if(sch_waves_loaded() >= 0) {
if(has_x && (xctx->top_path[0] == '\0' || strstr(xctx->top_path, ".x") == xctx->top_path)) {
tclvareval("set tctx::", xctx->current_win_path, "_waves Green", NULL);
tclvareval(xctx->top_path, ".menubar.waves configure -bg Green", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background Green", NULL);
}
} else {
if(has_x && (xctx->top_path[0] == '\0' || strstr(xctx->top_path, ".x") == xctx->top_path)) {
tclvareval("set tctx::", xctx->current_win_path, "_waves $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar.waves configure -bg $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background $simulate_bg", NULL);
}
}
}

View File

@ -3504,13 +3504,13 @@ int rstate; /* (reduced state, without ShiftMask) */
}
if(err) {
if(has_x) {
tclvareval(xctx->top_path, ".menubar.netlist configure -bg red", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background red", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist red", NULL);
}
} else {
if(has_x) {
tclvareval(xctx->top_path, ".menubar.netlist configure -bg Green", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background Green", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist Green", NULL);
}
}
@ -3544,12 +3544,12 @@ int rstate; /* (reduced state, without ShiftMask) */
}
if(err) {
if(has_x) {
tclvareval(xctx->top_path, ".menubar.netlist configure -bg red", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background red", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist red", NULL);
}
} else {
if(has_x) {
tclvareval(xctx->top_path, ".menubar.netlist configure -bg Green", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background Green", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist Green", NULL);
}
}

View File

@ -886,7 +886,7 @@ void free_rawfile(Raw **rawptr, int dr)
if(has_x) {
tclvareval("set tctx::", xctx->current_win_path, "_waves $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar.waves configure -bg $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background $simulate_bg", NULL);
}
if(dr) draw();
@ -1042,10 +1042,10 @@ int raw_read(const char *f, Raw **rawptr, const char *type, double sweep1, doubl
if(has_x) {
if(sch_waves_loaded() >= 0) {
tclvareval("set tctx::", xctx->current_win_path, "_waves Green", NULL);
tclvareval(xctx->top_path, ".menubar.waves configure -bg Green", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background Green", NULL);
} else {
tclvareval("set tctx::", xctx->current_win_path, "_waves $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar.waves configure -bg $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Waves -background $simulate_bg", NULL);
}
}
return res;
@ -3374,7 +3374,7 @@ int save_schematic(const char *schname) /* 20171020 added return value */
if(!strstr(xctx->sch[xctx->currsch], ".xschem_embedded_")) {
set_modify(0);
}
tclvareval(xctx->top_path, ".menubar.simulate configure -bg $simulate_bg", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Simulate -background $simulate_bg", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_simulate $simulate_bg", NULL);
tclvareval("catch {unset tctx::", xctx->current_win_path, "_simulate_id}", NULL);
/* set local simulation directory if local_netlist_dir is set*/

View File

@ -3226,12 +3226,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
}
if(err) {
if(has_x) {
tclvareval(xctx->top_path, ".menubar.netlist configure -bg red", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background red", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist red", NULL);
}
} else {
if(has_x) {
tclvareval(xctx->top_path, ".menubar.netlist configure -bg Green", NULL);
tclvareval(xctx->top_path, ".menubar entryconfigure Netlist -background Green", NULL);
tclvareval("set tctx::", xctx->current_win_path, "_netlist Green", NULL);
}
}

View File

@ -1129,12 +1129,10 @@ void toggle_fullscreen(const char *topwin)
tclvareval("toolbar_hide ", xctx->top_path, NULL);
}
tclvareval("pack forget ", xctx->top_path, ".tabs", NULL);
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")) {
@ -1604,8 +1602,8 @@ static void create_new_window(int *window_count, const char *noconfirm, const ch
tclvareval("save_ctx ", xctx->current_win_path, NULL);
(*window_count)++;
if(has_x) {
tclvareval("[xschem get top_path].menubar.simulate configure -bg $simulate_bg", NULL);
tcleval(".menubar.view.menu entryconfigure {Tabbed interface} -state disabled");
tclvareval("[xschem get top_path].menubar entryconfigure Simulate -background $simulate_bg", NULL);
tcleval(".menubar.view entryconfigure {Tabbed interface} -state disabled");
}
n = -1;
for(i = 1; i < MAX_NEW_WINDOWS; ++i) { /* search 1st free slot */
@ -1706,8 +1704,8 @@ static void create_new_tab(int *window_count, const char *noconfirm, const char
tclvareval("save_ctx ", xctx->current_win_path, NULL);
(*window_count)++;
if(has_x) {
tclvareval("[xschem get top_path].menubar.simulate configure -bg $simulate_bg", NULL);
tcleval(".menubar.view.menu entryconfigure {Tabbed interface} -state disabled");
tclvareval("[xschem get top_path].menubar entryconfigure Simulate -background $simulate_bg", NULL);
tcleval(".menubar.view entryconfigure {Tabbed interface} -state disabled");
}
for(i = 1; i < MAX_NEW_WINDOWS; ++i) { /* search 1st free slot */
if(save_xctx[i] == NULL) {
@ -1821,7 +1819,7 @@ static void destroy_window(int *window_count, const char *win_path)
my_strncpy(window_path[n], "", S(window_path[n]));
(*window_count)--;
if(has_x && *window_count == 0)
tcleval(".menubar.view.menu entryconfigure {Tabbed interface} -state normal");
tcleval(".menubar.view entryconfigure {Tabbed interface} -state normal");
}
}
/* following 3 lines must be done also if window not closed */
@ -1877,7 +1875,7 @@ static void destroy_tab(int *window_count, const char *win_path)
my_strncpy(window_path[n], "", S(window_path[n]));
/* delete Tcl context of deleted schematic window */
(*window_count)--;
if(*window_count == 0) tcleval(".menubar.view.menu entryconfigure {Tabbed interface} -state normal");
if(*window_count == 0) tcleval(".menubar.view entryconfigure {Tabbed interface} -state normal");
}
xctx = save_xctx[0]; /* restore main (.drw) schematic */
@ -1941,7 +1939,7 @@ static void destroy_all_windows(int *window_count, int force)
my_strncpy(window_path[i], "", S(window_path[i]));
(*window_count)--;
if(has_x && *window_count == 0)
tcleval(".menubar.view.menu entryconfigure {Tabbed interface} -state normal");
tcleval(".menubar.view entryconfigure {Tabbed interface} -state normal");
}
}
}
@ -1984,7 +1982,7 @@ static void destroy_all_tabs(int *window_count, int force)
save_xctx[i] = NULL;
my_strncpy(window_path[i], "", S(window_path[i]));
(*window_count)--;
if(has_x && *window_count == 0) tcleval(".menubar.view.menu entryconfigure {Tabbed interface} -state normal");
if(has_x && *window_count == 0) tcleval(".menubar.view entryconfigure {Tabbed interface} -state normal");
}
}
}

File diff suppressed because it is too large Load Diff