Added icon_value property to GIZMO_GT_button_2d #108988
|
@ -133,22 +133,30 @@ static void button2d_draw_intern(const bContext *C,
|
|||
const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
|
||||
if (button->is_init == false) {
|
||||
button->is_init = true;
|
||||
PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon");
|
||||
button->icon = -1;
|
||||
if (RNA_property_is_set(gz->ptr, prop)) {
|
||||
button->icon = RNA_property_enum_get(gz->ptr, prop);
|
||||
|
||||
PropertyRNA *icon_value = RNA_struct_find_property(gz->ptr, "icon_value");
|
||||
if (RNA_property_is_set(gz->ptr, icon_value)) {
|
||||
button->icon = RNA_property_int_get(gz->ptr, icon_value);
|
||||
}
|
||||
else {
|
||||
prop = RNA_struct_find_property(gz->ptr, "shape");
|
||||
const uint polys_len = RNA_property_string_length(gz->ptr, prop);
|
||||
/* We shouldn't need the +1, but a NULL char is set. */
|
||||
char *polys = MEM_mallocN(polys_len + 1, __func__);
|
||||
RNA_property_string_get(gz->ptr, prop, polys);
|
||||
button->shape_batch[0] = GPU_batch_tris_from_poly_2d_encoded(
|
||||
(uchar *)polys, polys_len, NULL);
|
||||
button->shape_batch[1] = GPU_batch_wire_from_poly_2d_encoded(
|
||||
(uchar *)polys, polys_len, NULL);
|
||||
MEM_freeN(polys);
|
||||
|
||||
PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon");
|
||||
if (RNA_property_is_set(gz->ptr, prop)) {
|
||||
button->icon = RNA_property_enum_get(gz->ptr, prop);
|
||||
}
|
||||
else {
|
||||
prop = RNA_struct_find_property(gz->ptr, "shape");
|
||||
const uint polys_len = RNA_property_string_length(gz->ptr, prop);
|
||||
/* We shouldn't need the +1, but a NULL char is set. */
|
||||
char *polys = MEM_mallocN(polys_len + 1, __func__);
|
||||
RNA_property_string_get(gz->ptr, prop, polys);
|
||||
button->shape_batch[0] = GPU_batch_tris_from_poly_2d_encoded(
|
||||
(uchar *)polys, polys_len, NULL);
|
||||
button->shape_batch[1] = GPU_batch_wire_from_poly_2d_encoded(
|
||||
(uchar *)polys, polys_len, NULL);
|
||||
MEM_freeN(polys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,6 +417,8 @@ static void GIZMO_GT_button_2d(wmGizmoType *gzt)
|
|||
|
||||
RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
|
||||
|
||||
RNA_def_property(gzt->srna, "icon_value", PROP_INT, PROP_NONE);
|
||||
|
||||
prop = RNA_def_property(gzt->srna, "icon", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, rna_enum_icon_items);
|
||||
|
||||
|
|
Loading…
Reference in New Issue