40 for (
const int i :
IndexRange(object->totcol)) {
43 gp_style.
flag &= ~GP_MATERIAL_HIDE;
60 ot->
name =
"Show All Materials";
61 ot->
idname =
"GREASE_PENCIL_OT_material_reveal";
62 ot->
description =
"Unhide all hidden Grease Pencil materials";
84 const int material_index =
object->actcol - 1;
86 for (
const int i :
IndexRange(object->totcol)) {
87 if (
invert && i == material_index) {
90 if (!
invert && i != material_index) {
112 ot->
name =
"Hide Materials";
113 ot->
idname =
"GREASE_PENCIL_OT_material_hide";
114 ot->
description =
"Hide active/inactive Grease Pencil material(s)";
124 ot->
srna,
"invert",
false,
"Invert",
"Hide inactive materials instead of the active one");
138 bool changed =
false;
139 for (
const int i :
IndexRange(object->totcol)) {
159 ot->
name =
"Lock All Materials";
160 ot->
idname =
"GREASE_PENCIL_OT_material_lock_all";
162 "Lock all Grease Pencil materials to prevent them from being accidentally modified";
182 bool changed =
false;
183 for (
const int i :
IndexRange(object->totcol)) {
186 gp_style.
flag &= ~GP_MATERIAL_LOCKED;
203 ot->
name =
"Unlock All Materials";
204 ot->
idname =
"GREASE_PENCIL_OT_material_unlock_all";
205 ot->
description =
"Unlock all Grease Pencil materials so that they can be edited";
225 bool changed =
false;
226 for (
const int material_index :
IndexRange(object->totcol)) {
247 ot->
name =
"Lock Unused Materials";
248 ot->
idname =
"GREASE_PENCIL_OT_material_lock_unused";
273 bool changed =
false;
281 *
object, info.drawing, info.layer_index, memory);
287 const VArray<int> material_indices = *attributes.lookup_or_default<
int>(
288 "material_index", AttrDomain::Curve, 0);
290 if (
const std::optional<int> single = material_indices.
get_if_single()) {
291 materials_used.
add(*single);
294 strokes.
foreach_index([&](
const int i) { materials_used.
add(material_indices[i]); });
301 for (
const int i :
IndexRange(object->totcol)) {
323 ot->
name =
"Lock Unselected Materials";
324 ot->
idname =
"GREASE_PENCIL_OT_material_lock_unselected";
325 ot->
description =
"Lock any material not used in any selected stroke";
349 if (ma_active ==
nullptr) {
360 if (only_active && ma_src != ma_active) {
364 if (ma_src ==
nullptr) {
385 ot->
name =
"Copy Materials to Selected Object";
386 ot->
idname =
"GREASE_PENCIL_OT_material_copy_to_object";
387 ot->
description =
"Append Materials of the active Grease Pencil to other object";
399 "Append only active material, uncheck to append all materials");
413 bool isolate =
false;
419 if (active_material ==
nullptr) {
426 for (
short i = 0; i < *totcol; i++) {
429 if (
ELEM(ma,
nullptr, active_ma)) {
437 if ((gp_style->
flag & flags) == 0) {
446 for (
short i = 0; i < *totcol; i++) {
452 if (gp_style == active_material) {
455 gp_style->
flag |= flags;
461 for (
short i = 0; i < *totcol; i++) {
467 gp_style->
flag &= ~flags;
481 ot->
name =
"Isolate Material";
482 ot->
idname =
"GREASE_PENCIL_OT_material_isolate";
484 "Toggle whether the active material is the only one that is editable and/or visible";
498 "In addition to toggling "
499 "the editability, also affect the visibility");
#define CTX_DATA_BEGIN(C, Type, instance, member)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
Low-level operations for curves.
Low-level operations for grease pencil.
General operations, lookup, etc. for materials.
struct Material * BKE_gpencil_material(struct Object *ob, short act)
struct Material * BKE_object_material_get(struct Object *ob, short act)
bool BKE_object_material_slot_used(struct Object *object, short actcol)
short * BKE_object_material_len_p(struct Object *ob)
int BKE_object_material_ensure(Main *bmain, Object *ob, Material *material)
struct MaterialGPencilStyle * BKE_gpencil_material_settings(struct Object *ob, short act)
void DEG_id_tag_update(ID *id, unsigned int flags)
bool contains(const Key &key) const
std::optional< T > get_if_single() const
void foreach_index(Fn &&fn) const
void ED_operatortypes_grease_pencil_material()
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
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 int grease_pencil_material_lock_all_exec(bContext *C, wmOperator *)
static int grease_pencil_material_lock_unselected_exec(bContext *C, wmOperator *)
static int grease_pencil_material_hide_exec(bContext *C, wmOperator *op)
static int grease_pencil_material_unlock_all_exec(bContext *C, wmOperator *)
static void GREASE_PENCIL_OT_material_hide(wmOperatorType *ot)
static int grease_pencil_material_reveal_exec(bContext *C, wmOperator *)
static int material_isolate_exec(bContext *C, wmOperator *op)
static int grease_pencil_material_copy_to_object_exec(bContext *C, wmOperator *op)
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 int grease_pencil_material_lock_unused_exec(bContext *C, wmOperator *)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
struct MaterialGPencilStyle * gp_style
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))