added intuitive_interface xschemrc and menu option: click and drag to quickly move objects without keyboard commands

This commit is contained in:
stefan schippers 2024-03-02 14:15:30 +01:00
parent 78ef3091e9
commit 77cd3eec56
6 changed files with 55 additions and 5 deletions

View File

@ -1348,6 +1348,7 @@ int rstate; /* (reduced state, without ShiftMask) */
* Do not start an area select if user is dragging a polygon/bezier point */
if(!(xctx->ui_state & STARTPOLYGON) && (state&Button1Mask) && !(xctx->ui_state & STARTWIRE) &&
!(xctx->ui_state & STARTPAN) && !(SET_MODMASK) && !xctx->poly_point_selected &&
!xctx->drag_elements &&
!(state & ShiftMask) && !(xctx->ui_state & (PLACE_SYMBOL | PLACE_TEXT)))
{
@ -1377,7 +1378,7 @@ int rstate; /* (reduced state, without ShiftMask) */
/* Select by area. Shift pressed */
else if((state&Button1Mask) && (state & ShiftMask) &&
!(xctx->ui_state & (PLACE_SYMBOL | PLACE_TEXT)) && !xctx->poly_point_selected &&
!(xctx->ui_state & STARTPAN) ) {
!xctx->drag_elements && !(xctx->ui_state & STARTPAN) ) {
if(mx != xctx->mx_save || my != xctx->my_save) {
if( !(xctx->ui_state & STARTSELECT)) {
select_rect(START,1);
@ -3152,7 +3153,12 @@ int rstate; /* (reduced state, without ShiftMask) */
}
/* If no shift was pressed while Button1Press delete selection */
if( !(state & (ShiftMask | ControlMask)) && !(SET_MODMASK) ) {
unselect_all(1);
if(xctx->intuitive_interface) {
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
if(!sel.type) unselect_all(1);
} else {
unselect_all(1);
}
}
/* polygon point: Check is user is clicking a control point of a polygon */
if(polygon_n >= 0) {
@ -3231,6 +3237,21 @@ int rstate; /* (reduced state, without ShiftMask) */
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
}
rebuild_selected_array();
/* intuitive interface: directly drag elements */
xctx->drag_elements = 0;
if(xctx->intuitive_interface && xctx->lastsel >= 1 &&
!(xctx->lastsel == 1 && xctx->sel_array[0].type==POLYGON) ) {
xctx->drag_elements = 1;
if( state == ControlMask && !tclgetboolvar("enable_stretch")) {
select_attached_nets(); /* stretch nets that land on selected instance pins */
}
if(state == ShiftMask) xctx->connect_by_kissing = 2;
move_objects(START,0,0,0);
}
#ifndef __unix__
draw_selection(xctx->gc[SELLAYER], 0);
#endif
@ -3260,7 +3281,11 @@ int rstate; /* (reduced state, without ShiftMask) */
/* if a polygon/bezier control point was clicked, end point move operation
* and set polygon state back to SELECTED from SELECTED1 */
if((xctx->ui_state & (STARTMOVE | SELECTION)) && xctx->poly_point_selected) {
if(xctx->drag_elements) {
move_objects(END,0,0,0);
xctx->drag_elements = 0;
}
else if((xctx->ui_state & (STARTMOVE | SELECTION)) && xctx->poly_point_selected) {
if(xctx->lastsel == 1 && xctx->sel_array[0].type==POLYGON) {
int k;
int n = xctx->sel_array[0].n;

View File

@ -1202,10 +1202,15 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
else
Tcl_SetResult(interp, "", TCL_STATIC);
}
else if(!strcmp(argv[2], "instances")) { /* number of instances in schematic */
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
Tcl_SetResult(interp, my_itoa(xctx->instances), TCL_VOLATILE);
}
else if(!strcmp(argv[2], "intuitive_interface")) { /* ERC messages */
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
Tcl_SetResult(interp, my_itoa(xctx->intuitive_interface), TCL_VOLATILE);
}
break;
case 'l':
if(!strcmp(argv[2], "last_created_window")) { /* return win_path of last created tab or window */
@ -4613,6 +4618,11 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
my_strdup(_ALLOC_ID_, &xctx->infowindow_text, argv[3]);
}
else if(!strcmp(argv[2], "intuitive_interface")) { /* ERC messages */
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}
xctx->intuitive_interface = atoi(argv[3]);
}
} else { /* argv[2][0] >= 'n' */
if(!strcmp(argv[2], "netlist_name")) { /* set custom netlist name */
if(!xctx) {Tcl_SetResult(interp, not_avail, TCL_STATIC); return TCL_ERROR;}

View File

@ -458,6 +458,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
xctx->tail_undo_ptr = 0;
xctx->undo_dirname = NULL;
xctx->infowindow_text = NULL;
xctx->intuitive_interface = 0;
if(!strcmp(tclgetvar("undo_type"), "disk")) {
xctx->undo_type = 0;
@ -580,6 +581,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path)
xctx->hilight_time = 0; /* timestamp for sims */
xctx->poly_point_selected = 0;
xctx->drag_elements = 0;
xctx->hilight_nets = 0;
xctx->hilight_color = 0;
for(i=0;i<CADMAXHIER; ++i) {
@ -2586,6 +2588,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
my_strncpy(xctx->plotfile, cli_opt_plotfile, S(xctx->plotfile));
xctx->draw_window = tclgetintvar("draw_window");
xctx->only_probes = tclgetintvar("only_probes");
xctx->intuitive_interface = tclgetboolvar("intuitive_interface");
/* set global variables fetching data from tcl code */

View File

@ -976,6 +976,7 @@ typedef struct {
int crosshair_layer;
char *undo_dirname;
char *infowindow_text; /* ERC messages */
int intuitive_interface;
int cur_undo_ptr;
int tail_undo_ptr;
int head_undo_ptr;
@ -984,6 +985,7 @@ typedef struct {
Node_hashentry **node_table;
Hilight_hashentry **hilight_table;
int poly_point_selected;
int drag_elements;
int hilight_nets;
int hilight_color;
int hilight_time; /* timestamp for sims */

View File

@ -6832,7 +6832,8 @@ set tctx::global_list {
graph_change_done graph_digital graph_linewidth_mult graph_logx
graph_logy graph_rainbow graph_schname graph_sel_color graph_sel_wave
graph_selected graph_sort graph_unlocked hide_empty_graphs hide_symbols tctx::hsize
incr_hilight incremental_select infowindow_text keep_symbols launcher_default_program
incr_hilight incremental_select infowindow_text intuitive_interface
keep_symbols launcher_default_program
light_colors line_width live_cursor2_backannotate local_netlist_dir lvs_ignore
lvs_netlist measure_text netlist_dir netlist_show netlist_type no_ask_save
no_change_attrs nolist_libs noprint_libs old_selected_tok only_probes path pathlist
@ -7207,7 +7208,7 @@ proc load_raw {{type {}}} {
proc build_widgets { {topwin {} } } {
global XSCHEM_SHAREDIR tabbed_interface simulate_bg OS sim
global recentfile color_ps transparent_svg menu_debug_var enable_stretch
global netlist_show flat_netlist split_files compare_sch
global netlist_show flat_netlist split_files compare_sch intuitive_interface
global draw_grid big_grid_points sym_txt change_lw incr_hilight symbol_width
global cadsnap cadgrid draw_window show_pin_net_names toolbar_visible hide_symbols undo_type
global disable_unique_names persistent_command autotrim_wires en_hilight_conn_inst
@ -7351,6 +7352,8 @@ proc build_widgets { {topwin {} } } {
}
}
$topwin.menubar.option.menu add checkbutton -label "Persistent wire/line place command" -variable persistent_command
$topwin.menubar.option.menu add checkbutton -label "Intuitive Click & Drag interface" \
-variable intuitive_interface -command {xschem set intuitive_interface $intuitive_interface}
$topwin.menubar.option.menu add command -label "Replace \[ and \] for buses in SPICE netlist" \
-command {
@ -8231,6 +8234,7 @@ set_ne draw_grid 1
set_ne big_grid_points 0
set_ne draw_grid_axes 1
set_ne persistent_command 0
set_ne intuitive_interface 0
set_ne autotrim_wires 0
set_ne compare_sch 0
set_ne disable_unique_names 0

View File

@ -189,6 +189,12 @@
#### default: 0
# set persistent_command 1
#### if set to 1 allow click & drag objects in the schematic
#### to move them without keyboard commands ('m')
#### default: 0
# set intuitive_interface 0
#### if set to 1 at end of a move operation that stretches wires attached to
#### moved objects these wires will be unselected.
#### default: not enabled (0)