Refactor: UI: Replace uiLayoutSetEmboss and uiLayoutGetEmboss with uiLayout methods

This converts `uiLayoutSetEmboss` and `uiLayoutGetEmboss` function APIs
to objects methods following recent `uiLayout` refactors.
Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/139811
This commit is contained in:
Guillermo Venegas
2025-06-05 06:00:02 +02:00
committed by Pratik Borhade
parent 8daea1d0b2
commit 25873ccf53
18 changed files with 40 additions and 37 deletions

View File

@@ -319,7 +319,7 @@ static void fmodifier_panel_header(const bContext *C, Panel *panel)
/* Right align. */
sub = &layout->row(true);
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT);
uiLayoutSetEmboss(sub, blender::ui::EmbossType::None);
sub->emboss_set(blender::ui::EmbossType::None);
/* 'Mute' button. */
sub->prop(ptr, "mute", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);

View File

@@ -139,7 +139,7 @@ class AssetCatalogSelectorTree : public ui::AbstractTreeView {
AssetCatalogSelectorTree &tree = dynamic_cast<AssetCatalogSelectorTree &>(get_tree_view());
uiBlock *block = uiLayoutGetBlock(&row);
uiLayoutSetEmboss(&row, blender::ui::EmbossType::Emboss);
row.emboss_set(blender::ui::EmbossType::Emboss);
uiLayout *subrow = &row.row(false);
uiLayoutSetActive(subrow, catalog_path_enabled_);

View File

@@ -104,6 +104,11 @@ struct uiLayout : uiItem {
float search_weight_;
public:
blender::ui::EmbossType emboss() const;
void emboss_set(blender::ui::EmbossType emboss);
/** Sub-layout items. */
uiLayout &absolute(bool align);
uiBlock *absolute_block();
@@ -478,7 +483,6 @@ void uiLayoutSetScaleX(uiLayout *layout, float scale);
void uiLayoutSetScaleY(uiLayout *layout, float scale);
void uiLayoutSetUnitsX(uiLayout *layout, float unit);
void uiLayoutSetUnitsY(uiLayout *layout, float unit);
void uiLayoutSetEmboss(uiLayout *layout, blender::ui::EmbossType emboss);
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep);
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep);
int uiLayoutGetLocalDir(const uiLayout *layout);
@@ -498,7 +502,6 @@ float uiLayoutGetScaleX(uiLayout *layout);
float uiLayoutGetScaleY(uiLayout *layout);
float uiLayoutGetUnitsX(uiLayout *layout);
float uiLayoutGetUnitsY(uiLayout *layout);
blender::ui::EmbossType uiLayoutGetEmboss(uiLayout *layout);
bool uiLayoutGetPropSep(uiLayout *layout);
bool uiLayoutGetPropDecorate(uiLayout *layout);
Panel *uiLayoutGetRootPanel(uiLayout *layout);

View File

