GPv3: Show All Materials #115001
|
@ -15,33 +15,36 @@ from bl_ui.properties_grease_pencil_common import (
|
|||
class GPENCIL_MT_material_context_menu(Menu):
|
||||
bl_label = "Material Specials"
|
||||
|
||||
def draw(self, _context):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
if context.preferences.experimental.use_grease_pencil_version3:
|
||||
layout.operator("grease_pencil.material_reveal", icon='RESTRICT_VIEW_OFF', text="Show All")
|
||||
else:
|
||||
layout.operator("gpencil.material_reveal", icon='RESTRICT_VIEW_OFF', text="Show All")
|
||||
layout.operator("gpencil.material_hide", icon='RESTRICT_VIEW_ON', text="Hide Others").unselected = True
|
||||
|
||||
layout.operator("gpencil.material_reveal", icon='RESTRICT_VIEW_OFF', text="Show All")
|
||||
layout.operator("gpencil.material_hide", icon='RESTRICT_VIEW_ON', text="Hide Others").unselected = True
|
||||
layout.separator()
|
||||
|
||||
layout.separator()
|
||||
layout.operator("gpencil.material_lock_all", icon='LOCKED', text="Lock All")
|
||||
layout.operator("gpencil.material_unlock_all", icon='UNLOCKED', text="Unlock All")
|
||||
|
||||
layout.operator("gpencil.material_lock_all", icon='LOCKED', text="Lock All")
|
||||
layout.operator("gpencil.material_unlock_all", icon='UNLOCKED', text="Unlock All")
|
||||
layout.operator("gpencil.material_lock_unused", text="Lock Unselected")
|
||||
layout.operator("gpencil.lock_layer", text="Lock Unused")
|
||||
|
||||
layout.operator("gpencil.material_lock_unused", text="Lock Unselected")
|
||||
layout.operator("gpencil.lock_layer", text="Lock Unused")
|
||||
layout.separator()
|
||||
|
||||
layout.separator()
|
||||
layout.operator("gpencil.material_to_vertex_color", text="Convert Materials to Color Attribute")
|
||||
layout.operator("gpencil.extract_palette_vertex", text="Extract Palette from Color Attribute")
|
||||
|
||||
layout.operator("gpencil.material_to_vertex_color", text="Convert Materials to Color Attribute")
|
||||
layout.operator("gpencil.extract_palette_vertex", text="Extract Palette from Color Attribute")
|
||||
layout.separator()
|
||||
|
||||
layout.separator()
|
||||
layout.operator("gpencil.materials_copy_to_object", text="Copy Material to Selected").only_active = True
|
||||
layout.operator("gpencil.materials_copy_to_object", text="Copy All Materials to Selected").only_active = False
|
||||
|
||||
layout.operator("gpencil.materials_copy_to_object", text="Copy Material to Selected").only_active = True
|
||||
layout.operator("gpencil.materials_copy_to_object", text="Copy All Materials to Selected").only_active = False
|
||||
layout.separator()
|
||||
|
||||
layout.separator()
|
||||
layout.operator("gpencil.stroke_merge_material", text="Merge Similar")
|
||||
|
||||
layout.operator("gpencil.stroke_merge_material", text="Merge Similar")
|
||||
layout.operator("object.material_slot_remove_unused")
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ set(SRC
|
|||
intern/grease_pencil_frames.cc
|
||||
intern/grease_pencil_geom.cc
|
||||
intern/grease_pencil_layers.cc
|
||||
intern/grease_pencil_material.cc
|
||||
intern/grease_pencil_ops.cc
|
||||
intern/grease_pencil_select.cc
|
||||
intern/grease_pencil_utils.cc
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup edgreasepencil
|
||||
*/
|
||||
|
||||
#include "DNA_material_types.h"
|
||||
antoniov marked this conversation as resolved
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_grease_pencil.hh"
|
||||
#include "BKE_material.h"
|
||||
|
||||
#include "DEG_depsgraph.hh"
|
||||
|
||||
#include "ED_grease_pencil.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
|
||||
namespace blender::ed::greasepencil {
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Show All Materials Operator
|
||||
* \{ */
|
||||
|
||||
static int grease_pencil_material_reveal_exec(bContext *C, wmOperator * /*op*/)
|
||||
{
|
||||
Object *object = CTX_data_active_object(C);
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
|
||||
|
||||
bool changed = false;
|
||||
for (const int i : IndexRange(object->totcol)) {
|
||||
if (Material *ma = BKE_gpencil_material(object, i + 1)) {
|
||||
MaterialGPencilStyle *gp_style = ma->gp_style;
|
||||
gp_style->flag &= ~GP_MATERIAL_HIDE;
|
||||
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA | NA_EDITED, &grease_pencil);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void GREASE_PENCIL_OT_material_reveal(wmOperatorType *ot)
|
||||
{
|
||||
/* Identifiers. */
|
||||
antoniov marked this conversation as resolved
Falk David
commented
You need to make sure to iterate over the material slots on the object and object-data. So I think
You need to make sure to iterate over the material slots on the object and object-data. So I think `BKE_object_material_len_p` doesn't work. But you can just use `obejct->totcol` I believe.
So:
```
for (const int i : IndexRange(object->totcol)) {
```
Antonio Vazquez
commented
It was something I was thinking... changed! It was something I was thinking... changed!
|
||||
ot->name = "Show All Materials";
|
||||
antoniov marked this conversation as resolved
Falk David
commented
`if (Material *ma = BKE_gpencil_material(object, i + 1)) {`
|
||||
ot->idname = "GREASE_PENCIL_OT_material_reveal";
|
||||
ot->description = "Unhide all hidden Grease Pencil materials";
|
||||
|
||||
/* Callbacks. */
|
||||
ot->exec = grease_pencil_material_reveal_exec;
|
||||
ot->poll = active_grease_pencil_poll;
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
} // namespace blender::ed::greasepencil
|
||||
|
||||
void ED_operatortypes_grease_pencil_material()
|
||||
{
|
||||
using namespace blender::ed::greasepencil;
|
||||
WM_operatortype_append(GREASE_PENCIL_OT_material_reveal);
|
||||
}
|
||||
antoniov marked this conversation as resolved
Falk David
commented
Remove blank line here. Remove blank line here.
|
|
@ -15,4 +15,5 @@ void ED_operatortypes_grease_pencil()
|
|||
ED_operatortypes_grease_pencil_layers();
|
||||
ED_operatortypes_grease_pencil_select();
|
||||
ED_operatortypes_grease_pencil_edit();
|
||||
ED_operatortypes_grease_pencil_material();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ void ED_operatortypes_grease_pencil_frames();
|
|||
void ED_operatortypes_grease_pencil_layers();
|
||||
void ED_operatortypes_grease_pencil_select();
|
||||
void ED_operatortypes_grease_pencil_edit();
|
||||
void ED_operatortypes_grease_pencil_material();
|
||||
void ED_keymap_grease_pencil(wmKeyConfig *keyconf);
|
||||
/**
|
||||
* Get the selection mode for Grease Pencil selection operators: point, stroke, segment.
|
||||
|
|
|
@ -68,6 +68,7 @@ const EnumPropertyItem rna_enum_ramp_blend_items[] = {
|
|||
# include "BKE_colorband.h"
|
||||
# include "BKE_context.hh"
|
||||
# include "BKE_gpencil_legacy.h"
|
||||
# include "BKE_grease_pencil.hh"
|
||||
# include "BKE_main.h"
|
||||
# include "BKE_material.h"
|
||||
# include "BKE_node.h"
|
||||
|
@ -112,6 +113,10 @@ static void rna_MaterialGpencil_update(Main *bmain, Scene *scene, PointerRNA *pt
|
|||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
if (ob->type == OB_GREASE_PENCIL) {
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
|
||||
DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
}
|
||||
|
||||
WM_main_add_notifier(NC_GPENCIL | ND_DATA, ma);
|
||||
|
|
Loading…
Reference in New Issue
Most of these includes look unnecessary