GPv3: port active_layer operator and menu #115606

Merged
Falk David merged 8 commits from SmugRainbowPony/blender:gp_active_layer into main 2023-11-30 16:10:14 +01:00
Contributor

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.

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.
Clément Busschaert added 5 commits 2023-11-30 12:22:07 +01:00
Falk David requested review from Falk David 2023-11-30 13:53:54 +01:00
Falk David added this to the Grease Pencil project 2023-11-30 13:53:59 +01:00
Falk David requested changes 2023-11-30 14:06:38 +01:00
Falk David left a comment
Member

Thank you for working on this :) I have a few smaller comments.

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:
Member

Return early for less indentations

if not obd.layers:
   return
...
Return early for less indentations ``` if not obd.layers: return ... ```
filedescriptor marked this conversation as resolved
@ -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)
Member

This variable tot_layers is only used once so we can remove it.

This variable `tot_layers` is only used once so we can remove it.
filedescriptor marked this conversation as resolved
@ -276,0 +286,4 @@
layout.separator()
tot_layers = len(obd.layers)
i = tot_layers - 1
while i >= 0:
Member

We can use a for loop over a range here which reduces the code size a bit.

for i in range(len(obd.layers) - 1,  -1,  -1):
We can use a `for` loop over a `range` here which reduces the code size a bit. ``` for i in range(len(obd.layers) - 1, -1, -1): ```
filedescriptor marked this conversation as resolved
@ -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());
Member

The accessor in a Span already has this assert, so this one is not needed.

The accessor in a `Span` already has this assert, so this one is not needed.
filedescriptor marked this conversation as resolved
@ -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) {
Member

Use grease_pencil.is_layer_active(layer) instead.

Use `grease_pencil.is_layer_active(layer)` instead.
filedescriptor marked this conversation as resolved
Clément Busschaert added 1 commit 2023-11-30 14:21:57 +01:00
Author
Contributor

Thanks for the review. I addressed those changes

Thanks for the review. I addressed those changes
Falk David requested changes 2023-11-30 14:58:15 +01:00
Falk David left a comment
Member

One last comment :)

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
Member

Since we're iterating over a range now, this line can be removed.

Since we're iterating over a range now, this line can be removed.
filedescriptor marked this conversation as resolved
Clément Busschaert added 1 commit 2023-11-30 15:02:58 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
ec6520c715
Cleanup: remove unneeded decrement
Member

@blender-bot build

@blender-bot build
Member

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, 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.
Author
Contributor

Alright, thank you!

Alright, thank you!
Falk David requested changes 2023-11-30 15:26:44 +01:00
Falk David left a comment
Member

Works great :) I noticed while testing that the default layer name is not consistent with the layer_add operator so that should be changed.

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"
Member

The default name should be the same as the one for the "layer_add" operator which is "Layer".

The default name should be the same as the one for the "layer_add" operator which is `"Layer"`.
Author
Contributor

makes enough sense to me, yes, thank you for catching that.

makes enough sense to me, yes, thank you for catching that.
filedescriptor marked this conversation as resolved
Falk David approved these changes 2023-11-30 15:47:43 +01:00
Falk David left a comment
Member

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 :)

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 :)
Clément Busschaert added 1 commit 2023-11-30 15:55:35 +01:00
Falk David merged commit 671f428ead into main 2023-11-30 16:10:14 +01: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#115606
No description provided.