Refactor: UI: Add active_default, activated_init, enabled methods

This replaces API for accessing the uiLayout  active_default,
acviated_init, enabled properties with methods, following uiLayout
refactors and the Python API naming.

Pull Request: https://projects.blender.org/blender/blender/pulls/140226
This commit is contained in:
Guillermo Venegas
2025-06-16 20:23:28 +02:00
committed by Hans Goudey
parent 9a41dc73f9
commit b03e64223c
32 changed files with 121 additions and 107 deletions

View File

@@ -989,12 +989,12 @@ static wmOperatorStatus armature_parent_set_invoke(bContext *C,
uiLayout *layout = UI_popup_menu_layout(pup);
uiLayout *row_offset = &layout->row(false);
uiLayoutSetEnabled(row_offset, enable_offset);
row_offset->enabled_set(enable_offset);
uiItemEnumO(
row_offset, "ARMATURE_OT_parent_set", std::nullopt, ICON_NONE, "type", ARM_PAR_OFFSET);
uiLayout *row_connect = &layout->row(false);
uiLayoutSetEnabled(row_connect, enable_connect);
row_connect->enabled_set(enable_connect);
uiItemEnumO(
row_connect, "ARMATURE_OT_parent_set", std::nullopt, ICON_NONE, "type", ARM_PAR_CONNECT);
@@ -1109,12 +1109,12 @@ static wmOperatorStatus armature_parent_clear_invoke(bContext *C,
uiLayout *layout = UI_popup_menu_layout(pup);
uiLayout *row_clear = &layout->row(false);
uiLayoutSetEnabled(row_clear, enable_clear);
row_clear->enabled_set(enable_clear);
uiItemEnumO(
row_clear, "ARMATURE_OT_parent_clear", std::nullopt, ICON_NONE, "type", ARM_PAR_CLEAR);
uiLayout *row_disconnect = &layout->row(false);
uiLayoutSetEnabled(row_disconnect, enable_disconnect);
row_disconnect->enabled_set(enable_disconnect);
uiItemEnumO(row_disconnect,
"ARMATURE_OT_parent_clear",
std::nullopt,

View File

@@ -1133,7 +1133,7 @@ static void move_to_collection_menu_create(bContext *C, uiLayout *layout, void *
/* Avoid assigning/moving to a linked bone collection. */
if (!ANIM_armature_bonecoll_is_editable(arm, bcoll)) {
uiLayout *sub = &layout->row(false);
uiLayoutSetEnabled(sub, false);
sub->enabled_set(false);
menu_add_item_for_move_assign_unassign(sub, arm, bcoll, index, is_move_operation);
continue;

View File

@@ -112,6 +112,29 @@ struct uiLayout : uiItem {
*/
void active_set(bool active);
bool active_default() const;
/**
* When set to true the next operator button added in the layout will be highlighted as default
* action when pressing return, in popup dialogs this overrides default confirmation buttons.
*/
void active_default_set(bool active_default);
bool activate_init() const;
/**
* When set to true, the next button added in the layout will be activated on first display.
* Only for popups dialogs and only the first button in the popup with this flag will be
* activated.
*/
void activate_init_set(bool activate_init);
bool enabled() const;
/**
* Sets the enabled state of the layout and its items.
* When false the layout and its buttons are grayed out, user can't interaction with them, only
* buttons tooltips are available on hovering.
*/
void enabled_set(bool enabled);
blender::ui::EmbossType emboss() const;
void emboss_set(blender::ui::EmbossType emboss);
@@ -383,6 +406,33 @@ inline void uiLayout::active_set(bool active)
active_ = active;
}
inline bool uiLayout::active_default() const
{
return active_default_;
}
inline void uiLayout::active_default_set(bool active_default)
{
active_default_ = active_default;
}
inline bool uiLayout::activate_init() const
{
return activate_init_;
}
inline void uiLayout::activate_init_set(bool activate_init)
{
activate_init_ = activate_init;
}
inline bool uiLayout::enabled() const
{
return enabled_;
}
inline void uiLayout::enabled_set(bool enabled)
{
enabled_ = enabled;
}
inline float uiLayout::scale_x() const
{
return scale_[0];
@@ -541,9 +591,6 @@ void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout);
/* Only for convenience. */
void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but);
void uiLayoutSetActiveDefault(uiLayout *layout, bool active_default);
void uiLayoutSetActivateInit(uiLayout *layout, bool activate_init);
void uiLayoutSetEnabled(uiLayout *layout, bool enabled);
void uiLayoutSetRedAlert(uiLayout *layout, bool redalert);
void uiLayoutSetAlignment(uiLayout *layout, char alignment);
void uiLayoutSetFixedSize(uiLayout *layout, bool fixed_size);
@@ -553,9 +600,6 @@ void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep);
int uiLayoutGetLocalDir(const uiLayout *layout);
void uiLayoutSetSearchWeight(uiLayout *layout, float weight);
bool uiLayoutGetActiveDefault(uiLayout *layout);
bool uiLayoutGetActivateInit(uiLayout *layout);
bool uiLayoutGetEnabled(uiLayout *layout);
bool uiLayoutGetRedAlert(uiLayout *layout);
int uiLayoutGetAlignment(uiLayout *layout);
bool uiLayoutGetFixedSize(uiLayout *layout);

View File

@@ -1022,12 +1022,12 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but, const wmEvent *ev
* operator poll, but that doesn't work since the operator also works with "selected_ids",
* which isn't cheap to check. */
uiLayout *sub = &layout->column(true);
uiLayoutSetEnabled(sub, !id->asset_data);
sub->enabled_set(!id->asset_data);
sub->op("ASSET_OT_mark_single",
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Mark as Asset"),
ICON_ASSET_MANAGER);
sub = &layout->column(true);
uiLayoutSetEnabled(sub, id->asset_data);
sub->enabled_set(id->asset_data);
sub->op("ASSET_OT_clear_single",
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Clear Asset"),
ICON_NONE);

View File

@@ -5101,21 +5101,6 @@ uiLayout &uiLayout::split(float percentage, bool align)
return *split;
}
void uiLayoutSetActiveDefault(uiLayout *layout, bool active_default)
{
layout->active_default_ = active_default;
}
void uiLayoutSetActivateInit(uiLayout *layout, bool activate_init)
{
layout->activate_init_ = activate_init;
}
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
{
layout->enabled_ = enabled;
}
void uiLayoutSetRedAlert(uiLayout *layout, bool redalert)
{
layout->redalert_ = redalert;
@@ -5171,21 +5156,6 @@ Panel *uiLayoutGetRootPanel(uiLayout *layout)
return layout->root_->block->panel;
}
bool uiLayoutGetActiveDefault(uiLayout *layout)
{
return layout->active_default_;
}
bool uiLayoutGetActivateInit(uiLayout *layout)
{
return layout->activate_init_;
}
bool uiLayoutGetEnabled(uiLayout *layout)
{
return layout->enabled_;
}
bool uiLayoutGetRedAlert(uiLayout *layout)
{
return layout->redalert_;

View File

@@ -418,14 +418,14 @@ eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout,
ELEM(type, PROP_STRING, PROP_INT, PROP_FLOAT));
if (use_activate_init) {
uiLayoutSetActivateInit(col, true);
col->activate_init_set(true);
}
col->prop(ptr, prop, -1, 0, compact ? UI_ITEM_R_COMPACT : UI_ITEM_NONE, name, ICON_NONE);
return_info &= ~UI_PROP_BUTS_NONE_ADDED;
if (use_activate_init) {
uiLayoutSetActivateInit(col, false);
col->activate_init_set(false);
}
}
RNA_STRUCT_END;

View File

@@ -172,7 +172,7 @@ static void hud_panel_operator_redo_draw(const bContext *C, Panel *panel)
return;
}
if (!WM_operator_check_ui_enabled(C, op->type->name)) {
uiLayoutSetEnabled(panel->layout, false);
panel->layout->enabled_set(false);
}
uiLayout *col = &panel->layout->column(false);
uiTemplateOperatorRedoProperties(col, C);

