Collection IO: Enable file exporters to be specified on Collections #116646
|
@ -2299,6 +2299,8 @@ uiLayout *uiLayoutRow(uiLayout *layout, bool align);
|
|||
* \param name: Text that's shown in the panel header. It should already be translated.
|
||||
* \param open_prop_owner: Data that contains the open-property.
|
||||
* \param open_prop_name: Name of the open-property in `open_prop_owner`.
|
||||
* \param create_header: Whether to create the panel header or not. If false, the header is assumed
|
||||
* to have been created already using #uiLayoutPanelHeader.
|
||||
*
|
||||
* \return NULL if the panel is closed and should not be drawn, otherwise the layout where the
|
||||
* sub-panel should be inserted into.
|
||||
|
@ -2307,7 +2309,13 @@ uiLayout *uiLayoutPanel(const bContext *C,
|
|||
uiLayout *layout,
|
||||
const char *name,
|
||||
PointerRNA *open_prop_owner,
|
||||
const char *open_prop_name);
|
||||
const char *open_prop_name,
|
||||
bool create_header);
|
||||
uiLayout *uiLayoutPanelHeader(const bContext *C,
|
||||
uiLayout *layout,
|
||||
const char *name,
|
||||
PointerRNA *open_prop_owner,
|
||||
const char *open_prop_name);
|
||||
|
||||
bool uiLayoutEndsWithPanelHeader(const uiLayout &layout);
|
||||
|
||||
|
|
|
@ -4971,11 +4971,11 @@ uiLayout *uiLayoutRow(uiLayout *layout, bool align)
|
|||
return litem;
|
||||
}
|
||||
|
||||
uiLayout *uiLayoutPanel(const bContext *C,
|
||||
uiLayout *layout,
|
||||
const char *name,
|
||||
PointerRNA *open_prop_owner,
|
||||
const char *open_prop_name)
|
||||
uiLayout *uiLayoutPanelHeader(const bContext *C,
|
||||
uiLayout *layout,
|
||||
const char *name,
|
||||
PointerRNA *open_prop_owner,
|
||||
const char *open_prop_name)
|
||||
{
|
||||
const ARegion *region = CTX_wm_region(C);
|
||||
|
||||
|
@ -4983,35 +4983,52 @@ uiLayout *uiLayoutPanel(const bContext *C,
|
|||
const bool search_filter_active = region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE;
|
||||
const bool is_open = is_real_open || search_filter_active;
|
||||
|
||||
{
|
||||
uiLayoutItemPanelHeader *header_litem = MEM_cnew<uiLayoutItemPanelHeader>(__func__);
|
||||
uiLayout *litem = &header_litem->litem;
|
||||
ui_litem_init_from_parent(litem, layout, false);
|
||||
litem->item.type = ITEM_LAYOUT_PANEL_HEADER;
|
||||
uiLayoutItemPanelHeader *header_litem = MEM_cnew<uiLayoutItemPanelHeader>(__func__);
|
||||
uiLayout *litem = &header_litem->litem;
|
||||
ui_litem_init_from_parent(litem, layout, false);
|
||||
litem->item.type = ITEM_LAYOUT_PANEL_HEADER;
|
||||
|
||||
header_litem->open_prop_owner = *open_prop_owner;
|
||||
STRNCPY(header_litem->open_prop_name, open_prop_name);
|
||||
header_litem->open_prop_owner = *open_prop_owner;
|
||||
STRNCPY(header_litem->open_prop_name, open_prop_name);
|
||||
|
||||
UI_block_layout_set_current(layout->root->block, litem);
|
||||
uiLayout *row = uiLayoutRow(litem, true);
|
||||
uiBlock *block = uiLayoutGetBlock(row);
|
||||
const int icon = is_open ? ICON_DOWNARROW_HLT : ICON_RIGHTARROW;
|
||||
const int width = ui_text_icon_width(layout, name, icon, false);
|
||||
uiDefIconTextBut(block,
|
||||
UI_BTYPE_LABEL,
|
||||
0,
|
||||
icon,
|
||||
name,
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
UI_UNIT_Y * 1.2f,
|
||||
nullptr,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
"");
|
||||
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
const int icon = is_open ? ICON_DOWNARROW_HLT : ICON_RIGHTARROW;
|
||||
const int width = ui_text_icon_width(layout, name, icon, false);
|
||||
uiDefIconTextBut(block,
|
||||
UI_BTYPE_LABEL,
|
||||
0,
|
||||
icon,
|
||||
name,
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
UI_UNIT_Y * 1.2f,
|
||||
nullptr,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
"");
|
||||
return row;
|
||||
}
|
||||
|
||||
uiLayout *uiLayoutPanel(const bContext *C,
|
||||
uiLayout *layout,
|
||||
const char *name,
|
||||
PointerRNA *open_prop_owner,
|
||||
const char *open_prop_name,
|
||||
bool create_header)
|
||||
{
|
||||
const ARegion *region = CTX_wm_region(C);
|
||||
|
||||
const bool is_real_open = RNA_boolean_get(open_prop_owner, open_prop_name);
|
||||
const bool search_filter_active = region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE;
|
||||
const bool is_open = is_real_open || search_filter_active;
|
||||
|
||||
if (create_header) {
|
||||
uiLayoutPanelHeader(C, layout, name, open_prop_owner, open_prop_name);
|
||||
}
|
||||
|
||||
if (!is_open) {
|
||||
|
|
|
@ -2371,20 +2371,22 @@ static wmOperator *minimal_operator_create(wmOperatorType *ot, PointerRNA *prope
|
|||
return op;
|
||||
}
|
||||
|
||||
void draw_export_controls(uiLayout *layout, PointerRNA *properties, int index)
|
||||
void draw_export_controls(uiLayout *layout, int index)
|
||||
{
|
||||
uiLayout *box = uiLayoutBox(layout);
|
||||
uiLayout *row = uiLayoutRow(box, true);
|
||||
uiItemR(row, properties, "filepath", UI_ITEM_NONE, nullptr, ICON_NONE);
|
||||
uiItemS(row);
|
||||
uiItemIntO(row, "", ICON_EXPORT, "COLLECTION_OT_io_handler_export", "index", index);
|
||||
uiItemIntO(row, "", ICON_X, "COLLECTION_OT_io_handler_remove", "index", index);
|
||||
uiItemS(layout);
|
||||
uiItemIntO(layout, "", ICON_EXPORT, "COLLECTION_OT_io_handler_export", "index", index);
|
||||
uiItemIntO(layout, "", ICON_X, "COLLECTION_OT_io_handler_remove", "index", index);
|
||||
}
|
||||
|
||||
void draw_export_properties(bContext *C, uiLayout *layout, IOHandlerData *data)
|
||||
void draw_export_properties(bContext *C,
|
||||
uiLayout *layout,
|
||||
PointerRNA *properties,
|
||||
IOHandlerData *data)
|
||||
{
|
||||
wmOperator *const op = data->runtime.op;
|
||||
uiLayout *box = uiLayoutBox(layout);
|
||||
uiItemR(box, properties, "filepath", UI_ITEM_NONE, nullptr, ICON_NONE);
|
||||
|
||||
wmOperator *const op = data->runtime.op;
|
||||
op->layout = layout;
|
||||
op->type->ui(C, op);
|
||||
op->layout = nullptr;
|
||||
|
@ -2417,9 +2419,14 @@ void uiTemplateCollectionExporters(uiLayout *layout, bContext *C)
|
|||
data->runtime.op = minimal_operator_create(ot, &properties);
|
||||
}
|
||||
|
||||
if (uiLayout *panel_layout = uiLayoutPanel(C, layout, fh->label, &io_handler_ptr, "is_open")) {
|
||||
draw_export_controls(panel_layout, &properties, index);
|
||||
draw_export_properties(C, panel_layout, data);
|
||||
uiLayout *header_layout = uiLayoutPanelHeader(
|
||||
C, layout, fh->label, &io_handler_ptr, "is_open");
|
||||
draw_export_controls(header_layout, index);
|
||||
|
||||
if (uiLayout *panel_layout = uiLayoutPanel(
|
||||
C, layout, nullptr, &io_handler_ptr, "is_open", false))
|
||||
{
|
||||
draw_export_properties(C, panel_layout, &properties, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1906,7 +1906,7 @@ static void draw_interface_panel_content(const bContext *C,
|
|||
PointerRNA panel_ptr = RNA_pointer_create(
|
||||
modifier_ptr->owner_id, &RNA_NodesModifierPanel, panel);
|
||||
if (uiLayout *panel_layout = uiLayoutPanel(
|
||||
C, layout, sub_interface_panel.name, &panel_ptr, "is_open"))
|
||||
C, layout, sub_interface_panel.name, &panel_ptr, "is_open", true))
|
||||
{
|
||||
draw_interface_panel_content(
|
||||
C, panel_layout, modifier_ptr, nmd, sub_interface_panel, next_input_index);
|
||||
|
@ -2066,12 +2066,12 @@ static void panel_draw(const bContext *C, Panel *panel)
|
|||
modifier_panel_end(layout, ptr);
|
||||
|
||||
if (uiLayout *panel_layout = uiLayoutPanel(
|
||||
C, layout, TIP_("Output Attributes"), ptr, "open_output_attributes_panel"))
|
||||
C, layout, TIP_("Output Attributes"), ptr, "open_output_attributes_panel", true))
|
||||
{
|
||||
draw_output_attributes_panel(C, panel_layout, *nmd, ptr);
|
||||
}
|
||||
if (uiLayout *panel_layout = uiLayoutPanel(
|
||||
C, layout, TIP_("Internal Dependencies"), ptr, "open_internal_dependencies_panel"))
|
||||
C, layout, TIP_("Internal Dependencies"), ptr, "open_internal_dependencies_panel", true))
|
||||
{
|
||||
draw_internal_dependencies_panel(panel_layout, ptr, *nmd);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue