GPv3: convert selection domain on curves when selection mode changes #109964

Merged
Falk David merged 3 commits from SietseB/blender:gp3-select-modes-convert into main 2023-07-12 10:22:52 +02:00
Member

When the selection mode in the Grease Pencil tool settings changes,
the selection domain of all curves in the active Grease Pencil object
has to change.
This PR handles that conversion. Point selections are converted to
curve selection and vice versa.

Note: this PR only takes care of selection modes 'Point' and 'Stroke'.
'Segment' mode is handled in a separate PR (#109221).

When the selection mode in the Grease Pencil tool settings changes, the selection domain of all curves in the active Grease Pencil object has to change. This PR handles that conversion. Point selections are converted to curve selection and vice versa. Note: this PR only takes care of selection modes 'Point' and 'Stroke'. 'Segment' mode is handled in a separate PR (#109221).
Sietse Brouwer added 1 commit 2023-07-11 12:45:11 +02:00
Sietse Brouwer requested review from Falk David 2023-07-11 12:45:24 +02:00
Sietse Brouwer added this to the Grease Pencil project 2023-07-11 12:45:29 +02:00
Falk David requested changes 2023-07-11 13:04:14 +02:00
Falk David left a comment
Member

First pass.

First pass.
@ -323,0 +334,4 @@
for (const int index : drawings.index_range()) {
GreasePencilDrawingBase *drawing_base = drawings[index];
if (drawing_base->type == GP_DRAWING) {
Member

Since bases of type GP_DRAWING_REFERENCE are never editable, we can just skip them. So instead of this if, we can just do:

if (drawing_base->type != GP_DRAWING) {
   continue;
}
Since bases of type `GP_DRAWING_REFERENCE` are never editable, we can just skip them. So instead of this `if`, we can just do: ``` if (drawing_base->type != GP_DRAWING) { continue; } ```
SietseB marked this conversation as resolved
@ -323,0 +344,4 @@
/* Skip curve when the selection domain already matches, or when there is no selection
* at all. */
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
Member

Since the following part is probably the same for curves, it might be worth it to put this logic into a common function. @HooglyBoogly What do you think?

Since the following part is probably the same for curves, it might be worth it to put this logic into a common function. @HooglyBoogly What do you think?
Author
Member

I noticed an UX difference: in GP, when you have a few points on a curve selected and you switch to 'curve' mode, the entire curve is selected. In '3D' curves, the curve is only selected when you have all points selected.
So if we unify the functions, we have to decide if we honour that difference.

I noticed an UX difference: in GP, when you have _a few_ points on a curve selected and you switch to 'curve' mode, the entire curve is selected. In '3D' curves, the curve is only selected when you have _all points_ selected. So if we unify the functions, we have to decide if we honour that difference.
Member

Ah that is a good point. Keeping the current grease pencil behavior is the way to go, so I think this can stay as is.

Ah that is a good point. Keeping the current grease pencil behavior is the way to go, so I think this can stay as is.
@ -323,0 +399,4 @@
ts->gpencil_selectmode_edit = mode_new;
/* Convert all drawings of the active GP to the new selection domain. */
select_convert_selection_domain(C);
Member

I don't think an extra function here is necessary. All the code can be in the _exec.

I don't think an extra function here is necessary. All the code can be in the `_exec`.
SietseB marked this conversation as resolved
Sietse Brouwer added 1 commit 2023-07-11 15:59:39 +02:00
Falk David requested changes 2023-07-11 17:36:02 +02:00
Falk David left a comment
Member

Small comment.

Small comment.
@ -323,0 +329,4 @@
ToolSettings *ts = CTX_data_tool_settings(C);
ts->gpencil_selectmode_edit = mode_new;
WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, nullptr);
Member

This should probably be moved in the if (changed)

This should probably be moved in the `if (changed)`
SietseB marked this conversation as resolved
Sietse Brouwer added 1 commit 2023-07-11 19:13:10 +02:00
Falk David approved these changes 2023-07-12 10:19:39 +02:00
Falk David left a comment
Member

Looks good now!

Looks good now!
Falk David merged commit 64887c80a2 into main 2023-07-12 10:22:52 +02:00
Sietse Brouwer deleted branch gp3-select-modes-convert 2023-07-12 12:06:53 +02:00
Sign in to join this conversation.
No reviewers
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 project
No Assignees
2 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#109964
No description provided.