62 ot->
name =
"Show All Materials";
63 ot->
idname =
"GREASE_PENCIL_OT_material_reveal";
64 ot->
description =
"Unhide all hidden Grease Pencil materials";
86 const int material_index =
object->actcol - 1;
89 if (
invert && i == material_index) {
92 if (!
invert && i != material_index) {
114 ot->
name =
"Hide Materials";
115 ot->
idname =
"GREASE_PENCIL_OT_material_hide";
116 ot->
description =
"Hide active/inactive Grease Pencil material(s)";
126 ot->
srna,
"invert",
false,
"Invert",
"Hide inactive materials instead of the active one");
140 bool changed =
false;
161 ot->
name =
"Lock All Materials";
162 ot->
idname =
"GREASE_PENCIL_OT_material_lock_all";
164 "Lock all Grease Pencil materials to prevent them from being accidentally modified";
184 bool changed =
false;
205 ot->
name =
"Unlock All Materials";
206 ot->
idname =
"GREASE_PENCIL_OT_material_unlock_all";
207 ot->
description =
"Unlock all Grease Pencil materials so that they can be edited";
227 bool changed =
false;
249 ot->
name =
"Lock Unused Materials";
250 ot->
idname =
"GREASE_PENCIL_OT_material_lock_unused";
251 ot->
description =
"Lock and hide any material not used";
275 bool changed =
false;
283 *
object, info.drawing, info.layer_index, memory);
292 if (
const std::optional<int> single = material_indices.
get_if_single()) {
293 materials_used.
add(*single);
296 strokes.
foreach_index([&](
const int i) { materials_used.
add(material_indices[i]); });
325 ot->
name =
"Lock Unselected Materials";
326 ot->
idname =
"GREASE_PENCIL_OT_material_lock_unselected";
327 ot->
description =
"Lock any material not used in any selected stroke";
350 if (ma_active ==
nullptr) {
361 if (only_active && ma_src != ma_active) {
365 if (ma_src ==
nullptr) {
386 ot->
name =
"Copy Materials to Selected Object";
387 ot->
idname =
"GREASE_PENCIL_OT_material_copy_to_object";
388 ot->
description =
"Append Materials of the active Grease Pencil to other object";
400 "Append only active material, uncheck to append all materials");
414 bool isolate =
false;
420 if (active_material ==
nullptr) {
427 for (
short i = 0; i < *totcol; i++) {
430 if (
ELEM(ma,
nullptr, active_ma)) {
437 gp_style = ma->gp_style;
438 if ((gp_style->
flag & flags) == 0) {
447 for (
short i = 0; i < *totcol; i++) {
452 gp_style = ma->gp_style;
453 if (gp_style == active_material) {
456 gp_style->
flag |= flags;
462 for (
short i = 0; i < *totcol; i++) {
467 gp_style = ma->gp_style;
468 gp_style->
flag &= ~flags;
482 ot->
name =
"Isolate Material";
483 ot->
idname =
"GREASE_PENCIL_OT_material_isolate";
485 "Toggle whether the active material is the only one that is editable and/or visible";
499 "In addition to toggling "
500 "the editability, also affect the visibility");
#define CTX_DATA_BEGIN(C, Type, instance, member)
Low-level operations for curves.
Low-level operations for grease pencil.
General operations, lookup, etc. for materials.
constexpr IndexRange()=default
bool contains(const Key &key) const
std::optional< T > get_if_single() const
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
float2x2 invert(float2x2 mat)
bool active_grease_pencil_poll(bContext *C)
IndexMask retrieve_editable_and_selected_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
static void GREASE_PENCIL_OT_material_lock_unused(wmOperatorType *ot)
static void GREASE_PENCIL_OT_material_copy_to_object(wmOperatorType *ot)
static void GREASE_PENCIL_OT_material_unlock_all(wmOperatorType *ot)
static void GREASE_PENCIL_OT_material_lock_unselected(wmOperatorType *ot)
static void GREASE_PENCIL_OT_material_isolate(wmOperatorType *ot)
static void GREASE_PENCIL_OT_material_lock_all(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_material_lock_unused_exec(bContext *C, wmOperator *)
static wmOperatorStatus material_isolate_exec(bContext *C, wmOperator *op)
static void GREASE_PENCIL_OT_material_hide(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_material_unlock_all_exec(bContext *C, wmOperator *)
static wmOperatorStatus grease_pencil_material_reveal_exec(bContext *C, wmOperator *)
static wmOperatorStatus grease_pencil_material_lock_unselected_exec(bContext *C, wmOperator *)
static wmOperatorStatus grease_pencil_material_copy_to_object_exec(bContext *C, wmOperator *op)
static wmOperatorStatus grease_pencil_material_lock_all_exec(bContext *C, wmOperator *)
bool active_grease_pencil_material_poll(bContext *C)
Vector< MutableDrawingInfo > retrieve_editable_drawings(const Scene &scene, GreasePencil &grease_pencil)
static void GREASE_PENCIL_OT_material_reveal(wmOperatorType *ot)
static wmOperatorStatus grease_pencil_material_hide_exec(bContext *C, wmOperator *op)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
Material * BKE_gpencil_material(Object *ob, short act)
short * BKE_object_material_len_p(Object *ob)
Material * BKE_object_material_get(Object *ob, short act)
eMaterialGPencilStyle_Flag
int BKE_object_material_ensure(Main *bmain, Object *ob, Material *material)
MaterialGPencilStyle * BKE_gpencil_material_settings(Object *ob, short act)
bool BKE_object_material_slot_used(Object *object, short actcol)
void DEG_id_tag_update(ID *id, unsigned int flags)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Main * CTX_data_main(const bContext *C)
void ED_operatortypes_grease_pencil_material()
Scene * CTX_data_scene(const bContext *C)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
Object * CTX_data_active_object(const bContext *C)
eMaterialGPencilStyle_Flag flag
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT