Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-04-29 07:32:55 +0300
committerHans Goudey <h.goudey@me.com>2021-04-29 07:32:55 +0300
commit2038250c62fa3753fcc31129f8dd5f4fdf08e2e7 (patch)
tree013d5ca0f535ebae01f3b03731cc507520a414c7
parent38ebac86cc28e53d7640dcc8ce3bc4edbb8f2a1b (diff)
WIP changes to compiling interface directory as C++ codetemp-interface-cpp
-rw-r--r--source/blender/editors/interface/CMakeLists.txt42
-rw-r--r--source/blender/editors/interface/interface.cc (renamed from source/blender/editors/interface/interface.c)159
-rw-r--r--source/blender/editors/interface/interface_button_group.cc (renamed from source/blender/editors/interface/interface_button_group.c)14
-rw-r--r--source/blender/editors/interface/interface_context_menu.cc (renamed from source/blender/editors/interface/interface_context_menu.c)27
-rw-r--r--source/blender/editors/interface/interface_draw.cc (renamed from source/blender/editors/interface/interface_draw.c)297
-rw-r--r--source/blender/editors/interface/interface_handlers.cc (renamed from source/blender/editors/interface/interface_handlers.c)204
-rw-r--r--source/blender/editors/interface/interface_icons_event.cc (renamed from source/blender/editors/interface/interface_icons_event.c)16
-rw-r--r--source/blender/editors/interface/interface_intern.h4
-rw-r--r--source/blender/editors/interface/interface_layout.cc (renamed from source/blender/editors/interface/interface_layout.c)356
-rw-r--r--source/blender/editors/interface/interface_panel.cc (renamed from source/blender/editors/interface/interface_panel.c)112
-rw-r--r--source/blender/editors/interface/interface_query.cc (renamed from source/blender/editors/interface/interface_query.c)10
-rw-r--r--source/blender/editors/interface/interface_region_color_picker.cc (renamed from source/blender/editors/interface/interface_region_color_picker.c)25
-rw-r--r--source/blender/editors/interface/interface_region_hud.cc (renamed from source/blender/editors/interface/interface_region_hud.c)41
-rw-r--r--source/blender/editors/interface/interface_region_popup.cc (renamed from source/blender/editors/interface/interface_region_popup.c)10
-rw-r--r--source/blender/editors/interface/interface_region_search.cc (renamed from source/blender/editors/interface/interface_region_search.c)50
-rw-r--r--source/blender/editors/interface/interface_regions.cc (renamed from source/blender/editors/interface/interface_regions.c)2
-rw-r--r--source/blender/editors/interface/interface_style.cc (renamed from source/blender/editors/interface/interface_style.c)16
-rw-r--r--source/blender/editors/interface/interface_template_search_menu.cc (renamed from source/blender/editors/interface/interface_template_search_menu.c)130
-rw-r--r--source/blender/editors/interface/interface_template_search_operator.cc (renamed from source/blender/editors/interface/interface_template_search_operator.c)4
-rw-r--r--source/blender/editors/interface/interface_templates.cc (renamed from source/blender/editors/interface/interface_templates.c)0
-rw-r--r--source/blender/editors/interface/interface_undo.cc (renamed from source/blender/editors/interface/interface_undo.c)7
-rw-r--r--source/blender/editors/interface/interface_utils.cc (renamed from source/blender/editors/interface/interface_utils.c)27
-rw-r--r--source/blender/editors/interface/resources.cc (renamed from source/blender/editors/interface/resources.c)14
23 files changed, 793 insertions, 774 deletions
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index 421019bebb8..d221dde4fae 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -36,12 +36,12 @@ set(INC
)
set(SRC
- interface.c
+ interface.cc
interface_align.c
interface_anim.c
- interface_button_group.c
- interface_context_menu.c
- interface_draw.c
+ interface_button_group.cc
+ interface_context_menu.cc
+ interface_draw.cc
interface_eyedropper.c
interface_eyedropper_color.c
interface_eyedropper_colorband.c
@@ -49,30 +49,30 @@ set(SRC
interface_eyedropper_depth.c
interface_eyedropper_driver.c
interface_eyedropper_gpencil_color.c
- interface_handlers.c
+ interface_handlers.cc
interface_icons.c
- interface_icons_event.c
- interface_layout.c
+ interface_icons_event.cc
+ interface_layout.cc
interface_ops.c
- interface_panel.c
- interface_query.c
- interface_region_color_picker.c
- interface_region_hud.c
+ interface_panel.cc
+ interface_query.cc
+ interface_region_color_picker.cc
+ interface_region_hud.cc
interface_region_menu_pie.c
interface_region_menu_popup.c
interface_region_popover.c
- interface_region_popup.c
- interface_region_search.c
+ interface_region_popup.cc
+ interface_region_search.cc
interface_region_tooltip.c
- interface_regions.c
- interface_style.c
- interface_template_search_menu.c
- interface_template_search_operator.c
- interface_templates.c
- interface_undo.c
- interface_utils.c
+ interface_regions.cc
+ interface_style.cc
+ interface_template_search_menu.cc
+ interface_template_search_operator.cc
+ interface_templates.cc
+ interface_undo.cc
+ interface_utils.cc
interface_widgets.c
- resources.c
+ resources.cc
view2d.c
view2d_draw.c
view2d_gizmo_navigate.c
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.cc
index 90d604b3190..4e06e1def27 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.cc
@@ -36,7 +36,7 @@
#include "DNA_userdef_types.h"
#include "DNA_workspace_types.h"
-#include "BLI_alloca.h"
+#include "BLI_array.hh"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rect.h"
@@ -88,6 +88,8 @@
#include "interface_intern.h"
+using blender::Array;
+
/* prototypes. */
static void ui_but_to_pixelrect(struct rcti *rect,
const struct ARegion *region,
@@ -269,7 +271,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block)
}
rcti rect;
- ui_but_to_pixelrect(&rect, region, block, block->buttons.last);
+ ui_but_to_pixelrect(&rect, region, block, (uiBut *)block->buttons.last);
const float buttons_width = (float)rect.xmax + UI_HEADER_OFFSET;
const float region_width = (float)region->sizex * U.dpi_fac;
@@ -278,7 +280,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block)
}
/* We could get rid of this loop if we agree on a max number of spacer */
- int *spacers_pos = alloca(sizeof(*spacers_pos) * (size_t)sepr_flex_len);
+ Array<int, 64> spacers_pos(sepr_flex_len);
int i = 0;
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (but->type == UI_BTYPE_SEPR_SPACER) {
@@ -338,7 +340,7 @@ static void ui_update_window_matrix(const wmWindow *window, const ARegion *regio
*/
void ui_region_winrct_get_no_margin(const struct ARegion *region, struct rcti *r_rect)
{
- uiBlock *block = region->uiblocks.first;
+ uiBlock *block = (uiBlock *)region->uiblocks.first;
if (block && (block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_RADIAL) == 0) {
BLI_rcti_rctf_copy_floor(r_rect, &block->rect);
BLI_rcti_translate(r_rect, region->winrct.xmin, region->winrct.ymin);
@@ -373,7 +375,7 @@ static void ui_block_bounds_calc_text(uiBlock *block, float offset)
UI_fontstyle_set(&style->widget);
- uiBut *init_col_bt = block->buttons.first;
+ uiBut *init_col_bt = (uiBut *)block->buttons.first;
LISTBASE_FOREACH (uiBut *, bt, &block->buttons) {
if (!ELEM(bt->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) {
j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr));
@@ -465,7 +467,7 @@ void ui_block_bounds_calc(uiBlock *block)
block->rect.xmax = block->rect.xmin + max_ff(BLI_rctf_size_x(&block->rect), block->minbounds);
/* hardcoded exception... but that one is annoying with larger safety */
- uiBut *bt = block->buttons.first;
+ uiBut *bt = (uiBut *)block->buttons.first;
const int xof = ((bt && STRPREFIX(bt->str, "ERROR")) ? 10 : 40) * U.dpi_fac;
block->safety.xmin = block->rect.xmin - xof;
@@ -499,8 +501,8 @@ static void ui_block_bounds_calc_centered(wmWindow *window, uiBlock *block)
static void ui_block_bounds_calc_centered_pie(uiBlock *block)
{
const int xy[2] = {
- block->pie_data.pie_center_spawned[0],
- block->pie_data.pie_center_spawned[1],
+ (int)block->pie_data.pie_center_spawned[0],
+ (int)block->pie_data.pie_center_spawned[1],
};
UI_block_translate(block, xy[0], xy[1]);
@@ -1178,7 +1180,7 @@ static bool ui_but_event_operator_string_from_operator(const bContext *C,
{
BLI_assert(but->optype != NULL);
bool found = false;
- IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
+ IDProperty *prop = (but->opptr) ? (IDProperty *)but->opptr->data : NULL;
if (WM_key_event_operator_string(
C, but->optype->idname, but->opcontext, prop, true, buf, buf_len)) {
@@ -1226,27 +1228,20 @@ static bool ui_but_event_operator_string_from_panel(const bContext *C,
const IDPropertyTemplate val = {0};
IDProperty *prop_panel = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
IDP_AddToGroup(prop_panel, IDP_NewString(pt->idname, "name", sizeof(pt->idname)));
- IDP_AddToGroup(prop_panel,
- IDP_New(IDP_INT,
- &(IDPropertyTemplate){
- .i = pt->space_type,
- },
- "space_type"));
- IDP_AddToGroup(prop_panel,
- IDP_New(IDP_INT,
- &(IDPropertyTemplate){
- .i = pt->region_type,
- },
- "region_type"));
+
+ IDPropertyTemplate space_type{0};
+ space_type.i = pt->space_type;
+ IDP_AddToGroup(prop_panel, IDP_New(IDP_INT, &space_type, "space_type"));
+
+ IDPropertyTemplate region_type{0};
+ space_type.i = pt->region_type;
+ IDP_AddToGroup(prop_panel, IDP_New(IDP_INT, &region_type, "region_type"));
for (int i = 0; i < 2; i++) {
/* FIXME(campbell): We can't reasonably search all configurations - long term. */
- IDP_ReplaceInGroup(prop_panel,
- IDP_New(IDP_INT,
- &(IDPropertyTemplate){
- .i = i,
- },
- "keep_open"));
+ IDPropertyTemplate keep_open{0};
+ keep_open.i = i;
+ IDP_ReplaceInGroup(prop_panel, IDP_New(IDP_INT, &keep_open, "keep_open"));
if (WM_key_event_operator_string(
C, "WM_OT_call_panel", WM_OP_INVOKE_REGION_WIN, prop_panel, true, buf, buf_len)) {
found = true;
@@ -1441,11 +1436,9 @@ static bool ui_but_event_property_operator_string(const bContext *C,
IDProperty *prop_value;
if (prop_enum_value_is_int) {
const int value = item[index].value;
- prop_value = IDP_New(IDP_INT,
- &(IDPropertyTemplate){
- .i = value,
- },
- prop_enum_value_id);
+ IDPropertyTemplate idp_template{0};
+ idp_template.i = value;
+ prop_value = IDP_New(IDP_INT, &idp_template, prop_enum_value_id);
}
else {
const char *id = item[index].identifier;
@@ -1508,7 +1501,7 @@ static bool ui_but_event_property_operator_string(const bContext *C,
*
* --Matt 07/2006
*/
-const char ui_radial_dir_order[8] = {
+static const RadialDirection ui_radial_dir_order[8] = {
UI_RADIAL_W,
UI_RADIAL_E,
UI_RADIAL_S,
@@ -1613,14 +1606,15 @@ static PointerRNA *ui_but_extra_operator_icon_add_ptr(uiBut *but,
short opcontext,
int icon)
{
- uiButExtraOpIcon *extra_op_icon = MEM_mallocN(sizeof(*extra_op_icon), __func__);
+ uiButExtraOpIcon *extra_op_icon = (uiButExtraOpIcon *)MEM_mallocN(sizeof(*extra_op_icon),
+ __func__);
extra_op_icon->icon = (BIFIconID)icon;
- extra_op_icon->optype_params = MEM_callocN(sizeof(*extra_op_icon->optype_params),
- "uiButExtraOpIcon.optype_params");
+ extra_op_icon->optype_params = (wmOperatorCallParams *)MEM_callocN(
+ sizeof(*extra_op_icon->optype_params), "uiButExtraOpIcon.optype_params");
extra_op_icon->optype_params->optype = optype;
- extra_op_icon->optype_params->opptr = MEM_callocN(sizeof(*extra_op_icon->optype_params->opptr),
- "uiButExtraOpIcon.optype_params.opptr");
+ extra_op_icon->optype_params->opptr = (PointerRNA *)MEM_callocN(
+ sizeof(*extra_op_icon->optype_params->opptr), "uiButExtraOpIcon.optype_params.opptr");
WM_operator_properties_create_ptr(extra_op_icon->optype_params->opptr,
extra_op_icon->optype_params->optype);
extra_op_icon->optype_params->opcontext = opcontext;
@@ -1773,7 +1767,7 @@ void UI_block_update_from_old(const bContext *C, uiBlock *block)
return;
}
- uiBut *but_old = block->oldblock->buttons.first;
+ uiBut *but_old = (uiBut *)block->oldblock->buttons.first;
if (BLI_listbase_is_empty(&block->oldblock->butstore) == false) {
UI_butstore_update(block);
@@ -2074,15 +2068,11 @@ static void ui_block_message_subscribe(ARegion *region, struct wmMsgBus *mbus, u
(but_prev->rnapoin.data == but->rnapoin.data) &&
(but_prev->rnapoin.owner_id == but->rnapoin.owner_id)) == false) {
/* TODO: could make this into utility function. */
- WM_msg_subscribe_rna(mbus,
- &but->rnapoin,
- but->rnaprop,
- &(const wmMsgSubscribeValue){
- .owner = region,
- .user_data = region,
- .notify = ED_region_do_msg_notify_tag_redraw,
- },
- __func__);
+ wmMsgSubscribeValue subscribe_value = {0};
+ subscribe_value.owner = region;
+ subscribe_value.owner_data = region;
+ subscribe_value.notify = ED_region_do_msg_notify_tag_redraw;
+ WM_msg_subscribe_rna(mbus, &but->rnapoin, but->rnaprop, &subscribe_value, __func__);
but_prev = but;
}
}
@@ -2620,7 +2610,7 @@ static double ui_get_but_scale_unit(uiBut *but, double value)
/* Time unit is a bit special, not handled by BKE_scene_unit_scale() for now. */
if (unit_type == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */
- Scene *scene = CTX_data_scene(but->block->evil_C);
+ Scene *scene = CTX_data_scene((bContext *)but->block->evil_C);
return FRA2TIME(value);
}
return BKE_scene_unit_scale(unit, RNA_SUBTYPE_UNIT_VALUE(unit_type), value);
@@ -2756,7 +2746,8 @@ void ui_but_string_get_ex(uiBut *but,
else if (type == PROP_ENUM) {
/* RNA enum */
const int value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
- if (RNA_property_enum_name(but->block->evil_C, &but->rnapoin, but->rnaprop, value, &buf)) {
+ if (RNA_property_enum_name(
+ (bContext *)but->block->evil_C, &but->rnapoin, but->rnaprop, value, &buf)) {
BLI_strncpy(str, buf, maxlen);
buf = str;
}
@@ -2873,7 +2864,7 @@ char *ui_but_string_get_dynamic(uiBut *but, int *r_str_size)
const int value = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
const char *value_id;
if (!RNA_property_enum_name(
- but->block->evil_C, &but->rnapoin, but->rnaprop, value, &value_id)) {
+ (bContext *)but->block->evil_C, &but->rnapoin, but->rnaprop, value, &value_id)) {
value_id = "";
}
@@ -3016,7 +3007,7 @@ static void ui_but_string_set_internal(uiBut *but, const char *str, size_t str_l
str_len += 1;
if (str_len > UI_MAX_NAME_STR) {
- but->str = MEM_mallocN(str_len, "ui_def_but str");
+ but->str = (char *)MEM_mallocN(str_len, "ui_def_but str");
}
else {
but->str = but->strdata;
@@ -3082,7 +3073,7 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
if (type == PROP_ENUM) {
int value;
if (RNA_property_enum_value(
- but->block->evil_C, &but->rnapoin, but->rnaprop, str, &value)) {
+ (bContext *)but->block->evil_C, &but->rnapoin, but->rnaprop, str, &value)) {
RNA_property_enum_set(&but->rnapoin, but->rnaprop, value);
return true;
}
@@ -3398,7 +3389,7 @@ void UI_block_free(const bContext *C, uiBlock *block)
UI_butstore_clear(block);
uiBut *but;
- while ((but = BLI_pophead(&block->buttons))) {
+ while ((but = (uiBut *)BLI_pophead(&block->buttons))) {
ui_but_free(C, but);
}
@@ -3445,7 +3436,7 @@ void UI_blocklist_draw(const bContext *C, const ListBase *lb)
void UI_blocklist_free(const bContext *C, ListBase *lb)
{
uiBlock *block;
- while ((block = BLI_pophead(lb))) {
+ while ((block = (uiBlock *)BLI_pophead(lb))) {
UI_block_free(C, block);
}
}
@@ -3473,7 +3464,7 @@ void UI_block_region_set(uiBlock *block, ARegion *region)
/* each listbase only has one block with this name, free block
* if is already there so it can be rebuilt from scratch */
if (lb) {
- oldblock = BLI_findstring(lb, block->name, offsetof(uiBlock, name));
+ oldblock = (uiBlock *)BLI_findstring(lb, block->name, offsetof(uiBlock, name));
if (oldblock) {
oldblock->active = false;
@@ -3493,7 +3484,7 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, eU
wmWindow *window = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
- uiBlock *block = MEM_callocN(sizeof(uiBlock), "uiBlock");
+ uiBlock *block = (uiBlock *)MEM_callocN(sizeof(uiBlock), "uiBlock");
block->active = true;
block->emboss = emboss;
block->evil_C = (void *)C; /* XXX */
@@ -3509,7 +3500,7 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, eU
STRNCPY(block->display_device, scene->display_settings.display_device);
/* copy to avoid crash when scene gets deleted with ui still open */
- block->unit = MEM_mallocN(sizeof(scene->unit), "UI UnitSettings");
+ block->unit = (UnitSettings *)MEM_mallocN(sizeof(scene->unit), "UI UnitSettings");
memcpy(block->unit, &scene->unit, sizeof(scene->unit));
}
else {
@@ -3699,12 +3690,15 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
const int value_enum = RNA_property_enum_get(&but->rnapoin, but->rnaprop);
EnumPropertyItem item;
- if (RNA_property_enum_item_from_value_gettexted(
- but->block->evil_C, &but->rnapoin, but->rnaprop, value_enum, &item)) {
+ if (RNA_property_enum_item_from_value_gettexted((bContext *)but->block->evil_C,
+ &but->rnapoin,
+ but->rnaprop,
+ value_enum,
+ &item)) {
const size_t slen = strlen(item.name);
ui_but_string_free_internal(but);
ui_but_string_set_internal(but, item.name, slen);
- but->icon = item.icon;
+ but->icon = (BIFIconID)item.icon;
}
}
}
@@ -3922,7 +3916,7 @@ static uiBut *ui_but_alloc(const eButType type)
const char *alloc_str;
ui_but_alloc_info(type, &alloc_size, &alloc_str, NULL);
- return MEM_callocN(alloc_size, alloc_str);
+ return (uiBut *)MEM_callocN(alloc_size, alloc_str);
}
/**
@@ -3956,7 +3950,7 @@ uiBut *ui_but_change_type(uiBut *but, eButType new_type)
const bool has_str_ptr_to_self = but->str == but->strdata;
const bool has_poin_ptr_to_self = but->poin == (char *)but;
- but = MEM_recallocN_id(but, alloc_size, alloc_str);
+ but = (uiBut *)MEM_recallocN_id(but, alloc_size, alloc_str);
but->type = new_type;
if (has_str_ptr_to_self) {
but->str = but->strdata;
@@ -3974,7 +3968,7 @@ uiBut *ui_but_change_type(uiBut *but, eButType new_type)
ui_button_group_replace_but_ptr(uiLayoutGetBlock(but->layout), old_but_ptr, but);
}
if (UI_editsource_enable_check()) {
- UI_editsource_but_replace(old_but_ptr, but);
+ UI_editsource_but_replace((const uiBut *)old_but_ptr, but);
}
}
@@ -4022,10 +4016,10 @@ static uiBut *ui_def_but(uiBlock *block,
}
}
- uiBut *but = ui_but_alloc(type & BUTTYPE);
+ uiBut *but = ui_but_alloc((eButType)(type & BUTTYPE));
- but->type = type & BUTTYPE;
- but->pointype = type & UI_BUT_POIN_TYPES;
+ but->type = (eButType)(type & BUTTYPE);
+ but->pointype = (eButPointerType)(type & UI_BUT_POIN_TYPES);
but->bit = type & UI_BUT_POIN_BIT;
but->bitnr = type & 31;
but->icon = ICON_NONE;
@@ -4041,7 +4035,7 @@ static uiBut *ui_def_but(uiBlock *block,
but->rect.xmax = but->rect.xmin + width;
but->rect.ymax = but->rect.ymin + height;
- but->poin = poin;
+ but->poin = (char *)poin;
but->hardmin = but->softmin = min;
but->hardmax = but->softmax = max;
but->a1 = a1;
@@ -4153,7 +4147,8 @@ static uiBut *ui_def_but(uiBlock *block,
void ui_def_but_icon(uiBut *but, const int icon, const int flag)
{
if (icon) {
- ui_icon_ensure_deferred(but->block->evil_C, icon, (flag & UI_BUT_ICON_PREVIEW) != 0);
+ ui_icon_ensure_deferred(
+ (bContext *)but->block->evil_C, icon, (flag & UI_BUT_ICON_PREVIEW) != 0);
}
but->icon = (BIFIconID)icon;
but->flag |= flag;
@@ -4186,7 +4181,7 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
bool free;
RNA_property_enum_items_gettexted(
- block->evil_C, &but->rnapoin, but->rnaprop, &item_array, NULL, &free);
+ (bContext *)block->evil_C, &but->rnapoin, but->rnaprop, &item_array, NULL, &free);
/* We don't want nested rows, cols in menus. */
UI_block_layout_set_current(block, layout);
@@ -4351,8 +4346,8 @@ static void ui_def_but_rna__menu(bContext *UNUSED(C), uiLayout *layout, void *bu
static void ui_def_but_rna__panel_type(bContext *C, uiLayout *layout, void *but_p)
{
- uiBut *but = but_p;
- const char *panel_type = but->func_argN;
+ uiBut *but = (uiBut *)but_p;
+ const char *panel_type = (const char *)but->func_argN;
PanelType *pt = WM_paneltype_find(panel_type, true);
if (pt) {
ui_item_paneltype_func(C, layout, pt);
@@ -4380,8 +4375,8 @@ bool ui_but_menu_draw_as_popover(const uiBut *but)
static void ui_def_but_rna__menu_type(bContext *C, uiLayout *layout, void *but_p)
{
- uiBut *but = but_p;
- const char *menu_type = but->func_argN;
+ uiBut *but = (uiBut *)but_p;
+ const char *menu_type = (const char *)but->func_argN;
MenuType *mt = WM_menutype_find(menu_type, true);
if (mt) {
ui_item_menutype_func(C, layout, mt);
@@ -4446,7 +4441,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
if ((proptype == PROP_ENUM) && ELEM(type, UI_BTYPE_MENU, UI_BTYPE_ROW, UI_BTYPE_LISTROW)) {
bool free;
const EnumPropertyItem *item;
- RNA_property_enum_items(block->evil_C, ptr, prop, &item, NULL, &free);
+ RNA_property_enum_items((bContext *)block->evil_C, ptr, prop, &item, NULL, &free);
int value;
/* UI_BTYPE_MENU is handled a little differently here */
@@ -4727,7 +4722,7 @@ uiBut *uiDefButImage(
uiBut *uiDefButAlert(uiBlock *block, int icon, int x, int y, short width, short height)
{
- struct ImBuf *ibuf = UI_icon_alert_imbuf_get(icon);
+ struct ImBuf *ibuf = UI_icon_alert_imbuf_get((eAlertIcon)icon);
bTheme *btheme = UI_GetTheme();
return uiDefButImage(block, ibuf, x, y, width, height, btheme->tui.wcol_menu_back.text);
}
@@ -4783,10 +4778,10 @@ AutoComplete *UI_autocomplete_begin(const char *startname, size_t maxlen)
{
AutoComplete *autocpl;
- autocpl = MEM_callocN(sizeof(AutoComplete), "AutoComplete");
+ autocpl = (AutoComplete *)MEM_callocN(sizeof(AutoComplete), "AutoComplete");
autocpl->maxlen = maxlen;
autocpl->matches = 0;
- autocpl->truncate = MEM_callocN(sizeof(char) * maxlen, "AutoCompleteTruncate");
+ autocpl->truncate = (char *)MEM_callocN(sizeof(char) * maxlen, "AutoCompleteTruncate");
autocpl->startname = startname;
return autocpl;
@@ -6142,7 +6137,7 @@ void UI_but_drag_set_asset(uiBut *but,
struct ImBuf *imb,
float scale)
{
- wmDragAsset *asset_drag = MEM_mallocN(sizeof(*asset_drag), "wmDragAsset");
+ wmDragAsset *asset_drag = (wmDragAsset *)MEM_mallocN(sizeof(*asset_drag), "wmDragAsset");
BLI_strncpy(asset_drag->name, name, sizeof(asset_drag->name));
asset_drag->path = path;
@@ -6218,7 +6213,7 @@ void UI_but_drag_set_image(
PointerRNA *UI_but_operator_ptr_get(uiBut *but)
{
if (but->optype && !but->opptr) {
- but->opptr = MEM_callocN(sizeof(PointerRNA), "uiButOpPtr");
+ but->opptr = (PointerRNA *)MEM_callocN(sizeof(PointerRNA), "uiButOpPtr");
WM_operator_properties_create_ptr(but->opptr, but->optype);
}
@@ -6724,7 +6719,7 @@ static void operator_enum_search_update_fn(const struct bContext *C,
RNA_property_identifier(prop));
}
else {
- PointerRNA *ptr = UI_but_operator_ptr_get(but); /* Will create it if needed! */
+ PointerRNA *ptr = UI_but_operator_ptr_get((uiBut *)but); /* Will create it if needed! */
bool do_free;
const EnumPropertyItem *all_items;
@@ -6760,7 +6755,7 @@ static void operator_enum_search_update_fn(const struct bContext *C,
static void operator_enum_search_exec_fn(struct bContext *UNUSED(C), void *but, void *arg2)
{
wmOperatorType *ot = ((uiBut *)but)->optype;
- PointerRNA *opptr = UI_but_operator_ptr_get(but); /* Will create it if needed! */
+ PointerRNA *opptr = UI_but_operator_ptr_get((uiBut *)but); /* Will create it if needed! */
if (ot) {
if (ot->prop) {
diff --git a/source/blender/editors/interface/interface_button_group.c b/source/blender/editors/interface/interface_button_group.cc
index 4e7da4ada33..e84ea59c786 100644
--- a/source/blender/editors/interface/interface_button_group.c
+++ b/source/blender/editors/interface/interface_button_group.cc
@@ -32,29 +32,29 @@
* Every function that adds a set of buttons must create another group,
* then #ui_def_but adds buttons to the current group (the last).
*/
-void ui_block_new_button_group(uiBlock *block, uiButtonGroupFlag flag)
+uiButtonGroup *ui_block_new_button_group(uiBlock *block)
{
/* Don't create a new group if there is a "lock" on new groups. */
if (!BLI_listbase_is_empty(&block->button_groups)) {
- uiButtonGroup *last_button_group = block->button_groups.last;
+ uiButtonGroup *last_button_group = (uiButtonGroup *)block->button_groups.last;
if (last_button_group->flag & UI_BUTTON_GROUP_LOCK) {
- return;
+ return last_button_group;
}
}
- uiButtonGroup *new_group = MEM_mallocN(sizeof(uiButtonGroup), __func__);
+ uiButtonGroup *new_group = (uiButtonGroup *)MEM_mallocN(sizeof(uiButtonGroup), __func__);
BLI_listbase_clear(&new_group->buttons);
- new_group->flag = flag;
BLI_addtail(&block->button_groups, new_group);
+ return new_group;
}
void ui_button_group_add_but(uiBlock *block, uiBut *but)
{
if (BLI_listbase_is_empty(&block->button_groups)) {
- ui_block_new_button_group(block, 0);
+ ui_block_new_button_group(block);
}
- uiButtonGroup *current_button_group = block->button_groups.last;
+ uiButtonGroup *current_button_group = (uiButtonGroup *)block->button_groups.last;
/* We can't use the button directly because adding it to
* this list would mess with its prev and next pointers. */
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.cc
index b142e383df0..ff514aa68bd 100644
--- a/source/blender/editors/interface/interface_context_menu.c
+++ b/source/blender/editors/interface/interface_context_menu.cc
@@ -104,7 +104,9 @@ static const char *shortcut_get_operator_property(bContext *C, uiBut *but, IDPro
{
if (but->optype) {
/* Operator */
- *r_prop = (but->opptr && but->opptr->data) ? IDP_CopyProperty(but->opptr->data) : NULL;
+ *r_prop = (but->opptr && but->opptr->data) ?
+ IDP_CopyProperty((const IDProperty *)but->opptr->data) :
+ NULL;
return but->optype->idname;
}
@@ -205,8 +207,8 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *region, void *arg)
uiItemL(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), ICON_HAND);
uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
- UI_block_bounds_set_popup(
- block, 6 * U.dpi_fac, (const int[2]){-100 * U.dpi_fac, 36 * U.dpi_fac});
+ const int bounds_offset[2] = {int(-100 * U.dpi_fac), int(36 * U.dpi_fac)};
+ UI_block_bounds_set_popup(block, 6 * U.dpi_fac, bounds_offset);
shortcut_free_operator_property(prop);
@@ -338,7 +340,7 @@ static bool ui_but_is_user_menu_compatible(bContext *C, uiBut *but)
static bUserMenuItem *ui_but_user_menu_find(bContext *C, uiBut *but, bUserMenu *um)
{
if (but->optype) {
- IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
+ IDProperty *prop = (but->opptr) ? (IDProperty *)but->opptr->data : NULL;
return (bUserMenuItem *)ED_screen_user_menu_item_find_operator(
&um->items, but->optype, prop, but->opcontext);
}
@@ -413,8 +415,11 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
#endif
}
}
- ED_screen_user_menu_item_add_operator(
- &um->items, drawstr, but->optype, but->opptr ? but->opptr->data : NULL, but->opcontext);
+ ED_screen_user_menu_item_add_operator(&um->items,
+ drawstr,
+ but->optype,
+ but->opptr ? (const IDProperty *)but->opptr->data : NULL,
+ but->opcontext);
}
else if (but->rnaprop) {
/* Note: 'member_id' may be a path. */
@@ -441,7 +446,7 @@ static void ui_but_user_menu_add(bContext *C, uiBut *but, bUserMenu *um)
static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *UNUSED(arg2))
{
- uiBut *but = arg1;
+ uiBut *but = (uiBut *)arg1;
bUserMenu *um = ED_screen_user_menu_ensure(C);
U.runtime.is_dirty = true;
ui_but_user_menu_add(C, but, um);
@@ -449,8 +454,8 @@ static void popup_user_menu_add_or_replace_func(bContext *C, void *arg1, void *U
static void popup_user_menu_remove_func(bContext *UNUSED(C), void *arg1, void *arg2)
{
- bUserMenu *um = arg1;
- bUserMenuItem *umi = arg2;
+ bUserMenu *um = (bUserMenu *)arg1;
+ bUserMenuItem *umi = (bUserMenuItem *)arg2;
U.runtime.is_dirty = true;
ED_screen_user_menu_item_remove(&um->items, umi);
}
@@ -953,7 +958,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but)
/* If the button represents an id, it can set the "id" context pointer. */
if (U.experimental.use_asset_browser && ED_asset_can_make_single_from_context(C)) {
- ID *id = CTX_data_pointer_get_type(C, "id", &RNA_ID).data;
+ ID *id = (ID *)CTX_data_pointer_get_type(C, "id", &RNA_ID).data;
/* Gray out items depending on if data-block is an asset. Preferably this could be done via
* operator poll, but that doesn't work since the operator also works with "selected_ids",
@@ -1278,7 +1283,7 @@ void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *panel)
/* evil, force shortcut flag */
{
uiBlock *block = uiLayoutGetBlock(layout);
- uiBut *but = block->buttons.last;
+ uiBut *but = (uiBut *)block->buttons.last;
but->flag |= UI_BUT_HAS_SEP_CHAR;
but->drawflag |= UI_BUT_HAS_SHORTCUT;
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.cc
index 40cfcaea883..5dde7fa5921 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.cc
@@ -91,36 +91,36 @@ void UI_draw_roundbox_4fv_ex(const rctf *rect,
{
/* WATCH: This is assuming the ModelViewProjectionMatrix is area pixel space.
* If it has been scaled, then it's no longer valid. */
- uiWidgetBaseParameters widget_params = {
- .recti.xmin = rect->xmin + outline_width,
- .recti.ymin = rect->ymin + outline_width,
- .recti.xmax = rect->xmax - outline_width,
- .recti.ymax = rect->ymax - outline_width,
- .rect = *rect,
- .radi = rad,
- .rad = rad,
- .round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f,
- .round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f,
- .round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f,
- .round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f,
- .color_inner1[0] = inner1 ? inner1[0] : 0.0f,
- .color_inner1[1] = inner1 ? inner1[1] : 0.0f,
- .color_inner1[2] = inner1 ? inner1[2] : 0.0f,
- .color_inner1[3] = inner1 ? inner1[3] : 0.0f,
- .color_inner2[0] = inner2 ? inner2[0] : inner1 ? inner1[0] : 0.0f,
- .color_inner2[1] = inner2 ? inner2[1] : inner1 ? inner1[1] : 0.0f,
- .color_inner2[2] = inner2 ? inner2[2] : inner1 ? inner1[2] : 0.0f,
- .color_inner2[3] = inner2 ? inner2[3] : inner1 ? inner1[3] : 0.0f,
- .color_outline[0] = outline ? outline[0] : inner1 ? inner1[0] : 0.0f,
- .color_outline[1] = outline ? outline[1] : inner1 ? inner1[1] : 0.0f,
- .color_outline[2] = outline ? outline[2] : inner1 ? inner1[2] : 0.0f,
- .color_outline[3] = outline ? outline[3] : inner1 ? inner1[3] : 0.0f,
- .shade_dir = shade_dir,
- .alpha_discard = 1.0f,
- };
+ uiWidgetBaseParameters params;
+ params.recti.xmin = rect->xmin + outline_width;
+ params.recti.ymin = rect->ymin + outline_width;
+ params.recti.xmax = rect->xmax - outline_width;
+ params.recti.ymax = rect->ymax - outline_width;
+ params.rect = *rect;
+ params.radi = rad;
+ params.rad = rad;
+ params.round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f;
+ params.round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f;
+ params.round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f;
+ params.round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f;
+ params.color_inner1[0] = inner1 ? inner1[0] : 0.0f;
+ params.color_inner1[1] = inner1 ? inner1[1] : 0.0f;
+ params.color_inner1[2] = inner1 ? inner1[2] : 0.0f;
+ params.color_inner1[3] = inner1 ? inner1[3] : 0.0f;
+ params.color_inner2[0] = inner2 ? inner2[0] : inner1 ? inner1[0] : 0.0f;
+ params.color_inner2[1] = inner2 ? inner2[1] : inner1 ? inner1[1] : 0.0f;
+ params.color_inner2[2] = inner2 ? inner2[2] : inner1 ? inner1[2] : 0.0f;
+ params.color_inner2[3] = inner2 ? inner2[3] : inner1 ? inner1[3] : 0.0f;
+ params.color_outline[0] = outline ? outline[0] : inner1 ? inner1[0] : 0.0f;
+ params.color_outline[1] = outline ? outline[1] : inner1 ? inner1[1] : 0.0f;
+ params.color_outline[2] = outline ? outline[2] : inner1 ? inner1[2] : 0.0f;
+ params.color_outline[3] = outline ? outline[3] : inner1 ? inner1[3] : 0.0f;
+ params.shade_dir = shade_dir;
+ params.alpha_discard = 1.0f;
+
GPUBatch *batch = ui_batch_roundbox_widget_get();
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
- GPU_batch_uniform_4fv_array(batch, "parameters", 11, (const float(*)[4]) & widget_params);
+ GPU_batch_uniform_4fv_array(batch, "parameters", 11, (const float(*)[4]) & params);
GPU_blend(GPU_BLEND_ALPHA);
GPU_batch_draw(batch);
GPU_blend(GPU_BLEND_NONE);
@@ -403,16 +403,13 @@ static void draw_scope_end(const rctf *rect)
/* outline */
UI_draw_roundbox_corner_set(UI_CNR_ALL);
const float color[4] = {0.0f, 0.0f, 0.0f, 0.5f};
- UI_draw_roundbox_4fv(
- &(const rctf){
- .xmin = rect->xmin - 1,
- .xmax = rect->xmax + 1,
- .ymin = rect->ymin,
- .ymax = rect->ymax + 1,
- },
- false,
- 3.0f,
- color);
+ const rctf box_rect{
+ rect->xmin - 1,
+ rect->xmax + 1,
+ rect->ymin,
+ rect->ymax + 1,
+ };
+ UI_draw_roundbox_4fv(&box_rect, false, 3.0f, color);
}
static void histogram_draw_one(float r,
@@ -490,10 +487,10 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
const bool is_line = (hist->flag & HISTO_FLAG_LINE) != 0;
rctf rect = {
- .xmin = (float)recti->xmin + 1,
- .xmax = (float)recti->xmax - 1,
- .ymin = (float)recti->ymin + 1,
- .ymax = (float)recti->ymax - 1,
+ (float)recti->xmin + 1,
+ (float)recti->xmax - 1,
+ (float)recti->ymin + 1,
+ (float)recti->ymax - 1,
};
const float w = BLI_rctf_size_x(&rect);
@@ -504,17 +501,15 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
float color[4];
UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- UI_draw_roundbox_4fv(
- &(const rctf){
- .xmin = rect.xmin - 1,
- .xmax = rect.xmax + 1,
- .ymin = rect.ymin - 1,
- .ymax = rect.ymax + 1,
- },
- true,
- 3.0f,
- color);
-
+ {
+ const rctf box_rect{
+ rect.xmin - 1,
+ rect.xmax + 1,
+ rect.ymin - 1,
+ rect.ymax + 1,
+ };
+ UI_draw_roundbox_4fv(&box_rect, true, 3.0f, color);
+ }
/* need scissor test, histogram can draw outside of boundary */
int scissor[4];
GPU_scissor_get(scissor);
@@ -620,10 +615,10 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
}
rctf rect = {
- .xmin = (float)recti->xmin + 1,
- .xmax = (float)recti->xmax - 1,
- .ymin = (float)recti->ymin + 1,
- .ymax = (float)recti->ymax - 1,
+ (float)recti->xmin + 1,
+ (float)recti->xmax - 1,
+ (float)recti->ymin + 1,
+ (float)recti->ymax - 1,
};
if (scopes->wavefrm_yfac < 0.5f) {
@@ -654,17 +649,15 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
float color[4];
UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- UI_draw_roundbox_4fv(
- &(const rctf){
- .xmin = rect.xmin - 1,
- .xmax = rect.xmax + 1,
- .ymin = rect.ymin - 1,
- .ymax = rect.ymax + 1,
- },
- true,
- 3.0f,
- color);
-
+ {
+ const rctf box_rect{
+ rect.xmin - 1,
+ rect.xmax + 1,
+ rect.ymin - 1,
+ rect.ymax + 1,
+ };
+ UI_draw_roundbox_4fv(&box_rect, true, 3.0f, color);
+ }
/* need scissor test, waveform can draw outside of boundary */
GPU_scissor_get(scissor);
GPU_scissor((rect.xmin - 1),
@@ -972,10 +965,10 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
};
rctf rect = {
- .xmin = (float)recti->xmin + 1,
- .xmax = (float)recti->xmax - 1,
- .ymin = (float)recti->ymin + 1,
- .ymax = (float)recti->ymax - 1,
+ (float)recti->xmin + 1,
+ (float)recti->xmax - 1,
+ (float)recti->ymin + 1,
+ (float)recti->ymax - 1,
};
const float w = BLI_rctf_size_x(&rect);
@@ -991,17 +984,16 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
float color[4];
UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- UI_draw_roundbox_4fv(
- &(const rctf){
- .xmin = rect.xmin - 1,
- .xmax = rect.xmax + 1,
- .ymin = rect.ymin - 1,
- .ymax = rect.ymax + 1,
- },
- true,
- 3.0f,
- color);
+ {
+ const rctf box_rect{
+ rect.xmin - 1,
+ rect.xmax + 1,
+ rect.ymin - 1,
+ rect.ymax + 1,
+ };
+ UI_draw_roundbox_4fv(&box_rect, true, 3.0f, color);
+ }
/* need scissor test, hvectorscope can draw outside of boundary */
int scissor[4];
GPU_scissor_get(scissor);
@@ -1374,18 +1366,16 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec
/* backdrop */
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- UI_draw_roundbox_3ub_alpha(
- &(const rctf){
- .xmin = rect->xmin,
- .xmax = rect->xmax,
- .ymin = rect->ymin,
- .ymax = rect->ymax,
- },
- true,
- 5.0f,
- wcol->inner,
- 255);
+ {
+ const rctf box_rect{
+ rect->xmin,
+ rect->xmax,
+ rect->ymin,
+ rect->ymax,
+ };
+ UI_draw_roundbox_3ub_alpha(&box_rect, true, 5.0f, wcol->inner, 255);
+ }
GPU_face_culling(GPU_CULL_BACK);
/* setup lights */
@@ -1519,10 +1509,10 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
int scissor[4];
GPU_scissor_get(scissor);
rcti scissor_new = {
- .xmin = rect->xmin,
- .ymin = rect->ymin,
- .xmax = rect->xmax,
- .ymax = rect->ymax,
+ rect->xmin,
+ rect->xmax,
+ rect->ymin,
+ rect->ymax,
};
const rcti scissor_region = {0, region->winx, 0, region->winy};
BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
@@ -1537,10 +1527,10 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol,
const float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */
rcti grid = {
- .xmin = rect->xmin + zoomx * (-offsx),
- .xmax = grid.xmin + zoomx,
- .ymin = rect->ymin + zoomy * (-offsy),
- .ymax = grid.ymin + zoomy,
+ rect->xmin + zoomx * (-offsx),
+ grid.xmin + zoomx,
+ rect->ymin + zoomy * (-offsy),
+ grid.ymin + zoomy,
};
ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f);
@@ -1793,10 +1783,10 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
int scissor[4];
GPU_scissor_get(scissor);
rcti scissor_new = {
- .xmin = rect->xmin,
- .ymin = rect->ymin,
- .xmax = rect->xmax,
- .ymax = rect->ymax,
+ rect->xmin,
+ rect->ymin,
+ rect->xmax,
+ rect->ymax,
};
const rcti scissor_region = {0, region->winx, 0, region->winy};
BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
@@ -1849,7 +1839,8 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
const uint tot_triangles = tot_points - 2;
/* Create array of the positions of the table's points. */
- float(*table_coords)[2] = MEM_mallocN(sizeof(*table_coords) * tot_points, "table x coords");
+ float(*table_coords)[2] = (float(*)[2])MEM_mallocN(sizeof(*table_coords) * tot_points,
+ "table x coords");
for (uint i = 0; i < (uint)PROF_TABLE_LEN(profile->path_len);
i++) { /* Only add the points from the table here. */
table_coords[i][0] = pts[i].x;
@@ -1888,7 +1879,8 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
}
/* Calculate the table point indices of the triangles for the profile's fill. */
- uint(*tri_indices)[3] = MEM_mallocN(sizeof(*tri_indices) * tot_triangles, "return tri indices");
+ uint(*tri_indices)[3] = (uint(*)[3])MEM_mallocN(sizeof(*tri_indices) * tot_triangles,
+ "return tri indices");
BLI_polyfill_calc(table_coords, tot_points, -1, tri_indices);
/* Draw the triangles for the profile fill. */
@@ -2052,10 +2044,10 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
rctf rect = {
- .xmin = (float)recti->xmin + 1,
- .xmax = (float)recti->xmax - 1,
- .ymin = (float)recti->ymin + 1,
- .ymax = (float)recti->ymax - 1,
+ (float)recti->xmin + 1,
+ (float)recti->xmax - 1,
+ (float)recti->ymin + 1,
+ (float)recti->ymax - 1,
};
const int width = BLI_rctf_size_x(&rect) + 1;
@@ -2074,16 +2066,13 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
if (scopes->track_disabled) {
const float color[4] = {0.7f, 0.3f, 0.3f, 0.3f};
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- UI_draw_roundbox_4fv(
- &(const rctf){
- .xmin = rect.xmin - 1,
- .xmax = rect.xmax + 1,
- .ymin = rect.ymin,
- .ymax = rect.ymax + 1,
- },
- true,
- 3.0f,
- color);
+ const rctf box_rect{
+ rect.xmin - 1,
+ rect.xmax + 1,
+ rect.ymin,
+ rect.ymax + 1,
+ };
+ UI_draw_roundbox_4fv(&box_rect, true, 3.0f, color);
ok = true;
}
@@ -2133,10 +2122,10 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_4fv(
&(const rctf){
- .xmin = rect.xmin - 1,
- .xmax = rect.xmax + 1,
- .ymin = rect.ymin,
- .ymax = rect.ymax + 1,
+ rect.xmin - 1,
+ rect.xmax + 1,
+ rect.ymin,
+ rect.ymax + 1,
},
true,
3.0f,
@@ -2202,16 +2191,13 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
if (!ok) {
const float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
UI_draw_roundbox_corner_set(UI_CNR_ALL);
- UI_draw_roundbox_4fv(
- &(const rctf){
- .xmin = rect.xmin - 1,
- .xmax = rect.xmax + 1,
- .ymin = rect.ymin,
- .ymax = rect.ymax + 1,
- },
- true,
- 3.0f,
- color);
+ const rctf box_rect{
+ rect.xmin - 1,
+ rect.xmax + 1,
+ rect.ymin,
+ rect.ymax + 1,
+ };
+ UI_draw_roundbox_4fv(&box_rect, true, 3.0f, color);
}
/* Restore scissor test. */
@@ -2356,23 +2342,22 @@ void ui_draw_dropshadow(
calpha += dalpha;
}
- uiWidgetBaseParameters widget_params = {
- .recti.xmin = rct->xmin,
- .recti.ymin = rct->ymin,
- .recti.xmax = rct->xmax,
- .recti.ymax = rct->ymax - 10.0f,
- .rect.xmin = rct->xmin - a,
- .rect.ymin = rct->ymin - a,
- .rect.xmax = rct->xmax + a,
- .rect.ymax = rct->ymax - 10.0f + a,
- .radi = rad,
- .rad = rad + a,
- .round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f,
- .round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f,
- .round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f,
- .round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f,
- .alpha_discard = 1.0f,
- };
+ uiWidgetBaseParameters widget_params;
+ widget_params.recti.xmin = rct->xmin;
+ widget_params.recti.ymin = rct->ymin;
+ widget_params.recti.xmax = rct->xmax;
+ widget_params.recti.ymax = rct->ymax - 10.0f;
+ widget_params.rect.xmin = rct->xmin - a;
+ widget_params.rect.ymin = rct->ymin - a;
+ widget_params.rect.xmax = rct->xmax + a;
+ widget_params.rect.ymax = rct->ymax - 10.0f + a;
+ widget_params.radi = rad;
+ widget_params.rad = rad + a;
+ widget_params.round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f;
+ widget_params.round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f;
+ widget_params.round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f;
+ widget_params.round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f;
+ widget_params.alpha_discard = 1.0f;
GPUBatch *batch = ui_batch_roundbox_shadow_get();
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW);
@@ -2384,10 +2369,10 @@ void ui_draw_dropshadow(
const float color[4] = {0.0f, 0.0f, 0.0f, 0.4f};
UI_draw_roundbox_4fv(
&(const rctf){
- .xmin = rct->xmin - 0.5f,
- .xmax = rct->xmax + 0.5f,
- .ymin = rct->ymin - 0.5f,
- .ymax = rct->ymax + 0.5f,
+ rct->xmin - 0.5f,
+ rct->xmax + 0.5f,
+ rct->ymin - 0.5f,
+ rct->ymax + 0.5f,
},
false,
radius + 0.5f,
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.cc
index 5a254db0eec..73ba9bdd192 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.cc
@@ -35,6 +35,7 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
+#include "BLI_array.hh"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -84,6 +85,8 @@
# include "wm_window.h"
#endif
+using blender::Array;
+
/* -------------------------------------------------------------------- */
/** \name Feature Defines
*
@@ -276,16 +279,16 @@ static void ui_selectcontext_apply(bContext *C,
# define DRAG_MULTINUM_THRESHOLD_VERTICAL (0.75f)
/* a simple version of uiHandleButtonData when accessing multiple buttons */
-typedef struct uiButMultiState {
+struct uiButMultiState {
double origvalue;
uiBut *but;
# ifdef USE_ALLSELECT
uiSelectContextStore select_others;
# endif
-} uiButMultiState;
+};
-typedef struct uiHandleButtonMulti {
+struct uiHandleButtonMulti {
enum {
/** gesture direction unknown, wait until mouse has moved enough... */
BUTTON_MULTI_INIT_UNSET = 0,
@@ -318,12 +321,11 @@ typedef struct uiHandleButtonMulti {
/* store x location once BUTTON_MULTI_INIT_SETUP is set,
* moving outside this sets BUTTON_MULTI_INIT_ENABLE */
int drag_lock_x;
-
-} uiHandleButtonMulti;
+};
#endif /* USE_DRAG_MULTINUM */
-typedef struct uiHandleButtonData {
+struct uiHandleButtonData {
wmWindowManager *wm;
wmWindow *window;
ScrArea *area;
@@ -418,9 +420,9 @@ typedef struct uiHandleButtonData {
/* post activate */
uiButtonActivateType posttype;
uiBut *postbut;
-} uiHandleButtonData;
+};
-typedef struct uiAfterFunc {
+struct uiAfterFunc {
struct uiAfterFunc *next, *prev;
uiButHandleFunc func;
@@ -456,7 +458,7 @@ typedef struct uiAfterFunc {
bContextStore *context;
char undostr[BKE_UNDO_STR_MAX];
-} uiAfterFunc;
+};
static void button_activate_init(bContext *C,
ARegion *region,
@@ -608,7 +610,9 @@ static bool ui_but_dragedit_update_mval(uiHandleButtonData *data, int mx)
return false;
}
#ifdef USE_DRAG_MULTINUM
- if (ELEM(data->multi_data.init, BUTTON_MULTI_INIT_UNSET, BUTTON_MULTI_INIT_SETUP)) {
+ if (ELEM(data->multi_data.init,
+ uiHandleButtonMulti::BUTTON_MULTI_INIT_UNSET,
+ uiHandleButtonMulti::BUTTON_MULTI_INIT_SETUP)) {
return false;
}
#endif
@@ -703,7 +707,7 @@ static ListBase UIAfterFuncs = {NULL, NULL};
static uiAfterFunc *ui_afterfunc_new(void)
{
- uiAfterFunc *after = MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
+ uiAfterFunc *after = (uiAfterFunc *)MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
BLI_addtail(&UIAfterFuncs, after);
@@ -725,7 +729,7 @@ PointerRNA *ui_handle_afterfunc_add_operator(wmOperatorType *ot, int opcontext,
after->opcontext = opcontext;
if (create_props) {
- ptr = MEM_callocN(sizeof(PointerRNA), __func__);
+ ptr = (PointerRNA *)MEM_callocN(sizeof(PointerRNA), __func__);
WM_operator_properties_create_ptr(ptr, ot);
after->opptr = ptr;
}
@@ -859,7 +863,7 @@ static void ui_apply_but_undo(uiBut *but)
}
else {
ID *id = but->rnapoin.owner_id;
- if (!ED_undo_is_legacy_compatible_for_property(but->block->evil_C, id)) {
+ if (!ED_undo_is_legacy_compatible_for_property((bContext *)but->block->evil_C, id)) {
skip_undo = true;
}
}
@@ -868,7 +872,8 @@ static void ui_apply_but_undo(uiBut *but)
if (skip_undo == false) {
/* XXX: disable all undo pushes from UI changes from sculpt mode as they cause memfile undo
* steps to be written which cause lag: T71434. */
- if (BKE_paintmode_get_active_from_context(but->block->evil_C) == PAINT_MODE_SCULPT) {
+ if (BKE_paintmode_get_active_from_context((bContext *)but->block->evil_C) ==
+ PAINT_MODE_SCULPT) {
skip_undo = true;
}
}
@@ -968,7 +973,7 @@ static void ui_apply_but_funcs_after(bContext *C)
}
if (after.rename_func) {
- after.rename_func(C, after.rename_arg1, after.rename_orig);
+ after.rename_func(C, after.rename_arg1, (char *)after.rename_orig);
}
if (after.rename_orig) {
MEM_freeN(after.rename_orig);
@@ -1185,7 +1190,7 @@ static void ui_multibut_add(uiHandleButtonData *data, uiBut *but)
BLI_assert(but->flag & UI_BUT_DRAG_MULTI);
BLI_assert(data->multi_data.has_mbuts);
- uiButMultiState *mbut_state = MEM_callocN(sizeof(*mbut_state), __func__);
+ uiButMultiState *mbut_state = (uiButMultiState *)MEM_callocN(sizeof(*mbut_state), __func__);
mbut_state->but = but;
mbut_state->origvalue = ui_but_value_get(but);
# ifdef USE_ALLSELECT
@@ -1200,7 +1205,7 @@ static void ui_multibut_add(uiHandleButtonData *data, uiBut *but)
static uiButMultiState *ui_multibut_lookup(uiHandleButtonData *data, const uiBut *but)
{
for (LinkNode *l = data->multi_data.mbuts; l; l = l->next) {
- uiButMultiState *mbut_state = l->link;
+ uiButMultiState *mbut_state = (uiButMultiState *)l->link;
if (mbut_state->but == but) {
return mbut_state;
@@ -1238,7 +1243,7 @@ static void ui_multibut_free(uiHandleButtonData *data, uiBlock *block)
LinkNode *list = data->multi_data.mbuts;
while (list) {
LinkNode *next = list->next;
- uiButMultiState *mbut_state = list->link;
+ uiButMultiState *mbut_state = (uiButMultiState *)list->link;
if (mbut_state->select_others.elems) {
MEM_freeN(mbut_state->select_others.elems);
@@ -1274,7 +1279,7 @@ static bool ui_multibut_states_tag(uiBut *but_active,
seg[1][0] = event->x;
seg[1][1] = event->y;
- BLI_assert(data->multi_data.init == BUTTON_MULTI_INIT_SETUP);
+ BLI_assert(data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_SETUP);
ui_window_to_block_fl(data->region, but_active->block, &seg[0][0], &seg[0][1]);
ui_window_to_block_fl(data->region, but_active->block, &seg[1][0], &seg[1][1]);
@@ -1319,7 +1324,7 @@ static bool ui_multibut_states_tag(uiBut *but_active,
static void ui_multibut_states_create(uiBut *but_active, uiHandleButtonData *data)
{
- BLI_assert(data->multi_data.init == BUTTON_MULTI_INIT_SETUP);
+ BLI_assert(data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_SETUP);
BLI_assert(data->multi_data.has_mbuts);
data->multi_data.bs_mbuts = UI_butstore_create(but_active->block);
@@ -1348,7 +1353,7 @@ static void ui_multibut_states_apply(bContext *C, uiHandleButtonData *data, uiBl
const double value_scale = data->multi_data.is_proportional ? (data->value / data->origvalue) :
0.0;
- BLI_assert(data->multi_data.init == BUTTON_MULTI_INIT_ENABLE);
+ BLI_assert(data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_ENABLE);
BLI_assert(data->multi_data.skip == false);
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
@@ -1577,13 +1582,13 @@ static void ui_drag_toggle_set(bContext *C, uiDragToggleHandle *drag_info, const
static void ui_handler_region_drag_toggle_remove(bContext *UNUSED(C), void *userdata)
{
- uiDragToggleHandle *drag_info = userdata;
+ uiDragToggleHandle *drag_info = (uiDragToggleHandle *)userdata;
MEM_freeN(drag_info);
}
static int ui_handler_region_drag_toggle(bContext *C, const wmEvent *event, void *userdata)
{
- uiDragToggleHandle *drag_info = userdata;
+ uiDragToggleHandle *drag_info = (uiDragToggleHandle *)userdata;
bool done = false;
switch (event->type) {
@@ -1662,8 +1667,8 @@ static bool ui_selectcontext_begin(bContext *C, uiBut *but, uiSelectContextStore
if (UI_context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path) &&
!BLI_listbase_is_empty(&lb)) {
selctx_data->elems_len = BLI_listbase_count(&lb);
- selctx_data->elems = MEM_mallocN(sizeof(uiSelectContextElem) * selctx_data->elems_len,
- __func__);
+ selctx_data->elems = (uiSelectContextElem *)MEM_mallocN(
+ sizeof(uiSelectContextElem) * selctx_data->elems_len, __func__);
int i;
LISTBASE_FOREACH_INDEX (CollectionPointerLink *, link, &lb, i) {
if (i >= selctx_data->elems_len) {
@@ -1823,7 +1828,7 @@ static void ui_selectcontext_apply(bContext *C,
wmWindow *win = CTX_wm_window(C);
if (!win->eventstate->shift) {
const int len = RNA_property_array_length(&but->rnapoin, prop);
- bool *tmparray = MEM_callocN(sizeof(bool) * len, __func__);
+ bool *tmparray = (bool *)MEM_callocN(sizeof(bool) * len, __func__);
tmparray[index] = true;
@@ -1917,7 +1922,8 @@ static bool ui_but_drag_init(bContext *C,
data->cancel = true;
#ifdef USE_DRAG_TOGGLE
if (ui_drag_toggle_but_is_supported(but)) {
- uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__);
+ uiDragToggleHandle *drag_info = (uiDragToggleHandle *)MEM_callocN(sizeof(*drag_info),
+ __func__);
ARegion *region_prev;
/* call here because regular mouse-up event wont run,
@@ -1969,7 +1975,8 @@ static bool ui_but_drag_init(bContext *C,
#endif
if (but->type == UI_BTYPE_COLOR) {
bool valid = false;
- uiDragColorHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__);
+ uiDragColorHandle *drag_info = (uiDragColorHandle *)MEM_callocN(sizeof(*drag_info),
+ __func__);
/* TODO support more button pointer types */
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
@@ -2229,7 +2236,8 @@ static void ui_apply_but(
#ifdef USE_DRAG_MULTINUM
if (data->multi_data.has_mbuts) {
- if ((data->multi_data.init == BUTTON_MULTI_INIT_ENABLE) && (data->multi_data.skip == false)) {
+ if ((data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_ENABLE) &&
+ (data->multi_data.skip == false)) {
if (data->cancel) {
ui_multibut_restore(C, data, block);
}
@@ -2275,7 +2283,8 @@ static void ui_apply_but(
/* only call if event type is EVT_DROP */
static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleButtonData *data)
{
- ListBase *drags = event->customdata; /* drop event type has listbase customdata by default */
+ /* drop event type has listbase customdata by default */
+ ListBase *drags = (ListBase *)event->customdata;
LISTBASE_FOREACH (wmDrag *, wmd, drags) {
/* TODO asset dropping. */
@@ -2316,7 +2325,7 @@ static void ui_but_get_pasted_text_from_clipboard(char **buf_paste, int *buf_len
*buf_len = length;
}
else {
- *buf_paste = MEM_callocN(sizeof(char), __func__);
+ *buf_paste = (char *)MEM_callocN(sizeof(char), __func__);
*buf_len = 0;
}
}
@@ -2381,9 +2390,9 @@ static void float_array_to_string(float *values,
static void ui_but_copy_numeric_array(uiBut *but, char *output, int output_len_max)
{
const int array_length = get_but_property_array_length(but);
- float *values = alloca(array_length * sizeof(float));
- RNA_property_float_get_array(&but->rnapoin, but->rnaprop, values);
- float_array_to_string(values, array_length, output, output_len_max);
+ Array<float, 32> values(array_length);
+ RNA_property_float_get_array(&but->rnapoin, but->rnaprop, values.data());
+ float_array_to_string(values.data(), array_length, output, output_len_max);
}
static bool parse_float_array(char *text, float *values, int expected_length)
@@ -2413,10 +2422,10 @@ static void ui_but_paste_numeric_array(bContext *C,
return;
}
- float *values = alloca(sizeof(float) * array_length);
+ Array<float, 32> values(array_length);
- if (parse_float_array(buf_paste, values, array_length)) {
- ui_but_set_float_array(C, but, data, values, array_length);
+ if (parse_float_array(buf_paste, values.data(), array_length)) {
+ ui_but_set_float_array(C, but, data, values.data(), array_length);
}
else {
WM_report(RPT_ERROR, "Expected an array of numbers: [n, n, ...]");
@@ -2537,7 +2546,7 @@ static void ui_but_paste_colorband(bContext *C, uiBut *but, uiHandleButtonData *
{
if (but_copypaste_coba.tot != 0) {
if (!but->poin) {
- but->poin = MEM_callocN(sizeof(ColorBand), "colorband");
+ but->poin = (char *)MEM_callocN(sizeof(ColorBand), "colorband");
}
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
@@ -2559,7 +2568,7 @@ static void ui_but_paste_curvemapping(bContext *C, uiBut *but)
{
if (but_copypaste_curve_alive) {
if (!but->poin) {
- but->poin = MEM_callocN(sizeof(CurveMapping), "curvemapping");
+ but->poin = (char *)MEM_callocN(sizeof(CurveMapping), "curvemapping");
}
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
@@ -2582,7 +2591,7 @@ static void ui_but_paste_CurveProfile(bContext *C, uiBut *but)
{
if (but_copypaste_profile_alive) {
if (!but->poin) {
- but->poin = MEM_callocN(sizeof(CurveProfile), "CurveProfile");
+ but->poin = (char *)MEM_callocN(sizeof(CurveProfile), "CurveProfile");
}
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
@@ -2874,7 +2883,7 @@ void ui_but_active_string_clear_and_exit(bContext *C, uiBut *but)
/* most likely NULL, but let's check, and give it temp zero string */
if (!but->active->str) {
- but->active->str = MEM_callocN(1, "temp str");
+ but->active->str = (char *)MEM_callocN(1, "temp str");
}
but->active->str[0] = 0;
@@ -2888,7 +2897,7 @@ static void ui_textedit_string_ensure_max_length(uiBut *but, uiHandleButtonData
BLI_assert(data->str == but->editstr);
if (maxlen > data->maxlen) {
- data->str = but->editstr = MEM_reallocN(data->str, sizeof(char) * maxlen);
+ data->str = but->editstr = (char *)MEM_reallocN(data->str, sizeof(char) * maxlen);
data->maxlen = maxlen;
}
}
@@ -2929,7 +2938,7 @@ static bool ui_textedit_set_cursor_pos_foreach_glyph(const char *UNUSED(str),
const int UNUSED(glyph_bearing[2]),
void *user_data)
{
- int *cursor_data = user_data;
+ int *cursor_data = (int *)user_data;
const float center = glyph_step_bounds->xmin + (BLI_rctf_size_x(glyph_bounds) / 2.0f);
if (cursor_data[0] < center) {
cursor_data[1] = str_step_ofs;
@@ -3148,7 +3157,7 @@ static void ui_textedit_move(uiBut *but,
static bool ui_textedit_delete(uiBut *but,
uiHandleButtonData *data,
- int direction,
+ eStrCursorJumpDirection direction,
eStrCursorJumpType jump)
{
char *str = data->str;
@@ -3248,7 +3257,7 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
else if (ELEM(mode, UI_TEXTEDIT_COPY, UI_TEXTEDIT_CUT)) {
/* copy the contents to the copypaste buffer */
const int sellen = but->selend - but->selsta;
- char *buf = MEM_mallocN(sizeof(char) * (sellen + 1), "ui_textedit_copypaste");
+ char *buf = (char *)MEM_mallocN(sizeof(char) * (sellen + 1), "ui_textedit_copypaste");
BLI_strncpy(buf, data->str + but->selsta, sellen + 1);
WM_clipboard_text_set(buf, 0);
@@ -3342,7 +3351,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
/* retrieve string */
data->maxlen = ui_but_string_get_max_length(but);
if (data->maxlen != 0) {
- data->str = MEM_callocN(sizeof(char) * data->maxlen, "textedit str");
+ data->str = (char *)MEM_callocN(sizeof(char) * data->maxlen, "textedit str");
/* We do not want to truncate precision to default here, it's nice to show value,
* not to edit it - way too much precision is lost then. */
ui_but_string_get_ex(
@@ -3475,7 +3484,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
}
}
}
- for (uiBut *but = block->buttons.first; but != actbut; but = but->next) {
+ for (uiBut *but = (uiBut *)block->buttons.first; but != actbut; but = but->next) {
if (ui_but_is_editable_as_text(but)) {
if (!(but->flag & UI_BUT_DISABLED)) {
data->postbut = but;
@@ -3507,7 +3516,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
}
}
}
- for (uiBut *but = block->buttons.last; but != actbut; but = but->prev) {
+ for (uiBut *but = (uiBut *)block->buttons.last; but != actbut; but = but->prev) {
if (ui_but_is_editable_as_text(but)) {
if (!(but->flag & UI_BUT_DISABLED)) {
data->postbut = but;
@@ -3710,13 +3719,13 @@ static void ui_do_but_textedit(
break;
case EVT_DELKEY:
changed = ui_textedit_delete(
- but, data, 1, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
+ but, data, STRCUR_DIR_NEXT, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
retval = WM_UI_HANDLER_BREAK;
break;
case EVT_BACKSPACEKEY:
changed = ui_textedit_delete(
- but, data, 0, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
+ but, data, STRCUR_DIR_PREV, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
retval = WM_UI_HANDLER_BREAK;
break;
@@ -4211,7 +4220,7 @@ static uiButExtraOpIcon *ui_but_extra_operator_icon_mouse_over_get(uiBut *but,
/* Handle the padding space from the right edge as the last button. */
if (x > xmax) {
- return but->extra_op_icons.last;
+ return (uiButExtraOpIcon *)but->extra_op_icons.last;
}
/* Inverse order, from right to left. */
@@ -5100,7 +5109,7 @@ static int ui_do_but_NUM(
if (data->dragchange) {
#ifdef USE_DRAG_MULTINUM
/* If we started multi-button but didn't drag, then edit. */
- if (data->multi_data.init == BUTTON_MULTI_INIT_SETUP) {
+ if (data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_SETUP) {
click = 1;
}
else
@@ -5138,7 +5147,7 @@ static int ui_do_but_NUM(
}
#ifdef USE_DRAG_MULTINUM
else if (data->multi_data.has_mbuts) {
- if (data->multi_data.init == BUTTON_MULTI_INIT_ENABLE) {
+ if (data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_ENABLE) {
ui_multibut_states_apply(C, data, block);
}
}
@@ -5422,7 +5431,7 @@ static int ui_do_but_SLI(
if (data->dragchange) {
#ifdef USE_DRAG_MULTINUM
/* If we started multi-button but didn't drag, then edit. */
- if (data->multi_data.init == BUTTON_MULTI_INIT_SETUP) {
+ if (data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_SETUP) {
click = 1;
}
else
@@ -5452,7 +5461,7 @@ static int ui_do_but_SLI(
#ifdef USE_DRAG_MULTINUM
else if (data->multi_data.has_mbuts) {
- if (data->multi_data.init == BUTTON_MULTI_INIT_ENABLE) {
+ if (data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_ENABLE) {
ui_multibut_states_apply(C, data, block);
}
}
@@ -5848,7 +5857,7 @@ static void ui_palette_set_active(uiButColor *color_but)
{
if (color_but->is_pallete_color) {
Palette *palette = (Palette *)color_but->but.rnapoin.owner_id;
- PaletteColor *color = color_but->but.rnapoin.data;
+ PaletteColor *color = (PaletteColor *)color_but->but.rnapoin.data;
palette->active_color = BLI_findindex(&palette->colors, color);
}
}
@@ -5885,7 +5894,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
return WM_UI_HANDLER_BREAK;
}
if (ELEM(event->type, MOUSEPAN, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->ctrl) {
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
float hsv_static[3] = {0.0f};
float *hsv = cpicker ? cpicker->hsv_perceptual : hsv_static;
float col[3];
@@ -5913,7 +5922,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co
}
if (color_but->is_pallete_color && (event->type == EVT_DELKEY) && (event->val == KM_PRESS)) {
Palette *palette = (Palette *)but->rnapoin.owner_id;
- PaletteColor *color = but->rnapoin.data;
+ PaletteColor *color = (PaletteColor *)but->rnapoin.data;
BKE_palette_color_remove(palette, color);
@@ -6114,7 +6123,7 @@ static bool ui_numedit_but_HSVCUBE(uiBut *but,
const bool shift)
{
const uiButHSVCube *hsv_but = (uiButHSVCube *)but;
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
float *hsv = cpicker->hsv_perceptual;
float rgb[3];
float x, y;
@@ -6343,7 +6352,7 @@ static int ui_do_but_HSVCUBE(
if (ELEM(len, 3, 4)) {
float rgb[3], def_hsv[3];
float def[4];
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
float *hsv = cpicker->hsv_perceptual;
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
@@ -6399,7 +6408,7 @@ static bool ui_numedit_but_HSVCIRCLE(uiBut *but,
const bool shift)
{
const bool changed = true;
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
float *hsv = cpicker->hsv_perceptual;
float mx_fl, my_fl;
@@ -6572,7 +6581,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but,
static int ui_do_but_HSVCIRCLE(
bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
float *hsv = cpicker->hsv_perceptual;
int mx = event->x;
int my = event->y;
@@ -6616,8 +6625,7 @@ static int ui_do_but_HSVCIRCLE(
len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
if (len >= 3) {
float rgb[3], def_hsv[3];
- float *def;
- def = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
+ float *def = (float *)MEM_callocN(sizeof(float) * len, "reset_defaults - float");
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
ui_color_picker_hsv_to_rgb(def, def_hsv);
@@ -7758,11 +7766,11 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
if (data) {
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) ||
/* if we started dragging, progress on any event */
- (data->multi_data.init == BUTTON_MULTI_INIT_SETUP)) {
+ (data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_SETUP)) {
if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) &&
ELEM(data->state, BUTTON_STATE_TEXT_EDITING, BUTTON_STATE_NUM_EDITING)) {
/* initialize! */
- if (data->multi_data.init == BUTTON_MULTI_INIT_UNSET) {
+ if (data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_UNSET) {
/* --> (BUTTON_MULTI_INIT_SETUP | BUTTON_MULTI_INIT_DISABLE) */
const float margin_y = DRAG_MULTINUM_THRESHOLD_DRAG_Y / sqrtf(block->aspect);
@@ -7775,15 +7783,15 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
normalize_v2_v2(dir_nor_drag, data->multi_data.drag_dir);
if (fabsf(dot_v2v2(dir_nor_drag, dir_nor_y)) > DRAG_MULTINUM_THRESHOLD_VERTICAL) {
- data->multi_data.init = BUTTON_MULTI_INIT_SETUP;
+ data->multi_data.init = uiHandleButtonMulti::BUTTON_MULTI_INIT_SETUP;
data->multi_data.drag_lock_x = event->x;
}
else {
- data->multi_data.init = BUTTON_MULTI_INIT_DISABLE;
+ data->multi_data.init = uiHandleButtonMulti::BUTTON_MULTI_INIT_DISABLE;
}
}
}
- else if (data->multi_data.init == BUTTON_MULTI_INIT_SETUP) {
+ else if (data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_SETUP) {
/* --> (BUTTON_MULTI_INIT_ENABLE) */
const float margin_x = DRAG_MULTINUM_THRESHOLD_DRAG_X / sqrtf(block->aspect);
/* Check if we're don't setting buttons. */
@@ -7794,15 +7802,15 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
abs(event->prevx - event->x) > abs(event->prevy - event->y))) {
if (data->multi_data.has_mbuts) {
ui_multibut_states_create(but, data);
- data->multi_data.init = BUTTON_MULTI_INIT_ENABLE;
+ data->multi_data.init = uiHandleButtonMulti::BUTTON_MULTI_INIT_ENABLE;
}
else {
- data->multi_data.init = BUTTON_MULTI_INIT_DISABLE;
+ data->multi_data.init = uiHandleButtonMulti::BUTTON_MULTI_INIT_DISABLE;
}
}
}
- if (data->multi_data.init == BUTTON_MULTI_INIT_SETUP) {
+ if (data->multi_data.init == uiHandleButtonMulti::BUTTON_MULTI_INIT_SETUP) {
if (ui_multibut_states_tag(but, data, event)) {
ED_region_tag_redraw(data->region);
}
@@ -8103,7 +8111,8 @@ static void button_activate_init(bContext *C,
BLI_assert(ui_region_find_active_but(region) == NULL);
/* setup struct */
- uiHandleButtonData *data = MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData");
+ uiHandleButtonData *data = (uiHandleButtonData *)MEM_callocN(sizeof(uiHandleButtonData),
+ "uiHandleButtonData");
data->wm = CTX_wm_manager(C);
data->window = CTX_wm_window(C);
data->area = CTX_wm_area(C);
@@ -8158,7 +8167,7 @@ static void button_activate_init(bContext *C,
/* activate first button in submenu */
if (data->menu && data->menu->region) {
ARegion *subar = data->menu->region;
- uiBlock *subblock = subar->uiblocks.first;
+ uiBlock *subblock = (uiBlock *)subar->uiblocks.first;
uiBut *subbut;
if (subblock) {
@@ -8645,9 +8654,10 @@ void ui_but_execute_begin(struct bContext *UNUSED(C),
BLI_assert(BLI_findindex(&region->uiblocks, but->block) != -1);
/* note: ideally we would not have to change 'but->active' however
* some functions we call don't use data (as they should be doing) */
- uiHandleButtonData *data;
+
*active_back = but->active;
- data = MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData_Fake");
+ uiHandleButtonData *data = (uiHandleButtonData *)MEM_callocN(sizeof(uiHandleButtonData),
+ "uiHandleButtonData_Fake");
but->active = data;
BLI_assert(region != NULL);
data->region = region;
@@ -8665,7 +8675,7 @@ void ui_but_execute_end(struct bContext *C,
}
/* use onfree event so undo is handled by caller and apply is already done above */
button_activate_exit((bContext *)C, but, but->active, false, true);
- but->active = active_back;
+ but->active = (uiHandleButtonData *)active_back;
}
static void ui_handle_button_activate(bContext *C,
@@ -8982,7 +8992,7 @@ static int ui_handle_button_event(bContext *C, const wmEvent *event, uiBut *but)
#ifdef USE_DRAG_MULTINUM
if (data->multi_data.mbuts) {
for (LinkNode *l = data->multi_data.mbuts; l; l = l->next) {
- uiButMultiState *state = l->link;
+ uiButMultiState *state = (uiButMultiState *)l->link;
uiBut *but_iter = state->but;
double default_value;
@@ -9031,7 +9041,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi
int scroll_dir = 1;
bool redraw = false;
- uiList *ui_list = listbox->custom_data;
+ uiList *ui_list = (uiList *)listbox->custom_data;
if (!ui_list || !ui_list->dyn_data) {
return retval;
}
@@ -9077,7 +9087,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi
if (dyn_data->items_filter_neworder || dyn_data->items_filter_flags) {
/* If we have a display order different from
* collection order, we have some work! */
- int *org_order = MEM_mallocN(dyn_data->items_shown * sizeof(int), __func__);
+ int *org_order = (int *)MEM_mallocN(dyn_data->items_shown * sizeof(int), __func__);
const int *new_order = dyn_data->items_filter_neworder;
int org_idx = -1, len = dyn_data->items_len;
int current_idx = -1;
@@ -9274,7 +9284,7 @@ static bool ui_mouse_motion_towards_check(uiBlock *block,
/* am I the last menu (test) */
ARegion *region = menu->region->next;
do {
- uiBlock *block_iter = region->uiblocks.first;
+ uiBlock *block_iter = (uiBlock *)region->uiblocks.first;
if (block_iter && ui_block_is_menu(block_iter)) {
return true;
}
@@ -9611,7 +9621,7 @@ static int ui_handle_menu_event(bContext *C,
{
uiBut *but;
ARegion *region = menu->region;
- uiBlock *block = region->uiblocks.first;
+ uiBlock *block = (uiBlock *)region->uiblocks.first;
int retval = WM_UI_HANDLER_CONTINUE;
@@ -9953,7 +9963,7 @@ static int ui_handle_menu_event(bContext *C,
}
count = 0;
- for (but = block->buttons.first; but; but = but->next) {
+ for (but = (uiBut *)block->buttons.first; but; but = but->next) {
bool doit = false;
if (!ELEM(but->type,
@@ -10036,7 +10046,7 @@ static int ui_handle_menu_event(bContext *C,
break;
}
- for (but = block->buttons.first; but; but = but->next) {
+ for (but = (uiBut *)block->buttons.first; but; but = but->next) {
if (!(but->flag & UI_BUT_DISABLED) && but->menu_key == event->type) {
if (but->type == UI_BTYPE_BUT) {
UI_but_execute(C, region, but);
@@ -10067,7 +10077,7 @@ static int ui_handle_menu_event(bContext *C,
* don't overwrite them, see: T61015.
*/
if ((inside == false) && (menu->menuretval == 0)) {
- uiSafetyRct *saferct = block->saferct.first;
+ uiSafetyRct *saferct = (uiSafetyRct *)block->saferct.first;
if (ELEM(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE)) {
if (ELEM(event->val, KM_PRESS, KM_DBL_CLICK)) {
@@ -10159,7 +10169,7 @@ static int ui_handle_menu_event(bContext *C,
ui_mouse_motion_towards_check(block, menu, &event->x, is_parent_inside == false);
/* Check for all parent rects, enables arrow-keys to be used. */
- for (saferct = block->saferct.first; saferct; saferct = saferct->next) {
+ for (saferct = (uiSafetyRct *)block->saferct.first; saferct; saferct = saferct->next) {
/* for mouse move we only check our own rect, for other
* events we check all preceding block rects too to make
* arrow keys navigation work */
@@ -10205,7 +10215,7 @@ static int ui_handle_menu_event(bContext *C,
#ifdef USE_UI_POPOVER_ONCE
if (block->flag & UI_BLOCK_POPOVER_ONCE) {
if ((event->type == LEFTMOUSE) && (event->val == KM_RELEASE)) {
- UI_popover_once_clear(menu->popup_create_vars.arg);
+ UI_popover_once_clear((uiPopover *)menu->popup_create_vars.arg);
block->flag &= ~UI_BLOCK_POPOVER_ONCE;
}
}
@@ -10233,7 +10243,7 @@ static int ui_handle_menu_return_submenu(bContext *C,
uiPopupBlockHandle *menu)
{
ARegion *region = menu->region;
- uiBlock *block = region->uiblocks.first;
+ uiBlock *block = (uiBlock *)region->uiblocks.first;
uiBut *but = ui_region_find_active_but(region);
@@ -10361,7 +10371,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
}
ARegion *region = menu->region;
- uiBlock *block = region->uiblocks.first;
+ uiBlock *block = (uiBlock *)region->uiblocks.first;
const bool is_click_style = (block->pie_data.flags & UI_PIE_CLICK_STYLE);
@@ -10410,7 +10420,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle
float vec[2];
float center[2];
- ui_but_pie_dir(but->pie_dir, vec);
+ ui_but_pie_dir((RadialDirection)but->pie_dir, vec);
center[0] = (vec[0] > 0.01f) ? 0.5f : ((vec[0] < -0.01f) ? -0.5f : 0.0f);
center[1] = (vec[1] > 0.99f) ? 0.5f : ((vec[1] < -0.99f) ? -0.5f : 0.0f);
@@ -10621,7 +10631,7 @@ static int ui_handle_menus_recursive(bContext *C,
uiPopupBlockHandle *submenu = (data) ? data->menu : NULL;
if (submenu) {
- uiBlock *block = menu->region->uiblocks.first;
+ uiBlock *block = (uiBlock *)menu->region->uiblocks.first;
const bool is_menu = ui_block_is_menu(block);
bool inside = false;
/* root pie menus accept the key that spawned
@@ -10659,7 +10669,7 @@ static int ui_handle_menus_recursive(bContext *C,
}
if (do_but_search) {
- uiBlock *block = menu->region->uiblocks.first;
+ uiBlock *block = (uiBlock *)menu->region->uiblocks.first;
retval = ui_handle_menu_button(C, event, menu);
@@ -10672,7 +10682,7 @@ static int ui_handle_menus_recursive(bContext *C,
}
}
else {
- uiBlock *block = menu->region->uiblocks.first;
+ uiBlock *block = (uiBlock *)menu->region->uiblocks.first;
uiBut *listbox = ui_list_find_mouse_over(menu->region, event);
if (block->flag & UI_BLOCK_RADIAL) {
@@ -10887,7 +10897,7 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE
/* two types of popups, one with operator + enum, other with regular callbacks */
static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
{
- uiPopupBlockHandle *menu = userdata;
+ uiPopupBlockHandle *menu = (uiPopupBlockHandle *)userdata;
/* we block all events, this is modal interaction,
* except for drop events which is described below */
int retval = WM_UI_HANDLER_BREAK;
@@ -10916,7 +10926,7 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
wmWindow *win = CTX_wm_window(C);
/* copy values, we have to free first (closes region) */
const uiPopupBlockHandle temp = *menu;
- uiBlock *block = menu->region->uiblocks.first;
+ uiBlock *block = (uiBlock *)menu->region->uiblocks.first;
/* set last pie event to allow chained pie spawning */
if (block->flag & UI_BLOCK_RADIAL) {
@@ -10974,7 +10984,7 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
static void ui_popup_handler_remove(bContext *C, void *userdata)
{
- uiPopupBlockHandle *menu = userdata;
+ uiPopupBlockHandle *menu = (uiPopupBlockHandle *)userdata;
/* More correct would be to expect UI_RETURN_CANCEL here, but not wanting to
* cancel when removing handlers because of file exit is a rare exception.
@@ -11018,7 +11028,7 @@ void UI_popup_handlers_remove(ListBase *handlers, uiPopupBlockHandle *popup)
if (handler_next && handler_next->head.type == WM_HANDLER_TYPE_UI &&
handler_next->handle_fn == ui_popup_handler &&
handler_next->remove_fn == ui_popup_handler_remove) {
- uiPopupBlockHandle *parent_popup = handler_next->user_data;
+ uiPopupBlockHandle *parent_popup = (uiPopupBlockHandle *)handler_next->user_data;
ED_region_tag_refresh_ui(parent_popup->region);
}
break;
diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.cc
index 3962ff6a702..33e3969ed2f 100644
--- a/source/blender/editors/interface/interface_icons_event.c
+++ b/source/blender/editors/interface/interface_icons_event.cc
@@ -119,10 +119,10 @@ void icon_draw_rect_input(float x,
UI_draw_roundbox_corner_set(UI_CNR_ALL);
UI_draw_roundbox_aa(
&(const rctf){
- .xmin = (int)x - U.pixelsize,
- .xmax = (int)(x + w),
- .ymin = (int)y,
- .ymax = (int)(y + h),
+ (int)x - U.pixelsize,
+ (int)(x + w),
+ (int)y,
+ (int)(y + h),
},
false,
3.0f * U.pixelsize,
@@ -144,10 +144,10 @@ void icon_draw_rect_input(float x,
;
const rctf rect = {
- .xmin = x,
- .ymin = y,
- .xmax = x + w,
- .ymax = y + h,
+ x,
+ x + w,
+ y,
+ y + h,
};
if ((event_type >= EVT_AKEY) && (event_type <= EVT_ZKEY)) {
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 0e465be5bf6..82e263e18f6 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -111,7 +111,7 @@ typedef enum RadialDirection {
UI_RADIAL_NW = 7,
} RadialDirection;
-extern const char ui_radial_dir_order[8];
+extern const RadialDirection ui_radial_dir_order[8];
extern const char ui_radial_dir_to_numpad[8];
extern const short ui_radial_dir_to_angle[8];
@@ -1068,7 +1068,7 @@ void ui_item_menutype_func(struct bContext *C, struct uiLayout *layout, void *ar
void ui_item_paneltype_func(struct bContext *C, struct uiLayout *layout, void *arg_pt);
/* interface_button_group.c */
-void ui_block_new_button_group(uiBlock *block, uiButtonGroupFlag flag);
+struct uiButtonGroup *ui_block_new_button_group(uiBlock *block);
void ui_button_group_add_but(uiBlock *block, uiBut *but);
void ui_button_group_replace_but_ptr(uiBlock *block, const void *old_but_ptr, uiBut *new_but);
void ui_block_free_button_groups(uiBlock *block);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.cc
index 8f2871ce18b..f376821cf8d 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.cc
@@ -29,7 +29,7 @@
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
-#include "BLI_alloca.h"
+#include "BLI_array.hh"
#include "BLI_dynstr.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -55,6 +55,8 @@
#include "interface_intern.h"
+using blender::Array;
+
/* Show an icon button after each RNA button to use to quickly set keyframes,
* this is a way to display animation/driven/override status, see T54951. */
#define UI_PROP_DECORATE
@@ -78,7 +80,7 @@
/* uiLayoutRoot */
-typedef struct uiLayoutRoot {
+struct uiLayoutRoot {
struct uiLayoutRoot *next, *prev;
int type;
@@ -93,11 +95,11 @@ typedef struct uiLayoutRoot {
const uiStyle *style;
uiBlock *block;
uiLayout *layout;
-} uiLayoutRoot;
+};
/* Item */
-typedef enum uiItemType {
+enum uiItemType {
ITEM_BUTTON,
ITEM_LAYOUT_ROW,
@@ -120,10 +122,10 @@ typedef enum uiItemType {
TEMPLATE_HEADER,
TEMPLATE_HEADER_ID,
#endif
-} uiItemType;
+};
typedef struct uiItem {
- void *next, *prev;
+ struct uiItem *next, *prev;
uiItemType type;
int flag;
} uiItem;
@@ -141,10 +143,10 @@ enum {
UI_ITEM_PROP_DECORATE_NO_PAD = 1 << 6,
};
-typedef struct uiButtonItem {
+struct uiButtonItem {
uiItem item;
uiBut *but;
-} uiButtonItem;
+};
struct uiLayout {
uiItem item;
@@ -177,13 +179,13 @@ struct uiLayout {
float units[2];
};
-typedef struct uiLayoutItemFlow {
+struct uiLayoutItemFlow {
uiLayout litem;
int number;
int totcol;
-} uiLayoutItemFlow;
+};
-typedef struct uiLayoutItemGridFlow {
+struct uiLayoutItemGridFlow {
uiLayout litem;
/* Extra parameters */
@@ -200,21 +202,21 @@ typedef struct uiLayoutItemGridFlow {
/* Pure internal runtime storage. */
int tot_items, tot_columns, tot_rows;
-} uiLayoutItemGridFlow;
+};
-typedef struct uiLayoutItemBx {
+struct uiLayoutItemBx {
uiLayout litem;
uiBut *roundbox;
-} uiLayoutItemBx;
+};
-typedef struct uiLayoutItemSplit {
+struct uiLayoutItemSplit {
uiLayout litem;
float percentage;
-} uiLayoutItemSplit;
+};
-typedef struct uiLayoutItemRoot {
+struct uiLayoutItemRoot {
uiLayout litem;
-} uiLayoutItemRoot;
+};
/** \} */
@@ -448,7 +450,7 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, bool
static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
{
wmWindow *win = CTX_wm_window(C);
- uiBut *but = arg_but;
+ uiBut *but = (uiBut *)arg_but;
PointerRNA *ptr = &but->rnapoin;
PropertyRNA *prop = but->rnaprop;
const int index = POINTER_AS_INT(arg_index);
@@ -519,7 +521,7 @@ static void ui_item_array(uiLayout *layout,
const int buth = UI_UNIT_X * 0.75;
if (ptr->type == &RNA_Armature) {
- bArmature *arm = ptr->data;
+ bArmature *arm = (bArmature *)ptr->data;
layer_used = arm->layer_used;
@@ -666,7 +668,7 @@ static void ui_item_array(uiLayout *layout,
bool *boolarr = NULL;
if (type == PROP_BOOLEAN &&
ELEM(layout->root->block->emboss, UI_EMBOSS_NONE, UI_EMBOSS_PULLDOWN)) {
- boolarr = MEM_callocN(sizeof(bool) * len, __func__);
+ boolarr = (bool *)MEM_callocN(sizeof(bool) * len, __func__);
RNA_property_boolean_get_array(ptr, prop, boolarr);
}
@@ -807,10 +809,12 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
bool free;
const EnumPropertyItem *item_array;
if (radial) {
- RNA_property_enum_items_gettexted_all(block->evil_C, ptr, prop, &item_array, NULL, &free);
+ RNA_property_enum_items_gettexted_all(
+ (bContext *)block->evil_C, ptr, prop, &item_array, NULL, &free);
}
else {
- RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item_array, NULL, &free);
+ RNA_property_enum_items_gettexted(
+ (bContext *)block->evil_C, ptr, prop, &item_array, NULL, &free);
}
/* We don't want nested rows, cols in menus. */
@@ -892,12 +896,12 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
const int h,
const bool icon_only)
{
- uiBut *last = block->buttons.last;
+ uiBut *last = (uiBut *)block->buttons.last;
ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_TAB, icon_only);
BLI_assert(last != block->buttons.last);
- for (uiBut *tab = last ? last->next : block->buttons.first; tab; tab = tab->next) {
+ for (uiBut *tab = last ? last->next : (uiBut *)block->buttons.first; tab; tab = tab->next) {
UI_but_drawflag_enable(tab, ui_but_align_opposite_to_area_align_get(CTX_wm_region(C)));
}
@@ -905,10 +909,10 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
if (use_custom_highlight) {
const int highlight_array_len = RNA_property_array_length(ptr_highlight, prop_highlight);
- bool *highlight_array = alloca(sizeof(bool) * highlight_array_len);
- RNA_property_boolean_get_array(ptr_highlight, prop_highlight, highlight_array);
+ Array<bool, 32> highlight_array(highlight_array_len);
+ RNA_property_boolean_get_array(ptr_highlight, prop_highlight, highlight_array.data());
int i = 0;
- for (uiBut *tab_but = last ? last->next : block->buttons.first;
+ for (uiBut *tab_but = last ? last->next : (uiBut *)block->buttons.first;
(tab_but != NULL) && (i < highlight_array_len);
tab_but = tab_but->next, i++) {
SET_FLAG_FROM_TEST(tab_but->flag, !highlight_array[i], UI_BUT_INACTIVE);
@@ -919,7 +923,7 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
/* callback for keymap item change button */
static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_v))
{
- uiBut *but = but_v;
+ uiBut *but = (uiBut *)but_v;
RNA_boolean_set(&but->rnapoin, "shift", (but->modifier_key & KM_SHIFT) != 0);
RNA_boolean_set(&but->rnapoin, "ctrl", (but->modifier_key & KM_CTRL) != 0);
@@ -1040,7 +1044,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
else if ((flag & UI_ITEM_R_FULL_EVENT) && is_keymapitem_ptr) {
char buf[128];
- WM_keymap_item_to_string(ptr->data, false, buf, sizeof(buf));
+ WM_keymap_item_to_string((const wmKeyMapItem *)ptr->data, false, buf, sizeof(buf));
but = uiDefButR_prop(block,
UI_BTYPE_HOTKEY_EVENT,
@@ -1185,7 +1189,7 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
}
UI_block_layout_set_current(block, layout);
- ui_block_new_button_group(block, 0);
+ ui_block_new_button_group(block);
const int w = ui_text_icon_width(layout, name, icon, 0);
@@ -1278,7 +1282,7 @@ static void ui_item_menu_hold(struct bContext *C, ARegion *butregion, uiBut *but
}
UI_block_direction_set(block, direction);
- const char *menu_id = but->hold_argN;
+ const char *menu_id = (const char *)but->hold_argN;
MenuType *mt = WM_menutype_find(menu_id, true);
if (mt) {
uiLayoutSetContextFromBut(layout, but);
@@ -1345,7 +1349,7 @@ static const char *ui_menu_enumpropname(uiLayout *layout,
{
bool free;
const EnumPropertyItem *item;
- RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
+ RNA_property_enum_items((bContext *)layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
const char *name;
if (RNA_enum_name(item, retval, &name)) {
@@ -1384,7 +1388,8 @@ void uiItemEnumO_ptr(uiLayout *layout,
name = ui_menu_enumpropname(layout, &ptr, prop, value);
}
- uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
+ uiItemFullO_ptr(
+ layout, ot, name, icon, (IDProperty *)ptr.data, layout->root->opcontext, 0, NULL);
}
void uiItemEnumO(uiLayout *layout,
const char *opname,
@@ -1497,7 +1502,7 @@ void uiItemsFullEnumO_items(uiLayout *layout,
WM_operator_properties_create_ptr(&tptr, ot);
if (properties) {
if (tptr.data) {
- IDP_FreeProperty(tptr.data);
+ IDP_FreeProperty((IDProperty *)tptr.data);
}
tptr.data = IDP_CopyProperty(properties);
}
@@ -1507,12 +1512,12 @@ void uiItemsFullEnumO_items(uiLayout *layout,
ot,
(flag & UI_ITEM_R_ICON_ONLY) ? NULL : item->name,
item->icon,
- tptr.data,
+ (IDProperty *)tptr.data,
context,
flag,
NULL);
- ui_but_tip_from_enum_item(block->buttons.last, item);
+ ui_but_tip_from_enum_item((uiBut *)block->buttons.last, item);
}
else {
if (item->name) {
@@ -1527,7 +1532,7 @@ void uiItemsFullEnumO_items(uiLayout *layout,
if (item->icon || radial) {
uiItemL(target, item->name, item->icon);
- but = block->buttons.last;
+ but = (uiBut *)block->buttons.last;
}
else {
/* Do not use uiItemL here, as our root layout is a menu one,
@@ -1603,13 +1608,15 @@ void uiItemsFullEnumO(uiLayout *layout,
*/
#if 0
RNA_property_enum_items_gettexted_all(
- block->evil_C, &ptr, prop, &item_array, &totitem, &free);
+ (bContext *)block->evil_C, &ptr, prop, &item_array, &totitem, &free);
#else
- RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item_array, &totitem, &free);
+ RNA_property_enum_items_gettexted(
+ (bContext *)block->evil_C, &ptr, prop, &item_array, &totitem, &free);
#endif
}
else {
- RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item_array, &totitem, &free);
+ RNA_property_enum_items_gettexted(
+ (bContext *)block->evil_C, &ptr, prop, &item_array, &totitem, &free);
}
/* add items */
@@ -1665,7 +1672,8 @@ void uiItemEnumO_value(uiLayout *layout,
name = ui_menu_enumpropname(layout, &ptr, prop, value);
}
- uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
+ uiItemFullO_ptr(
+ layout, ot, name, icon, (IDProperty *)ptr.data, layout->root->opcontext, 0, NULL);
}
void uiItemEnumO_string(uiLayout *layout,
@@ -1691,7 +1699,7 @@ void uiItemEnumO_string(uiLayout *layout,
/* no need for translations here */
const EnumPropertyItem *item;
bool free;
- RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
+ RNA_property_enum_items((bContext *)layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
int value;
if (item == NULL || RNA_enum_value_from_id(item, value_str, &value) == 0) {
@@ -1713,7 +1721,8 @@ void uiItemEnumO_string(uiLayout *layout,
name = ui_menu_enumpropname(layout, &ptr, prop, value);
}
- uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
+ uiItemFullO_ptr(
+ layout, ot, name, icon, (IDProperty *)ptr.data, layout->root->opcontext, 0, NULL);
}
void uiItemBooleanO(uiLayout *layout,
@@ -1730,7 +1739,8 @@ void uiItemBooleanO(uiLayout *layout,
WM_operator_properties_create_ptr(&ptr, ot);
RNA_boolean_set(&ptr, propname, value);
- uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
+ uiItemFullO_ptr(
+ layout, ot, name, icon, (IDProperty *)ptr.data, layout->root->opcontext, 0, NULL);
}
void uiItemIntO(uiLayout *layout,
@@ -1747,7 +1757,8 @@ void uiItemIntO(uiLayout *layout,
WM_operator_properties_create_ptr(&ptr, ot);
RNA_int_set(&ptr, propname, value);
- uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
+ uiItemFullO_ptr(
+ layout, ot, name, icon, (IDProperty *)ptr.data, layout->root->opcontext, 0, NULL);
}
void uiItemFloatO(uiLayout *layout,
@@ -1765,7 +1776,8 @@ void uiItemFloatO(uiLayout *layout,
WM_operator_properties_create_ptr(&ptr, ot);
RNA_float_set(&ptr, propname, value);
- uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
+ uiItemFullO_ptr(
+ layout, ot, name, icon, (IDProperty *)ptr.data, layout->root->opcontext, 0, NULL);
}
void uiItemStringO(uiLayout *layout,
@@ -1783,7 +1795,8 @@ void uiItemStringO(uiLayout *layout,
WM_operator_properties_create_ptr(&ptr, ot);
RNA_string_set(&ptr, propname, value);
- uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0, NULL);
+ uiItemFullO_ptr(
+ layout, ot, name, icon, (IDProperty *)ptr.data, layout->root->opcontext, 0, NULL);
}
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
@@ -1828,7 +1841,7 @@ static void ui_item_rna_size(uiLayout *layout,
const EnumPropertyItem *item_array;
bool free;
RNA_property_enum_items_gettexted(
- layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free);
+ (bContext *)layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free);
for (const EnumPropertyItem *item = item_array; item->identifier; item++) {
if (item->identifier[0]) {
@@ -2004,7 +2017,7 @@ void uiItemFullR(uiLayout *layout,
#endif /* UI_PROP_DECORATE */
UI_block_layout_set_current(block, layout);
- ui_block_new_button_group(block, 0);
+ ui_block_new_button_group(block);
/* retrieve info */
const PropertyType type = RNA_property_type(prop);
@@ -2235,7 +2248,7 @@ void uiItemFullR(uiLayout *layout,
ui_decorate.layout = uiLayoutColumn(layout_row, true);
ui_decorate.layout->space = 0;
UI_block_layout_set_current(block, layout);
- ui_decorate.but = block->buttons.last;
+ ui_decorate.but = (uiBut *)block->buttons.last;
/* Clear after. */
layout->item.flag |= UI_ITEM_PROP_DECORATE_NO_PAD;
@@ -2361,7 +2374,7 @@ void uiItemFullR(uiLayout *layout,
#ifdef UI_PROP_DECORATE
if (ui_decorate.use_prop_decorate) {
- uiBut *but_decorate = ui_decorate.but ? ui_decorate.but->next : block->buttons.first;
+ uiBut *but_decorate = ui_decorate.but ? ui_decorate.but->next : (uiBut *)block->buttons.first;
const bool use_blank_decorator = (flag & UI_ITEM_R_FORCE_BLANK_DECORATE);
uiLayout *layout_col = uiLayoutColumn(ui_decorate.layout, false);
layout_col->space = 0;
@@ -2374,7 +2387,7 @@ void uiItemFullR(uiLayout *layout,
/* The icons are set in 'ui_but_anim_flag' */
uiItemDecoratorR_prop(layout_col, ptr_dec, prop_dec, but_decorate->rnaindex);
- but = block->buttons.last;
+ but = (uiBut *)block->buttons.last;
/* Order the decorator after the button we decorate, this is used so we can always
* do a quick lookup. */
@@ -2426,7 +2439,7 @@ void uiItemFullR_with_popover(uiLayout *layout,
const char *panel_type)
{
uiBlock *block = layout->root->block;
- uiBut *but = block->buttons.last;
+ uiBut *but = (uiBut *)block->buttons.last;
uiItemFullR(layout, ptr, prop, index, value, flag, name, icon);
but = but->next;
while (but) {
@@ -2457,7 +2470,7 @@ void uiItemFullR_with_menu(uiLayout *layout,
const char *menu_type)
{
uiBlock *block = layout->root->block;
- uiBut *but = block->buttons.last;
+ uiBut *but = (uiBut *)block->buttons.last;
uiItemFullR(layout, ptr, prop, index, value, flag, name, icon);
but = but->next;
while (but) {
@@ -2528,7 +2541,7 @@ void uiItemEnumR_string_prop(uiLayout *layout,
const EnumPropertyItem *item;
bool free;
- RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
+ RNA_property_enum_items((bContext *)layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
int ivalue;
if (!RNA_enum_value_from_id(item, value, &ivalue)) {
@@ -2602,12 +2615,12 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
int totitem;
const EnumPropertyItem *item;
bool free;
- RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
+ RNA_property_enum_items_gettexted((bContext *)block->evil_C, ptr, prop, &item, &totitem, &free);
for (int i = 0; i < totitem; i++) {
if (item[i].identifier[0]) {
uiItemEnumR_prop(column, item[i].name, item[i].icon, ptr, prop, item[i].value);
- ui_but_tip_from_enum_item(block->buttons.last, &item[i]);
+ ui_but_tip_from_enum_item((uiBut *)block->buttons.last, &item[i]);
}
else {
if (item[i].name) {
@@ -2618,7 +2631,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
}
uiItemL(column, item[i].name, ICON_NONE);
- uiBut *bt = block->buttons.last;
+ uiBut *bt = (uiBut *)block->buttons.last;
bt->drawflag = UI_BUT_TEXT_LEFT;
ui_but_tip_from_enum_item(bt, &item[i]);
@@ -2663,7 +2676,7 @@ static void search_id_collection(StructRNA *ptype, PointerRNA *r_ptr, PropertyRN
static void ui_rna_collection_search_arg_free_fn(void *ptr)
{
- uiRNACollectionSearch *coll_search = ptr;
+ uiRNACollectionSearch *coll_search = (uiRNACollectionSearch *)ptr;
UI_butstore_free(coll_search->butstore_block, coll_search->butstore);
MEM_freeN(ptr);
}
@@ -2686,7 +2699,8 @@ uiBut *ui_but_add_search(
/* turn button into search button */
if (searchprop) {
- uiRNACollectionSearch *coll_search = MEM_mallocN(sizeof(*coll_search), __func__);
+ uiRNACollectionSearch *coll_search = (uiRNACollectionSearch *)MEM_mallocN(sizeof(*coll_search),
+ __func__);
uiButSearch *search_but;
but = ui_but_change_type(but, UI_BTYPE_SEARCH_MENU);
@@ -2742,7 +2756,7 @@ void uiItemPointerR_prop(uiLayout *layout,
{
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
- ui_block_new_button_group(uiLayoutGetBlock(layout), 0);
+ ui_block_new_button_group(uiLayoutGetBlock(layout));
const PropertyType type = RNA_property_type(prop);
if (!ELEM(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) {
@@ -2848,7 +2862,7 @@ static uiBut *ui_item_menu(uiLayout *layout,
uiLayout *heading_layout = ui_layout_heading_find(layout);
UI_block_layout_set_current(block, layout);
- ui_block_new_button_group(block, 0);
+ ui_block_new_button_group(block);
if (!name) {
name = "";
@@ -2948,8 +2962,7 @@ void uiItemMContents(uiLayout *layout, const char *menuname)
}
uiBlock *block = layout->root->block;
- bContext *C = block->evil_C;
- UI_menutype_draw(C, mt, layout);
+ UI_menutype_draw((bContext *)block->evil_C, mt, layout);
}
/**
@@ -3115,7 +3128,7 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
uiBlock *block = layout->root->block;
UI_block_layout_set_current(block, layout);
- ui_block_new_button_group(block, 0);
+ ui_block_new_button_group(block);
if (!name) {
name = "";
@@ -3410,7 +3423,7 @@ void uiItemMenuEnumO_ptr(uiLayout *layout,
icon = ICON_BLANK1;
}
- MenuItemLevel *lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
+ MenuItemLevel *lvl = (MenuItemLevel *)MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname));
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
lvl->opcontext = layout->root->opcontext;
@@ -3466,7 +3479,7 @@ void uiItemMenuEnumR_prop(
icon = ICON_BLANK1;
}
- MenuItemLevel *lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
+ MenuItemLevel *lvl = (MenuItemLevel *)MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
lvl->rnapoin = *ptr;
BLI_strncpy(lvl->propname, RNA_property_identifier(prop), sizeof(lvl->propname));
lvl->opcontext = layout->root->opcontext;
@@ -3679,12 +3692,12 @@ static void ui_litem_layout_row(uiLayout *litem)
}
/* add extra pixel */
- uiItem *last_item = litem->items.last;
+ uiItem *last_item = (uiItem *)litem->items.last;
extra_pixel = litem->w - (x - litem->x);
if (extra_pixel > 0 && litem->alignment == UI_LAYOUT_ALIGN_EXPAND && last_free_item &&
last_item && last_item->flag & UI_ITEM_AUTO_FIXED_SIZE) {
ui_item_move(last_free_item, 0, extra_pixel);
- for (uiItem *item = last_free_item->next; item; item = item->next) {
+ for (uiItem *item = (uiItem *)last_free_item->next; item; item = item->next) {
ui_item_move(item, extra_pixel, extra_pixel);
}
}
@@ -3869,7 +3882,7 @@ static void ui_litem_estimate_root(uiLayout *UNUSED(litem))
static void ui_litem_layout_root_radial(uiLayout *litem)
{
/* first item is pie menu title, align on center of menu */
- uiItem *item = litem->items.first;
+ uiItem *item = (uiItem *)litem->items.first;
if (item->type == ITEM_BUTTON) {
int itemh, itemw, x, y;
@@ -4079,13 +4092,13 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
}
/* multi-column and multi-row layout. */
-typedef struct UILayoutGridFlowInput {
+struct UILayoutGridFlowInput {
/* General layout control settings. */
- const bool row_major : 1; /* Fill rows before columns */
- const bool even_columns : 1; /* All columns will have same width. */
- const bool even_rows : 1; /* All rows will have same height. */
- const int space_x; /* Space between columns. */
- const int space_y; /* Space between rows. */
+ const bool row_major = true; /* Fill rows before columns */
+ const bool even_columns = true; /* All columns will have same width. */
+ const bool even_rows = true; /* All rows will have same height. */
+ const int space_x; /* Space between columns. */
+ const int space_y; /* Space between rows. */
/* Real data about current position and size of this layout item
* (either estimated, or final values). */
const int litem_w; /* Layout item width. */
@@ -4094,9 +4107,9 @@ typedef struct UILayoutGridFlowInput {
/* Actual number of columns and rows to generate (computed from first pass usually). */
const int tot_columns; /* Number of columns. */
const int tot_rows; /* Number of rows. */
-} UILayoutGridFlowInput;
+};
-typedef struct UILayoutGridFlowOutput {
+struct UILayoutGridFlowOutput {
int *tot_items; /* Total number of items in this grid layout. */
/* Width / X pos data. */
float *global_avg_w; /* Computed average width of the columns. */
@@ -4108,7 +4121,7 @@ typedef struct UILayoutGridFlowOutput {
int *cos_y_array; /* Computed Y coordinate of each column. */
int *heights_array; /* Computed height of each column. */
int *tot_h; /* Computed total height. */
-} UILayoutGridFlowOutput;
+};
static void ui_litem_grid_flow_compute(ListBase *items,
UILayoutGridFlowInput *parameters,
@@ -4118,8 +4131,9 @@ static void ui_litem_grid_flow_compute(ListBase *items,
float global_avg_w = 0.0f, global_totweight_w = 0.0f;
int global_max_h = 0;
- float *avg_w = NULL, *totweight_w = NULL;
- int *max_h = NULL;
+ Array<float, 128> avg_w(parameters->tot_columns, 0.0f);
+ Array<float, 128> totweight_w(parameters->tot_columns, 0.0f);
+ Array<int, 128> max_h(parameters->tot_rows, 0);
BLI_assert(
parameters->tot_columns != 0 ||
@@ -4142,17 +4156,6 @@ static void ui_litem_grid_flow_compute(ListBase *items,
return;
}
- if (parameters->tot_columns != 0) {
- avg_w = BLI_array_alloca(avg_w, parameters->tot_columns);
- totweight_w = BLI_array_alloca(totweight_w, parameters->tot_columns);
- memset(avg_w, 0, sizeof(*avg_w) * parameters->tot_columns);
- memset(totweight_w, 0, sizeof(*totweight_w) * parameters->tot_columns);
- }
- if (parameters->tot_rows != 0) {
- max_h = BLI_array_alloca(max_h, parameters->tot_rows);
- memset(max_h, 0, sizeof(*max_h) * parameters->tot_rows);
- }
-
int i = 0;
LISTBASE_FOREACH (uiItem *, item, items) {
int item_w, item_h;
@@ -4270,22 +4273,22 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
float avg_w;
int max_h;
- ui_litem_grid_flow_compute(&litem->items,
- &((UILayoutGridFlowInput){
- .row_major = gflow->row_major,
- .even_columns = gflow->even_columns,
- .even_rows = gflow->even_rows,
- .litem_w = litem->w,
- .litem_x = litem->x,
- .litem_y = litem->y,
- .space_x = space_x,
- .space_y = space_y,
- }),
- &((UILayoutGridFlowOutput){
- .tot_items = &gflow->tot_items,
- .global_avg_w = &avg_w,
- .global_max_h = &max_h,
- }));
+ UILayoutGridFlowInput grid_flow_input{
+ gflow->row_major,
+ gflow->even_columns,
+ gflow->even_rows,
+ litem->w,
+ litem->x,
+ litem->y,
+ space_x,
+ space_y,
+ };
+ UILayoutGridFlowOutput grid_flow_output;
+ grid_flow_output.tot_items = &gflow->tot_items;
+ grid_flow_output.global_avg_w = &avg_w;
+ grid_flow_output.global_max_h = &max_h;
+
+ ui_litem_grid_flow_compute(&litem->items, &grid_flow_input, &grid_flow_output);
if (gflow->tot_items == 0) {
litem->w = litem->h = 0;
@@ -4361,23 +4364,24 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
{
int tot_w, tot_h;
- ui_litem_grid_flow_compute(&litem->items,
- &((UILayoutGridFlowInput){
- .row_major = gflow->row_major,
- .even_columns = gflow->even_columns,
- .even_rows = gflow->even_rows,
- .litem_w = litem->w,
- .litem_x = litem->x,
- .litem_y = litem->y,
- .space_x = space_x,
- .space_y = space_y,
- .tot_columns = gflow->tot_columns,
- .tot_rows = gflow->tot_rows,
- }),
- &((UILayoutGridFlowOutput){
- .tot_w = &tot_w,
- .tot_h = &tot_h,
- }));
+ UILayoutGridFlowInput grid_flow_input{
+ gflow->row_major,
+ gflow->even_columns,
+ gflow->even_rows,
+ litem->w,
+ litem->x,
+ litem->y,
+ space_x,
+ space_y,
+ gflow->tot_columns,
+ gflow->tot_rows,
+ };
+
+ UILayoutGridFlowOutput grid_flow_output;
+ grid_flow_output.tot_w = &tot_w;
+ grid_flow_output.tot_h = &tot_h;
+
+ ui_litem_grid_flow_compute(&litem->items, &grid_flow_input, &grid_flow_output);
litem->w = tot_w;
litem->h = tot_h;
@@ -4400,31 +4404,32 @@ static void ui_litem_layout_grid_flow(uiLayout *litem)
const int space_x = style->columnspace;
const int space_y = style->buttonspacey;
- int *widths = BLI_array_alloca(widths, gflow->tot_columns);
- int *heights = BLI_array_alloca(heights, gflow->tot_rows);
- int *cos_x = BLI_array_alloca(cos_x, gflow->tot_columns);
- int *cos_y = BLI_array_alloca(cos_y, gflow->tot_rows);
+ Array<int, 64> widths(gflow->tot_columns);
+ Array<int, 64> heights(gflow->tot_rows);
+ Array<int, 64> cos_x(gflow->tot_columns);
+ Array<int, 64> cos_y(gflow->tot_rows);
+
+ UILayoutGridFlowInput grid_flow_input{
+ gflow->row_major,
+ gflow->even_columns,
+ gflow->even_rows,
+ litem->w,
+ litem->x,
+ litem->y,
+ space_x,
+ space_y,
+ gflow->tot_columns,
+ gflow->tot_rows,
+ };
+
+ UILayoutGridFlowOutput grid_flow_output;
+ grid_flow_output.cos_x_array = cos_x.data();
+ grid_flow_output.cos_y_array = cos_y.data();
+ grid_flow_output.widths_array = widths.data();
+ grid_flow_output.heights_array = heights.data();
/* This time we directly compute coordinates and sizes of all cells. */
- ui_litem_grid_flow_compute(&litem->items,
- &((UILayoutGridFlowInput){
- .row_major = gflow->row_major,
- .even_columns = gflow->even_columns,
- .even_rows = gflow->even_rows,
- .litem_w = litem->w,
- .litem_x = litem->x,
- .litem_y = litem->y,
- .space_x = space_x,
- .space_y = space_y,
- .tot_columns = gflow->tot_columns,
- .tot_rows = gflow->tot_rows,
- }),
- &((UILayoutGridFlowOutput){
- .cos_x_array = cos_x,
- .cos_y_array = cos_y,
- .widths_array = widths,
- .heights_array = heights,
- }));
+ ui_litem_grid_flow_compute(&litem->items, &grid_flow_input, &grid_flow_output);
int i;
LISTBASE_FOREACH_INDEX (uiItem *, item, &litem->items, i) {
@@ -4648,7 +4653,7 @@ static void ui_layout_heading_set(uiLayout *layout, const char *heading)
/* layout create functions */
uiLayout *uiLayoutRow(uiLayout *layout, bool align)
{
- uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRow");
+ uiLayout *litem = (uiLayout *)MEM_callocN(sizeof(uiLayout), "uiLayoutRow");
ui_litem_init_from_parent(litem, layout, align);
litem->item.type = ITEM_LAYOUT_ROW;
@@ -4671,7 +4676,7 @@ uiLayout *uiLayoutRowWithHeading(uiLayout *layout, bool align, const char *headi
uiLayout *uiLayoutColumn(uiLayout *layout, bool align)
{
- uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutColumn");
+ uiLayout *litem = (uiLayout *)MEM_callocN(sizeof(uiLayout), "uiLayoutColumn");
ui_litem_init_from_parent(litem, layout, align);
litem->item.type = ITEM_LAYOUT_COLUMN;
@@ -4697,7 +4702,8 @@ uiLayout *uiLayoutColumnWithHeading(uiLayout *layout, bool align, const char *he
uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, bool align)
{
- uiLayoutItemFlow *flow = MEM_callocN(sizeof(uiLayoutItemFlow), "uiLayoutItemFlow");
+ uiLayoutItemFlow *flow = (uiLayoutItemFlow *)MEM_callocN(sizeof(uiLayoutItemFlow),
+ "uiLayoutItemFlow");
ui_litem_init_from_parent(&flow->litem, layout, align);
flow->litem.item.type = ITEM_LAYOUT_COLUMN_FLOW;
@@ -4716,7 +4722,8 @@ uiLayout *uiLayoutGridFlow(uiLayout *layout,
bool even_rows,
bool align)
{
- uiLayoutItemGridFlow *flow = MEM_callocN(sizeof(uiLayoutItemGridFlow), __func__);
+ uiLayoutItemGridFlow *flow = (uiLayoutItemGridFlow *)MEM_callocN(sizeof(uiLayoutItemGridFlow),
+ __func__);
flow->litem.item.type = ITEM_LAYOUT_GRID_FLOW;
ui_litem_init_from_parent(&flow->litem, layout, align);
@@ -4733,7 +4740,7 @@ uiLayout *uiLayoutGridFlow(uiLayout *layout,
static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type)
{
- uiLayoutItemBx *box = MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx");
+ uiLayoutItemBx *box = (uiLayoutItemBx *)MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx");
ui_litem_init_from_parent(&box->litem, layout, false);
box->litem.item.type = ITEM_LAYOUT_BOX;
@@ -4762,7 +4769,7 @@ uiLayout *uiLayoutRadial(uiLayout *layout)
}
}
- uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRadial");
+ uiLayout *litem = (uiLayout *)MEM_callocN(sizeof(uiLayout), "uiLayoutRadial");
ui_litem_init_from_parent(litem, layout, false);
litem->item.type = ITEM_LAYOUT_RADIAL;
@@ -4817,7 +4824,7 @@ uiLayout *uiLayoutListBox(uiLayout *layout,
uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align)
{
- uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutAbsolute");
+ uiLayout *litem = (uiLayout *)MEM_callocN(sizeof(uiLayout), "uiLayoutAbsolute");
ui_litem_init_from_parent(litem, layout, align);
litem->item.type = ITEM_LAYOUT_ABSOLUTE;
@@ -4837,7 +4844,7 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout)
uiLayout *uiLayoutOverlap(uiLayout *layout)
{
- uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutOverlap");
+ uiLayout *litem = (uiLayout *)MEM_callocN(sizeof(uiLayout), "uiLayoutOverlap");
ui_litem_init_from_parent(litem, layout, false);
litem->item.type = ITEM_LAYOUT_OVERLAP;
@@ -4849,7 +4856,8 @@ uiLayout *uiLayoutOverlap(uiLayout *layout)
uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, bool align)
{
- uiLayoutItemSplit *split = MEM_callocN(sizeof(uiLayoutItemSplit), "uiLayoutItemSplit");
+ uiLayoutItemSplit *split = (uiLayoutItemSplit *)MEM_callocN(sizeof(uiLayoutItemSplit),
+ "uiLayoutItemSplit");
ui_litem_init_from_parent(&split->litem, layout, align);
split->litem.item.type = ITEM_LAYOUT_SPLIT;
@@ -5094,7 +5102,7 @@ static bool button_matches_search_filter(uiBut *but, const char *search_filter)
static bool button_group_has_search_match(uiButtonGroup *button_group, const char *search_filter)
{
LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) {
- uiBut *but = link->data;
+ uiBut *but = (uiBut *)link->data;
if (button_matches_search_filter(but, search_filter)) {
return true;
}
@@ -5121,7 +5129,7 @@ static bool block_search_filter_tag_buttons(uiBlock *block, const char *search_f
}
else {
LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) {
- uiBut *but = link->data;
+ uiBut *but = (uiBut *)link->data;
but->flag |= UI_SEARCH_FILTER_NO_MATCH;
}
}
@@ -5431,14 +5439,14 @@ uiLayout *UI_block_layout(uiBlock *block,
int padding,
const uiStyle *style)
{
- uiLayoutRoot *root = MEM_callocN(sizeof(uiLayoutRoot), "uiLayoutRoot");
+ uiLayoutRoot *root = (uiLayoutRoot *)MEM_callocN(sizeof(uiLayoutRoot), "uiLayoutRoot");
root->type = type;
root->style = style;
root->block = block;
root->padding = padding;
root->opcontext = WM_OP_INVOKE_REGION_WIN;
- uiLayout *layout = MEM_callocN(sizeof(uiLayout), "uiLayout");
+ uiLayout *layout = (uiLayout *)MEM_callocN(sizeof(uiLayout), "uiLayout");
layout->item.type = (type == UI_LAYOUT_VERT_BAR) ? ITEM_LAYOUT_COLUMN : ITEM_LAYOUT_ROOT;
/* Only used when 'UI_ITEM_PROP_SEP' is set. */
@@ -5492,7 +5500,7 @@ void UI_block_layout_set_current(uiBlock *block, uiLayout *layout)
void ui_layout_add_but(uiLayout *layout, uiBut *but)
{
- uiButtonItem *bitem = MEM_callocN(sizeof(uiButtonItem), "uiButtonItem");
+ uiButtonItem *bitem = (uiButtonItem *)MEM_callocN(sizeof(uiButtonItem), "uiButtonItem");
bitem->item.type = ITEM_BUTTON;
bitem->but = but;
@@ -5658,7 +5666,7 @@ wmOperatorType *UI_but_operatortype_get_from_enum_menu(uiBut *but, PropertyRNA *
}
if (but->menu_create_func == menu_item_enum_opname_menu) {
- MenuItemLevel *lvl = but->func_argN;
+ MenuItemLevel *lvl = (MenuItemLevel *)but->func_argN;
wmOperatorType *ot = WM_operatortype_find(lvl->opname, false);
if ((ot != NULL) && (r_prop != NULL)) {
*r_prop = RNA_struct_type_find_property(ot->srna, lvl->propname);
@@ -5688,10 +5696,7 @@ PanelType *UI_but_paneltype_get(uiBut *but)
void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout)
{
- Menu menu = {
- .layout = layout,
- .type = mt,
- };
+ Menu menu = {mt, layout};
if (G.debug & G_DEBUG_WM) {
printf("%s: opening menu \"%s\"\n", __func__, mt->idname);
@@ -5730,11 +5735,11 @@ static bool ui_layout_has_panel_label(const uiLayout *layout, const PanelType *p
static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout, bool show_header)
{
- Panel *panel = MEM_callocN(sizeof(Panel), "popover panel");
+ Panel *panel = (Panel *)MEM_callocN(sizeof(Panel), "popover panel");
panel->type = pt;
panel->flag = PNL_POPOVER;
- uiLayout *last_item = layout->items.last;
+ uiLayout *last_item = (uiLayout *)layout->items.last;
/* Draw main panel. */
if (show_header) {
@@ -5762,13 +5767,13 @@ static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout,
/* Draw child panels. */
LISTBASE_FOREACH (LinkData *, link, &pt->children) {
- PanelType *child_pt = link->data;
+ PanelType *child_pt = (PanelType *)link->data;
if (child_pt->poll == NULL || child_pt->poll(C, child_pt)) {
/* Add space if something was added to the layout. */
if (last_item != layout->items.last) {
uiItemS(layout);
- last_item = layout->items.last;
+ last_item = (uiLayout *)layout->items.last;
}
uiLayout *col = uiLayoutColumn(layout, false);
@@ -5816,7 +5821,7 @@ static void ui_layout_introspect_button(DynStr *ds, uiButtonItem *bitem)
if (but->optype) {
char *opstr = WM_operator_pystring_ex(
- but->block->evil_C, NULL, false, true, but->optype, but->opptr);
+ (bContext *)but->block->evil_C, NULL, false, true, but->optype, but->opptr);
BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : "");
MEM_freeN(opstr);
}
@@ -5825,7 +5830,8 @@ static void ui_layout_introspect_button(DynStr *ds, uiButtonItem *bitem)
PropertyRNA *prop = NULL;
wmOperatorType *ot = UI_but_operatortype_get_from_enum_menu(but, &prop);
if (ot) {
- char *opstr = WM_operator_pystring_ex(but->block->evil_C, NULL, false, true, ot, NULL);
+ char *opstr = WM_operator_pystring_ex(
+ (bContext *)but->block->evil_C, NULL, false, true, ot, NULL);
BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : "");
BLI_dynstr_appendf(ds, "'property':'''%s''', ", prop ? RNA_property_identifier(prop) : "");
MEM_freeN(opstr);
@@ -5847,7 +5853,7 @@ static void ui_layout_introspect_items(DynStr *ds, ListBase *lb)
BLI_dynstr_append(ds, "[");
- for (item = lb->first; item; item = item->next) {
+ for (item = (uiItem *)lb->first; item; item = item->next) {
BLI_dynstr_append(ds, "{");
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.cc
index 6505a7cd76a..74d19bb4e6a 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.cc
@@ -171,7 +171,7 @@ static bool panel_active_animation_changed(ListBase *lb,
/* Detect animation. */
if (panel->activedata) {
- uiHandlePanelData *data = panel->activedata;
+ uiHandlePanelData *data = (uiHandlePanelData *)panel->activedata;
if (data->state == PANEL_STATE_ANIMATION) {
*r_panel_animation = panel;
}
@@ -194,7 +194,7 @@ static bool panel_active_animation_changed(ListBase *lb,
static bool properties_space_needs_realign(const ScrArea *area, const ARegion *region)
{
if (area->spacetype == SPACE_PROPERTIES && region->regiontype == RGN_TYPE_WINDOW) {
- SpaceProperties *sbuts = area->spacedata.first;
+ SpaceProperties *sbuts = (SpaceProperties *)area->spacedata.first;
if (sbuts->mainbo != sbuts->mainb) {
return true;
@@ -241,7 +241,7 @@ static Panel *panel_add_instanced(ARegion *region,
PanelType *panel_type,
PointerRNA *custom_data)
{
- Panel *panel = MEM_callocN(sizeof(Panel), __func__);
+ Panel *panel = (Panel *)MEM_callocN(sizeof(Panel), __func__);
panel->type = panel_type;
BLI_strncpy(panel->panelname, panel_type->idname, sizeof(panel->panelname));
@@ -251,7 +251,7 @@ static Panel *panel_add_instanced(ARegion *region,
/* Add the panel's children too. Although they aren't instanced panels, we can still use this
* function to create them, as UI_panel_begin does other things we don't need to do. */
LISTBASE_FOREACH (LinkData *, child, &panel_type->children) {
- PanelType *child_type = child->data;
+ PanelType *child_type = (PanelType *)child->data;
panel_add_instanced(region, &panel->children, child_type, custom_data);
}
@@ -285,7 +285,7 @@ Panel *UI_panel_add_instanced(const bContext *C,
{
ARegionType *region_type = region->type;
- PanelType *panel_type = BLI_findstring(
+ PanelType *panel_type = (PanelType *)BLI_findstring(
&region_type->paneltypes, panel_idname, offsetof(PanelType, idname));
if (panel_type == NULL) {
@@ -383,7 +383,7 @@ bool UI_panel_list_matches_data(ARegion *region,
}
else {
data_len = BLI_listbase_count(data);
- data_link = data->first;
+ data_link = (Link *)data->first;
}
int i = 0;
@@ -454,7 +454,8 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
BLI_assert(start_index != -1); /* The drag panel should definitely be in the list. */
/* Sort the matching instanced panels by their display order. */
- PanelSort *panel_sort = MEM_callocN(list_panels_len * sizeof(*panel_sort), __func__);
+ PanelSort *panel_sort = (PanelSort *)MEM_callocN(list_panels_len * sizeof(*panel_sort),
+ __func__);
PanelSort *sort_index = panel_sort;
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
if (panel->type) {
@@ -709,7 +710,7 @@ Panel *UI_panel_begin(
const bool newpanel = (panel == NULL);
if (newpanel) {
- panel = MEM_callocN(sizeof(Panel), __func__);
+ panel = (Panel *)MEM_callocN(sizeof(Panel), __func__);
panel->type = pt;
BLI_strncpy(panel->panelname, idname, sizeof(panel->panelname));
@@ -739,7 +740,7 @@ Panel *UI_panel_begin(
/* If a new panel is added, we insert it right after the panel that was last added.
* This way new panels are inserted in the right place between versions. */
- for (panel_last = lb->first; panel_last; panel_last = panel_last->next) {
+ for (panel_last = (Panel *)lb->first; panel_last; panel_last = panel_last->next) {
if (panel_last->runtime_flag & PANEL_LAST_ADDED) {
BLI_remlink(lb, panel);
BLI_insertlinkafter(lb, panel_last, panel);
@@ -788,7 +789,8 @@ void UI_panel_header_buttons_begin(Panel *panel)
{
uiBlock *block = panel->runtime.block;
- ui_block_new_button_group(block, UI_BUTTON_GROUP_LOCK | UI_BUTTON_GROUP_PANEL_HEADER);
+ uiButtonGroup *new_group = ui_block_new_button_group(block);
+ new_group->flag = (UI_BUTTON_GROUP_LOCK | UI_BUTTON_GROUP_PANEL_HEADER);
}
/**
@@ -801,7 +803,7 @@ void UI_panel_header_buttons_end(Panel *panel)
/* A button group should always be created in #UI_panel_header_buttons_begin. */
BLI_assert(!BLI_listbase_is_empty(&block->button_groups));
- uiButtonGroup *button_group = block->button_groups.last;
+ uiButtonGroup *button_group = (uiButtonGroup *)block->button_groups.last;
button_group->flag &= ~UI_BUTTON_GROUP_LOCK;
@@ -816,7 +818,7 @@ void UI_panel_header_buttons_end(Panel *panel)
/* Always add a new button group. Although this may result in many empty groups, without it,
* new buttons in the panel body not protected with a #ui_block_new_button_group call would
* end up in the panel header group. */
- ui_block_new_button_group(block, 0);
+ ui_block_new_button_group(block);
}
}
@@ -994,7 +996,7 @@ static void panel_remove_invisible_layouts_recursive(Panel *panel, const Panel *
continue;
}
LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) {
- uiBut *but = link->data;
+ uiBut *but = (uiBut *)link->data;
but->flag |= UI_HIDDEN;
}
}
@@ -1561,26 +1563,28 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
{
/* Draw filled rectangle and outline for tab. */
UI_draw_roundbox_corner_set(roundboxtype);
- UI_draw_roundbox_4fv(
- &(const rctf){
- .xmin = rct->xmin,
- .xmax = rct->xmax,
- .ymin = rct->ymin,
- .ymax = rct->ymax,
- },
- true,
- tab_curve_radius,
- is_active ? theme_col_tab_active : theme_col_tab_inactive);
- UI_draw_roundbox_4fv(
- &(const rctf){
- .xmin = rct->xmin,
- .xmax = rct->xmax,
- .ymin = rct->ymin,
- .ymax = rct->ymax,
- },
- false,
- tab_curve_radius,
- theme_col_tab_outline);
+ {
+ const rctf box_rect{
+ rct->xmin,
+ rct->xmax,
+ rct->ymin,
+ rct->ymax,
+ };
+ UI_draw_roundbox_4fv(&box_rect,
+ true,
+ tab_curve_radius,
+ is_active ? theme_col_tab_active : theme_col_tab_inactive);
+ }
+
+ {
+ const rctf box_rect{
+ rct->xmin,
+ rct->xmax,
+ rct->ymin,
+ rct->ymax,
+ };
+ UI_draw_roundbox_4fv(&box_rect, false, tab_curve_radius, theme_col_tab_outline);
+ }
/* Disguise the outline on one side to join the tab to the panel. */
pos = GPU_vertformat_attr_add(
@@ -1771,7 +1775,8 @@ static bool uiAlignPanelStep(ARegion *region, const float factor, const bool dra
}
/* Sort panels. */
- PanelSort *panel_sort = MEM_mallocN(sizeof(PanelSort) * active_panels_len, __func__);
+ PanelSort *panel_sort = (PanelSort *)MEM_mallocN(sizeof(PanelSort) * active_panels_len,
+ __func__);
{
PanelSort *ps = panel_sort;
LISTBASE_FOREACH (Panel *, panel, &region->panels) {
@@ -1882,7 +1887,7 @@ static void ui_panels_size(ARegion *region, int *r_x, int *r_y)
static void ui_do_animate(bContext *C, Panel *panel)
{
- uiHandlePanelData *data = panel->activedata;
+ uiHandlePanelData *data = (uiHandlePanelData *)panel->activedata;
ARegion *region = CTX_wm_region(C);
float fac = (PIL_check_seconds_timer() - data->starttime) / ANIMATION_TIME;
@@ -1983,7 +1988,7 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y)
#define DRAG_REGION_PAD (PNL_HEADER * 0.5)
static void ui_do_drag(const bContext *C, const wmEvent *event, Panel *panel)
{
- uiHandlePanelData *data = panel->activedata;
+ uiHandlePanelData *data = (uiHandlePanelData *)panel->activedata;
ARegion *region = CTX_wm_region(C);
/* Keep the drag position in the region with a small pad to keep the panel visible. */
@@ -2040,7 +2045,7 @@ typedef struct uiPanelDragCollapseHandle {
static void ui_panel_drag_collapse_handler_remove(bContext *UNUSED(C), void *userdata)
{
- uiPanelDragCollapseHandle *dragcol_data = userdata;
+ uiPanelDragCollapseHandle *dragcol_data = (uiPanelDragCollapseHandle *)userdata;
MEM_freeN(dragcol_data);
}
@@ -2097,7 +2102,7 @@ static void ui_panel_drag_collapse(const bContext *C,
static int ui_panel_drag_collapse_handler(bContext *C, const wmEvent *event, void *userdata)
{
wmWindow *win = CTX_wm_window(C);
- uiPanelDragCollapseHandle *dragcol_data = userdata;
+ uiPanelDragCollapseHandle *dragcol_data = (uiPanelDragCollapseHandle *)userdata;
short retval = WM_UI_HANDLER_CONTINUE;
switch (event->type) {
@@ -2128,7 +2133,8 @@ static void ui_panel_drag_collapse_handler_add(const bContext *C, const bool was
{
wmWindow *win = CTX_wm_window(C);
const wmEvent *event = win->eventstate;
- uiPanelDragCollapseHandle *dragcol_data = MEM_mallocN(sizeof(*dragcol_data), __func__);
+ uiPanelDragCollapseHandle *dragcol_data = (uiPanelDragCollapseHandle *)MEM_mallocN(
+ sizeof(*dragcol_data), __func__);
dragcol_data->was_first_open = was_open;
copy_v2_v2_int(dragcol_data->xy_init, &event->x);
@@ -2193,7 +2199,7 @@ static void ui_handle_panel_header(const bContext *C,
else {
/* If a panel has sub-panels and it's open, toggle the expansion
* of the sub-panels (based on the expansion of the first sub-panel). */
- Panel *first_child = panel->children.first;
+ Panel *first_child = (Panel *)panel->children.first;
BLI_assert(first_child != NULL);
panel_set_flag_recursive(panel, PNL_CLOSED, !UI_panel_is_closed(first_child));
panel->flag |= PNL_CLOSED;
@@ -2248,12 +2254,13 @@ bool UI_panel_category_is_visible(const ARegion *region)
PanelCategoryDyn *UI_panel_category_find(const ARegion *region, const char *idname)
{
- return BLI_findstring(&region->panels_category, idname, offsetof(PanelCategoryDyn, idname));
+ return (PanelCategoryDyn *)BLI_findstring(
+ &region->panels_category, idname, offsetof(PanelCategoryDyn, idname));
}
PanelCategoryStack *UI_panel_category_active_find(ARegion *region, const char *idname)
{
- return BLI_findstring(
+ return (PanelCategoryStack *)BLI_findstring(
&region->panels_category_active, idname, offsetof(PanelCategoryStack, idname));
}
@@ -2266,7 +2273,7 @@ static void ui_panel_category_active_set(ARegion *region, const char *idname, bo
BLI_remlink(lb, pc_act);
}
else {
- pc_act = MEM_callocN(sizeof(PanelCategoryStack), __func__);
+ pc_act = (PanelCategoryStack *)MEM_callocN(sizeof(PanelCategoryStack), __func__);
BLI_strncpy(pc_act->idname, idname, sizeof(pc_act->idname));
}
@@ -2317,7 +2324,7 @@ const char *UI_panel_category_active_get(ARegion *region, bool set_fallback)
}
if (set_fallback) {
- PanelCategoryDyn *pc_dyn = region->panels_category.first;
+ PanelCategoryDyn *pc_dyn = (PanelCategoryDyn *)region->panels_category.first;
if (pc_dyn) {
ui_panel_category_active_set(region, pc_dyn->idname, true);
return pc_dyn->idname;
@@ -2340,7 +2347,7 @@ static PanelCategoryDyn *panel_categories_find_mouse_over(ARegion *region, const
void UI_panel_category_add(ARegion *region, const char *name)
{
- PanelCategoryDyn *pc_dyn = MEM_callocN(sizeof(*pc_dyn), __func__);
+ PanelCategoryDyn *pc_dyn = (PanelCategoryDyn *)MEM_callocN(sizeof(*pc_dyn), __func__);
BLI_addtail(&region->panels_category, pc_dyn);
BLI_strncpy(pc_dyn->idname, name, sizeof(pc_dyn->idname));
@@ -2385,7 +2392,8 @@ static int ui_handle_panel_category_cycling(const wmEvent *event,
pc_dyn = backwards ? pc_dyn->prev : pc_dyn->next;
if (!pc_dyn) {
/* Proper cyclic behavior, back to first/last category (only used for ctrl+tab). */
- pc_dyn = backwards ? region->panels_category.last : region->panels_category.first;
+ pc_dyn = backwards ? (PanelCategoryDyn *)region->panels_category.last :
+ (PanelCategoryDyn *)region->panels_category.first;
}
}
@@ -2567,8 +2575,8 @@ PointerRNA *UI_region_panel_custom_data_under_cursor(const bContext *C, const wm
/* Note, this is modal handler and should not swallow events for animation. */
static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata)
{
- Panel *panel = userdata;
- uiHandlePanelData *data = panel->activedata;
+ Panel *panel = (Panel *)userdata;
+ uiHandlePanelData *data = (uiHandlePanelData *)panel->activedata;
/* Verify if we can stop. */
if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
@@ -2588,7 +2596,7 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata)
}
}
- data = panel->activedata;
+ data = (uiHandlePanelData *)panel->activedata;
if (data && data->state == PANEL_STATE_ANIMATION) {
return WM_UI_HANDLER_CONTINUE;
@@ -2598,7 +2606,7 @@ static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata)
static void ui_handler_remove_panel(bContext *C, void *userdata)
{
- Panel *panel = userdata;
+ Panel *panel = (Panel *)userdata;
panel_activate_state(C, panel, PANEL_STATE_EXIT);
}
@@ -2615,7 +2623,7 @@ static void panel_handle_data_ensure(const bContext *C,
C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, 0);
}
- uiHandlePanelData *data = panel->activedata;
+ uiHandlePanelData *data = (uiHandlePanelData *)panel->activedata;
data->animtimer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL);
@@ -2636,7 +2644,7 @@ static void panel_handle_data_ensure(const bContext *C,
*/
static void panel_activate_state(const bContext *C, Panel *panel, const uiHandlePanelState state)
{
- uiHandlePanelData *data = panel->activedata;
+ uiHandlePanelData *data = (uiHandlePanelData *)panel->activedata;
wmWindow *win = CTX_wm_window(C);
ARegion *region = CTX_wm_region(C);
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.cc
index aa10d092f5e..f3aeae2464f 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.cc
@@ -199,7 +199,7 @@ static bool ui_but_isect_pie_seg(const uiBlock *block, const uiBut *but)
return false;
}
- ui_but_pie_dir(but->pie_dir, vec);
+ ui_but_pie_dir((RadialDirection)but->pie_dir, vec);
if (saacos(dot_v2v2(vec, block->pie_data.pie_dir)) < angle_range) {
return true;
@@ -412,9 +412,7 @@ uiBut *ui_but_first(uiBlock *block)
uiBut *ui_but_last(uiBlock *block)
{
- uiBut *but;
-
- but = block->buttons.last;
+ uiBut *but = (uiBut *)block->buttons.last;
while (but) {
if (ui_but_is_editable(but)) {
return but;
@@ -517,7 +515,7 @@ static const uiBut *ui_but_next_non_separator(const uiBut *but)
bool UI_block_is_empty_ex(const uiBlock *block, const bool skip_title)
{
- const uiBut *but = block->buttons.first;
+ const uiBut *but = (const uiBut *)block->buttons.first;
if (skip_title) {
/* Skip the first label, since popups often have a title,
* we may want to consider the block empty in this case. */
@@ -537,7 +535,7 @@ bool UI_block_is_empty(const uiBlock *block)
bool UI_block_can_add_separator(const uiBlock *block)
{
if (ui_block_is_menu(block) && !ui_block_is_pie_menu(block)) {
- const uiBut *but = block->buttons.last;
+ const uiBut *but = (const uiBut *)block->buttons.last;
return (but && !ELEM(but->type, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR));
}
return true;
diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.cc
index e68705e4321..e7195ca4643 100644
--- a/source/blender/editors/interface/interface_region_color_picker.c
+++ b/source/blender/editors/interface/interface_region_color_picker.cc
@@ -187,7 +187,7 @@ static void ui_color_picker_update_hsv(ColorPicker *cpicker,
void ui_but_hsv_set(uiBut *but)
{
float rgb_perceptual[3];
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
float *hsv_perceptual = cpicker->hsv_perceptual;
ui_color_picker_hsv_to_rgb(hsv_perceptual, rgb_perceptual);
@@ -274,7 +274,8 @@ static void ui_colorpicker_rgba_update_cb(bContext *UNUSED(C), void *bt1, void *
if (prop) {
RNA_property_float_get_array(&ptr, prop, rgb_scene_linear);
- ui_update_color_picker_buts_rgb(but, but->block, but->custom_data, rgb_scene_linear);
+ ui_update_color_picker_buts_rgb(
+ but, but->block, (ColorPicker *)but->custom_data, rgb_scene_linear);
}
if (popup) {
@@ -287,7 +288,7 @@ static void ui_colorpicker_hsv_update_cb(bContext *UNUSED(C), void *bt1, void *U
uiBut *but = (uiBut *)bt1;
uiPopupBlockHandle *popup = but->block->handle;
float rgb_scene_linear[3];
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
ui_color_picker_hsv_to_rgb(cpicker->hsv_scene_linear, rgb_scene_linear);
ui_update_color_picker_buts_rgb(but, but->block, cpicker, rgb_scene_linear);
@@ -301,7 +302,7 @@ static void ui_colorpicker_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexc
{
uiBut *but = (uiBut *)bt1;
uiPopupBlockHandle *popup = but->block->handle;
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
char *hexcol = (char *)hexcl;
float rgb[3];
@@ -326,7 +327,7 @@ static void ui_popup_close_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
uiPopupBlockHandle *popup = but->block->handle;
if (popup) {
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
BLI_assert(cpicker->is_init);
popup->menuretval = (equals_v3v3(cpicker->hsv_perceptual, cpicker->hsv_perceptual_init) ?
UI_RETURN_CANCEL :
@@ -356,9 +357,9 @@ static void ui_colorpicker_hide_reveal(uiBlock *block, enum ePickerType colormod
static void ui_colorpicker_create_mode_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
{
- uiBut *bt = bt1;
+ uiBut *bt = (uiBut *)bt1;
const short colormode = ui_but_value_get(bt);
- ui_colorpicker_hide_reveal(bt->block, colormode);
+ ui_colorpicker_hide_reveal(bt->block, (ePickerType)colormode);
}
#define PICKER_H (7.5f * U.widget_unit)
@@ -488,7 +489,7 @@ static void ui_colorpicker_square(uiBlock *block,
0,
0,
TIP_("Value"));
- hsv_but->gradient_type = type + 3;
+ hsv_but->gradient_type = (eButGradientType)(type + 3);
UI_but_func_set(&hsv_but->but, ui_colorpicker_rgba_update_cb, &hsv_but->but, NULL);
hsv_but->but.custom_data = cpicker;
}
@@ -835,7 +836,7 @@ static void ui_block_colorpicker(uiBlock *block,
0,
"");
- ui_colorpicker_hide_reveal(block, colormode);
+ ui_colorpicker_hide_reveal(block, (ePickerType)colormode);
}
static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C),
@@ -855,7 +856,7 @@ static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C),
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (but->type == UI_BTYPE_HSVCUBE && but->active == NULL) {
uiPopupBlockHandle *popup = block->handle;
- ColorPicker *cpicker = but->custom_data;
+ ColorPicker *cpicker = (ColorPicker *)but->custom_data;
float *hsv_perceptual = cpicker->hsv_perceptual;
float rgb_perceptual[3];
@@ -884,7 +885,7 @@ static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C),
uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_but)
{
- uiBut *but = arg_but;
+ uiBut *but = (uiBut *)arg_but;
uiBlock *block;
bool show_picker = true;
@@ -920,7 +921,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_
ColorPicker *ui_block_colorpicker_create(struct uiBlock *block)
{
- ColorPicker *cpicker = MEM_callocN(sizeof(ColorPicker), "color_picker");
+ ColorPicker *cpicker = (ColorPicker *)MEM_callocN(sizeof(ColorPicker), "color_picker");
BLI_addhead(&block->color_pickers.list, cpicker);
return cpicker;
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.cc
index b50daa0df21..d7b3130e4ec 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.cc
@@ -106,7 +106,7 @@ static bool hud_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt
ScrArea *area = CTX_wm_area(C);
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_HUD);
if (region != NULL) {
- struct HudRegionData *hrd = region->regiondata;
+ HudRegionData *hrd = (HudRegionData *)region->regiondata;
if (hrd != NULL) {
return last_redo_poll(C, hrd->regionid);
}
@@ -135,9 +135,7 @@ static void hud_panel_operator_redo_draw(const bContext *C, Panel *panel)
static void hud_panels_register(ARegionType *art, int space_type, int region_type)
{
- PanelType *pt;
-
- pt = MEM_callocN(sizeof(PanelType), __func__);
+ PanelType *pt = (PanelType *)MEM_callocN(sizeof(PanelType), __func__);
strcpy(pt->idname, "OPERATOR_PT_redo");
strcpy(pt->label, N_("Redo"));
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
@@ -170,7 +168,7 @@ static void hud_region_free(ARegion *region)
static void hud_region_layout(const bContext *C, ARegion *region)
{
- struct HudRegionData *hrd = region->regiondata;
+ HudRegionData *hrd = (HudRegionData *)region->regiondata;
if (hrd == NULL || !last_redo_poll(C, hrd->regionid)) {
ED_region_tag_redraw(region);
hud_region_hide(region);
@@ -220,19 +218,20 @@ static void hud_region_draw(const bContext *C, ARegion *region)
GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
if ((region->flag & RGN_FLAG_HIDDEN) == 0) {
- ui_draw_menu_back(NULL,
- NULL,
- &(rcti){
- .xmax = region->winx,
- .ymax = region->winy,
- });
+ rcti rect{
+ 0,
+ region->winx,
+ 0,
+ region->winy,
+ };
+ ui_draw_menu_back(NULL, NULL, &rect);
ED_region_panels_draw(C, region);
}
}
ARegionType *ED_area_type_hud(int space_type)
{
- ARegionType *art = MEM_callocN(sizeof(ARegionType), __func__);
+ ARegionType *art = (ARegionType *)MEM_callocN(sizeof(ARegionType), __func__);
art->regionid = RGN_TYPE_HUD;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
art->layout = hud_region_layout;
@@ -253,7 +252,7 @@ ARegionType *ED_area_type_hud(int space_type)
static ARegion *hud_region_add(ScrArea *area)
{
- ARegion *region = MEM_callocN(sizeof(ARegion), "area region");
+ ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "area region");
ARegion *region_win = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
if (region_win) {
BLI_insertlinkbefore(&area->regionbase, region_win, region);
@@ -347,9 +346,9 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *area)
}
{
- struct HudRegionData *hrd = region->regiondata;
+ HudRegionData *hrd = (HudRegionData *)region->regiondata;
if (hrd == NULL) {
- hrd = MEM_callocN(sizeof(*hrd), __func__);
+ hrd = (HudRegionData *)MEM_callocN(sizeof(*hrd), __func__);
region->regiondata = hrd;
}
if (region_op) {
@@ -371,8 +370,10 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *area)
/* Reset zoom level (not well supported). */
region->v2d.cur = region->v2d.tot = (rctf){
- .xmax = region->winx,
- .ymax = region->winy,
+ 0.0f,
+ region->winx,
+ 0.0f,
+ region->winy,
};
region->v2d.minzoom = 1.0f;
region->v2d.maxzoom = 1.0f;
@@ -389,8 +390,10 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *area)
region->winx = region->v2d.winx;
region->winy = region->v2d.winy;
region->v2d.cur = region->v2d.tot = (rctf){
- .xmax = region->winx,
- .ymax = region->winy,
+ 0.0f,
+ region->winx,
+ 0.0f,
+ region->winy,
};
}
CTX_wm_region_set((bContext *)C, region_prev);
diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.cc
index 8135f5a203e..dcfbd538f89 100644
--- a/source/blender/editors/interface/interface_region_popup.c
+++ b/source/blender/editors/interface/interface_region_popup.cc
@@ -354,7 +354,7 @@ static void ui_popup_block_position(wmWindow *window,
}
/* Keep a list of these, needed for pull-down menus. */
- uiSafetyRct *saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
+ uiSafetyRct *saferct = (uiSafetyRct *)MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
saferct->parent = butrct;
saferct->safety = block->safety;
BLI_freelistN(&block->saferct);
@@ -570,7 +570,7 @@ uiBlock *ui_popup_block_refresh(bContext *C,
const uiBlockHandleCreateFunc handle_create_func = handle->popup_create_vars.handle_create_func;
void *arg = handle->popup_create_vars.arg;
- uiBlock *block_old = region->uiblocks.first;
+ uiBlock *block_old = (uiBlock *)region->uiblocks.first;
uiBlock *block;
handle->refresh = (block_old != NULL);
@@ -633,7 +633,7 @@ uiBlock *ui_popup_block_refresh(bContext *C,
else {
uiSafetyRct *saferct;
/* Keep a list of these, needed for pull-down menus. */
- saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
+ saferct = (uiSafetyRct *)MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
saferct->safety = block->safety;
BLI_addhead(&block->saferct, saferct);
}
@@ -780,7 +780,6 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C,
static ARegionType type;
ARegion *region;
uiBlock *block;
- uiPopupBlockHandle *handle;
/* disable tooltips from buttons below */
if (activebut) {
@@ -790,7 +789,8 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C,
WM_cursor_set(window, WM_CURSOR_DEFAULT);
/* create handle */
- handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
+ uiPopupBlockHandle *handle = (uiPopupBlockHandle *)MEM_callocN(sizeof(uiPopupBlockHandle),
+ "uiPopupBlockHandle");
/* store context for operator */
handle->ctx_area = CTX_wm_area(C);
diff --git a/source/blender/editors/interface/interface_region_search.c b/source/blender/editors/interface/interface_region_search.cc
index 987cde61f97..28343f81836 100644
--- a/source/blender/editors/interface/interface_region_search.c
+++ b/source/blender/editors/interface/interface_region_search.cc
@@ -167,7 +167,7 @@ bool UI_search_item_add(uiSearchItems *items,
if (name_prefix_offset != 0) {
/* Lazy initialize, as this isn't used often. */
if (items->name_prefix_offsets == NULL) {
- items->name_prefix_offsets = MEM_callocN(
+ items->name_prefix_offsets = (uint8_t *)MEM_callocN(
items->maxitem * sizeof(*items->name_prefix_offsets), "search name prefix offsets");
}
items->name_prefix_offsets[items->totitem] = name_prefix_offset;
@@ -218,7 +218,7 @@ int UI_search_items_find_index(uiSearchItems *items, const char *name)
/* region is the search box itself */
static void ui_searchbox_select(bContext *C, ARegion *region, uiBut *but, int step)
{
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
/* apply step */
data->active += step;
@@ -285,14 +285,14 @@ static void ui_searchbox_butrect(rcti *r_rect, uiSearchboxData *data, int itemnr
int ui_searchbox_find_index(ARegion *region, const char *name)
{
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
return UI_search_items_find_index(&data->items, name);
}
/* x and y in screen-coords. */
bool ui_searchbox_inside(ARegion *region, int x, int y)
{
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
return BLI_rcti_isect_pt(&data->bbox, x - region->winrct.xmin, y - region->winrct.ymin);
}
@@ -300,7 +300,7 @@ bool ui_searchbox_inside(ARegion *region, int x, int y)
/* string validated to be of correct length (but->hardmax) */
bool ui_searchbox_apply(uiBut *but, ARegion *region)
{
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
uiButSearch *search_but = (uiButSearch *)but;
BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
@@ -352,7 +352,7 @@ static struct ARegion *wm_searchbox_tooltip_init(struct bContext *C,
}
ARegion *searchbox_region = UI_region_searchbox_region_get(region);
- uiSearchboxData *data = searchbox_region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)searchbox_region->regiondata;
BLI_assert(data->items.pointers[data->active] == search_but->item_active);
@@ -369,7 +369,7 @@ static struct ARegion *wm_searchbox_tooltip_init(struct bContext *C,
bool ui_searchbox_event(
bContext *C, ARegion *region, uiBut *but, ARegion *butregion, const wmEvent *event)
{
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
uiButSearch *search_but = (uiButSearch *)but;
int type = event->type, val = event->val;
bool handled = false;
@@ -476,7 +476,7 @@ static void ui_searchbox_update_fn(bContext *C,
void ui_searchbox_update(bContext *C, ARegion *region, uiBut *but, const bool reset)
{
uiButSearch *search_but = (uiButSearch *)but;
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
@@ -555,7 +555,7 @@ void ui_searchbox_update(bContext *C, ARegion *region, uiBut *but, const bool re
int ui_searchbox_autocomplete(bContext *C, ARegion *region, uiBut *but, char *str)
{
uiButSearch *search_but = (uiButSearch *)but;
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
int match = AUTOCOMPLETE_NO_MATCH;
BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
@@ -574,7 +574,7 @@ int ui_searchbox_autocomplete(bContext *C, ARegion *region, uiBut *but, char *st
static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *region)
{
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
/* pixel space */
wmOrtho2_region_pixelspace(region);
@@ -699,7 +699,7 @@ static void ui_searchbox_region_draw_cb(const bContext *C, ARegion *region)
static void ui_searchbox_region_free_cb(ARegion *region)
{
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
int a;
/* free search data */
@@ -738,7 +738,8 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearc
region->type = &type;
/* create searchbox data */
- uiSearchboxData *data = MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData");
+ uiSearchboxData *data = (uiSearchboxData *)MEM_callocN(sizeof(uiSearchboxData),
+ "uiSearchboxData");
/* set font, get bb */
data->fstyle = style->widget; /* copy struct */
@@ -876,13 +877,14 @@ ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiButSearc
}
data->items.maxstrlen = but->hardmax;
data->items.totitem = 0;
- data->items.names = MEM_callocN(data->items.maxitem * sizeof(void *), "search names");
- data->items.pointers = MEM_callocN(data->items.maxitem * sizeof(void *), "search pointers");
- data->items.icons = MEM_callocN(data->items.maxitem * sizeof(int), "search icons");
- data->items.states = MEM_callocN(data->items.maxitem * sizeof(int), "search flags");
+ data->items.names = (char **)MEM_callocN(data->items.maxitem * sizeof(void *), "search names");
+ data->items.pointers = (void **)MEM_callocN(data->items.maxitem * sizeof(void *),
+ "search pointers");
+ data->items.icons = (int *)MEM_callocN(data->items.maxitem * sizeof(int), "search icons");
+ data->items.states = (int *)MEM_callocN(data->items.maxitem * sizeof(int), "search flags");
data->items.name_prefix_offsets = NULL; /* Lazy initialized as needed. */
for (int i = 0; i < data->items.maxitem; i++) {
- data->items.names[i] = MEM_callocN(but->hardmax + 1, "search pointers");
+ data->items.names[i] = (char *)MEM_callocN(but->hardmax + 1, "search pointers");
}
return region;
@@ -915,7 +917,7 @@ static void str_tolower_titlecaps_ascii(char *str, const size_t len)
static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARegion *region)
{
- uiSearchboxData *data = region->regiondata;
+ uiSearchboxData *data = (uiSearchboxData *)region->regiondata;
/* pixel space */
wmOrtho2_region_pixelspace(region);
@@ -944,9 +946,9 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
{
const int state = ((a == data->active) ? UI_ACTIVE : 0) | data->items.states[a];
- wmOperatorType *ot = data->items.pointers[a];
+ wmOperatorType *ot = (wmOperatorType *)data->items.pointers[a];
char text_pre[128];
- char *text_pre_p = strstr(ot->idname, "_OT_");
+ char *text_pre_p = const_cast<char *>(strstr(ot->idname, "_OT_"));
if (text_pre_p == NULL) {
text_pre[0] = '\0';
}
@@ -1040,17 +1042,17 @@ void ui_but_search_refresh(uiButSearch *search_but)
return;
}
- items = MEM_callocN(sizeof(uiSearchItems), "search items");
+ items = (uiSearchItems *)MEM_callocN(sizeof(uiSearchItems), "search items");
/* setup search struct */
items->maxitem = 10;
items->maxstrlen = 256;
- items->names = MEM_callocN(items->maxitem * sizeof(void *), "search names");
+ items->names = (char **)MEM_callocN(items->maxitem * sizeof(void *), "search names");
for (x1 = 0; x1 < items->maxitem; x1++) {
- items->names[x1] = MEM_callocN(but->hardmax + 1, "search names");
+ items->names[x1] = (char *)MEM_callocN(but->hardmax + 1, "search names");
}
- ui_searchbox_update_fn(but->block->evil_C, search_but, but->drawstr, items);
+ ui_searchbox_update_fn((bContext *)but->block->evil_C, search_but, but->drawstr, items);
if (!search_but->results_are_suggestions) {
/* Only red-alert when we are sure of it, this can miss cases when >10 matches. */
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.cc
index 51b4e82d679..9934421c7d2 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.cc
@@ -41,7 +41,7 @@
ARegion *ui_region_temp_add(bScreen *screen)
{
- ARegion *region = MEM_callocN(sizeof(ARegion), __func__);
+ ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), __func__);
BLI_addtail(&screen->regionbase, region);
region->regiontype = RGN_TYPE_TEMPORARY;
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.cc
index ad0c523a594..b3aca8f9ea2 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.cc
@@ -74,7 +74,7 @@
static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id)
{
- uiStyle *style = MEM_callocN(sizeof(uiStyle), "new style");
+ uiStyle *style = (uiStyle *)MEM_callocN(sizeof(uiStyle), "new style");
BLI_addtail(styles, style);
BLI_strncpy(style->name, name, MAX_STYLE_NAME);
@@ -129,14 +129,14 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
static uiFont *uifont_to_blfont(int id)
{
- uiFont *font = U.uifonts.first;
+ uiFont *font = (uiFont *)U.uifonts.first;
for (; font; font = font->next) {
if (font->uifont_id == id) {
return font;
}
}
- return U.uifonts.first;
+ return (uiFont *)U.uifonts.first;
}
/* *************** draw ************************ */
@@ -373,7 +373,7 @@ const uiStyle *UI_style_get(void)
style = BLI_findstring(&U.uistyles, "Unifont Style", sizeof(style) * 2);
return (style != NULL) ? style : U.uistyles.first;
#else
- return U.uistyles.first;
+ return (uiStyle *)U.uistyles.first;
#endif
}
@@ -432,9 +432,9 @@ int UI_fontstyle_height_max(const uiFontStyle *fs)
/* called on each startup.blend read */
/* reading without uifont will create one */
-void uiStyleInit(void)
+void uiStyleInit()
{
- uiStyle *style = U.uistyles.first;
+ uiStyle *style = (uiStyle *)U.uistyles.first;
/* recover from uninitialized dpi */
if (U.dpi == 0) {
@@ -456,11 +456,11 @@ void uiStyleInit(void)
blf_mono_font_render = -1;
}
- uiFont *font_first = U.uifonts.first;
+ uiFont *font_first = (uiFont *)U.uifonts.first;
/* default builtin */
if (font_first == NULL) {
- font_first = MEM_callocN(sizeof(uiFont), "ui font");
+ font_first = (uiFont *)MEM_callocN(sizeof(uiFont), "ui font");
BLI_addtail(&U.uifonts, font_first);
}
diff --git a/source/blender/editors/interface/interface_template_search_menu.c b/source/blender/editors/interface/interface_template_search_menu.cc
index 91ad6619889..fc7d705a150 100644
--- a/source/blender/editors/interface/interface_template_search_menu.c
+++ b/source/blender/editors/interface/interface_template_search_menu.cc
@@ -88,16 +88,16 @@ struct MenuSearch_Context {
};
struct MenuSearch_Parent {
- struct MenuSearch_Parent *parent;
+ MenuSearch_Parent *parent;
MenuType *parent_mt;
const char *drawstr;
/** Set while writing menu items only. */
- struct MenuSearch_Parent *temp_child;
+ MenuSearch_Parent *temp_child;
};
struct MenuSearch_Item {
- struct MenuSearch_Item *next, *prev;
+ MenuSearch_Item *next, *prev;
const char *drawstr;
const char *drawwstr_full;
/** Support a single level sub-menu nesting (for operator buttons that expand). */
@@ -105,7 +105,7 @@ struct MenuSearch_Item {
int icon;
int state;
- struct MenuSearch_Parent *menu_parent;
+ MenuSearch_Parent *menu_parent;
MenuType *mt;
enum {
@@ -133,7 +133,7 @@ struct MenuSearch_Item {
};
/** Set when we need each menu item to be able to set its own context. may be NULL. */
- struct MenuSearch_Context *wm_context;
+ MenuSearch_Context *wm_context;
};
struct MenuSearch_Data {
@@ -151,15 +151,15 @@ struct MenuSearch_Data {
static int menu_item_sort_by_drawstr_full(const void *menu_item_a_v, const void *menu_item_b_v)
{
- const struct MenuSearch_Item *menu_item_a = menu_item_a_v;
- const struct MenuSearch_Item *menu_item_b = menu_item_b_v;
+ const MenuSearch_Item *menu_item_a = (MenuSearch_Item *)menu_item_a_v;
+ const MenuSearch_Item *menu_item_b = (MenuSearch_Item *)menu_item_b_v;
return strcmp(menu_item_a->drawwstr_full, menu_item_b->drawwstr_full);
}
static const char *strdup_memarena(MemArena *memarena, const char *str)
{
const uint str_size = strlen(str) + 1;
- char *str_dst = BLI_memarena_alloc(memarena, str_size);
+ char *str_dst = (char *)BLI_memarena_alloc(memarena, str_size);
memcpy(str_dst, str, str_size);
return str_dst;
}
@@ -167,19 +167,19 @@ static const char *strdup_memarena(MemArena *memarena, const char *str)
static const char *strdup_memarena_from_dynstr(MemArena *memarena, DynStr *dyn_str)
{
const uint str_size = BLI_dynstr_get_len(dyn_str) + 1;
- char *str_dst = BLI_memarena_alloc(memarena, str_size);
+ char *str_dst = (char *)BLI_memarena_alloc(memarena, str_size);
BLI_dynstr_get_cstring_ex(dyn_str, str_dst);
return str_dst;
}
-static bool menu_items_from_ui_create_item_from_button(struct MenuSearch_Data *data,
+static bool menu_items_from_ui_create_item_from_button(MenuSearch_Data *data,
MemArena *memarena,
struct MenuType *mt,
const char *drawstr_submenu,
uiBut *but,
- struct MenuSearch_Context *wm_context)
+ MenuSearch_Context *wm_context)
{
- struct MenuSearch_Item *item = NULL;
+ MenuSearch_Item *item = NULL;
/* Use override if the name is empty, this can happen with popovers. */
const char *drawstr_override = NULL;
@@ -193,8 +193,8 @@ static bool menu_items_from_ui_create_item_from_button(struct MenuSearch_Data *d
drawstr_override = WM_operatortype_name(but->optype, but->opptr);
}
- item = BLI_memarena_calloc(memarena, sizeof(*item));
- item->type = MENU_SEARCH_TYPE_OP;
+ item = (MenuSearch_Item *)BLI_memarena_calloc(memarena, sizeof(*item));
+ item->type = MenuSearch_Item::MENU_SEARCH_TYPE_OP;
item->op.type = but->optype;
item->op.opcontext = but->opcontext;
@@ -209,8 +209,11 @@ static bool menu_items_from_ui_create_item_from_button(struct MenuSearch_Data *d
if (prop_type == PROP_ENUM) {
const int value_enum = (int)but->hardmax;
EnumPropertyItem enum_item;
- if (RNA_property_enum_item_from_value_gettexted(
- but->block->evil_C, &but->rnapoin, but->rnaprop, value_enum, &enum_item)) {
+ if (RNA_property_enum_item_from_value_gettexted((bContext *)but->block->evil_C,
+ &but->rnapoin,
+ but->rnaprop,
+ value_enum,
+ &enum_item)) {
drawstr_override = enum_item.name;
}
else {
@@ -232,8 +235,8 @@ static bool menu_items_from_ui_create_item_from_button(struct MenuSearch_Data *d
prop_type);
}
else {
- item = BLI_memarena_calloc(memarena, sizeof(*item));
- item->type = MENU_SEARCH_TYPE_RNA;
+ MenuSearch_Item *item = (MenuSearch_Item *)BLI_memarena_calloc(memarena, sizeof(*item));
+ item->type = MenuSearch_Item::MENU_SEARCH_TYPE_RNA;
item->rna.ptr = but->rnapoin;
item->rna.prop = but->rnaprop;
@@ -275,11 +278,11 @@ static bool menu_items_from_ui_create_item_from_button(struct MenuSearch_Data *d
/**
* Populate a fake button from a menu item (use for context menu).
*/
-static bool menu_items_to_ui_button(struct MenuSearch_Item *item, uiBut *but)
+static bool menu_items_to_ui_button(MenuSearch_Item *item, uiBut *but)
{
bool changed = false;
switch (item->type) {
- case MENU_SEARCH_TYPE_OP: {
+ case MenuSearch_Item::MENU_SEARCH_TYPE_OP: {
but->optype = item->op.type;
but->opcontext = item->op.opcontext;
but->context = item->op.context;
@@ -287,7 +290,7 @@ static bool menu_items_to_ui_button(struct MenuSearch_Item *item, uiBut *but)
changed = true;
break;
}
- case MENU_SEARCH_TYPE_RNA: {
+ case MenuSearch_Item::MENU_SEARCH_TYPE_RNA: {
const int prop_type = RNA_property_type(item->rna.prop);
but->rnapoin = item->rna.ptr;
@@ -310,7 +313,7 @@ static bool menu_items_to_ui_button(struct MenuSearch_Item *item, uiBut *but)
*drawstr_sep = '\0';
}
- but->icon = item->icon;
+ but->icon = (BIFIconID)item->icon;
but->str = but->strdata;
}
@@ -381,7 +384,7 @@ static void menu_types_add_from_keymap_items(bContext *C,
/**
* Display all operators (last). Developer-only convenience feature.
*/
-static void menu_items_from_all_operators(bContext *C, struct MenuSearch_Data *data)
+static void menu_items_from_all_operators(bContext *C, MenuSearch_Data *data)
{
/* Add to temporary list so we can sort them separately. */
ListBase operator_items = {NULL, NULL};
@@ -390,7 +393,7 @@ static void menu_items_from_all_operators(bContext *C, struct MenuSearch_Data *d
GHashIterator iter;
for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter);
BLI_ghashIterator_step(&iter)) {
- wmOperatorType *ot = BLI_ghashIterator_getValue(&iter);
+ wmOperatorType *ot = (wmOperatorType *)BLI_ghashIterator_getValue(&iter);
if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) {
continue;
@@ -399,9 +402,8 @@ static void menu_items_from_all_operators(bContext *C, struct MenuSearch_Data *d
if (WM_operator_poll((bContext *)C, ot)) {
const char *ot_ui_name = CTX_IFACE_(ot->translation_context, ot->name);
- struct MenuSearch_Item *item = NULL;
- item = BLI_memarena_calloc(memarena, sizeof(*item));
- item->type = MENU_SEARCH_TYPE_OP;
+ MenuSearch_Item *item = (MenuSearch_Item *)BLI_memarena_calloc(memarena, sizeof(*item));
+ item->type = MenuSearch_Item::MENU_SEARCH_TYPE_OP;
item->op.type = ot;
item->op.opcontext = WM_OP_INVOKE_DEFAULT;
@@ -433,7 +435,7 @@ static void menu_items_from_all_operators(bContext *C, struct MenuSearch_Data *d
* - Look up predefined editor-menus.
* - Look up key-map items which call menus.
*/
-static struct MenuSearch_Data *menu_items_from_ui_create(
+static MenuSearch_Data *menu_items_from_ui_create(
bContext *C, wmWindow *win, ScrArea *area_init, ARegion *region_init, bool include_all_areas)
{
MemArena *memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
@@ -443,7 +445,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
const uiStyle *style = UI_style_get_dpi();
/* Convert into non-ui structure. */
- struct MenuSearch_Data *data = MEM_callocN(sizeof(*data), __func__);
+ MenuSearch_Data *data = (MenuSearch_Data *)MEM_callocN(sizeof(*data), __func__);
DynStr *dyn_str = BLI_dynstr_new_memarena();
@@ -482,7 +484,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
for (WM_menutype_iter(&iter); (!BLI_ghashIterator_done(&iter));
(BLI_ghashIterator_step(&iter))) {
- MenuType *mt = BLI_ghashIterator_getValue(&iter);
+ MenuType *mt = (MenuType *)BLI_ghashIterator_getValue(&iter);
if (BLI_str_endswith(mt->idname, "_context_menu")) {
BLI_gset_add(menu_tagged, mt);
}
@@ -500,7 +502,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
}
/* Collect contexts, one for each 'ui_type'. */
- struct MenuSearch_Context *wm_contexts = NULL;
+ MenuSearch_Context *wm_contexts = NULL;
const EnumPropertyItem *space_type_ui_items = NULL;
int space_type_ui_items_len = 0;
@@ -531,7 +533,8 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
&space_type_ui_items_len,
&space_type_ui_items_free);
- wm_contexts = BLI_memarena_calloc(memarena, sizeof(*wm_contexts) * space_type_ui_items_len);
+ wm_contexts = (MenuSearch_Context *)BLI_memarena_calloc(
+ memarena, sizeof(*wm_contexts) * space_type_ui_items_len);
for (int i = 0; i < space_type_ui_items_len; i++) {
wm_contexts[i].space_type_ui_index = -1;
}
@@ -574,7 +577,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
ScrArea *area = NULL;
ARegion *region = NULL;
- struct MenuSearch_Context *wm_context = NULL;
+ MenuSearch_Context *wm_context = NULL;
if (include_all_areas) {
if (space_type_ui_index == -1) {
@@ -623,7 +626,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
break
if (area != NULL) {
- SpaceLink *sl = area->spacedata.first;
+ SpaceLink *sl = (SpaceLink *)area->spacedata.first;
switch ((eSpace_Type)area->spacetype) {
SPACE_MENU_MAP(SPACE_VIEW3D, "VIEW3D_MT_editor_menus");
SPACE_MENU_MAP(SPACE_GRAPH, "GRAPH_MT_editor_menus");
@@ -669,7 +672,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
bool has_keymap_menu_items = false;
while (menu_stack != NULL) {
- MenuType *mt = BLI_linklist_pop(&menu_stack);
+ MenuType *mt = (MenuType *)BLI_linklist_pop(&menu_stack);
if (!WM_menutype_poll(C, mt)) {
continue;
}
@@ -713,8 +716,8 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
}
if (!BLI_ghash_haskey(menu_parent_map, mt_from_but)) {
- struct MenuSearch_Parent *menu_parent = BLI_memarena_calloc(memarena,
- sizeof(*menu_parent));
+ MenuSearch_Parent *menu_parent = (MenuSearch_Parent *)BLI_memarena_calloc(
+ memarena, sizeof(*menu_parent));
/* Use brackets for menu key shortcuts,
* converting "Text|Some-Shortcut" to "Text (Some-Shortcut)".
* This is needed so we don't right align sub-menu contents
@@ -804,20 +807,21 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
}
}
- LISTBASE_FOREACH (struct MenuSearch_Item *, item, &data->items) {
- item->menu_parent = BLI_ghash_lookup(menu_parent_map, item->mt);
+ LISTBASE_FOREACH (MenuSearch_Item *, item, &data->items) {
+ item->menu_parent = (MenuSearch_Parent *)BLI_ghash_lookup(menu_parent_map, item->mt);
}
GHASH_ITER (iter, menu_parent_map) {
- struct MenuSearch_Parent *menu_parent = BLI_ghashIterator_getValue(&iter);
- menu_parent->parent = BLI_ghash_lookup(menu_parent_map, menu_parent->parent_mt);
+ MenuSearch_Parent *menu_parent = (MenuSearch_Parent *)BLI_ghashIterator_getValue(&iter);
+ menu_parent->parent = (MenuSearch_Parent *)BLI_ghash_lookup(menu_parent_map,
+ menu_parent->parent_mt);
}
/* NOTE: currently this builds the full path for each menu item,
* that could be moved into the parent menu. */
/* Set names as full paths. */
- LISTBASE_FOREACH (struct MenuSearch_Item *, item, &data->items) {
+ LISTBASE_FOREACH (MenuSearch_Item *, item, &data->items) {
BLI_assert(BLI_dynstr_get_len(dyn_str) == 0);
if (include_all_areas) {
@@ -829,7 +833,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
}
if (item->menu_parent != NULL) {
- struct MenuSearch_Parent *menu_parent = item->menu_parent;
+ MenuSearch_Parent *menu_parent = item->menu_parent;
menu_parent->temp_child = NULL;
while (menu_parent && menu_parent->parent) {
menu_parent->parent->temp_child = menu_parent;
@@ -842,13 +846,13 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
}
}
else {
- const char *drawstr = BLI_ghash_lookup(menu_display_name_map, item->mt);
+ const char *drawstr = (const char *)BLI_ghash_lookup(menu_display_name_map, item->mt);
if (drawstr == NULL) {
drawstr = CTX_IFACE_(item->mt->translation_context, item->mt->label);
}
BLI_dynstr_append(dyn_str, drawstr);
- wmKeyMapItem *kmi = BLI_ghash_lookup(menu_to_kmi, item->mt);
+ wmKeyMapItem *kmi = (wmKeyMapItem *)BLI_ghash_lookup(menu_to_kmi, item->mt);
if (kmi != NULL) {
char kmi_str[128];
WM_keymap_item_to_string(kmi, false, kmi_str, sizeof(kmi_str));
@@ -914,16 +918,16 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
static void menu_search_arg_free_fn(void *data_v)
{
- struct MenuSearch_Data *data = data_v;
- LISTBASE_FOREACH (struct MenuSearch_Item *, item, &data->items) {
+ MenuSearch_Data *data = (MenuSearch_Data *)data_v;
+ LISTBASE_FOREACH (MenuSearch_Item *, item, &data->items) {
switch (item->type) {
- case MENU_SEARCH_TYPE_OP: {
+ case MenuSearch_Item::MENU_SEARCH_TYPE_OP: {
if (item->op.opptr != NULL) {
WM_operator_properties_free(item->op.opptr);
MEM_freeN(item->op.opptr);
}
}
- case MENU_SEARCH_TYPE_RNA: {
+ case MenuSearch_Item::MENU_SEARCH_TYPE_RNA: {
break;
}
}
@@ -936,7 +940,8 @@ static void menu_search_arg_free_fn(void *data_v)
static void menu_search_exec_fn(bContext *C, void *UNUSED(arg1), void *arg2)
{
- struct MenuSearch_Item *item = arg2;
+ MenuSearch_Item *item = (MenuSearch_Item *)arg2;
+
if (item == NULL) {
return;
}
@@ -953,13 +958,13 @@ static void menu_search_exec_fn(bContext *C, void *UNUSED(arg1), void *arg2)
}
switch (item->type) {
- case MENU_SEARCH_TYPE_OP: {
+ case MenuSearch_Item::MENU_SEARCH_TYPE_OP: {
CTX_store_set(C, item->op.context);
WM_operator_name_call_ptr(C, item->op.type, item->op.opcontext, item->op.opptr);
CTX_store_set(C, NULL);
break;
}
- case MENU_SEARCH_TYPE_RNA: {
+ case MenuSearch_Item::MENU_SEARCH_TYPE_RNA: {
PointerRNA *ptr = &item->rna.ptr;
PropertyRNA *prop = item->rna.prop;
const int index = item->rna.index;
@@ -1002,19 +1007,19 @@ static void menu_search_update_fn(const bContext *UNUSED(C),
uiSearchItems *items,
const bool UNUSED(is_first))
{
- struct MenuSearch_Data *data = arg;
+ MenuSearch_Data *data = (MenuSearch_Data *)arg;
StringSearch *search = BLI_string_search_new();
- LISTBASE_FOREACH (struct MenuSearch_Item *, item, &data->items) {
+ LISTBASE_FOREACH (MenuSearch_Item *, item, &data->items) {
BLI_string_search_add(search, item->drawwstr_full, item);
}
- struct MenuSearch_Item **filtered_items;
+ MenuSearch_Item **filtered_items;
const int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_items);
for (int i = 0; i < filtered_amount; i++) {
- struct MenuSearch_Item *item = filtered_items[i];
+ MenuSearch_Item *item = filtered_items[i];
if (!UI_search_item_add(items, item->drawwstr_full, item, item->icon, item->state, 0)) {
break;
}
@@ -1039,8 +1044,8 @@ static bool ui_search_menu_create_context_menu(struct bContext *C,
void *active,
const struct wmEvent *UNUSED(event))
{
- struct MenuSearch_Data *data = arg;
- struct MenuSearch_Item *item = active;
+ MenuSearch_Data *data = (MenuSearch_Data *)arg;
+ MenuSearch_Item *item = (MenuSearch_Item *)active;
bool has_menu = false;
memset(&data->context_menu_data, 0x0, sizeof(data->context_menu_data));
@@ -1083,8 +1088,8 @@ static struct ARegion *ui_search_menu_create_tooltip(struct bContext *C,
void *arg,
void *active)
{
- struct MenuSearch_Data *data = arg;
- struct MenuSearch_Item *item = active;
+ MenuSearch_Data *data = (MenuSearch_Data *)arg;
+ MenuSearch_Item *item = (MenuSearch_Item *)active;
memset(&data->context_menu_data, 0x0, sizeof(data->context_menu_data));
uiBut *but = &data->context_menu_data.but;
@@ -1135,14 +1140,13 @@ static struct ARegion *ui_search_menu_create_tooltip(struct bContext *C,
void UI_but_func_menu_search(uiBut *but)
{
- bContext *C = but->block->evil_C;
+ bContext *C = (bContext *)but->block->evil_C;
wmWindow *win = CTX_wm_window(C);
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
/* When run from top-bar scan all areas in the current window. */
const bool include_all_areas = (area && (area->spacetype == SPACE_TOPBAR));
- struct MenuSearch_Data *data = menu_items_from_ui_create(
- C, win, area, region, include_all_areas);
+ MenuSearch_Data *data = menu_items_from_ui_create(C, win, area, region, include_all_areas);
UI_but_func_search_set(but,
/* Generic callback. */
ui_searchbox_create_menu,
diff --git a/source/blender/editors/interface/interface_template_search_operator.c b/source/blender/editors/interface/interface_template_search_operator.cc
index 2b765a1a2f5..b4320252219 100644
--- a/source/blender/editors/interface/interface_template_search_operator.c
+++ b/source/blender/editors/interface/interface_template_search_operator.cc
@@ -49,7 +49,7 @@
static void operator_search_exec_fn(bContext *C, void *UNUSED(arg1), void *arg2)
{
- wmOperatorType *ot = arg2;
+ wmOperatorType *ot = (wmOperatorType *)arg2;
if (ot) {
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL);
@@ -72,7 +72,7 @@ static void operator_search_update_fn(const bContext *C,
for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter);
BLI_ghashIterator_step(&iter)) {
- wmOperatorType *ot = BLI_ghashIterator_getValue(&iter);
+ wmOperatorType *ot = (wmOperatorType *)BLI_ghashIterator_getValue(&iter);
const char *ot_ui_name = CTX_IFACE_(ot->translation_context, ot->name);
if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) {
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.cc
index 6ca0f196280..6ca0f196280 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.cc
diff --git a/source/blender/editors/interface/interface_undo.c b/source/blender/editors/interface/interface_undo.cc
index 304d2254a81..22cdee0b755 100644
--- a/source/blender/editors/interface/interface_undo.c
+++ b/source/blender/editors/interface/interface_undo.cc
@@ -109,7 +109,8 @@ void ui_textedit_undo_push(uiUndoStack_Text *stack, const char *text, int cursor
/* Create the new state */
const int text_size = strlen(text) + 1;
- stack->current = MEM_mallocN(sizeof(uiUndoStack_Text_State) + text_size, __func__);
+ stack->current = (uiUndoStack_Text_State *)MEM_mallocN(
+ sizeof(uiUndoStack_Text_State) + text_size, __func__);
stack->current->cursor_index = cursor_index;
memcpy(stack->current->text, text, text_size);
BLI_addtail(&stack->states, stack->current);
@@ -119,9 +120,9 @@ void ui_textedit_undo_push(uiUndoStack_Text *stack, const char *text, int cursor
*
* \note The current state should be pushed immediately after calling this.
*/
-uiUndoStack_Text *ui_textedit_undo_stack_create(void)
+uiUndoStack_Text *ui_textedit_undo_stack_create()
{
- uiUndoStack_Text *stack = MEM_mallocN(sizeof(uiUndoStack_Text), __func__);
+ uiUndoStack_Text *stack = (uiUndoStack_Text *)MEM_mallocN(sizeof(uiUndoStack_Text), __func__);
stack->current = NULL;
BLI_listbase_clear(&stack->states);
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.cc
index 6ad1de68a1f..b350269af38 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.cc
@@ -377,7 +377,7 @@ eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout,
continue;
}
if (check_prop && check_prop(ptr, prop, user_data) == 0) {
- return_info |= UI_PROP_BUTS_ANY_FAILED_CHECK;
+ return_info = (eAutoPropButsReturn)(int(return_info) | int(UI_PROP_BUTS_ANY_FAILED_CHECK));
continue;
}
@@ -421,7 +421,7 @@ eAutoPropButsReturn uiDefAutoButsRNA(uiLayout *layout,
}
uiItemFullR(col, ptr, prop, -1, 0, compact ? UI_ITEM_R_COMPACT : 0, name, ICON_NONE);
- return_info &= ~UI_PROP_BUTS_NONE_ADDED;
+ return_info = (eAutoPropButsReturn)(int(return_info) | int(~UI_PROP_BUTS_NONE_ADDED));
if (use_activate_init) {
uiLayoutSetActivateInit(col, false);
@@ -456,10 +456,11 @@ static bool add_collection_search_item(CollItemSearch *cis,
* name prefix for showing the library status. */
int name_prefix_offset = cis->name_prefix_offset;
if (!has_id_icon && cis->is_id && !requires_exact_data_name) {
- cis->iconid = UI_icon_from_library(cis->data);
+ cis->iconid = UI_icon_from_library((ID *)cis->data);
/* No need to re-allocate, string should be shorter than before (lib status prefix is
* removed). */
- BKE_id_full_name_ui_prefix_get(name_buf, cis->data, false, UI_SEP_CHAR, &name_prefix_offset);
+ BKE_id_full_name_ui_prefix_get(
+ name_buf, (ID *)cis->data, false, UI_SEP_CHAR, &name_prefix_offset);
BLI_assert(strlen(name_buf) <= MEM_allocN_len(cis->name));
strcpy(cis->name, name_buf);
}
@@ -478,9 +479,9 @@ void ui_rna_collection_search_update_fn(const struct bContext *C,
uiSearchItems *items,
const bool is_first)
{
- uiRNACollectionSearch *data = arg;
+ uiRNACollectionSearch *data = (uiRNACollectionSearch *)arg;
const int flag = RNA_property_flag(data->target_prop);
- ListBase *items_list = MEM_callocN(sizeof(ListBase), "items_list");
+ ListBase *items_list = (ListBase *)MEM_callocN(sizeof(ListBase), "items_list");
const bool is_ptr_target = (RNA_property_type(data->target_prop) == PROP_POINTER);
/* For non-pointer properties, UI code acts entirely based on the item's name. So the name has to
* match the RNA name exactly. So only for pointer properties, the name can be modified to add
@@ -516,7 +517,7 @@ void ui_rna_collection_search_update_fn(const struct bContext *C,
const bool is_id = itemptr.type && RNA_struct_is_ID(itemptr.type);
if (is_id) {
- iconid = ui_id_icon_get(C, itemptr.data, false);
+ iconid = ui_id_icon_get(C, (ID *)itemptr.data, false);
if (!ELEM(iconid, 0, ICON_BLANK1)) {
has_id_icon = true;
}
@@ -525,9 +526,9 @@ void ui_rna_collection_search_update_fn(const struct bContext *C,
name = RNA_struct_name_get_alloc(&itemptr, name_buf, sizeof(name_buf), NULL);
}
else {
- const ID *id = itemptr.data;
+ const ID *id = (const ID *)itemptr.data;
BKE_id_full_name_ui_prefix_get(
- name_buf, itemptr.data, true, UI_SEP_CHAR, &name_prefix_offset);
+ name_buf, (const ID *)itemptr.data, true, UI_SEP_CHAR, &name_prefix_offset);
BLI_STATIC_ASSERT(sizeof(name_buf) >= MAX_ID_FULL_NAME_UI,
"Name string buffer should be big enough to hold full UI ID name");
name = name_buf;
@@ -539,7 +540,7 @@ void ui_rna_collection_search_update_fn(const struct bContext *C,
}
if (name) {
- CollItemSearch *cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch");
+ CollItemSearch *cis = (CollItemSearch *)MEM_callocN(sizeof(CollItemSearch), __func__);
cis->data = itemptr.data;
cis->name = BLI_strdup(name);
cis->index = item_index;
@@ -603,7 +604,7 @@ int UI_icon_from_id(const ID *id)
if (ob->type == OB_EMPTY) {
return ICON_EMPTY_DATA;
}
- return UI_icon_from_id(ob->data);
+ return UI_icon_from_id((const ID *)ob->data);
}
/* otherwise get it through RNA, creating the pointer
@@ -801,7 +802,7 @@ struct uiButStoreElem {
*/
uiButStore *UI_butstore_create(uiBlock *block)
{
- uiButStore *bs_handle = MEM_callocN(sizeof(uiButStore), __func__);
+ uiButStore *bs_handle = (uiButStore *)MEM_callocN(sizeof(uiButStore), __func__);
bs_handle->block = block;
BLI_addtail(&block->butstore, bs_handle);
@@ -851,7 +852,7 @@ bool UI_butstore_is_registered(uiBlock *block, uiBut *but)
void UI_butstore_register(uiButStore *bs_handle, uiBut **but_p)
{
- uiButStoreElem *bs_elem = MEM_callocN(sizeof(uiButStoreElem), __func__);
+ uiButStoreElem *bs_elem = (uiButStoreElem *)MEM_callocN(sizeof(uiButStoreElem), __func__);
BLI_assert(*but_p);
bs_elem->but_p = but_p;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.cc
index afac254f542..f610a765797 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.cc
@@ -1041,9 +1041,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
void UI_theme_init_default(void)
{
/* we search for the theme with name Default */
- bTheme *btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name));
+ bTheme *btheme = (bTheme *)BLI_findstring(&U.themes, "Default", offsetof(bTheme, name));
if (btheme == NULL) {
- btheme = MEM_callocN(sizeof(bTheme), __func__);
+ btheme = (bTheme *)MEM_callocN(sizeof(bTheme), __func__);
BLI_addtail(&U.themes, btheme);
}
@@ -1065,27 +1065,27 @@ void UI_SetTheme(int spacetype, int regionid)
{
if (spacetype) {
/* later on, a local theme can be found too */
- theme_active = U.themes.first;
+ theme_active = (bTheme *)U.themes.first;
theme_spacetype = spacetype;
theme_regionid = regionid;
}
else if (regionid) {
/* popups */
- theme_active = U.themes.first;
+ theme_active = (bTheme *)U.themes.first;
theme_spacetype = SPACE_PROPERTIES;
theme_regionid = regionid;
}
else {
/* for safety, when theme was deleted */
- theme_active = U.themes.first;
+ theme_active = (bTheme *)U.themes.first;
theme_spacetype = SPACE_VIEW3D;
theme_regionid = RGN_TYPE_WINDOW;
}
}
-bTheme *UI_GetTheme(void)
+bTheme *UI_GetTheme()
{
- return U.themes.first;
+ return (bTheme *)U.themes.first;
}
/**