Page MenuHome

Move selection box with spacebar
ClosedPublic

Authored by Erik Abrahamsson (erik85) on Oct 16 2020, 12:08 AM.
Tokens
"Love" token, awarded by hitrpr."Like" token, awarded by DaveDeer."Love" token, awarded by asknarin."Like" token, awarded by MetinSeven."Love" token, awarded by gilberto_rodrigues."100" token, awarded by Torrent."Love" token, awarded by ThinkingPolygons."Love" token, awarded by jenkm."Like" token, awarded by duarteframos."Burninate" token, awarded by harley.

Details

Summary

This patch adds a modal key to move the selection box/lasso/line while drawing it. It also sets "repeat": False on the animation playback key to prevent accidental playback if the spacebar is released after the mouse button.

Diff Detail

Repository
rB Blender

Event Timeline

Erik Abrahamsson (erik85) requested review of this revision.Oct 16 2020, 12:08 AM
Erik Abrahamsson (erik85) created this revision.

Brilliant! I love the fact that it's generic so it works everywhere!

Here I tested it on Box Selection, Box Mask, Box Face Sets, Box Trim, Render Border.

Thanks for working on this Erik!

This revision is now accepted and ready to land.Oct 16 2020, 12:57 AM

Nice to see this finally in blender.. 👍
Does it also work with the line gestures tools like the Line Project tool of sculpt mode? This tool desperately needs this functionality.

Testing this, it doesn't work when accessing border select with modifiers.

So if you have the box select tool, pressing Ctrl-drag means you need to release Ctrl before pressing spacebar.

I suspect some users will run into this, in this case would the fix be to allow space-bar with any modifier state? Or do we require releasing modifiers before pressing space.

release/scripts/presets/keyconfig/keymap_data/blender_default.py
2945

repeat will need to be set to false for all uses of the space-bar.

Check the 2.7x keymap too.

Campbell Barton (campbellbarton) requested changes to this revision.Oct 16 2020, 1:48 AM
This revision now requires changes to proceed.Oct 16 2020, 1:48 AM

Added repeat: false to all space bar commands, and any: true to allow modifiers while moving the selection.

Campbell Barton (campbellbarton) requested changes to this revision.Oct 16 2020, 2:36 AM
Campbell Barton (campbellbarton) added inline comments.
source/blender/windowmanager/WM_types.h
490–492

There is no need to store the size here, rectangle can be moved while maintaining it's current size.

source/blender/windowmanager/intern/wm_gesture_ops.c
212

Prefer the order of these checks be swapped, so the move case is checked first, using else { ... } for the default dragging behavior.

219–222

Suggest to calculate the offset, then use BLI_rcti_translate

This revision now requires changes to proceed.Oct 16 2020, 2:36 AM
source/blender/windowmanager/intern/wm_gesture_ops.c
219–222

I get what you mean, but don't know how to do it. Translate is a relative function, do I not need to store atleast the coordinates of the beginning of the move operation?

Erik Abrahamsson (erik85) marked 3 inline comments as done.

Updated as comments suggested.

jorge (jorsh) rescinded a token.

Does it also work with the line gestures tools like the Line Project tool of sculpt mode? This tool desperately needs this functionality.

+1
I'd be disappointed if it doesn't.

Campbell Barton (campbellbarton) requested changes to this revision.Oct 16 2020, 7:31 AM
  • The 2.7x keymap doesn't ignore repeat events.
  • There is no need to disable repeat on release events.
This revision now requires changes to proceed.Oct 16 2020, 7:31 AM
Erik Abrahamsson (erik85) marked an inline comment as done.

This also works with the lasso tool now, so maybe the review can be postponed a little while until I update the diff again.

Made Lasso gesture movable too.

Added the move function to line gestures too, so now all selection types and the new sculpt line project for example should be supported.

Added the move function to line gestures too

Now we are talking! Amazing 👌

source/blender/windowmanager/intern/wm_gesture_ops.c
696–699

This seems unnecessarily confusing, it can be written as.

for (int i = 0; i < gesture->points; i++) {
  lasso[(i * 2)] += x;
  lasso[(i * 2) + 1] += y;
}
Erik Abrahamsson (erik85) marked an inline comment as done.
Erik Abrahamsson (erik85) edited the summary of this revision. (Show Details)

Simplified the for-loop as suggested (with a tiny change to make it work).

Changed from MOVE_ON/MOVE_OFF flags to a toggling MOVE.

There's one thing that worries me about the latest update.
If the event value is 'ANY', repeated press events would cause the value to toggle. I'm not sure if we should rely on the repeat=False behavior, because it was only recently introduced and is quite OS dependent. I think it's fine (it's supported on Win, Linux/X11 & macOS now). But there's a chance it will break on some systems.

But this seems fine. Should there be an issue it's easy to restore the previous patch version.

Harley Acheson (harley) added inline comments.
source/blender/windowmanager/intern/wm_gesture_ops.c
697

This distance, being always unscaled pixels, should mean that this lasso smoothing will be different when using a high-dpi displays.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 20 2020, 10:20 PM
This revision was automatically updated to reflect the committed changes.