RNA: rename prop_popover_enum to prop_with_popover
A version for menu's is going to be added next and we already have UILayout.prop_menu_enum. This name indicates the popover is added behavior instead of a different kind of widget.
This commit is contained in:
		@@ -139,7 +139,7 @@ class VIEW3D_HT_header(Header):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            sub = row.row()
 | 
					            sub = row.row()
 | 
				
			||||||
            sub.ui_units_x = 4
 | 
					            sub.ui_units_x = 4
 | 
				
			||||||
            sub.prop_popover_enum(
 | 
					            sub.prop_with_popover(
 | 
				
			||||||
                orient_slot,
 | 
					                orient_slot,
 | 
				
			||||||
                "type",
 | 
					                "type",
 | 
				
			||||||
                text="",
 | 
					                text="",
 | 
				
			||||||
@@ -148,7 +148,7 @@ class VIEW3D_HT_header(Header):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # Pivot
 | 
					        # Pivot
 | 
				
			||||||
        if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode:
 | 
					        if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode:
 | 
				
			||||||
            layout.prop_popover_enum(
 | 
					            layout.prop_with_popover(
 | 
				
			||||||
                tool_settings,
 | 
					                tool_settings,
 | 
				
			||||||
                "transform_pivot_point",
 | 
					                "transform_pivot_point",
 | 
				
			||||||
                text="",
 | 
					                text="",
 | 
				
			||||||
@@ -226,7 +226,7 @@ class VIEW3D_HT_header(Header):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # grease pencil
 | 
					        # grease pencil
 | 
				
			||||||
        if object_mode == 'PAINT_GPENCIL':
 | 
					        if object_mode == 'PAINT_GPENCIL':
 | 
				
			||||||
            layout.prop_popover_enum(
 | 
					            layout.prop_with_popover(
 | 
				
			||||||
                tool_settings,
 | 
					                tool_settings,
 | 
				
			||||||
                "gpencil_stroke_placement_view3d",
 | 
					                "gpencil_stroke_placement_view3d",
 | 
				
			||||||
                text="",
 | 
					                text="",
 | 
				
			||||||
@@ -234,7 +234,7 @@ class VIEW3D_HT_header(Header):
 | 
				
			|||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}:
 | 
					        if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}:
 | 
				
			||||||
            row.prop_popover_enum(
 | 
					            row.prop_with_popover(
 | 
				
			||||||
                tool_settings.gpencil_sculpt,
 | 
					                tool_settings.gpencil_sculpt,
 | 
				
			||||||
                "lock_axis",
 | 
					                "lock_axis",
 | 
				
			||||||
                text="",
 | 
					                text="",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,7 +85,7 @@
 | 
				
			|||||||
/* prototypes. */
 | 
					/* prototypes. */
 | 
				
			||||||
static void ui_but_to_pixelrect(struct rcti *rect, const struct ARegion *ar, struct uiBlock *block, struct uiBut *but);
 | 
					static void ui_but_to_pixelrect(struct rcti *rect, const struct ARegion *ar, struct uiBlock *block, struct uiBut *but);
 | 
				
			||||||
static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p);
 | 
					static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *but_p);
 | 
				
			||||||
static void ui_def_but_rna__popover(bContext *UNUSED(C), uiLayout *layout, void *but_p);
 | 
					static void ui_def_but_rna__panel_type(bContext *UNUSED(C), uiLayout *layout, void *but_p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* avoid unneeded calls to ui_but_value_get */
 | 
					/* avoid unneeded calls to ui_but_value_get */
 | 
				
			||||||
#define UI_BUT_VALUE_UNSET DBL_MAX
 | 
					#define UI_BUT_VALUE_UNSET DBL_MAX
 | 
				
			||||||
@@ -1150,7 +1150,9 @@ static bool ui_but_event_property_operator_string(
 | 
				
			|||||||
		if ((but->type == UI_BTYPE_BUT_MENU) &&
 | 
							if ((but->type == UI_BTYPE_BUT_MENU) &&
 | 
				
			||||||
		    (but_parent && but_parent->rnaprop) &&
 | 
							    (but_parent && but_parent->rnaprop) &&
 | 
				
			||||||
		    (RNA_property_type(but_parent->rnaprop) == PROP_ENUM) &&
 | 
							    (RNA_property_type(but_parent->rnaprop) == PROP_ENUM) &&
 | 
				
			||||||
		    ELEM(but_parent->menu_create_func, ui_def_but_rna__menu, ui_def_but_rna__popover))
 | 
							    ELEM(but_parent->menu_create_func,
 | 
				
			||||||
 | 
							         ui_def_but_rna__menu,
 | 
				
			||||||
 | 
							         ui_def_but_rna__panel_type))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			prop_enum_value = (int)but->hardmin;
 | 
								prop_enum_value = (int)but->hardmin;
 | 
				
			||||||
			ptr = &but_parent->rnapoin;
 | 
								ptr = &but_parent->rnapoin;
 | 
				
			||||||
@@ -3832,7 +3834,7 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
 | 
				
			|||||||
	block->flag |= UI_BLOCK_IS_FLIP;
 | 
						block->flag |= UI_BLOCK_IS_FLIP;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void ui_def_but_rna__popover(bContext *C, uiLayout *layout, void *but_p)
 | 
					static void ui_def_but_rna__panel_type(bContext *C, uiLayout *layout, void *but_p)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uiBut *but = but_p;
 | 
						uiBut *but = but_p;
 | 
				
			||||||
	const char *panel_type = but->func_argN;
 | 
						const char *panel_type = but->func_argN;
 | 
				
			||||||
@@ -3847,18 +3849,18 @@ static void ui_def_but_rna__popover(bContext *C, uiLayout *layout, void *but_p)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ui_but_rna_menu_convert_to_popover(uiBut *but, const char *panel_type)
 | 
					void ui_but_rna_menu_convert_to_panel_type(uiBut *but, const char *panel_type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	BLI_assert(but->type == UI_BTYPE_MENU);
 | 
						BLI_assert(but->type == UI_BTYPE_MENU);
 | 
				
			||||||
	BLI_assert(but->menu_create_func == ui_def_but_rna__menu);
 | 
						BLI_assert(but->menu_create_func == ui_def_but_rna__menu);
 | 
				
			||||||
	BLI_assert((void *)but->poin == but);
 | 
						BLI_assert((void *)but->poin == but);
 | 
				
			||||||
	but->menu_create_func = ui_def_but_rna__popover;
 | 
						but->menu_create_func = ui_def_but_rna__panel_type;
 | 
				
			||||||
	but->func_argN = BLI_strdup(panel_type);
 | 
						but->func_argN = BLI_strdup(panel_type);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool ui_but_menu_draw_as_popover(const uiBut *but)
 | 
					bool ui_but_menu_draw_as_popover(const uiBut *but)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (but->menu_create_func == ui_def_but_rna__popover);
 | 
						return (but->menu_create_func == ui_def_but_rna__panel_type);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void ui_but_submenu_enable(uiBlock *block, uiBut *but)
 | 
					static void ui_but_submenu_enable(uiBlock *block, uiBut *but)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -485,7 +485,7 @@ extern uiButExtraIconType ui_but_icon_extra_get(uiBut *but);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
extern void ui_but_default_set(struct bContext *C, const bool all, const bool use_afterfunc);
 | 
					extern void ui_but_default_set(struct bContext *C, const bool all, const bool use_afterfunc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void ui_but_rna_menu_convert_to_popover(struct uiBut *but, const char *panel_type);
 | 
					extern void ui_but_rna_menu_convert_to_panel_type(struct uiBut *but, const char *panel_type);
 | 
				
			||||||
extern bool ui_but_menu_draw_as_popover(const uiBut *but);
 | 
					extern bool ui_but_menu_draw_as_popover(const uiBut *but);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void ui_but_update(uiBut *but);
 | 
					extern void ui_but_update(uiBut *but);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2003,7 +2003,7 @@ void uiItemFullR_with_popover(
 | 
				
			|||||||
	but = but->next;
 | 
						but = but->next;
 | 
				
			||||||
	while (but) {
 | 
						while (but) {
 | 
				
			||||||
		if (but->rnaprop == prop && but->type == UI_BTYPE_MENU) {
 | 
							if (but->rnaprop == prop && but->type == UI_BTYPE_MENU) {
 | 
				
			||||||
			ui_but_rna_menu_convert_to_popover(but, panel_type);
 | 
								ui_but_rna_menu_convert_to_panel_type(but, panel_type);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		but = but->next;
 | 
							but = but->next;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -117,23 +117,7 @@ static void rna_uiItemR(
 | 
				
			|||||||
	uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon);
 | 
						uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void rna_uiItemMenuEnumR(
 | 
					static void rna_uiItemR_with_popover(
 | 
				
			||||||
        uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
 | 
					 | 
				
			||||||
        const char *text_ctxt, bool translate, int icon)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!prop) {
 | 
					 | 
				
			||||||
		RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Get translated name (label). */
 | 
					 | 
				
			||||||
	name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
 | 
					 | 
				
			||||||
	uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void rna_uiItemPopoverPanelEnumR(
 | 
					 | 
				
			||||||
        uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
 | 
					        uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
 | 
				
			||||||
        const char *text_ctxt, bool translate, int icon,
 | 
					        const char *text_ctxt, bool translate, int icon,
 | 
				
			||||||
        bool icon_only,
 | 
					        bool icon_only,
 | 
				
			||||||
@@ -158,6 +142,22 @@ static void rna_uiItemPopoverPanelEnumR(
 | 
				
			|||||||
	uiItemFullR_with_popover(layout, ptr, prop, -1, 0, flag, name, icon, panel_type);
 | 
						uiItemFullR_with_popover(layout, ptr, prop, -1, 0, flag, name, icon, panel_type);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void rna_uiItemMenuEnumR(
 | 
				
			||||||
 | 
					        uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
 | 
				
			||||||
 | 
					        const char *text_ctxt, bool translate, int icon)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!prop) {
 | 
				
			||||||
 | 
							RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Get translated name (label). */
 | 
				
			||||||
 | 
						name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
 | 
				
			||||||
 | 
						uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void rna_uiItemTabsEnumR(
 | 
					static void rna_uiItemTabsEnumR(
 | 
				
			||||||
        uiLayout *layout, bContext *C,
 | 
					        uiLayout *layout, bContext *C,
 | 
				
			||||||
        struct PointerRNA *ptr, const char *propname,
 | 
					        struct PointerRNA *ptr, const char *propname,
 | 
				
			||||||
@@ -664,7 +664,7 @@ void RNA_api_ui_layout(StructRNA *srna)
 | 
				
			|||||||
	api_ui_item_rna_common(func);
 | 
						api_ui_item_rna_common(func);
 | 
				
			||||||
	api_ui_item_common(func);
 | 
						api_ui_item_common(func);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	func = RNA_def_function(srna, "prop_popover_enum", "rna_uiItemPopoverPanelEnumR");
 | 
						func = RNA_def_function(srna, "prop_with_popover", "rna_uiItemR_with_popover");
 | 
				
			||||||
	api_ui_item_rna_common(func);
 | 
						api_ui_item_rna_common(func);
 | 
				
			||||||
	api_ui_item_common(func);
 | 
						api_ui_item_common(func);
 | 
				
			||||||
	RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
 | 
						RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user