Add new factor parameter to layout.separator()

The new parameter allows to define the scale of the space.
This commit is contained in:
Antonioya
2018-11-02 16:32:31 +01:00
parent d3ade45774
commit f3ffb4e049
3 changed files with 14 additions and 2 deletions

View File

@@ -1187,6 +1187,7 @@ void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int
void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon); /* menu */
void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value */
void uiItemS(uiLayout *layout); /* separator */
void uiItemS_ex(uiLayout *layout, float factor);
void uiItemSpacer(uiLayout *layout); /* Special separator. */
void uiItemPopoverPanel_ptr(

View File

@@ -2419,16 +2419,23 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
}
/* separator item */
void uiItemS(uiLayout *layout)
void uiItemS_ex(uiLayout *layout, float factor)
{
uiBlock *block = layout->root->block;
bool is_menu = ui_block_is_menu(block);
int space = (is_menu) ? 0.45f * UI_UNIT_X : 0.3f * UI_UNIT_X;
space *= factor;
UI_block_layout_set_current(block, layout);
uiDefBut(block, (is_menu) ? UI_BTYPE_SEPR_LINE : UI_BTYPE_SEPR, 0, "", 0, 0, space, space, NULL, 0.0, 0.0, 0, 0, "");
}
/* separator item */
void uiItemS(uiLayout *layout)
{
uiItemS_ex(layout, 1.0f);
}
/* Flexible spacing. */
void uiItemSpacer(uiLayout *layout)
{

View File

@@ -760,8 +760,12 @@ void RNA_api_ui_layout(StructRNA *srna)
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");
func = RNA_def_function(srna, "separator", "uiItemS_ex");
RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items");
RNA_def_float(
func, "factor", 0.0f, 0.0f, FLT_MAX, "Percentage",
"Percentage of width to space (leave unset for default space)",
0.0f, FLT_MAX);
func = RNA_def_function(srna, "separator_spacer", "uiItemSpacer");
RNA_def_function_ui_description(func, "Item. Inserts horizontal spacing empty space into the layout between items");