diff --git a/src/actions.c b/src/actions.c index 006331ff..4f589757 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2436,13 +2436,15 @@ int place_text(int draw_text, double mx, double my) t->flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC; str = get_tok_value(t->prop_ptr, "weight", 0); t->flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; + str = get_tok_value(t->prop_ptr, "hide", 0); + t->flags |= strcmp(str, "true") ? 0 : SYM_HIDE_TEXT; my_strdup(21, &t->font, get_tok_value(t->prop_ptr, "font", 0)); textlayer = t->layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER; #if HAS_CAIRO==1 textfont = t->font; - if((textfont && textfont[0]) || t->flags) { + if((textfont && textfont[0]) || (t->flags & (TEXT_BOLD | TEXT_OBLIQUE | TEXT_ITALIC))) { cairo_font_slant_t slant; cairo_font_weight_t weight; textfont = (t->font && t->font[0]) ? t->font : tclgetvar("cairo_font_name"); @@ -2463,7 +2465,7 @@ int place_text(int draw_text, double mx, double my) } xctx->draw_window = save_draw; #if HAS_CAIRO==1 - if((textfont && textfont[0]) || t->flags) { + if((textfont && textfont[0]) || (t->flags & (TEXT_BOLD | TEXT_OBLIQUE | TEXT_ITALIC))) { cairo_restore(xctx->cairo_ctx); cairo_restore(xctx->cairo_save_ctx); } diff --git a/src/draw.c b/src/draw.c index f40aea6b..73e201a7 100644 --- a/src/draw.c +++ b/src/draw.c @@ -115,7 +115,7 @@ int set_text_custom_font(xText *txt) /* 20171122 for correct text_bbox calculati const char *textfont; textfont = txt->font; - if((textfont && textfont[0]) || txt->flags) { + if((textfont && textfont[0]) || (txt->flags & (TEXT_BOLD | TEXT_OBLIQUE | TEXT_ITALIC))) { cairo_font_slant_t slant; cairo_font_weight_t weight; textfont = (txt->font && txt->font[0]) ? txt->font : tclgetvar("cairo_font_name"); @@ -481,6 +481,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, { text = symptr->text[j]; if(text.xscale*FONTWIDTH*xctx->mooz<1) continue; + if(symptr->text[j].flags & SYM_HIDE_TEXT) continue; if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue; txtptr= translate(n, text.txt_ptr); ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1); @@ -494,7 +495,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, if(xctx->inst[n].color == -PINLAYER || xctx->enable_layer[textlayer]) { #if HAS_CAIRO==1 textfont = symptr->text[j].font; - if((textfont && textfont[0]) || symptr->text[j].flags) { + if((textfont && textfont[0]) || (symptr->text[j].flags & (TEXT_BOLD | TEXT_OBLIQUE | TEXT_ITALIC))) { cairo_font_slant_t slant; cairo_font_weight_t weight; textfont = (symptr->text[j].font && symptr->text[j].font[0]) ? @@ -519,7 +520,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, drawline(textlayer, END, 0.0, 0.0, 0.0, 0.0, 0); #endif #if HAS_CAIRO==1 - if( (textfont && textfont[0]) || symptr->text[j].flags) { + if( (textfont && textfont[0]) || (symptr->text[j].flags & (TEXT_BOLD | TEXT_OBLIQUE | TEXT_ITALIC))) { cairo_restore(xctx->cairo_ctx); cairo_restore(xctx->cairo_save_ctx); } @@ -2685,7 +2686,8 @@ void draw(void) #if HAS_CAIRO==1 if(!xctx->enable_layer[textlayer]) continue; textfont = xctx->text[i].font; - if( (textfont && textfont[0]) || xctx->text[i].flags) { + if( (textfont && textfont[0]) || + (xctx->text[i].flags & (TEXT_BOLD | TEXT_OBLIQUE | TEXT_ITALIC))) { cairo_font_slant_t slant; cairo_font_weight_t weight; textfont = (xctx->text[i].font && xctx->text[i].font[0]) ? @@ -2706,7 +2708,8 @@ void draw(void) xctx->text[i].x0,xctx->text[i].y0, xctx->text[i].xscale, xctx->text[i].yscale); #if HAS_CAIRO==1 - if((textfont && textfont[0]) || xctx->text[i].flags ) { + if( (textfont && textfont[0]) || + (xctx->text[i].flags & (TEXT_BOLD | TEXT_OBLIQUE | TEXT_ITALIC))) { cairo_restore(xctx->cairo_ctx); cairo_restore(xctx->cairo_save_ctx); } diff --git a/src/editprop.c b/src/editprop.c index 8386b0aa..625c0496 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -854,6 +854,8 @@ static void edit_text_property(int x) xctx->text[sel].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC; str = get_tok_value(xctx->text[sel].prop_ptr, "weight", 0); xctx->text[sel].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; + str = get_tok_value(xctx->text[sel].prop_ptr, "hide", 0); + xctx->text[sel].flags |= strcmp(str, "true") ? 0 : SYM_HIDE_TEXT; if(k == 0 ) { hsize =atof(tclgetvar("hsize")); vsize =atof(tclgetvar("vsize")); diff --git a/src/move.c b/src/move.c index f65d9a32..aa381d47 100644 --- a/src/move.c +++ b/src/move.c @@ -916,6 +916,8 @@ void copy_objects(int what) xctx->text[xctx->texts].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC; str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "weight", 0); xctx->text[xctx->texts].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; + str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "hide", 0); + xctx->text[xctx->texts].flags |= strcmp(str, "true") ? 0 : SYM_HIDE_TEXT; xctx->text[xctx->texts].xscale=xctx->text[n].xscale; xctx->text[xctx->texts].yscale=xctx->text[n].yscale; diff --git a/src/paste.c b/src/paste.c index 09bed40b..7f7342dd 100644 --- a/src/paste.c +++ b/src/paste.c @@ -64,6 +64,8 @@ void merge_text(FILE *fd) xctx->text[i].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC; str = get_tok_value(xctx->text[i].prop_ptr, "weight", 0); xctx->text[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; + str = get_tok_value(xctx->text[i].prop_ptr, "hide", 0); + xctx->text[i].flags |= strcmp(str, "true") ? 0 : SYM_HIDE_TEXT; select_text(i,SELECTED, 1); set_modify(1); diff --git a/src/save.c b/src/save.c index d6fd58a9..479a5878 100644 --- a/src/save.c +++ b/src/save.c @@ -498,10 +498,12 @@ static void load_text(FILE *fd) else xctx->text[i].layer = -1; xctx->text[i].flags = 0; str = get_tok_value(xctx->text[i].prop_ptr, "slant", 0); - xctx->text[i].flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE; - xctx->text[i].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC; + xctx->text[i].flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE; + xctx->text[i].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC; str = get_tok_value(xctx->text[i].prop_ptr, "weight", 0); - xctx->text[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; + xctx->text[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; + str = get_tok_value(xctx->text[i].prop_ptr, "hide", 0); + xctx->text[i].flags |= strcmp(str, "true") ? 0 : SYM_HIDE_TEXT; xctx->texts++; } @@ -2000,6 +2002,8 @@ int load_sym_def(const char *name, FILE *embed_fd) tt[i].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC; str = get_tok_value(tt[i].prop_ptr, "weight", 0); tt[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD; + str = get_tok_value(tt[i].prop_ptr, "hide", 0); + tt[i].flags |= strcmp(str, "true") ? 0 : SYM_HIDE_TEXT; lastt++; break; case 'N': /* store wires as lines on layer WIRELAYER. */ diff --git a/src/xschem.h b/src/xschem.h index 9374ceb7..5f7a88c3 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -267,10 +267,12 @@ extern char win_temp_dir[PATH_MAX]; #define XDELETE 2 #define XINSERT_NOREPLACE 3 /* do not replace token value in hash if already present */ -/* Cairo text flags */ +/* Cairo text flags (.flags field) */ #define TEXT_BOLD 1 #define TEXT_OBLIQUE 2 #define TEXT_ITALIC 4 +/* flag (.flags field) to hide text in symbols when displaying instances */ +#define SYM_HIDE_TEXT 8 #define S(a) (sizeof(a)/sizeof(char)) #define BUS_WIDTH 4 diff --git a/src/xschem.tcl b/src/xschem.tcl index 7693c524..7116fd33 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -2094,7 +2094,7 @@ proc enter_text {textlabel {preserve_disabled disabled}} { wm geometry .dialog "+$X+$Y" frame .dialog.f1 label .dialog.f1.txtlab -text $textlabel - text .dialog.txt -width 100 -height 12 + text .dialog.txt -width 100 -height 4 .dialog.txt delete 1.0 end .dialog.txt insert 1.0 $retval checkbutton .dialog.f1.l1 -text "preserve unchanged props" -variable preserve_unchanged_attrs \ diff --git a/xschem_library/examples/mos_power_ampli.sym b/xschem_library/examples/mos_power_ampli.sym index 08bc29f6..9099ea62 100644 --- a/xschem_library/examples/mos_power_ampli.sym +++ b/xschem_library/examples/mos_power_ampli.sym @@ -1,4 +1,4 @@ -v {xschem version=2.9.9 file_version=1.2 } +v {xschem version=3.0.0 file_version=1.2 } G {} K {type=subcircuit format="@name @pinlist @symname" @@ -32,3 +32,4 @@ T {VSS} -125 -4 0 0 0.2 0.2 {} T {OUT} 125 -44 0 1 0.2 0.2 {} T {VPP} -125 16 0 0 0.2 0.2 {} T {VNN} -125 36 0 0 0.2 0.2 {} +T {MOS Power amplifier} -110 -90 0 0 0.4 0.4 {hide=true}