Refactor: UI: Add uiLayout fixed_size, red_alert, root_panel, search_weight and width methods

This replaces API for accessing the uiLayout fixed_size,
red_alert, root_panel, search_weight and width properties
with methods, following uiLayout refactors and the
Python API naming

Pull Request: https://projects.blender.org/blender/blender/pulls/140673
This commit is contained in:
Guillermo Venegas
2025-06-23 06:55:01 +02:00
committed by Pratik Borhade
parent e5ddffd5d1
commit cc5ba71114
22 changed files with 92 additions and 92 deletions

View File

@@ -244,7 +244,7 @@ static void popover_panel_draw(const bContext *C, Panel *panel)
uiLayout *row = &layout->row(false);
uiLayout *catalogs_col = &row->column(false);
catalogs_col->ui_units_x_set(LEFT_COL_WIDTH_UNITS);
uiLayoutSetFixedSize(catalogs_col, true);
catalogs_col->fixed_size_set(true);
library_selector_draw(C, catalogs_col, *shelf);
catalog_tree_draw(*C, *catalogs_col, *shelf);
@@ -262,7 +262,7 @@ static void popover_panel_draw(const bContext *C, Panel *panel)
uiLayout *asset_view_col = &right_col->column(false);
BLI_assert((layout_width_units - LEFT_COL_WIDTH_UNITS) > 0);
asset_view_col->ui_units_x_set(layout_width_units - LEFT_COL_WIDTH_UNITS);
uiLayoutSetFixedSize(asset_view_col, true);
asset_view_col->fixed_size_set(true);
build_asset_view(*asset_view_col, shelf->settings.asset_library_reference, *shelf, *C);
}

View File

@@ -765,7 +765,7 @@ static uiBlock *wm_block_insert_unicode_create(bContext *C, ARegion *region, voi
UI_but_flag_enable(confirm, UI_BUT_ACTIVE_DEFAULT);
int bounds_offset[2];
bounds_offset[0] = uiLayoutGetWidth(layout) * -0.2f;
bounds_offset[0] = layout->width() * -0.2f;
bounds_offset[1] = UI_UNIT_Y * 2.5;
UI_block_bounds_set_popup(block, 7 * UI_SCALE_FAC, bounds_offset);

View File

@@ -159,16 +159,31 @@ struct uiLayout : uiItem {
blender::ui::EmbossType emboss() const;
void emboss_set(blender::ui::EmbossType emboss);
bool fixed_size() const;
void fixed_size_set(bool fixed_size);
wmOperatorCallContext operator_context() const;
/** Sets the default call context for new operator buttons added in any #root_ sub-layout. */
void operator_context_set(wmOperatorCallContext opcontext);
bool red_alert() const;
/**
* When set to true new items added in the layout are highlighted with the error state
* color #TH_REDALERT.
*/
void red_alert_set(bool red_alert);
Panel *root_panel() const;
float scale_x() const;
void scale_x_set(float scale);
float scale_y() const;
void scale_y_set(float scale);
float search_weight() const;
void search_weight_set(float weight);
float ui_units_x() const;
/** Sets a fixed width size for this layout. */
void ui_units_x_set(float width);
@@ -177,6 +192,8 @@ struct uiLayout : uiItem {
/** Sets a fixed height size for this layout. */
void ui_units_y_set(float height);
int width() const;
/** Sub-layout items. */
uiLayout &absolute(bool align);
@@ -469,6 +486,24 @@ inline void uiLayout::enabled_set(bool enabled)
enabled_ = enabled;
}
inline bool uiLayout::red_alert() const
{
return redalert_;
}
inline void uiLayout::red_alert_set(bool red_alert)
{
redalert_ = red_alert;
}
inline float uiLayout::search_weight() const
{
return search_weight_;
}
inline void uiLayout::search_weight_set(float weight)
{
search_weight_ = weight;
}
inline float uiLayout::scale_x() const
{
return scale_[0];
@@ -505,6 +540,11 @@ inline void uiLayout::ui_units_y_set(float height)
units_[1] = height;
};
inline int uiLayout::width() const
{
return this->w_;
}
enum {
UI_LAYOUT_HORIZONTAL = 0,
UI_LAYOUT_VERTICAL = 1,
@@ -619,20 +659,11 @@ void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout);
*/
void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout);
void uiLayoutSetRedAlert(uiLayout *layout, bool redalert);
void uiLayoutSetFixedSize(uiLayout *layout, bool fixed_size);
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep);
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep);
int uiLayoutGetLocalDir(const uiLayout *layout);
void uiLayoutSetSearchWeight(uiLayout *layout, float weight);
bool uiLayoutGetRedAlert(uiLayout *layout);
bool uiLayoutGetFixedSize(uiLayout *layout);
int uiLayoutGetWidth(uiLayout *layout);
bool uiLayoutGetPropSep(uiLayout *layout);
bool uiLayoutGetPropDecorate(uiLayout *layout);
Panel *uiLayoutGetRootPanel(uiLayout *layout);
float uiLayoutGetSearchWeight(uiLayout *layout);
int uiLayoutListItemPaddingWidth();
void uiLayoutListItemAddPadding(uiLayout *layout);