View File

@@ -90,11 +90,11 @@ void uiTemplateCacheFileProcedural(uiLayout *layout, const bContext *C, PointerR
const bool use_prefetch = RNA_boolean_get(fileptr, "use_prefetch");
row = &layout->row(false);
uiLayoutSetEnabled(row, use_render_procedural);
row->enabled_set(use_render_procedural);
row->prop(fileptr, "use_prefetch", UI_ITEM_NONE, std::nullopt, ICON_NONE);
sub = &layout->row(false);
uiLayoutSetEnabled(sub, use_prefetch && use_render_procedural);
sub->enabled_set(use_prefetch && use_render_procedural);
sub->prop(fileptr, "prefetch_cache_size", UI_ITEM_NONE, std::nullopt, ICON_NONE);
}

View File

@@ -76,7 +76,7 @@ static void constraint_ops_extra_draw(bContext *C, uiLayout *layout, void *con_v
UI_ITEM_NONE);
RNA_int_set(&op_ptr, "index", 0);
if (!con->prev) {
uiLayoutSetEnabled(row, false);
row->enabled_set(false);
}
/* Move to last. */
@@ -90,7 +90,7 @@ static void constraint_ops_extra_draw(bContext *C, uiLayout *layout, void *con_v
ob, con, nullptr);
RNA_int_set(&op_ptr, "index", BLI_listbase_count(constraint_list) - 1);
if (!con->next) {
uiLayoutSetEnabled(row, false);
row->enabled_set(false);
}
}

