GPv3: port active_layer
operator and menu #115606
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#115606
Loading…
Reference in New Issue
No description provided.
Delete Branch "SmugRainbowPony/blender:gp_active_layer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #113915 .
I did what I could to reproduce the behaviour, look, and locations of the old operators and menus. Only difference is the Draw header menu in GPv2 draw mode was replaced with a Paint menu.
Thank you for working on this :) I have a few smaller comments.
@ -276,0 +280,4 @@
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
obd = context.active_object.data
if obd.layers:
Return early for less indentations
@ -276,0 +284,4 @@
nlop = layout.operator("grease_pencil.layer_add", text="New Layer", icon='ADD')
nlop.new_layer_name = "New Layer"
layout.separator()
tot_layers = len(obd.layers)
This variable
tot_layers
is only used once so we can remove it.@ -276,0 +286,4 @@
layout.separator()
tot_layers = len(obd.layers)
i = tot_layers - 1
while i >= 0:
We can use a
for
loop over arange
here which reduces the code size a bit.@ -200,0 +204,4 @@
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
int layer_index = RNA_int_get(op->ptr, "layer");
BLI_assert(layer_index >= 0 && layer_index < grease_pencil.layers().size());
The accessor in a
Span
already has this assert, so this one is not needed.@ -200,0 +207,4 @@
BLI_assert(layer_index >= 0 && layer_index < grease_pencil.layers().size());
const Layer &layer = *grease_pencil.layers()[layer_index];
if (grease_pencil.active_layer == &layer) {
Use
grease_pencil.is_layer_active(layer)
instead.Thanks for the review. I addressed those changes
One last comment :)
@ -276,0 +295,4 @@
else:
icon = 'NONE'
layout.operator("grease_pencil.layer_active", text=layer.name, icon=icon).layer = i
i -= 1
Since we're iterating over a range now, this line can be removed.
@blender-bot build
Alright, I'll let the build bot build this to make sure all platforms build without issues and the tests run through.
While that's happening I'll test this locally to see if it works as I expect it to.
Alright, thank you!
Works great :) I noticed while testing that the default layer name is not consistent with the
layer_add
operator so that should be changed.@ -276,0 +284,4 @@
return
nlop = layout.operator("grease_pencil.layer_add", text="New Layer", icon='ADD')
nlop.new_layer_name = "New Layer"
The default name should be the same as the one for the "layer_add" operator which is
"Layer"
.makes enough sense to me, yes, thank you for catching that.
Cool, the build bots are happy. I'll approve this and once the default name is changed, I'll merge it.
Welcome to Blender developement :)