View File

@@ -1061,7 +1061,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
/* Favorites Menu */
if (ui_but_is_user_menu_compatible(C, but)) {
uiBlock *block = layout->block();
const int w = uiLayoutGetWidth(layout);
const int w = layout->width();
bool item_found = false;
uint um_array_len;
@@ -1128,7 +1128,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
const char *idname = shortcut_get_operator_property(C, but, &prop);
if (idname != nullptr) {
uiBlock *block = layout->block();
const int w = uiLayoutGetWidth(layout);
const int w = layout->width();
/* We want to know if this op has a shortcut, be it hotkey or not. */
wmKeyMap *km;
@@ -1145,7 +1145,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
"Change Shortcut",
0,
0,
uiLayoutGetWidth(layout),
layout->width(),
UI_UNIT_Y,
"");
#endif

View File

@@ -4038,7 +4038,7 @@ static void ui_litem_estimate_panel_header(uiLayout *litem)
static void ui_litem_layout_panel_header(uiLayout *litem)
{
uiLayoutItemPanelHeader *header_litem = static_cast<uiLayoutItemPanelHeader *>(litem);
Panel *panel = litem->block()->panel;
Panel *panel = litem->root_panel();
BLI_assert(litem->items_.size() == 1);
uiItem *item = litem->items_.first();
@@ -4062,7 +4062,7 @@ static void ui_litem_estimate_panel_body(uiLayout *litem)
static void ui_litem_layout_panel_body(uiLayout *litem)
{
Panel *panel = litem->block()->panel;
Panel *panel = litem->root_panel();
ui_litem_layout_column(litem, false, false);
const float offset = UI_style_get_dpi()->panelspace;
panel->runtime->layout_panels.bodies.append({
@@ -4887,7 +4887,7 @@ uiLayout *uiLayout::panel_prop(const bContext *C,
PanelLayout uiLayout::panel(const bContext *C, const StringRef idname, const bool default_closed)
{
Panel *root_panel = uiLayoutGetRootPanel(this);
Panel *root_panel = this->root_panel();
BLI_assert(root_panel != nullptr);
LayoutPanelState *state = BKE_panel_layout_panel_state_ensure(
@@ -5101,11 +5101,6 @@ uiLayout &uiLayout::split(float percentage, bool align)
return *split;
}
void uiLayoutSetRedAlert(uiLayout *layout, bool redalert)
{
layout->redalert_ = redalert;
}
void uiLayout::emboss_set(blender::ui::EmbossType emboss)
{
emboss_ = emboss;
@@ -5131,29 +5126,9 @@ void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
SET_FLAG_FROM_TEST(layout->flag_, is_sep, uiItemInternalFlag::PropDecorate);
}
void uiLayoutSetSearchWeight(uiLayout *layout, const float weight)
Panel *uiLayout::root_panel() const
{
layout->search_weight_ = weight;
}
float uiLayoutGetSearchWeight(uiLayout *layout)
{
return layout->search_weight_;
}
Panel *uiLayoutGetRootPanel(uiLayout *layout)
{
return layout->block()->panel;
}
bool uiLayoutGetRedAlert(uiLayout *layout)
{
return layout->redalert_;
}
int uiLayoutGetWidth(uiLayout *layout)
{
return layout->w_;
return this->block()->panel;
}
blender::ui::EmbossType uiLayout::emboss() const
@@ -5173,7 +5148,7 @@ void uiLayoutListItemAddPadding(uiLayout *layout)
{
uiBlock *block = layout->block();
uiLayout *row = &layout->row(true);
uiLayoutSetFixedSize(row, true);
row->fixed_size_set(true);
uiDefBut(
block, UI_BTYPE_SEPR, 0, "", 0, 0, uiLayoutListItemPaddingWidth(), 0, nullptr, 0.0, 0.0, "");
@@ -5767,19 +5742,14 @@ bool ui_layout_replace_but_ptr(uiLayout *layout, const void *old_but_ptr, uiBut
return true;
}
void uiLayoutSetFixedSize(uiLayout *layout, bool fixed_size)
void uiLayout::fixed_size_set(bool fixed_size)
{
if (fixed_size) {
layout->flag_ |= uiItemInternalFlag::FixedSize;
}
else {
layout->flag_ &= ~uiItemInternalFlag::FixedSize;
}
SET_FLAG_FROM_TEST(flag_, fixed_size, uiItemInternalFlag::FixedSize);
}
bool uiLayoutGetFixedSize(uiLayout *layout)
bool uiLayout::fixed_size() const
{
return bool(layout->flag_ & uiItemInternalFlag::FixedSize);
return bool(flag_ & uiItemInternalFlag::FixedSize);
}
void uiLayout::operator_context_set(wmOperatorCallContext opcontext)

View File

@@ -238,7 +238,7 @@ void uiTemplatePalette(uiLayout *layout,
PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
uiBut *but = nullptr;
const int cols_per_row = std::max(uiLayoutGetWidth(layout) / UI_UNIT_X, 1);
const int cols_per_row = std::max(layout->width() / UI_UNIT_X, 1);
if (!prop) {
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname.c_str());

View File

@@ -116,7 +116,7 @@ static void draw_constraint_header(uiLayout *layout, Object *ob, bConstraint *co
/* Constraint type icon. */
uiLayout *sub = &layout->row(false);
sub->emboss_set(blender::ui::EmbossType::Emboss);
uiLayoutSetRedAlert(sub, (con->flag & CONSTRAINT_DISABLE));
sub->red_alert_set(con->flag & CONSTRAINT_DISABLE);
sub->label("", RNA_struct_ui_icon(ptr.type));
UI_block_emboss_set(block, blender::ui::EmbossType::Emboss);

View File

@@ -568,7 +568,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
but_func_argN_copy<RNAUpdateCb>);
/* Curve itself. */
const int size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
const int size = max_ii(layout->width(), UI_UNIT_X);
row = &layout->row(false);
uiButCurveMapping *curve_but = (uiButCurveMapping *)uiDefBut(
block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, "");

View File

@@ -375,7 +375,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, const
but_func_argN_copy<RNAUpdateCb>);
/* The path itself */
int path_width = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
int path_width = max_ii(layout->width(), UI_UNIT_X);
path_width = min_ii(path_width, int(16.0f * UI_UNIT_X));
const int path_height = path_width;
layout->row(false);

View File

@@ -989,8 +989,7 @@ static void ui_template_list_layout_draw(const bContext *C,
const int size_x = UI_preview_tile_size_x();
const int size_y = show_names ? UI_preview_tile_size_y() : UI_preview_tile_size_y_no_label();
const int cols_per_row = std::max(int((uiLayoutGetWidth(box) - V2D_SCROLL_WIDTH) / size_x),
1);
const int cols_per_row = std::max(int((box->width() - V2D_SCROLL_WIDTH) / size_x), 1);
uiLayout *grid = &row->grid_flow(true, cols_per_row, true, true, true);
TemplateListLayoutDrawData adjusted_layout_data = *layout_data;

View File

@@ -386,7 +386,7 @@ void GridViewLayoutBuilder::build_grid_tile(const bContext &C,
AbstractGridViewItem &item) const
{
uiLayout *overlap = &grid_layout.overlap();
uiLayoutSetFixedSize(overlap, true);
overlap->fixed_size_set(true);
item.add_grid_tile_button(block_);
item.build_grid_tile(C, overlap->row(false));
@@ -406,7 +406,7 @@ void GridViewLayoutBuilder::build_from_view(const bContext &C,
* the root level and inherits its width. Might need a more reliable method. */
const int guessed_layout_width = (parent_layout->ui_units_x() > 0) ?
parent_layout->ui_units_x() * UI_UNIT_X :
uiLayoutGetWidth(parent_layout);
parent_layout->width();
const int cols_per_row = std::max(guessed_layout_width / style.tile_width, 1);
const AbstractGridViewItem *search_highlight_item = dynamic_cast<const AbstractGridViewItem *>(

View File

@@ -486,7 +486,7 @@ void AbstractTreeViewItem::add_indent(uiLayout &row) const
{
uiBlock *block = row.block();
uiLayout *subrow = &row.row(true);
uiLayoutSetFixedSize(subrow, true);
subrow->fixed_size_set(true);
uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, this->indent_width(), 0, nullptr, 0.0, 0.0, "");
@@ -901,7 +901,7 @@ void TreeViewLayoutBuilder::build_row(AbstractTreeViewItem &item) const
uiLayout &prev_layout = current_layout();
const int width = uiLayoutGetWidth(&prev_layout);
const int width = prev_layout.width();
if (width < int(40 * UI_SCALE_FAC)) {
return;
}

View File

@@ -3614,7 +3614,7 @@ void ED_region_header_layout(const bContext *C, ARegion *region)
}
/* for view2d */
xco = uiLayoutGetWidth(layout);
xco = layout->width();
maxco = std::max(xco, maxco);
}

View File

@@ -112,7 +112,7 @@ static void file_panel_execution_cancel_button(uiLayout *layout)
{
uiLayout *row = &layout->row(false);
row->scale_x_set(0.8f);
uiLayoutSetFixedSize(row, true);
row->fixed_size_set(true);
row->op("FILE_OT_cancel", IFACE_("Cancel"), ICON_NONE);
}
@@ -120,7 +120,7 @@ static void file_panel_execution_execute_button(uiLayout *layout, const char *ti
{
uiLayout *row = &layout->row(false);
row->scale_x_set(0.8f);
uiLayoutSetFixedSize(row, true);
row->fixed_size_set(true);
/* Just a display hint. */
row->active_default_set(true);
row->op("FILE_OT_execute", title, ICON_NONE);

View File

@@ -751,7 +751,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa
/* Target ID */
row = &layout->row(false);
uiLayoutSetRedAlert(row, ((dtar->flag & DTAR_FLAG_INVALID) && !dtar->id));
row->red_alert_set((dtar->flag & DTAR_FLAG_INVALID) && !dtar->id);
uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:"));
/* Target Property */
@@ -761,7 +761,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa
/* rna path */
col = &layout->column(true);
uiLayoutSetRedAlert(col, (dtar->flag & (DTAR_FLAG_INVALID | DTAR_FLAG_FALLBACK_USED)));
col->red_alert_set(dtar->flag & (DTAR_FLAG_INVALID | DTAR_FLAG_FALLBACK_USED));
uiTemplatePathBuilder(col,
&dtar_ptr,
"data_path",
@@ -789,7 +789,7 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar *
/* Object 1 */
col = &layout->column(true);
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
col->red_alert_set(dtar->flag & DTAR_FLAG_INVALID); /* XXX: per field... */
col->prop(&dtar_ptr, "id", UI_ITEM_NONE, IFACE_("Object 1"), ICON_NONE);
if (dtar->id && GS(dtar->id->name) == ID_OB && ob1->pose) {
@@ -799,7 +799,7 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar *
/* Object 2 */
col = &layout->column(true);
uiLayoutSetRedAlert(col, (dtar2->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
col->red_alert_set(dtar2->flag & DTAR_FLAG_INVALID); /* XXX: per field... */
col->prop(&dtar2_ptr, "id", UI_ITEM_NONE, IFACE_("Object 2"), ICON_NONE);
if (dtar2->id && GS(dtar2->id->name) == ID_OB && ob2->pose) {
@@ -823,7 +823,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
/* Object 1 */
col = &layout->column(true);
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
col->red_alert_set(dtar->flag & DTAR_FLAG_INVALID); /* XXX: per field... */
col->prop(&dtar_ptr, "id", UI_ITEM_NONE, IFACE_("Object 1"), ICON_NONE);
if (dtar->id && GS(dtar->id->name) == ID_OB && ob1->pose) {
@@ -833,13 +833,13 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
}
/* we can clear it again now - it's only needed when creating the ID/Bone fields */
uiLayoutSetRedAlert(col, false);
col->red_alert_set(false);
col->prop(&dtar_ptr, "transform_space", UI_ITEM_NONE, std::nullopt, ICON_NONE);
/* Object 2 */
col = &layout->column(true);
uiLayoutSetRedAlert(col, (dtar2->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
col->red_alert_set(dtar2->flag & DTAR_FLAG_INVALID); /* XXX: per field... */
col->prop(&dtar2_ptr, "id", UI_ITEM_NONE, IFACE_("Object 2"), ICON_NONE);
if (dtar2->id && GS(dtar2->id->name) == ID_OB && ob2->pose) {
@@ -849,7 +849,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
}
/* we can clear it again now - it's only needed when creating the ID/Bone fields */
uiLayoutSetRedAlert(col, false);
col->red_alert_set(false);
col->prop(&dtar2_ptr, "transform_space", UI_ITEM_NONE, std::nullopt, ICON_NONE);
}
@@ -866,7 +866,7 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar
/* properties */
col = &layout->column(true);
uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */
col->red_alert_set(dtar->flag & DTAR_FLAG_INVALID); /* XXX: per field... */
col->prop(&dtar_ptr, "id", UI_ITEM_NONE, IFACE_("Object"), ICON_NONE);
if (dtar->id && GS(dtar->id->name) == ID_OB && ob->pose) {
@@ -907,7 +907,7 @@ static void graph_panel_driverVar__contextProp(uiLayout *layout, ID *id, DriverV
/* Target Path */
{
uiLayout *col = &layout->column(true);
uiLayoutSetRedAlert(col, (dtar->flag & (DTAR_FLAG_INVALID | DTAR_FLAG_FALLBACK_USED)));
col->red_alert_set(dtar->flag & (DTAR_FLAG_INVALID | DTAR_FLAG_FALLBACK_USED));
uiTemplatePathBuilder(col,
&dtar_ptr,
"data_path",

View File

@@ -1394,12 +1394,12 @@ static void rna_UILayout_activate_init_set(PointerRNA *ptr, bool value)
static bool rna_UILayout_alert_get(PointerRNA *ptr)
{
return uiLayoutGetRedAlert(static_cast<uiLayout *>(ptr->data));
return static_cast<uiLayout *>(ptr->data)->red_alert();
}
static void rna_UILayout_alert_set(PointerRNA *ptr, bool value)
{
uiLayoutSetRedAlert(static_cast<uiLayout *>(ptr->data), value);
static_cast<uiLayout *>(ptr->data)->red_alert_set(value);
}
static void rna_UILayout_op_context_set(PointerRNA *ptr, int value)
@@ -1425,12 +1425,12 @@ static void rna_UILayout_enabled_set(PointerRNA *ptr, bool value)
# if 0
static int rna_UILayout_red_alert_get(PointerRNA *ptr)
{
return uiLayoutGetRedAlert(static_cast<uiLayout *>(ptr->data));
return static_cast<uiLayout *>(ptr->data)->red_alert();
}
static void rna_UILayout_red_alert_set(PointerRNA *ptr, bool value)
{
uiLayoutSetRedAlert(static_cast<uiLayout *>(ptr->data), value);
static_cast<uiLayout *>(ptr->data)->red_alert_set(value);
}
# endif

View File

@@ -374,12 +374,12 @@ static PointerRNA rna_uiItemO(uiLayout *layout,
flag |= UI_ITEM_O_DEPRESS;
}
const float prev_weight = uiLayoutGetSearchWeight(layout);
uiLayoutSetSearchWeight(layout, search_weight);
const float prev_weight = layout->search_weight();
layout->search_weight_set(search_weight);
PointerRNA opptr = layout->op(ot, text, icon, layout->operator_context(), flag);
uiLayoutSetSearchWeight(layout, prev_weight);
layout->search_weight_set(prev_weight);
return opptr;
}
@@ -866,7 +866,7 @@ void rna_uiLayoutPanelProp(uiLayout *layout,
uiLayout **r_layout_header,
uiLayout **r_layout_body)
{
Panel *panel = uiLayoutGetRootPanel(layout);
Panel *panel = layout->root_panel();
if (panel == nullptr) {
BKE_reportf(reports, RPT_ERROR, "Layout panels can not be used in this context");
*r_layout_header = nullptr;
@@ -887,7 +887,7 @@ void rna_uiLayoutPanel(uiLayout *layout,
uiLayout **r_layout_header,
uiLayout **r_layout_body)
{
Panel *panel = uiLayoutGetRootPanel(layout);
Panel *panel = layout->root_panel();
if (panel == nullptr) {
BKE_reportf(reports, RPT_ERROR, "Layout panels can not be used in this context");
*r_layout_header = nullptr;

View File

@@ -346,7 +346,7 @@ static void axis_mapping_panel_draw(const bContext * /*C*/, Panel *panel)
uiLayoutSetPropSep(layout, true);
col = &layout->column(true);
uiLayoutSetRedAlert(col, RNA_enum_get(ptr, "forward_axis") == RNA_enum_get(ptr, "up_axis"));
col->red_alert_set(RNA_enum_get(ptr, "forward_axis") == RNA_enum_get(ptr, "up_axis"));
col->prop(ptr, "forward_axis", UI_ITEM_NONE, std::nullopt, ICON_NONE);
col->prop(ptr, "up_axis", UI_ITEM_NONE, std::nullopt, ICON_NONE);

View File

@@ -325,7 +325,7 @@ static void modifier_panel_header(const bContext *C, Panel *panel)
sub = &layout->row(true);
sub->emboss_set(blender::ui::EmbossType::None);
if (mti->is_disabled && mti->is_disabled(scene, md, false)) {
uiLayoutSetRedAlert(sub, true);
sub->red_alert_set(true);
}
PointerRNA op_ptr = sub->op("OBJECT_OT_modifier_set_active", "", RNA_struct_ui_icon(ptr->type));
RNA_string_set(&op_ptr, "modifier", md->name);

View File

@@ -984,7 +984,7 @@ void draw_geometry_nodes_operator_redo_ui(const bContext &C,
DrawGroupInputsContext ctx{
C, &tree, tree_log, nodes::build_properties_vector_set(op.properties), op.ptr, &bmain_ptr};
ctx.panel_open_property_fn = [&](const bNodeTreeInterfacePanel &io_panel) -> PanelOpenProperty {
Panel *root_panel = uiLayoutGetRootPanel(&layout);
Panel *root_panel = layout.root_panel();
LayoutPanelState *state = BKE_panel_layout_panel_state_ensure(
root_panel,
"node_operator_panel_" + std::to_string(io_panel.identifier),

View File

@@ -169,7 +169,7 @@ static void shaderfx_panel_header(const bContext * /*C*/, Panel *panel)
/* Effect type icon. */
uiLayout *row = &layout->row(false);
if (fxti->is_disabled && fxti->is_disabled(fx, false)) {
uiLayoutSetRedAlert(row, true);
row->red_alert_set(true);
}
row->label("", RNA_struct_ui_icon(ptr->type));

View File

@@ -1659,7 +1659,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *user_
if (data->position == WM_POPUP_POSITION_MOUSE) {
const float button_center_x = windows_layout ? -0.4f : -0.90f;
const float button_center_y = small ? 2.0f : 3.1f;
const int bounds_offset[2] = {int(button_center_x * uiLayoutGetWidth(layout)),
const int bounds_offset[2] = {int(button_center_x * layout->width()),
int(button_center_y * UI_UNIT_X)};
UI_block_bounds_set_popup(block, padding, bounds_offset);
}