Animation: Graph Editor Handle Selection #111143

Merged
Nathan Vegdahl merged 11 commits from nathanvegdahl/blender:select_handles_patch into main 2023-09-21 15:05:37 +02:00
Member

Continuation of PR #108142 from @cgtinker.

This patch adds an operator for the graph editor, graph.select_key_handles,
that changes the selection of the different parts of a bezier keyframe. It
operates on all keys that are either themselves selected or have either of
their handles selected, and changes whether the key itself and/or its handles
are selected.

The operator has three options:

  • left_handle_action
  • right_handle_action
  • key_action

Each of which can be set to:

  • Select
  • Deselect
  • Keep (do nothing)

Co-authored-by: cgtinker Denys.Hsu@gmail.com

Continuation of PR #108142 from @cgtinker. This patch adds an operator for the graph editor, `graph.select_key_handles`, that changes the selection of the different parts of a bezier keyframe. It operates on all keys that are either themselves selected or have either of their handles selected, and changes whether the key itself and/or its handles are selected. The operator has three options: - `left_handle_action` - `right_handle_action` - `key_action` Each of which can be set to: - Select - Deselect - Keep (do nothing) Co-authored-by: cgtinker <Denys.Hsu@gmail.com>
Author
Member

I think the operator parameters could be made both a little clearer and more flexible with this approach:

Three parameters:

  • left_handle
  • right_handle
  • keyframe

Each of which can be "select", "deselect", or "leave alone". (Better naming for the last one welcome!)

What do people think?

I think the operator parameters could be made both a little clearer and more flexible with this approach: Three parameters: - `left_handle` - `right_handle` - `keyframe` Each of which can be "select", "deselect", or "leave alone". (Better naming for the last one welcome!) What do people think?
Nathan Vegdahl added the
Module
Animation & Rigging
label 2023-08-17 12:50:37 +02:00
Nathan Vegdahl added this to the Animation & Rigging project 2023-08-17 12:50:41 +02:00
Nathan Vegdahl requested review from Christoph Lendenfeld 2023-08-17 12:51:17 +02:00
Nathan Vegdahl requested review from Sybren A. Stüvel 2023-08-17 12:51:29 +02:00

@nathanvegdahl the current state of the code looks good to me
But I agree the parameters should be broken up into 3 separate parameters
the last option I suggest is "keep"

@nathanvegdahl the current state of the code looks good to me But I agree the parameters should be broken up into 3 separate parameters the last option I suggest is "keep"
Sybren A. Stüvel approved these changes 2023-09-15 15:09:39 +02:00
Sybren A. Stüvel left a comment
Member

Some minor remarks. Can be adjusted when landing.

Some minor remarks. Can be adjusted when landing.
@ -2067,0 +2126,4 @@
* Select keyframe handles left/right/both or keys based on the given selection.
*
* mode: Determines which handles to select - left, right, or both.
* deselect_keyframe: Specifies whether keyframes should be deselected (true) or if the current

Suggestion: "whether keyframes should" → "whether the keys themselves should".

Suggestion: "whether keyframes should" → "whether the keys themselves should".
nathanvegdahl marked this conversation as resolved
@ -2067,0 +2148,4 @@
continue;
}
switch (mode) {
case GRAPHKEYS_HANDLESEL_BOTH: {

Remove the curly braces, they are only necessary when introducing new variables inside the case.

Remove the curly braces, they are only necessary when introducing new variables inside the `case`.
nathanvegdahl marked this conversation as resolved
@ -2067,0 +2161,4 @@
break;
}
case GRAPHKEYS_HANDLESEL_KEY: {
ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, bezt_sel_keys, NULL);

Missing break

Missing `break`
nathanvegdahl marked this conversation as resolved
@ -2067,0 +2185,4 @@
const eGraphKey_HandleSelect_Side leftright = static_cast<eGraphKey_HandleSelect_Side>(
RNA_enum_get(op->ptr, "mode"));
const bool deselect_keyframe = RNA_boolean_get(op->ptr, "deselect_keyframe");
/* Perform selection changes. */

You don't need to explain what the function does at the call site of the function. If it needs explanation, choose a better function name.

You don't need to explain what the function does at the call site of the function. If it needs explanation, choose a better function name.
nathanvegdahl marked this conversation as resolved
@ -2067,0 +2199,4 @@
uiLayout *layout = op->layout;
uiLayout *row;
bool keyframe_selection = RNA_enum_get(op->ptr, "mode") == GRAPHKEYS_HANDLESEL_KEY;

const, and move this line down to where keyframe_selection is actually used.

`const`, and move this line down to where `keyframe_selection` is actually used.
nathanvegdahl marked this conversation as resolved
@ -2067,0 +2200,4 @@
uiLayout *row;
bool keyframe_selection = RNA_enum_get(op->ptr, "mode") == GRAPHKEYS_HANDLESEL_KEY;
row = uiLayoutRow(layout, false);

Declare row here, and not at the start of the function. The days of AncientC are over.

Declare `row` here, and not at the start of the function. The days of AncientC are over.
nathanvegdahl marked this conversation as resolved
@ -2067,0 +2230,4 @@
GRAPHKEYS_HANDLESEL_BOTH,
"Mode",
"Selects corresponding keyframe handles (left, right, both or keys) based on the given "
"selection");

"Selects ... based on the given selection" is not the clearest explanation. Suggestion:

Of the selected keys & handles, change the selection to only the handles (left/right/both) or just the keys themselves.

"Selects ... based on the given selection" is not the clearest explanation. Suggestion: > Of the selected keys & handles, change the selection to only the handles (left/right/both) or just the keys themselves.
Author
Member

