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
Notes: blender-bot 2023-09-13 08:48:34 +02:00
Referenced by issue #102827, Regression: Checkmarks in header are broken
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

@ -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)