View File

@@ -101,7 +101,7 @@ class NodeSocketViewItem : public BasicTreeViewItem {
void build_row(uiLayout &row) override
{
if (ID_IS_LINKED(&nodetree_)) {
uiLayoutSetEnabled(&row, false);
row.enabled_set(false);
}
uiLayoutSetPropDecorate(&row, false);
@@ -191,7 +191,7 @@ class NodePanelViewItem : public BasicTreeViewItem {
void build_row(uiLayout &row) override
{
if (ID_IS_LINKED(&nodetree_)) {
uiLayoutSetEnabled(&row, false);
row.enabled_set(false);
}
/* Add boolean socket if panel has a toggle. */
if (toggle_ != nullptr) {

View File

@@ -447,7 +447,7 @@ void uiTemplateCollectionExporters(uiLayout *layout, bContext *C)
col = &layout->column(true);
col->op("COLLECTION_OT_export_all", std::nullopt, ICON_EXPORT);
uiLayoutSetEnabled(col, !BLI_listbase_is_empty(exporters));
col->enabled_set(!BLI_listbase_is_empty(exporters));
/* Draw the active exporter. */
CollectionExport *data = (CollectionExport *)BLI_findlink(exporters, index);

View File

@@ -164,7 +164,7 @@ static void ui_obj_export_settings(const bContext *C, uiLayout *layout, PointerR
col->prop(ptr, "export_vertex_groups", UI_ITEM_NONE, IFACE_("Vertex Groups"), ICON_NONE);
col->prop(ptr, "export_smooth_groups", UI_ITEM_NONE, IFACE_("Smooth Groups"), ICON_NONE);
col = &col->column(false);
uiLayoutSetEnabled(col, export_smooth_groups);
col->enabled_set(export_smooth_groups);
col->prop(
ptr, "smooth_group_bitflags", UI_ITEM_NONE, IFACE_("Smooth Group Bitflags"), ICON_NONE);
}
@@ -176,7 +176,7 @@ static void ui_obj_export_settings(const bContext *C, uiLayout *layout, PointerR
panel.header->label(IFACE_("Materials"), ICON_NONE);
if (panel.body) {
uiLayout *col = &panel.body->column(false);
uiLayoutSetEnabled(col, export_materials);
col->enabled_set(export_materials);
col->prop(ptr, "export_pbr_extensions", UI_ITEM_NONE, IFACE_("PBR Extensions"), ICON_NONE);
col->prop(ptr, "path_mode", UI_ITEM_NONE, IFACE_("Path Mode"), ICON_NONE);
@@ -189,7 +189,7 @@ static void ui_obj_export_settings(const bContext *C, uiLayout *layout, PointerR
panel.header->label(IFACE_("Animation"), ICON_NONE);
if (panel.body) {
uiLayout *col = &panel.body->column(false);
uiLayoutSetEnabled(col, export_animation);
col->enabled_set(export_animation);
col->prop(ptr, "start_frame", UI_ITEM_NONE, IFACE_("Frame Start"), ICON_NONE);
col->prop(ptr, "end_frame", UI_ITEM_NONE, IFACE_("End"), ICON_NONE);

View File

@@ -553,7 +553,7 @@ static void wm_usd_export_draw(bContext *C, wmOperator *op)
uiLayout *col2 = &col->column(true);
uiLayoutSetPropSep(col2, true);
uiLayoutSetEnabled(col2, textures_mode == USD_TEX_EXPORT_NEW_PATH);
col2->enabled_set(textures_mode == USD_TEX_EXPORT_NEW_PATH);
col2->prop(ptr, "overwrite_textures", UI_ITEM_NONE, std::nullopt, ICON_NONE);
col2->prop(ptr, "usdz_downscale_size", UI_ITEM_NONE, std::nullopt, ICON_NONE);
if (RNA_enum_get(ptr, "usdz_downscale_size") == USD_TEXTURE_SIZE_CUSTOM) {
@@ -1160,11 +1160,11 @@ static void wm_usd_import_draw(bContext *C, wmOperator *op)
col->prop(ptr, "import_all_materials", UI_ITEM_NONE, std::nullopt, ICON_NONE);
col->prop(ptr, "import_usd_preview", UI_ITEM_NONE, std::nullopt, ICON_NONE);
uiLayoutSetEnabled(col, RNA_boolean_get(ptr, "import_materials"));
col->enabled_set(RNA_boolean_get(ptr, "import_materials"));
uiLayout *row = &col->row(true);
row->prop(ptr, "set_material_blend", UI_ITEM_NONE, std::nullopt, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(ptr, "import_usd_preview"));
row->enabled_set(RNA_boolean_get(ptr, "import_usd_preview"));
col->prop(ptr, "mtl_name_collision_mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
}
@@ -1176,11 +1176,11 @@ static void wm_usd_import_draw(bContext *C, wmOperator *op)
uiLayout *row = &col->row(true);
row->prop(ptr, "import_textures_dir", UI_ITEM_NONE, std::nullopt, ICON_NONE);
uiLayoutSetEnabled(row, copy_textures);
row->enabled_set(copy_textures);
row = &col->row(true);
row->prop(ptr, "tex_name_collision_mode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
uiLayoutSetEnabled(row, copy_textures);
uiLayoutSetEnabled(col, RNA_boolean_get(ptr, "import_materials"));
row->enabled_set(copy_textures);
col->enabled_set(RNA_boolean_get(ptr, "import_materials"));
}
if (uiLayout *panel = layout->panel(

View File

@@ -121,7 +121,7 @@ static void file_panel_execution_execute_button(uiLayout *layout, const char *ti
row->scale_x_set(0.8f);
uiLayoutSetFixedSize(row, true);
/* Just a display hint. */
uiLayoutSetActiveDefault(row, true);
row->active_default_set(true);
row->op("FILE_OT_execute", title, ICON_NONE);
}

View File

@@ -222,7 +222,7 @@ static void graph_panel_properties(const bContext *C, Panel *panel)
/* RNA-Path Editing - only really should be enabled when things aren't working */
col = &layout->column(false);
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0);
col->enabled_set((fcu->flag & FCURVE_DISABLED) != 0);
col->prop(&fcu_ptr, "data_path", UI_ITEM_NONE, "", ICON_RNA);
col->prop(&fcu_ptr, "array_index", UI_ITEM_NONE, std::nullopt, ICON_NONE);

View File

@@ -832,7 +832,7 @@ void uiTemplateImage(uiLayout *layout,
}
layout = &layout->column(false);
uiLayoutSetEnabled(layout, !is_dirty);
layout->enabled_set(!is_dirty);
uiLayoutSetPropDecorate(layout, false);
/* Image source */
@@ -858,7 +858,7 @@ void uiTemplateImage(uiLayout *layout,
}
row = &row->row(true);
uiLayoutSetEnabled(row, is_packed == false);
row->enabled_set(is_packed == false);
prop = RNA_struct_find_property(&imaptr, "filepath");
uiDefAutoButR(block, &imaptr, prop, -1, "", ICON_NONE, 0, 0, 200, UI_UNIT_Y);

View File

@@ -561,7 +561,7 @@ static void nla_panel_evaluation(const bContext *C, Panel *panel)
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, RNA_boolean_get(&strip_ptr, "use_animated_influence"));
layout->enabled_set(RNA_boolean_get(&strip_ptr, "use_animated_influence"));
layout->prop(&strip_ptr, "influence", UI_ITEM_NONE, std::nullopt, ICON_NONE);
}
@@ -599,7 +599,7 @@ static void nla_panel_animated_strip_time(const bContext *C, Panel *panel)
UI_block_func_handle_set(block, do_nla_region_buttons, nullptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, RNA_boolean_get(&strip_ptr, "use_animated_time"));
layout->enabled_set(RNA_boolean_get(&strip_ptr, "use_animated_time"));
layout->prop(&strip_ptr, "strip_time", UI_ITEM_NONE, std::nullopt, ICON_NONE);
}

View File

@@ -346,7 +346,7 @@ static void node_buts_image_user(uiLayout *layout,
/* Avoid losing changes image is painted. */
if (BKE_image_is_dirty((Image *)imaptr->data)) {
uiLayoutSetEnabled(split, false);
split->enabled_set(false);
}
}
}

View File

@@ -245,7 +245,7 @@ static void undo_history_draw_menu(const bContext *C, Menu *menu)
}
const bool is_active = (us == wm->undo_stack->step_active);
uiLayout *row = &column->row(false);
uiLayoutSetEnabled(row, !is_active);
row->enabled_set(!is_active);
PointerRNA op_ptr = row->op("ED_OT_undo_history",
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, us->name),
is_active ? ICON_LAYER_ACTIVE : ICON_NONE);

View File

@@ -1506,7 +1506,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *panel)
xco += x;
row = &split->row(true);
uiLayoutSetEnabled(row, !locked);
row->enabled_set(!locked);
/* The weight group value */
/* To be reworked still */

View File

@@ -1373,22 +1373,22 @@ static void rna_UILayout_active_set(PointerRNA *ptr, bool value)
static bool rna_UILayout_active_default_get(PointerRNA *ptr)
{
return uiLayoutGetActiveDefault(static_cast<uiLayout *>(ptr->data));
return static_cast<uiLayout *>(ptr->data)->active_default();
}
static void rna_UILayout_active_default_set(PointerRNA *ptr, bool value)
{
uiLayoutSetActiveDefault(static_cast<uiLayout *>(ptr->data), value);
static_cast<uiLayout *>(ptr->data)->active_default_set(value);
}
static bool rna_UILayout_activate_init_get(PointerRNA *ptr)
{
return uiLayoutGetActivateInit(static_cast<uiLayout *>(ptr->data));
return static_cast<uiLayout *>(ptr->data)->activate_init();
}
static void rna_UILayout_activate_init_set(PointerRNA *ptr, bool value)
{
uiLayoutSetActivateInit(static_cast<uiLayout *>(ptr->data), value);
static_cast<uiLayout *>(ptr->data)->activate_init_set(value);
}
static bool rna_UILayout_alert_get(PointerRNA *ptr)
@@ -1413,12 +1413,12 @@ static int rna_UILayout_op_context_get(PointerRNA *ptr)
static bool rna_UILayout_enabled_get(PointerRNA *ptr)
{
return uiLayoutGetEnabled(static_cast<uiLayout *>(ptr->data));
return static_cast<uiLayout *>(ptr->data)->enabled();
}
static void rna_UILayout_enabled_set(PointerRNA *ptr, bool value)
{
uiLayoutSetEnabled(static_cast<uiLayout *>(ptr->data), value);
static_cast<uiLayout *>(ptr->data)->enabled_set(value);
}
# if 0

View File

@@ -801,7 +801,7 @@ static void panel_draw(const bContext * /*C*/, Panel *panel)
layout->separator();
row = &layout->row(true);
uiLayoutSetEnabled(row, has_vertex_group);
row->enabled_set(has_vertex_group);
row->op(
"OBJECT_OT_laplaciandeform_bind", is_bind ? IFACE_("Unbind") : IFACE_("Bind"), ICON_NONE);

View File

@@ -228,7 +228,7 @@ static void panel_draw(const bContext * /*C*/, Panel *panel)
const bool is_baked = RNA_boolean_get(ptr, "is_baked");
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
if (!is_first_lineart(*static_cast<const GreasePencilLineartModifierData *>(ptr->data))) {
layout->prop(ptr, "use_cache", UI_ITEM_NONE, std::nullopt, ICON_NONE);
@@ -278,7 +278,7 @@ static void edge_types_panel_draw(const bContext * /*C*/, Panel *panel)
*static_cast<const GreasePencilLineartModifierData *>(ptr->data));
const bool has_light = RNA_pointer_get(ptr, "light_contour_object").data != nullptr;
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
uiLayoutSetPropSep(layout, true);
@@ -359,7 +359,7 @@ static void options_light_reference_draw(const bContext * /*C*/, Panel *panel)
*static_cast<const GreasePencilLineartModifierData *>(ptr->data));
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
if (use_cache && !is_first) {
layout->label(RPT_("Cached from the first Line Art modifier."), ICON_INFO);
@@ -390,7 +390,7 @@ static void options_panel_draw(const bContext * /*C*/, Panel *panel)
*static_cast<const GreasePencilLineartModifierData *>(ptr->data));
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
if (use_cache && !is_first) {
layout->label(TIP_("Cached from the first Line Art modifier"), ICON_INFO);
@@ -428,7 +428,7 @@ static void occlusion_panel_draw(const bContext * /*C*/, Panel *panel)
const bool show_in_front = RNA_boolean_get(&ob_ptr, "show_in_front");
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
if (!show_in_front) {
layout->label(TIP_("Object is not in front"), ICON_INFO);
@@ -469,7 +469,7 @@ static void material_mask_panel_draw_header(const bContext * /*C*/, Panel *panel
const bool is_baked = RNA_boolean_get(ptr, "is_baked");
const bool show_in_front = RNA_boolean_get(&ob_ptr, "show_in_front");
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
layout->active_set(show_in_front && anything_showing_through(ptr));
layout->prop(ptr, "use_material_mask", UI_ITEM_NONE, IFACE_("Material Mask"), ICON_NONE);
@@ -481,12 +481,12 @@ static void material_mask_panel_draw(const bContext * /*C*/, Panel *panel)
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
const bool is_baked = RNA_boolean_get(ptr, "is_baked");
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
layout->active_set(anything_showing_through(ptr));
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, RNA_boolean_get(ptr, "use_material_mask"));
layout->enabled_set(RNA_boolean_get(ptr, "use_material_mask"));
uiLayout *col = &layout->column(true);
uiLayout *sub = &col->row(true, IFACE_("Masks"));
@@ -508,7 +508,7 @@ static void intersection_panel_draw(const bContext * /*C*/, Panel *panel)
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
const bool is_baked = RNA_boolean_get(ptr, "is_baked");
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
uiLayoutSetPropSep(layout, true);
@@ -540,7 +540,7 @@ static void face_mark_panel_draw_header(const bContext * /*C*/, Panel *panel)
*static_cast<const GreasePencilLineartModifierData *>(ptr->data));
if (!use_cache || is_first) {
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
layout->prop(ptr, "use_face_mark", UI_ITEM_NONE, IFACE_("Face Mark Filtering"), ICON_NONE);
}
else {
@@ -560,7 +560,7 @@ static void face_mark_panel_draw(const bContext * /*C*/, Panel *panel)
const bool is_first = is_first_lineart(
*static_cast<const GreasePencilLineartModifierData *>(ptr->data));
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
if (use_cache && !is_first) {
layout->label(TIP_("Cached from the first Line Art modifier"), ICON_INFO);
@@ -590,7 +590,7 @@ static void chaining_panel_draw(const bContext * /*C*/, Panel *panel)
const bool is_geom = RNA_boolean_get(ptr, "use_geometry_space_chain");
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
if (use_cache && !is_first) {
layout->label(TIP_("Cached from the first Line Art modifier"), ICON_INFO);
@@ -630,7 +630,7 @@ static void vgroup_panel_draw(const bContext * /*C*/, Panel *panel)
*static_cast<const GreasePencilLineartModifierData *>(ptr->data));
uiLayoutSetPropSep(layout, true);
uiLayoutSetEnabled(layout, !is_baked);
layout->enabled_set(!is_baked);
if (use_cache && !is_first) {
layout->label(TIP_("Cached from the first Line Art modifier"), ICON_INFO);
@@ -667,7 +667,7 @@ static void bake_panel_draw(const bContext * /*C*/, Panel *panel)
}
uiLayout *col = &layout->column(false);
uiLayoutSetEnabled(col, !is_baked);
col->enabled_set(!is_baked);
col->op("OBJECT_OT_lineart_bake_strokes", std::nullopt, ICON_NONE);
PointerRNA op_ptr = col->op("OBJECT_OT_lineart_bake_strokes", IFACE_("Bake All"), ICON_NONE);
RNA_boolean_set(&op_ptr, "bake_all", true);

View File

@@ -515,13 +515,13 @@ static void panel_draw(const bContext * /*C*/, Panel *panel)
uiLayoutSetPropSep(layout, true);
col = &layout->column(true);
uiLayoutSetEnabled(col, !is_bound);
col->enabled_set(!is_bound);
col->prop(ptr, "object", UI_ITEM_NONE, std::nullopt, ICON_NONE);
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", std::nullopt);
col = &layout->column(false);
uiLayoutSetEnabled(col, !is_bound);
col->enabled_set(!is_bound);
col->prop(ptr, "precision", UI_ITEM_NONE, std::nullopt, ICON_NONE);
col->prop(ptr, "use_dynamic_bind", UI_ITEM_NONE, std::nullopt, ICON_NONE);

View File

@@ -323,7 +323,7 @@ static void subdivisions_panel_draw(const bContext * /*C*/, Panel *panel)
PointerRNA ob_ptr;
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
uiLayoutSetEnabled(layout, RNA_enum_get(&ob_ptr, "mode") != OB_MODE_EDIT);
layout->enabled_set(RNA_enum_get(&ob_ptr, "mode") != OB_MODE_EDIT);
MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
@@ -377,7 +377,7 @@ static void shape_panel_draw(const bContext * /*C*/, Panel *panel)
PointerRNA ob_ptr;
modifier_panel_get_property_pointers(panel, &ob_ptr);
uiLayoutSetEnabled(layout, RNA_enum_get(&ob_ptr, "mode") != OB_MODE_EDIT);
layout->enabled_set(RNA_enum_get(&ob_ptr, "mode") != OB_MODE_EDIT);
row = &layout->row(false);
row->op("OBJECT_OT_multires_reshape", IFACE_("Reshape"), ICON_NONE);

View File

@@ -638,7 +638,7 @@ static void bake_panel_draw(const bContext * /*C*/, Panel *panel)
layout->prop(ptr, "filepath", UI_ITEM_NONE, std::nullopt, ICON_NONE);
col = &layout->column(true);
uiLayoutSetEnabled(col, !is_cached);
col->enabled_set(!is_cached);
col->prop(ptr, "frame_start", UI_ITEM_NONE, IFACE_("Frame Start"), ICON_NONE);
col->prop(ptr, "frame_end", UI_ITEM_NONE, IFACE_("End"), ICON_NONE);

View File

@@ -1598,7 +1598,7 @@ static void panel_draw(const bContext * /*C*/, Panel *panel)
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", std::nullopt);
col = &layout->column(false);
uiLayoutSetEnabled(col, !is_bound);
col->enabled_set(!is_bound);
col->active_set(!is_bound && RNA_string_length(ptr, "vertex_group") != 0);
col->prop(ptr, "use_sparse_bind", UI_ITEM_NONE, std::nullopt, ICON_NONE);

View File

@@ -510,11 +510,11 @@ static void node_layout(uiLayout *layout, bContext *C, PointerRNA *ptr)
return;
}
layout->active_set(ctx.is_bakeable_in_current_context);
uiLayoutSetEnabled(layout, ID_IS_EDITABLE(ctx.object));
layout->enabled_set(ID_IS_EDITABLE(ctx.object));
uiLayout *col = &layout->column(false);
{
uiLayout *row = &col->row(true);
uiLayoutSetEnabled(row, !ctx.is_baked);
row->enabled_set(!ctx.is_baked);
row->prop(&ctx.bake_rna, "bake_mode", UI_ITEM_R_EXPAND, IFACE_("Mode"), ICON_NONE);
}
draw_bake_button_row(ctx, col);
@@ -531,13 +531,13 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
}
layout->active_set(ctx.is_bakeable_in_current_context);
uiLayoutSetEnabled(layout, ID_IS_EDITABLE(ctx.object));
layout->enabled_set(ID_IS_EDITABLE(ctx.object));
{
uiLayout *col = &layout->column(false);
{
uiLayout *row = &col->row(true);
uiLayoutSetEnabled(row, !ctx.is_baked);
row->enabled_set(!ctx.is_baked);
row->prop(&ctx.bake_rna, "bake_mode", UI_ITEM_R_EXPAND, IFACE_("Mode"), ICON_NONE);
}

View File

@@ -232,7 +232,7 @@ static void node_layout_ex(uiLayout *layout, bContext *C, PointerRNA *current_no
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiLayoutSetEnabled(layout, ID_IS_EDITABLE(ctx.object));
layout->enabled_set(ID_IS_EDITABLE(ctx.object));
{
uiLayout *col = &layout->column(false);

View File

@@ -136,7 +136,7 @@ static void gpencil_shaderfx_ops_extra_draw(bContext *C, uiLayout *layout, void
UI_ITEM_NONE);
RNA_int_set(&op_ptr, "index", 0);
if (!fx->prev) {
uiLayoutSetEnabled(row, false);
row->enabled_set(false);
}
/* Move to last. */
@@ -148,7 +148,7 @@ static void gpencil_shaderfx_ops_extra_draw(bContext *C, uiLayout *layout, void
UI_ITEM_NONE);
RNA_int_set(&op_ptr, "index", BLI_listbase_count(&ob->shader_fx) - 1);
if (!fx->next) {
uiLayoutSetEnabled(row, false);
row->enabled_set(false);
}
}

View File

@@ -3340,7 +3340,7 @@ static void wm_open_mainfile_ui(bContext * /*C*/, wmOperator *op)
if (file_info->is_untrusted) {
autoexec_text = IFACE_("Trusted Source [Untrusted Path]");
col->active_set(false);
uiLayoutSetEnabled(col, false);
col->enabled_set(false);
}
else {
autoexec_text = IFACE_("Trusted Source");

View File

@@ -1436,7 +1436,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *region, void *arg_op)
if (op == WM_operator_last_redo(C)) {
if (!WM_operator_check_ui_enabled(C, op->type->name)) {
uiLayoutSetEnabled(layout, false);
layout->enabled_set(false);
}
}