Since the functionality has become a bit more flexible, I changed the description. Would love to have your eyes on it again.

Since the functionality has become a bit more flexible, I changed the description. Would love to have your eyes on it again.
nathanvegdahl marked this conversation as resolved
Nathan Vegdahl force-pushed select_handles_patch from 5c7fe5ed49 to 47e50a8383 2023-09-18 17:02:13 +02:00 Compare
Author
Member

I've updated the PR to the new options I outlined earlier.

Now that I've done that, however, it's not clear to me that the current operator name is appropriate anymore, given its additional flexibility. Maybe something like "Select Keyframe Parts"? @ChrisLend @dr.sybren Any ideas?

(The menu entries can still be labeled with what they each do, though, I think. "Select Handles", "Select Left Handles", etc.)

I've updated the PR to the new options I outlined earlier. Now that I've done that, however, it's not clear to me that the current operator name is appropriate anymore, given its additional flexibility. Maybe something like "Select Keyframe Parts"? @ChrisLend @dr.sybren Any ideas? (The menu entries can still be labeled with what they each do, though, I think. "Select Handles", "Select Left Handles", etc.)
Nathan Vegdahl requested review from Sybren A. Stüvel 2023-09-18 17:09:45 +02:00
Author
Member

Brought naming of the operator up at the module meeting, and consensus was "Select Key / Handles".

Brought naming of the operator up at the module meeting, and consensus was "Select Key / Handles".
Author
Member

I changed the operator name. Still not happy with the tool tips. I'll work on improving those next.

I changed the operator name. Still not happy with the tool tips. I'll work on improving those next.
Nathan Vegdahl force-pushed select_handles_patch from 967f92f89b to 5c5be1b8b5 2023-09-19 14:21:14 +02:00 Compare
Christoph Lendenfeld reviewed 2023-09-21 10:32:44 +02:00
@ -220,0 +229,4 @@
props = layout.operator("graph.select_key_handles", text="Select Handles Right")
props.left_handle_action = 'DESELECT'
props.right_handle_action = 'SELECT'
props.key_action = 'KEEP'

I think this should be 'DESELECT' because right now using this option you still have the key selected, meaning when using G to move it you move the key and not the handle.

I think this should be 'DESELECT' because right now using this option you still have the key selected, meaning when using G to move it you move the key and not the handle.
Author
Member

Good call.

But now that I think of it, do we even need the left/right versions in there at all? The primary use case is quickly selecting/deselecting both handles together. It's still good for the core operator to be flexible, so users with more niche use cases can do what they like. But for the provided menu items it might be best to just have "Select Handles" and "Select Keys".

Thoughts?

Good call. But now that I think of it, do we even need the left/right versions in there at all? [The primary use case](https://projects.blender.org/blender/blender/issues/103802#issuecomment-936441) is quickly selecting/deselecting both handles together. It's still good for the core operator to be flexible, so users with more niche use cases can do what they like. But for the provided menu items it might be best to just have "Select Handles" and "Select Keys". Thoughts?

In the context of this issue it makes sense to only have "Select Handles" and "Select Keys"

When talking about animation in general it could make sense to have a shortcut to only select handles on one side. But since the functionality exists it is reasonably easy to expose in a GUI. Maybe even a pie menu. But we can leave that for the future I think

In the context of this issue it makes sense to only have "Select Handles" and "Select Keys" When talking about animation in general it could make sense to have a shortcut to only select handles on one side. But since the functionality exists it is reasonably easy to expose in a GUI. Maybe even a pie menu. But we can leave that for the future I think
Author
Member

Yeah. I also checked with one of the animators here at the studio, and he said he would use Select Handles and Select Keys, but couldn't think of a common use for left/right. Of course, that's just a sample size of one. But I think it makes sense to keep things minimal now, and like you said we can always add more things and explore other ways to expose this in the future.

Yeah. I also checked with one of the animators here at the studio, and he said he would use Select Handles and Select Keys, but couldn't think of a common use for left/right. Of course, that's just a sample size of one. But I think it makes sense to keep things minimal now, and like you said we can always add more things and explore other ways to expose this in the future.
nathanvegdahl marked this conversation as resolved
Nathan Vegdahl added 1 commit 2023-09-21 11:28:22 +02:00
Nathan Vegdahl added 2 commits 2023-09-21 14:20:22 +02:00
Nathan Vegdahl added 1 commit 2023-09-21 14:31:20 +02:00
Christoph Lendenfeld approved these changes 2023-09-21 14:36:33 +02:00
Christoph Lendenfeld left a comment
Member

yep looks good to me :)

yep looks good to me :)
@ -2067,0 +2109,4 @@
int i = 0;
BezTriple *bezt = fcu->bezt;
for (; i < fcu->totvert; bezt++, i++) {

Personally I am not a fan of pointer incrementing. But I will leave this up to you

Personally I am not a fan of pointer incrementing. But I will leave this up to you
Author
Member

Ah, fair point. I basically just copy-pasted this from elsewhere. I agree that just using the index directly makes more sense here. Thanks for the catch!

Ah, fair point. I basically just copy-pasted this from elsewhere. I agree that just using the index directly makes more sense here. Thanks for the catch!
nathanvegdahl marked this conversation as resolved
Nathan Vegdahl added 1 commit 2023-09-21 14:43:42 +02:00
Nathan Vegdahl added 1 commit 2023-09-21 14:57:12 +02:00
Nathan Vegdahl merged commit be5cf8f8a1 into main 2023-09-21 15:05:37 +02:00
Nathan Vegdahl deleted branch select_handles_patch 2023-09-21 15:05:39 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#111143
No description provided.