set line width commands also set minimum allowed line width (good for UHD displays)

This commit is contained in:
stefan schippers 2025-04-09 11:47:19 +02:00
parent 8d0837d5e9
commit c3cb1218a1
4 changed files with 9 additions and 9 deletions

View File

@ -3879,7 +3879,6 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
if(state & ControlMask) { /* change line width */ if(state & ControlMask) { /* change line width */
xctx->lw = round_to_n_digits(xctx->lw + 0.5, 2); xctx->lw = round_to_n_digits(xctx->lw + 0.5, 2);
change_linewidth(xctx->lw); change_linewidth(xctx->lw);
tclsetboolvar("change_lw", 0);
draw(); draw();
} }
break; break;
@ -3889,11 +3888,10 @@ static void handle_key_press(int event, KeySym key, int state, int rstate, int m
xctx->lw = round_to_n_digits(xctx->lw - 0.5, 2); xctx->lw = round_to_n_digits(xctx->lw - 0.5, 2);
if(xctx->lw < 0.0) xctx->lw = 0.0; if(xctx->lw < 0.0) xctx->lw = 0.0;
change_linewidth(xctx->lw); change_linewidth(xctx->lw);
tclsetboolvar("change_lw", 0);
draw(); draw();
} }
else if(EQUAL_MODMASK) { else if(EQUAL_MODMASK) {
tcleval("set change_lw 0; input_line \"Enter linewidth (float):\" \"xschem line_width\""); tcleval("input_line \"Enter linewidth (float):\" \"xschem line_width\"");
} }
break; break;

View File

@ -512,6 +512,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
xctx->ui_state = 0; xctx->ui_state = 0;
xctx->ui_state2 = 0; xctx->ui_state2 = 0;
xctx->lw = 0.0; xctx->lw = 0.0;
xctx->min_lw = 0;
xctx->need_reb_sel_arr = 1; xctx->need_reb_sel_arr = 1;
xctx->lastsel = 0; xctx->lastsel = 0;
xctx->maxsel = 0; xctx->maxsel = 0;
@ -2077,10 +2078,11 @@ void change_linewidth(double w)
} }
/* explicitly set line width */ /* explicitly set line width */
} else { } else {
xctx->min_lw = (int)w;
xctx->lw=w; xctx->lw=w;
} }
linew = XLINEWIDTH(xctx->lw);
if(has_x) { if(has_x) {
linew = INT_WIDTH(xctx->lw);
dbg(1, "Line width = %d\n", linew); dbg(1, "Line width = %d\n", linew);
for(i=0;i<cadlayers; ++i) { for(i=0;i<cadlayers; ++i) {
XSetLineAttributes(display, xctx->gc[i], linew, LineSolid, LINECAP , LINEJOIN); XSetLineAttributes(display, xctx->gc[i], linew, LineSolid, LINECAP , LINEJOIN);
@ -2097,8 +2099,8 @@ void change_linewidth(double w)
} }
#if HAS_CAIRO==1 #if HAS_CAIRO==1
if(has_x) { if(has_x) {
cairo_set_line_width(xctx->cairo_ctx, INT_WIDTH(xctx->lw)); cairo_set_line_width(xctx->cairo_ctx, linew);
cairo_set_line_width(xctx->cairo_save_ctx, INT_WIDTH(xctx->lw)); cairo_set_line_width(xctx->cairo_save_ctx, linew);
} }
#endif #endif
} }

View File

@ -422,8 +422,8 @@ do { \
#define SWAP(a,b, tmp) do { tmp = a; a = b; b = tmp; } while(0) #define SWAP(a,b, tmp) do { tmp = a; a = b; b = tmp; } while(0)
#define XLINEWIDTH(x) ( tclgetboolvar("change_lw") ? ( (int)(x) == 0 ? 1 : (int)(x) ) : (int)(x) ) #define XLINEWIDTH(x) MAJOR((tclgetboolvar("change_lw") ? ((int)(x) == 0 ? 1 : (int)(x)) : (int)(x)), xctx->min_lw)
#define INT_WIDTH(x) ((int)(x) == 0 ? 1 : (int)(x)) #define INT_WIDTH(x) MAJOR(((int)(x) == 0 ? 1 : (int)(x)), xctx->min_lw)
#define INT_BUS_WIDTH(x) ( (int)( (BUS_WIDTH) * (x) ) == 0 ? 1 : (int)( (BUS_WIDTH) * (x) ) ) #define INT_BUS_WIDTH(x) ( (int)( (BUS_WIDTH) * (x) ) == 0 ? 1 : (int)( (BUS_WIDTH) * (x) ) )
/* set do double if you need more precision at the expense of memory */ /* set do double if you need more precision at the expense of memory */
@ -942,6 +942,7 @@ typedef struct {
double zoom; double zoom;
double mooz; double mooz;
double lw; double lw;
int min_lw; /* minimum allowed line width (for UHD displays) */
unsigned int ui_state; /* this signals that we are doing a net place,panning etc. unsigned int ui_state; /* this signals that we are doing a net place,panning etc.
* used to prevent nesting of some commands */ * used to prevent nesting of some commands */
unsigned int ui_state2; /* sub states of ui_state MENUSTART bit */ unsigned int ui_state2; /* sub states of ui_state MENUSTART bit */

View File

@ -9110,7 +9110,6 @@ proc build_widgets { {topwin {} } } {
-selectcolor $selectcolor -accelerator {_} -selectcolor $selectcolor -accelerator {_}
$topwin.menubar.view add command -label "Set line width" -accelerator {Alt+-} \ $topwin.menubar.view add command -label "Set line width" -accelerator {Alt+-} \
-command { -command {
set change_lw 0
input_line "Enter linewidth (float):" "xschem line_width" input_line "Enter linewidth (float):" "xschem line_width"
} }
$topwin.menubar.view add command -label "Set grid point size" \ $topwin.menubar.view add command -label "Set grid point size" \