Refactor: UI: Replace uiLayoutAbsolute and uiLayoutAbsoluteBlock with uiLayout class methods
This converts the public `uiLayoutAbsolute ` and `uiLayoutAbsoluteBlock` functions to an object oriented API (an `uiLayout::absolute` and `uiLayout::absolute_block` respectively), following recent changes. `uiLayout::absolute` now returns an uiLayout reference instead of a pointer. New calls to this method should use references too. Part of: #117604 Pull Request: https://projects.blender.org/blender/blender/pulls/138546
This commit is contained in:
committed by
Hans Goudey
parent
b3732f057e
commit
a46e3d2e78
@@ -95,6 +95,9 @@ struct uiLayout : uiItem {
|
||||
float search_weight_;
|
||||
|
||||
public:
|
||||
uiLayout &absolute(bool align);
|
||||
uiBlock *absolute_block();
|
||||
|
||||
/**
|
||||
* Add a new box sub-layout, items placed in this sub-layout are added vertically one under
|
||||
* each other in a column and are surrounded by a box.
|
||||
@@ -391,9 +394,7 @@ uiLayout *uiLayoutListBox(uiLayout *layout,
|
||||
uiList *ui_list,
|
||||
PointerRNA *actptr,
|
||||
PropertyRNA *actprop);
|
||||
uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align);
|
||||
uiLayout *uiLayoutOverlap(uiLayout *layout);
|
||||
uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout);
|
||||
/** Pie menu layout: Buttons are arranged around a center. */
|
||||
uiLayout *uiLayoutRadial(uiLayout *layout);
|
||||
|
||||
|
||||
@@ -542,7 +542,7 @@ static void ui_item_array(uiLayout *layout,
|
||||
uint layer_used = 0;
|
||||
uint layer_active = 0;
|
||||
|
||||
UI_block_layout_set_current(block, uiLayoutAbsolute(layout, false));
|
||||
UI_block_layout_set_current(block, &layout->absolute(false));
|
||||
|
||||
const int butw = UI_UNIT_X * 0.75;
|
||||
const int buth = UI_UNIT_X * 0.75;
|
||||
@@ -603,7 +603,7 @@ static void ui_item_array(uiLayout *layout,
|
||||
int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */
|
||||
int row, col;
|
||||
|
||||
UI_block_layout_set_current(block, uiLayoutAbsolute(layout, true));
|
||||
UI_block_layout_set_current(block, &layout->absolute(true));
|
||||
|
||||
totdim = RNA_property_array_dimension(ptr, prop, dim_size);
|
||||
if (totdim != 2) {
|
||||
@@ -5208,22 +5208,22 @@ uiLayout *uiLayoutListBox(uiLayout *layout,
|
||||
return (uiLayout *)box;
|
||||
}
|
||||
|
||||
uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align)
|
||||
uiLayout &uiLayout::absolute(bool align)
|
||||
{
|
||||
uiLayout *litem = MEM_new<uiLayout>(__func__);
|
||||
ui_litem_init_from_parent(litem, layout, align);
|
||||
ui_litem_init_from_parent(litem, this, align);
|
||||
|
||||
litem->type_ = uiItemType::LayoutAbsolute;
|
||||
|
||||
UI_block_layout_set_current(layout->root_->block, litem);
|
||||
UI_block_layout_set_current(root_->block, litem);
|
||||
|
||||
return litem;
|
||||
return *litem;
|
||||
}
|
||||
|
||||
uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout)
|
||||
uiBlock *uiLayout::absolute_block()
|
||||
{
|
||||
uiBlock *block = uiLayoutGetBlock(layout);
|
||||
uiLayoutAbsolute(layout, false);
|
||||
uiBlock *block = uiLayoutGetBlock(this);
|
||||
absolute(false);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ void uiTemplateColorRamp(uiLayout *layout,
|
||||
rect.ymin = 0;
|
||||
rect.ymax = 19.5f * UI_UNIT_X;
|
||||
|
||||
uiBlock *block = uiLayoutAbsoluteBlock(layout);
|
||||
uiBlock *block = layout->absolute_block();
|
||||
|
||||
ID *id = cptr.owner_id;
|
||||
UI_block_lock_set(block, (id && !ID_IS_EDITABLE(id)), ERROR_LIBDATA_MESSAGE);
|
||||
|
||||
@@ -95,7 +95,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_lit
|
||||
|
||||
void uiTemplateIcon(uiLayout *layout, int icon_value, float icon_scale)
|
||||
{
|
||||
uiBlock *block = uiLayoutAbsoluteBlock(layout);
|
||||
uiBlock *block = layout->absolute_block();
|
||||
uiBut *but = uiDefIconBut(block,
|
||||
UI_BTYPE_LABEL,
|
||||
0,
|
||||
@@ -127,7 +127,7 @@ void uiTemplateIconView(uiLayout *layout,
|
||||
return;
|
||||
}
|
||||
|
||||
uiBlock *block = uiLayoutAbsoluteBlock(layout);
|
||||
uiBlock *block = layout->absolute_block();
|
||||
|
||||
int tot_items;
|
||||
bool free_items;
|
||||
|
||||
@@ -59,7 +59,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
|
||||
return;
|
||||
}
|
||||
|
||||
uiLayout *ui_abs = uiLayoutAbsolute(layout, false);
|
||||
uiLayout *ui_abs = &layout->absolute(false);
|
||||
uiBlock *block = uiLayoutGetBlock(ui_abs);
|
||||
blender::ui::EmbossType previous_emboss = UI_block_emboss_get(block);
|
||||
|
||||
@@ -518,7 +518,7 @@ void uiTemplateStatusInfo(uiLayout *layout, bContext *C)
|
||||
}
|
||||
|
||||
const uiStyle *style = UI_style_get();
|
||||
uiLayout *ui_abs = uiLayoutAbsolute(layout, false);
|
||||
uiLayout *ui_abs = &layout->absolute(false);
|
||||
uiBlock *block = uiLayoutGetBlock(ui_abs);
|
||||
blender::ui::EmbossType previous_emboss = UI_block_emboss_get(block);
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ uiBlock *template_common_search_menu(const bContext *C,
|
||||
|
||||
void uiTemplateHeader(uiLayout *layout, bContext *C)
|
||||
{
|
||||
uiBlock *block = uiLayoutAbsoluteBlock(layout);
|
||||
uiBlock *block = layout->absolute_block();
|
||||
ED_area_header_switchbutton(C, block, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -452,7 +452,7 @@ void uiTemplateMarker(uiLayout *layout,
|
||||
|
||||
if (track->flag & TRACK_LOCKED) {
|
||||
uiLayoutSetActive(layout, false);
|
||||
uiBlock *block = uiLayoutAbsoluteBlock(layout);
|
||||
uiBlock *block = layout->absolute_block();
|
||||
uiDefBut(block,
|
||||
UI_BTYPE_LABEL,
|
||||
0,
|
||||
@@ -488,7 +488,7 @@ void uiTemplateMarker(uiLayout *layout,
|
||||
|
||||
cb->marker_flag = marker->flag;
|
||||
|
||||
uiBlock *block = uiLayoutAbsoluteBlock(layout);
|
||||
uiBlock *block = layout->absolute_block();
|
||||
UI_block_func_handle_set(block, marker_block_handler, cb);
|
||||
UI_block_funcN_set(block, marker_update_cb, cb, nullptr);
|
||||
|
||||
@@ -520,7 +520,7 @@ void uiTemplateMarker(uiLayout *layout,
|
||||
uiLayout *col = &layout->column(true);
|
||||
uiLayoutSetActive(col, (cb->marker_flag & MARKER_DISABLED) == 0);
|
||||
|
||||
block = uiLayoutAbsoluteBlock(col);
|
||||
block = col->absolute_block();
|
||||
UI_block_align_begin(block);
|
||||
|
||||
uiDefBut(block,
|
||||
|
||||
@@ -310,7 +310,7 @@ static void v3d_editvertex_buts(
|
||||
const bContext *C, uiLayout *layout, View3D *v3d, Object *ob, float lim)
|
||||
{
|
||||
using namespace blender;
|
||||
uiBlock *block = (layout) ? uiLayoutAbsoluteBlock(layout) : nullptr;
|
||||
uiBlock *block = (layout) ? layout->absolute_block() : nullptr;
|
||||
TransformProperties *tfp = v3d_transform_props_ensure(v3d);
|
||||
TransformMedian median_basis, ve_median_basis;
|
||||
int tot, totedgedata, totcurvedata, totlattdata, totcurvebweight;
|
||||
@@ -1311,7 +1311,7 @@ static void v3d_editvertex_buts(
|
||||
|
||||
static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d, Object *ob)
|
||||
{
|
||||
uiBlock *block = (layout) ? uiLayoutAbsoluteBlock(layout) : nullptr;
|
||||
uiBlock *block = (layout) ? layout->absolute_block() : nullptr;
|
||||
TransformProperties *tfp = v3d_transform_props_ensure(v3d);
|
||||
const bool is_editable = ID_IS_EDITABLE(&ob->id);
|
||||
|
||||
@@ -1428,7 +1428,7 @@ static void update_active_vertex_weight(bContext *C, void *arg1, void * /*arg2*/
|
||||
|
||||
static void view3d_panel_vgroup(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiBlock *block = uiLayoutAbsoluteBlock(panel->layout);
|
||||
uiBlock *block = panel->layout->absolute_block();
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
|
||||
@@ -239,7 +239,7 @@ static void image_panel_uv(const bContext *C, Panel *panel)
|
||||
{
|
||||
uiBlock *block;
|
||||
|
||||
block = uiLayoutAbsoluteBlock(panel->layout);
|
||||
block = panel->layout->absolute_block();
|
||||
UI_block_func_handle_set(block, do_uvedit_vertex, nullptr);
|
||||
|
||||
uvedit_vertex_buttons(C, block);
|
||||
|
||||
Reference in New Issue
Block a user