diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_properties.py | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_screen.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 40 |
4 files changed, 44 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py index 053df113dd7..b7d5b5007d6 100644 --- a/release/scripts/startup/bl_ui/space_properties.py +++ b/release/scripts/startup/bl_ui/space_properties.py @@ -72,9 +72,10 @@ class PROPERTIES_PT_navigation_bar(Panel): class PROPERTIES_PT_options(Panel): + """Show options for the properties editor""" bl_space_type = 'PROPERTIES' bl_region_type = 'HEADER' - bl_label = 'Show options for the properties editor' + bl_label = "Options" def draw(self, context): layout = self.layout diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 2fc0caf1a2c..32c888b058f 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -240,6 +240,7 @@ typedef struct PanelType { char idname[BKE_ST_MAXNAME]; /* unique name */ char label[BKE_ST_MAXNAME]; /* for panel header */ + char *description; /* for panel tooltip */ char translation_context[BKE_ST_MAXNAME]; char context[BKE_ST_MAXNAME]; /* for buttons window */ char category[BKE_ST_MAXNAME]; /* for category tabs */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index fef243d7193..8f90dc7f801 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -3057,7 +3057,8 @@ void uiItemPopoverPanel_ptr( }; pt->draw_header(C, &panel); } - uiBut *but = ui_item_menu(layout, name, icon, ui_item_paneltype_func, pt, NULL, NULL, true); + uiBut *but = ui_item_menu( + layout, name, icon, ui_item_paneltype_func, pt, NULL, pt->description, true); but->type = UI_BTYPE_POPOVER; if (!ok) { but->flag |= UI_BUT_DISABLED; diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 1d3a7750c39..5e5b3549986 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -261,9 +261,14 @@ static StructRNA *rna_Panel_register(Main *bmain, Panel dummypanel = {NULL}; PointerRNA dummyptr; int have_function[4]; + size_t over_alloc = 0; /* Warning, if this becomes a mess, we better do another allocation. */ + char _panel_descr[RNA_DYN_DESCR_MAX]; + size_t description_size = 0; /* setup dummy panel & panel type to store static properties in */ dummypanel.type = &dummypt; + _panel_descr[0] = '\0'; + dummypanel.type->description = _panel_descr; RNA_pointer_create(NULL, &RNA_Panel, &dummypanel, &dummyptr); /* We have to set default context! Else we get a void string... */ @@ -355,9 +360,22 @@ static StructRNA *rna_Panel_register(Main *bmain, } /* create a new panel type */ - pt = MEM_mallocN(sizeof(PanelType), "python buttons panel"); + if (_panel_descr[0]) { + description_size = strlen(_panel_descr) + 1; + over_alloc += description_size; + } + pt = MEM_callocN(sizeof(PanelType) + over_alloc, "python buttons panel"); memcpy(pt, &dummypt, sizeof(dummypt)); + if (_panel_descr[0]) { + char *buf = (char *)(pt + 1); + memcpy(buf, _panel_descr, description_size); + pt->description = buf; + } + else { + pt->description = NULL; + } + pt->rna_ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, pt->idname, &RNA_Panel); RNA_def_struct_translation_context(pt->rna_ext.srna, pt->translation_context); pt->rna_ext.data = data; @@ -993,6 +1011,18 @@ static StructRNA *rna_Menu_refine(PointerRNA *mtr) return (menu->type && menu->type->rna_ext.srna) ? menu->type->rna_ext.srna : &RNA_Menu; } +static void rna_Panel_bl_description_set(PointerRNA *ptr, const char *value) +{ + Panel *data = (Panel *)(ptr->data); + char *str = (char *)data->type->description; + if (!str[0]) { + BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */ + } + else { + BLI_assert(!"setting the bl_description on a non-builtin panel"); + } +} + static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value) { Menu *data = (Menu *)(ptr->data); @@ -1408,6 +1438,14 @@ static void rna_def_panel(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); RNA_define_verify_sdna(true); + prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->description"); + RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */ + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Panel_bl_description_set"); + /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ + 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_category", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->category"); RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); |