Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-04-22 18:16:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-04-22 18:45:14 +0300
commite6d1fb87c6b0184416ce202ccba6a96a3ee04552 (patch)
tree39e1e321364129dfae355ecff938f0bafb5eae33 /source/blender/makesrna/intern/rna_ui_api.c
parentb8e7991811dcf6fa698077f850fef17be83d2abb (diff)
UI: Initial popover support for panels
- UILayout.popover(.. panel_type ..) A single panel - UILayout.popover_group(.. panel categories ..) Expands all panels matching args. Currently used in the topbar for redo and paint options.
Diffstat (limited to 'source/blender/makesrna/intern/rna_ui_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 367efd71519..a8ae3374b16 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -268,6 +268,29 @@ static void rna_uiItemM(uiLayout *layout, bContext *C, const char *menuname, con
uiItemM(layout, C, menuname, name, icon);
}
+static void rna_uiItemPopoverPanel(
+ uiLayout *layout, bContext *C,
+ int space_type, int region_type, const char *panel_type,
+ const char *name, const char *text_ctxt,
+ int translate, int icon, int icon_value)
+{
+ /* Get translated name (label). */
+ name = rna_translate_ui_text(name, text_ctxt, NULL, NULL, translate);
+
+ if (icon_value && !icon) {
+ icon = icon_value;
+ }
+
+ uiItemPopoverPanel(layout, C, space_type, region_type, panel_type, name, icon);
+}
+
+static void rna_uiItemPopoverPanelFromGroup(
+ uiLayout *layout, bContext *C,
+ int space_id, int region_id, const char *context, const char *category)
+{
+ uiItemPopoverPanelFromGroup(layout, C, space_id, region_id, context, category);
+}
+
static void rna_uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename,
const char *name, const char *text_ctxt, int translate)
{
@@ -670,6 +693,29 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
+ func = RNA_def_function(srna, "popover", "rna_uiItemPopoverPanel");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ parm = RNA_def_enum(func, "space_type", rna_enum_space_type_items, 0, "Space Type", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_enum(func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_string(func, "panel_type", NULL, 0, "", "Identifier of the panel");
+ api_ui_item_common(func);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
+
+ func = RNA_def_function(srna, "popover_group", "rna_uiItemPopoverPanelFromGroup");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+ parm = RNA_def_enum(func, "space_type", rna_enum_space_type_items, 0, "Space Type", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_enum(func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_string(func, "context", NULL, 0, "", "panel type context");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_string(func, "category", NULL, 0, "", "panel type category");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+
func = RNA_def_function(srna, "separator", "uiItemS");
RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items");