add `hide=instance` attribute for in-symbol text objects (in addition to hide=true or hide=false). If set the text is invisible in instantiated symbols, but is visible if descending into the symbol

This commit is contained in:
stefan schippers 2024-01-08 15:47:01 +01:00
parent 0597bae9dc
commit 8c55f3a99e
8 changed files with 16 additions and 8 deletions

View File

@ -287,7 +287,9 @@ device="tantalium capacitor"<br>
<li><kbd>weight</kbd> If set to <kbd>bold</kbd> use bold style</li>
<li><kbd>slant</kbd> If set to <kbd> italic</kbd> or <kbd>oblique</kbd> use that style for text</li>
<li><kbd>hide</kbd> If set to <kbd>true</kbd> text will be hidden unless <kbd>View-&gt;Show hidden texts</kbd>
is enabled</li>
is enabled<br>
If <kbd>hide=instance</kbd> is given the text will be invisible in placed instances of the
symbol, but visible when descending into the symbol.</li>
</ul>
</li>
</ul>

View File

@ -100,7 +100,9 @@ p{padding: 15px 30px 10px;}
<kbd>slant=oblique</kbd> may specify italic or slanted text.<br>
A <kbd>hide=true</kbd> will make the specified text invisible unless the <kbd>View-&gt;Show hidden texts</kbd>
option is enabled.
</p>
If <kbd>hide=instance</kbd> is given the text will be invisible in placed instances of the symbol, but visible
when descending into the symbol.
</p>
<img src="xschem_elements_02.png">
<p>
You wil learn in the <a href="xschem_properties.html">xschem properties chapter</a>

View File

@ -874,7 +874,10 @@ int set_text_flags(xText *t)
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 |= strboolcmp(str, "true") ? 0 : HIDE_TEXT;
if(!strcmp(str, "instance")) t->flags |= HIDE_TEXT_INSTANTIATED;
else {
t->flags |= strboolcmp(str, "true") ? 0 : HIDE_TEXT;
}
str = get_tok_value(t->prop_ptr, "name", 0);
if(!xctx->tok_size) str = get_tok_value(t->prop_ptr, "floater", 0);
t->flags |= xctx->tok_size ? TEXT_FLOATER : 0;

View File

@ -679,7 +679,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot,
get_sym_text_size(n, j, &xscale, &yscale);
text = symptr->text[j];
if(!text.txt_ptr || !text.txt_ptr[0] || xscale*FONTWIDTH*xctx->mooz<1) continue;
if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue;
if(!xctx->show_hidden_texts && (text.flags & (HIDE_TEXT | HIDE_TEXT_INSTANTIATED))) continue;
if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue;
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
textlayer = c;
@ -875,7 +875,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot
get_sym_text_size(n, j, &xscale, &yscale);
text = symptr->text[j];
if(!text.txt_ptr || !text.txt_ptr[0] || xscale*FONTWIDTH*xctx->mooz<1) continue;
if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue;
if(!xctx->show_hidden_texts && (text.flags & (HIDE_TEXT | HIDE_TEXT_INSTANTIATED))) continue;
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
#if HAS_CAIRO==1
customfont = set_text_custom_font(&text);

View File

@ -907,7 +907,7 @@ static void ps_draw_symbol(int n,int layer, int what, short tmp_flip, short rot,
get_sym_text_size(n, j, &xscale, &yscale);
text = (xctx->inst[n].ptr+ xctx->sym)->text[j];
/* if(xscale*FONTWIDTH* xctx->mooz<1) continue; */
if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue;
if(!xctx->show_hidden_texts && (text.flags & (HIDE_TEXT | HIDE_TEXT_INSTANTIATED))) 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);

View File

@ -357,7 +357,7 @@ void symbol_bbox(int i, double *x1,double *y1, double *x2, double *y2)
get_sym_text_size(i, j, &xscale, &yscale);
text = (xctx->inst[i].ptr+ xctx->sym)->text[j];
if(!xctx->show_hidden_texts && (text.flags & HIDE_TEXT)) continue;
if(!xctx->show_hidden_texts && (text.flags & (HIDE_TEXT | HIDE_TEXT_INSTANTIATED))) continue;
sym_flip = flip;
sym_rot = rot;
/* dbg(2, "symbol_bbox(): instance %d text n: %d text str=%s\n", i,j, text.txt_ptr? text.txt_ptr:"NULL"); */

View File

@ -547,7 +547,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
get_sym_text_size(n, j, &xscale, &yscale);
text = symptr->text[j];
/* if(xscale*FONTWIDTH* xctx->mooz<1) continue; */
if(!xctx->show_hidden_texts && (symptr->text[j].flags & HIDE_TEXT)) continue;
if(!xctx->show_hidden_texts && (symptr->text[j].flags & (HIDE_TEXT | HIDE_TEXT_INSTANTIATED))) 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);

View File

@ -311,6 +311,7 @@ extern char win_temp_dir[PATH_MAX];
/* flag (.flags field) to hide text in symbols when displaying instances */
#define HIDE_TEXT 8
#define TEXT_FLOATER 16
#define HIDE_TEXT_INSTANTIATED 32
#define S(a) (sizeof(a)/sizeof(a[0]))
#define BUS_WIDTH 4