recent components are in paned window (can be resized)

This commit is contained in:
Stefan Frederik 2022-09-27 09:27:39 +02:00
parent 0bb4c9f2e0
commit 3e6815ccc5
4 changed files with 40 additions and 39 deletions

View File

@ -1919,11 +1919,12 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
if(xctx->semaphore >= 2) break; if(xctx->semaphore >= 2) break;
descend_symbol();break; descend_symbol();break;
} }
if((key==XK_Insert && state == ShiftMask)) /* insert sym */ if((key==XK_Insert && state & ShiftMask)) /* insert sym */
{ {
tcleval("load_file_dialog {Insert symbol} .sym INITIALINSTDIR 2"); tcleval("load_file_dialog {Insert symbol} .sym INITIALINSTDIR 2");
break;
} }
if((key==XK_Insert && state == 0) || (key == 'I' && state == ShiftMask) ) /* insert sym */ if(key==XK_Insert || (key == 'I' && state == ShiftMask) ) /* insert sym */
{ {
if(xctx->semaphore >= 2) break; if(xctx->semaphore >= 2) break;
start_place_symbol(mx, my); start_place_symbol(mx, my);

View File

@ -420,7 +420,7 @@ void break_wires_at_pins(void)
xctx->wire[xctx->wires].y1=xctx->wire[i].y1; xctx->wire[xctx->wires].y1=xctx->wire[i].y1;
xctx->wire[xctx->wires].x2=x0; xctx->wire[xctx->wires].x2=x0;
xctx->wire[xctx->wires].y2=y0; xctx->wire[xctx->wires].y2=y0;
xctx->wire[xctx->wires].sel=SELECTED; xctx->wire[xctx->wires].sel=0;
xctx->wire[xctx->wires].prop_ptr=NULL; xctx->wire[xctx->wires].prop_ptr=NULL;
my_strdup(31, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr); my_strdup(31, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr);
if(!strcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true")) if(!strcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true"))
@ -476,7 +476,7 @@ void break_wires_at_pins(void)
xctx->wire[xctx->wires].y1=xctx->wire[i].y1; xctx->wire[xctx->wires].y1=xctx->wire[i].y1;
xctx->wire[xctx->wires].x2=x0; xctx->wire[xctx->wires].x2=x0;
xctx->wire[xctx->wires].y2=y0; xctx->wire[xctx->wires].y2=y0;
xctx->wire[xctx->wires].sel=SELECTED; xctx->wire[xctx->wires].sel=0;
xctx->wire[xctx->wires].prop_ptr=NULL; xctx->wire[xctx->wires].prop_ptr=NULL;
my_strdup(33, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr); my_strdup(33, &xctx->wire[xctx->wires].prop_ptr, xctx->wire[i].prop_ptr);
if(!strcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true")) if(!strcmp(get_tok_value(xctx->wire[xctx->wires].prop_ptr,"bus",0), "true"))

View File

@ -834,18 +834,14 @@ static void my_cairo_drawpoints(cairo_t *ct, int layer, XPoint *points, int npoi
cairo_stroke(ct); /* This lines need to be here */ cairo_stroke(ct); /* This lines need to be here */
} }
} }
#endif
#if !defined(__unix__) && defined(HAS_CAIRO)
static void check_cairo_drawline(void *cr, int layer, double x1, double y1, double x2, double y2, int dash) static void check_cairo_drawline(void *cr, int layer, double x1, double y1, double x2, double y2, int dash)
{ {
if (cr==NULL) return; if (cr==NULL) return;
cairo_t *ct = (cairo_t *)cr; cairo_t *ct = (cairo_t *)cr;
my_cairo_drawline(cr, layer, x1, y1, x2, y2, dash); my_cairo_drawline(cr, layer, x1, y1, x2, y2, dash);
} }
#endif
#if !defined(__unix__) && defined(HAS_CAIRO)
static void check_cairo_drawpoints(void *cr, int layer, XPoint *points, int npoints) static void check_cairo_drawpoints(void *cr, int layer, XPoint *points, int npoints)
{ {
if (cr==NULL) return; if (cr==NULL) return;
@ -883,7 +879,9 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
XDrawLine(display, xctx->window, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); XDrawLine(display, xctx->window, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
if (xctx->draw_pixmap) if (xctx->draw_pixmap)
XDrawLine(display, xctx->save_pixmap, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); XDrawLine(display, xctx->save_pixmap, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
#if defined(HAS_CAIRO)
check_cairo_drawline(ct, c, rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2, 0); check_cairo_drawline(ct, c, rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2, 0);
#endif
} }
#endif #endif
i=0; i=0;
@ -922,7 +920,7 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
if(dash) { if(dash) {
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound); XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound, JoinRound);
} }
#ifndef __unix__ #if !defined(__unix__) && defined(HAS_CAIRO)
check_cairo_drawline(ct, c, x1, y1, x2, y2, dash); check_cairo_drawline(ct, c, x1, y1, x2, y2, dash);
#endif #endif
} }
@ -946,7 +944,7 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
} }
if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[c], (int)x1, (int)y1, (int)x2, (int)y2); if(xctx->draw_window) XDrawLine(display, xctx->window, xctx->gc[c], (int)x1, (int)y1, (int)x2, (int)y2);
if(xctx->draw_pixmap) XDrawLine(display, xctx->save_pixmap, xctx->gc[c], (int)x1, (int)y1, (int)x2, (int)y2); if(xctx->draw_pixmap) XDrawLine(display, xctx->save_pixmap, xctx->gc[c], (int)x1, (int)y1, (int)x2, (int)y2);
#ifndef __unix__ #if !defined(__unix__) && defined(HAS_CAIRO)
check_cairo_drawline(ct, c, x1, y1, x2, y2, dash); check_cairo_drawline(ct, c, x1, y1, x2, y2, dash);
#endif #endif
XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound); XSetLineAttributes (display, xctx->gc[c], INT_WIDTH(xctx->lw), LineSolid, CapRound , JoinRound);
@ -963,7 +961,9 @@ void drawline(int c, int what, double linex1, double liney1, double linex2, doub
XDrawLine(display, xctx->window, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); XDrawLine(display, xctx->window, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
if (xctx->draw_pixmap) if (xctx->draw_pixmap)
XDrawLine(display, xctx->save_pixmap, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2); XDrawLine(display, xctx->save_pixmap, xctx->gc[c], rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2);
#if defined(HAS_CAIRO)
check_cairo_drawline(ct, c, rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2, 0); check_cairo_drawline(ct, c, rr[j].x1, rr[j].y1, rr[j].x2, rr[j].y2, 0);
#endif
} }
#endif #endif
i=0; i=0;
@ -1924,7 +1924,7 @@ static void draw_graph_points(int idx, int first, int last,
if(xctx->draw_pixmap) { if(xctx->draw_pixmap) {
XDrawLines(display, xctx->save_pixmap, xctx->gc[wave_col], point, poly_npoints, CoordModeOrigin); XDrawLines(display, xctx->save_pixmap, xctx->gc[wave_col], point, poly_npoints, CoordModeOrigin);
} }
#ifndef __unix__ #if !defined(__unix__) && defined(HAS_CAIRO)
check_cairo_drawpoints(ct, wave_col, point, poly_npoints); check_cairo_drawpoints(ct, wave_col, point, poly_npoints);
#endif #endif
set_thick_waves(0, wcnt, wave_col, gr); set_thick_waves(0, wcnt, wave_col, gr);

View File

@ -583,9 +583,15 @@ proc load_recent_file {} {
-icon warning -parent . -type ok -icon warning -parent . -type ok
} }
} }
foreach i [info vars c_toolbar::c_t_*] {
if {[set ${i}(w)] != $c_toolbar::c_t(w) ||
[set ${i}(n)] != $c_toolbar::c_t(n)} {
array unset $i
}
}
set hash $c_toolbar::c_t(hash) set hash $c_toolbar::c_t(hash)
if { [info exists c_toolbar::c_t_$hash]} { if { [info exists c_toolbar::c_t_$hash]} {
array set c_toolbar::c_t [array get c_toolbar::c_t_$hash] array set c_toolbar::c_t [array get c_toolbar::c_t_$hash]
} }
} }
} }
@ -2136,22 +2142,17 @@ proc hash_string {s} {
namespace eval c_toolbar { namespace eval c_toolbar {
# Create a variable inside the namespace # Create a variable inside the namespace
variable c_t variable c_t
set c_t(w) .load.recent variable i
set c_t(w) .load.l.recent
set c_t(hash) [hash_string $XSCHEM_LIBRARY_PATH] set c_t(hash) [hash_string $XSCHEM_LIBRARY_PATH]
set c_t(n) 25
proc create {} { set c_t(top) 0
variable c_t for {set i 0} {$i < $c_t(n)} {incr i} {
if { ![info exists c_t(n)]} { set c_t($i,text) {}
set c_t(n) 30 set c_t($i,command) {}
set c_t(top) 0 set c_t($i,file) {}
for {set i 0} {$i < $c_t(n)} {incr i} {
set c_t($i,text) {}
set c_t($i,command) {}
set c_t($i,file) {}
}
}
} }
proc cleanup {} { proc cleanup {} {
variable c_t variable c_t
if {![info exists c_t(n)]} return if {![info exists c_t(n)]} return
@ -2186,7 +2187,6 @@ namespace eval c_toolbar {
proc display {} { proc display {} {
variable c_t variable c_t
if { [winfo exists $c_t(w)]} { if { [winfo exists $c_t(w)]} {
create
set w $c_t(w) set w $c_t(w)
set n $c_t(n) set n $c_t(n)
cleanup cleanup
@ -2195,11 +2195,11 @@ namespace eval c_toolbar {
destroy $w.b$i destroy $w.b$i
} }
set i $c_t(top) set i $c_t(top)
button $w.title -text Recent -pady 0 -padx 0 -width 13 -state disabled -disabledforeground black \ button $w.title -text Recent -pady 0 -padx 0 -width 7 -state disabled -disabledforeground black \
-background grey60 -highlightthickness 0 -borderwidth 0 -font {TkDefaultFont 12 bold} -background grey60 -highlightthickness 0 -borderwidth 0 -font {TkDefaultFont 12 bold}
pack $w.title -side top -fill x pack $w.title -side top -fill x
while {1} { while {1} {
button $w.b$i -text $c_t($i,text) -pady 0 -padx 0 -command $c_t($i,command) -width 13 button $w.b$i -text $c_t($i,text) -pady 0 -padx 0 -command $c_t($i,command) -width 7
pack $w.b$i -side top -fill x pack $w.b$i -side top -fill x
set i [expr {($i + 1) % $n}] set i [expr {($i + 1) % $n}]
if { $i == $c_t(top) } break if { $i == $c_t(top) } break
@ -2209,7 +2209,6 @@ namespace eval c_toolbar {
proc add {f} { proc add {f} {
variable c_t variable c_t
create
for {set i 0} {$i < $c_t(n)} {incr i} { for {set i 0} {$i < $c_t(n)} {incr i} {
if { $c_t($i,file) eq $f } { return 0} if { $c_t($i,file) eq $f } { return 0}
} }
@ -2217,10 +2216,7 @@ namespace eval c_toolbar {
set ret 1 set ret 1
set i [expr { ($c_t(top)-1) % $c_t(n) } ];# last element set i [expr { ($c_t(top)-1) % $c_t(n) } ];# last element
set c_t($i,file) $f set c_t($i,file) $f
set c_t($i,command) " set c_t($i,command) "xschem abort_operation; xschem place_symbol {$f}"
xschem abort_operation
xschem place_symbol {$f}
"
set c_t($i,text) [file tail [file rootname $f]] set c_t($i,text) [file tail [file rootname $f]]
set c_t(top) $i set c_t(top) $i
if {$ret} {write_recent_file} if {$ret} {write_recent_file}
@ -2410,8 +2406,8 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}}
set myload_index1 0 set myload_index1 0
} }
set_ne myload_files2 {} set_ne myload_files2 {}
if { $loadfile == 2} {frame .load.recent}
panedwindow .load.l -orient horizontal panedwindow .load.l -orient horizontal
if { $loadfile == 2} {frame .load.l.recent}
frame .load.l.paneleft frame .load.l.paneleft
eval [subst {listbox .load.l.paneleft.list -listvariable myload_files1 -width 20 -height 12 \ eval [subst {listbox .load.l.paneleft.list -listvariable myload_files1 -width 20 -height 12 \
-yscrollcommand ".load.l.paneleft.yscroll set" -selectmode browse \ -yscrollcommand ".load.l.paneleft.yscroll set" -selectmode browse \
@ -2450,6 +2446,10 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}}
pack .load.l.paneright.xscroll -side bottom -fill x pack .load.l.paneright.xscroll -side bottom -fill x
pack .load.l.paneright.list -side bottom -fill both -expand true pack .load.l.paneright.list -side bottom -fill both -expand true
if { $loadfile == 2} {
.load.l add .load.l.recent -minsize 30
c_toolbar::display
}
.load.l add .load.l.paneleft -minsize 40 .load.l add .load.l.paneleft -minsize 40
.load.l add .load.l.paneright -minsize 40 .load.l add .load.l.paneright -minsize 40
# .load.l paneconfigure .load.l.paneleft -stretch always # .load.l paneconfigure .load.l.paneleft -stretch always
@ -2524,10 +2524,10 @@ proc load_file_dialog {{msg {}} {ext {}} {global_initdir {INITIALINSTDIR}}
pack .load.buttons_bot.label -side left pack .load.buttons_bot.label -side left
pack .load.buttons_bot.entry -side left -fill x -expand true pack .load.buttons_bot.entry -side left -fill x -expand true
pack .load.buttons_bot.cancel .load.buttons_bot.ok -side left pack .load.buttons_bot.cancel .load.buttons_bot.ok -side left
if { $loadfile == 2} { # if { $loadfile == 2} {
pack .load.recent -side left -fill y # pack .load.recent -side left -fill y
c_toolbar::display # c_toolbar::display
} # }
pack .load.l -expand true -fill both pack .load.l -expand true -fill both
pack .load.buttons -side top -fill x pack .load.buttons -side top -fill x
pack .load.buttons_bot -side top -fill x pack .load.buttons_bot -side top -fill x