Cleanup: Move six more interface files to C++

This commit is contained in:
Hans Goudey
2022-11-25 23:48:02 -06:00
parent 1aff91b1a7
commit 162f0dcb2f
8 changed files with 1312 additions and 1202 deletions

View File

@@ -35,7 +35,7 @@ set(SRC
eyedroppers/eyedropper_gpencil_color.c
eyedroppers/interface_eyedropper.c
interface.cc
interface_align.c
interface_align.cc
interface_anim.cc
interface_button_group.cc
interface_context_menu.cc
@@ -44,9 +44,9 @@ set(SRC
interface_draw.cc
interface_dropboxes.cc
interface_handlers.c
interface_icons.c
interface_icons.cc
interface_icons_event.cc
interface_layout.c
interface_layout.cc
interface_ops.cc
interface_panel.cc
interface_query.cc
@@ -65,11 +65,11 @@ set(SRC
interface_template_list.cc
interface_template_search_menu.cc
interface_template_search_operator.cc
interface_templates.c
interface_templates.cc
interface_undo.cc
interface_utils.cc
interface_widgets.c
resources.c
interface_widgets.cc
resources.cc
view2d.cc
view2d_draw.cc
view2d_edge_pan.cc

View File

@@ -41,7 +41,7 @@
* This will probably not work in all possible cases,
* but not sure we want to support such exotic cases anyway.
*/
typedef struct ButAlign {
struct ButAlign {
uiBut *but;
/* Neighbor buttons */
@@ -56,7 +56,7 @@ typedef struct ButAlign {
/* Flags, used to mark whether we should 'stitch'
* the corners of this button with its neighbors' ones. */
char flags[4];
} ButAlign;
};
/* Side-related enums and flags. */
enum {
@@ -168,7 +168,7 @@ static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other
/* We found an as close or closer neighbor.
* If both buttons are alignable, we set them as each other neighbors.
* Else, we have an unalignable one, we need to reset the others matching
* neighbor to NULL if its 'proximity distance'
* neighbor to nullptr if its 'proximity distance'
* is really lower with current one.
*
* NOTE: We cannot only execute that piece of code in case we found a
@@ -181,10 +181,10 @@ static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other
butal_other->neighbors[side_opp] = butal;
}
else if (butal_can_align && (delta < butal->dists[side])) {
butal->neighbors[side] = NULL;
butal->neighbors[side] = nullptr;
}
else if (butal_other_can_align && (delta < butal_other->dists[side_opp])) {
butal_other->neighbors[side_opp] = NULL;
butal_other->neighbors[side_opp] = nullptr;
}
butal->dists[side] = butal_other->dists[side_opp] = delta;
}
@@ -196,10 +196,10 @@ static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other
const int stitch = STITCH(side);
const int stitch_opp = STITCH(side_opp);
if (butal->neighbors[side] == NULL) {
if (butal->neighbors[side] == nullptr) {
butal->neighbors[side] = butal_other;
}
if (butal_other->neighbors[side_opp] == NULL) {
if (butal_other->neighbors[side_opp] == nullptr) {
butal_other->neighbors[side_opp] = butal;
}
@@ -304,8 +304,8 @@ static void block_align_stitch_neighbors(ButAlign *butal,
*/
static int ui_block_align_butal_cmp(const void *a, const void *b)
{
const ButAlign *butal = a;
const ButAlign *butal_other = b;
const ButAlign *butal = static_cast<const ButAlign *>(a);
const ButAlign *butal_other = static_cast<const ButAlign *>(b);
/* Sort by align group. */
if (butal->but->alignnr != butal_other->but->alignnr) {
@@ -402,7 +402,8 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region)
butal_array = butal_array_buf;
}
else {
butal_array = MEM_mallocN(sizeof(*butal_array) * num_buttons, __func__);
butal_array = static_cast<ButAlign *>(
MEM_mallocN(sizeof(*butal_array) * num_buttons, __func__));
}
memset(butal_array, 0, sizeof(*butal_array) * (size_t)num_buttons);
@@ -549,7 +550,7 @@ static bool buts_are_horiz(uiBut *but1, uiBut *but2)
static void ui_block_align_calc_but(uiBut *first, short nr)
{
uiBut *prev, *but = NULL, *next;
uiBut *prev, *but = nullptr, *next;
int flag = 0, cols = 0, rows = 0;
/* auto align */
@@ -569,10 +570,10 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
/* NOTE: manipulation of 'flag' in the loop below is confusing.
* In some cases it's assigned, other times OR is used. */
for (but = first, prev = NULL; but && but->alignnr == nr; prev = but, but = but->next) {
for (but = first, prev = nullptr; but && but->alignnr == nr; prev = but, but = but->next) {
next = but->next;
if (next && next->alignnr != nr) {
next = NULL;
next = nullptr;
}
/* clear old flag */
@@ -593,7 +594,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
}
}
}
else if (next == NULL) { /* last case */
else if (next == nullptr) { /* last case */
if (prev) {
if (buts_are_horiz(prev, but)) {
if (rows == 0) {
@@ -622,7 +623,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
}
bt = bt->next;
}
if (bt == NULL || bt->alignnr != nr) {
if (bt == nullptr || bt->alignnr != nr) {
flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT;
}
}
@@ -704,7 +705,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
}
}
void ui_block_align_calc(uiBlock *block, const struct ARegion *UNUSED(region))
void ui_block_align_calc(uiBlock *block, const struct ARegion *(region))
{
short nr;

View File

@@ -5,9 +5,9 @@
* \ingroup edinterface
*/
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
@@ -74,15 +74,15 @@
# define ICON_GRID_H 32
#endif /* WITH_HEADLESS */
typedef struct IconImage {
struct IconImage {
int w;
int h;
uint *rect;
const uchar *datatoc_rect;
int datatoc_size;
} IconImage;
};
typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
using VectorDrawFunc = void (*)(int x, int y, int w, int h, float alpha);
#define ICON_TYPE_PREVIEW 0
#define ICON_TYPE_COLOR_TEXTURE 1
@@ -95,7 +95,7 @@ typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
#define ICON_TYPE_GPLAYER 8
#define ICON_TYPE_BLANK 9
typedef struct DrawInfo {
struct DrawInfo {
int type;
union {
@@ -123,26 +123,26 @@ typedef struct DrawInfo {
struct DrawInfo *next;
} input;
} data;
} DrawInfo;
};
typedef struct IconTexture {
struct GPUTexture *tex[2];
struct IconTexture {
GPUTexture *tex[2];
int num_textures;
int w;
int h;
float invw;
float invh;
} IconTexture;
};
typedef struct IconType {
struct IconType {
int type;
int theme_color;
} IconType;
};
/* ******************* STATIC LOCAL VARS ******************* */
/* Static here to cache results of icon directory scan, so it's not
* scanning the file-system each time the menu is drawn. */
static struct ListBase iconfilelist = {NULL, NULL};
static ListBase iconfilelist = {NULL, NULL};
static IconTexture icongltex = {{NULL, NULL}, 0, 0, 0, 0.0f, 0.0f};
#ifndef WITH_HEADLESS
@@ -168,12 +168,12 @@ static const IconType icontypes[] = {
static DrawInfo *def_internal_icon(
ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color)
{
Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon");
Icon *new_icon = MEM_cnew<Icon>(__func__);
new_icon->obj = NULL; /* icon is not for library object */
new_icon->id_type = 0;
DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
DrawInfo *di = MEM_cnew<DrawInfo>(__func__);
di->type = type;
if (ELEM(type, ICON_TYPE_COLOR_TEXTURE, ICON_TYPE_MONO_TEXTURE)) {
@@ -184,7 +184,7 @@ static DrawInfo *def_internal_icon(
di->data.texture.h = size;
}
else if (type == ICON_TYPE_BUFFER) {
IconImage *iimg = MEM_callocN(sizeof(IconImage), "icon_img");
IconImage *iimg = MEM_cnew<IconImage>(__func__);
iimg->w = size;
iimg->h = size;
@@ -192,7 +192,7 @@ static DrawInfo *def_internal_icon(
if (bbuf) {
int y, imgsize;
iimg->rect = MEM_mallocN(size * size * sizeof(uint), "icon_rect");
iimg->rect = static_cast<uint *>(MEM_mallocN(size * size * sizeof(uint), __func__));
/* Here we store the rect in the icon - same as before */
if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) {
@@ -220,12 +220,12 @@ static DrawInfo *def_internal_icon(
static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
{
Icon *new_icon = MEM_callocN(sizeof(Icon), "texicon");
Icon *new_icon = MEM_cnew<Icon>("texicon");
new_icon->obj = NULL; /* icon is not for library object */
new_icon->id_type = 0;
DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
DrawInfo *di = MEM_cnew<DrawInfo>("drawinfo");
di->type = ICON_TYPE_VECTOR;
di->data.vector.func = drawFunc;
@@ -244,7 +244,7 @@ static void vicon_keytype_draw_wrapper(
{
/* Initialize dummy theme state for Action Editor - where these colors are defined
* (since we're doing this off-screen, free from any particular space_id). */
struct bThemeState theme_state;
bThemeState theme_state;
UI_Theme_Store(&theme_state);
UI_SetTheme(SPACE_ACTION, RGN_TYPE_WINDOW);
@@ -822,7 +822,7 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf,
const int offset_write = (sy + by) * buf->x + (sx + bx);
const float blurred_alpha = blurred_alpha_buffer[blurred_alpha_offset];
const float border_srgb[4] = {
0, 0, 0, MIN2(1.0, blurred_alpha * border_sharpness) * border_intensity};
0, 0, 0, MIN2(1.0f, blurred_alpha * border_sharpness) * border_intensity};
const uint color_read = buf->rect[offset_write];
const uchar *orig_color = (uchar *)&color_read;
@@ -1036,7 +1036,7 @@ static void init_internal_icons(void)
vicon_strip_color_draw_library_data_override_noneditable);
}
static void init_iconfile_list(struct ListBase *list)
static void init_iconfile_list(ListBase *list)
{
BLI_listbase_clear(list);
const char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
@@ -1045,7 +1045,7 @@ static void init_iconfile_list(struct ListBase *list)
return;
}
struct direntry *dir;
direntry *dir;
const int totfile = BLI_filelist_dir_contents(icondir, &dir);
int index = 1;
@@ -1083,7 +1083,7 @@ static void init_iconfile_list(struct ListBase *list)
# endif /* removed */
/* found a potential icon file, so make an entry for it in the cache list */
IconFile *ifile = MEM_callocN(sizeof(IconFile), "IconFile");
IconFile *ifile = MEM_cnew<IconFile>(__func__);
BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename));
ifile->index = index;
@@ -1099,12 +1099,9 @@ static void init_iconfile_list(struct ListBase *list)
dir = NULL;
}
static void free_iconfile_list(struct ListBase *list)
static void free_iconfile_list(ListBase *list)
{
IconFile *ifile = NULL, *next_ifile = NULL;
for (ifile = list->first; ifile; ifile = next_ifile) {
next_ifile = ifile->next;
LISTBASE_FOREACH_MUTABLE (IconFile *, ifile, &iconfilelist) {
BLI_freelinkN(list, ifile);
}
}
@@ -1119,10 +1116,7 @@ void UI_icons_reload_internal_textures(void)
int UI_iconfile_get_index(const char *filename)
{
IconFile *ifile;
ListBase *list = &(iconfilelist);
for (ifile = list->first; ifile; ifile = ifile->next) {
LISTBASE_FOREACH (const IconFile *, ifile, &iconfilelist) {
if (BLI_path_cmp(filename, ifile->filename) == 0) {
return ifile->index;
}
@@ -1149,7 +1143,7 @@ void UI_icons_free(void)
void UI_icons_free_drawinfo(void *drawinfo)
{
DrawInfo *di = drawinfo;
DrawInfo *di = static_cast<DrawInfo *>(drawinfo);
if (di == NULL) {
return;
@@ -1179,7 +1173,7 @@ static DrawInfo *icon_create_drawinfo(Icon *icon)
{
const int icon_data_type = icon->obj_type;
DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "di_icon");
DrawInfo *di = MEM_cnew<DrawInfo>("di_icon");
if (ELEM(icon_data_type, ICON_DATA_ID, ICON_DATA_PREVIEW)) {
di->type = ICON_TYPE_PREVIEW;
@@ -1206,7 +1200,7 @@ static DrawInfo *icon_create_drawinfo(Icon *icon)
static DrawInfo *icon_ensure_drawinfo(Icon *icon)
{
if (icon->drawinfo) {
return icon->drawinfo;
return static_cast<DrawInfo *>(icon->drawinfo);
}
DrawInfo *di = icon_create_drawinfo(icon);
icon->drawinfo = di;
@@ -1287,7 +1281,7 @@ int UI_icon_preview_to_render_size(enum eIconSizes size)
/* Create rect for the icon
*/
static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
static void icon_create_rect(PreviewImage *prv_img, enum eIconSizes size)
{
const uint render_size = UI_icon_preview_to_render_size(size);
@@ -1301,7 +1295,8 @@ static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
prv_img->h[size] = render_size;
prv_img->flag[size] |= PRV_CHANGED;
prv_img->changed_timestamp[size] = 0;
prv_img->rect[size] = MEM_callocN(render_size * render_size * sizeof(uint), "prv_rect");
prv_img->rect[size] = static_cast<uint *>(
MEM_callocN(render_size * render_size * sizeof(uint), "prv_rect"));
}
}
@@ -1316,7 +1311,7 @@ static void ui_studiolight_icon_job_exec(void *customdata,
Icon **tmp = (Icon **)customdata;
Icon *icon = *tmp;
DrawInfo *di = icon_ensure_drawinfo(icon);
StudioLight *sl = icon->obj;
StudioLight *sl = static_cast<StudioLight *>(icon->obj);
BKE_studiolight_preview(di->data.buffer.image->rect, sl, icon->id_type);
}
@@ -1329,7 +1324,7 @@ static void ui_studiolight_kill_icon_preview_job(wmWindowManager *wm, int icon_i
static void ui_studiolight_free_function(StudioLight *sl, void *data)
{
wmWindowManager *wm = data;
wmWindowManager *wm = static_cast<wmWindowManager *>(data);
/* Happens if job was canceled or already finished. */
if (wm == NULL) {
@@ -1355,7 +1350,7 @@ static void ui_studiolight_icon_job_end(void *customdata)
{
Icon **tmp = (Icon **)customdata;
Icon *icon = *tmp;
StudioLight *sl = icon->obj;
StudioLight *sl = static_cast<StudioLight *>(icon->obj);
BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, NULL);
}
@@ -1375,8 +1370,9 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi
switch (di->type) {
case ICON_TYPE_PREVIEW: {
ID *id = (icon->id_type != 0) ? icon->obj : NULL;
PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj;
ID *id = (icon->id_type != 0) ? static_cast<ID *>(icon->obj) : NULL;
PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) :
static_cast<PreviewImage *>(icon->obj);
/* Using jobs for screen previews crashes due to off-screen rendering.
* XXX: would be nicer if #PreviewImage could store if it supports jobs. */
const bool use_jobs = !id || (GS(id->name) != ID_SCR);
@@ -1394,20 +1390,24 @@ void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool bi
if (icon->obj_type == ICON_DATA_STUDIOLIGHT) {
if (di->data.buffer.image == NULL) {
wmWindowManager *wm = CTX_wm_manager(C);
StudioLight *sl = icon->obj;
StudioLight *sl = static_cast<StudioLight *>(icon->obj);
BKE_studiolight_set_free_function(sl, &ui_studiolight_free_function, wm);
IconImage *img = MEM_mallocN(sizeof(IconImage), __func__);
IconImage *img = MEM_cnew<IconImage>(__func__);
img->w = STUDIOLIGHT_ICON_SIZE;
img->h = STUDIOLIGHT_ICON_SIZE;
const size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint);
img->rect = MEM_mallocN(size, __func__);
img->rect = static_cast<uint *>(MEM_mallocN(size, __func__));
memset(img->rect, 0, size);
di->data.buffer.image = img;
wmJob *wm_job = WM_jobs_get(
wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT);
Icon **tmp = MEM_callocN(sizeof(Icon *), __func__);
wmJob *wm_job = WM_jobs_get(wm,
CTX_wm_window(C),
icon,
"StudioLight Icon",
eWM_JobFlag(0),
WM_JOB_TYPE_STUDIOLIGHT);
Icon **tmp = MEM_cnew<Icon *>(__func__);
*tmp = icon;
WM_jobs_customdata_set(wm_job, tmp, MEM_freeN);
WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW);
@@ -1478,7 +1478,7 @@ PreviewImage *UI_icon_to_preview(int icon_id)
if (di->type == ICON_TYPE_PREVIEW) {
PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
icon->obj;
static_cast<PreviewImage *>(icon->obj);
if (prv) {
return BKE_previewimg_copy(prv);
@@ -1581,16 +1581,16 @@ static void icon_draw_rect(float x,
* efficient than simple glUniform calls. */
#define ICON_DRAW_CACHE_SIZE 16
typedef struct IconDrawCall {
struct IconDrawCall {
rctf pos;
rctf tex;
float color[4];
} IconDrawCall;
};
typedef struct IconTextureDrawCall {
struct IconTextureDrawCall {
IconDrawCall drawcall_cache[ICON_DRAW_CACHE_SIZE];
int calls; /* Number of calls batched together */
} IconTextureDrawCall;
};
static struct {
IconTextureDrawCall normal;
@@ -1616,7 +1616,7 @@ static void icon_draw_cache_texture_flush_ex(GPUTexture *texture,
const int data_binding = GPU_shader_get_uniform_block_binding(shader, "multi_rect_data");
GPUUniformBuf *ubo = GPU_uniformbuf_create_ex(
sizeof(struct MultiRectCallData), texture_draw_calls->drawcall_cache, __func__);
sizeof(MultiRectCallData), texture_draw_calls->drawcall_cache, __func__);
GPU_uniformbuf_bind(ubo, data_binding);
const int img_binding = GPU_shader_get_texture_binding(shader, "image");
@@ -1752,21 +1752,20 @@ static void icon_draw_texture(float x,
fstyle_small.points *= zoom_factor;
fstyle_small.points *= 0.8f;
rcti text_rect = {
.xmax = x + UI_UNIT_X * zoom_factor,
.xmin = x,
.ymax = y,
.ymin = y,
};
rcti text_rect{};
text_rect.xmax = x + UI_UNIT_X * zoom_factor;
text_rect.xmin = x;
text_rect.ymax = y;
text_rect.ymin = y;
uiFontStyleDraw_Params params{};
params.align = UI_STYLE_TEXT_RIGHT;
UI_fontstyle_draw(&fstyle_small,
&text_rect,
text_overlay->text,
sizeof(text_overlay->text),
text_color,
&(struct uiFontStyleDraw_Params){
.align = UI_STYLE_TEXT_RIGHT,
});
&params);
text_width = (float)UI_fontstyle_string_width(&fstyle_small, text_overlay->text) / UI_UNIT_X /
zoom_factor;
}
@@ -1798,14 +1797,19 @@ static void icon_draw_texture(float x,
const int rect_geom_loc = GPU_shader_get_uniform(shader, "rect_geom");
if (rgb) {
GPU_shader_uniform_vector(shader, color_loc, 4, 1, (float[4]){UNPACK3(rgb), alpha});
const float color[4] = {rgb[0], rgb[1], rgb[2], alpha};
GPU_shader_uniform_vector(shader, color_loc, 4, 1, color);
}
else {
GPU_shader_uniform_vector(shader, color_loc, 4, 1, (float[4]){alpha, alpha, alpha, alpha});
const float color[4] = {alpha, alpha, alpha, alpha};
GPU_shader_uniform_vector(shader, color_loc, 4, 1, color);
}
GPU_shader_uniform_vector(shader, rect_tex_loc, 4, 1, (float[4]){x1, y1, x2, y2});
GPU_shader_uniform_vector(shader, rect_geom_loc, 4, 1, (float[4]){x, y, x + w, y + h});
const float tex_color[4] = {x1, y1, x2, y2};
const float geom_color[4] = {x, y, x + w, y + h};
GPU_shader_uniform_vector(shader, rect_tex_loc, 4, 1, tex_color);
GPU_shader_uniform_vector(shader, rect_geom_loc, 4, 1, geom_color);
GPU_shader_uniform_1f(shader, "text_width", text_width);
GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false);
@@ -1867,7 +1871,7 @@ static void icon_draw_size(float x,
UI_widgetbase_draw_cache_flush();
if (di->type == ICON_TYPE_IMBUF) {
ImBuf *ibuf = icon->obj;
ImBuf *ibuf = static_cast<ImBuf *>(icon->obj);
GPU_blend(GPU_BLEND_ALPHA_PREMULT);
icon_draw_rect(x, y, w, h, aspect, ibuf->x, ibuf->y, ibuf->rect, alpha, desaturate);
@@ -1902,9 +1906,9 @@ static void icon_draw_size(float x,
IMB_freeImBuf(ibuf);
}
if (invert != geom_inverted) {
BKE_icon_geom_invert_lightness(icon->obj);
BKE_icon_geom_invert_lightness(static_cast<Icon_Geom *>(icon->obj));
}
ibuf = BKE_icon_geom_rasterize(icon->obj, w, h);
ibuf = BKE_icon_geom_rasterize(static_cast<Icon_Geom *>(icon->obj), w, h);
di->data.geom.image_cache = ibuf;
di->data.geom.inverted = invert;
}
@@ -1984,7 +1988,7 @@ static void icon_draw_size(float x,
}
else if (di->type == ICON_TYPE_PREVIEW) {
PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
icon->obj;
static_cast<PreviewImage *>(icon->obj);
if (pi) {
/* no create icon on this level in code */
@@ -2016,7 +2020,7 @@ static void ui_id_preview_image_render_size(
/* changed only ever set by dynamic icons */
if ((pi->flag[size] & PRV_CHANGED) || !pi->rect[size]) {
/* create the rect if necessary */
icon_set_image(C, scene, id, pi, size, use_job);
icon_set_image(C, scene, id, pi, eIconSizes(size), use_job);
pi->flag[size] &= ~PRV_CHANGED;
}
@@ -2045,8 +2049,8 @@ void UI_icon_render_id(
/* For objects, first try if a preview can created via the object data. */
if (GS(id->name) == ID_OB) {
Object *ob = (Object *)id;
if (ED_preview_id_is_supported(ob->data)) {
id_to_render = ob->data;
if (ED_preview_id_is_supported(static_cast<const ID *>(ob->data))) {
id_to_render = static_cast<ID *>(ob->data);
}
}
@@ -2065,7 +2069,7 @@ static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
return;
}
for (enum eIconSizes i = 0; i < NUM_ICON_SIZES; i++) {
for (int i = 0; i < NUM_ICON_SIZES; i++) {
ui_id_preview_image_render_size(C, NULL, id, pi, i, use_jobs);
}
}
@@ -2112,7 +2116,7 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id)
}
else if (space_type == SPACE_IMAGE) {
if (area->spacetype == space_type) {
const SpaceImage *sima = area->spacedata.first;
const SpaceImage *sima = static_cast<const SpaceImage *>(area->spacedata.first);
if (sima->mode == SI_MODE_PAINT) {
paint_mode = PAINT_MODE_TEXTURE_2D;
}
@@ -2310,16 +2314,16 @@ int UI_icon_from_rnaptr(const bContext *C, PointerRNA *ptr, int rnaicon, const b
id = ptr->owner_id;
}
else if (RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) {
id = RNA_pointer_get(ptr, "material").data;
id = static_cast<ID *>(RNA_pointer_get(ptr, "material").data);
}
else if (RNA_struct_is_a(ptr->type, &RNA_TextureSlot)) {
id = RNA_pointer_get(ptr, "texture").data;
id = static_cast<ID *>(RNA_pointer_get(ptr, "texture").data);
}
else if (RNA_struct_is_a(ptr->type, &RNA_FileBrowserFSMenuEntry)) {
return RNA_int_get(ptr, "icon");
}
else if (RNA_struct_is_a(ptr->type, &RNA_DynamicPaintSurface)) {
DynamicPaintSurface *surface = ptr->data;
DynamicPaintSurface *surface = static_cast<DynamicPaintSurface *>(ptr->data);
if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) {
return ICON_SHADING_TEXTURE;
@@ -2332,7 +2336,7 @@ int UI_icon_from_rnaptr(const bContext *C, PointerRNA *ptr, int rnaicon, const b
}
}
else if (RNA_struct_is_a(ptr->type, &RNA_StudioLight)) {
StudioLight *sl = ptr->data;
StudioLight *sl = static_cast<StudioLight *>(ptr->data);
switch (sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS) {
case STUDIOLIGHT_TYPE_STUDIO:
return sl->icon_id_irradiance;
@@ -2550,7 +2554,7 @@ ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon)
return NULL;
#else
const int ALERT_IMG_SIZE = 256;
icon = MIN2(icon, ALERT_ICON_MAX - 1);
icon = eAlertIcon(MIN2(icon, ALERT_ICON_MAX - 1));
const int left = icon * ALERT_IMG_SIZE;
const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1};
ImBuf *ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_alert_icons_png,

View File

@@ -1158,7 +1158,7 @@ void ui_but_ime_reposition(uiBut *but, int x, int y, bool complete);
struct wmIMEData *ui_but_ime_data_get(uiBut *but);
#endif
/* interface_widgets.c */
/* interface_widgets.cc */
/* Widget shader parameters, must match the shader layout. */
typedef struct uiWidgetBaseParameters {
@@ -1282,7 +1282,7 @@ extern const float ui_pixel_jitter[UI_PIXEL_AA_JITTER][2];
*/
void uiStyleInit(void);
/* interface_icons.c */
/* interface_icons.cc */
void ui_icon_ensure_deferred(const struct bContext *C, int icon_id, bool big);
int ui_id_icon_get(const struct bContext *C, struct ID *id, bool big);
@@ -1292,12 +1292,12 @@ int ui_id_icon_get(const struct bContext *C, struct ID *id, bool big);
void icon_draw_rect_input(
float x, float y, int w, int h, float alpha, short event_type, short event_value);
/* resources.c */
/* resources.cc */
void ui_resources_init(void);
void ui_resources_free(void);
/* interface_layout.c */
/* interface_layout.cc */
void ui_layout_add_but(uiLayout *layout, uiBut *but);
void ui_layout_remove_but(uiLayout *layout, const uiBut *but);
@@ -1342,7 +1342,7 @@ void ui_but_drag_free(uiBut *but);
bool ui_but_drag_is_draggable(const uiBut *but);
void ui_but_drag_start(struct bContext *C, uiBut *but);
/* interface_align.c */
/* interface_align.cc */
bool ui_but_can_align(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
int ui_but_align_opposite_to_area_align_get(const struct ARegion *region) ATTR_WARN_UNUSED_RESULT;
@@ -1556,7 +1556,7 @@ uiViewHandle *ui_block_view_find_matching_in_old_block(const uiBlock *new_block,
uiButViewItem *ui_block_view_find_matching_view_item_but_in_old_block(
const uiBlock *new_block, const uiViewItemHandle *new_item_handle);
/* interface_templates.c */
/* interface_templates.cc */
struct uiListType *UI_UL_cache_file_layers(void);

View File

@@ -4,10 +4,10 @@
* \ingroup edinterface
*/
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
@@ -15,7 +15,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"
@@ -54,7 +54,7 @@
* \{ */
#define UI_OPERATOR_ERROR_RET(_ot, _opname, return_statement) \
if (ot == NULL) { \
if (ot == nullptr) { \
ui_item_disabled(layout, _opname); \
RNA_warning("'%s' unknown operator", _opname); \
return_statement; \
@@ -65,8 +65,8 @@
/* uiLayoutRoot */
typedef struct uiLayoutRoot {
struct uiLayoutRoot *next, *prev;
struct uiLayoutRoot {
uiLayoutRoot *next, *prev;
int type;
wmOperatorCallContext opcontext;
@@ -80,11 +80,11 @@ typedef struct uiLayoutRoot {
const uiStyle *style;
uiBlock *block;
uiLayout *layout;
} uiLayoutRoot;
};
/* Item */
typedef enum uiItemType {
enum uiItemType {
ITEM_BUTTON,
ITEM_LAYOUT_ROW,
@@ -107,13 +107,13 @@ typedef enum uiItemType {
TEMPLATE_HEADER,
TEMPLATE_HEADER_ID,
#endif
} uiItemType;
};
typedef struct uiItem {
void *next, *prev;
struct uiItem {
uiItem *next, *prev;
uiItemType type;
int flag;
} uiItem;
};
enum {
UI_ITEM_AUTO_FIXED_SIZE = 1 << 0,
@@ -128,10 +128,10 @@ enum {
UI_ITEM_PROP_DECORATE_NO_PAD = 1 << 6,
};
typedef struct uiButtonItem {
struct uiButtonItem {
uiItem item;
uiBut *but;
} uiButtonItem;
};
struct uiLayout {
uiItem item;
@@ -164,13 +164,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 */
@@ -187,21 +187,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;
};
/** \} */
@@ -294,25 +294,13 @@ struct uiTextIconPadFactor {
* but taking margins into account its fine,
* except for #ui_text_pad_compact where a bit more margin is required.
*/
static const struct uiTextIconPadFactor ui_text_pad_default = {
.text = 1.50f,
.icon = 0.25f,
.icon_only = 0.0f,
};
static const uiTextIconPadFactor ui_text_pad_default = {1.50f, 0.25f, 0.0f};
/** #ui_text_pad_default scaled down. */
static const struct uiTextIconPadFactor ui_text_pad_compact = {
.text = 1.25f,
.icon = 0.35f,
.icon_only = 0.0f,
};
static const uiTextIconPadFactor ui_text_pad_compact = {1.25f, 0.35f, 0.0f};
/** Least amount of padding not to clip the text or icon. */
static const struct uiTextIconPadFactor ui_text_pad_none = {
.text = 0.25f,
.icon = 1.50f,
.icon_only = 0.0f,
};
static const uiTextIconPadFactor ui_text_pad_none = {0.25f, 1.50f, 0.0f};
/**
* Estimated size of text + icon.
@@ -320,7 +308,7 @@ static const struct uiTextIconPadFactor ui_text_pad_none = {
static int ui_text_icon_width_ex(uiLayout *layout,
const char *name,
int icon,
const struct uiTextIconPadFactor *pad_factor)
const uiTextIconPadFactor *pad_factor)
{
const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f);
@@ -489,7 +477,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 = static_cast<uiBut *>(arg_but);
PointerRNA *ptr = &but->rnapoin;
PropertyRNA *prop = but->rnaprop;
const int index = POINTER_AS_INT(arg_index);
@@ -524,7 +512,7 @@ static void ui_item_array(uiLayout *layout,
int x,
int y,
int w,
int UNUSED(h),
int /*h*/,
bool expand,
bool slider,
int toggle,
@@ -543,7 +531,7 @@ static void ui_item_array(uiLayout *layout,
/* create label */
if (name[0] && show_text) {
uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, nullptr, 0.0, 0.0, 0, 0, "");
}
/* create buttons */
@@ -560,7 +548,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 = static_cast<bArmature *>(ptr->data);
layer_used = arm->layer_used;
@@ -681,7 +669,7 @@ static void ui_item_array(uiLayout *layout,
0,
-1,
-1,
NULL);
nullptr);
}
else {
/* NOTE: this block of code is a bit arbitrary and has just been made
@@ -704,10 +692,10 @@ static void ui_item_array(uiLayout *layout,
}
/* Show check-boxes for rna on a non-emboss block (menu for eg). */
bool *boolarr = NULL;
bool *boolarr = nullptr;
if (type == PROP_BOOLEAN &&
ELEM(layout->root->block->emboss, UI_EMBOSS_NONE, UI_EMBOSS_PULLDOWN)) {
boolarr = MEM_callocN(sizeof(bool) * len, __func__);
boolarr = static_cast<bool *>(MEM_callocN(sizeof(bool) * len, __func__));
RNA_property_boolean_get_array(ptr, prop, boolarr);
}
@@ -790,22 +778,22 @@ static void ui_item_enum_expand_elem_exec(uiLayout *layout,
uiBut *but;
if (icon && name[0] && !icon_only) {
but = uiDefIconTextButR_prop(
block, but_type, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
block, but_type, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, nullptr);
}
else if (icon) {
const int w = (is_first) ? itemw : ceilf(itemw - U.pixelsize);
but = uiDefIconButR_prop(
block, but_type, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
block, but_type, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, nullptr);
}
else {
but = uiDefButR_prop(
block, but_type, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
block, but_type, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, nullptr);
}
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
/* If this is set, assert since we're clobbering someone elses callback. */
/* Buttons get their block's func by default, so we cannot assert in that case either. */
BLI_assert(ELEM(but->func, NULL, block->func));
BLI_assert(ELEM(but->func, nullptr, block->func));
UI_but_func_set(but, ui_item_enum_expand_handle, but, POINTER_FROM_INT(value));
}
@@ -833,7 +821,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
* is insane and inconsistent with general UI API:
*
* - uiname is the *enum property* label.
* - when it is NULL or empty, we do not draw *enum items* labels,
* - when it is nullptr or empty, we do not draw *enum items* labels,
* this doubles the icon_only parameter.
* - we *never* draw (i.e. really use) the enum label uiname, it is just used as a mere flag!
*
@@ -848,14 +836,16 @@ 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(
static_cast<bContext *>(block->evil_C), ptr, prop, &item_array, nullptr, &free);
}
else {
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item_array, NULL, &free);
RNA_property_enum_items_gettexted(
static_cast<bContext *>(block->evil_C), ptr, prop, &item_array, nullptr, &free);
}
/* We don't want nested rows, cols in menus. */
uiLayout *layout_radial = NULL;
uiLayout *layout_radial = nullptr;
if (radial) {
if (layout->root->layout == layout) {
layout_radial = uiLayoutRadial(layout);
@@ -933,24 +923,25 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
const int h,
const bool icon_only)
{
uiBut *last = block->buttons.last;
uiBut *last = static_cast<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 : static_cast<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)));
}
const bool use_custom_highlight = (prop_highlight != NULL);
const bool use_custom_highlight = (prop_highlight != nullptr);
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);
blender::Array<bool, 64> 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;
(tab_but != NULL) && (i < highlight_array_len);
for (uiBut *tab_but = last ? last->next : static_cast<uiBut *>(block->buttons.first);
(tab_but != nullptr) && (i < highlight_array_len);
tab_but = tab_but->next, i++) {
SET_FLAG_FROM_TEST(tab_but->flag, !highlight_array[i], UI_BUT_INACTIVE);
}
@@ -958,9 +949,9 @@ 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))
static void ui_keymap_but_cb(bContext * /*C*/, void *but_v, void * /*key_v*/)
{
uiBut *but = but_v;
uiBut *but = static_cast<uiBut *>(but_v);
BLI_assert(but->type == UI_BTYPE_HOTKEY_EVENT);
const uiButHotkeyEvent *hotkey_but = (uiButHotkeyEvent *)but;
@@ -996,7 +987,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
uiLayout *sub = layout;
int prop_but_width = w_hint;
#ifdef UI_PROP_DECORATE
uiLayout *layout_prop_decorate = NULL;
uiLayout *layout_prop_decorate = nullptr;
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
const bool use_prop_decorate = use_prop_sep && (layout->item.flag & UI_ITEM_PROP_DECORATE) &&
(layout->item.flag & UI_ITEM_PROP_DECORATE_NO_PAD) == 0;
@@ -1041,7 +1032,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
else {
w_label = w_hint / 3;
}
uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, nullptr, 0.0, 0.0, 0, 0, "");
}
}
@@ -1064,7 +1055,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
y,
UI_UNIT_X,
h,
NULL);
nullptr);
}
else if (flag & UI_ITEM_R_EVENT) {
but = uiDefButR_prop(block,
@@ -1082,12 +1073,13 @@ static uiBut *ui_item_with_label(uiLayout *layout,
0,
-1,
-1,
NULL);
nullptr);
}
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(
static_cast<const wmKeyMapItem *>(ptr->data), false, buf, sizeof(buf));
but = uiDefButR_prop(block,
UI_BTYPE_HOTKEY_EVENT,
@@ -1104,21 +1096,21 @@ static uiBut *ui_item_with_label(uiLayout *layout,
0,
-1,
-1,
NULL);
UI_but_func_set(but, ui_keymap_but_cb, but, NULL);
nullptr);
UI_but_func_set(but, ui_keymap_but_cb, but, nullptr);
if (flag & UI_ITEM_R_IMMEDIATE) {
UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
}
}
else {
const char *str = (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "";
const char *str = (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? nullptr : "";
but = uiDefAutoButR(block, ptr, prop, index, str, icon, x, y, prop_but_width, h);
}
#ifdef UI_PROP_DECORATE
/* Only for alignment. */
if (use_prop_decorate) { /* Note that sep flag may have been unset meanwhile. */
uiItemL(layout_prop_decorate ? layout_prop_decorate : sub, NULL, ICON_BLANK1);
uiItemL(layout_prop_decorate ? layout_prop_decorate : sub, nullptr, ICON_BLANK1);
}
#endif /* UI_PROP_DECORATE */
@@ -1133,10 +1125,10 @@ void UI_context_active_but_prop_get_filebrowser(const bContext *C,
bool *r_is_userdef)
{
ARegion *region = CTX_wm_menu(C) ? CTX_wm_menu(C) : CTX_wm_region(C);
uiBut *prevbut = NULL;
uiBut *prevbut = nullptr;
memset(r_ptr, 0, sizeof(*r_ptr));
*r_prop = NULL;
*r_prop = nullptr;
*r_is_undo = false;
*r_is_userdef = false;
@@ -1175,7 +1167,7 @@ void UI_context_active_but_prop_get_filebrowser(const bContext *C,
*/
static void ui_but_tip_from_enum_item(uiBut *but, const EnumPropertyItem *item)
{
if (but->tip == NULL || but->tip[0] == '\0') {
if (but->tip == nullptr || but->tip[0] == '\0') {
if (item->description && item->description[0] &&
!(but->optype && but->optype->get_description)) {
but->tip = item->description;
@@ -1197,13 +1189,13 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
const int w = ui_text_icon_width(layout, name, 0, 0);
uiBut *but = uiDefBut(
block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, nullptr, 0.0, 0.0, 0, 0, "");
UI_but_disable(but, "");
}
/**
* Operator Item
* \param r_opptr: Optional, initialize with operator properties when not NULL.
* \param r_opptr: Optional, initialize with operator properties when not nullptr.
* Will always be written to even in the case of errors.
*/
static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
@@ -1220,7 +1212,7 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
if (!name) {
if (ot && ot->srna && (flag & UI_ITEM_R_ICON_ONLY) == 0) {
name = WM_operatortype_name(ot, NULL);
name = WM_operatortype_name(ot, nullptr);
}
else {
name = "";
@@ -1232,7 +1224,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, uiButtonGroupFlag(0));
const int w = ui_text_icon_width(layout, name, icon, 0);
@@ -1246,17 +1238,17 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
if (icon) {
if (name[0]) {
but = uiDefIconTextButO_ptr(
block, UI_BTYPE_BUT, ot, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL);
block, UI_BTYPE_BUT, ot, context, icon, name, 0, 0, w, UI_UNIT_Y, nullptr);
}
else {
but = uiDefIconButO_ptr(block, UI_BTYPE_BUT, ot, context, icon, 0, 0, w, UI_UNIT_Y, NULL);
but = uiDefIconButO_ptr(block, UI_BTYPE_BUT, ot, context, icon, 0, 0, w, UI_UNIT_Y, nullptr);
}
}
else {
but = uiDefButO_ptr(block, UI_BTYPE_BUT, ot, context, name, 0, 0, w, UI_UNIT_Y, NULL);
but = uiDefButO_ptr(block, UI_BTYPE_BUT, ot, context, name, 0, 0, w, UI_UNIT_Y, nullptr);
}
BLI_assert(but->optype != NULL);
BLI_assert(but->optype != nullptr);
if (flag & UI_ITEM_R_NO_BG) {
layout->emboss = prev_emboss;
@@ -1296,7 +1288,7 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
return but;
}
static void ui_item_menu_hold(struct bContext *C, ARegion *butregion, uiBut *but)
static void ui_item_menu_hold(bContext *C, ARegion *butregion, uiBut *but)
{
uiPopupMenu *pup = UI_popup_menu_begin(C, "", ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
@@ -1325,7 +1317,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 = static_cast<const char *>(but->hold_argN);
MenuType *mt = WM_menutype_find(menu_id, true);
if (mt) {
uiLayoutSetContextFromBut(layout, but);
@@ -1392,7 +1384,8 @@ 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(
static_cast<bContext *>(layout->root->block->evil_C), ptr, prop, &item, nullptr, &free);
const char *name;
if (RNA_enum_name(item, retval, &name)) {
@@ -1420,7 +1413,7 @@ void uiItemEnumO_ptr(uiLayout *layout,
WM_operator_properties_create_ptr(&ptr, ot);
PropertyRNA *prop = RNA_struct_find_property(&ptr, propname);
if (prop == NULL) {
if (prop == nullptr) {
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
return;
}
@@ -1431,7 +1424,14 @@ 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,
static_cast<IDProperty *>(ptr.data),
layout->root->opcontext,
0,
nullptr);
}
void uiItemEnumO(uiLayout *layout,
const char *opname,
@@ -1473,7 +1473,7 @@ void uiItemsFullEnumO_items(uiLayout *layout,
return;
}
uiLayout *target, *split = NULL;
uiLayout *target, *split = nullptr;
uiBlock *block = layout->root->block;
const bool radial = ui_layout_is_radial(layout);
@@ -1493,12 +1493,12 @@ void uiItemsFullEnumO_items(uiLayout *layout,
0,
1.25f * UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0,
0,
0,
0,
NULL);
nullptr);
}
else {
split = uiLayoutSplit(layout, 0.0f, false);
@@ -1522,8 +1522,14 @@ void uiItemsFullEnumO_items(uiLayout *layout,
}
if (tmp->identifier) { /* only true if loop above found item and did early-exit */
ui_pie_menu_level_create(
block, ot, propname, properties, item_array, totitem, context, flag);
ui_pie_menu_level_create(block,
ot,
propname,
properties,
item_array,
totitem,
context,
wmOperatorCallContext(flag));
/* break since rest of items is handled in new pie level */
break;
}
@@ -1539,7 +1545,7 @@ void uiItemsFullEnumO_items(uiLayout *layout,
WM_operator_properties_create_ptr(&tptr, ot);
if (properties) {
if (tptr.data) {
IDP_FreeProperty(tptr.data);
IDP_FreeProperty(static_cast<IDProperty *>(tptr.data));
}
tptr.data = IDP_CopyProperty(properties);
}
@@ -1547,18 +1553,18 @@ void uiItemsFullEnumO_items(uiLayout *layout,
uiItemFullO_ptr(target,
ot,
(flag & UI_ITEM_R_ICON_ONLY) ? NULL : item->name,
(flag & UI_ITEM_R_ICON_ONLY) ? nullptr : item->name,
item->icon,
tptr.data,
static_cast<IDProperty *>(tptr.data),
context,
flag,
NULL);
nullptr);
ui_but_tip_from_enum_item(block->buttons.last, item);
ui_but_tip_from_enum_item(static_cast<uiBut *>(block->buttons.last), item);
}
else {
if (item->name) {
if (item != item_array && !radial && split != NULL) {
if (item != item_array && !radial && split != nullptr) {
target = uiLayoutColumn(split, layout->align);
/* inconsistent, but menus with labels do not look good flipped */
@@ -1569,7 +1575,7 @@ void uiItemsFullEnumO_items(uiLayout *layout,
if (item->icon || radial) {
uiItemL(target, item->name, item->icon);
but = block->buttons.last;
but = static_cast<uiBut *>(block->buttons.last);
}
else {
/* Do not use uiItemL here, as our root layout is a menu one,
@@ -1582,7 +1588,7 @@ void uiItemsFullEnumO_items(uiLayout *layout,
0,
UI_UNIT_X * 5,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -1629,11 +1635,11 @@ void uiItemsFullEnumO(uiLayout *layout,
PropertyRNA *prop = RNA_struct_find_property(&ptr, propname);
/* don't let bad properties slip through */
BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM));
BLI_assert((prop == nullptr) || (RNA_property_type(prop) == PROP_ENUM));
uiBlock *block = layout->root->block;
if (prop && RNA_property_type(prop) == PROP_ENUM) {
const EnumPropertyItem *item_array = NULL;
const EnumPropertyItem *item_array = nullptr;
int totitem;
bool free;
@@ -1645,13 +1651,15 @@ void uiItemsFullEnumO(uiLayout *layout,
*/
#if 0
RNA_property_enum_items_gettexted_all(
block->evil_C, &ptr, prop, &item_array, &totitem, &free);
static_cast<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(
static_cast<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(
static_cast<bContext *>(block->evil_C), &ptr, prop, &item_array, &totitem, &free);
}
/* add items */
@@ -1676,7 +1684,7 @@ void uiItemsFullEnumO(uiLayout *layout,
void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname)
{
uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0);
uiItemsFullEnumO(layout, opname, propname, nullptr, layout->root->opcontext, 0);
}
void uiItemEnumO_value(uiLayout *layout,
@@ -1694,7 +1702,7 @@ void uiItemEnumO_value(uiLayout *layout,
/* enum lookup */
PropertyRNA *prop = RNA_struct_find_property(&ptr, propname);
if (prop == NULL) {
if (prop == nullptr) {
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
return;
}
@@ -1706,7 +1714,14 @@ 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,
static_cast<IDProperty *>(ptr.data),
layout->root->opcontext,
0,
nullptr);
}
void uiItemEnumO_string(uiLayout *layout,
@@ -1723,7 +1738,7 @@ void uiItemEnumO_string(uiLayout *layout,
WM_operator_properties_create_ptr(&ptr, ot);
PropertyRNA *prop = RNA_struct_find_property(&ptr, propname);
if (prop == NULL) {
if (prop == nullptr) {
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
return;
}
@@ -1732,10 +1747,11 @@ 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(
static_cast<bContext *>(layout->root->block->evil_C), &ptr, prop, &item, nullptr, &free);
int value;
if (item == NULL || RNA_enum_value_from_id(item, value_str, &value) == 0) {
if (item == nullptr || RNA_enum_value_from_id(item, value_str, &value) == 0) {
if (free) {
MEM_freeN((void *)item);
}
@@ -1754,7 +1770,14 @@ 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,
static_cast<IDProperty *>(ptr.data),
layout->root->opcontext,
0,
nullptr);
}
void uiItemBooleanO(uiLayout *layout,
@@ -1771,7 +1794,14 @@ 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,
static_cast<IDProperty *>(ptr.data),
layout->root->opcontext,
0,
nullptr);
}
void uiItemIntO(uiLayout *layout,
@@ -1788,7 +1818,14 @@ 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,
static_cast<IDProperty *>(ptr.data),
layout->root->opcontext,
0,
nullptr);
}
void uiItemFloatO(uiLayout *layout,
@@ -1806,7 +1843,14 @@ 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,
static_cast<IDProperty *>(ptr.data),
layout->root->opcontext,
0,
nullptr);
}
void uiItemStringO(uiLayout *layout,
@@ -1824,12 +1868,19 @@ 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,
static_cast<IDProperty *>(ptr.data),
layout->root->opcontext,
0,
nullptr);
}
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
{
uiItemFullO(layout, opname, name, icon, NULL, layout->root->opcontext, 0, NULL);
uiItemFullO(layout, opname, name, icon, nullptr, layout->root->opcontext, 0, nullptr);
}
/* RNA property items */
@@ -1868,8 +1919,12 @@ static void ui_item_rna_size(uiLayout *layout,
/* Find the longest enum item name, instead of using a dummy text! */
const EnumPropertyItem *item_array;
bool free;
RNA_property_enum_items_gettexted(
layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free);
RNA_property_enum_items_gettexted(static_cast<bContext *>(layout->root->block->evil_C),
ptr,
prop,
&item_array,
nullptr,
&free);
for (const EnumPropertyItem *item = item_array; item->identifier; item++) {
if (item->identifier[0]) {
@@ -1960,7 +2015,7 @@ static uiLayout *ui_layout_heading_find(uiLayout *cur_layout)
}
}
return NULL;
return nullptr;
}
static void ui_layout_heading_label_add(uiLayout *layout,
@@ -2034,18 +2089,20 @@ void uiItemFullR(uiLayout *layout,
bool use_split_empty_name = (flag & UI_ITEM_R_SPLIT_EMPTY_NAME);
#ifdef UI_PROP_DECORATE
struct {
struct DecorateInfo {
bool use_prop_decorate;
int len;
uiLayout *layout;
uiBut *but;
} ui_decorate = {
.use_prop_decorate = (((layout->item.flag & UI_ITEM_PROP_DECORATE) != 0) && use_prop_sep),
};
DecorateInfo ui_decorate{};
ui_decorate.use_prop_decorate = (((layout->item.flag & UI_ITEM_PROP_DECORATE) != 0) &&
use_prop_sep);
#endif /* UI_PROP_DECORATE */
UI_block_layout_set_current(block, layout);
ui_block_new_button_group(block, 0);
ui_block_new_button_group(block, uiButtonGroupFlag(0));
/* retrieve info */
const PropertyType type = RNA_property_type(prop);
@@ -2166,13 +2223,13 @@ void uiItemFullR(uiLayout *layout,
layout->emboss = UI_EMBOSS_NONE_OR_STATUS;
}
uiBut *but = NULL;
uiBut *but = nullptr;
/* Split the label / property. */
uiLayout *layout_parent = layout;
if (use_prop_sep) {
uiLayout *layout_row = NULL;
uiLayout *layout_row = nullptr;
#ifdef UI_PROP_DECORATE
if (ui_decorate.use_prop_decorate) {
layout_row = uiLayoutRow(layout, true);
@@ -2220,7 +2277,7 @@ void uiItemFullR(uiLayout *layout,
0,
w,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -2235,7 +2292,7 @@ void uiItemFullR(uiLayout *layout,
else {
if (name) {
but = uiDefBut(
block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, nullptr, 0.0, 0.0, 0, 0, "");
but->drawflag |= UI_BUT_TEXT_RIGHT;
but->drawflag &= ~UI_BUT_TEXT_LEFT;
@@ -2276,7 +2333,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 = static_cast<uiBut *>(block->buttons.last);
/* Clear after. */
layout->item.flag |= UI_ITEM_PROP_DECORATE_NO_PAD;
@@ -2319,16 +2376,31 @@ void uiItemFullR(uiLayout *layout,
/* enum item */
else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
if (icon && name[0] && !icon_only) {
uiDefIconTextButR_prop(
block, UI_BTYPE_ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
uiDefIconTextButR_prop(block,
UI_BTYPE_ROW,
0,
icon,
name,
0,
0,
w,
h,
ptr,
prop,
-1,
0,
value,
-1,
-1,
nullptr);
}
else if (icon) {
uiDefIconButR_prop(
block, UI_BTYPE_ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
block, UI_BTYPE_ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, nullptr);
}
else {
uiDefButR_prop(
block, UI_BTYPE_ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
block, UI_BTYPE_ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, nullptr);
}
}
/* expanded enum */
@@ -2345,7 +2417,7 @@ void uiItemFullR(uiLayout *layout,
results_are_suggestions = true;
}
}
but = ui_but_add_search(but, ptr, prop, NULL, NULL, results_are_suggestions);
but = ui_but_add_search(but, ptr, prop, nullptr, nullptr, results_are_suggestions);
if (layout->redalert) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
@@ -2409,7 +2481,8 @@ 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 :
static_cast<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;
@@ -2417,12 +2490,12 @@ void uiItemFullR(uiLayout *layout,
int i;
for (i = 0; i < ui_decorate.len && but_decorate; i++) {
PointerRNA *ptr_dec = use_blank_decorator ? NULL : &but_decorate->rnapoin;
PropertyRNA *prop_dec = use_blank_decorator ? NULL : but_decorate->rnaprop;
PointerRNA *ptr_dec = use_blank_decorator ? nullptr : &but_decorate->rnapoin;
PropertyRNA *prop_dec = use_blank_decorator ? nullptr : but_decorate->rnaprop;
/* 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 = static_cast<uiBut *>(block->buttons.last);
/* Order the decorator after the button we decorate, this is used so we can always
* do a quick lookup. */
@@ -2471,7 +2544,7 @@ void uiItemFullR_with_popover(uiLayout *layout,
const char *panel_type)
{
uiBlock *block = layout->root->block;
uiBut *but = block->buttons.last;
uiBut *but = static_cast<uiBut *>(block->buttons.last);
uiItemFullR(layout, ptr, prop, index, value, flag, name, icon);
but = but->next;
while (but) {
@@ -2481,7 +2554,7 @@ void uiItemFullR_with_popover(uiLayout *layout,
}
but = but->next;
}
if (but == NULL) {
if (but == nullptr) {
const char *propname = RNA_property_identifier(prop);
ui_item_disabled(layout, panel_type);
RNA_warning("property could not use a popover: %s.%s (%s)",
@@ -2502,7 +2575,7 @@ void uiItemFullR_with_menu(uiLayout *layout,
const char *menu_type)
{
uiBlock *block = layout->root->block;
uiBut *but = block->buttons.last;
uiBut *but = static_cast<uiBut *>(block->buttons.last);
uiItemFullR(layout, ptr, prop, index, value, flag, name, icon);
but = but->next;
while (but) {
@@ -2512,7 +2585,7 @@ void uiItemFullR_with_menu(uiLayout *layout,
}
but = but->next;
}
if (but == NULL) {
if (but == nullptr) {
const char *propname = RNA_property_identifier(prop);
ui_item_disabled(layout, menu_type);
RNA_warning("property could not use a menu: %s.%s (%s)",
@@ -2522,12 +2595,8 @@ void uiItemFullR_with_menu(uiLayout *layout,
}
}
void uiItemEnumR_prop(uiLayout *layout,
const char *name,
int icon,
struct PointerRNA *ptr,
PropertyRNA *prop,
int value)
void uiItemEnumR_prop(
uiLayout *layout, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int value)
{
if (RNA_property_type(prop) != PROP_ENUM) {
const char *propname = RNA_property_identifier(prop);
@@ -2539,16 +2608,12 @@ void uiItemEnumR_prop(uiLayout *layout,
uiItemFullR(layout, ptr, prop, RNA_ENUM_VALUE, value, 0, name, icon);
}
void uiItemEnumR(uiLayout *layout,
const char *name,
int icon,
struct PointerRNA *ptr,
const char *propname,
int value)
void uiItemEnumR(
uiLayout *layout, const char *name, int icon, PointerRNA *ptr, const char *propname, int value)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
if (prop == NULL) {
if (prop == nullptr) {
ui_item_disabled(layout, propname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
@@ -2558,7 +2623,7 @@ void uiItemEnumR(uiLayout *layout,
}
void uiItemEnumR_string_prop(uiLayout *layout,
struct PointerRNA *ptr,
PointerRNA *ptr,
PropertyRNA *prop,
const char *value,
const char *name,
@@ -2573,7 +2638,8 @@ 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(
static_cast<bContext *>(layout->root->block->evil_C), ptr, prop, &item, nullptr, &free);
int ivalue;
if (!RNA_enum_value_from_id(item, value, &ivalue)) {
@@ -2609,14 +2675,14 @@ void uiItemEnumR_string_prop(uiLayout *layout,
}
void uiItemEnumR_string(uiLayout *layout,
struct PointerRNA *ptr,
PointerRNA *ptr,
const char *propname,
const char *value,
const char *name,
int icon)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
if (UNLIKELY(prop == NULL)) {
if (UNLIKELY(prop == nullptr)) {
ui_item_disabled(layout, propname);
RNA_warning("enum property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
@@ -2624,7 +2690,7 @@ void uiItemEnumR_string(uiLayout *layout,
uiItemEnumR_string_prop(layout, ptr, prop, value, name, icon);
}
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname)
void uiItemsEnumR(uiLayout *layout, PointerRNA *ptr, const char *propname)
{
uiBlock *block = layout->root->block;
@@ -2647,12 +2713,13 @@ 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(
static_cast<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(static_cast<uiBut *>(block->buttons.last), &item[i]);
}
else {
if (item[i].name) {
@@ -2663,7 +2730,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 = static_cast<uiBut *>(block->buttons.last);
bt->drawflag = UI_BUT_TEXT_LEFT;
ui_but_tip_from_enum_item(bt, &item[i]);
@@ -2690,7 +2757,7 @@ static void search_id_collection(StructRNA *ptype, PointerRNA *r_ptr, PropertyRN
/* NOTE: using global Main is OK-ish here, UI shall not access other Mains anyway. */
RNA_main_pointer_create(G_MAIN, r_ptr);
*r_prop = NULL;
*r_prop = nullptr;
RNA_STRUCT_BEGIN (r_ptr, iprop) {
/* if it's a collection and has same pointer type, we've got it */
@@ -2708,7 +2775,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 = static_cast<uiRNACollectionSearch *>(ptr);
UI_butstore_free(coll_search->butstore_block, coll_search->butstore);
MEM_freeN(ptr);
}
@@ -2737,7 +2804,8 @@ uiBut *ui_but_add_search(uiBut *but,
/* turn button into search button */
if (has_search_fn || searchprop) {
uiRNACollectionSearch *coll_search = MEM_mallocN(sizeof(*coll_search), __func__);
uiRNACollectionSearch *coll_search = static_cast<uiRNACollectionSearch *>(
MEM_mallocN(sizeof(*coll_search), __func__));
uiButSearch *search_but;
but = ui_but_change_type(but, UI_BTYPE_SEARCH_MENU);
@@ -2764,7 +2832,7 @@ uiBut *ui_but_add_search(uiBut *but,
else {
/* Rely on `has_search_fn`. */
coll_search->search_ptr = PointerRNA_NULL;
coll_search->search_prop = NULL;
coll_search->search_prop = nullptr;
}
coll_search->search_but = but;
@@ -2786,8 +2854,8 @@ uiBut *ui_but_add_search(uiBut *but,
coll_search,
false,
ui_rna_collection_search_arg_free_fn,
NULL,
NULL);
nullptr,
nullptr);
/* If this is called multiple times for the same button, an earlier call may have taken the
* else branch below so the button was disabled. Now we have a searchprop, so it can be enabled
* again. */
@@ -2813,7 +2881,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), uiButtonGroupFlag(0));
const PropertyType type = RNA_property_type(prop);
if (!ELEM(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) {
@@ -2918,7 +2986,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, uiButtonGroupFlag(0));
if (!name) {
name = "";
@@ -2927,7 +2995,7 @@ static uiBut *ui_item_menu(uiLayout *layout,
icon = ICON_BLANK1;
}
struct uiTextIconPadFactor pad_factor = ui_text_pad_compact;
uiTextIconPadFactor pad_factor = ui_text_pad_compact;
if (layout->root->type == UI_LAYOUT_HEADER) { /* Ugly! */
if (icon == ICON_NONE && force_menu) {
/* pass */
@@ -2982,7 +3050,7 @@ static uiBut *ui_item_menu(uiLayout *layout,
void uiItemM_ptr(uiLayout *layout, MenuType *mt, const char *name, int icon)
{
uiBlock *block = layout->root->block;
bContext *C = block->evil_C;
bContext *C = static_cast<bContext *>(block->evil_C);
if (WM_menutype_poll(C, mt) == false) {
return;
}
@@ -3000,7 +3068,7 @@ void uiItemM_ptr(uiLayout *layout, MenuType *mt, const char *name, int icon)
icon,
ui_item_menutype_func,
mt,
NULL,
nullptr,
mt->description ? TIP_(mt->description) : "",
false);
}
@@ -3008,7 +3076,7 @@ void uiItemM_ptr(uiLayout *layout, MenuType *mt, const char *name, int icon)
void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon)
{
MenuType *mt = WM_menutype_find(menuname, false);
if (mt == NULL) {
if (mt == nullptr) {
RNA_warning("not found %s", menuname);
return;
}
@@ -3018,13 +3086,13 @@ void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon)
void uiItemMContents(uiLayout *layout, const char *menuname)
{
MenuType *mt = WM_menutype_find(menuname, false);
if (mt == NULL) {
if (mt == nullptr) {
RNA_warning("not found %s", menuname);
return;
}
uiBlock *block = layout->root->block;
bContext *C = block->evil_C;
bContext *C = static_cast<bContext *>(block->evil_C);
if (WM_menutype_poll(C, mt) == false) {
return;
}
@@ -3047,7 +3115,7 @@ void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop,
col->space = 0;
col->emboss = UI_EMBOSS_NONE;
if (ELEM(NULL, ptr, prop) || !RNA_property_animateable(ptr, prop)) {
if (ELEM(nullptr, ptr, prop) || !RNA_property_animateable(ptr, prop)) {
uiBut *but = uiDefIconBut(block,
UI_BTYPE_DECORATOR,
0,
@@ -3056,7 +3124,7 @@ void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0.0,
@@ -3079,14 +3147,14 @@ void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Animate property"));
UI_but_func_set(&decorator_but->but, ui_but_anim_decorate_cb, decorator_but, NULL);
UI_but_func_set(&decorator_but->but, ui_but_anim_decorate_cb, decorator_but, nullptr);
decorator_but->but.flag |= UI_BUT_UNDO | UI_BUT_DRAG_LOCK;
/* Reusing RNA search members, setting actual RNA data has many side-effects. */
decorator_but->rnapoin = *ptr;
@@ -3098,7 +3166,7 @@ void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop,
void uiItemDecoratorR(uiLayout *layout, PointerRNA *ptr, const char *propname, int index)
{
PropertyRNA *prop = NULL;
PropertyRNA *prop = nullptr;
if (ptr && propname) {
/* validate arguments */
@@ -3110,7 +3178,7 @@ void uiItemDecoratorR(uiLayout *layout, PointerRNA *ptr, const char *propname, i
}
}
/* ptr and prop are allowed to be NULL here. */
/* ptr and prop are allowed to be nullptr here. */
uiItemDecoratorR_prop(layout, ptr, prop, index);
}
@@ -3125,18 +3193,16 @@ void uiItemPopoverPanel_ptr(
icon = ICON_BLANK1;
}
const bool ok = (pt->poll == NULL) || pt->poll(C, pt);
if (ok && (pt->draw_header != NULL)) {
const bool ok = (pt->poll == nullptr) || pt->poll(C, pt);
if (ok && (pt->draw_header != nullptr)) {
layout = uiLayoutRow(layout, true);
Panel panel = {
.type = pt,
.layout = layout,
.flag = PNL_POPOVER,
};
Panel panel{};
panel.type = pt;
panel.layout = layout;
pt->draw_header(C, &panel);
}
uiBut *but = ui_item_menu(
layout, name, icon, ui_item_paneltype_func, pt, NULL, pt->description, true);
layout, name, icon, ui_item_paneltype_func, pt, nullptr, pt->description, true);
but->type = UI_BTYPE_POPOVER;
if (!ok) {
but->flag |= UI_BUT_DISABLED;
@@ -3147,7 +3213,7 @@ void uiItemPopoverPanel(
uiLayout *layout, const bContext *C, const char *panel_type, const char *name, int icon)
{
PanelType *pt = WM_paneltype_find(panel_type, true);
if (pt == NULL) {
if (pt == nullptr) {
RNA_warning("Panel type not found '%s'", panel_type);
return;
}
@@ -3162,12 +3228,12 @@ void uiItemPopoverPanelFromGroup(uiLayout *layout,
const char *category)
{
SpaceType *st = BKE_spacetype_from_id(space_id);
if (st == NULL) {
if (st == nullptr) {
RNA_warning("space type not found %d", space_id);
return;
}
ARegionType *art = BKE_regiontype_from_id(st, region_id);
if (art == NULL) {
if (art == nullptr) {
RNA_warning("region type not found %d", region_id);
return;
}
@@ -3177,8 +3243,8 @@ void uiItemPopoverPanelFromGroup(uiLayout *layout,
if (pt->parent_id[0] == '\0') {
if (/* (*context == '\0') || */ STREQ(pt->context, context)) {
if ((*category == '\0') || STREQ(pt->category, category)) {
if (pt->poll == NULL || pt->poll(C, pt)) {
uiItemPopoverPanel_ptr(layout, C, pt, NULL, ICON_NONE);
if (pt->poll == nullptr || pt->poll(C, pt)) {
uiItemPopoverPanel_ptr(layout, C, pt, nullptr, ICON_NONE);
}
}
}
@@ -3192,7 +3258,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, uiButtonGroupFlag(0));
if (!name) {
name = "";
@@ -3204,15 +3270,29 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
const int w = ui_text_icon_width_ex(layout, name, icon, &ui_text_pad_none);
uiBut *but;
if (icon && name[0]) {
but = uiDefIconTextBut(
block, UI_BTYPE_LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, NULL);
but = uiDefIconTextBut(block,
UI_BTYPE_LABEL,
0,
icon,
name,
0,
0,
w,
UI_UNIT_Y,
nullptr,
0.0,
0.0,
0,
0,
nullptr);
}
else if (icon) {
but = uiDefIconBut(
block, UI_BTYPE_LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, NULL);
block, UI_BTYPE_LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, nullptr, 0.0, 0.0, 0, 0, nullptr);
}
else {
but = uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, NULL);
but = uiDefBut(
block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, nullptr, 0.0, 0.0, 0, 0, nullptr);
}
/* to compensate for string size padding in ui_text_icon_width,
@@ -3259,7 +3339,7 @@ void uiItemL(uiLayout *layout, const char *name, int icon)
uiPropertySplitWrapper uiItemPropertySplitWrapperCreate(uiLayout *parent_layout)
{
uiPropertySplitWrapper split_wrapper = {NULL};
uiPropertySplitWrapper split_wrapper = {nullptr};
uiLayout *layout_row = uiLayoutRow(parent_layout, true);
uiLayout *layout_split = uiLayoutSplit(layout_row, UI_ITEM_PROP_SEP_DIVIDE, true);
@@ -3309,7 +3389,7 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
{
/* label */
uiBlock *block = layout->root->block;
int *retvalue = (block->handle) ? &block->handle->retvalue : NULL;
int *retvalue = (block->handle) ? &block->handle->retvalue : nullptr;
UI_block_layout_set_current(block, layout);
@@ -3368,7 +3448,7 @@ void uiItemS_ex(uiLayout *layout, float factor)
0,
space,
space,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -3405,7 +3485,7 @@ void uiItemSpacer(uiLayout *layout)
0,
0.3f * UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -3419,7 +3499,7 @@ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc
return;
}
ui_item_menu(layout, name, icon, func, arg, NULL, "", false);
ui_item_menu(layout, name, icon, func, arg, nullptr, "", false);
}
void uiItemMenuFN(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *argN)
@@ -3432,21 +3512,21 @@ void uiItemMenuFN(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc
ui_item_menu(layout, name, icon, func, argN, argN, "", false);
}
typedef struct MenuItemLevel {
struct MenuItemLevel {
wmOperatorCallContext opcontext;
/* don't use pointers to the strings because python can dynamically
* allocate strings and free before the menu draws, see T27304. */
char opname[OP_MAX_TYPENAME];
char propname[MAX_IDPROP_NAME];
PointerRNA rnapoin;
} MenuItemLevel;
};
static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
static void menu_item_enum_opname_menu(bContext * /*C*/, uiLayout *layout, void *arg)
{
uiBut *but = arg;
MenuItemLevel *lvl = but->func_argN;
uiBut *but = static_cast<uiBut *>(arg);
MenuItemLevel *lvl = static_cast<MenuItemLevel *>(but->func_argN);
/* Use the operator properties from the button owning the menu. */
IDProperty *op_props = but->opptr ? but->opptr->data : NULL;
IDProperty *op_props = but->opptr ? static_cast<IDProperty *>(but->opptr->data) : nullptr;
uiLayoutSetOperatorContext(layout, lvl->opcontext);
uiItemsFullEnumO(layout, lvl->opname, lvl->propname, op_props, lvl->opcontext, 0);
@@ -3466,28 +3546,29 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout,
PointerRNA *r_opptr)
{
/* Caller must check */
BLI_assert(ot->srna != NULL);
BLI_assert(ot->srna != nullptr);
if (name == NULL) {
name = WM_operatortype_name(ot, NULL);
if (name == nullptr) {
name = WM_operatortype_name(ot, nullptr);
}
if (layout->root->type == UI_LAYOUT_MENU && !icon) {
icon = ICON_BLANK1;
}
MenuItemLevel *lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
MenuItemLevel *lvl = MEM_cnew<MenuItemLevel>("MenuItemLevel");
BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname));
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
lvl->opcontext = layout->root->opcontext;
uiBut *but = ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl, NULL, true);
uiBut *but = ui_item_menu(
layout, name, icon, menu_item_enum_opname_menu, nullptr, lvl, nullptr, true);
/* Use the menu button as owner for the operator properties, which will then be passed to the
* individual menu items. */
if (r_opptr) {
but->opptr = MEM_callocN(sizeof(PointerRNA), "uiButOpPtr");
but->opptr = MEM_cnew<PointerRNA>("uiButOpPtr");
WM_operator_properties_create_ptr(but->opptr, ot);
BLI_assert(but->opptr->data == NULL);
BLI_assert(but->opptr->data == nullptr);
WM_operator_properties_alloc(&but->opptr, (IDProperty **)&but->opptr->data, ot->idname);
*r_opptr = *but->opptr;
}
@@ -3496,7 +3577,7 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout,
if ((layout->root->block->flag & UI_BLOCK_LOOP) && (ot->prop && ot->invoke)) {
char keybuf[128];
if (WM_key_event_operator_string(
C, ot->idname, layout->root->opcontext, NULL, false, keybuf, sizeof(keybuf))) {
C, ot->idname, layout->root->opcontext, nullptr, false, keybuf, sizeof(keybuf))) {
ui_but_add_shortcut(but, keybuf, false);
}
}
@@ -3530,10 +3611,10 @@ void uiItemMenuEnumO(uiLayout *layout,
const char *name,
int icon)
{
uiItemMenuEnumFullO(layout, C, opname, propname, name, icon, NULL);
uiItemMenuEnumFullO(layout, C, opname, propname, name, icon, nullptr);
}
static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
static void menu_item_enum_rna_menu(bContext * /*C*/, uiLayout *layout, void *arg)
{
MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN);
@@ -3543,7 +3624,7 @@ static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void
}
void uiItemMenuEnumR_prop(
uiLayout *layout, struct PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon)
uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, const char *name, int icon)
{
if (!name) {
name = RNA_property_ui_name(prop);
@@ -3552,7 +3633,7 @@ void uiItemMenuEnumR_prop(
icon = ICON_BLANK1;
}
MenuItemLevel *lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
MenuItemLevel *lvl = MEM_cnew<MenuItemLevel>("MenuItemLevel");
lvl->rnapoin = *ptr;
BLI_strncpy(lvl->propname, RNA_property_identifier(prop), sizeof(lvl->propname));
lvl->opcontext = layout->root->opcontext;
@@ -3561,14 +3642,14 @@ void uiItemMenuEnumR_prop(
name,
icon,
menu_item_enum_rna_menu,
NULL,
nullptr,
lvl,
RNA_property_description(prop),
false);
}
void uiItemMenuEnumR(
uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon)
uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, int icon)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -3592,7 +3673,7 @@ void uiItemTabsEnumR_prop(uiLayout *layout,
UI_block_layout_set_current(block, layout);
ui_item_enum_expand_tabs(
layout, C, block, ptr, prop, ptr_highlight, prop_highlight, NULL, UI_UNIT_Y, icon_only);
layout, C, block, ptr, prop, ptr_highlight, prop_highlight, nullptr, UI_UNIT_Y, icon_only);
}
/** \} */
@@ -3635,7 +3716,7 @@ static int ui_litem_min_width(int itemw)
static void ui_litem_layout_row(uiLayout *litem)
{
uiItem *last_free_item = NULL;
uiItem *last_free_item = nullptr;
int x, neww, newtotw, itemw, minw, itemh, offset;
int freew, fixedx, freex, flag = 0, lastw = 0;
float extra_pixel;
@@ -3765,7 +3846,7 @@ static void ui_litem_layout_row(uiLayout *litem)
}
/* add extra pixel */
uiItem *last_item = litem->items.last;
uiItem *last_item = static_cast<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) {
@@ -3844,7 +3925,7 @@ static RadialDirection ui_get_radialbut_vec(float vec[2], short itemnum)
PIE_MAX_ITEMS);
}
const RadialDirection dir = ui_radial_dir_order[itemnum];
const RadialDirection dir = RadialDirection(ui_radial_dir_order[itemnum]);
ui_but_pie_dir(dir, vec);
return dir;
@@ -3947,7 +4028,7 @@ static void ui_litem_layout_radial(uiLayout *litem)
}
/* root layout */
static void ui_litem_estimate_root(uiLayout *UNUSED(litem))
static void ui_litem_estimate_root(uiLayout * /*litem*/)
{
/* nothing to do */
}
@@ -3955,7 +4036,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 = static_cast<uiItem *>(litem->items.first);
if (item->type == ITEM_BUTTON) {
int itemh, itemw, x, y;
@@ -4164,24 +4245,24 @@ 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. */
/* Real data about current position and size of this layout item
* (either estimated, or final values). */
const int litem_w; /* Layout item width. */
const int litem_x; /* Layout item X position. */
const int litem_y; /* Layout item Y position. */
bool row_major : 1; /* Fill rows before columns */
bool even_columns : 1; /* All columns will have same width. */
bool even_rows : 1; /* All rows will have same height. */
int space_x; /* Space between columns. */
int space_y; /* Space between rows. */
/* Real data about current position and size of this layout item
* (either estimated, or final values). */
int litem_w; /* Layout item width. */
int litem_x; /* Layout item X position. */
int litem_y; /* Layout item Y position. */
/* 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;
int tot_columns; /* Number of columns. */
int tot_rows; /* Number of rows. */
};
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. */
@@ -4193,31 +4274,28 @@ 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,
const UILayoutGridFlowInput *parameters,
UILayoutGridFlowOutput *results)
{
float tot_w = 0.0f, tot_h = 0.0f;
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;
BLI_assert(
parameters->tot_columns != 0 ||
(results->cos_x_array == NULL && results->widths_array == NULL && results->tot_w == NULL));
BLI_assert(
parameters->tot_rows != 0 ||
(results->cos_y_array == NULL && results->heights_array == NULL && results->tot_h == NULL));
BLI_assert(parameters->tot_columns != 0 ||
(results->cos_x_array == nullptr && results->widths_array == nullptr &&
results->tot_w == nullptr));
BLI_assert(parameters->tot_rows != 0 ||
(results->cos_y_array == nullptr && results->heights_array == nullptr &&
results->tot_h == nullptr));
if (results->tot_items) {
*results->tot_items = 0;
}
if (items->first == NULL) {
if (items->first == nullptr) {
if (results->global_avg_w) {
*results->global_avg_w = 0.0f;
}
@@ -4227,16 +4305,9 @@ 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);
}
blender::Array<float, 64> avg_w(parameters->tot_columns, 0.0f);
blender::Array<float, 64> totweight_w(parameters->tot_columns, 0.0f);
blender::Array<int, 64> max_h(parameters->tot_rows, 0);
int i = 0;
LISTBASE_FOREACH (uiItem *, item, items) {
@@ -4287,7 +4358,7 @@ static void ui_litem_grid_flow_compute(ListBase *items,
}
/* Compute positions and sizes of all cells. */
if (results->cos_x_array != NULL && results->widths_array != NULL) {
if (results->cos_x_array != nullptr && results->widths_array != nullptr) {
/* We enlarge/narrow columns evenly to match available width. */
const float wfac = (float)(parameters->litem_w -
(parameters->tot_columns - 1) * parameters->space_x) /
@@ -4314,7 +4385,7 @@ static void ui_litem_grid_flow_compute(ListBase *items,
}
}
}
if (results->cos_y_array != NULL && results->heights_array != NULL) {
if (results->cos_y_array != nullptr && results->heights_array != nullptr) {
for (int row = 0; row < parameters->tot_rows; row++) {
if (parameters->even_rows) {
results->heights_array[row] = global_max_h;
@@ -4355,22 +4426,20 @@ 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 input{};
input.row_major = gflow->row_major;
input.even_columns = gflow->even_columns;
input.even_rows = gflow->even_rows;
input.litem_w = litem->w;
input.litem_x = litem->x;
input.litem_y = litem->y;
input.space_x = space_x;
input.space_y = space_y;
UILayoutGridFlowOutput output{};
output.tot_items = &gflow->tot_items;
output.global_avg_w = &avg_w;
output.global_max_h = &max_h;
ui_litem_grid_flow_compute(&litem->items, &input, &output);
if (gflow->tot_items == 0) {
litem->w = litem->h = 0;
@@ -4445,24 +4514,21 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
* we can compute actual needed space for non-evenly sized axes. */
{
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 input{};
input.row_major = gflow->row_major;
input.even_columns = gflow->even_columns;
input.even_rows = gflow->even_rows;
input.litem_w = litem->w;
input.litem_x = litem->x;
input.litem_y = litem->y;
input.space_x = space_x;
input.space_y = space_y;
input.tot_columns = gflow->tot_columns;
input.tot_rows = gflow->tot_rows;
UILayoutGridFlowOutput output{};
output.tot_w = &tot_w;
output.tot_h = &tot_h;
ui_litem_grid_flow_compute(&litem->items, &input, &output);
litem->w = tot_w;
litem->h = tot_h;
@@ -4485,31 +4551,29 @@ 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);
blender::Array<int, 64> widths(gflow->tot_columns);
blender::Array<int, 64> heights(gflow->tot_rows);
blender::Array<int, 64> cos_x(gflow->tot_columns);
blender::Array<int, 64> cos_y(gflow->tot_rows);
/* 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,
}));
UILayoutGridFlowInput input{};
input.row_major = gflow->row_major;
input.even_columns = gflow->even_columns;
input.even_rows = gflow->even_rows;
input.litem_w = litem->w;
input.litem_x = litem->x;
input.litem_y = litem->y;
input.space_x = space_x;
input.space_y = space_y;
input.tot_columns = gflow->tot_columns;
input.tot_rows = gflow->tot_rows;
UILayoutGridFlowOutput output{};
output.cos_x_array = cos_x.data();
output.cos_y_array = cos_y.data();
output.widths_array = widths.data();
output.heights_array = heights.data();
ui_litem_grid_flow_compute(&litem->items, &input, &output);
int i;
LISTBASE_FOREACH_INDEX (uiItem *, item, &litem->items, i) {
@@ -4643,7 +4707,7 @@ static void ui_litem_layout_split(uiLayout *litem)
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
int itemh;
ui_item_size(item, NULL, &itemh);
ui_item_size(item, nullptr, &itemh);
ui_item_position(item, x, y - itemh, colw, itemh);
x += colw;
@@ -4732,7 +4796,7 @@ static void ui_layout_heading_set(uiLayout *layout, const char *heading)
uiLayout *uiLayoutRow(uiLayout *layout, bool align)
{
uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRow");
uiLayout *litem = MEM_cnew<uiLayout>(__func__);
ui_litem_init_from_parent(litem, layout, align);
litem->item.type = ITEM_LAYOUT_ROW;
@@ -4752,7 +4816,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 = MEM_cnew<uiLayout>(__func__);
ui_litem_init_from_parent(litem, layout, align);
litem->item.type = ITEM_LAYOUT_COLUMN;
@@ -4772,7 +4836,7 @@ 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 = MEM_cnew<uiLayoutItemFlow>(__func__);
ui_litem_init_from_parent(&flow->litem, layout, align);
flow->litem.item.type = ITEM_LAYOUT_COLUMN_FLOW;
@@ -4791,7 +4855,7 @@ uiLayout *uiLayoutGridFlow(uiLayout *layout,
bool even_rows,
bool align)
{
uiLayoutItemGridFlow *flow = MEM_callocN(sizeof(uiLayoutItemGridFlow), __func__);
uiLayoutItemGridFlow *flow = MEM_cnew<uiLayoutItemGridFlow>(__func__);
flow->litem.item.type = ITEM_LAYOUT_GRID_FLOW;
ui_litem_init_from_parent(&flow->litem, layout, align);
@@ -4808,7 +4872,7 @@ uiLayout *uiLayoutGridFlow(uiLayout *layout,
static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type)
{
uiLayoutItemBx *box = MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx");
uiLayoutItemBx *box = MEM_cnew<uiLayoutItemBx>(__func__);
ui_litem_init_from_parent(&box->litem, layout, false);
box->litem.item.type = ITEM_LAYOUT_BOX;
@@ -4816,7 +4880,8 @@ static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type)
UI_block_layout_set_current(layout->root->block, &box->litem);
box->roundbox = uiDefBut(layout->root->block, type, 0, "", 0, 0, 0, 0, NULL, 0.0, 0.0, 0, 0, "");
box->roundbox = uiDefBut(
layout->root->block, type, 0, "", 0, 0, 0, 0, nullptr, 0.0, 0.0, 0, 0, "");
return box;
}
@@ -4837,7 +4902,7 @@ uiLayout *uiLayoutRadial(uiLayout *layout)
}
}
uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRadial");
uiLayout *litem = MEM_cnew<uiLayout>(__func__);
ui_litem_init_from_parent(litem, layout, false);
litem->item.type = ITEM_LAYOUT_RADIAL;
@@ -4887,7 +4952,7 @@ uiLayout *uiLayoutListBox(uiLayout *layout,
uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align)
{
uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutAbsolute");
uiLayout *litem = MEM_cnew<uiLayout>(__func__);
ui_litem_init_from_parent(litem, layout, align);
litem->item.type = ITEM_LAYOUT_ABSOLUTE;
@@ -4907,7 +4972,7 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout)
uiLayout *uiLayoutOverlap(uiLayout *layout)
{
uiLayout *litem = MEM_callocN(sizeof(uiLayout), "uiLayoutOverlap");
uiLayout *litem = MEM_cnew<uiLayout>(__func__);
ui_litem_init_from_parent(litem, layout, false);
litem->item.type = ITEM_LAYOUT_OVERLAP;
@@ -4919,7 +4984,7 @@ uiLayout *uiLayoutOverlap(uiLayout *layout)
uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, bool align)
{
uiLayoutItemSplit *split = MEM_callocN(sizeof(uiLayoutItemSplit), "uiLayoutItemSplit");
uiLayoutItemSplit *split = MEM_cnew<uiLayoutItemSplit>(__func__);
ui_litem_init_from_parent(&split->litem, layout, align);
split->litem.item.type = ITEM_LAYOUT_SPLIT;
@@ -5090,7 +5155,7 @@ eUIEmbossType uiLayoutGetEmboss(uiLayout *layout)
static bool block_search_panel_label_matches(const uiBlock *block, const char *search_string)
{
if ((block->panel != NULL) && (block->panel->type != NULL)) {
if ((block->panel != nullptr) && (block->panel->type != nullptr)) {
if (BLI_strcasestr(block->panel->type->label, search_string)) {
return true;
}
@@ -5108,13 +5173,13 @@ static bool button_matches_search_filter(uiBut *but, const char *search_filter)
return true;
}
if (but->optype != NULL) {
if (but->optype != nullptr) {
if (BLI_strcasestr(but->optype->name, search_filter)) {
return true;
}
}
if (but->rnaprop != NULL) {
if (but->rnaprop != nullptr) {
if (BLI_strcasestr(RNA_property_ui_name(but->rnaprop), search_filter)) {
return true;
}
@@ -5132,17 +5197,17 @@ static bool button_matches_search_filter(uiBut *but, const char *search_filter)
PropertyRNA *enum_prop = but->rnaprop;
int items_len;
const EnumPropertyItem *items_array = NULL;
const EnumPropertyItem *items_array = nullptr;
bool free;
RNA_property_enum_items_gettexted(NULL, ptr, enum_prop, &items_array, &items_len, &free);
RNA_property_enum_items_gettexted(nullptr, ptr, enum_prop, &items_array, &items_len, &free);
if (items_array == NULL) {
if (items_array == nullptr) {
return false;
}
for (int i = 0; i < items_len; i++) {
/* Check for NULL name field which enums use for separators. */
if (items_array[i].name == NULL) {
/* Check for nullptr name field which enums use for separators. */
if (items_array[i].name == nullptr) {
continue;
}
if (BLI_strcasestr(items_array[i].name, search_filter)) {
@@ -5164,7 +5229,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 = static_cast<uiBut *>(link->data);
if (button_matches_search_filter(but, search_filter)) {
return true;
}
@@ -5191,7 +5256,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 = static_cast<uiBut *>(link->data);
but->flag |= UI_SEARCH_FILTER_NO_MATCH;
}
}
@@ -5201,15 +5266,15 @@ static bool block_search_filter_tag_buttons(uiBlock *block, const char *search_f
bool UI_block_apply_search_filter(uiBlock *block, const char *search_filter)
{
if (search_filter == NULL || search_filter[0] == '\0') {
if (search_filter == nullptr || search_filter[0] == '\0') {
return false;
}
Panel *panel = block->panel;
if (panel != NULL && panel->type->flag & PANEL_TYPE_NO_SEARCH) {
if (panel != nullptr && panel->type->flag & PANEL_TYPE_NO_SEARCH) {
/* Panels for active blocks should always have a type, otherwise they wouldn't be created. */
BLI_assert(block->panel->type != NULL);
BLI_assert(block->panel->type != nullptr);
if (panel->type->flag & PANEL_TYPE_NO_SEARCH) {
return false;
}
@@ -5221,7 +5286,7 @@ bool UI_block_apply_search_filter(uiBlock *block, const char *search_filter)
true :
block_search_filter_tag_buttons(block, search_filter);
if (panel != NULL) {
if (panel != nullptr) {
if (has_result) {
ui_panel_tag_search_filter_match(block->panel);
}
@@ -5461,7 +5526,7 @@ static void ui_layout_free(uiLayout *layout)
if (item->type == ITEM_BUTTON) {
uiButtonItem *bitem = (uiButtonItem *)item;
bitem->but->layout = NULL;
bitem->but->layout = nullptr;
MEM_freeN(item);
}
else {
@@ -5480,8 +5545,20 @@ static void ui_layout_add_padding_button(uiLayoutRoot *root)
uiLayout *prev_layout = block->curlayout;
block->curlayout = root->layout;
uiDefBut(
block, UI_BTYPE_SEPR, 0, "", 0, 0, root->padding, root->padding, NULL, 0.0, 0.0, 0, 0, "");
uiDefBut(block,
UI_BTYPE_SEPR,
0,
"",
0,
0,
root->padding,
root->padding,
nullptr,
0.0,
0.0,
0,
0,
"");
block->curlayout = prev_layout;
}
}
@@ -5496,14 +5573,14 @@ uiLayout *UI_block_layout(uiBlock *block,
int padding,
const uiStyle *style)
{
uiLayoutRoot *root = MEM_callocN(sizeof(uiLayoutRoot), "uiLayoutRoot");
uiLayoutRoot *root = MEM_cnew<uiLayoutRoot>(__func__);
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 = MEM_cnew<uiLayout>(__func__);
layout->item.type = (type == UI_LAYOUT_VERT_BAR) ? ITEM_LAYOUT_COLUMN : ITEM_LAYOUT_ROOT;
/* Only used when 'UI_ITEM_PROP_SEP' is set. */
@@ -5515,7 +5592,7 @@ uiLayout *UI_block_layout(uiBlock *block,
layout->space = style->templatespace;
layout->active = true;
layout->enabled = true;
layout->context = NULL;
layout->context = nullptr;
layout->emboss = UI_EMBOSS_UNDEFINED;
if (ELEM(type, UI_LAYOUT_MENU, UI_LAYOUT_PIEMENU)) {
@@ -5557,7 +5634,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 = MEM_cnew<uiButtonItem>(__func__);
bitem->item.type = ITEM_BUTTON;
bitem->but = but;
@@ -5610,7 +5687,7 @@ static uiButtonItem *ui_layout_find_button_item(const uiLayout *layout, const ui
}
}
return NULL;
return nullptr;
}
void ui_layout_remove_but(uiLayout *layout, const uiBut *but)
@@ -5625,7 +5702,8 @@ void ui_layout_remove_but(uiLayout *layout, const uiBut *but)
bool ui_layout_replace_but_ptr(uiLayout *layout, const void *old_but_ptr, uiBut *new_but)
{
uiButtonItem *bitem = ui_layout_find_button_item(layout, old_but_ptr);
uiButtonItem *bitem = ui_layout_find_button_item(layout,
static_cast<const uiBut *>(old_but_ptr));
if (!bitem) {
return false;
}
@@ -5679,12 +5757,12 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
*r_y = 0;
}
block->curlayout = NULL;
block->curlayout = nullptr;
LISTBASE_FOREACH_MUTABLE (uiLayoutRoot *, root, &block->layouts) {
ui_layout_add_padding_button(root);
/* NULL in advance so we don't interfere when adding button */
/* nullptr in advance so we don't interfere when adding button */
ui_layout_end(block, root->layout, r_x, r_y);
ui_layout_free(root->layout);
MEM_freeN(root);
@@ -5732,7 +5810,7 @@ void uiLayoutSetTooltipFunc(uiLayout *layout,
LISTBASE_FOREACH (uiItem *, item, &layout->items) {
/* Each button will call free_arg for "its" argument, so we need to
* duplicate the allocation for each button after the first. */
if (copy_arg != NULL && arg_used) {
if (copy_arg != nullptr && arg_used) {
arg = copy_arg(arg);
}
arg_used = true;
@@ -5764,7 +5842,7 @@ void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but)
if (but->rnapoin.data && but->rnaprop) {
/* TODO: index could be supported as well */
PointerRNA ptr_prop;
RNA_pointer_create(NULL, &RNA_Property, but->rnaprop, &ptr_prop);
RNA_pointer_create(nullptr, &RNA_Property, but->rnaprop, &ptr_prop);
uiLayoutSetContextPointer(layout, "button_prop", &ptr_prop);
uiLayoutSetContextPointer(layout, "button_pointer", &but->rnapoin);
}
@@ -5772,19 +5850,19 @@ void uiLayoutSetContextFromBut(uiLayout *layout, uiBut *but)
wmOperatorType *UI_but_operatortype_get_from_enum_menu(uiBut *but, PropertyRNA **r_prop)
{
if (r_prop != NULL) {
*r_prop = NULL;
if (r_prop != nullptr) {
*r_prop = nullptr;
}
if (but->menu_create_func == menu_item_enum_opname_menu) {
MenuItemLevel *lvl = but->func_argN;
MenuItemLevel *lvl = static_cast<MenuItemLevel *>(but->func_argN);
wmOperatorType *ot = WM_operatortype_find(lvl->opname, false);
if ((ot != NULL) && (r_prop != NULL)) {
if ((ot != nullptr) && (r_prop != nullptr)) {
*r_prop = RNA_struct_type_find_property(ot->srna, lvl->propname);
}
return ot;
}
return NULL;
return nullptr;
}
MenuType *UI_but_menutype_get(uiBut *but)
@@ -5792,7 +5870,7 @@ MenuType *UI_but_menutype_get(uiBut *but)
if (but->menu_create_func == ui_item_menutype_func) {
return (MenuType *)but->poin;
}
return NULL;
return nullptr;
}
PanelType *UI_but_paneltype_get(uiBut *but)
@@ -5800,15 +5878,14 @@ PanelType *UI_but_paneltype_get(uiBut *but)
if (but->menu_create_func == ui_item_paneltype_func) {
return (PanelType *)but->poin;
}
return NULL;
return nullptr;
}
void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout)
void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout)
{
Menu menu = {
.layout = layout,
.type = mt,
};
Menu menu{};
menu.layout = layout;
menu.type = mt;
if (G.debug & G_DEBUG_WM) {
printf("%s: opening menu \"%s\"\n", __func__, mt->idname);
@@ -5817,7 +5894,8 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout)
if (mt->listener) {
/* Forward the menu type listener to the block we're drawing in. */
uiBlock *block = uiLayoutGetBlock(layout);
uiBlockDynamicListener *listener = MEM_mallocN(sizeof(*listener), "uiBlockDynamicListener");
uiBlockDynamicListener *listener = static_cast<uiBlockDynamicListener *>(
MEM_mallocN(sizeof(*listener), __func__));
listener->listener_func = mt->listener;
BLI_addtail(&block->dynamic_listeners, listener);
}
@@ -5829,7 +5907,7 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout)
mt->draw(C, &menu);
if (layout->context) {
CTX_store_set(C, NULL);
CTX_store_set(C, nullptr);
}
}
@@ -5855,11 +5933,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 = MEM_cnew<Panel>(__func__);
panel->type = pt;
panel->flag = PNL_POPOVER;
uiLayout *last_item = layout->items.last;
uiLayout *last_item = static_cast<uiLayout *>(layout->items.last);
/* Draw main panel. */
if (show_header) {
@@ -5867,7 +5945,7 @@ static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout,
if (pt->draw_header) {
panel->layout = row;
pt->draw_header(C, panel);
panel->layout = NULL;
panel->layout = nullptr;
}
/* draw_header() is often used to add a checkbox to the header. If we add the label like below
@@ -5880,20 +5958,20 @@ static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout,
panel->layout = layout;
pt->draw(C, panel);
panel->layout = NULL;
BLI_assert(panel->runtime.custom_data_ptr == NULL);
panel->layout = nullptr;
BLI_assert(panel->runtime.custom_data_ptr == nullptr);
MEM_freeN(panel);
/* Draw child panels. */
LISTBASE_FOREACH (LinkData *, link, &pt->children) {
PanelType *child_pt = link->data;
PanelType *child_pt = static_cast<PanelType *>(link->data);
if (child_pt->poll == NULL || child_pt->poll(C, child_pt)) {
if (child_pt->poll == nullptr || 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;
uiItemS(static_cast<uiLayout *>(layout));
last_item = static_cast<uiLayout *>(layout->items.last);
}
uiLayout *col = uiLayoutColumn(layout, false);
@@ -5911,7 +5989,7 @@ void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout)
ui_paneltype_draw_impl(C, pt, layout, false);
if (layout->context) {
CTX_store_set(C, NULL);
CTX_store_set(C, nullptr);
}
}
@@ -5937,17 +6015,22 @@ static void ui_layout_introspect_button(DynStr *ds, uiButtonItem *bitem)
BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : "");
if (but->optype) {
char *opstr = WM_operator_pystring_ex(
but->block->evil_C, NULL, false, true, but->optype, but->opptr);
char *opstr = WM_operator_pystring_ex(static_cast<bContext *>(but->block->evil_C),
nullptr,
false,
true,
but->optype,
but->opptr);
BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : "");
MEM_freeN(opstr);
}
{
PropertyRNA *prop = NULL;
PropertyRNA *prop = nullptr;
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(
static_cast<bContext *>(but->block->evil_C), nullptr, false, true, ot, nullptr);
BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : "");
BLI_dynstr_appendf(ds, "'property':'''%s''', ", prop ? RNA_property_identifier(prop) : "");
MEM_freeN(opstr);
@@ -5969,7 +6052,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 = static_cast<uiItem *>(lb->first); item; item = item->next) {
BLI_dynstr_append(ds, "{");
@@ -6026,8 +6109,8 @@ const char *UI_layout_introspect(uiLayout *layout)
{
DynStr *ds = BLI_dynstr_new();
uiLayout layout_copy = *layout;
layout_copy.item.next = NULL;
layout_copy.item.prev = NULL;
layout_copy.item.next = nullptr;
layout_copy.item.prev = nullptr;
ListBase layout_dummy_list = {&layout_copy, &layout_copy};
ui_layout_introspect_items(ds, &layout_dummy_list);
const char *result = BLI_dynstr_get_cstring(ds);

View File

@@ -4,10 +4,10 @@
* \ingroup edinterface
*/
#include <ctype.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <cctype>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
@@ -158,7 +158,9 @@ static void template_add_button_search_menu(const bContext *C,
const bool live_icon)
{
const PointerRNA active_ptr = RNA_property_pointer_get(ptr, prop);
ID *id = (active_ptr.data && RNA_struct_is_ID(active_ptr.type)) ? active_ptr.data : NULL;
ID *id = (active_ptr.data && RNA_struct_is_ID(active_ptr.type)) ?
static_cast<ID *>(active_ptr.data) :
nullptr;
const ID *idfrom = ptr->owner_id;
const StructRNA *type = active_ptr.type ? active_ptr.type : RNA_property_pointer_type(ptr, prop);
uiBut *but;
@@ -172,7 +174,7 @@ static void template_add_button_search_menu(const bContext *C,
const bool use_preview_icon = use_big_size || (id && (GS(id->name) != ID_SCR));
const short width = UI_UNIT_X * (use_big_size ? 6 : 1.6f);
const short height = UI_UNIT_Y * (use_big_size ? 6 : 1);
uiLayout *col = NULL;
uiLayout *col = nullptr;
if (use_big_size) {
/* Assume column layout here. To be more correct, we should check if the layout passed to
@@ -247,7 +249,7 @@ static uiBlock *template_common_search_menu(const bContext *C,
const int h = 5 * U.widget_unit * preview_rows * scale;
/* fake button, it holds space for search items */
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, NULL, 0, 0, 0, 0, NULL);
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, nullptr, 0, 0, 0, 0, nullptr);
but = uiDefSearchBut(block,
search,
@@ -276,12 +278,12 @@ static uiBlock *template_common_search_menu(const bContext *C,
15,
searchbox_width,
searchbox_height,
NULL,
nullptr,
0,
0,
0,
0,
NULL);
nullptr);
but = uiDefSearchBut(block,
search,
0,
@@ -300,7 +302,7 @@ static uiBlock *template_common_search_menu(const bContext *C,
search_update_fn,
search_arg,
false,
NULL,
nullptr,
search_exec_fn,
active_item);
UI_but_func_search_set_tooltip(but, item_tooltip_fn);
@@ -322,7 +324,7 @@ static uiBlock *template_common_search_menu(const bContext *C,
/** \name Search Callbacks
* \{ */
typedef struct TemplateID {
struct TemplateID {
PointerRNA ptr;
PropertyRNA *prop;
@@ -332,7 +334,7 @@ typedef struct TemplateID {
int prv_rows, prv_cols;
bool preview;
float scale;
} TemplateID;
};
/* Search browse menu, assign. */
static void template_ID_set_property_exec_fn(bContext *C, void *arg_template, void *item)
@@ -343,8 +345,8 @@ static void template_ID_set_property_exec_fn(bContext *C, void *arg_template, vo
if (item) {
PointerRNA idptr;
RNA_id_pointer_create(item, &idptr);
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL);
RNA_id_pointer_create(static_cast<ID *>(item), &idptr);
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, nullptr);
RNA_property_update(C, &template_ui->ptr, template_ui->prop);
}
}
@@ -412,7 +414,7 @@ static void id_search_cb(const bContext *C,
void *arg_template,
const char *str,
uiSearchItems *items,
const bool UNUSED(is_first))
const bool /*is_first*/)
{
TemplateID *template_ui = (TemplateID *)arg_template;
ListBase *lb = template_ui->idlb;
@@ -484,11 +486,11 @@ static void id_search_cb_objects_from_scene(const bContext *C,
void *arg_template,
const char *str,
uiSearchItems *items,
const bool UNUSED(is_first))
const bool /*is_first*/)
{
TemplateID *template_ui = (TemplateID *)arg_template;
ListBase *lb = template_ui->idlb;
Scene *scene = NULL;
Scene *scene = nullptr;
ID *id_from = template_ui->ptr.owner_id;
if (id_from && GS(id_from->name) == ID_SCE) {
@@ -510,8 +512,8 @@ static void id_search_cb_objects_from_scene(const bContext *C,
static ARegion *template_ID_search_menu_item_tooltip(
bContext *C, ARegion *region, const rcti *item_rect, void *arg, void *active)
{
TemplateID *template_ui = arg;
ID *active_id = active;
TemplateID *template_ui = static_cast<TemplateID *>(arg);
ID *active_id = static_cast<ID *>(active);
StructRNA *type = RNA_property_pointer_type(&template_ui->ptr, template_ui->prop);
uiSearchItemTooltipData tooltip_data = {0};
@@ -583,10 +585,10 @@ void UI_context_active_but_prop_get_templateID(bContext *C,
uiBut *but = UI_context_active_but_get(C);
memset(r_ptr, 0, sizeof(*r_ptr));
*r_prop = NULL;
*r_prop = nullptr;
if (but && (but->funcN == template_id_cb) && but->func_argN) {
TemplateID *template_ui = but->func_argN;
TemplateID *template_ui = static_cast<TemplateID *>(but->func_argN);
*r_ptr = template_ui->ptr;
*r_prop = template_ui->prop;
}
@@ -607,7 +609,9 @@ static void template_id_liboverride_hierarchy_collection_root_find_recursive(
*r_collection_parent_best = collection;
}
}
for (CollectionParent *iter = collection->parents.first; iter != NULL; iter = iter->next) {
for (CollectionParent *iter = static_cast<CollectionParent *>(collection->parents.first);
iter != nullptr;
iter = iter->next) {
if (iter->collection->id.lib != collection->id.lib && ID_IS_LINKED(iter->collection)) {
continue;
}
@@ -624,7 +628,8 @@ static void template_id_liboverride_hierarchy_collections_tag_recursive(
/* Tag all local parents of the root collection, so that usages of the root collection and other
* linked ones can be replaced by the local overrides in those parents too. */
if (do_parents) {
for (CollectionParent *iter = root_collection->parents.first; iter != NULL;
for (CollectionParent *iter = static_cast<CollectionParent *>(root_collection->parents.first);
iter != nullptr;
iter = iter->next) {
if (ID_IS_LINKED(iter->collection)) {
continue;
@@ -633,7 +638,9 @@ static void template_id_liboverride_hierarchy_collections_tag_recursive(
}
}
for (CollectionChild *iter = root_collection->children.first; iter != NULL; iter = iter->next) {
for (CollectionChild *iter = static_cast<CollectionChild *>(root_collection->children.first);
iter != nullptr;
iter = iter->next) {
if (iter->collection->id.lib != root_collection->id.lib && ID_IS_LINKED(root_collection)) {
continue;
}
@@ -657,7 +664,7 @@ ID *ui_template_id_liboverride_hierarchy_make(
bContext *C, Main *bmain, ID *owner_id, ID *id, const char **r_undo_push_label)
{
const char *undo_push_label;
if (r_undo_push_label == NULL) {
if (r_undo_push_label == nullptr) {
r_undo_push_label = &undo_push_label;
}
@@ -665,7 +672,7 @@ ID *ui_template_id_liboverride_hierarchy_make(
* system override with reset. */
if (!ID_IS_LINKED(id) && ID_IS_OVERRIDE_LIBRARY(id)) {
if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
BKE_lib_override_library_get(bmain, id, NULL, &id);
BKE_lib_override_library_get(bmain, id, nullptr, &id);
}
if (id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) {
id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED;
@@ -676,9 +683,9 @@ ID *ui_template_id_liboverride_hierarchy_make(
*r_undo_push_label = "Clear Library Override Hierarchy";
}
WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL);
WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, nullptr);
WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, nullptr);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, nullptr);
return id;
}
@@ -687,43 +694,43 @@ ID *ui_template_id_liboverride_hierarchy_make(
* context, better to abort than create random overrides all over the place. */
if (!ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(id)) {
WM_reportf(RPT_ERROR, "The data-block %s is not overridable", id->name);
return NULL;
return nullptr;
}
Object *object_active = CTX_data_active_object(C);
if (object_active == NULL && GS(owner_id->name) == ID_OB) {
if (object_active == nullptr && GS(owner_id->name) == ID_OB) {
object_active = (Object *)owner_id;
}
if (object_active != NULL) {
if (object_active != nullptr) {
if (ID_IS_LINKED(object_active)) {
if (object_active->id.lib != id->lib ||
!ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(object_active)) {
/* The active object is from a different library than the overridden ID, or otherwise
* cannot be used in hierarchy. */
object_active = NULL;
object_active = nullptr;
}
}
else if (!ID_IS_OVERRIDE_LIBRARY_REAL(object_active)) {
/* Fully local object cannot be used in override hierarchy either. */
object_active = NULL;
object_active = nullptr;
}
}
Collection *collection_active = CTX_data_collection(C);
if (collection_active == NULL && GS(owner_id->name) == ID_GR) {
if (collection_active == nullptr && GS(owner_id->name) == ID_GR) {
collection_active = (Collection *)owner_id;
}
if (collection_active != NULL) {
if (collection_active != nullptr) {
if (ID_IS_LINKED(collection_active)) {
if (collection_active->id.lib != id->lib ||
!ID_IS_OVERRIDABLE_LIBRARY_HIERARCHY(collection_active)) {
/* The active collection is from a different library than the overridden ID, or otherwise
* cannot be used in hierarchy. */
collection_active = NULL;
collection_active = nullptr;
}
else {
int parent_level_best = -1;
Collection *collection_parent_best = NULL;
Collection *collection_parent_best = nullptr;
template_id_liboverride_hierarchy_collection_root_find_recursive(
collection_active, 0, &collection_parent_best, &parent_level_best);
collection_active = collection_parent_best;
@@ -731,10 +738,10 @@ ID *ui_template_id_liboverride_hierarchy_make(
}
else if (!ID_IS_OVERRIDE_LIBRARY_REAL(collection_active)) {
/* Fully local collection cannot be used in override hierarchy either. */
collection_active = NULL;
collection_active = nullptr;
}
}
if (collection_active == NULL && object_active != NULL &&
if (collection_active == nullptr && object_active != nullptr &&
(ID_IS_LINKED(object_active) || ID_IS_OVERRIDE_LIBRARY_REAL(object_active))) {
/* If we failed to find a valid 'active' collection so far for our override hierarchy, but do
* have a valid 'active' object, try to find a collection from that object. */
@@ -746,7 +753,7 @@ ID *ui_template_id_liboverride_hierarchy_make(
continue;
}
int parent_level_best = -1;
Collection *collection_parent_best = NULL;
Collection *collection_parent_best = nullptr;
template_id_liboverride_hierarchy_collection_root_find_recursive(
collection_iter, 0, &collection_parent_best, &parent_level_best);
collection_active = collection_parent_best;
@@ -754,21 +761,28 @@ ID *ui_template_id_liboverride_hierarchy_make(
}
}
ID *id_override = NULL;
ID *id_override = nullptr;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
switch (GS(id->name)) {
case ID_GR:
if (collection_active != NULL &&
if (collection_active != nullptr &&
BKE_collection_has_collection(collection_active, (Collection *)id)) {
template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true);
if (object_active != NULL) {
if (object_active != nullptr) {
object_active->id.tag |= LIB_TAG_DOIT;
}
BKE_lib_override_library_create(
bmain, scene, view_layer, NULL, id, &collection_active->id, NULL, &id_override, false);
BKE_lib_override_library_create(bmain,
scene,
view_layer,
nullptr,
id,
&collection_active->id,
nullptr,
&id_override,
false);
}
else if (object_active != NULL && !ID_IS_LINKED(object_active) &&
else if (object_active != nullptr && !ID_IS_LINKED(object_active) &&
&object_active->instance_collection->id == id) {
object_active->id.tag |= LIB_TAG_DOIT;
BKE_lib_override_library_create(bmain,
@@ -783,23 +797,30 @@ ID *ui_template_id_liboverride_hierarchy_make(
}
break;
case ID_OB:
if (collection_active != NULL &&
if (collection_active != nullptr &&
BKE_collection_has_object_recursive(collection_active, (Object *)id)) {
template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true);
if (object_active != NULL) {
if (object_active != nullptr) {
object_active->id.tag |= LIB_TAG_DOIT;
}
BKE_lib_override_library_create(
bmain, scene, view_layer, NULL, id, &collection_active->id, NULL, &id_override, false);
BKE_lib_override_library_create(bmain,
scene,
view_layer,
nullptr,
id,
&collection_active->id,
nullptr,
&id_override,
false);
}
else {
if (object_active != NULL) {
if (object_active != nullptr) {
object_active->id.tag |= LIB_TAG_DOIT;
}
BKE_lib_override_library_create(
bmain, scene, view_layer, NULL, id, NULL, NULL, &id_override, false);
bmain, scene, view_layer, nullptr, id, nullptr, nullptr, &id_override, false);
BKE_scene_collections_object_remove(bmain, scene, (Object *)id, true);
WM_event_add_notifier(C, NC_ID | NA_REMOVED, NULL);
WM_event_add_notifier(C, NC_ID | NA_REMOVED, nullptr);
}
break;
case ID_ME:
@@ -815,32 +836,39 @@ ID *ui_template_id_liboverride_hierarchy_make(
case ID_PT:
case ID_VO:
case ID_NT: /* Essentially geometry nodes from modifier currently. */
if (object_active != NULL) {
if (collection_active != NULL &&
if (object_active != nullptr) {
if (collection_active != nullptr &&
BKE_collection_has_object_recursive(collection_active, object_active)) {
template_id_liboverride_hierarchy_collections_tag_recursive(collection_active, id, true);
if (object_active != NULL) {
if (object_active != nullptr) {
object_active->id.tag |= LIB_TAG_DOIT;
}
BKE_lib_override_library_create(bmain,
scene,
view_layer,
NULL,
nullptr,
id,
&collection_active->id,
NULL,
nullptr,
&id_override,
false);
}
else {
object_active->id.tag |= LIB_TAG_DOIT;
BKE_lib_override_library_create(
bmain, scene, view_layer, NULL, id, &object_active->id, NULL, &id_override, false);
BKE_lib_override_library_create(bmain,
scene,
view_layer,
nullptr,
id,
&object_active->id,
nullptr,
&id_override,
false);
}
}
else {
BKE_lib_override_library_create(
bmain, scene, view_layer, NULL, id, id, NULL, &id_override, false);
bmain, scene, view_layer, nullptr, id, id, nullptr, &id_override, false);
}
break;
case ID_MA:
@@ -859,7 +887,7 @@ ID *ui_template_id_liboverride_hierarchy_make(
break;
}
if (id_override != NULL) {
if (id_override != nullptr) {
id_override->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED;
*r_undo_push_label = "Make Library Override Hierarchy";
@@ -871,8 +899,8 @@ ID *ui_template_id_liboverride_hierarchy_make(
* rebuild of outliner trees, leading to crashes.
*
* So for now, add some extra notifiers here. */
WM_event_add_notifier(C, NC_ID | NA_ADDED, NULL);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL);
WM_event_add_notifier(C, NC_ID | NA_ADDED, nullptr);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, nullptr);
}
return id_override;
}
@@ -883,13 +911,13 @@ static void template_id_liboverride_hierarchy_make(bContext *C,
PointerRNA *idptr,
const char **r_undo_push_label)
{
ID *id = idptr->data;
ID *id = static_cast<ID *>(idptr->data);
ID *owner_id = template_ui->ptr.owner_id;
ID *id_override = ui_template_id_liboverride_hierarchy_make(
C, bmain, owner_id, id, r_undo_push_label);
if (id_override != NULL) {
if (id_override != nullptr) {
/* `idptr` is re-assigned to owner property to ensure proper updates etc. Here we also use it
* to ensure remapping of the owner property from the linked data to the newly created
* liboverride (note that in theory this remapping has already been done by code above), but
@@ -910,9 +938,9 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
{
TemplateID *template_ui = (TemplateID *)arg_litem;
PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
ID *id = idptr.data;
ID *id = static_cast<ID *>(idptr.data);
const int event = POINTER_AS_INT(arg_event);
const char *undo_push_label = NULL;
const char *undo_push_label = nullptr;
switch (event) {
case UI_ID_NOP:
@@ -930,7 +958,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
break;
case UI_ID_DELETE:
memset(&idptr, 0, sizeof(idptr));
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL);
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, nullptr);
RNA_property_update(C, &template_ui->ptr, template_ui->prop);
if (id && CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) {
@@ -971,8 +999,8 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
undo_push_label = "Make Local";
}
}
if (undo_push_label != NULL) {
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL);
if (undo_push_label != nullptr) {
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, nullptr);
RNA_property_update(C, &template_ui->ptr, template_ui->prop);
}
}
@@ -987,7 +1015,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
BKE_lib_override_library_make_local(id);
/* Reassign to get proper updates/notifiers. */
idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL);
RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, nullptr);
RNA_property_update(C, &template_ui->ptr, template_ui->prop);
undo_push_label = "Make Local";
}
@@ -1002,8 +1030,8 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
if (do_scene_obj) {
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ED_object_single_user(bmain, scene, (struct Object *)id);
WM_event_add_notifier(C, NC_WINDOW, NULL);
ED_object_single_user(bmain, scene, (Object *)id);
WM_event_add_notifier(C, NC_WINDOW, nullptr);
DEG_relations_tag_update(bmain);
}
else {
@@ -1020,7 +1048,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
#endif
}
if (undo_push_label != NULL) {
if (undo_push_label != nullptr) {
ED_undo_push(C, undo_push_label);
}
}
@@ -1122,7 +1150,7 @@ static void template_id_workspace_pin_extra_icon(const TemplateID *template_ui,
return;
}
const wmWindow *win = template_ui->ptr.data;
const wmWindow *win = static_cast<const wmWindow *>(template_ui->ptr.data);
const WorkSpace *workspace = WM_window_get_active_workspace(win);
UI_but_extra_operator_icon_add(but,
"WORKSPACE_OT_scene_pin_toggle",
@@ -1210,7 +1238,7 @@ static uiBut *template_id_def_new_but(uiBlock *block,
0,
w,
but_height,
NULL);
nullptr);
UI_but_funcN_set(
but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW));
}
@@ -1224,12 +1252,12 @@ static uiBut *template_id_def_new_but(uiBlock *block,
0,
w,
but_height,
NULL,
nullptr,
0,
0,
0,
0,
NULL);
nullptr);
UI_but_funcN_set(
but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW));
}
@@ -1262,7 +1290,7 @@ static void template_ID(const bContext *C,
const bool use_previews = template_ui->preview = (flag & UI_ID_PREVIEWS) != 0;
PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
ID *id = idptr.data;
ID *id = static_cast<ID *>(idptr.data);
ID *idfrom = template_ui->ptr.owner_id;
// lb = template_ui->idlb;
@@ -1341,7 +1369,7 @@ static void template_ID(const bContext *C,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0,
0,
0,
@@ -1358,7 +1386,7 @@ static void template_ID(const bContext *C,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0,
0,
0,
@@ -1384,7 +1412,7 @@ static void template_ID(const bContext *C,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0,
0,
0,
@@ -1410,7 +1438,7 @@ static void template_ID(const bContext *C,
0,
numstr_len * 0.2f * UI_UNIT_X + UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0,
0,
0,
@@ -1445,7 +1473,7 @@ static void template_ID(const bContext *C,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL);
nullptr);
}
else if (!ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS) &&
(hide_buttons == false)) {
@@ -1464,7 +1492,7 @@ static void template_ID(const bContext *C,
0,
-1,
-1,
NULL);
nullptr);
}
}
}
@@ -1506,7 +1534,7 @@ static void template_ID(const bContext *C,
0,
w,
UI_UNIT_Y,
NULL);
nullptr);
UI_but_funcN_set(
but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN));
}
@@ -1520,12 +1548,12 @@ static void template_ID(const bContext *C,
0,
w,
UI_UNIT_Y,
NULL,
nullptr,
0,
0,
0,
0,
NULL);
nullptr);
UI_but_funcN_set(
but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN));
}
@@ -1539,7 +1567,7 @@ static void template_ID(const bContext *C,
/* don't use RNA_property_is_unlink here */
if (id && (flag & UI_ID_DELETE) && (hide_buttons == false)) {
/* allow unlink if 'unlinkop' is passed, even when 'PROP_NEVER_UNLINK' is set */
but = NULL;
but = nullptr;
if (unlinkop) {
but = uiDefIconButO(block,
@@ -1551,7 +1579,7 @@ static void template_ID(const bContext *C,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL);
nullptr);
/* so we can access the template from operators, font unlinking needs this */
UI_but_funcN_set(
but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_NOP));
@@ -1567,7 +1595,7 @@ static void template_ID(const bContext *C,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0,
0,
0,
@@ -1601,22 +1629,22 @@ ID *UI_context_active_but_get_tab_ID(bContext *C)
uiBut *but = UI_context_active_but_get(C);
if (but && but->type == UI_BTYPE_TAB) {
return but->custom_data;
return static_cast<ID *>(but->custom_data);
}
return NULL;
return nullptr;
}
static void template_ID_tabs(const bContext *C,
uiLayout *layout,
TemplateID *template,
TemplateID *template_id,
StructRNA *type,
int flag,
const char *newop,
const char *menu)
{
const ARegion *region = CTX_wm_region(C);
const PointerRNA active_ptr = RNA_property_pointer_get(&template->ptr, template->prop);
MenuType *mt = menu ? WM_menutype_find(menu, false) : NULL;
const PointerRNA active_ptr = RNA_property_pointer_get(&template_id->ptr, template_id->prop);
MenuType *mt = menu ? WM_menutype_find(menu, false) : nullptr;
const int but_align = ui_but_align_opposite_to_area_align_get(region);
const int but_height = UI_UNIT_Y * 1.1;
@@ -1625,10 +1653,10 @@ static void template_ID_tabs(const bContext *C,
const uiStyle *style = UI_style_get_dpi();
ListBase ordered;
BKE_id_ordered_list(&ordered, template->idlb);
BKE_id_ordered_list(&ordered, template_id->idlb);
LISTBASE_FOREACH (LinkData *, link, &ordered) {
ID *id = link->data;
ID *id = static_cast<ID *>(link->data);
const int name_width = UI_fontstyle_string_width(&style->widget, id->name + 2);
const int but_width = name_width + UI_UNIT_X;
@@ -1640,15 +1668,15 @@ static void template_ID_tabs(const bContext *C,
0,
but_width,
but_height,
&template->ptr,
template->prop,
&template_id->ptr,
template_id->prop,
0,
0.0f,
sizeof(id->name) - 2,
0.0f,
0.0f,
"");
UI_but_funcN_set(&tab->but, template_ID_set_property_exec_fn, MEM_dupallocN(template), id);
UI_but_funcN_set(&tab->but, template_ID_set_property_exec_fn, MEM_dupallocN(template_id), id);
UI_but_drag_set_id(&tab->but, id);
tab->but.custom_data = (void *)id;
tab->menu = mt;
@@ -1659,7 +1687,7 @@ static void template_ID_tabs(const bContext *C,
BLI_freelistN(&ordered);
if (flag & UI_ID_ADD_NEW) {
const bool editable = RNA_property_editable(&template->ptr, template->prop);
const bool editable = RNA_property_editable(&template_id->ptr, template_id->prop);
uiBut *but;
if (active_ptr.type) {
@@ -1667,8 +1695,8 @@ static void template_ID_tabs(const bContext *C,
}
but = template_id_def_new_but(block,
active_ptr.data,
template,
static_cast<const ID *>(active_ptr.data),
template_id,
type,
newop,
editable,
@@ -1705,7 +1733,7 @@ static void ui_template_id(uiLayout *layout,
return;
}
TemplateID *template_ui = MEM_callocN(sizeof(TemplateID), "TemplateID");
TemplateID *template_ui = MEM_cnew<TemplateID>(__func__);
template_ui->ptr = *ptr;
template_ui->prop = prop;
template_ui->prv_rows = prv_rows;
@@ -1776,7 +1804,7 @@ void uiTemplateID(uiLayout *layout,
newop,
openop,
unlinkop,
NULL,
nullptr,
text,
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
0,
@@ -1805,7 +1833,7 @@ void uiTemplateIDBrowse(uiLayout *layout,
newop,
openop,
unlinkop,
NULL,
nullptr,
text,
UI_ID_BROWSE | UI_ID_RENAME,
0,
@@ -1836,8 +1864,8 @@ void uiTemplateIDPreview(uiLayout *layout,
newop,
openop,
unlinkop,
NULL,
NULL,
nullptr,
nullptr,
UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS,
rows,
cols,
@@ -1861,11 +1889,11 @@ void uiTemplateGpencilColorPreview(uiLayout *layout,
C,
ptr,
propname,
NULL,
NULL,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
UI_ID_BROWSE | UI_ID_PREVIEWS | UI_ID_DELETE,
rows,
cols,
@@ -1889,10 +1917,10 @@ void uiTemplateIDTabs(uiLayout *layout,
ptr,
propname,
newop,
NULL,
NULL,
nullptr,
nullptr,
menu,
NULL,
nullptr,
UI_ID_BROWSE | UI_ID_RENAME,
0,
0,
@@ -1975,22 +2003,22 @@ void uiTemplateAnyID(uiLayout *layout,
/** \name Search Template
* \{ */
typedef struct TemplateSearch {
struct TemplateSearch {
uiRNACollectionSearch search_data;
bool use_previews;
int preview_rows, preview_cols;
} TemplateSearch;
};
static void template_search_exec_fn(bContext *C, void *arg_template, void *item)
{
TemplateSearch *template_search = arg_template;
TemplateSearch *template_search = static_cast<TemplateSearch *>(arg_template);
uiRNACollectionSearch *coll_search = &template_search->search_data;
StructRNA *type = RNA_property_pointer_type(&coll_search->target_ptr, coll_search->target_prop);
PointerRNA item_ptr;
RNA_pointer_create(NULL, type, item, &item_ptr);
RNA_property_pointer_set(&coll_search->target_ptr, coll_search->target_prop, item_ptr, NULL);
RNA_pointer_create(nullptr, type, item, &item_ptr);
RNA_property_pointer_set(&coll_search->target_ptr, coll_search->target_prop, item_ptr, nullptr);
RNA_property_update(C, &coll_search->target_ptr, coll_search->target_prop);
}
@@ -2009,7 +2037,7 @@ static uiBlock *template_search_menu(bContext *C, ARegion *region, void *arg_tem
&template_search,
template_search_exec_fn,
active_ptr.data,
NULL,
nullptr,
template_search.preview_rows,
template_search.preview_cols,
1.0f);
@@ -2059,7 +2087,7 @@ static void template_search_add_button_operator(uiBlock *block,
}
uiBut *but = uiDefIconButO(
block, UI_BTYPE_BUT, operator_name, opcontext, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
block, UI_BTYPE_BUT, operator_name, opcontext, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, nullptr);
if (!editable) {
UI_but_drawflag_enable(but, UI_BUT_DISABLED);
@@ -2104,11 +2132,11 @@ static PropertyRNA *template_search_get_searchprop(PointerRNA *targetptr,
PropertyRNA *searchprop;
if (searchptr && !searchptr->data) {
searchptr = NULL;
searchptr = nullptr;
}
if (!searchptr && !searchpropname) {
/* both NULL means we don't use a custom rna collection to search in */
/* both nullptr means we don't use a custom rna collection to search in */
}
else if (!searchptr && searchpropname) {
RNA_warning("searchpropname defined (%s) but searchptr is missing", searchpropname);
@@ -2139,7 +2167,7 @@ static PropertyRNA *template_search_get_searchprop(PointerRNA *targetptr,
return searchprop;
}
return NULL;
return nullptr;
}
static TemplateSearch *template_search_setup(PointerRNA *ptr,
@@ -2151,11 +2179,11 @@ static TemplateSearch *template_search_setup(PointerRNA *ptr,
if (!prop || RNA_property_type(prop) != PROP_POINTER) {
RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return NULL;
return nullptr;
}
PropertyRNA *searchprop = template_search_get_searchprop(ptr, prop, searchptr, searchpropname);
TemplateSearch *template_search = MEM_callocN(sizeof(*template_search), __func__);
TemplateSearch *template_search = MEM_cnew<TemplateSearch>(__func__);
template_search->search_data.target_ptr = *ptr;
template_search->search_data.target_prop = prop;
template_search->search_data.search_ptr = *searchptr;
@@ -2175,7 +2203,7 @@ void uiTemplateSearch(uiLayout *layout,
{
TemplateSearch *template_search = template_search_setup(
ptr, propname, searchptr, searchpropname);
if (template_search != NULL) {
if (template_search != nullptr) {
template_search_buttons(C, layout, template_search, newop, unlinkop);
MEM_freeN(template_search);
}
@@ -2195,7 +2223,7 @@ void uiTemplateSearchPreview(uiLayout *layout,
TemplateSearch *template_search = template_search_setup(
ptr, propname, searchptr, searchpropname);
if (template_search != NULL) {
if (template_search != nullptr) {
template_search->use_previews = true;
template_search->preview_rows = rows;
template_search->preview_cols = cols;
@@ -2217,7 +2245,7 @@ void uiTemplateSearchPreview(uiLayout *layout,
void uiTemplatePathBuilder(uiLayout *layout,
PointerRNA *ptr,
const char *propname,
PointerRNA *UNUSED(root_ptr),
PointerRNA * /*root_ptr*/,
const char *text)
{
/* check that properties are valid */
@@ -2248,10 +2276,10 @@ void uiTemplatePathBuilder(uiLayout *layout,
static void modifier_panel_id(void *md_link, char *r_name)
{
ModifierData *md = (ModifierData *)md_link;
BKE_modifier_type_panel_id(md->type, r_name);
BKE_modifier_type_panel_id(ModifierType(md->type), r_name);
}
void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
void uiTemplateModifiers(uiLayout * /*layout*/, bContext *C)
{
ARegion *region = CTX_wm_region(C);
@@ -2262,10 +2290,10 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
if (!panels_match) {
UI_panels_free_instanced(C, region);
ModifierData *md = modifiers->first;
ModifierData *md = static_cast<ModifierData *>(modifiers->first);
for (int i = 0; md; i++, md = md->next) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
if (mti->panelRegister == NULL) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
if (mti->panelRegister == nullptr) {
continue;
}
@@ -2273,7 +2301,7 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
modifier_panel_id(md, panel_idname);
/* Create custom data RNA pointer. */
PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
PointerRNA *md_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__));
RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr);
UI_panel_add_instanced(C, region, &region->panels, panel_idname, md_ptr);
@@ -2281,20 +2309,21 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C)
}
else {
/* Assuming there's only one group of instanced panels, update the custom data pointers. */
Panel *panel = region->panels.first;
Panel *panel = static_cast<Panel *>(region->panels.first);
LISTBASE_FOREACH (ModifierData *, md, modifiers) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
if (mti->panelRegister == NULL) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
if (mti->panelRegister == nullptr) {
continue;
}
/* Move to the next instanced panel corresponding to the next modifier. */
while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
panel = panel->next;
BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */
BLI_assert(panel !=
nullptr); /* There shouldn't be fewer panels than modifiers with UIs. */
}
PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
PointerRNA *md_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__));
RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr);
UI_panel_custom_data_set(panel, md_ptr);
@@ -2341,14 +2370,14 @@ static void constraint_reorder(bContext *C, Panel *panel, int new_index)
RNA_int_set(&props_ptr, "index", new_index);
/* Set owner to #EDIT_CONSTRAINT_OWNER_OBJECT or #EDIT_CONSTRAINT_OWNER_BONE. */
RNA_enum_set(&props_ptr, "owner", constraint_from_bone ? 1 : 0);
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, NULL);
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr, nullptr);
WM_operator_properties_free(&props_ptr);
}
/**
* Get the expand flag from the active constraint to use for the panel.
*/
static short get_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel)
static short get_constraint_expand_flag(const bContext * /*C*/, Panel *panel)
{
PointerRNA *con_ptr = UI_panel_custom_data_get(panel);
bConstraint *con = (bConstraint *)con_ptr->data;
@@ -2359,7 +2388,7 @@ static short get_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel)
/**
* Save the expand flag for the panel and sub-panels to the constraint.
*/
static void set_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel, short expand_flag)
static void set_constraint_expand_flag(const bContext * /*C*/, Panel *panel, short expand_flag)
{
PointerRNA *con_ptr = UI_panel_custom_data_get(panel);
bConstraint *con = (bConstraint *)con_ptr->data;
@@ -2378,7 +2407,7 @@ static void object_constraint_panel_id(void *md_link, char *r_name)
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type);
/* Cannot get TypeInfo for invalid/legacy constraints. */
if (cti == NULL) {
if (cti == nullptr) {
return;
}
@@ -2392,7 +2421,7 @@ static void bone_constraint_panel_id(void *md_link, char *r_name)
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_from_type(con->type);
/* Cannot get TypeInfo for invalid/legacy constraints. */
if (cti == NULL) {
if (cti == nullptr) {
return;
}
@@ -2400,16 +2429,16 @@ static void bone_constraint_panel_id(void *md_link, char *r_name)
strcat(r_name, cti->structName);
}
void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_constraints)
void uiTemplateConstraints(uiLayout * /*layout*/, bContext *C, bool use_bone_constraints)
{
ARegion *region = CTX_wm_region(C);
Object *ob = ED_object_active_context(C);
ListBase *constraints = {NULL};
ListBase *constraints = {nullptr};
if (use_bone_constraints) {
constraints = ED_object_pose_constraint_list(C);
}
else if (ob != NULL) {
else if (ob != nullptr) {
constraints = &ob->constraints;
}
@@ -2421,7 +2450,8 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
if (!panels_match) {
UI_panels_free_instanced(C, region);
bConstraint *con = (constraints == NULL) ? NULL : constraints->first;
bConstraint *con = (constraints == nullptr) ? nullptr :
static_cast<bConstraint *>(constraints->first);
for (int i = 0; con; i++, con = con->next) {
/* Don't show invalid/legacy constraints. */
if (con->type == CONSTRAINT_TYPE_NULL) {
@@ -2429,7 +2459,7 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
}
/* Don't show temporary constraints (AutoIK and target-less IK constraints). */
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = con->data;
bKinematicConstraint *data = static_cast<bKinematicConstraint *>(con->data);
if (data->flag & CONSTRAINT_IK_TEMP) {
continue;
}
@@ -2439,7 +2469,7 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
panel_id_func(con, panel_idname);
/* Create custom data RNA pointer. */
PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
PointerRNA *con_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__));
RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr);
Panel *new_panel = UI_panel_add_instanced(C, region, &region->panels, panel_idname, con_ptr);
@@ -2454,7 +2484,7 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
}
else {
/* Assuming there's only one group of instanced panels, update the custom data pointers. */
Panel *panel = region->panels.first;
Panel *panel = static_cast<Panel *>(region->panels.first);
LISTBASE_FOREACH (bConstraint *, con, constraints) {
/* Don't show invalid/legacy constraints. */
if (con->type == CONSTRAINT_TYPE_NULL) {
@@ -2462,19 +2492,19 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
}
/* Don't show temporary constraints (AutoIK and target-less IK constraints). */
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
bKinematicConstraint *data = con->data;
bKinematicConstraint *data = static_cast<bKinematicConstraint *>(con->data);
if (data->flag & CONSTRAINT_IK_TEMP) {
continue;
}
}
/* Move to the next instanced panel corresponding to the next constraint. */
while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
panel = panel->next;
BLI_assert(panel != NULL); /* There shouldn't be fewer panels than constraint panels. */
BLI_assert(panel != nullptr); /* There shouldn't be fewer panels than constraint panels. */
}
PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "constraint panel customdata");
PointerRNA *con_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__));
RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr);
UI_panel_custom_data_set(panel, con_ptr);
@@ -2498,10 +2528,10 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
static void gpencil_modifier_panel_id(void *md_link, char *r_name)
{
ModifierData *md = (ModifierData *)md_link;
BKE_gpencil_modifierType_panel_id(md->type, r_name);
BKE_gpencil_modifierType_panel_id(GpencilModifierType(md->type), r_name);
}
void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
void uiTemplateGpencilModifiers(uiLayout * /*layout*/, bContext *C)
{
ARegion *region = CTX_wm_region(C);
Object *ob = ED_object_active_context(C);
@@ -2512,10 +2542,11 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
if (!panels_match) {
UI_panels_free_instanced(C, region);
GpencilModifierData *md = modifiers->first;
GpencilModifierData *md = static_cast<GpencilModifierData *>(modifiers->first);
for (int i = 0; md; i++, md = md->next) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
if (mti->panelRegister == NULL) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(
GpencilModifierType(md->type));
if (mti->panelRegister == nullptr) {
continue;
}
@@ -2523,7 +2554,7 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
gpencil_modifier_panel_id(md, panel_idname);
/* Create custom data RNA pointer. */
PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
PointerRNA *md_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__));
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr);
UI_panel_add_instanced(C, region, &region->panels, panel_idname, md_ptr);
@@ -2531,20 +2562,22 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
}
else {
/* Assuming there's only one group of instanced panels, update the custom data pointers. */
Panel *panel = region->panels.first;
Panel *panel = static_cast<Panel *>(region->panels.first);
LISTBASE_FOREACH (ModifierData *, md, modifiers) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type);
if (mti->panelRegister == NULL) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(
GpencilModifierType(md->type));
if (mti->panelRegister == nullptr) {
continue;
}
/* Move to the next instanced panel corresponding to the next modifier. */
while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
panel = panel->next;
BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */
BLI_assert(panel !=
nullptr); /* There shouldn't be fewer panels than modifiers with UIs. */
}
PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
PointerRNA *md_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__));
RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr);
UI_panel_custom_data_set(panel, md_ptr);
@@ -2570,10 +2603,10 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C)
static void shaderfx_panel_id(void *fx_v, char *r_idname)
{
ShaderFxData *fx = (ShaderFxData *)fx_v;
BKE_shaderfxType_panel_id(fx->type, r_idname);
BKE_shaderfxType_panel_id(ShaderFxType(fx->type), r_idname);
}
void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C)
void uiTemplateShaderFx(uiLayout * /*layout*/, bContext *C)
{
ARegion *region = CTX_wm_region(C);
Object *ob = ED_object_active_context(C);
@@ -2583,13 +2616,13 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C)
if (!panels_match) {
UI_panels_free_instanced(C, region);
ShaderFxData *fx = shaderfx->first;
ShaderFxData *fx = static_cast<ShaderFxData *>(shaderfx->first);
for (int i = 0; fx; i++, fx = fx->next) {
char panel_idname[MAX_NAME];
shaderfx_panel_id(fx, panel_idname);
/* Create custom data RNA pointer. */
PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
PointerRNA *fx_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__));
RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr);
UI_panel_add_instanced(C, region, &region->panels, panel_idname, fx_ptr);
@@ -2597,20 +2630,21 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C)
}
else {
/* Assuming there's only one group of instanced panels, update the custom data pointers. */
Panel *panel = region->panels.first;
Panel *panel = static_cast<Panel *>(region->panels.first);
LISTBASE_FOREACH (ShaderFxData *, fx, shaderfx) {
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type);
if (fxi->panelRegister == NULL) {
const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(ShaderFxType(fx->type));
if (fxi->panelRegister == nullptr) {
continue;
}
/* Move to the next instanced panel corresponding to the next modifier. */
while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) {
panel = panel->next;
BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */
BLI_assert(panel !=
nullptr); /* There shouldn't be fewer panels than modifiers with UIs. */
}
PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
PointerRNA *fx_ptr = static_cast<PointerRNA *>(MEM_mallocN(sizeof(PointerRNA), __func__));
RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr);
UI_panel_custom_data_set(panel, fx_ptr);
@@ -2625,26 +2659,25 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C)
/** \name Operator Property Buttons Template
* \{ */
typedef struct uiTemplateOperatorPropertyPollParam {
struct uiTemplateOperatorPropertyPollParam {
const bContext *C;
wmOperator *op;
short flag;
} uiTemplateOperatorPropertyPollParam;
};
#ifdef USE_OP_RESET_BUT
static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C),
void *op_pt,
void *UNUSED(arg_dummy2))
static void ui_layout_operator_buts__reset_cb(bContext * /*C*/, void *op_pt, void * /*arg_dummy2*/)
{
WM_operator_properties_reset((wmOperator *)op_pt);
}
#endif
static bool ui_layout_operator_buts_poll_property(struct PointerRNA *UNUSED(ptr),
struct PropertyRNA *prop,
static bool ui_layout_operator_buts_poll_property(PointerRNA * /*ptr*/,
PropertyRNA *prop,
void *user_data)
{
uiTemplateOperatorPropertyPollParam *params = user_data;
uiTemplateOperatorPropertyPollParam *params = static_cast<uiTemplateOperatorPropertyPollParam *>(
user_data);
if ((params->flag & UI_TEMPLATE_OP_PROPS_HIDE_ADVANCED) &&
(RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED)) {
@@ -2661,7 +2694,7 @@ static eAutoPropButsReturn template_operator_property_buts_draw_single(
int layout_flags)
{
uiBlock *block = uiLayoutGetBlock(layout);
eAutoPropButsReturn return_info = 0;
eAutoPropButsReturn return_info = eAutoPropButsReturn(0);
if (!op->properties) {
const IDPropertyTemplate val = {0};
@@ -2692,13 +2725,13 @@ static eAutoPropButsReturn template_operator_property_buts_draw_single(
block->ui_operator = op;
row = uiLayoutRow(layout, true);
uiItemM(row, "WM_MT_operator_presets", NULL, ICON_NONE);
uiItemM(row, "WM_MT_operator_presets", nullptr, ICON_NONE);
wmOperatorType *ot = WM_operatortype_find("WM_OT_operator_preset_add", false);
uiItemFullO_ptr(row, ot, "", ICON_ADD, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
uiItemFullO_ptr(row, ot, "", ICON_ADD, nullptr, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
RNA_string_set(&op_ptr, "operator", op->type->idname);
uiItemFullO_ptr(row, ot, "", ICON_REMOVE, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
uiItemFullO_ptr(row, ot, "", ICON_REMOVE, nullptr, WM_OP_INVOKE_DEFAULT, 0, &op_ptr);
RNA_string_set(&op_ptr, "operator", op->type->idname);
RNA_boolean_set(&op_ptr, "remove_active", true);
}
@@ -2706,14 +2739,17 @@ static eAutoPropButsReturn template_operator_property_buts_draw_single(
if (op->type->ui) {
op->layout = layout;
op->type->ui((bContext *)C, op);
op->layout = NULL;
op->layout = nullptr;
/* #UI_LAYOUT_OP_SHOW_EMPTY ignored. retun_info is ignored too.
* We could allow #wmOperatorType.ui callback to return this, but not needed right now. */
}
else {
wmWindowManager *wm = CTX_wm_manager(C);
uiTemplateOperatorPropertyPollParam user_data = {.C = C, .op = op, .flag = layout_flags};
uiTemplateOperatorPropertyPollParam user_data{};
user_data.C = C;
user_data.op = op;
user_data.flag = layout_flags;
const bool use_prop_split = (layout_flags & UI_TEMPLATE_OP_PROPS_NO_SPLIT_LAYOUT) == 0;
PointerRNA ptr;
@@ -2726,8 +2762,8 @@ static eAutoPropButsReturn template_operator_property_buts_draw_single(
return_info = uiDefAutoButsRNA(
layout,
&ptr,
op->type->poll_property ? ui_layout_operator_buts_poll_property : NULL,
op->type->poll_property ? &user_data : NULL,
op->type->poll_property ? ui_layout_operator_buts_poll_property : nullptr,
op->type->poll_property ? &user_data : nullptr,
op->type->prop,
label_align,
(layout_flags & UI_TEMPLATE_OP_PROPS_COMPACT));
@@ -2757,20 +2793,20 @@ static eAutoPropButsReturn template_operator_property_buts_draw_single(
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Reset operator defaults"));
UI_but_func_set(but, ui_layout_operator_buts__reset_cb, op, NULL);
UI_but_func_set(but, ui_layout_operator_buts__reset_cb, op, nullptr);
}
#endif
/* set various special settings for buttons */
/* Only do this if we're not refreshing an existing UI. */
if (block->oldblock == NULL) {
if (block->oldblock == nullptr) {
const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0;
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
@@ -2831,7 +2867,10 @@ static bool ui_layout_operator_properties_only_booleans(const bContext *C,
}
}
else {
uiTemplateOperatorPropertyPollParam user_data = {.C = C, .op = op, .flag = layout_flags};
uiTemplateOperatorPropertyPollParam user_data{};
user_data.C = C;
user_data.op = op;
user_data.flag = layout_flags;
PointerRNA ptr;
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
@@ -2865,7 +2904,7 @@ void uiTemplateOperatorPropertyButs(
flag |= UI_TEMPLATE_OP_PROPS_NO_SPLIT_LAYOUT;
}
template_operator_property_buts_draw_recursive(C, op, layout, label_align, flag, NULL);
template_operator_property_buts_draw_recursive(C, op, layout, label_align, flag, nullptr);
}
void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
@@ -2873,7 +2912,7 @@ void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
wmOperator *op = WM_operator_last_redo(C);
uiBlock *block = uiLayoutGetBlock(layout);
if (op == NULL) {
if (op == nullptr) {
return;
}
@@ -2884,15 +2923,15 @@ void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
"SCREEN_OT_repeat_last",
WM_operatortype_name(op->type, op->ptr),
ICON_NONE,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
NULL);
nullptr);
#endif
if (WM_operator_repeat_check(C, op)) {
int layout_flags = 0;
if (block->panel == NULL) {
if (block->panel == nullptr) {
layout_flags = UI_TEMPLATE_OP_PROPS_SHOW_TITLE;
}
#if 0
@@ -2901,7 +2940,7 @@ void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
UI_block_func_handle_set(block, ED_undo_operator_repeat_cb_evt, op);
template_operator_property_buts_draw_recursive(
C, op, layout, UI_BUT_LABEL_ALIGN_NONE, layout_flags, NULL /* &has_advanced */);
C, op, layout, UI_BUT_LABEL_ALIGN_NONE, layout_flags, nullptr /* &has_advanced */);
/* Warning! this leaves the handle function for any other users of this block. */
#if 0
@@ -2920,9 +2959,9 @@ void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
#define ERROR_LIBDATA_MESSAGE TIP_("Can't edit external library data")
static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v)
static void constraint_active_func(bContext * /*C*/, void *ob_v, void *con_v)
{
ED_object_constraint_active_set(ob_v, con_v);
ED_object_constraint_active_set(static_cast<Object *>(ob_v), static_cast<bConstraint *>(con_v));
}
static void constraint_ops_extra_draw(bContext *C, uiLayout *layout, void *con_v)
@@ -2965,7 +3004,7 @@ static void constraint_ops_extra_draw(bContext *C, uiLayout *layout, void *con_v
"CONSTRAINT_OT_move_to_index",
IFACE_("Move to First"),
ICON_TRIA_UP,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
&op_ptr);
@@ -2980,11 +3019,11 @@ static void constraint_ops_extra_draw(bContext *C, uiLayout *layout, void *con_v
"CONSTRAINT_OT_move_to_index",
IFACE_("Move to Last"),
ICON_TRIA_DOWN,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
&op_ptr);
ListBase *constraint_list = ED_object_constraint_list_from_constraint(ob, con, NULL);
ListBase *constraint_list = ED_object_constraint_list_from_constraint(ob, con, nullptr);
RNA_int_set(&op_ptr, "index", BLI_listbase_count(constraint_list) - 1);
if (!con->next) {
uiLayoutSetEnabled(row, false);
@@ -3009,7 +3048,7 @@ static void draw_constraint_header(uiLayout *layout, Object *ob, bConstraint *co
/* Constraint type icon. */
uiLayout *sub = uiLayoutRow(layout, false);
uiLayoutSetEmboss(sub, false);
uiLayoutSetEmboss(sub, UI_EMBOSS);
uiLayoutSetRedAlert(sub, (con->flag & CONSTRAINT_DISABLE));
uiItemL(sub, "", RNA_struct_ui_icon(ptr.type));
@@ -3047,7 +3086,7 @@ void uiTemplateConstraintHeader(uiLayout *layout, PointerRNA *ptr)
}
Object *ob = (Object *)ptr->owner_id;
bConstraint *con = ptr->data;
bConstraint *con = static_cast<bConstraint *>(ptr->data);
if (!ob || !(GS(ob->id.name) == ID_OB)) {
RNA_warning("Expected constraint on object");
@@ -3088,9 +3127,9 @@ void uiTemplatePreview(uiLayout *layout,
MTex *slot,
const char *preview_id)
{
Material *ma = NULL;
Material *ma = nullptr;
Tex *tex = (Tex *)id;
short *pr_texture = NULL;
short *pr_texture = nullptr;
PointerRNA material_ptr;
PointerRNA texture_ptr;
@@ -3103,7 +3142,7 @@ void uiTemplatePreview(uiLayout *layout,
/* decide what to render */
ID *pid = id;
ID *pparent = NULL;
ID *pparent = nullptr;
if (id && (GS(id->name) == ID_TE)) {
if (parent && (GS(parent->name) == ID_MA)) {
@@ -3138,11 +3177,11 @@ void uiTemplatePreview(uiLayout *layout,
/* Find or add the uiPreview to the current Region. */
ARegion *region = CTX_wm_region(C);
uiPreview *ui_preview = BLI_findstring(
&region->ui_previews, preview_id, offsetof(uiPreview, preview_id));
uiPreview *ui_preview = static_cast<uiPreview *>(
BLI_findstring(&region->ui_previews, preview_id, offsetof(uiPreview, preview_id)));
if (!ui_preview) {
ui_preview = MEM_callocN(sizeof(uiPreview), "uiPreview");
ui_preview = MEM_cnew<uiPreview>(__func__);
BLI_strncpy(ui_preview->preview_id, preview_id, sizeof(ui_preview->preview_id));
ui_preview->height = (short)(UI_UNIT_Y * 7.6f);
BLI_addtail(&region->ui_previews, ui_preview);
@@ -3177,7 +3216,7 @@ void uiTemplatePreview(uiLayout *layout,
0,
"");
UI_but_func_drawextra_set(block, ED_preview_draw, pparent, slot);
UI_block_func_handle_set(block, do_preview_buttons, NULL);
UI_block_func_handle_set(block, do_preview_buttons, nullptr);
uiDefIconButS(block,
UI_BTYPE_GRIP,
@@ -3320,7 +3359,7 @@ void uiTemplatePreview(uiLayout *layout,
/* Alpha button for texture preview */
if (*pr_texture != TEX_PR_OTHER) {
row = uiLayoutRow(layout, false);
uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE);
uiItemR(row, &texture_ptr, "use_preview_alpha", 0, nullptr, ICON_NONE);
}
}
}
@@ -3332,12 +3371,12 @@ void uiTemplatePreview(uiLayout *layout,
/** \name ColorRamp Template
* \{ */
typedef struct RNAUpdateCb {
struct RNAUpdateCb {
PointerRNA ptr;
PropertyRNA *prop;
} RNAUpdateCb;
};
static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
static void rna_update_cb(bContext *C, void *arg_cb, void * /*arg*/)
{
RNAUpdateCb *cb = (RNAUpdateCb *)arg_cb;
@@ -3388,7 +3427,7 @@ static void colorband_distribute_cb(bContext *C, ColorBand *coba, bool evenly)
static void colorband_tools_dofunc(bContext *C, void *coba_v, int event)
{
ColorBand *coba = coba_v;
ColorBand *coba = static_cast<ColorBand *>(coba_v);
switch (event) {
case CB_FUNC_FLIP:
@@ -3411,7 +3450,7 @@ static void colorband_tools_dofunc(bContext *C, void *coba_v, int event)
static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v)
{
const uiStyle *style = UI_style_get_dpi();
ColorBand *coba = coba_v;
ColorBand *coba = static_cast<ColorBand *>(coba_v);
short yco = 0;
const short menuwidth = 10 * UI_UNIT_X;
@@ -3430,7 +3469,7 @@ static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v)
UI_block_layout_set_current(block, layout);
{
PointerRNA coba_ptr;
RNA_pointer_create(NULL, &RNA_ColorRamp, coba, &coba_ptr);
RNA_pointer_create(nullptr, &RNA_ColorRamp, coba, &coba_ptr);
uiLayoutSetContextPointer(layout, "color_ramp", &coba_ptr);
}
@@ -3446,7 +3485,7 @@ static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v)
yco -= UI_UNIT_Y,
menuwidth,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -3461,7 +3500,7 @@ static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v)
yco -= UI_UNIT_Y,
menuwidth,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -3476,7 +3515,7 @@ static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v)
yco -= UI_UNIT_Y,
menuwidth,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -3494,7 +3533,7 @@ static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v)
yco -= UI_UNIT_Y,
menuwidth,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -3510,7 +3549,7 @@ static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v)
static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
{
ColorBand *coba = coba_v;
ColorBand *coba = static_cast<ColorBand *>(coba_v);
float pos = 0.5f;
if (coba->tot > 1) {
@@ -3523,25 +3562,25 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
}
if (BKE_colorband_element_add(coba, pos)) {
rna_update_cb(C, cb_v, NULL);
rna_update_cb(C, cb_v, nullptr);
ED_undo_push(C, "Add Color Ramp Stop");
}
}
static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v)
{
ColorBand *coba = coba_v;
ColorBand *coba = static_cast<ColorBand *>(coba_v);
if (BKE_colorband_element_remove(coba, coba->cur)) {
ED_undo_push(C, "Delete Color Ramp Stop");
rna_update_cb(C, cb_v, NULL);
rna_update_cb(C, cb_v, nullptr);
}
}
static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v)
static void colorband_update_cb(bContext * /*C*/, void *bt_v, void *coba_v)
{
uiBut *bt = bt_v;
ColorBand *coba = coba_v;
uiBut *bt = static_cast<uiBut *>(bt_v);
ColorBand *coba = static_cast<ColorBand *>(coba_v);
/* Sneaky update here, we need to sort the color-band points to be in order,
* however the RNA pointer then is wrong, so we update it */
@@ -3579,7 +3618,7 @@ static void colorband_buttons_layout(uiLayout *layout,
0,
2.0f * unit,
UI_UNIT_Y,
NULL,
nullptr,
0,
0,
0,
@@ -3596,7 +3635,7 @@ static void colorband_buttons_layout(uiLayout *layout,
ys + UI_UNIT_Y,
2.0f * unit,
UI_UNIT_Y,
NULL,
nullptr,
0,
0,
0,
@@ -3647,7 +3686,7 @@ static void colorband_buttons_layout(uiLayout *layout,
0,
0,
"");
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr);
row = uiLayoutRow(layout, false);
@@ -3670,7 +3709,7 @@ static void colorband_buttons_layout(uiLayout *layout,
UI_UNIT_Y,
&coba->cur,
0.0,
(float)MAX2(0, coba->tot - 1),
float(MAX2(0, coba->tot - 1)),
0,
0,
TIP_("Choose active color stop"));
@@ -3697,7 +3736,7 @@ static void colorband_buttons_layout(uiLayout *layout,
UI_UNIT_Y,
&coba->cur,
0.0,
(float)MAX2(0, coba->tot - 1),
float(MAX2(0, coba->tot - 1)),
0,
0,
TIP_("Choose active color stop"));
@@ -3725,7 +3764,7 @@ static void colorband_buttons_layout(uiLayout *layout,
}
if (STREQ(prop_identifier, "color")) {
UI_but_funcN_set(but, rna_update_cb, MEM_dupallocN(cb), NULL);
UI_but_funcN_set(but, rna_update_cb, MEM_dupallocN(cb), nullptr);
}
}
}
@@ -3744,7 +3783,7 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
return;
}
RNAUpdateCb *cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
RNAUpdateCb *cb = MEM_cnew<RNAUpdateCb>("RNAUpdateCb");
cb->ptr = *ptr;
cb->prop = prop;
@@ -3759,7 +3798,7 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
ID *id = cptr.owner_id;
UI_block_lock_set(block, (id && ID_IS_LINKED(id)), ERROR_LIBDATA_MESSAGE);
colorband_buttons_layout(layout, block, cptr.data, &rect, cb, expand);
colorband_buttons_layout(layout, block, static_cast<ColorBand *>(cptr.data), &rect, cb, expand);
UI_block_lock_clear(block);
@@ -3783,7 +3822,7 @@ void uiTemplateIcon(uiLayout *layout, int icon_value, float icon_scale)
0,
UI_UNIT_X * icon_scale,
UI_UNIT_Y * icon_scale,
NULL,
nullptr,
0.0,
0.0,
0.0,
@@ -3798,12 +3837,12 @@ void uiTemplateIcon(uiLayout *layout, int icon_value, float icon_scale)
/** \name Icon viewer Template
* \{ */
typedef struct IconViewMenuArgs {
struct IconViewMenuArgs {
PointerRNA ptr;
PropertyRNA *prop;
bool show_labels;
float icon_scale;
} IconViewMenuArgs;
};
/* ID Search browse menu, open */
static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_litem)
@@ -3821,7 +3860,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_lit
bool free;
const EnumPropertyItem *item;
RNA_property_enum_items(C, &args.ptr, args.prop, &item, NULL, &free);
RNA_property_enum_items(C, &args.ptr, args.prop, &item, nullptr, &free);
for (int a = 0; item[a].identifier; a++) {
const int x = (a % 8) * w;
@@ -3847,7 +3886,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_lit
value,
-1,
-1,
NULL);
nullptr);
}
else {
but = uiDefIconButR_prop(block,
@@ -3865,7 +3904,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_lit
value,
-1,
-1,
NULL);
nullptr);
}
ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
}
@@ -3900,14 +3939,15 @@ void uiTemplateIconView(uiLayout *layout,
int tot_items;
bool free_items;
const EnumPropertyItem *items;
RNA_property_enum_items(block->evil_C, ptr, prop, &items, &tot_items, &free_items);
RNA_property_enum_items(
static_cast<bContext *>(block->evil_C), ptr, prop, &items, &tot_items, &free_items);
const int value = RNA_property_enum_get(ptr, prop);
int icon = ICON_NONE;
RNA_enum_icon_from_value(items, value, &icon);
uiBut *but;
if (RNA_property_editable(ptr, prop)) {
IconViewMenuArgs *cb_args = MEM_callocN(sizeof(IconViewMenuArgs), __func__);
IconViewMenuArgs *cb_args = MEM_cnew<IconViewMenuArgs>(__func__);
cb_args->ptr = *ptr;
cb_args->prop = prop;
cb_args->show_labels = show_labels;
@@ -3932,7 +3972,7 @@ void uiTemplateIconView(uiLayout *layout,
0,
UI_UNIT_X * icon_scale,
UI_UNIT_Y * icon_scale,
NULL,
nullptr,
0.0,
0.0,
0.0,
@@ -4139,9 +4179,9 @@ static bool curvemap_can_zoom_in(CurveMapping *cumap)
return BLI_rctf_size_x(&cumap->curr) > CURVE_ZOOM_MAX * BLI_rctf_size_x(&cumap->clipr);
}
static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(arg))
static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void * /*arg*/)
{
CurveMapping *cumap = cumap_v;
CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v);
if (curvemap_can_zoom_in(cumap)) {
const float dx = 0.1154f * BLI_rctf_size_x(&cumap->curr);
@@ -4155,9 +4195,9 @@ static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(ar
ED_region_tag_redraw(CTX_wm_region(C));
}
static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(unused))
static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void * /*unused*/)
{
CurveMapping *cumap = cumap_v;
CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v);
float d, d1;
if (curvemap_can_zoom_out(cumap)) {
@@ -4199,27 +4239,27 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
ED_region_tag_redraw(CTX_wm_region(C));
}
static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *UNUSED(arg))
static void curvemap_buttons_setclip(bContext * /*C*/, void *cumap_v, void * /*arg*/)
{
CurveMapping *cumap = cumap_v;
CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v);
BKE_curvemapping_changed(cumap, false);
}
static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v)
{
CurveMapping *cumap = cumap_v;
CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v);
BKE_curvemap_remove(cumap->cm + cumap->cur, SELECT);
BKE_curvemapping_changed(cumap, false);
rna_update_cb(C, cb_v, NULL);
rna_update_cb(C, cb_v, nullptr);
}
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap_v)
{
CurveMapping *cumap = cumap_v;
CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v);
uiBut *bt;
const float width = 8 * UI_UNIT_X;
@@ -4242,7 +4282,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *region, void *cumap
10,
0,
"");
UI_but_func_set(bt, curvemap_buttons_setclip, cumap, NULL);
UI_but_func_set(bt, curvemap_buttons_setclip, cumap, nullptr);
UI_block_align_begin(block);
bt = uiDefButF(block,
@@ -4330,7 +4370,7 @@ enum {
static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
{
CurveMapping *cumap = cumap_v;
CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v);
CurveMap *cuma = cumap->cm + cumap->cur;
switch (event) {
@@ -4390,7 +4430,7 @@ static uiBlock *curvemap_tools_func(
yco -= UI_UNIT_Y,
menuwidth,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -4408,7 +4448,7 @@ static uiBlock *curvemap_tools_func(
yco -= UI_UNIT_Y,
menuwidth,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -4423,7 +4463,7 @@ static uiBlock *curvemap_tools_func(
yco -= UI_UNIT_Y,
menuwidth,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -4441,7 +4481,7 @@ static uiBlock *curvemap_tools_func(
yco -= UI_UNIT_Y,
menuwidth,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -4457,54 +4497,58 @@ static uiBlock *curvemap_tools_func(
static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *region, void *cumap_v)
{
return curvemap_tools_func(C, region, cumap_v, true, UICURVE_FUNC_RESET_POS);
return curvemap_tools_func(
C, region, static_cast<CurveMapping *>(cumap_v), true, UICURVE_FUNC_RESET_POS);
}
static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *region, void *cumap_v)
{
return curvemap_tools_func(C, region, cumap_v, true, UICURVE_FUNC_RESET_NEG);
return curvemap_tools_func(
C, region, static_cast<CurveMapping *>(cumap_v), true, UICURVE_FUNC_RESET_NEG);
}
static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *region, void *cumap_v)
{
return curvemap_tools_func(C, region, cumap_v, false, UICURVE_FUNC_RESET_NEG);
return curvemap_tools_func(
C, region, static_cast<CurveMapping *>(cumap_v), false, UICURVE_FUNC_RESET_NEG);
}
static uiBlock *curvemap_brush_tools_negslope_func(bContext *C, ARegion *region, void *cumap_v)
{
return curvemap_tools_func(C, region, cumap_v, false, UICURVE_FUNC_RESET_POS);
return curvemap_tools_func(
C, region, static_cast<CurveMapping *>(cumap_v), false, UICURVE_FUNC_RESET_POS);
}
static void curvemap_tools_handle_vector(bContext *C, void *cumap_v, void *UNUSED(arg))
static void curvemap_tools_handle_vector(bContext *C, void *cumap_v, void * /*arg*/)
{
curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_VECTOR);
}
static void curvemap_tools_handle_auto(bContext *C, void *cumap_v, void *UNUSED(arg))
static void curvemap_tools_handle_auto(bContext *C, void *cumap_v, void * /*arg*/)
{
curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_AUTO);
}
static void curvemap_tools_handle_auto_clamped(bContext *C, void *cumap_v, void *UNUSED(arg))
static void curvemap_tools_handle_auto_clamped(bContext *C, void *cumap_v, void * /*arg*/)
{
curvemap_tools_dofunc(C, cumap_v, UICURVE_FUNC_HANDLE_AUTO_ANIM);
}
static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
static void curvemap_buttons_redraw(bContext *C, void * /*arg1*/, void * /*arg2*/)
{
ED_region_tag_redraw(CTX_wm_region(C));
}
static void curvemap_buttons_update(bContext *C, void *arg1_v, void *cumap_v)
{
CurveMapping *cumap = cumap_v;
CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v);
BKE_curvemapping_changed(cumap, true);
rna_update_cb(C, arg1_v, NULL);
rna_update_cb(C, arg1_v, nullptr);
}
static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
{
CurveMapping *cumap = cumap_v;
CurveMapping *cumap = static_cast<CurveMapping *>(cumap_v);
cumap->preset = CURVE_PRESET_LINE;
for (int a = 0; a < CM_TOT; a++) {
BKE_curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
@@ -4512,11 +4556,11 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f;
cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
BKE_curvemapping_set_black_white(cumap, NULL, NULL);
BKE_curvemapping_set_black_white(cumap, nullptr, nullptr);
BKE_curvemapping_changed(cumap, false);
rna_update_cb(C, cb_v, NULL);
rna_update_cb(C, cb_v, nullptr);
}
/**
@@ -4533,7 +4577,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
bool tone,
RNAUpdateCb *cb)
{
CurveMapping *cumap = ptr->data;
CurveMapping *cumap = static_cast<CurveMapping *>(ptr->data);
CurveMap *cm = &cumap->cm[cumap->cur];
uiBut *bt;
const float dx = UI_UNIT_X;
@@ -4545,7 +4589,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
if (tone) {
uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
uiItemR(uiLayoutRow(split, false), ptr, "tone", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(uiLayoutRow(split, false), ptr, "tone", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
}
/* curve chooser */
@@ -4559,17 +4603,17 @@ static void curvemap_buttons_layout(uiLayout *layout,
if (cumap->cm[0].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
if (cumap->cm[1].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
if (cumap->cm[2].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
}
else if (labeltype == 'c') {
@@ -4580,22 +4624,22 @@ static void curvemap_buttons_layout(uiLayout *layout,
if (cumap->cm[3].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
if (cumap->cm[0].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
if (cumap->cm[1].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
if (cumap->cm[2].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
}
else if (labeltype == 'h') {
@@ -4606,17 +4650,17 @@ static void curvemap_buttons_layout(uiLayout *layout,
if (cumap->cm[0].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
if (cumap->cm[1].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
if (cumap->cm[2].curve) {
bt = uiDefButI(
block, UI_BTYPE_ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL);
UI_but_func_set(bt, curvemap_buttons_redraw, nullptr, nullptr);
}
}
else {
@@ -4641,13 +4685,13 @@ static void curvemap_buttons_layout(uiLayout *layout,
0,
dx,
dx,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Zoom in"));
UI_but_func_set(bt, curvemap_buttons_zoom_in, cumap, NULL);
UI_but_func_set(bt, curvemap_buttons_zoom_in, cumap, nullptr);
if (!curvemap_can_zoom_in(cumap)) {
UI_but_disable(bt, "");
}
@@ -4661,13 +4705,13 @@ static void curvemap_buttons_layout(uiLayout *layout,
0,
dx,
dx,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Zoom out"));
UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, NULL);
UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, nullptr);
if (!curvemap_can_zoom_out(cumap)) {
UI_but_disable(bt, "");
}
@@ -4677,7 +4721,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
bt = uiDefIconBlockBut(
block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
bt->drawflag &= ~UI_BUT_ICON_LEFT;
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr);
if (brush && neg_slope) {
bt = uiDefIconBlockBut(
@@ -4695,20 +4739,20 @@ static void curvemap_buttons_layout(uiLayout *layout,
bt = uiDefIconBlockBut(
block, curvemap_tools_posslope_func, cumap, 0, 0, 0, 0, dx, dx, TIP_("Tools"));
}
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr);
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), nullptr);
/* Curve itself. */
const int size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
row = uiLayoutRow(layout, false);
uiButCurveMapping *curve_but = (uiButCurveMapping *)uiDefBut(
block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, -1, 0, "");
curve_but->gradient_type = bg;
curve_but->gradient_type = eButGradientType(bg);
/* Sliders for selected curve point. */
int i;
CurveMapPoint *cmp = NULL;
CurveMapPoint *cmp = nullptr;
bool point_last_or_first = false;
for (i = 0; i < cm->totpoint; i++) {
if (cm->curve[i].flag & CUMA_SELECT) {
@@ -4743,13 +4787,13 @@ static void curvemap_buttons_layout(uiLayout *layout,
UI_UNIT_Y,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Auto Handle"));
UI_but_func_set(bt, curvemap_tools_handle_auto, cumap, NULL);
UI_but_func_set(bt, curvemap_tools_handle_auto, cumap, nullptr);
if (((cmp->flag & CUMA_HANDLE_AUTO_ANIM) == false) &&
((cmp->flag & CUMA_HANDLE_VECTOR) == false)) {
bt->flag |= UI_SELECT_DRAW;
@@ -4763,13 +4807,13 @@ static void curvemap_buttons_layout(uiLayout *layout,
UI_UNIT_Y,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Vector Handle"));
UI_but_func_set(bt, curvemap_tools_handle_vector, cumap, NULL);
UI_but_func_set(bt, curvemap_tools_handle_vector, cumap, nullptr);
if (cmp->flag & CUMA_HANDLE_VECTOR) {
bt->flag |= UI_SELECT_DRAW;
}
@@ -4782,13 +4826,13 @@ static void curvemap_buttons_layout(uiLayout *layout,
UI_UNIT_Y,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Auto Clamped"));
UI_but_func_set(bt, curvemap_tools_handle_auto_clamped, cumap, NULL);
UI_but_func_set(bt, curvemap_tools_handle_auto_clamped, cumap, nullptr);
if (cmp->flag & CUMA_HANDLE_AUTO_ANIM) {
bt->flag |= UI_SELECT_DRAW;
}
@@ -4837,7 +4881,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
0,
dx,
dx,
NULL,
nullptr,
0.0,
0.0,
0.0,
@@ -4852,8 +4896,10 @@ static void curvemap_buttons_layout(uiLayout *layout,
/* black/white levels */
if (levels) {
uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
uiItemR(uiLayoutColumn(split, false), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(uiLayoutColumn(split, false), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(
uiLayoutColumn(split, false), ptr, "black_level", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
uiItemR(
uiLayoutColumn(split, false), ptr, "white_level", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
uiLayoutRow(layout, false);
bt = uiDefBut(block,
@@ -4864,7 +4910,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
0,
UI_UNIT_X * 10,
UI_UNIT_Y,
NULL,
nullptr,
0.0f,
0.0f,
0,
@@ -4873,7 +4919,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
UI_but_funcN_set(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap);
}
UI_block_funcN_set(block, NULL, NULL, NULL);
UI_block_funcN_set(block, nullptr, nullptr, nullptr);
}
void uiTemplateCurveMapping(uiLayout *layout,
@@ -4903,7 +4949,7 @@ void uiTemplateCurveMapping(uiLayout *layout,
return;
}
RNAUpdateCb *cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
RNAUpdateCb *cb = MEM_cnew<RNAUpdateCb>("RNAUpdateCb");
cb->ptr = *ptr;
cb->prop = prop;
@@ -4925,7 +4971,7 @@ void uiTemplateCurveMapping(uiLayout *layout,
static void CurveProfile_presets_dofunc(bContext *C, void *profile_v, int event)
{
CurveProfile *profile = profile_v;
CurveProfile *profile = static_cast<CurveProfile *>(profile_v);
profile->preset = event;
BKE_curveprofile_reset(profile);
@@ -4951,7 +4997,7 @@ static uiBlock *CurveProfile_presets_func(bContext *C, ARegion *region, CurvePro
yco -= UI_UNIT_Y,
0,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -4966,7 +5012,7 @@ static uiBlock *CurveProfile_presets_func(bContext *C, ARegion *region, CurvePro
yco -= UI_UNIT_Y,
0,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -4981,7 +5027,7 @@ static uiBlock *CurveProfile_presets_func(bContext *C, ARegion *region, CurvePro
yco -= UI_UNIT_Y,
0,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -4996,7 +5042,7 @@ static uiBlock *CurveProfile_presets_func(bContext *C, ARegion *region, CurvePro
yco -= UI_UNIT_Y,
0,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -5011,7 +5057,7 @@ static uiBlock *CurveProfile_presets_func(bContext *C, ARegion *region, CurvePro
yco -= UI_UNIT_Y,
0,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -5019,7 +5065,7 @@ static uiBlock *CurveProfile_presets_func(bContext *C, ARegion *region, CurvePro
"");
UI_block_direction_set(block, UI_DIR_DOWN);
UI_block_bounds_set_text(block, (int)(3.0f * UI_UNIT_X));
UI_block_bounds_set_text(block, int(3.0f * UI_UNIT_X));
return block;
}
@@ -5037,7 +5083,7 @@ enum {
static void CurveProfile_tools_dofunc(bContext *C, void *profile_v, int event)
{
CurveProfile *profile = profile_v;
CurveProfile *profile = static_cast<CurveProfile *>(profile_v);
switch (event) {
case UIPROFILE_FUNC_RESET: /* reset */
@@ -5068,7 +5114,7 @@ static uiBlock *CurveProfile_tools_func(bContext *C, ARegion *region, CurveProfi
yco -= UI_UNIT_Y,
0,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -5083,7 +5129,7 @@ static uiBlock *CurveProfile_tools_func(bContext *C, ARegion *region, CurveProfi
yco -= UI_UNIT_Y,
0,
UI_UNIT_Y,
NULL,
nullptr,
0.0,
0.0,
0,
@@ -5091,7 +5137,7 @@ static uiBlock *CurveProfile_tools_func(bContext *C, ARegion *region, CurveProfi
"");
UI_block_direction_set(block, UI_DIR_DOWN);
UI_block_bounds_set_text(block, (int)(3.0f * UI_UNIT_X));
UI_block_bounds_set_text(block, int(3.0f * UI_UNIT_X));
return block;
}
@@ -5112,9 +5158,9 @@ static bool CurveProfile_can_zoom_out(CurveProfile *profile)
return BLI_rctf_size_x(&profile->view_rect) < BLI_rctf_size_x(&profile->clip_rect);
}
static void CurveProfile_buttons_zoom_in(bContext *C, void *profile_v, void *UNUSED(arg))
static void CurveProfile_buttons_zoom_in(bContext *C, void *profile_v, void * /*arg*/)
{
CurveProfile *profile = profile_v;
CurveProfile *profile = static_cast<CurveProfile *>(profile_v);
if (CurveProfile_can_zoom_in(profile)) {
const float dx = 0.1154f * BLI_rctf_size_x(&profile->view_rect);
@@ -5128,9 +5174,9 @@ static void CurveProfile_buttons_zoom_in(bContext *C, void *profile_v, void *UNU
ED_region_tag_redraw(CTX_wm_region(C));
}
static void CurveProfile_buttons_zoom_out(bContext *C, void *profile_v, void *UNUSED(arg))
static void CurveProfile_buttons_zoom_out(bContext *C, void *profile_v, void * /*arg*/)
{
CurveProfile *profile = profile_v;
CurveProfile *profile = static_cast<CurveProfile *>(profile_v);
if (CurveProfile_can_zoom_out(profile)) {
float d = 0.15f * BLI_rctf_size_x(&profile->view_rect);
@@ -5174,51 +5220,51 @@ static void CurveProfile_buttons_zoom_out(bContext *C, void *profile_v, void *UN
static void CurveProfile_clipping_toggle(bContext *C, void *cb_v, void *profile_v)
{
CurveProfile *profile = profile_v;
CurveProfile *profile = static_cast<CurveProfile *>(profile_v);
profile->flag ^= PROF_USE_CLIP;
BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
rna_update_cb(C, cb_v, NULL);
rna_update_cb(C, cb_v, nullptr);
}
static void CurveProfile_buttons_reverse(bContext *C, void *cb_v, void *profile_v)
{
CurveProfile *profile = profile_v;
CurveProfile *profile = static_cast<CurveProfile *>(profile_v);
BKE_curveprofile_reverse(profile);
BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
rna_update_cb(C, cb_v, NULL);
rna_update_cb(C, cb_v, nullptr);
}
static void CurveProfile_buttons_delete(bContext *C, void *cb_v, void *profile_v)
{
CurveProfile *profile = profile_v;
CurveProfile *profile = static_cast<CurveProfile *>(profile_v);
BKE_curveprofile_remove_by_flag(profile, SELECT);
BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
rna_update_cb(C, cb_v, NULL);
rna_update_cb(C, cb_v, nullptr);
}
static void CurveProfile_buttons_update(bContext *C, void *arg1_v, void *profile_v)
{
CurveProfile *profile = profile_v;
CurveProfile *profile = static_cast<CurveProfile *>(profile_v);
BKE_curveprofile_update(profile, PROF_UPDATE_REMOVE_DOUBLES | PROF_UPDATE_CLIP);
rna_update_cb(C, arg1_v, NULL);
rna_update_cb(C, arg1_v, nullptr);
}
static void CurveProfile_buttons_reset(bContext *C, void *arg1_v, void *profile_v)
{
CurveProfile *profile = profile_v;
CurveProfile *profile = static_cast<CurveProfile *>(profile_v);
BKE_curveprofile_reset(profile);
BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
rna_update_cb(C, arg1_v, NULL);
rna_update_cb(C, arg1_v, nullptr);
}
static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUpdateCb *cb)
{
CurveProfile *profile = ptr->data;
CurveProfile *profile = static_cast<CurveProfile *>(ptr->data);
uiBut *bt;
uiBlock *block = uiLayoutGetBlock(layout);
@@ -5233,7 +5279,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
uiLayout *row = uiLayoutRow(layout, true);
bt = uiDefBlockBut(
block, CurveProfile_buttons_presets, profile, "Preset", 0, 0, UI_UNIT_X, UI_UNIT_X, "");
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr);
/* Show a "re-apply" preset button when it has been changed from the preset. */
if (profile->flag & PROF_DIRTY_PRESET) {
@@ -5248,7 +5294,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
0,
UI_UNIT_X,
UI_UNIT_X,
NULL,
nullptr,
0.0,
0.0,
0.0,
@@ -5273,13 +5319,13 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
0,
UI_UNIT_X,
UI_UNIT_X,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Zoom in"));
UI_but_func_set(bt, CurveProfile_buttons_zoom_in, profile, NULL);
UI_but_func_set(bt, CurveProfile_buttons_zoom_in, profile, nullptr);
if (!CurveProfile_can_zoom_in(profile)) {
UI_but_disable(bt, "");
}
@@ -5293,13 +5339,13 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
0,
UI_UNIT_X,
UI_UNIT_X,
NULL,
nullptr,
0.0,
0.0,
0.0,
0.0,
TIP_("Zoom out"));
UI_but_func_set(bt, CurveProfile_buttons_zoom_out, profile, NULL);
UI_but_func_set(bt, CurveProfile_buttons_zoom_out, profile, nullptr);
if (!CurveProfile_can_zoom_out(profile)) {
UI_but_disable(bt, "");
}
@@ -5317,7 +5363,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
0,
UI_UNIT_X,
UI_UNIT_X,
NULL,
nullptr,
0.0,
0.0,
0.0,
@@ -5335,7 +5381,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
0,
UI_UNIT_X,
UI_UNIT_X,
NULL,
nullptr,
0.0,
0.0,
0.0,
@@ -5346,13 +5392,13 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
/* Reset view, reset curve */
bt = uiDefIconBlockBut(
block, CurveProfile_buttons_tools, profile, 0, 0, 0, 0, UI_UNIT_X, UI_UNIT_X, TIP_("Tools"));
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr);
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), nullptr);
/* The path itself */
int path_width = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
path_width = min_ii(path_width, (int)(16.0f * UI_UNIT_X));
path_width = min_ii(path_width, int(16.0f * UI_UNIT_X));
const int path_height = path_width;
uiLayoutRow(layout, false);
uiDefBut(block,
@@ -5374,7 +5420,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
int i;
float *selection_x, *selection_y;
bool point_last_or_first = false;
CurveProfilePoint *point = NULL;
CurveProfilePoint *point = nullptr;
for (i = 0; i < profile->path_len; i++) {
if (profile->path[i].flag & PROF_SELECT) {
point = &profile->path[i];
@@ -5473,7 +5519,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
0,
UI_UNIT_X,
UI_UNIT_X,
NULL,
nullptr,
0.0,
0.0,
0.0,
@@ -5485,10 +5531,10 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
}
}
uiItemR(layout, ptr, "use_sample_straight_edges", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "use_sample_even_lengths", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "use_sample_straight_edges", 0, nullptr, ICON_NONE);
uiItemR(layout, ptr, "use_sample_even_lengths", 0, nullptr, ICON_NONE);
UI_block_funcN_set(block, NULL, NULL, NULL);
UI_block_funcN_set(block, nullptr, nullptr, nullptr);
}
void uiTemplateCurveProfile(uiLayout *layout, PointerRNA *ptr, const char *propname)
@@ -5515,7 +5561,7 @@ void uiTemplateCurveProfile(uiLayout *layout, PointerRNA *ptr, const char *propn
}
/* Share update functionality with the CurveMapping widget template. */
RNAUpdateCb *cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
RNAUpdateCb *cb = MEM_cnew<RNAUpdateCb>("RNAUpdateCb");
cb->ptr = *ptr;
cb->prop = prop;
@@ -5560,7 +5606,7 @@ void uiTemplateColorPicker(uiLayout *layout,
uiLayout *col = uiLayoutColumn(layout, true);
uiLayout *row = uiLayoutRow(col, true);
uiBut *but = NULL;
uiBut *but = nullptr;
uiButHSVCube *hsv_but;
switch (U.color_picker_type) {
case USER_CP_SQUARE_SV:
@@ -5672,7 +5718,7 @@ void uiTemplateColorPicker(uiLayout *layout,
0,
0,
"");
hsv_but->gradient_type = UI_GRAD_SV + 3;
hsv_but->gradient_type = eButGradientType(UI_GRAD_SV + 3);
break;
case USER_CP_SQUARE_HS:
uiItemS(col);
@@ -5692,7 +5738,7 @@ void uiTemplateColorPicker(uiLayout *layout,
0,
0,
"");
hsv_but->gradient_type = UI_GRAD_HS + 3;
hsv_but->gradient_type = eButGradientType(UI_GRAD_HS + 3);
break;
case USER_CP_SQUARE_HV:
uiItemS(col);
@@ -5712,7 +5758,7 @@ void uiTemplateColorPicker(uiLayout *layout,
0,
0,
"");
hsv_but->gradient_type = UI_GRAD_HV + 3;
hsv_but->gradient_type = eButGradientType(UI_GRAD_HV + 3);
break;
/* user default */
@@ -5743,7 +5789,7 @@ void uiTemplateColorPicker(uiLayout *layout,
}
}
static void ui_template_palette_menu(bContext *UNUSED(C), uiLayout *layout, void *UNUSED(but_p))
static void ui_template_palette_menu(bContext * /* C*/, uiLayout *layout, void * /*but_p*/)
{
uiLayout *row;
@@ -5758,13 +5804,10 @@ static void ui_template_palette_menu(bContext *UNUSED(C), uiLayout *layout, void
uiItemEnumO_value(row, IFACE_("Luminance"), ICON_NONE, "PALETTE_OT_sort", "type", 4);
}
void uiTemplatePalette(uiLayout *layout,
PointerRNA *ptr,
const char *propname,
bool UNUSED(colors))
void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, bool /*colors*/)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
uiBut *but = NULL;
uiBut *but = nullptr;
const int cols_per_row = MAX2(uiLayoutGetWidth(layout) / UI_UNIT_X, 1);
@@ -5780,7 +5823,7 @@ void uiTemplatePalette(uiLayout *layout,
uiBlock *block = uiLayoutGetBlock(layout);
Palette *palette = cptr.data;
Palette *palette = static_cast<Palette *>(cptr.data);
uiLayout *col = uiLayoutColumn(layout, true);
uiLayoutRow(col, true);
@@ -5793,7 +5836,7 @@ void uiTemplatePalette(uiLayout *layout,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL);
nullptr);
uiDefIconButO(block,
UI_BTYPE_BUT,
"PALETTE_OT_color_delete",
@@ -5803,8 +5846,8 @@ void uiTemplatePalette(uiLayout *layout,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL);
if (palette->colors.first != NULL) {
nullptr);
if (palette->colors.first != nullptr) {
but = uiDefIconButO(block,
UI_BTYPE_BUT,
"PALETTE_OT_color_move",
@@ -5814,7 +5857,7 @@ void uiTemplatePalette(uiLayout *layout,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL);
nullptr);
UI_but_operator_ptr_get(but);
RNA_enum_set(but->opptr, "type", -1);
@@ -5827,13 +5870,13 @@ void uiTemplatePalette(uiLayout *layout,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL);
nullptr);
UI_but_operator_ptr_get(but);
RNA_enum_set(but->opptr, "type", 1);
/* Menu. */
uiDefIconMenuBut(
block, ui_template_palette_menu, NULL, ICON_SORTSIZE, 0, 0, UI_UNIT_X, UI_UNIT_Y, "");
block, ui_template_palette_menu, nullptr, ICON_SORTSIZE, 0, 0, UI_UNIT_X, UI_UNIT_Y, "");
}
col = uiLayoutColumn(layout, true);
@@ -5906,7 +5949,7 @@ void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propn
static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
{
uiBut *but = arg1;
uiBut *but = static_cast<uiBut *>(arg1);
const int cur = POINTER_AS_INT(arg2);
wmWindow *win = CTX_wm_window(C);
const bool shift = win->eventstate->modifier & KM_SHIFT;
@@ -5952,7 +5995,7 @@ void uiTemplateLayers(uiLayout *layout,
const int cols = (layers / 2) + (layers % 2);
const int groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group);
PropertyRNA *used_prop = NULL;
PropertyRNA *used_prop = nullptr;
if (used_ptr && used_propname) {
used_prop = RNA_struct_find_property(used_ptr, used_propname);
if (!used_prop) {
@@ -5963,7 +6006,7 @@ void uiTemplateLayers(uiLayout *layout,
}
if (RNA_property_array_length(used_ptr, used_prop) < layers) {
used_prop = NULL;
used_prop = nullptr;
}
}
@@ -6013,29 +6056,29 @@ void uiTemplateLayers(uiLayout *layout,
#define B_STOPFILE 7
#define B_STOPOTHER 8
static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
static void do_running_jobs(bContext *C, void * /*arg*/, int event)
{
switch (event) {
case B_STOPRENDER:
G.is_break = true;
break;
case B_STOPCAST:
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C), NULL);
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C), nullptr);
break;
case B_STOPANIM:
WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, NULL, NULL);
WM_operator_name_call(C, "SCREEN_OT_animation_play", WM_OP_INVOKE_SCREEN, nullptr, nullptr);
break;
case B_STOPCOMPO:
WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL);
WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), nullptr);
break;
case B_STOPSEQ:
WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL);
WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), nullptr);
break;
case B_STOPCLIP:
WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL);
WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), nullptr);
break;
case B_STOPFILE:
WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), NULL);
WM_jobs_stop(CTX_wm_manager(C), CTX_data_scene(C), nullptr);
break;
case B_STOPOTHER:
G.is_break = true;
@@ -6048,9 +6091,9 @@ struct ProgressTooltip_Store {
void *owner;
};
static char *progress_tooltip_func(bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
static char *progress_tooltip_func(bContext * /*C*/, void *argN, const char * /*tip*/)
{
struct ProgressTooltip_Store *arg = argN;
ProgressTooltip_Store *arg = static_cast<ProgressTooltip_Store *>(argN);
wmWindowManager *wm = arg->wm;
void *owner = arg->owner;
@@ -6079,13 +6122,13 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *area = CTX_wm_area(C);
void *owner = NULL;
void *owner = nullptr;
int handle_event, icon = 0;
uiBlock *block = uiLayoutGetBlock(layout);
UI_block_layout_set_current(block, layout);
UI_block_func_handle_set(block, do_running_jobs, NULL);
UI_block_func_handle_set(block, do_running_jobs, nullptr);
/* another scene can be rendering too, for example via compositor */
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
@@ -6194,7 +6237,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
/* get percentage done and set it as the UI text */
const float progress = WM_jobs_progress(wm, owner);
char text[8];
BLI_snprintf(text, 8, "%d%%", (int)(progress * 100));
BLI_snprintf(text, 8, "%d%%", int(progress * 100));
const char *name = active ? WM_jobs_name(wm, owner) : "Canceling...";
@@ -6209,7 +6252,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
0,
textwidth + UI_UNIT_X * 1.5f,
UI_UNIT_Y,
NULL,
nullptr,
0.0f,
0.0f,
0.0f,
@@ -6222,7 +6265,8 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
block = uiLayoutGetBlock(row);
{
struct ProgressTooltip_Store *tip_arg = MEM_mallocN(sizeof(*tip_arg), __func__);
ProgressTooltip_Store *tip_arg = static_cast<ProgressTooltip_Store *>(
MEM_mallocN(sizeof(*tip_arg), __func__));
tip_arg->wm = wm;
tip_arg->owner = owner;
uiButProgressbar *but_progress = (uiButProgressbar *)uiDefIconTextBut(block,
@@ -6234,12 +6278,12 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
0,
UI_UNIT_X * 6.0f,
UI_UNIT_Y,
NULL,
nullptr,
0.0f,
0.0f,
0.0f,
0,
NULL);
nullptr);
but_progress->progress = progress;
UI_but_func_tooltip_set(&but_progress->but, progress_tooltip_func, tip_arg, MEM_freeN);
@@ -6255,7 +6299,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL,
nullptr,
0.0f,
0.0f,
0,
@@ -6274,7 +6318,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
0,
UI_UNIT_X * 5.0f,
UI_UNIT_Y,
NULL,
nullptr,
0.0f,
0.0f,
0,
@@ -6314,7 +6358,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
UI_fontstyle_set(&style->widgetlabel);
int width = BLF_width(style->widgetlabel.uifont_id, report->message, report->len);
width = min_ii((int)(rti->widthfac * width), width);
width = min_ii(int(rti->widthfac * width), width);
width = max_ii(width, 10 * UI_DPI_FAC);
UI_block_align_begin(block);
@@ -6328,7 +6372,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
0,
UI_UNIT_X + (6 * UI_DPI_FAC),
UI_UNIT_Y,
NULL,
nullptr,
0.0f,
0.0f,
0,
@@ -6346,7 +6390,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
0,
UI_UNIT_X + width,
UI_UNIT_Y,
NULL,
nullptr,
0.0f,
0.0f,
0,
@@ -6389,7 +6433,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
UI_block_emboss_set(block, previous_emboss);
}
void uiTemplateInputStatus(uiLayout *layout, struct bContext *C)
void uiTemplateInputStatus(uiLayout *layout, bContext *C)
{
wmWindow *win = CTX_wm_window(C);
WorkSpace *workspace = CTX_wm_workspace(C);
@@ -6416,7 +6460,7 @@ void uiTemplateInputStatus(uiLayout *layout, struct bContext *C)
const char *msg_drag = CTX_TIP_(BLT_I18NCONTEXT_OPERATOR_DEFAULT,
WM_window_cursor_keymap_status_get(win, i, 1));
if (msg || (msg_drag == NULL)) {
if (msg || (msg_drag == nullptr)) {
uiItemL(row, msg ? msg : "", (ICON_MOUSE_LMB + i));
}
@@ -6436,10 +6480,10 @@ void uiTemplateInputStatus(uiLayout *layout, struct bContext *C)
/** \name Keymap Template
* \{ */
static void keymap_item_modified(bContext *UNUSED(C), void *kmi_p, void *UNUSED(unused))
static void keymap_item_modified(bContext * /*C*/, void *kmi_p, void * /*unused*/)
{
wmKeyMapItem *kmi = (wmKeyMapItem *)kmi_p;
WM_keyconfig_update_tag(NULL, kmi);
WM_keyconfig_update_tag(nullptr, kmi);
}
static void template_keymap_item_properties(uiLayout *layout, const char *title, PointerRNA *ptr)
@@ -6472,7 +6516,7 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title,
uiLayout *row = uiLayoutRow(box, false);
/* property value */
uiItemFullR(row, ptr, prop, -1, 0, 0, NULL, ICON_NONE);
uiItemFullR(row, ptr, prop, -1, 0, 0, nullptr, ICON_NONE);
if (is_set) {
/* unset operator */
@@ -6487,7 +6531,7 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title,
0,
UI_UNIT_X,
UI_UNIT_Y,
NULL);
nullptr);
but->rnapoin = *ptr;
but->rnaprop = prop;
UI_block_emboss_set(block, UI_EMBOSS);
@@ -6501,17 +6545,17 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
PointerRNA propptr = RNA_pointer_get(ptr, "properties");
if (propptr.data) {
uiBut *but = uiLayoutGetBlock(layout)->buttons.last;
uiBut *but = static_cast<uiBut *>(uiLayoutGetBlock(layout)->buttons.last);
WM_operator_properties_sanitize(&propptr, false);
template_keymap_item_properties(layout, NULL, &propptr);
template_keymap_item_properties(layout, nullptr, &propptr);
/* attach callbacks to compensate for missing properties update,
* we don't know which keymap (item) is being modified there */
for (; but; but = but->next) {
/* operator buttons may store props for use (file selector, T36492) */
if (but->rnaprop) {
UI_but_func_set(but, keymap_item_modified, ptr->data, NULL);
UI_but_func_set(but, keymap_item_modified, ptr->data, nullptr);
/* Otherwise the keymap will be re-generated which we're trying to edit,
* see: T47685 */
@@ -6527,9 +6571,9 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
/** \name Event Icon Template
* \{ */
bool uiTemplateEventFromKeymapItem(struct uiLayout *layout,
bool uiTemplateEventFromKeymapItem(uiLayout *layout,
const char *text,
const struct wmKeyMapItem *kmi,
const wmKeyMapItem *kmi,
bool text_fallback)
{
bool ok = false;
@@ -6578,7 +6622,7 @@ void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char
}
void uiTemplateColormanagedViewSettings(uiLayout *layout,
bContext *UNUSED(C),
bContext * /*C*/,
PointerRNA *ptr,
const char *propname)
{
@@ -6591,18 +6635,19 @@ void uiTemplateColormanagedViewSettings(uiLayout *layout,
}
PointerRNA view_transform_ptr = RNA_property_pointer_get(ptr, prop);
ColorManagedViewSettings *view_settings = view_transform_ptr.data;
ColorManagedViewSettings *view_settings = static_cast<ColorManagedViewSettings *>(
view_transform_ptr.data);
uiLayout *col = uiLayoutColumn(layout, false);
uiItemR(col, &view_transform_ptr, "view_transform", 0, IFACE_("View"), ICON_NONE);
uiItemR(col, &view_transform_ptr, "look", 0, IFACE_("Look"), ICON_NONE);
col = uiLayoutColumn(layout, false);
uiItemR(col, &view_transform_ptr, "exposure", 0, NULL, ICON_NONE);
uiItemR(col, &view_transform_ptr, "gamma", 0, NULL, ICON_NONE);
uiItemR(col, &view_transform_ptr, "exposure", 0, nullptr, ICON_NONE);
uiItemR(col, &view_transform_ptr, "gamma", 0, nullptr, ICON_NONE);
col = uiLayoutColumn(layout, false);
uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, NULL, ICON_NONE);
uiItemR(col, &view_transform_ptr, "use_curve_mapping", 0, nullptr, ICON_NONE);
if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) {
uiTemplateCurveMapping(
col, &view_transform_ptr, "curve_mapping", 'c', true, false, false, false);
@@ -6615,10 +6660,10 @@ void uiTemplateColormanagedViewSettings(uiLayout *layout,
/** \name Component Menu
* \{ */
typedef struct ComponentMenuArgs {
struct ComponentMenuArgs {
PointerRNA ptr;
char propname[64]; /* XXX arbitrary */
} ComponentMenuArgs;
};
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
static uiBlock *component_menu(bContext *C, ARegion *region, void *args_v)
{
@@ -6650,7 +6695,7 @@ void uiTemplateComponentMenu(uiLayout *layout,
const char *propname,
const char *name)
{
ComponentMenuArgs *args = MEM_callocN(sizeof(ComponentMenuArgs), "component menu template args");
ComponentMenuArgs *args = MEM_cnew<ComponentMenuArgs>(__func__);
args->ptr = *ptr;
BLI_strncpy(args->propname, propname, sizeof(args->propname));
@@ -6674,7 +6719,7 @@ void uiTemplateComponentMenu(uiLayout *layout,
/** \name Node Socket Icon Template
* \{ */
void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float color[4])
void uiTemplateNodeSocket(uiLayout *layout, bContext * /*C*/, float color[4])
{
uiBlock *block = uiLayoutGetBlock(layout);
UI_block_align_begin(block);
@@ -6684,7 +6729,7 @@ void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float color[4])
* but this requires a better design for extendable color palettes in user prefs.
*/
uiBut *but = uiDefBut(
block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, nullptr, 0, 0, 0, 0, "");
rgba_float_to_uchar(but->col, color);
UI_block_align_end(block);
@@ -6705,8 +6750,8 @@ void uiTemplateCacheFileVelocity(uiLayout *layout, PointerRNA *fileptr)
/* Ensure that the context has a CacheFile as this may not be set inside of modifiers panels. */
uiLayoutSetContextPointer(layout, "edit_cachefile", fileptr);
uiItemR(layout, fileptr, "velocity_name", 0, NULL, ICON_NONE);
uiItemR(layout, fileptr, "velocity_unit", 0, NULL, ICON_NONE);
uiItemR(layout, fileptr, "velocity_name", 0, nullptr, ICON_NONE);
uiItemR(layout, fileptr, "velocity_unit", 0, nullptr, ICON_NONE);
}
void uiTemplateCacheFileProcedural(uiLayout *layout, const bContext *C, PointerRNA *fileptr)
@@ -6721,7 +6766,7 @@ void uiTemplateCacheFileProcedural(uiLayout *layout, const bContext *C, PointerR
uiLayout *row, *sub;
/* Only enable render procedural option if the active engine supports it. */
const struct RenderEngineType *engine_type = CTX_data_engine_type(C);
const RenderEngineType *engine_type = CTX_data_engine_type(C);
Scene *scene = CTX_data_scene(C);
const bool engine_supports_procedural = RE_engine_supports_alembic_procedural(engine_type,
@@ -6745,18 +6790,18 @@ void uiTemplateCacheFileProcedural(uiLayout *layout, const bContext *C, PointerR
row = uiLayoutRow(layout, false);
uiLayoutSetActive(row, engine_supports_procedural);
uiItemR(row, fileptr, "use_render_procedural", 0, NULL, ICON_NONE);
uiItemR(row, fileptr, "use_render_procedural", 0, nullptr, ICON_NONE);
const bool use_render_procedural = RNA_boolean_get(fileptr, "use_render_procedural");
const bool use_prefetch = RNA_boolean_get(fileptr, "use_prefetch");
row = uiLayoutRow(layout, false);
uiLayoutSetEnabled(row, use_render_procedural);
uiItemR(row, fileptr, "use_prefetch", 0, NULL, ICON_NONE);
uiItemR(row, fileptr, "use_prefetch", 0, nullptr, ICON_NONE);
sub = uiLayoutRow(layout, false);
uiLayoutSetEnabled(sub, use_prefetch && use_render_procedural);
uiItemR(sub, fileptr, "prefetch_cache_size", 0, NULL, ICON_NONE);
uiItemR(sub, fileptr, "prefetch_cache_size", 0, nullptr, ICON_NONE);
}
void uiTemplateCacheFileTimeSettings(uiLayout *layout, PointerRNA *fileptr)
@@ -6771,7 +6816,7 @@ void uiTemplateCacheFileTimeSettings(uiLayout *layout, PointerRNA *fileptr)
uiLayout *row, *sub, *subsub;
row = uiLayoutRow(layout, false);
uiItemR(row, fileptr, "is_sequence", 0, NULL, ICON_NONE);
uiItemR(row, fileptr, "is_sequence", 0, nullptr, ICON_NONE);
row = uiLayoutRowWithHeading(layout, true, IFACE_("Override Frame"));
sub = uiLayoutRow(row, true);
@@ -6783,20 +6828,20 @@ void uiTemplateCacheFileTimeSettings(uiLayout *layout, PointerRNA *fileptr)
uiItemDecoratorR(row, fileptr, "frame", 0);
row = uiLayoutRow(layout, false);
uiItemR(row, fileptr, "frame_offset", 0, NULL, ICON_NONE);
uiItemR(row, fileptr, "frame_offset", 0, nullptr, ICON_NONE);
uiLayoutSetActive(row, !RNA_boolean_get(fileptr, "is_sequence"));
}
static void cache_file_layer_item(uiList *UNUSED(ui_list),
const bContext *UNUSED(C),
static void cache_file_layer_item(uiList * /*ui_list*/,
const bContext * /*C*/,
uiLayout *layout,
PointerRNA *UNUSED(dataptr),
PointerRNA * /*dataptr*/,
PointerRNA *itemptr,
int UNUSED(icon),
PointerRNA *UNUSED(active_dataptr),
const char *UNUSED(active_propname),
int UNUSED(index),
int UNUSED(flt_flag))
int /*icon*/,
PointerRNA * /*active_dataptr*/,
const char * /*active_propname*/,
int /*index*/,
int /*flt_flag*/)
{
uiLayout *row = uiLayoutRow(layout, true);
uiItemR(row, itemptr, "hide_layer", UI_ITEM_R_NO_BG, "", ICON_NONE);
@@ -6844,7 +6889,7 @@ void uiTemplateCacheFileLayers(uiLayout *layout, const bContext *C, PointerRNA *
uiItemO(col, "", ICON_ADD, "cachefile.layer_add");
uiItemO(col, "", ICON_REMOVE, "cachefile.layer_remove");
CacheFile *file = fileptr->data;
CacheFile *file = static_cast<CacheFile *>(fileptr->data);
if (BLI_listbase_count(&file->layers) > 1) {
uiItemS_ex(col, 1.0f);
uiItemO(col, "", ICON_TRIA_UP, "cachefile.layer_move");
@@ -6888,7 +6933,7 @@ void uiTemplateCacheFile(uiLayout *layout,
return;
}
CacheFile *file = fileptr.data;
CacheFile *file = static_cast<CacheFile *>(fileptr.data);
uiLayoutSetContextPointer(layout, "edit_cachefile", &fileptr);
@@ -6896,12 +6941,12 @@ void uiTemplateCacheFile(uiLayout *layout,
C,
ptr,
propname,
NULL,
nullptr,
"CACHEFILE_OT_open",
NULL,
nullptr,
UI_TEMPLATE_ID_FILTER_ALL,
false,
NULL);
nullptr);
if (!file) {
return;
@@ -6914,7 +6959,7 @@ void uiTemplateCacheFile(uiLayout *layout,
uiLayoutSetPropSep(layout, true);
row = uiLayoutRow(layout, true);
uiItemR(row, &fileptr, "filepath", 0, NULL, ICON_NONE);
uiItemR(row, &fileptr, "filepath", 0, nullptr, ICON_NONE);
sub = uiLayoutRow(row, true);
uiItemO(sub, "", ICON_FILE_REFRESH, "cachefile.reload");
@@ -6953,7 +6998,7 @@ int uiTemplateRecentFiles(uiLayout *layout, int rows)
"WM_OT_open_mainfile",
filename,
BLO_has_bfile_extension(filename) ? ICON_FILE_BLEND : ICON_FILE_BACKUP,
NULL,
nullptr,
WM_OP_INVOKE_DEFAULT,
0,
&ptr);

View File

@@ -5,9 +5,9 @@
* \ingroup edinterface
*/
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <climits>
#include <cstdlib>
#include <cstring>
#include "DNA_brush_types.h"
#include "DNA_screen_types.h"
@@ -55,7 +55,7 @@
/* visual types for drawing */
/* for time being separated from functional types */
typedef enum {
enum uiWidgetTypeEnum {
/* default */
UI_WTYPE_REGULAR,
@@ -105,12 +105,12 @@ typedef enum {
UI_WTYPE_PROGRESSBAR,
UI_WTYPE_NODESOCKET,
UI_WTYPE_VIEW_ITEM,
} uiWidgetTypeEnum;
};
/**
* The button's state information adapted for drawing. Use #STATE_INFO_NULL for empty state.
*/
typedef struct {
struct uiWidgetStateInfo {
/** Copy of #uiBut.flag (possibly with overrides for drawing). */
int but_flag;
/** Copy of #uiBut.drawflag (possibly with overrides for drawing). */
@@ -120,7 +120,7 @@ typedef struct {
bool has_hold_action : 1;
/** The button is in text input mode. */
bool is_text_input : 1;
} uiWidgetStateInfo;
};
static const uiWidgetStateInfo STATE_INFO_NULL = {0};
@@ -212,22 +212,21 @@ static void color_mul_hsl_v3(uchar ch[3], float h_factor, float s_factor, float
/* fill this struct with polygon info to draw AA'ed */
/* it has outline, back, and two optional tria meshes */
typedef struct uiWidgetTrias {
struct uiWidgetTrias {
uint tot;
int type;
float size, center[2];
float vec[16][2];
const uint (*index)[3];
} uiWidgetTrias;
};
/* max as used by round_box__edges */
/* Make sure to change widget_base_vert.glsl accordingly. */
#define WIDGET_CURVE_RESOLU 9
#define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU * 4)
typedef struct uiWidgetBase {
struct uiWidgetBase {
/* TODO: remove these completely. */
int totvert, halfwayvert;
float outer_v[WIDGET_SIZE_MAX][2];
@@ -241,13 +240,13 @@ typedef struct uiWidgetBase {
/* Widget shader parameters, must match the shader layout. */
uiWidgetBaseParameters uniform_params;
} uiWidgetBase;
};
/**
* For time being only for visual appearance,
* later, a handling callback can be added too.
*/
typedef struct uiWidgetType {
struct uiWidgetType {
/* pointer to theme color definition */
const uiWidgetColors *wcol_theme;
@@ -272,8 +271,7 @@ typedef struct uiWidgetType {
void (*draw_block)(
uiWidgetColors *, rcti *, int block_flag, int roundboxalign, const float zoom);
void (*text)(const uiFontStyle *, const uiWidgetColors *, uiBut *, rcti *);
} uiWidgetType;
};
/** \} */
@@ -424,7 +422,7 @@ static GPUVertFormat *vflag_format(void)
static void set_roundbox_vertex_data(GPUVertBufRaw *vflag_step, uint32_t d)
{
uint32_t *data = GPU_vertbuf_raw_step(vflag_step);
uint32_t *data = static_cast<uint32_t *>(GPU_vertbuf_raw_step(vflag_step));
*data = d;
}
@@ -436,7 +434,7 @@ static uint32_t set_roundbox_vertex(GPUVertBufRaw *vflag_step,
bool emboss,
int color)
{
uint32_t *data = GPU_vertbuf_raw_step(vflag_step);
uint32_t *data = static_cast<uint32_t *>(GPU_vertbuf_raw_step(vflag_step));
*data = corner_id;
*data |= corner_v << 2;
*data |= jit_v << 6;
@@ -448,7 +446,7 @@ static uint32_t set_roundbox_vertex(GPUVertBufRaw *vflag_step,
GPUBatch *ui_batch_roundbox_widget_get(void)
{
if (g_ui_batch_cache.roundbox_widget == NULL) {
if (g_ui_batch_cache.roundbox_widget == nullptr) {
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format());
GPU_vertbuf_data_alloc(vbo, 12);
@@ -474,7 +472,7 @@ GPUBatch *ui_batch_roundbox_widget_get(void)
GPUBatch *ui_batch_roundbox_shadow_get(void)
{
if (g_ui_batch_cache.roundbox_shadow == NULL) {
if (g_ui_batch_cache.roundbox_shadow == nullptr) {
uint32_t last_data;
GPUVertBufRaw vflag_step;
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format());
@@ -502,7 +500,7 @@ GPUBatch *ui_batch_roundbox_shadow_get(void)
}
}
g_ui_batch_cache.roundbox_shadow = GPU_batch_create_ex(
GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO);
GPU_PRIM_TRI_STRIP, vbo, nullptr, GPU_BATCH_OWNS_VBO);
gpu_batch_presets_register(g_ui_batch_cache.roundbox_shadow);
}
return g_ui_batch_cache.roundbox_shadow;
@@ -971,7 +969,7 @@ static void shape_preset_init_scroll_circle(uiWidgetTrias *tria,
static void widget_draw_vertex_buffer(uint pos,
uint col,
int mode,
GPUPrimType mode,
const float quads_pos[WIDGET_SIZE_MAX][2],
const uchar quads_col[WIDGET_SIZE_MAX][4],
uint totvert)
@@ -1073,7 +1071,7 @@ static void widgetbase_outline(uiWidgetBase *wtb, uint pos)
widget_verts_to_triangle_strip(wtb, wtb->totvert, triangle_strip);
widget_draw_vertex_buffer(
pos, 0, GPU_PRIM_TRI_STRIP, triangle_strip, NULL, wtb->totvert * 2 + 2);
pos, 0, GPU_PRIM_TRI_STRIP, triangle_strip, nullptr, wtb->totvert * 2 + 2);
}
static void widgetbase_set_uniform_alpha_discard(uiWidgetBase *wtb,
@@ -1502,7 +1500,8 @@ static void ui_text_clip_right_ex(const uiFontStyle *fstyle,
BLI_assert(str[0]);
/* How many BYTES (not characters) of this utf-8 string can fit, along with appended ellipsis. */
int l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth - sep_strwidth, NULL);
int l_end = BLF_width_to_strlen(
fstyle->uifont_id, str, max_len, okwidth - sep_strwidth, nullptr);
if (l_end > 0) {
/* At least one character, so clip and add the ellipsis. */
@@ -1513,7 +1512,7 @@ static void ui_text_clip_right_ex(const uiFontStyle *fstyle,
}
else {
/* Otherwise fit as much as we can without adding an ellipsis. */
l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth, NULL);
l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth, nullptr);
str[l_end] = '\0';
if (r_final_len) {
*r_final_len = (size_t)l_end;
@@ -1541,7 +1540,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
const int sep_len = sizeof(sep) - 1;
const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 1);
char *rpart = NULL, rpart_buf[UI_MAX_DRAW_STR];
char *rpart = nullptr, rpart_buf[UI_MAX_DRAW_STR];
float rpart_width = 0.0f;
size_t rpart_len = 0;
size_t final_lpart_len;
@@ -1559,7 +1558,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
/* Not enough place for actual label, just display protected right part.
* Here just for safety, should never happen in real life! */
memmove(str, rpart, rpart_len + 1);
rpart = NULL;
rpart = nullptr;
okwidth += rpart_width;
strwidth = rpart_width;
}
@@ -1575,7 +1574,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
}
const size_t l_end = BLF_width_to_strlen(
fstyle->uifont_id, str, max_len, parts_strwidth, NULL);
fstyle->uifont_id, str, max_len, parts_strwidth, nullptr);
if (l_end < 10 || min_ff(parts_strwidth, strwidth - okwidth) < minwidth) {
/* If we really have no place, or we would clip a very small piece of string in the middle,
* only show start of string.
@@ -1586,7 +1585,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
else {
size_t r_offset, r_len;
r_offset = BLF_width_to_rstrlen(fstyle->uifont_id, str, max_len, parts_strwidth, NULL);
r_offset = BLF_width_to_rstrlen(fstyle->uifont_id, str, max_len, parts_strwidth, nullptr);
r_len = strlen(str + r_offset) + 1; /* +1 for the trailing '\0'. */
if (l_end + sep_len + r_len + rpart_len > max_len) {
@@ -1869,7 +1868,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
{
int drawstr_left_len = UI_MAX_DRAW_STR;
const char *drawstr = but->drawstr;
const char *drawstr_right = NULL;
const char *drawstr_right = nullptr;
bool use_right_only = false;
#ifdef WITH_INPUT_IME
@@ -1901,7 +1900,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
else {
if (but->editstr) {
/* max length isn't used in this case,
* we rely on string being NULL terminated. */
* we rely on string being nullptr terminated. */
drawstr_left_len = INT_MAX;
#ifdef WITH_INPUT_IME
@@ -2058,7 +2057,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
bool use_drawstr_right_as_hint = false;
/* cut string in 2 parts - only for menu entries */
if (but->flag & UI_BUT_HAS_SEP_CHAR && (but->editstr == NULL)) {
if (but->flag & UI_BUT_HAS_SEP_CHAR && (but->editstr == nullptr)) {
drawstr_right = strrchr(drawstr, UI_SEP_CHAR);
if (drawstr_right) {
use_drawstr_right_as_hint = true;
@@ -2071,7 +2070,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
if (!drawstr_right && (but->drawflag & UI_BUT_TEXT_LEFT) &&
ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) &&
/* if we're editing or multi-drag (fake editing), then use left alignment */
(but->editstr == NULL) && (drawstr == but->drawstr)) {
(but->editstr == nullptr) && (drawstr == but->drawstr)) {
drawstr_right = strrchr(drawstr + but->ofs, ':');
if (drawstr_right) {
drawstr_right++;
@@ -2097,17 +2096,17 @@ static void widget_draw_text(const uiFontStyle *fstyle,
(drawstr_left_len - but->ofs);
if (drawlen > 0) {
uiFontStyleDraw_Params params{};
params.align = align;
UI_fontstyle_draw_ex(fstyle,
rect,
drawstr + but->ofs,
drawlen,
wcol->text,
&(struct uiFontStyleDraw_Params){
.align = align,
},
&params,
&font_xofs,
&font_yofs,
NULL);
nullptr);
if (but->menu_key != '\0') {
const char *drawstr_ofs = drawstr + but->ofs;
@@ -2116,10 +2115,10 @@ static void widget_draw_text(const uiFontStyle *fstyle,
{
/* Find upper case, fallback to lower case. */
const char *drawstr_end = drawstr_ofs + drawlen;
const char keys[] = {but->menu_key - 32, but->menu_key};
const char keys[] = {char(but->menu_key - 32), but->menu_key};
for (int i = 0; i < ARRAY_SIZE(keys); i++) {
const char *drawstr_menu = strchr(drawstr_ofs, keys[i]);
if (drawstr_menu != NULL && drawstr_menu < drawstr_end) {
if (drawstr_menu != nullptr && drawstr_menu < drawstr_end) {
ul_index = (int)(drawstr_menu - drawstr_ofs);
break;
}
@@ -2153,14 +2152,9 @@ static void widget_draw_text(const uiFontStyle *fstyle,
}
rect->xmax -= UI_TEXT_CLIP_MARGIN;
UI_fontstyle_draw(fstyle,
rect,
drawstr_right,
UI_MAX_DRAW_STR,
col,
&(struct uiFontStyleDraw_Params){
.align = UI_STYLE_TEXT_RIGHT,
});
uiFontStyleDraw_Params params{};
params.align = UI_STYLE_TEXT_RIGHT;
UI_fontstyle_draw(fstyle, rect, drawstr_right, UI_MAX_DRAW_STR, col, &params);
}
}
@@ -2219,7 +2213,7 @@ static void widget_draw_node_link_socket(const uiWidgetColors *wcol,
UI_widgetbase_draw_cache_flush();
GPU_blend(GPU_BLEND_NONE);
ED_node_socket_draw(but->custom_data, rect, col, scale);
ED_node_socket_draw(static_cast<bNodeSocket *>(but->custom_data), rect, col, scale);
}
else {
widget_draw_icon(but, ICON_LAYER_USED, alpha, rect, wcol->text);
@@ -2263,7 +2257,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
/* Big previews with optional text label below */
if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) {
const BIFIconID icon = ui_but_icon(but);
const BIFIconID icon = BIFIconID(ui_but_icon(but));
int icon_size = BLI_rcti_size_y(rect);
int text_size = 0;
@@ -2300,7 +2294,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
}
#endif
const BIFIconID icon = ui_but_icon(but);
const BIFIconID icon = BIFIconID(ui_but_icon(but));
const int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT;
const float icon_size = icon_size_init / (but->block->aspect * U.inv_dpi_fac);
const float icon_padding = 2 * UI_DPI_FAC;
@@ -2350,7 +2344,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
rect->xmin += text_padding;
}
else if (but->flag & UI_BUT_DRAG_MULTI) {
const bool text_is_edited = ui_but_drag_multi_edit_get(but) != NULL;
const bool text_is_edited = ui_but_drag_multi_edit_get(but) != nullptr;
if (text_is_edited || (but->drawflag & UI_BUT_TEXT_LEFT)) {
rect->xmin += text_padding;
}
@@ -2456,7 +2450,7 @@ static const uchar *widget_color_blend_from_flags(const uiWidgetStateColors *wco
{
/* Explicitly require #UI_EMBOSS_NONE_OR_STATUS for color blending with no emboss. */
if (emboss == UI_EMBOSS_NONE) {
return NULL;
return nullptr;
}
if (state->but_drawflag & UI_BUT_ANIMATED_CHANGED) {
@@ -2474,7 +2468,7 @@ static const uchar *widget_color_blend_from_flags(const uiWidgetStateColors *wco
if (state->but_flag & UI_BUT_OVERRIDDEN) {
return wcol_state->inner_overridden_sel;
}
return NULL;
return nullptr;
}
/* copy colors from theme, and set changes in it based on state */
@@ -2498,7 +2492,7 @@ static void widget_state(uiWidgetType *wt, const uiWidgetStateInfo *state, eUIEm
if (state->but_flag & UI_SELECT) {
copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel);
if (color_blend != NULL) {
if (color_blend != nullptr) {
color_blend_v3_v3(wt->wcol.inner, color_blend, wcol_state->blend);
}
@@ -2513,7 +2507,7 @@ static void widget_state(uiWidgetType *wt, const uiWidgetStateInfo *state, eUIEm
copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel);
copy_v4_v4_uchar(wt->wcol.text, wt->wcol.text_sel);
}
if (color_blend != NULL) {
if (color_blend != nullptr) {
color_blend_v3_v3(wt->wcol.inner, color_blend, wcol_state->blend);
}
@@ -2587,7 +2581,7 @@ static void widget_state_numslider(uiWidgetType *wt,
widget_state(wt, state, emboss);
const uchar *color_blend = widget_color_blend_from_flags(wcol_state, state, emboss);
if (color_blend != NULL) {
if (color_blend != nullptr) {
/* Set the slider 'item' so that it reflects state settings too.
* De-saturate so the color of the slider doesn't conflict with the blend color,
* which can make the color hard to see when the slider is set to full (see T66102). */
@@ -2622,16 +2616,16 @@ static void widget_state_option_menu(uiWidgetType *wt,
}
static void widget_state_nothing(uiWidgetType *wt,
const uiWidgetStateInfo *UNUSED(state),
eUIEmbossType UNUSED(emboss))
const uiWidgetStateInfo * /*state*/,
eUIEmbossType /*emboss*/)
{
wt->wcol = *(wt->wcol_theme);
}
/* special case, button that calls pulldown */
static void widget_state_pulldown(uiWidgetType *wt,
const uiWidgetStateInfo *UNUSED(state),
eUIEmbossType UNUSED(emboss))
const uiWidgetStateInfo * /*state*/,
eUIEmbossType /*emboss*/)
{
wt->wcol = *(wt->wcol_theme);
}
@@ -2639,7 +2633,7 @@ static void widget_state_pulldown(uiWidgetType *wt,
/* special case, pie menu items */
static void widget_state_pie_menu_item(uiWidgetType *wt,
const uiWidgetStateInfo *state,
eUIEmbossType UNUSED(emboss))
eUIEmbossType /*emboss*/)
{
wt->wcol = *(wt->wcol_theme);
@@ -2673,7 +2667,7 @@ static void widget_state_pie_menu_item(uiWidgetType *wt,
/* special case, menu items */
static void widget_state_menu_item(uiWidgetType *wt,
const uiWidgetStateInfo *state,
eUIEmbossType UNUSED(emboss))
eUIEmbossType /*emboss*/)
{
wt->wcol = *(wt->wcol_theme);
@@ -2754,7 +2748,7 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
widget_verts_to_triangle_strip(&wtb, totvert, triangle_strip);
widget_draw_vertex_buffer(pos, 0, GPU_PRIM_TRI_STRIP, triangle_strip, NULL, totvert * 2);
widget_draw_vertex_buffer(pos, 0, GPU_PRIM_TRI_STRIP, triangle_strip, nullptr, totvert * 2);
}
immUnbindProgram();
@@ -2861,7 +2855,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const
const float centy = BLI_rcti_cent_y_fl(rect);
const float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f;
ColorPicker *cpicker = but->custom_data;
ColorPicker *cpicker = static_cast<ColorPicker *>(but->custom_data);
float rgb[3], hsv[3], rgb_center[3];
const bool is_color_gamma = ui_but_is_color_gamma(but);
@@ -3171,7 +3165,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect)
const uiButHSVCube *hsv_but = (uiButHSVCube *)but;
float rgb[3];
float x = 0.0f, y = 0.0f;
ColorPicker *cpicker = but->custom_data;
ColorPicker *cpicker = static_cast<ColorPicker *>(but->custom_data);
float *hsv = cpicker->hsv_perceptual;
float hsv_n[3];
@@ -3235,14 +3229,19 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect)
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
/* setup temp colors */
widgetbase_draw(&wtb,
&((uiWidgetColors){
.outline = {0, 0, 0, 255},
.inner = {128, 128, 128, 255},
.shadetop = 127,
.shadedown = -128,
.shaded = 1,
}));
uiWidgetColors colors{};
colors.outline[0] = 0;
colors.outline[1] = 0;
colors.outline[2] = 0;
colors.outline[3] = 255;
colors.inner[0] = 128;
colors.inner[1] = 128;
colors.inner[2] = 128;
colors.inner[3] = 255;
colors.shadetop = 127;
colors.shadedown = -128;
colors.shaded = 1;
widgetbase_draw(&wtb, &colors);
/* We are drawing on top of widget bases. Flush cache. */
GPU_blend(GPU_BLEND_ALPHA);
@@ -3411,7 +3410,7 @@ static void widget_numbut(uiWidgetColors *wcol,
static void widget_menubut(uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
const uiWidgetStateInfo * /*state*/,
int roundboxalign,
const float zoom)
{
@@ -3435,11 +3434,11 @@ static void widget_menubut(uiWidgetColors *wcol,
/**
* Draw menu buttons still with triangles when field is not embossed
*/
static void widget_menubut_embossn(const uiBut *UNUSED(but),
static void widget_menubut_embossn(const uiBut * /*but*/,
uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
int UNUSED(roundboxalign))
const uiWidgetStateInfo * /*state*/,
int /*roundboxalign*/)
{
uiWidgetBase wtb;
widget_init(&wtb);
@@ -3457,7 +3456,7 @@ static void widget_menubut_embossn(const uiBut *UNUSED(but),
/**
* Draw number buttons still with triangles when field is not embossed
*/
static void widget_numbut_embossn(const uiBut *UNUSED(but),
static void widget_numbut_embossn(const uiBut * /*but*/,
uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *state,
@@ -3548,8 +3547,8 @@ static void widget_scroll(uiBut *but,
uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *state,
int UNUSED(roundboxalign),
const float UNUSED(zoom))
int /*roundboxalign*/,
const float /*zoom*/)
{
/* calculate slider part */
const float value = (float)ui_but_value_get(but);
@@ -3603,7 +3602,7 @@ static void widget_scroll(uiBut *but,
static void widget_progressbar(uiBut *but,
uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
const uiWidgetStateInfo * /*state*/,
int roundboxalign,
const float zoom)
{
@@ -3638,7 +3637,7 @@ static void widget_progressbar(uiBut *but,
static void widget_view_item(uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *state,
int UNUSED(roundboxalign),
int /*roundboxalign*/,
const float zoom)
{
uiWidgetBase wtb;
@@ -3657,9 +3656,9 @@ static void widget_view_item(uiWidgetColors *wcol,
static void widget_nodesocket(uiBut *but,
uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
int UNUSED(roundboxalign),
const float UNUSED(zoom))
const uiWidgetStateInfo * /*state*/,
int /*roundboxalign*/,
const float /*zoom*/)
{
const int radi = 0.25f * BLI_rcti_size_y(rect);
@@ -3902,8 +3901,8 @@ static void widget_swatch(uiBut *but,
static void widget_unitvec(uiBut *but,
uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
int UNUSED(roundboxalign),
const uiWidgetStateInfo * /*state*/,
int /*roundboxalign*/,
const float zoom)
{
const float rad = widget_radius_from_zoom(zoom, wcol);
@@ -3961,9 +3960,9 @@ static void widget_textbut(uiWidgetColors *wcol,
static void widget_preview_tile(uiBut *but,
uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
int UNUSED(roundboxalign),
const float UNUSED(zoom))
const uiWidgetStateInfo * /*state*/,
int /*roundboxalign*/,
const float /*zoom*/)
{
const uiStyle *style = UI_style_get();
ui_draw_preview_item_stateless(
@@ -3972,7 +3971,7 @@ static void widget_preview_tile(uiBut *but,
static void widget_menuiconbut(uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
const uiWidgetStateInfo * /*state*/,
int roundboxalign,
const float zoom)
{
@@ -4020,8 +4019,8 @@ static void widget_pulldownbut(uiWidgetColors *wcol,
static void widget_menu_itembut(uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
int UNUSED(roundboxalign),
const uiWidgetStateInfo * /*state*/,
int /*roundboxalign*/,
const float zoom)
{
uiWidgetBase wtb;
@@ -4044,8 +4043,8 @@ static void widget_menu_itembut(uiWidgetColors *wcol,
static void widget_menu_itembut_unpadded(uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
int UNUSED(roundboxalign),
const uiWidgetStateInfo * /*state*/,
int /*roundboxalign*/,
const float zoom)
{
/* This function is used for menu items placed close to each other horizontally, e.g. the matcap
@@ -4066,8 +4065,8 @@ static void widget_menu_itembut_unpadded(uiWidgetColors *wcol,
static void widget_menu_radial_itembut(uiBut *but,
uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
int UNUSED(roundboxalign),
const uiWidgetStateInfo * /*state*/,
int /*roundboxalign*/,
const float zoom)
{
const float fac = but->block->pie_data.alphafac;
@@ -4092,8 +4091,8 @@ static void widget_menu_radial_itembut(uiBut *but,
static void widget_list_itembut(uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
int UNUSED(roundboxalign),
const uiWidgetStateInfo * /*state*/,
int /*roundboxalign*/,
const float zoom)
{
uiWidgetBase wtb;
@@ -4110,8 +4109,8 @@ static void widget_list_itembut(uiWidgetColors *wcol,
static void widget_optionbut(uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *state,
int UNUSED(roundboxalign),
const float UNUSED(zoom))
int /*roundboxalign*/,
const float /*zoom*/)
{
/* For a right aligned layout (signified by #UI_BUT_TEXT_RIGHT), draw the text on the left of the
* checkbox. */
@@ -4187,7 +4186,7 @@ static void widget_state_label(uiWidgetType *wt,
static void widget_radiobut(uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
const uiWidgetStateInfo * /*state*/,
int roundboxalign,
const float zoom)
{
@@ -4203,7 +4202,7 @@ static void widget_radiobut(uiWidgetColors *wcol,
static void widget_box(uiBut *but,
uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
const uiWidgetStateInfo * /*state*/,
int roundboxalign,
const float zoom)
{
@@ -4214,7 +4213,7 @@ static void widget_box(uiBut *but,
copy_v3_v3_uchar(old_col, wcol->inner);
/* abuse but->hsv - if it's non-zero, use this color as the box's background */
if (but != NULL && but->col[3]) {
if (but != nullptr && but->col[3]) {
wcol->inner[0] = but->col[0];
wcol->inner[1] = but->col[1];
wcol->inner[2] = but->col[2];
@@ -4231,7 +4230,7 @@ static void widget_box(uiBut *but,
static void widget_but(uiWidgetColors *wcol,
rcti *rect,
const uiWidgetStateInfo *UNUSED(state),
const uiWidgetStateInfo * /*state*/,
int roundboxalign,
const float zoom)
{
@@ -4245,7 +4244,7 @@ static void widget_but(uiWidgetColors *wcol,
}
#if 0
static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int /*state*/ int roundboxalign)
{
uiWidgetBase wtb;
const float rad = wcol->roundness * U.widget_unit;
@@ -4382,7 +4381,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.wcol_state = &btheme->tui.wcol_state;
wt.state = widget_state;
wt.draw = widget_but;
wt.custom = NULL;
wt.custom = nullptr;
wt.text = widget_draw_text_icon;
switch (type) {
@@ -4390,7 +4389,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break;
case UI_WTYPE_LABEL:
wt.draw = NULL;
wt.draw = nullptr;
wt.state = widget_state_label;
break;
@@ -4507,9 +4506,9 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break;
case UI_WTYPE_PREVIEW_TILE:
wt.draw = NULL;
wt.draw = nullptr;
/* Drawn via the `custom` callback. */
wt.text = NULL;
wt.text = nullptr;
wt.custom = widget_preview_tile;
break;
@@ -4637,12 +4636,12 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
/** \name Public API
* \{ */
void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBut *but, rcti *rect)
void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but, rcti *rect)
{
bTheme *btheme = UI_GetTheme();
const ThemeUI *tui = &btheme->tui;
const uiFontStyle *fstyle = &style->widget;
uiWidgetType *wt = NULL;
uiWidgetType *wt = nullptr;
/* handle menus separately */
if (but->emboss == UI_EMBOSS_PULLDOWN) {
@@ -4908,7 +4907,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
}
}
if (wt == NULL) {
if (wt == nullptr) {
return;
}
@@ -4996,7 +4995,7 @@ static void ui_draw_clip_tri(uiBlock *block, rcti *rect, uiWidgetType *wt)
}
}
void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
void ui_draw_menu_back(uiStyle * /*style*/, uiBlock *block, rcti *rect)
{
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
@@ -5086,15 +5085,12 @@ static void ui_draw_popover_back_impl(const uiWidgetColors *wcol,
GPU_blend(GPU_BLEND_NONE);
}
void ui_draw_popover_back(struct ARegion *region,
uiStyle *UNUSED(style),
uiBlock *block,
rcti *rect)
void ui_draw_popover_back(ARegion *region, uiStyle * /*style*/, uiBlock *block, rcti *rect)
{
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
if (block) {
float mval_origin[2] = {UNPACK2(block->bounds_offset)};
float mval_origin[2] = {float(block->bounds_offset[0]), float(block->bounds_offset[1])};
ui_window_to_block_fl(region, block, &mval_origin[0], &mval_origin[1]);
ui_draw_popover_back_impl(
wt->wcol_theme, rect, block->direction, U.widget_unit / block->aspect, mval_origin);
@@ -5203,7 +5199,7 @@ void ui_draw_pie_center(uiBlock *block)
pie_radius_external,
subd,
btheme->tui.wcol_pie_menu.inner,
NULL,
nullptr,
false);
}
@@ -5231,7 +5227,7 @@ void ui_draw_pie_center(uiBlock *block)
pie_radius_external,
subd,
btheme->tui.wcol_pie_menu.inner_sel,
NULL,
nullptr,
false);
}
}
@@ -5259,7 +5255,7 @@ void ui_draw_pie_center(uiBlock *block)
pie_confirm_external,
subd,
col,
NULL,
nullptr,
false);
}
@@ -5312,10 +5308,10 @@ void ui_draw_widget_menu_back_color(const rcti *rect, bool use_shadow, const flo
void ui_draw_widget_menu_back(const rcti *rect, bool use_shadow)
{
ui_draw_widget_back_color(UI_WTYPE_MENU_BACK, use_shadow, rect, NULL);
ui_draw_widget_back_color(UI_WTYPE_MENU_BACK, use_shadow, rect, nullptr);
}
void ui_draw_tooltip_background(const uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect)
void ui_draw_tooltip_background(const uiStyle * /*style*/, uiBlock * /*block*/, rcti *rect)
{
uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
wt->state(wt, &STATE_INFO_NULL, UI_EMBOSS_UNDEFINED);
@@ -5336,7 +5332,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
const int row_height = BLI_rcti_size_y(rect);
int max_hint_width = INT_MAX;
int padding = 0.25f * row_height;
char *cpoin = NULL;
char *cpoin = nullptr;
uiWidgetStateInfo state = {0};
state.but_flag = but_flag;
@@ -5354,7 +5350,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
/* cut string in 2 parts? */
if (separator_type != UI_MENU_ITEM_SEPARATOR_NONE) {
cpoin = strrchr(name, UI_SEP_CHAR);
cpoin = const_cast<char *>(strrchr(name, UI_SEP_CHAR));
if (cpoin) {
*cpoin = 0;
@@ -5400,19 +5396,12 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
}
int xofs = 0, yofs = 0;
struct ResultBLF info;
UI_fontstyle_draw_ex(fstyle,
rect,
drawstr,
sizeof(drawstr),
wt->wcol.text,
&(struct uiFontStyleDraw_Params){
.align = UI_STYLE_TEXT_LEFT,
},
&xofs,
&yofs,
&info);
if (r_xmax != NULL) {
ResultBLF info;
uiFontStyleDraw_Params params{};
params.align = UI_STYLE_TEXT_LEFT;
UI_fontstyle_draw_ex(
fstyle, rect, drawstr, sizeof(drawstr), wt->wcol.text, &params, &xofs, &yofs, &info);
if (r_xmax != nullptr) {
*r_xmax = xofs + info.width;
}
}
@@ -5457,14 +5446,9 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
}
rect->xmax = _rect.xmax - 5;
UI_fontstyle_draw(fstyle,
rect,
hint_drawstr,
sizeof(hint_drawstr),
wt->wcol.text,
&(struct uiFontStyleDraw_Params){
.align = UI_STYLE_TEXT_RIGHT,
});
uiFontStyleDraw_Params params{};
params.align = UI_STYLE_TEXT_RIGHT;
UI_fontstyle_draw(fstyle, rect, hint_drawstr, sizeof(hint_drawstr), wt->wcol.text, &params);
*cpoin = UI_SEP_CHAR;
}
}
@@ -5487,7 +5471,7 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
rect->ymin += text_size;
}
GPU_blend(GPU_BLEND_ALPHA);
widget_draw_preview(iconid, 1.0f, rect);
widget_draw_preview(BIFIconID(iconid), 1.0f, rect);
GPU_blend(GPU_BLEND_NONE);
if (!has_text) {
@@ -5513,14 +5497,9 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
BLI_strncpy(drawstr, name, sizeof(drawstr));
UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');
UI_fontstyle_draw(fstyle,
&trect,
drawstr,
sizeof(drawstr),
text_col,
&(struct uiFontStyleDraw_Params){
.align = text_align,
});
uiFontStyleDraw_Params params{};
params.align = text_align;
UI_fontstyle_draw(fstyle, &trect, drawstr, sizeof(drawstr), text_col, &params);
}
}

View File

@@ -5,9 +5,9 @@
* \ingroup edinterface
*/
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
@@ -36,22 +36,19 @@
#include "GPU_framebuffer.h"
#include "interface_intern.h"
/* global for themes */
typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
/* be sure to keep 'bThemeState' in sync */
static struct bThemeState g_theme_state = {
NULL,
static bThemeState g_theme_state = {
nullptr,
SPACE_VIEW3D,
RGN_TYPE_WINDOW,
};
void ui_resources_init(void)
void ui_resources_init()
{
UI_icons_init();
}
void ui_resources_free(void)
void ui_resources_free()
{
UI_icons_free();
}
@@ -62,7 +59,7 @@ void ui_resources_free(void)
const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
{
ThemeSpace *ts = NULL;
ThemeSpace *ts = nullptr;
static uchar error[4] = {240, 0, 240, 255};
static uchar alert[4] = {240, 60, 60, 255};
static uchar header_active[4] = {0, 0, 0, 255};
@@ -230,7 +227,7 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp = ts->header;
break;
case TH_HEADER_ACTIVE:
case TH_HEADER_ACTIVE: {
cp = ts->header;
const int factor = 5;
/* Lighten the header color when editor is active. */
@@ -240,7 +237,7 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
header_active[3] = cp[3];
cp = header_active;
break;
}
case TH_HEADER_TEXT:
cp = ts->header_text;
break;
@@ -1021,12 +1018,13 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
return (const uchar *)cp;
}
void UI_theme_init_default(void)
void UI_theme_init_default()
{
/* we search for the theme with name Default */
bTheme *btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name));
if (btheme == NULL) {
btheme = MEM_callocN(sizeof(bTheme), __func__);
bTheme *btheme = static_cast<bTheme *>(
BLI_findstring(&U.themes, "Default", offsetof(bTheme, name)));
if (btheme == nullptr) {
btheme = MEM_cnew<bTheme>(__func__);
BLI_addtail(&U.themes, btheme);
}
@@ -1037,7 +1035,7 @@ void UI_theme_init_default(void)
btheme->active_theme_area = active_theme_area;
}
void UI_style_init_default(void)
void UI_style_init_default()
{
BLI_freelistN(&U.uistyles);
/* gets automatically re-allocated */
@@ -1048,34 +1046,34 @@ void UI_SetTheme(int spacetype, int regionid)
{
if (spacetype) {
/* later on, a local theme can be found too */
g_theme_state.theme = U.themes.first;
g_theme_state.theme = static_cast<bTheme *>(U.themes.first);
g_theme_state.spacetype = spacetype;
g_theme_state.regionid = regionid;
}
else if (regionid) {
/* popups */
g_theme_state.theme = U.themes.first;
g_theme_state.theme = static_cast<bTheme *>(U.themes.first);
g_theme_state.spacetype = SPACE_PROPERTIES;
g_theme_state.regionid = regionid;
}
else {
/* for safety, when theme was deleted */
g_theme_state.theme = U.themes.first;
g_theme_state.theme = static_cast<bTheme *>(U.themes.first);
g_theme_state.spacetype = SPACE_VIEW3D;
g_theme_state.regionid = RGN_TYPE_WINDOW;
}
}
bTheme *UI_GetTheme(void)
bTheme *UI_GetTheme()
{
return U.themes.first;
return static_cast<bTheme *>(U.themes.first);
}
void UI_Theme_Store(struct bThemeState *theme_state)
void UI_Theme_Store(bThemeState *theme_state)
{
*theme_state = g_theme_state;
}
void UI_Theme_Restore(struct bThemeState *theme_state)
void UI_Theme_Restore(bThemeState *theme_state)
{
g_theme_state = *theme_state;
}
@@ -1084,13 +1082,13 @@ void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset,
{
int r, g, b, a;
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
r = coloffset + (int)cp[0];
r = coloffset + int(cp[0]);
CLAMP(r, 0, 255);
g = coloffset + (int)cp[1];
g = coloffset + int(cp[1]);
CLAMP(g, 0, 255);
b = coloffset + (int)cp[2];
b = coloffset + int(cp[2]);
CLAMP(b, 0, 255);
a = alphaoffset + (int)cp[3];
a = alphaoffset + int(cp[3]);
CLAMP(a, 0, 255);
col[0] = r;
@@ -1143,51 +1141,51 @@ void UI_FontThemeColor(int fontid, int colorid)
float UI_GetThemeValuef(int colorid)
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
return ((float)cp[0]);
return (float(cp[0]));
}
int UI_GetThemeValue(int colorid)
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
return ((int)cp[0]);
return (int(cp[0]));
}
float UI_GetThemeValueTypef(int colorid, int spacetype)
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid);
return ((float)cp[0]);
return (float(cp[0]));
}
int UI_GetThemeValueType(int colorid, int spacetype)
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid);
return ((int)cp[0]);
return (int(cp[0]));
}
void UI_GetThemeColor3fv(int colorid, float col[3])
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
col[0] = ((float)cp[0]) / 255.0f;
col[1] = ((float)cp[1]) / 255.0f;
col[2] = ((float)cp[2]) / 255.0f;
col[0] = (float(cp[0])) / 255.0f;
col[1] = (float(cp[1])) / 255.0f;
col[2] = (float(cp[2])) / 255.0f;
}
void UI_GetThemeColor4fv(int colorid, float col[4])
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
col[0] = ((float)cp[0]) / 255.0f;
col[1] = ((float)cp[1]) / 255.0f;
col[2] = ((float)cp[2]) / 255.0f;
col[3] = ((float)cp[3]) / 255.0f;
col[0] = (float(cp[0])) / 255.0f;
col[1] = (float(cp[1])) / 255.0f;
col[2] = (float(cp[2])) / 255.0f;
col[3] = (float(cp[3])) / 255.0f;
}
void UI_GetThemeColorType4fv(int colorid, int spacetype, float col[4])
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid);
col[0] = ((float)cp[0]) / 255.0f;
col[1] = ((float)cp[1]) / 255.0f;
col[2] = ((float)cp[2]) / 255.0f;
col[3] = ((float)cp[3]) / 255.0f;
col[0] = (float(cp[0])) / 255.0f;
col[1] = (float(cp[1])) / 255.0f;
col[2] = (float(cp[2])) / 255.0f;
col[3] = (float(cp[3])) / 255.0f;
}
void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3])
@@ -1195,16 +1193,16 @@ void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3])
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
int r, g, b;
r = offset + (int)cp[0];
r = offset + int(cp[0]);
CLAMP(r, 0, 255);
g = offset + (int)cp[1];
g = offset + int(cp[1]);
CLAMP(g, 0, 255);
b = offset + (int)cp[2];
b = offset + int(cp[2]);
CLAMP(b, 0, 255);
col[0] = ((float)r) / 255.0f;
col[1] = ((float)g) / 255.0f;
col[2] = ((float)b) / 255.0f;
col[0] = float(r) / 255.0f;
col[1] = float(g) / 255.0f;
col[2] = float(b) / 255.0f;
}
void UI_GetThemeColorShade3ubv(int colorid, int offset, uchar col[3])
@@ -1212,11 +1210,11 @@ void UI_GetThemeColorShade3ubv(int colorid, int offset, uchar col[3])
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
int r, g, b;
r = offset + (int)cp[0];
r = offset + int(cp[0]);
CLAMP(r, 0, 255);
g = offset + (int)cp[1];
g = offset + int(cp[1]);
CLAMP(g, 0, 255);
b = offset + (int)cp[2];
b = offset + int(cp[2]);
CLAMP(b, 0, 255);
col[0] = r;
@@ -1245,11 +1243,11 @@ void UI_GetThemeColorShade4ubv(int colorid, int offset, uchar col[4])
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
int r, g, b;
r = offset + (int)cp[0];
r = offset + int(cp[0]);
CLAMP(r, 0, 255);
g = offset + (int)cp[1];
g = offset + int(cp[1]);
CLAMP(g, 0, 255);
b = offset + (int)cp[2];
b = offset + int(cp[2]);
CLAMP(b, 0, 255);
col[0] = r;
@@ -1263,19 +1261,19 @@ void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset,
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
int r, g, b, a;
r = coloffset + (int)cp[0];
r = coloffset + int(cp[0]);
CLAMP(r, 0, 255);
g = coloffset + (int)cp[1];
g = coloffset + int(cp[1]);
CLAMP(g, 0, 255);
b = coloffset + (int)cp[2];
b = coloffset + int(cp[2]);
CLAMP(b, 0, 255);
a = alphaoffset + (int)cp[3];
a = alphaoffset + int(cp[3]);
CLAMP(a, 0, 255);
col[0] = ((float)r) / 255.0f;
col[1] = ((float)g) / 255.0f;
col[2] = ((float)b) / 255.0f;
col[3] = ((float)a) / 255.0f;
col[0] = float(r) / 255.0f;
col[1] = float(g) / 255.0f;
col[2] = float(b) / 255.0f;
col[3] = float(a) / 255.0f;
}
void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int offset, float col[3])
@@ -1293,9 +1291,9 @@ void UI_GetThemeColorBlendShade3fv(int colorid1, int colorid2, float fac, int of
b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
CLAMP(b, 0, 255);
col[0] = ((float)r) / 255.0f;
col[1] = ((float)g) / 255.0f;
col[2] = ((float)b) / 255.0f;
col[0] = float(r) / 255.0f;
col[1] = float(g) / 255.0f;
col[2] = float(b) / 255.0f;
}
void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
@@ -1316,10 +1314,10 @@ void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int of
a = floorf((1.0f - fac) * cp1[3] + fac * cp2[3]); /* No shading offset. */
CLAMP(a, 0, 255);
col[0] = ((float)r) / 255.0f;
col[1] = ((float)g) / 255.0f;
col[2] = ((float)b) / 255.0f;
col[3] = ((float)a) / 255.0f;
col[0] = float(r) / 255.0f;
col[1] = float(g) / 255.0f;
col[2] = float(b) / 255.0f;
col[3] = float(a) / 255.0f;
}
void UI_GetThemeColor3ubv(int colorid, uchar col[3])
@@ -1335,20 +1333,20 @@ void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4])
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, g_theme_state.spacetype, colorid);
int r, g, b, a;
r = offset + (int)cp[0];
r = offset + int(cp[0]);
CLAMP(r, 0, 255);
g = offset + (int)cp[1];
g = offset + int(cp[1]);
CLAMP(g, 0, 255);
b = offset + (int)cp[2];
b = offset + int(cp[2]);
CLAMP(b, 0, 255);
a = (int)cp[3]; /* no shading offset... */
a = int(cp[3]); /* no shading offset... */
CLAMP(a, 0, 255);
col[0] = ((float)r) / 255.0f;
col[1] = ((float)g) / 255.0f;
col[2] = ((float)b) / 255.0f;
col[3] = ((float)a) / 255.0f;
col[0] = float(r) / 255.0f;
col[1] = float(g) / 255.0f;
col[2] = float(b) / 255.0f;
col[3] = float(a) / 255.0f;
}
void UI_GetThemeColor4ubv(int colorid, uchar col[4])
@@ -1363,9 +1361,9 @@ void UI_GetThemeColor4ubv(int colorid, uchar col[4])
void UI_GetThemeColorType3fv(int colorid, int spacetype, float col[3])
{
const uchar *cp = UI_ThemeGetColorPtr(g_theme_state.theme, spacetype, colorid);
col[0] = ((float)cp[0]) / 255.0f;
col[1] = ((float)cp[1]) / 255.0f;
col[2] = ((float)cp[2]) / 255.0f;
col[0] = (float(cp[0])) / 255.0f;
col[1] = (float(cp[1])) / 255.0f;
col[2] = (float(cp[2])) / 255.0f;
}
void UI_GetThemeColorType3ubv(int colorid, int spacetype, uchar col[3])
@@ -1418,9 +1416,9 @@ void UI_GetColorPtrShade3ubv(const uchar cp[3], uchar col[3], int offset)
{
int r, g, b;
r = offset + (int)cp[0];
g = offset + (int)cp[1];
b = offset + (int)cp[2];
r = offset + int(cp[0]);
g = offset + int(cp[1]);
b = offset + int(cp[2]);
CLAMP(r, 0, 255);
CLAMP(g, 0, 255);
@@ -1458,10 +1456,10 @@ void UI_ThemeClearColor(int colorid)
GPU_clear_color(col[0], col[1], col[2], 1.0f);
}
int UI_ThemeMenuShadowWidth(void)
int UI_ThemeMenuShadowWidth()
{
bTheme *btheme = UI_GetTheme();
return (int)(btheme->tui.menu_shadow_width * UI_DPI_FAC);
return int(btheme->tui.menu_shadow_width * UI_DPI_FAC);
}
void UI_make_axis_color(const uchar src_col[3], uchar dst_col[3], const char axis)