@@ -5156,9 +5156,9 @@ void uiLayoutSetUnitsY(uiLayout *layout, float unit)
layout->units_[1] = unit;
}
void uiLayoutSetEmboss(uiLayout *layout, blender::ui::EmbossType emboss)
void uiLayout::emboss_set(blender::ui::EmbossType emboss)
{
layout->emboss_ = emboss;
emboss_ = emboss;
}
bool uiLayoutGetPropSep(uiLayout *layout)
@@ -5256,12 +5256,12 @@ float uiLayoutGetUnitsY(uiLayout *layout)
return layout->units_[1];
}
blender::ui::EmbossType uiLayoutGetEmboss(uiLayout *layout)
blender::ui::EmbossType uiLayout::emboss() const
{
if (layout->emboss_ == blender::ui::EmbossType::Undefined) {
return layout->root_->block->emboss;
if (emboss_ == blender::ui::EmbossType::Undefined) {
return root_->block->emboss;
}
return layout->emboss_;
return emboss_;
}
int uiLayoutListItemPaddingWidth()

View File

@@ -115,7 +115,7 @@ static void draw_constraint_header(uiLayout *layout, Object *ob, bConstraint *co
/* Constraint type icon. */
uiLayout *sub = &layout->row(false);
uiLayoutSetEmboss(sub, blender::ui::EmbossType::Emboss);
sub->emboss_set(blender::ui::EmbossType::Emboss);
uiLayoutSetRedAlert(sub, (con->flag & CONSTRAINT_DISABLE));
sub->label("", RNA_struct_ui_icon(ptr.type));
@@ -133,7 +133,7 @@ static void draw_constraint_header(uiLayout *layout, Object *ob, bConstraint *co
/* Close 'button' - emboss calls here disable drawing of 'button' behind X */
sub = &row->row(false);
uiLayoutSetEmboss(sub, blender::ui::EmbossType::None);
sub->emboss_set(blender::ui::EmbossType::None);
uiLayoutSetOperatorContext(sub, WM_OP_INVOKE_DEFAULT);
sub->op("CONSTRAINT_OT_delete", "", ICON_X);

View File

@@ -109,7 +109,7 @@ class NodeSocketViewItem : public BasicTreeViewItem {
uiLayout *input_socket_layout = &row.row(true);
if (socket_.flag & NODE_INTERFACE_SOCKET_INPUT) {
/* XXX Socket template only draws in embossed layouts (Julian). */
uiLayoutSetEmboss(input_socket_layout, blender::ui::EmbossType::Emboss);
input_socket_layout->emboss_set(blender::ui::EmbossType::Emboss);
/* Context is not used by the template function. */
uiTemplateNodeSocket(input_socket_layout, /*C*/ nullptr, socket_.socket_color());
}
@@ -123,7 +123,7 @@ class NodeSocketViewItem : public BasicTreeViewItem {
uiLayout *output_socket_layout = &row.row(true);
if (socket_.flag & NODE_INTERFACE_SOCKET_OUTPUT) {
/* XXX Socket template only draws in embossed layouts (Julian). */
uiLayoutSetEmboss(output_socket_layout, blender::ui::EmbossType::Emboss);
output_socket_layout->emboss_set(blender::ui::EmbossType::Emboss);
/* Context is not used by the template function. */
uiTemplateNodeSocket(output_socket_layout, /*C*/ nullptr, socket_.socket_color());
}
@@ -197,7 +197,7 @@ class NodePanelViewItem : public BasicTreeViewItem {
if (toggle_ != nullptr) {
uiLayout *toggle_layout = &row.row(true);
/* XXX Socket template only draws in embossed layouts (Julian). */
uiLayoutSetEmboss(toggle_layout, blender::ui::EmbossType::Emboss);
toggle_layout->emboss_set(blender::ui::EmbossType::Emboss);
/* Context is not used by the template function. */
uiTemplateNodeSocket(toggle_layout, /*C*/ nullptr, toggle_->socket_color());
}

View File

@@ -350,7 +350,7 @@ static void draw_export_controls(
layout->label(label, ICON_NONE);
if (valid) {
uiLayout *row = &layout->row(false);
uiLayoutSetEmboss(row, blender::ui::EmbossType::None);
row->emboss_set(blender::ui::EmbossType::None);
uiItemPopoverPanel(row, C, "WM_PT_operator_presets", "", ICON_PRESET);
PointerRNA op_ptr = row->op("COLLECTION_OT_exporter_export", "", ICON_EXPORT);
RNA_int_set(&op_ptr, "index", index);
@@ -403,7 +403,7 @@ static void draw_exporter_item(uiList * /*ui_list*/,
int /*flt_flag*/)
{
uiLayout *row = &layout->row(false);
uiLayoutSetEmboss(row, blender::ui::EmbossType::None);
row->emboss_set(blender::ui::EmbossType::None);
row->prop(itemptr, "name", UI_ITEM_NONE, "", ICON_NONE);
}

View File

@@ -420,7 +420,7 @@ void uiTemplateStatusInfo(uiLayout *layout, bContext *C)
row->label("|", ICON_NONE);
row->separator(-0.5f);
}
uiLayoutSetEmboss(row, blender::ui::EmbossType::None);
row->emboss_set(blender::ui::EmbossType::None);
/* This operator also works fine for blocked extensions. */
row->op("EXTENSIONS_OT_userpref_show_for_update", "", ICON_ERROR);
uiBut *but = uiLayoutGetBlock(layout)->buttons.last().get();
@@ -446,7 +446,7 @@ void uiTemplateStatusInfo(uiLayout *layout, bContext *C)
row->label("", ICON_INTERNET_OFFLINE);
}
else {
uiLayoutSetEmboss(row, blender::ui::EmbossType::None);
row->emboss_set(blender::ui::EmbossType::None);
row->op("EXTENSIONS_OT_userpref_show_online", "", ICON_INTERNET_OFFLINE);
uiBut *but = uiLayoutGetBlock(layout)->buttons.last().get();
uchar color[4];
@@ -470,7 +470,7 @@ void uiTemplateStatusInfo(uiLayout *layout, bContext *C)
row->label("|", ICON_NONE);
row->separator(-0.5f);
}
uiLayoutSetEmboss(row, blender::ui::EmbossType::None);
row->emboss_set(blender::ui::EmbossType::None);
row->op("EXTENSIONS_OT_userpref_show_for_update", "", icon);
uiBut *but = uiLayoutGetBlock(layout)->buttons.last().get();
uchar color[4];

View File

@@ -908,7 +908,7 @@ void TreeViewLayoutBuilder::build_row(AbstractTreeViewItem &item) const
uiLayout *row = &overlap->row(false);
/* Enable emboss for mouse hover highlight. */
uiLayoutSetEmboss(row, blender::ui::EmbossType::Emboss);
row->emboss_set(blender::ui::EmbossType::Emboss);
/* Every item gets one! Other buttons can be overlapped on top. */
item.add_treerow_button(block_);

View File

@@ -1258,7 +1258,7 @@ static void buttons_panel_context_draw(const bContext *C, Panel *panel)
uiLayout *pin_row = &row->row(false);
uiLayoutSetAlignment(pin_row, UI_LAYOUT_ALIGN_RIGHT);
uiItemSpacer(pin_row);
uiLayoutSetEmboss(pin_row, blender::ui::EmbossType::None);
pin_row->emboss_set(blender::ui::EmbossType::None);
pin_row->op(
"BUTTONS_OT_toggle_pin", "", (sbuts->flag & SB_PIN_CONTEXT) ? ICON_PINNED : ICON_UNPINNED);
}

View File

@@ -1118,7 +1118,7 @@ static void draw_node_socket_name_editable(uiLayout *layout,
{
if (sock->runtime->declaration) {
if (sock->runtime->declaration->socket_name_rna) {
uiLayoutSetEmboss(layout, blender::ui::EmbossType::None);
layout->emboss_set(blender::ui::EmbossType::None);
layout->prop((&sock->runtime->declaration->socket_name_rna->owner),
sock->runtime->declaration->socket_name_rna->property_name,
UI_ITEM_NONE,

View File

@@ -1054,7 +1054,7 @@ static void draw_context_panel(const bContext &C, uiLayout &layout)
SpaceSpreadsheet &sspreadsheet = *CTX_wm_space_spreadsheet(&C);
PanelLayout context_panel = layout.panel(&C, "context", false);
uiLayoutSetEmboss(context_panel.header, ui::EmbossType::None);
context_panel.header->emboss_set(ui::EmbossType::None);
if (ID *root_id = get_current_id(&sspreadsheet)) {
std::string label = BKE_id_name(*root_id);
if (!context_panel.body) {

View File

@@ -149,7 +149,7 @@ static void spreadsheet_filter_panel_draw_header(const bContext *C, Panel *panel
}
uiLayout *row = &layout->row(true);
uiLayoutSetEmboss(row, blender::ui::EmbossType::None);
row->emboss_set(blender::ui::EmbossType::None);
row->prop(filter_ptr, "enabled", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
if (column_name.is_empty()) {
@@ -170,7 +170,7 @@ static void spreadsheet_filter_panel_draw_header(const bContext *C, Panel *panel
}
row = &layout->row(true);
uiLayoutSetEmboss(row, blender::ui::EmbossType::None);
row->emboss_set(blender::ui::EmbossType::None);
const int current_index = BLI_findindex(&sspreadsheet->row_filters, filter);
PointerRNA op_ptr = row->op("SPREADSHEET_OT_remove_row_filter_rule", "", ICON_X);
RNA_int_set(&op_ptr, "index", current_index);

View File

@@ -1604,7 +1604,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr)
colsub = &split->column(true);
colsub->prop(ptr, "location", UI_ITEM_NONE, std::nullopt, ICON_NONE);
colsub = &split->column(true);
uiLayoutSetEmboss(colsub, blender::ui::EmbossType::NoneOrStatus);
colsub->emboss_set(blender::ui::EmbossType::NoneOrStatus);
colsub->label("", ICON_NONE);
colsub->prop(
ptr, "lock_location", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED);
@@ -1616,7 +1616,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr)
colsub = &split->column(true);
colsub->prop(ptr, "rotation_quaternion", UI_ITEM_NONE, IFACE_("Rotation"), ICON_NONE);
colsub = &split->column(true);
uiLayoutSetEmboss(colsub, blender::ui::EmbossType::NoneOrStatus);
colsub->emboss_set(blender::ui::EmbossType::NoneOrStatus);
colsub->prop(ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE);
if (RNA_boolean_get(ptr, "lock_rotations_4d")) {
colsub->prop(ptr,
@@ -1638,7 +1638,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr)
colsub = &split->column(true);
colsub->prop(ptr, "rotation_axis_angle", UI_ITEM_NONE, IFACE_("Rotation"), ICON_NONE);
colsub = &split->column(true);
uiLayoutSetEmboss(colsub, blender::ui::EmbossType::NoneOrStatus);
colsub->emboss_set(blender::ui::EmbossType::NoneOrStatus);
colsub->prop(ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE);
if (RNA_boolean_get(ptr, "lock_rotations_4d")) {
colsub->prop(ptr,
@@ -1660,7 +1660,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr)
colsub = &split->column(true);
colsub->prop(ptr, "rotation_euler", UI_ITEM_NONE, IFACE_("Rotation"), ICON_NONE);
colsub = &split->column(true);
uiLayoutSetEmboss(colsub, blender::ui::EmbossType::NoneOrStatus);
colsub->emboss_set(blender::ui::EmbossType::NoneOrStatus);
colsub->label("", ICON_NONE);
colsub->prop(ptr,
"lock_rotation",
@@ -1675,7 +1675,7 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr)
colsub = &split->column(true);
colsub->prop(ptr, "scale", UI_ITEM_NONE, std::nullopt, ICON_NONE);
colsub = &split->column(true);
uiLayoutSetEmboss(colsub, blender::ui::EmbossType::NoneOrStatus);
colsub->emboss_set(blender::ui::EmbossType::NoneOrStatus);
colsub->label("", ICON_NONE);
colsub->prop(
ptr, "lock_scale", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED);

View File

@@ -1500,12 +1500,12 @@ static void rna_UILayout_units_y_set(PointerRNA *ptr, float value)
static int rna_UILayout_emboss_get(PointerRNA *ptr)
{
return int(uiLayoutGetEmboss(static_cast<uiLayout *>(ptr->data)));
return int(static_cast<uiLayout *>(ptr->data)->emboss());
}
static void rna_UILayout_emboss_set(PointerRNA *ptr, int value)
{
uiLayoutSetEmboss(static_cast<uiLayout *>(ptr->data), blender::ui::EmbossType(value));
static_cast<uiLayout *>(ptr->data)->emboss_set(blender::ui::EmbossType(value));
}
static bool rna_UILayout_property_split_get(PointerRNA *ptr)

View File

@@ -322,7 +322,7 @@ static void modifier_panel_header(const bContext *C, Panel *panel)
/* Modifier Icon. */
sub = &layout->row(true);
uiLayoutSetEmboss(sub, blender::ui::EmbossType::None);
sub->emboss_set(blender::ui::EmbossType::None);
if (mti->is_disabled && mti->is_disabled(scene, md, false)) {
uiLayoutSetRedAlert(sub, true);
}
@@ -422,7 +422,7 @@ static void modifier_panel_header(const bContext *C, Panel *panel)
/* Delete button. */
if (modifier_can_delete(md) && !modifier_is_simulation(md)) {
sub = &row->row(false);
uiLayoutSetEmboss(sub, blender::ui::EmbossType::None);
sub->emboss_set(blender::ui::EmbossType::None);
sub->op("OBJECT_OT_modifier_remove", "", ICON_X);
buttons_number++;
}

View File

@@ -39,7 +39,7 @@ static void draw_item_in_list(uiList * /*ui_list*/,
RNA_float_get_array(itemptr, "color", color);
uiTemplateNodeSocket(row, const_cast<bContext *>(C), color);
}
uiLayoutSetEmboss(row, blender::ui::EmbossType::None);
row->emboss_set(blender::ui::EmbossType::None);
row->prop(itemptr, "name", UI_ITEM_NONE, "", ICON_NONE);
}

View File

@@ -191,7 +191,7 @@ static void shaderfx_panel_header(const bContext * /*C*/, Panel *panel)
row->menu_fn("", ICON_DOWNARROW_HLT, gpencil_shaderfx_ops_extra_draw, fx);
row = &row->row(false);
uiLayoutSetEmboss(row, blender::ui::EmbossType::None);
row->emboss_set(blender::ui::EmbossType::None);
row->op("OBJECT_OT_shaderfx_remove", "", ICON_X);
/* Some padding so the X isn't too close to the drag icon. */