From 9ea9d529f71f4d6a17580231191b2cfa268eeffd Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 12 May 2023 14:54:22 +0200 Subject: [PATCH] fix toggle_ignore function. If multiple elements selected with different *_ignore attributes flip each one of them accordingly. Baseline code added for text floaters --- src/actions.c | 2 ++ src/draw.c | 12 ++++++++++-- src/scheduler.c | 9 ++++----- src/xschem.h | 2 ++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/actions.c b/src/actions.c index 8964776a..ead75407 100644 --- a/src/actions.c +++ b/src/actions.c @@ -628,6 +628,8 @@ int set_text_flags(xText *t) t->flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; str = get_tok_value(t->prop_ptr, "hide", 0); t->flags |= strcmp(str, "true") ? 0 : HIDE_TEXT; + str = get_tok_value(t->prop_ptr, "floater", 0); + t->flags |= xctx->tok_size ? TEXT_FLOATER : 0; } return 0; } diff --git a/src/draw.c b/src/draw.c index 713eea6d..a6b0bbb2 100644 --- a/src/draw.c +++ b/src/draw.c @@ -3729,11 +3729,19 @@ void draw(void) if(xctx->draw_single_layer ==-1 || xctx->draw_single_layer==TEXTLAYER) { for(i=0;itexts; ++i) { + const char *txt_ptr = xctx->text[i].txt_ptr; textlayer = xctx->text[i].layer; if(!xctx->show_hidden_texts && (xctx->text[i].flags & HIDE_TEXT)) continue; if(xctx->only_probes) textlayer = GRIDLAYER; else if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; - dbg(1, "draw(): drawing string %d = %s\n",i, xctx->text[i].txt_ptr); + dbg(1, "draw(): drawing string %d = %s\n",i, txt_ptr); + if(xctx->text[i].flags & TEXT_FLOATER) { + int inst = get_instance(get_tok_value(xctx->text[i].prop_ptr, "floater", 0)); + if(inst >= 0) { + dbg(1, "floater: %s\n", xctx->text[i].txt_ptr); + txt_ptr = translate(inst, xctx->text[i].txt_ptr); + } + } #if HAS_CAIRO==1 if(!xctx->enable_layer[textlayer]) continue; textfont = xctx->text[i].font; @@ -3757,7 +3765,7 @@ void draw(void) cairo_font_face_destroy(xctx->cairo_font); } #endif - draw_string(textlayer, ADD, xctx->text[i].txt_ptr, + draw_string(textlayer, ADD, txt_ptr, xctx->text[i].rot, xctx->text[i].flip, xctx->text[i].hcenter, xctx->text[i].vcenter, xctx->text[i].x0,xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); diff --git a/src/scheduler.c b/src/scheduler.c index 09abcbb3..bf128c4a 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -56,7 +56,7 @@ static int get_symbol(const char *s) return i; } -static int get_instance(const char *s) +int get_instance(const char *s) { int i, found=0; for(i=0;iinstances; ++i) { @@ -3716,11 +3716,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg i = xctx->sel_array[n].n; if(first) { xctx->push_undo(); - if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr, attr, 0), "true")) { - remove = 1; - } + first = 0; } - first = 0; + remove = 0; + if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr, attr, 0), "true")) remove = 1; if(remove) { my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, subst_token(xctx->inst[i].prop_ptr, attr, NULL)); } else { diff --git a/src/xschem.h b/src/xschem.h index 1a483374..81198ec0 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -289,6 +289,7 @@ extern char win_temp_dir[PATH_MAX]; #define TEXT_ITALIC 4 /* flag (.flags field) to hide text in symbols when displaying instances */ #define HIDE_TEXT 8 +#define TEXT_FLOATER 16 #define S(a) (sizeof(a)/sizeof(a[0])) #define BUS_WIDTH 4 @@ -1362,6 +1363,7 @@ extern void new_polygon(int what); extern void compile_font(void); extern void rebuild_selected_array(void); +extern int get_instance(const char *s); extern void edit_property(int x); extern int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * argv[]);