fix wave panning if a non graph added, better error reporting in png writer function, better flags option names for special objejcts (image and graphs)

This commit is contained in:
Stefan Frederik 2022-01-21 02:16:51 +01:00
parent a3ccc094f5
commit e66abe36fa
8 changed files with 51 additions and 414 deletions

View File

@ -190,6 +190,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
double xx1, xx2, yy1, yy2;
double delta_threshold = 0.25;
double zoom_m = 0.5;
int save_mouse_at_end = 0;
#if HAS_CAIRO==1
cairo_save(xctx->cairo_ctx);
cairo_save(xctx->cairo_save_ctx);
@ -231,7 +232,6 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
xctx->graph_bottom = 0;
}
xctx->graph_master = i;
zoom_m = (xctx->mousex - gr->x1) / gr->w;
/* dragging cursors when mouse is very close */
if(event == ButtonPress && button == Button1) {
@ -375,6 +375,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
}
}
} else {
save_mouse_at_end = 1;
delta = gr->gw;
delta_threshold = 0.01;
if( r->sel || !(r->flags & 2) || i == xctx->graph_master) {
@ -388,13 +389,6 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
need_redraw = 1;
}
}
/* update saved mouse position after processing all graphs */
if(fabs(xctx->mx_double_save - xctx->mousex_snap) > fabs(gr->cx * delta) * delta_threshold) {
if(i >= xctx->rects[GRIDLAYER] - 1) {
xctx->mx_double_save = xctx->mousex_snap;
xctx->my_double_save = xctx->mousey_snap;
}
}
}
}
else if((button == Button5 && !(state & ShiftMask))) {
@ -743,6 +737,16 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
draw_graph(i, 1 + 8 + (xctx->graph_flags & 6), gr); /* draw data in each graph box */
}
} /* for(i=0; i< xctx->rects[GRIDLAYER]; i++ */
/* update saved mouse position after processing all graphs */
if(save_mouse_at_end &&
fabs(xctx->mx_double_save - xctx->mousex_snap) > fabs(gr->cx * gr->gw) * delta_threshold) {
xctx->mx_double_save = xctx->mousex_snap;
xctx->my_double_save = xctx->mousey_snap;
}
draw_selection(xctx->gc[SELLAYER], 0);
#if HAS_CAIRO==1
cairo_restore(xctx->cairo_ctx);

View File

@ -2581,7 +2581,7 @@ static cairo_status_t png_reader(void *in_closure, unsigned char *out_data, unsi
static cairo_status_t png_writer(void *in_closure, const unsigned char *in_data, unsigned int length)
{
png_to_byte_closure_t *closure = (png_to_byte_closure_t *) in_closure;
if(!in_data) return CAIRO_STATUS_READ_ERROR;
if(!in_data) return CAIRO_STATUS_WRITE_ERROR;
if(closure->pos + length > closure->size) {
my_realloc(1472, &closure->buffer, closure->pos + length + 65536);
closure->size = closure->pos + length + 65536;
@ -2643,7 +2643,7 @@ int draw_images_all(void)
closure.pos = 0;
closure.size = data_size; /* should not be necessary */
emb_ptr->image = cairo_image_surface_create_from_png_stream(png_reader, &closure);
if(closure.buffer == NULL) dbg(0, "Error: null closure.buffer, i=%d\n", i);
if(closure.buffer == NULL) dbg(0, "draw_images_all(): null closure.buffer, i=%d\n", i);
my_free(1467, &closure.buffer);
dbg(1, "draw_images_all(): length2 = %d\n", closure.pos);
/* ... or read PNG from file (image attribute) */

View File

@ -793,10 +793,10 @@ int set_rect_flags(xRect *r)
unsigned short f = 0;
if(r->prop_ptr && r->prop_ptr[0]) {
flags = get_tok_value(r->prop_ptr,"flags",0);
if(!strcmp(flags, "image")) f |= 1024;
else if(!strcmp(flags, "image_unscaled")) f |= 3072;
else if(!strcmp(flags, "graph")) f |= 1;
else if(!strcmp(flags, "graph_unlocked")) f |= 3;
if(strstr(flags, "unscaled")) f |= 3072;
else if(strstr(flags, "image")) f |= 1024;
else if(strstr(flags, "unlocked")) f |= 3;
else if(strstr(flags, "graph")) f |= 1;
}
r->flags = f;
return f;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -14,34 +14,34 @@ L 18 900 -580 910 -580 {}
L 18 880 -530 900 -580 {}
L 18 880 -530 880 -450 {}
L 18 900 -580 900 -400 {}
B 2 1200 -860 1880 -550 {flags=graph
y1 = -60
y2 = 60
divy = 12
x1=6e-09
x2=0.03
divx=10
node="outp outm vpp vnn x1.vboost x0.vboost"
color="4 5 6 12 8 10" unitx=m
}
B 2 1200 -530 1880 -340 {flags=graph
y1 = 0
y2 = 12
divy = 6
x1=6e-09
x2=0.03
divx=10
node="i(v.x1.vu) i(v.x0.vu) i(v.x1.vd) i(v.x0.vd)"
color="11 12 13 14" unitx=m}
B 2 1200 -330 1880 -140 {flags=graph
B 2 1200 -330 1880 -140 {flags=graph,locked
y1 = 0
y2 = .05
divy = 5
x1=6e-09
x2=0.03
x1=0.0145769
x2=0.015228
divx=10
node="i(v.x1.v3)"
color="11 12 13 14" unitx=m unity=m}
B 2 1200 -530 1880 -340 {flags=graph,locked
y1 = 0
y2 = 12
divy = 6
x1=0.0145769
x2=0.015228
divx=10
node="i(v.x1.vu) i(v.x0.vu) i(v.x1.vd) i(v.x0.vd)"
color="11 12 13 14" unitx=m}
B 2 1200 -860 1880 -550 {flags=graph,locked
y1 = -60
y2 = 60
divy = 12
x1=0.0145769
x2=0.015228
divx=10
node="outp outm vpp vnn x1.vboost x0.vboost"
color="4 5 6 12 8 10" unitx=m}
T {actual value
50u} 400 -820 0 0 0.4 0.4 {}
T {actual value

View File

@ -47,8 +47,8 @@ y1 = -0.021
y2 = 1.5
subdivy=1
divy = 4
x1=1.41996e-07
x2=2.02558e-07
x1=1.58347e-07
x2=2.18909e-07
divx=10
subdivx=4
node="ldcp ldyms[4] ldyms[5] ldyms[6] ldymsref"
@ -77,8 +77,8 @@ y2 = 1.6
ypos1=0.0694741
ypos2=2.61557
divy = 1
x1=1.39863e-07
x2=2.00425e-07
x1=2.07427e-07
x2=2.67989e-07
divx=12
subdivx=4
node="
@ -104,8 +104,8 @@ B 2 1840 -1300 2890 -1160 {flags=graph_unlocked
y1 = -0.022
y2 = 1.6
divy = 4
x1=1.41996e-07
x2=2.02558e-07
x1=1.84671e-07
x2=2.45233e-07
divx=8
unitx=n
node="xsa[0].ldqib xsa[5].ldqib xsa[0].ldsali xctrl.ldq_b"