diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_ui.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 97 |
1 files changed, 94 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index f0b6f8d5423..ce1f9efcf63 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -179,6 +179,12 @@ static void rna_Panel_unregister(Main *UNUSED(bmain), StructRNA *type) RNA_struct_free_extension(type, &pt->ext); RNA_struct_free(&BLENDER_RNA, type); + if (pt->parent) { + LinkData *link = BLI_findptr(&pt->parent->children, pt, offsetof(LinkData, data)); + BLI_freelinkN(&pt->parent->children, link); + } + + BLI_freelistN(&pt->children); BLI_freelinkN(&art->paneltypes, pt); /* update while blender is running */ @@ -190,7 +196,7 @@ static StructRNA *rna_Panel_register( StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) { ARegionType *art; - PanelType *pt, dummypt = {NULL}; + PanelType *pt, *parent = NULL, dummypt = {NULL}; Panel dummypanel = {NULL}; PointerRNA dummyptr; int have_function[3]; @@ -229,6 +235,10 @@ static StructRNA *rna_Panel_register( BLI_freelinkN(&art->paneltypes, pt); break; } + + if (dummypt.parent_id[0] && STREQ(pt->idname, dummypt.parent_id)) { + parent = pt; + } } if (!RNA_struct_available_or_report(reports, dummypt.idname)) { return NULL; @@ -236,6 +246,11 @@ static StructRNA *rna_Panel_register( if (!RNA_struct_bl_idname_ok_or_report(reports, dummypt.idname, "_PT_")) { return NULL; } + if (dummypt.parent_id[0] && !parent) { + BKE_reportf(reports, RPT_ERROR, "Registering panel class: parent '%s' for '%s' not found", + dummypt.parent_id, dummypt.idname); + return NULL; + } /* create a new panel type */ pt = MEM_callocN(sizeof(PanelType), "python buttons panel"); @@ -267,6 +282,18 @@ static StructRNA *rna_Panel_register( else BLI_addtail(&art->paneltypes, pt); + if (parent) { + pt->parent = parent; + BLI_addtail(&parent->children, BLI_genericNodeN(pt)); + } + + { + const char *owner_id = RNA_struct_state_owner_get(); + if (owner_id) { + BLI_strncpy(pt->owner_id, owner_id, sizeof(pt->owner_id)); + } + } + /* update while blender is running */ WM_main_add_notifier(NC_WINDOW, NULL); @@ -561,7 +588,7 @@ static void rna_Header_unregister(Main *UNUSED(bmain), StructRNA *type) if (!ht) return; - if (!(art = region_type_find(NULL, ht->space_type, RGN_TYPE_HEADER))) + if (!(art = region_type_find(NULL, ht->space_type, ht->region_type))) return; RNA_struct_free_extension(type, &ht->ext); @@ -585,6 +612,7 @@ static StructRNA *rna_Header_register( /* setup dummy header & header type to store static properties in */ dummyheader.type = &dummyht; + dummyht.region_type = RGN_TYPE_HEADER; /* RGN_TYPE_HEADER by default, may be overridden */ RNA_pointer_create(NULL, &RNA_Header, &dummyheader, &dummyhtr); /* validate the python class */ @@ -597,7 +625,7 @@ static StructRNA *rna_Header_register( return NULL; } - if (!(art = region_type_find(reports, dummyht.space_type, RGN_TYPE_HEADER))) + if (!(art = region_type_find(reports, dummyht.space_type, dummyht.region_type))) return NULL; /* check if we have registered this header type before, and remove it */ @@ -773,6 +801,13 @@ static StructRNA *rna_Menu_register( mt->poll = (have_function[0]) ? menu_poll : NULL; mt->draw = (have_function[1]) ? menu_draw : NULL; + { + const char *owner_id = RNA_struct_state_owner_get(); + if (owner_id) { + BLI_strncpy(mt->owner_id, owner_id, sizeof(mt->owner_id)); + } + } + WM_menutype_add(mt); /* update while blender is running */ @@ -889,6 +924,26 @@ static void rna_UILayout_scale_y_set(PointerRNA *ptr, float value) uiLayoutSetScaleY(ptr->data, value); } +static int rna_UILayout_emboss_get(PointerRNA *ptr) +{ + return uiLayoutGetEmboss(ptr->data); +} + +static void rna_UILayout_emboss_set(PointerRNA *ptr, int value) +{ + uiLayoutSetEmboss(ptr->data, value); +} + +static int rna_UILayout_property_split_get(PointerRNA *ptr) +{ + return uiLayoutGetPropSep(ptr->data); +} + +static void rna_UILayout_property_split_set(PointerRNA *ptr, int value) +{ + uiLayoutSetPropSep(ptr->data, value); +} + #else /* RNA_RUNTIME */ static void rna_def_ui_layout(BlenderRNA *brna) @@ -904,6 +959,14 @@ static void rna_def_ui_layout(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static const EnumPropertyItem emboss_items[] = { + {UI_EMBOSS, "NORMAL", 0, "Normal", "Draw standard button emboss style"}, + {UI_EMBOSS_NONE, "NONE", 0, "None", "Draw only text and icons"}, + {UI_EMBOSS_PULLDOWN, "PULLDOWN_MENU", 0, "Pulldown Menu", "Draw pulldown menu style"}, + {UI_EMBOSS_RADIAL, "RADIAL_MENU", 0, "Radial Menu", "Draw radial menu style"}, + {0, NULL, 0, NULL, NULL} + }; + /* layout */ srna = RNA_def_struct(brna, "UILayout", NULL); @@ -941,6 +1004,13 @@ static void rna_def_ui_layout(BlenderRNA *brna) RNA_def_property_float_funcs(prop, "rna_UILayout_scale_y_get", "rna_UILayout_scale_y_set", NULL); RNA_def_property_ui_text(prop, "Scale Y", "Scale factor along the Y for items in this (sub)layout"); RNA_api_ui_layout(srna); + + prop = RNA_def_property(srna, "emboss", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, emboss_items); + RNA_def_property_enum_funcs(prop, "rna_UILayout_emboss_get", "rna_UILayout_emboss_set", NULL); + + prop = RNA_def_property(srna, "use_property_split", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_UILayout_property_split_get", "rna_UILayout_property_split_set"); } static void rna_def_panel(BlenderRNA *brna) @@ -1023,6 +1093,10 @@ static void rna_def_panel(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "type->category"); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->owner_id"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type->space_type"); RNA_def_property_enum_items(prop, rna_enum_space_type_items); @@ -1048,6 +1122,11 @@ static void rna_def_panel(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG); RNA_def_property_ui_text(prop, "Options", "Options for this panel type"); + prop = RNA_def_property(srna, "bl_parent_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->parent_id"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_def_property_ui_text(prop, "Parent ID Name", "If this is set, the panel becomes a subpanel"); + prop = RNA_def_property(srna, "use_pin", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PNL_PIN); RNA_def_property_ui_text(prop, "Pin", ""); @@ -1222,6 +1301,14 @@ static void rna_def_header(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER); RNA_def_property_ui_text(prop, "Space type", "The space where the header is going to be used in"); + prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->region_type"); + RNA_def_property_enum_default(prop, RGN_TYPE_HEADER); + RNA_def_property_enum_items(prop, rna_enum_region_type_items); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_def_property_ui_text(prop, "Region Type", "The region where the header is going to be used in " + "(defaults to header region)"); + RNA_define_verify_sdna(1); } @@ -1290,6 +1377,10 @@ static void rna_def_menu(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */ + prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->owner_id"); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_define_verify_sdna(1); } |