GPv3: Tint tool #119314

Closed
opened 2024-03-11 11:12:29 +01:00 by Falk David · 1 comment
Member

The tint tool needs to be added for GPv3.

Here is a checklist for adding the tint operation (without the implementation) and exposing it in the UI:

Adding the operation

  • Create a file in blender/source/blender/editors/sculpt_paint/ called grease_pencil_tint.cc.
  • Declare a function std::unique_ptr<GreasePencilStrokeOperation> new_tint_operation(); in blender/source/blender/editors/sculpt_paint/grease_pencil_intern.hh. The implementation will go into grease_pencil_tint.cc
  • In grease_pencil_tint.cc write a class
class TintOperation : public GreasePencilStrokeOperation {
 public:
  void on_stroke_begin(const bContext &C, const InputSample &start_sample) override;
  void on_stroke_extended(const bContext &C, const InputSample &extension_sample) override;
  void on_stroke_done(const bContext &C) override;
};
  • Make sure to add the function to create the operation
std::unique_ptr<GreasePencilStrokeOperation> new_tint_operation()
{
  return std::make_unique<TintOperation>();
}
  • Add a case for GPAINT_TOOL_TINT in start_brush_operation in blender/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc. This should call new_tint_operation().release().

Exposing it in the UI

  • In blender/scripts/startup/bl_ui/space_toolsystem_toolbar.py in the _defs_paint_grease_pencil class add the following snippet:
@ToolDef.from_fn
def tint():
    return dict(
        idname="builtin_brush.Tint",
        label="Tint",
        icon="brush.gpencil_draw.tint",
        data_block='TINT',
    )

Implementation

The implementation is done in the on_stroke_begin, on_stroke_extend, and on_stroke_done functions. See blender/source/blender/editors/sculpt_paint/grease_pencil_paint.cc for how these are used. Generally, it's best to not store anything from the bContext in the class and just re-query it on every on_stroke_extend callback.
See brush_tint_apply in blender/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.cc for the legacy implementation.

The tint tool needs to be added for GPv3. Here is a checklist for adding the tint operation (without the implementation) and exposing it in the UI: ## Adding the operation - [ ] Create a file in `blender/source/blender/editors/sculpt_paint/` called `grease_pencil_tint.cc`. - [ ] Declare a function `std::unique_ptr<GreasePencilStrokeOperation> new_tint_operation();` in `blender/source/blender/editors/sculpt_paint/grease_pencil_intern.hh`. The implementation will go into `grease_pencil_tint.cc` - [ ] In `grease_pencil_tint.cc` write a class ```cpp class TintOperation : public GreasePencilStrokeOperation { public: void on_stroke_begin(const bContext &C, const InputSample &start_sample) override; void on_stroke_extended(const bContext &C, const InputSample &extension_sample) override; void on_stroke_done(const bContext &C) override; }; ``` - [ ] Make sure to add the function to create the operation ```cpp std::unique_ptr<GreasePencilStrokeOperation> new_tint_operation() { return std::make_unique<TintOperation>(); } ``` - [ ] Add a case for `GPAINT_TOOL_TINT` in `start_brush_operation` in `blender/source/blender/editors/sculpt_paint/grease_pencil_draw_ops.cc`. This should call `new_tint_operation().release()`. ## Exposing it in the UI - [ ] In `blender/scripts/startup/bl_ui/space_toolsystem_toolbar.py` in the `_defs_paint_grease_pencil` class add the following snippet: ```py @ToolDef.from_fn def tint(): return dict( idname="builtin_brush.Tint", label="Tint", icon="brush.gpencil_draw.tint", data_block='TINT', ) ``` # Implementation The implementation is done in the `on_stroke_begin`, `on_stroke_extend`, and `on_stroke_done` functions. See `blender/source/blender/editors/sculpt_paint/grease_pencil_paint.cc` for how these are used. Generally, it's best to not store anything from the `bContext` in the class and just re-query it on every `on_stroke_extend` callback. See `brush_tint_apply` in `blender/source/blender/editors/gpencil_legacy/gpencil_vertex_paint.cc` for the legacy implementation.
Falk David added the
Type
To Do
label 2024-03-11 11:12:29 +01:00
Falk David added this to the Grease Pencil project 2024-03-11 11:12:32 +01:00
YimingWu was assigned by Falk David 2024-03-11 11:13:02 +01:00
Author
Member

Committed 127f879be9.

Committed https://projects.blender.org/blender/blender/commit/127f879be93fc91ed3f7c4ae0c30d395ece8be8a.
Blender Bot added the
Status
Archived
label 2024-03-29 12:43:45 +01: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 project
No Assignees
1 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#119314
No description provided.