1
1

Compare commits

...

19 Commits

Author SHA1 Message Date
f77be09171 Merge branch 'master' into temp-ui-cpp 2022-11-26 00:22:49 -06:00
1a3681b83c Cleanup: Move interface_intern.hh
The entire interface directory is now compiled as C++ files!
2022-11-26 00:21:17 -06:00
3c2073d844 Cleanup: Move interface eyedroppers directory to C++ 2022-11-26 00:01:49 -06:00
a1ea6d6496 Cleanup: Move interface_handlers.c to C++ 2022-11-25 23:48:33 -06:00
1836acbeac Cleanup: Move six more interface files to C++ 2022-11-25 23:48:18 -06:00
ae3f443220 Merge branch 'master' into temp-ui-cpp 2022-04-03 12:07:43 -05:00
b9d1b07a45 Cleanup: Move interface.c to C++
Similar to 4537eb0c3b
2022-04-03 12:07:38 -05:00
dd1be8db19 Cleanup: Move interface View2D files to C++ 2022-04-02 21:32:25 -05:00
6450f380ac Cleanup: Move more interface files to C++ 2022-04-02 15:07:36 -05:00
1051c17af3 Cleanup: Move interface_query.c to C++ 2022-04-02 14:07:43 -05:00
87628abaa1 Merge branch 'master' into temp-ui-cpp 2022-04-02 13:54:52 -05:00
462177fd62 Merge branch 'master' into temp-ui-cpp 2021-12-01 22:37:05 -05:00
5d221a2a8a Merge branch 'temp-ui-cpp' of git.blender.org:blender into temp-ui-cpp 2021-11-26 08:08:01 -05:00
fb4b7aaa8f Attempt to resolve build error 2021-11-26 08:07:50 -05:00
6183f63250 Merge branch 'master' into temp-ui-cpp 2021-11-21 11:39:51 -05:00
08228956d9 Cleanup: Move outliner_tools.c to C++ 2021-11-20 17:00:41 -05:00
956be86c09 Merge branch 'master' into temp-ui-cpp 2021-11-20 16:31:11 -05:00
e2f9602be2 Remove designated initializer 2021-11-20 15:59:05 -05:00
24ae9c52d8 Cleanup: Move search menu template to C++
This will allow using improved data structures, and
make other refactors to the search button API cleaner.
2021-11-19 23:51:48 -05:00
53 changed files with 2237 additions and 2178 deletions

View File

@@ -5,6 +5,8 @@
* \ingroup bke * \ingroup bke
*/ */
#include "BKE_undo_system.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -13,8 +15,6 @@ struct Main;
struct MemFileUndoData; struct MemFileUndoData;
struct bContext; struct bContext;
enum eUndoStepDir;
#define BKE_UNDO_STR_MAX 64 #define BKE_UNDO_STR_MAX 64
struct MemFileUndoData *BKE_memfile_undo_encode(struct Main *bmain, struct MemFileUndoData *BKE_memfile_undo_encode(struct Main *bmain,

View File

@@ -27,15 +27,15 @@ set(INC
) )
set(SRC set(SRC
eyedroppers/eyedropper_color.c eyedroppers/eyedropper_color.cc
eyedroppers/eyedropper_colorband.c eyedroppers/eyedropper_colorband.cc
eyedroppers/eyedropper_datablock.c eyedroppers/eyedropper_datablock.cc
eyedroppers/eyedropper_depth.c eyedroppers/eyedropper_depth.cc
eyedroppers/eyedropper_driver.c eyedroppers/eyedropper_driver.cc
eyedroppers/eyedropper_gpencil_color.c eyedroppers/eyedropper_gpencil_color.cc
eyedroppers/interface_eyedropper.c eyedroppers/interface_eyedropper.cc
interface.cc interface.cc
interface_align.c interface_align.cc
interface_anim.cc interface_anim.cc
interface_button_group.cc interface_button_group.cc
interface_context_menu.cc interface_context_menu.cc
@@ -43,10 +43,10 @@ set(SRC
interface_drag.cc interface_drag.cc
interface_draw.cc interface_draw.cc
interface_dropboxes.cc interface_dropboxes.cc
interface_handlers.c interface_handlers.cc
interface_icons.c interface_icons.cc
interface_icons_event.cc interface_icons_event.cc
interface_layout.c interface_layout.cc
interface_ops.cc interface_ops.cc
interface_panel.cc interface_panel.cc
interface_query.cc interface_query.cc
@@ -65,11 +65,11 @@ set(SRC
interface_template_list.cc interface_template_list.cc
interface_template_search_menu.cc interface_template_search_menu.cc
interface_template_search_operator.cc interface_template_search_operator.cc
interface_templates.c interface_templates.cc
interface_undo.cc interface_undo.cc
interface_utils.cc interface_utils.cc
interface_widgets.c interface_widgets.cc
resources.c resources.cc
view2d.cc view2d.cc
view2d_draw.cc view2d_draw.cc
view2d_edge_pan.cc view2d_edge_pan.cc
@@ -81,8 +81,8 @@ set(SRC
views/interface_view.cc views/interface_view.cc
views/tree_view.cc views/tree_view.cc
eyedroppers/eyedropper_intern.h eyedroppers/eyedropper_intern.hh
interface_intern.h interface_intern.hh
interface_regions_intern.hh interface_regions_intern.hh
) )

View File

@@ -41,7 +41,7 @@
#include "RNA_define.h" #include "RNA_define.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "ED_clip.h" #include "ED_clip.h"
#include "ED_image.h" #include "ED_image.h"
@@ -50,10 +50,10 @@
#include "RE_pipeline.h" #include "RE_pipeline.h"
#include "eyedropper_intern.h" #include "eyedropper_intern.hh"
typedef struct Eyedropper { struct Eyedropper {
struct ColorManagedDisplay *display; ColorManagedDisplay *display;
PointerRNA ptr; PointerRNA ptr;
PropertyRNA *prop; PropertyRNA *prop;
@@ -71,23 +71,24 @@ typedef struct Eyedropper {
char sample_text[MAX_NAME]; char sample_text[MAX_NAME];
bNode *crypto_node; bNode *crypto_node;
struct CryptomatteSession *cryptomatte_session; CryptomatteSession *cryptomatte_session;
} Eyedropper; };
static void eyedropper_draw_cb(const wmWindow *window, void *arg) static void eyedropper_draw_cb(const wmWindow *window, void *arg)
{ {
Eyedropper *eye = arg; Eyedropper *eye = static_cast<Eyedropper *>(arg);
eyedropper_draw_cursor_text_window(window, eye->sample_text); eyedropper_draw_cursor_text_window(window, eye->sample_text);
} }
static bool eyedropper_init(bContext *C, wmOperator *op) static bool eyedropper_init(bContext *C, wmOperator *op)
{ {
Eyedropper *eye = MEM_callocN(sizeof(Eyedropper), __func__); Eyedropper *eye = MEM_cnew<Eyedropper>(__func__);
uiBut *but = UI_context_active_but_prop_get(C, &eye->ptr, &eye->prop, &eye->index); uiBut *but = UI_context_active_but_prop_get(C, &eye->ptr, &eye->prop, &eye->index);
const enum PropertySubType prop_subtype = eye->prop ? RNA_property_subtype(eye->prop) : 0; const enum PropertySubType prop_subtype = eye->prop ? RNA_property_subtype(eye->prop) :
PropertySubType(0);
if ((eye->ptr.data == NULL) || (eye->prop == NULL) || if ((eye->ptr.data == nullptr) || (eye->prop == nullptr) ||
(RNA_property_editable(&eye->ptr, eye->prop) == false) || (RNA_property_editable(&eye->ptr, eye->prop) == false) ||
(RNA_property_array_length(&eye->ptr, eye->prop) < 3) || (RNA_property_array_length(&eye->ptr, eye->prop) < 3) ||
(RNA_property_type(eye->prop) != PROP_FLOAT) || (RNA_property_type(eye->prop) != PROP_FLOAT) ||
@@ -127,18 +128,18 @@ static bool eyedropper_init(bContext *C, wmOperator *op)
static void eyedropper_exit(bContext *C, wmOperator *op) static void eyedropper_exit(bContext *C, wmOperator *op)
{ {
Eyedropper *eye = op->customdata; Eyedropper *eye = static_cast<Eyedropper *>(op->customdata);
wmWindow *window = CTX_wm_window(C); wmWindow *window = CTX_wm_window(C);
WM_cursor_modal_restore(window); WM_cursor_modal_restore(window);
if (eye->draw_handle_sample_text) { if (eye->draw_handle_sample_text) {
WM_draw_cb_exit(window, eye->draw_handle_sample_text); WM_draw_cb_exit(window, eye->draw_handle_sample_text);
eye->draw_handle_sample_text = NULL; eye->draw_handle_sample_text = nullptr;
} }
if (eye->cryptomatte_session) { if (eye->cryptomatte_session) {
BKE_cryptomatte_free(eye->cryptomatte_session); BKE_cryptomatte_free(eye->cryptomatte_session);
eye->cryptomatte_session = NULL; eye->cryptomatte_session = nullptr;
} }
MEM_SAFE_FREE(op->customdata); MEM_SAFE_FREE(op->customdata);
@@ -219,11 +220,11 @@ static bool eyedropper_cryptomatte_sample_image_fl(const bNode *node,
{ {
bool success = false; bool success = false;
Image *image = (Image *)node->id; Image *image = (Image *)node->id;
BLI_assert((image == NULL) || (GS(image->id.name) == ID_IM)); BLI_assert((image == nullptr) || (GS(image->id.name) == ID_IM));
ImageUser *iuser = &crypto->iuser; ImageUser *iuser = &crypto->iuser;
if (image && image->type == IMA_TYPE_MULTILAYER) { if (image && image->type == IMA_TYPE_MULTILAYER) {
ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, NULL); ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, nullptr);
if (image->rr) { if (image->rr) {
LISTBASE_FOREACH (RenderLayer *, render_layer, &image->rr->layers) { LISTBASE_FOREACH (RenderLayer *, render_layer, &image->rr->layers) {
success = eyedropper_cryptomatte_sample_renderlayer_fl(render_layer, prefix, fpos, r_col); success = eyedropper_cryptomatte_sample_renderlayer_fl(render_layer, prefix, fpos, r_col);
@@ -232,7 +233,7 @@ static bool eyedropper_cryptomatte_sample_image_fl(const bNode *node,
} }
} }
} }
BKE_image_release_ibuf(image, ibuf, NULL); BKE_image_release_ibuf(image, ibuf, nullptr);
} }
return success; return success;
} }
@@ -243,7 +244,7 @@ static bool eyedropper_cryptomatte_sample_fl(bContext *C,
float r_col[3]) float r_col[3])
{ {
bNode *node = eye->crypto_node; bNode *node = eye->crypto_node;
NodeCryptomatte *crypto = node ? ((NodeCryptomatte *)node->storage) : NULL; NodeCryptomatte *crypto = node ? ((NodeCryptomatte *)node->storage) : nullptr;
if (!crypto) { if (!crypto) {
return false; return false;
@@ -264,18 +265,18 @@ static bool eyedropper_cryptomatte_sample_fl(bContext *C,
float fpos[2] = {-1.0f, -1.0}; float fpos[2] = {-1.0f, -1.0};
switch (area->spacetype) { switch (area->spacetype) {
case SPACE_IMAGE: { case SPACE_IMAGE: {
SpaceImage *sima = area->spacedata.first; SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
ED_space_image_get_position(sima, region, mval, fpos); ED_space_image_get_position(sima, region, mval, fpos);
break; break;
} }
case SPACE_NODE: { case SPACE_NODE: {
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
SpaceNode *snode = area->spacedata.first; SpaceNode *snode = static_cast<SpaceNode *>(area->spacedata.first);
ED_space_node_get_position(bmain, snode, region, mval, fpos); ED_space_node_get_position(bmain, snode, region, mval, fpos);
break; break;
} }
case SPACE_CLIP: { case SPACE_CLIP: {
SpaceClip *sc = area->spacedata.first; SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
ED_space_clip_get_position(sc, region, mval, fpos); ED_space_clip_get_position(sc, region, mval, fpos);
break; break;
} }
@@ -315,7 +316,7 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C); wmWindowManager *wm = CTX_wm_manager(C);
const char *display_device = CTX_data_scene(C)->display_settings.display_device; const char *display_device = CTX_data_scene(C)->display_settings.display_device;
struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device); ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
int mval[2]; int mval[2];
wmWindow *win; wmWindow *win;
@@ -326,10 +327,10 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
if (area->spacetype == SPACE_IMAGE) { if (area->spacetype == SPACE_IMAGE) {
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval); ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval);
if (region) { if (region) {
SpaceImage *sima = area->spacedata.first; SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin}; const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
if (ED_space_image_color_sample(sima, region, region_mval, r_col, NULL)) { if (ED_space_image_color_sample(sima, region, region_mval, r_col, nullptr)) {
return; return;
} }
} }
@@ -337,7 +338,7 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
else if (area->spacetype == SPACE_NODE) { else if (area->spacetype == SPACE_NODE) {
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval); ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval);
if (region) { if (region) {
SpaceNode *snode = area->spacedata.first; SpaceNode *snode = static_cast<SpaceNode *>(area->spacedata.first);
const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin}; const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
if (ED_space_node_color_sample(bmain, snode, region, region_mval, r_col)) { if (ED_space_node_color_sample(bmain, snode, region, region_mval, r_col)) {
@@ -348,7 +349,7 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
else if (area->spacetype == SPACE_CLIP) { else if (area->spacetype == SPACE_CLIP) {
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval); ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval);
if (region) { if (region) {
SpaceClip *sc = area->spacedata.first; SpaceClip *sc = static_cast<SpaceClip *>(area->spacedata.first);
const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin}; const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
if (ED_space_clip_color_sample(sc, region, region_mval, r_col)) { if (ED_space_clip_color_sample(sc, region, region_mval, r_col)) {
@@ -440,7 +441,7 @@ static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, co
static void eyedropper_cancel(bContext *C, wmOperator *op) static void eyedropper_cancel(bContext *C, wmOperator *op)
{ {
Eyedropper *eye = op->customdata; Eyedropper *eye = static_cast<Eyedropper *>(op->customdata);
if (eye->is_set) { if (eye->is_set) {
eyedropper_color_set(C, eye, eye->init_col); eyedropper_color_set(C, eye, eye->init_col);
} }
@@ -495,7 +496,7 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
} }
/* Modal Operator init */ /* Modal Operator init */
static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{ {
/* init */ /* init */
if (eyedropper_init(C, op)) { if (eyedropper_init(C, op)) {
@@ -532,7 +533,7 @@ static bool eyedropper_poll(bContext *C)
{ {
/* Actual test for active button happens later, since we don't /* Actual test for active button happens later, since we don't
* know which one is active until mouse over. */ * know which one is active until mouse over. */
return (CTX_wm_window(C) != NULL); return (CTX_wm_window(C) != nullptr);
} }
void UI_OT_eyedropper_color(wmOperatorType *ot) void UI_OT_eyedropper_color(wmOperatorType *ot)

View File

@@ -33,16 +33,16 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "eyedropper_intern.h" #include "eyedropper_intern.hh"
typedef struct Colorband_RNAUpdateCb { struct Colorband_RNAUpdateCb {
PointerRNA ptr; PointerRNA ptr;
PropertyRNA *prop; PropertyRNA *prop;
} Colorband_RNAUpdateCb; };
typedef struct EyedropperColorband { struct EyedropperColorband {
int event_xy_last[2]; int event_xy_last[2];
/* Alpha is currently fixed at 1.0, may support in future. */ /* Alpha is currently fixed at 1.0, may support in future. */
float (*color_buffer)[4]; float (*color_buffer)[4];
@@ -55,7 +55,7 @@ typedef struct EyedropperColorband {
PropertyRNA *prop; PropertyRNA *prop;
bool is_undo; bool is_undo;
bool is_set; bool is_set;
} EyedropperColorband; };
/* For user-data only. */ /* For user-data only. */
struct EyedropperColorband_Context { struct EyedropperColorband_Context {
@@ -65,15 +65,15 @@ struct EyedropperColorband_Context {
static bool eyedropper_colorband_init(bContext *C, wmOperator *op) static bool eyedropper_colorband_init(bContext *C, wmOperator *op)
{ {
ColorBand *band = NULL; ColorBand *band = nullptr;
uiBut *but = UI_context_active_but_get(C); uiBut *but = UI_context_active_but_get(C);
PointerRNA rna_update_ptr = PointerRNA_NULL; PointerRNA rna_update_ptr = PointerRNA_NULL;
PropertyRNA *rna_update_prop = NULL; PropertyRNA *rna_update_prop = nullptr;
bool is_undo = true; bool is_undo = true;
if (but == NULL) { if (but == nullptr) {
/* pass */ /* pass */
} }
else { else {
@@ -95,8 +95,8 @@ static bool eyedropper_colorband_init(bContext *C, wmOperator *op)
if (!band) { if (!band) {
const PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp); const PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp);
if (ptr.data != NULL) { if (ptr.data != nullptr) {
band = ptr.data; band = static_cast<ColorBand *>(ptr.data);
/* Set this to a sub-member of the property to trigger an update. */ /* Set this to a sub-member of the property to trigger an update. */
rna_update_ptr = ptr; rna_update_ptr = ptr;
@@ -109,9 +109,10 @@ static bool eyedropper_colorband_init(bContext *C, wmOperator *op)
return false; return false;
} }
EyedropperColorband *eye = MEM_callocN(sizeof(EyedropperColorband), __func__); EyedropperColorband *eye = MEM_cnew<EyedropperColorband>(__func__);
eye->color_buffer_alloc = 16; eye->color_buffer_alloc = 16;
eye->color_buffer = MEM_mallocN(sizeof(*eye->color_buffer) * eye->color_buffer_alloc, __func__); eye->color_buffer = static_cast<float(*)[4]>(
MEM_mallocN(sizeof(*eye->color_buffer) * eye->color_buffer_alloc, __func__));
eye->color_buffer_len = 0; eye->color_buffer_len = 0;
eye->color_band = band; eye->color_band = band;
eye->init_color_band = *eye->color_band; eye->init_color_band = *eye->color_band;
@@ -134,8 +135,8 @@ static void eyedropper_colorband_sample_point(bContext *C,
eyedropper_color_sample_fl(C, m_xy, col); eyedropper_color_sample_fl(C, m_xy, col);
if (eye->color_buffer_len + 1 == eye->color_buffer_alloc) { if (eye->color_buffer_len + 1 == eye->color_buffer_alloc) {
eye->color_buffer_alloc *= 2; eye->color_buffer_alloc *= 2;
eye->color_buffer = MEM_reallocN(eye->color_buffer, eye->color_buffer = static_cast<float(*)[4]>(
sizeof(*eye->color_buffer) * eye->color_buffer_alloc); MEM_reallocN(eye->color_buffer, sizeof(*eye->color_buffer) * eye->color_buffer_alloc));
} }
copy_v4_v4(eye->color_buffer[eye->color_buffer_len], col); copy_v4_v4(eye->color_buffer[eye->color_buffer_len], col);
eye->color_buffer_len += 1; eye->color_buffer_len += 1;
@@ -146,7 +147,7 @@ static void eyedropper_colorband_sample_point(bContext *C,
static bool eyedropper_colorband_sample_callback(int mx, int my, void *userdata) static bool eyedropper_colorband_sample_callback(int mx, int my, void *userdata)
{ {
struct EyedropperColorband_Context *data = userdata; EyedropperColorband_Context *data = static_cast<EyedropperColorband_Context *>(userdata);
bContext *C = data->context; bContext *C = data->context;
EyedropperColorband *eye = data->eye; EyedropperColorband *eye = data->eye;
const int cursor[2] = {mx, my}; const int cursor[2] = {mx, my};
@@ -160,7 +161,7 @@ static void eyedropper_colorband_sample_segment(bContext *C,
{ {
/* Since the mouse tends to move rather rapidly we use #BLI_bitmap_draw_2d_line_v2v2i /* Since the mouse tends to move rather rapidly we use #BLI_bitmap_draw_2d_line_v2v2i
* to interpolate between the reported coordinates */ * to interpolate between the reported coordinates */
struct EyedropperColorband_Context userdata = {C, eye}; EyedropperColorband_Context userdata = {C, eye};
BLI_bitmap_draw_2d_line_v2v2i( BLI_bitmap_draw_2d_line_v2v2i(
eye->event_xy_last, m_xy, eyedropper_colorband_sample_callback, &userdata); eye->event_xy_last, m_xy, eyedropper_colorband_sample_callback, &userdata);
} }
@@ -170,16 +171,16 @@ static void eyedropper_colorband_exit(bContext *C, wmOperator *op)
WM_cursor_modal_restore(CTX_wm_window(C)); WM_cursor_modal_restore(CTX_wm_window(C));
if (op->customdata) { if (op->customdata) {
EyedropperColorband *eye = op->customdata; EyedropperColorband *eye = static_cast<EyedropperColorband *>(op->customdata);
MEM_freeN(eye->color_buffer); MEM_freeN(eye->color_buffer);
MEM_freeN(eye); MEM_freeN(eye);
op->customdata = NULL; op->customdata = nullptr;
} }
} }
static void eyedropper_colorband_apply(bContext *C, wmOperator *op) static void eyedropper_colorband_apply(bContext *C, wmOperator *op)
{ {
EyedropperColorband *eye = op->customdata; EyedropperColorband *eye = static_cast<EyedropperColorband *>(op->customdata);
/* Always filter, avoids noise in resulting color-band. */ /* Always filter, avoids noise in resulting color-band. */
const bool filter_samples = true; const bool filter_samples = true;
BKE_colorband_init_from_table_rgba( BKE_colorband_init_from_table_rgba(
@@ -192,7 +193,7 @@ static void eyedropper_colorband_apply(bContext *C, wmOperator *op)
static void eyedropper_colorband_cancel(bContext *C, wmOperator *op) static void eyedropper_colorband_cancel(bContext *C, wmOperator *op)
{ {
EyedropperColorband *eye = op->customdata; EyedropperColorband *eye = static_cast<EyedropperColorband *>(op->customdata);
if (eye->is_set) { if (eye->is_set) {
*eye->color_band = eye->init_color_band; *eye->color_band = eye->init_color_band;
if (eye->prop) { if (eye->prop) {
@@ -205,7 +206,7 @@ static void eyedropper_colorband_cancel(bContext *C, wmOperator *op)
/* main modal status check */ /* main modal status check */
static int eyedropper_colorband_modal(bContext *C, wmOperator *op, const wmEvent *event) static int eyedropper_colorband_modal(bContext *C, wmOperator *op, const wmEvent *event)
{ {
EyedropperColorband *eye = op->customdata; EyedropperColorband *eye = static_cast<EyedropperColorband *>(op->customdata);
/* handle modal keymap */ /* handle modal keymap */
if (event->type == EVT_MODAL_MAP) { if (event->type == EVT_MODAL_MAP) {
switch (event->val) { switch (event->val) {
@@ -242,7 +243,7 @@ static int eyedropper_colorband_modal(bContext *C, wmOperator *op, const wmEvent
static int eyedropper_colorband_point_modal(bContext *C, wmOperator *op, const wmEvent *event) static int eyedropper_colorband_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
{ {
EyedropperColorband *eye = op->customdata; EyedropperColorband *eye = static_cast<EyedropperColorband *>(op->customdata);
/* handle modal keymap */ /* handle modal keymap */
if (event->type == EVT_MODAL_MAP) { if (event->type == EVT_MODAL_MAP) {
switch (event->val) { switch (event->val) {
@@ -280,7 +281,7 @@ static int eyedropper_colorband_point_modal(bContext *C, wmOperator *op, const w
} }
/* Modal Operator init */ /* Modal Operator init */
static int eyedropper_colorband_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) static int eyedropper_colorband_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{ {
/* init */ /* init */
if (eyedropper_colorband_init(C, op)) { if (eyedropper_colorband_init(C, op)) {
@@ -320,7 +321,7 @@ static bool eyedropper_colorband_poll(bContext *C)
return true; return true;
} }
const PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp); const PointerRNA ptr = CTX_data_pointer_get_type(C, "color_ramp", &RNA_ColorRamp);
if (ptr.data != NULL) { if (ptr.data != nullptr) {
return true; return true;
} }
return false; return false;

View File

@@ -38,13 +38,13 @@
#include "ED_space_api.h" #include "ED_space_api.h"
#include "ED_view3d.h" #include "ED_view3d.h"
#include "eyedropper_intern.h" #include "eyedropper_intern.hh"
#include "interface_intern.h" #include "interface_intern.hh"
/** /**
* \note #DataDropper is only internal name to avoid confusion with other kinds of eye-droppers. * \note #DataDropper is only internal name to avoid confusion with other kinds of eye-droppers.
*/ */
typedef struct DataDropper { struct DataDropper {
PointerRNA ptr; PointerRNA ptr;
PropertyRNA *prop; PropertyRNA *prop;
short idcode; short idcode;
@@ -58,13 +58,11 @@ typedef struct DataDropper {
void *draw_handle_pixel; void *draw_handle_pixel;
int name_pos[2]; int name_pos[2];
char name[200]; char name[200];
} DataDropper; };
static void datadropper_draw_cb(const struct bContext *UNUSED(C), static void datadropper_draw_cb(const bContext * /*C*/, ARegion * /*region*/, void *arg)
ARegion *UNUSED(region),
void *arg)
{ {
DataDropper *ddr = arg; DataDropper *ddr = static_cast<DataDropper *>(arg);
eyedropper_draw_cursor_text_region(ddr->name_pos, ddr->name); eyedropper_draw_cursor_text_region(ddr->name_pos, ddr->name);
} }
@@ -79,11 +77,11 @@ static int datadropper_init(bContext *C, wmOperator *op)
st = BKE_spacetype_from_id(SPACE_VIEW3D); st = BKE_spacetype_from_id(SPACE_VIEW3D);
art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW); art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW);
DataDropper *ddr = MEM_callocN(sizeof(DataDropper), __func__); DataDropper *ddr = MEM_cnew<DataDropper>(__func__);
uiBut *but = UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &index_dummy); uiBut *but = UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &index_dummy);
if ((ddr->ptr.data == NULL) || (ddr->prop == NULL) || if ((ddr->ptr.data == nullptr) || (ddr->prop == nullptr) ||
(RNA_property_editable(&ddr->ptr, ddr->prop) == false) || (RNA_property_editable(&ddr->ptr, ddr->prop) == false) ||
(RNA_property_type(ddr->prop) != PROP_POINTER)) { (RNA_property_type(ddr->prop) != PROP_POINTER)) {
MEM_freeN(ddr); MEM_freeN(ddr);
@@ -126,7 +124,7 @@ static void datadropper_exit(bContext *C, wmOperator *op)
MEM_freeN(op->customdata); MEM_freeN(op->customdata);
op->customdata = NULL; op->customdata = nullptr;
} }
WM_event_add_mousemove(win); WM_event_add_mousemove(win);
@@ -168,7 +166,7 @@ static void datadropper_id_sample_pt(
if (base) { if (base) {
Object *ob = base->object; Object *ob = base->object;
ID *id = NULL; ID *id = nullptr;
if (ddr->idcode == ID_OB) { if (ddr->idcode == ID_OB) {
id = (ID *)ob; id = (ID *)ob;
} }
@@ -208,7 +206,7 @@ static bool datadropper_id_set(bContext *C, DataDropper *ddr, ID *id)
RNA_id_pointer_create(id, &ptr_value); RNA_id_pointer_create(id, &ptr_value);
RNA_property_pointer_set(&ddr->ptr, ddr->prop, ptr_value, NULL); RNA_property_pointer_set(&ddr->ptr, ddr->prop, ptr_value, nullptr);
RNA_property_update(C, &ddr->ptr, ddr->prop); RNA_property_update(C, &ddr->ptr, ddr->prop);
@@ -220,7 +218,7 @@ static bool datadropper_id_set(bContext *C, DataDropper *ddr, ID *id)
/* single point sample & set */ /* single point sample & set */
static bool datadropper_id_sample(bContext *C, DataDropper *ddr, const int m_xy[2]) static bool datadropper_id_sample(bContext *C, DataDropper *ddr, const int m_xy[2])
{ {
ID *id = NULL; ID *id = nullptr;
int mval[2]; int mval[2];
wmWindow *win; wmWindow *win;
@@ -233,7 +231,7 @@ static bool datadropper_id_sample(bContext *C, DataDropper *ddr, const int m_xy[
static void datadropper_cancel(bContext *C, wmOperator *op) static void datadropper_cancel(bContext *C, wmOperator *op)
{ {
DataDropper *ddr = op->customdata; DataDropper *ddr = static_cast<DataDropper *>(op->customdata);
datadropper_id_set(C, ddr, ddr->init_id); datadropper_id_set(C, ddr, ddr->init_id);
datadropper_exit(C, op); datadropper_exit(C, op);
} }
@@ -287,7 +285,7 @@ static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
} }
} }
else if (event->type == MOUSEMOVE) { else if (event->type == MOUSEMOVE) {
ID *id = NULL; ID *id = nullptr;
int mval[2]; int mval[2];
wmWindow *win; wmWindow *win;
@@ -304,7 +302,7 @@ static int datadropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
} }
/* Modal Operator init */ /* Modal Operator init */
static int datadropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) static int datadropper_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{ {
/* init */ /* init */
if (datadropper_init(C, op)) { if (datadropper_init(C, op)) {
@@ -342,7 +340,7 @@ static bool datadropper_poll(bContext *C)
uiBut *but; uiBut *but;
/* data dropper only supports object data */ /* data dropper only supports object data */
if ((CTX_wm_window(C) != NULL) && if ((CTX_wm_window(C) != nullptr) &&
(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) && (but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) &&
(but->type == UI_BTYPE_SEARCH_MENU) && (but->flag & UI_BUT_VALUE_CLEAR)) { (but->type == UI_BTYPE_SEARCH_MENU) && (but->flag & UI_BUT_VALUE_CLEAR)) {
if (prop && RNA_property_type(prop) == PROP_POINTER) { if (prop && RNA_property_type(prop) == PROP_POINTER) {

View File

@@ -38,13 +38,13 @@
#include "ED_space_api.h" #include "ED_space_api.h"
#include "ED_view3d.h" #include "ED_view3d.h"
#include "eyedropper_intern.h" #include "eyedropper_intern.hh"
#include "interface_intern.h" #include "interface_intern.hh"
/** /**
* \note #DepthDropper is only internal name to avoid confusion with other kinds of eye-droppers. * \note #DepthDropper is only internal name to avoid confusion with other kinds of eye-droppers.
*/ */
typedef struct DepthDropper { struct DepthDropper {
PointerRNA ptr; PointerRNA ptr;
PropertyRNA *prop; PropertyRNA *prop;
bool is_undo; bool is_undo;
@@ -60,13 +60,11 @@ typedef struct DepthDropper {
void *draw_handle_pixel; void *draw_handle_pixel;
int name_pos[2]; int name_pos[2];
char name[200]; char name[200];
} DepthDropper; };
static void depthdropper_draw_cb(const struct bContext *UNUSED(C), static void depthdropper_draw_cb(const struct bContext * /*C*/, ARegion * /*region*/, void *arg)
ARegion *UNUSED(region),
void *arg)
{ {
DepthDropper *ddr = arg; DepthDropper *ddr = static_cast<DepthDropper *>(arg);
eyedropper_draw_cursor_text_region(ddr->name_pos, ddr->name); eyedropper_draw_cursor_text_region(ddr->name_pos, ddr->name);
} }
@@ -80,17 +78,17 @@ static int depthdropper_init(bContext *C, wmOperator *op)
st = BKE_spacetype_from_id(SPACE_VIEW3D); st = BKE_spacetype_from_id(SPACE_VIEW3D);
art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW); art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW);
DepthDropper *ddr = MEM_callocN(sizeof(DepthDropper), __func__); DepthDropper *ddr = MEM_cnew<DepthDropper>(__func__);
uiBut *but = UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &index_dummy); uiBut *but = UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &index_dummy);
/* fallback to the active camera's dof */ /* fallback to the active camera's dof */
if (ddr->prop == NULL) { if (ddr->prop == nullptr) {
RegionView3D *rv3d = CTX_wm_region_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C);
if (rv3d && rv3d->persp == RV3D_CAMOB) { if (rv3d && rv3d->persp == RV3D_CAMOB) {
View3D *v3d = CTX_wm_view3d(C); View3D *v3d = CTX_wm_view3d(C);
if (v3d->camera && v3d->camera->data && if (v3d->camera && v3d->camera->data &&
BKE_id_is_editable(CTX_data_main(C), v3d->camera->data)) { BKE_id_is_editable(CTX_data_main(C), static_cast<const ID *>(v3d->camera->data))) {
Camera *camera = (Camera *)v3d->camera->data; Camera *camera = (Camera *)v3d->camera->data;
RNA_pointer_create(&camera->id, &RNA_CameraDOFSettings, &camera->dof, &ddr->ptr); RNA_pointer_create(&camera->id, &RNA_CameraDOFSettings, &camera->dof, &ddr->ptr);
ddr->prop = RNA_struct_find_property(&ddr->ptr, "focus_distance"); ddr->prop = RNA_struct_find_property(&ddr->ptr, "focus_distance");
@@ -102,7 +100,7 @@ static int depthdropper_init(bContext *C, wmOperator *op)
ddr->is_undo = UI_but_flag_is_set(but, UI_BUT_UNDO); ddr->is_undo = UI_but_flag_is_set(but, UI_BUT_UNDO);
} }
if ((ddr->ptr.data == NULL) || (ddr->prop == NULL) || if ((ddr->ptr.data == nullptr) || (ddr->prop == nullptr) ||
(RNA_property_editable(&ddr->ptr, ddr->prop) == false) || (RNA_property_editable(&ddr->ptr, ddr->prop) == false) ||
(RNA_property_type(ddr->prop) != PROP_FLOAT)) { (RNA_property_type(ddr->prop) != PROP_FLOAT)) {
MEM_freeN(ddr); MEM_freeN(ddr);
@@ -131,7 +129,7 @@ static void depthdropper_exit(bContext *C, wmOperator *op)
MEM_freeN(op->customdata); MEM_freeN(op->customdata);
op->customdata = NULL; op->customdata = nullptr;
} }
} }
@@ -159,8 +157,8 @@ static void depthdropper_depth_sample_pt(bContext *C,
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, m_xy); ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, m_xy);
if (region) { if (region) {
struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
View3D *v3d = area->spacedata.first; View3D *v3d = static_cast<View3D *>(area->spacedata.first);
RegionView3D *rv3d = region->regiondata; RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
/* weak, we could pass in some reference point */ /* weak, we could pass in some reference point */
const float *view_co = v3d->camera ? v3d->camera->object_to_world[3] : rv3d->viewinv[3]; const float *view_co = v3d->camera ? v3d->camera->object_to_world[3] : rv3d->viewinv[3];
const int mval[2] = {m_xy[0] - region->winrct.xmin, m_xy[1] - region->winrct.ymin}; const int mval[2] = {m_xy[0] - region->winrct.xmin, m_xy[1] - region->winrct.ymin};
@@ -176,7 +174,7 @@ static void depthdropper_depth_sample_pt(bContext *C,
view3d_operator_needs_opengl(C); view3d_operator_needs_opengl(C);
if (ED_view3d_autodist(depsgraph, region, v3d, mval, co, true, NULL)) { if (ED_view3d_autodist(depsgraph, region, v3d, mval, co, true, nullptr)) {
const float mval_center_fl[2] = {(float)region->winx / 2, (float)region->winy / 2}; const float mval_center_fl[2] = {(float)region->winx / 2, (float)region->winy / 2};
float co_align[3]; float co_align[3];
@@ -244,7 +242,7 @@ static void depthdropper_depth_sample_accum(bContext *C, DepthDropper *ddr, cons
static void depthdropper_cancel(bContext *C, wmOperator *op) static void depthdropper_cancel(bContext *C, wmOperator *op)
{ {
DepthDropper *ddr = op->customdata; DepthDropper *ddr = static_cast<DepthDropper *>(op->customdata);
if (ddr->is_set) { if (ddr->is_set) {
depthdropper_depth_set(C, ddr, ddr->init_depth); depthdropper_depth_set(C, ddr, ddr->init_depth);
} }
@@ -254,7 +252,7 @@ static void depthdropper_cancel(bContext *C, wmOperator *op)
/* main modal status check */ /* main modal status check */
static int depthdropper_modal(bContext *C, wmOperator *op, const wmEvent *event) static int depthdropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
{ {
DepthDropper *ddr = (DepthDropper *)op->customdata; DepthDropper *ddr = static_cast<DepthDropper *>(op->customdata);
/* handle modal keymap */ /* handle modal keymap */
if (event->type == EVT_MODAL_MAP) { if (event->type == EVT_MODAL_MAP) {
@@ -299,7 +297,7 @@ static int depthdropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
} }
/* Modal Operator init */ /* Modal Operator init */
static int depthdropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) static int depthdropper_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{ {
/* init */ /* init */
if (depthdropper_init(C, op)) { if (depthdropper_init(C, op)) {
@@ -337,9 +335,9 @@ static bool depthdropper_poll(bContext *C)
uiBut *but; uiBut *but;
/* check if there's an active button taking depth value */ /* check if there's an active button taking depth value */
if ((CTX_wm_window(C) != NULL) && if ((CTX_wm_window(C) != nullptr) &&
(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) && (but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) &&
(but->type == UI_BTYPE_NUM) && (prop != NULL)) { (but->type == UI_BTYPE_NUM) && (prop != nullptr)) {
if ((RNA_property_type(prop) == PROP_FLOAT) && if ((RNA_property_type(prop) == PROP_FLOAT) &&
(RNA_property_subtype(prop) & PROP_UNIT_LENGTH) && (RNA_property_subtype(prop) & PROP_UNIT_LENGTH) &&
(RNA_property_array_check(prop) == false)) { (RNA_property_array_check(prop) == false)) {
@@ -351,7 +349,7 @@ static bool depthdropper_poll(bContext *C)
if (rv3d && rv3d->persp == RV3D_CAMOB) { if (rv3d && rv3d->persp == RV3D_CAMOB) {
View3D *v3d = CTX_wm_view3d(C); View3D *v3d = CTX_wm_view3d(C);
if (v3d->camera && v3d->camera->data && if (v3d->camera && v3d->camera->data &&
BKE_id_is_editable(CTX_data_main(C), v3d->camera->data)) { BKE_id_is_editable(CTX_data_main(C), static_cast<const ID *>(v3d->camera->data))) {
return true; return true;
} }
} }

View File

@@ -33,10 +33,10 @@
#include "ED_keyframing.h" #include "ED_keyframing.h"
#include "eyedropper_intern.h" #include "eyedropper_intern.hh"
#include "interface_intern.h" #include "interface_intern.hh"
typedef struct DriverDropper { struct DriverDropper {
/* Destination property (i.e. where we'll add a driver) */ /* Destination property (i.e. where we'll add a driver) */
PointerRNA ptr; PointerRNA ptr;
PropertyRNA *prop; PropertyRNA *prop;
@@ -44,15 +44,15 @@ typedef struct DriverDropper {
bool is_undo; bool is_undo;
/* TODO: new target? */ /* TODO: new target? */
} DriverDropper; };
static bool driverdropper_init(bContext *C, wmOperator *op) static bool driverdropper_init(bContext *C, wmOperator *op)
{ {
DriverDropper *ddr = MEM_callocN(sizeof(DriverDropper), __func__); DriverDropper *ddr = MEM_cnew<DriverDropper>(__func__);
uiBut *but = UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &ddr->index); uiBut *but = UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &ddr->index);
if ((ddr->ptr.data == NULL) || (ddr->prop == NULL) || if ((ddr->ptr.data == nullptr) || (ddr->prop == nullptr) ||
(RNA_property_editable(&ddr->ptr, ddr->prop) == false) || (RNA_property_editable(&ddr->ptr, ddr->prop) == false) ||
(RNA_property_animateable(&ddr->ptr, ddr->prop) == false) || (but->flag & UI_BUT_DRIVEN)) { (RNA_property_animateable(&ddr->ptr, ddr->prop) == false) || (but->flag & UI_BUT_DRIVEN)) {
MEM_freeN(ddr); MEM_freeN(ddr);
@@ -74,14 +74,14 @@ static void driverdropper_exit(bContext *C, wmOperator *op)
static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *event) static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *event)
{ {
DriverDropper *ddr = (DriverDropper *)op->customdata; DriverDropper *ddr = static_cast<DriverDropper *>(op->customdata);
uiBut *but = eyedropper_get_property_button_under_mouse(C, event); uiBut *but = eyedropper_get_property_button_under_mouse(C, event);
const short mapping_type = RNA_enum_get(op->ptr, "mapping_type"); const short mapping_type = RNA_enum_get(op->ptr, "mapping_type");
const short flag = 0; const short flag = 0;
/* we can only add a driver if we know what RNA property it corresponds to */ /* we can only add a driver if we know what RNA property it corresponds to */
if (but == NULL) { if (but == nullptr) {
return; return;
} }
/* Get paths for the source. */ /* Get paths for the source. */
@@ -112,7 +112,7 @@ static void driverdropper_sample(bContext *C, wmOperator *op, const wmEvent *eve
UI_context_update_anim_flag(C); UI_context_update_anim_flag(C);
DEG_relations_tag_update(CTX_data_main(C)); DEG_relations_tag_update(CTX_data_main(C));
DEG_id_tag_update(ddr->ptr.owner_id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); DEG_id_tag_update(ddr->ptr.owner_id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); /* XXX */ WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, nullptr); /* XXX */
} }
} }
@@ -133,7 +133,7 @@ static void driverdropper_cancel(bContext *C, wmOperator *op)
/* main modal status check */ /* main modal status check */
static int driverdropper_modal(bContext *C, wmOperator *op, const wmEvent *event) static int driverdropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
{ {
DriverDropper *ddr = op->customdata; DriverDropper *ddr = static_cast<DriverDropper *>(op->customdata);
/* handle modal keymap */ /* handle modal keymap */
if (event->type == EVT_MODAL_MAP) { if (event->type == EVT_MODAL_MAP) {
@@ -156,7 +156,7 @@ static int driverdropper_modal(bContext *C, wmOperator *op, const wmEvent *event
} }
/* Modal Operator init */ /* Modal Operator init */
static int driverdropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) static int driverdropper_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{ {
/* init */ /* init */
if (driverdropper_init(C, op)) { if (driverdropper_init(C, op)) {

View File

@@ -46,16 +46,16 @@
#include "DEG_depsgraph.h" #include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h" #include "DEG_depsgraph_build.h"
#include "eyedropper_intern.h" #include "eyedropper_intern.hh"
#include "interface_intern.h" #include "interface_intern.hh"
typedef struct EyedropperGPencil { struct EyedropperGPencil {
struct ColorManagedDisplay *display; struct ColorManagedDisplay *display;
/** color under cursor RGB */ /** color under cursor RGB */
float color[3]; float color[3];
/** Mode */ /** Mode */
int mode; int mode;
} EyedropperGPencil; };
/* Helper: Draw status message while the user is running the operator */ /* Helper: Draw status message while the user is running the operator */
static void eyedropper_gpencil_status_indicators(bContext *C) static void eyedropper_gpencil_status_indicators(bContext *C)
@@ -70,7 +70,7 @@ static void eyedropper_gpencil_status_indicators(bContext *C)
/* Initialize. */ /* Initialize. */
static bool eyedropper_gpencil_init(bContext *C, wmOperator *op) static bool eyedropper_gpencil_init(bContext *C, wmOperator *op)
{ {
EyedropperGPencil *eye = MEM_callocN(sizeof(EyedropperGPencil), __func__); EyedropperGPencil *eye = MEM_cnew<EyedropperGPencil>(__func__);
op->customdata = eye; op->customdata = eye;
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
@@ -87,7 +87,7 @@ static bool eyedropper_gpencil_init(bContext *C, wmOperator *op)
static void eyedropper_gpencil_exit(bContext *C, wmOperator *op) static void eyedropper_gpencil_exit(bContext *C, wmOperator *op)
{ {
/* Clear status message area. */ /* Clear status message area. */
ED_workspace_status_text(C, NULL); ED_workspace_status_text(C, nullptr);
MEM_SAFE_FREE(op->customdata); MEM_SAFE_FREE(op->customdata);
} }
@@ -100,7 +100,7 @@ static void eyedropper_add_material(bContext *C,
{ {
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
Object *ob = CTX_data_active_object(C); Object *ob = CTX_data_active_object(C);
Material *ma = NULL; Material *ma = nullptr;
bool found = false; bool found = false;
@@ -108,12 +108,12 @@ static void eyedropper_add_material(bContext *C,
short *totcol = BKE_object_material_len_p(ob); short *totcol = BKE_object_material_len_p(ob);
for (short i = 0; i < *totcol; i++) { for (short i = 0; i < *totcol; i++) {
ma = BKE_object_material_get(ob, i + 1); ma = BKE_object_material_get(ob, i + 1);
if (ma == NULL) { if (ma == nullptr) {
continue; continue;
} }
MaterialGPencilStyle *gp_style = ma->gp_style; MaterialGPencilStyle *gp_style = ma->gp_style;
if (gp_style != NULL) { if (gp_style != nullptr) {
/* Check stroke color. */ /* Check stroke color. */
bool found_stroke = compare_v3v3(gp_style->stroke_rgba, col_conv, 0.01f) && bool found_stroke = compare_v3v3(gp_style->stroke_rgba, col_conv, 0.01f) &&
(gp_style->flag & GP_MATERIAL_STROKE_SHOW); (gp_style->flag & GP_MATERIAL_STROKE_SHOW);
@@ -134,8 +134,8 @@ static void eyedropper_add_material(bContext *C,
/* Found existing material. */ /* Found existing material. */
if (found) { if (found) {
ob->actcol = i + 1; ob->actcol = i + 1;
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL); WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, nullptr);
WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, NULL); WM_main_add_notifier(NC_SPACE | ND_SPACE_VIEW3D, nullptr);
return; return;
} }
} }
@@ -147,13 +147,13 @@ static void eyedropper_add_material(bContext *C,
int idx; int idx;
Material *ma_new = BKE_gpencil_object_material_new(bmain, ob, "Material", &idx); Material *ma_new = BKE_gpencil_object_material_new(bmain, ob, "Material", &idx);
WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, &ob->id); WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, &ob->id);
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL); WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, nullptr);
DEG_relations_tag_update(bmain); DEG_relations_tag_update(bmain);
BLI_assert(ma_new != NULL); BLI_assert(ma_new != nullptr);
MaterialGPencilStyle *gp_style_new = ma_new->gp_style; MaterialGPencilStyle *gp_style_new = ma_new->gp_style;
BLI_assert(gp_style_new != NULL); BLI_assert(gp_style_new != nullptr);
/* Only create Stroke (default option). */ /* Only create Stroke (default option). */
if (only_stroke) { if (only_stroke) {
@@ -193,13 +193,13 @@ static void eyedropper_add_palette_color(bContext *C, const float col_conv[4])
Paint *vertexpaint = &gp_vertexpaint->paint; Paint *vertexpaint = &gp_vertexpaint->paint;
/* Check for Palette in Draw and Vertex Paint Mode. */ /* Check for Palette in Draw and Vertex Paint Mode. */
if (paint->palette == NULL) { if (paint->palette == nullptr) {
Palette *palette = BKE_palette_add(bmain, "Grease Pencil"); Palette *palette = BKE_palette_add(bmain, "Grease Pencil");
id_us_min(&palette->id); id_us_min(&palette->id);
BKE_paint_palette_set(paint, palette); BKE_paint_palette_set(paint, palette);
if (vertexpaint->palette == NULL) { if (vertexpaint->palette == nullptr) {
BKE_paint_palette_set(vertexpaint, palette); BKE_paint_palette_set(vertexpaint, palette);
} }
} }
@@ -280,7 +280,7 @@ static int eyedropper_gpencil_modal(bContext *C, wmOperator *op, const wmEvent *
/* Create material. */ /* Create material. */
eyedropper_gpencil_color_set(C, event, eye); eyedropper_gpencil_color_set(C, event, eye);
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, nullptr);
eyedropper_gpencil_exit(C, op); eyedropper_gpencil_exit(C, op);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
@@ -305,7 +305,7 @@ static int eyedropper_gpencil_modal(bContext *C, wmOperator *op, const wmEvent *
} }
/* Modal Operator init */ /* Modal Operator init */
static int eyedropper_gpencil_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) static int eyedropper_gpencil_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{ {
/* Init. */ /* Init. */
if (eyedropper_gpencil_init(C, op)) { if (eyedropper_gpencil_init(C, op)) {
@@ -337,12 +337,12 @@ static bool eyedropper_gpencil_poll(bContext *C)
{ {
/* Only valid if the current active object is grease pencil. */ /* Only valid if the current active object is grease pencil. */
Object *obact = CTX_data_active_object(C); Object *obact = CTX_data_active_object(C);
if ((obact == NULL) || (obact->type != OB_GPENCIL)) { if ((obact == nullptr) || (obact->type != OB_GPENCIL)) {
return false; return false;
} }
/* Test we have a window below. */ /* Test we have a window below. */
return (CTX_wm_window(C) != NULL); return (CTX_wm_window(C) != nullptr);
} }
void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot) void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot)
@@ -350,7 +350,7 @@ void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot)
static const EnumPropertyItem items_mode[] = { static const EnumPropertyItem items_mode[] = {
{0, "MATERIAL", 0, "Material", ""}, {0, "MATERIAL", 0, "Material", ""},
{1, "PALETTE", 0, "Palette", ""}, {1, "PALETTE", 0, "Palette", ""},
{0, NULL, 0, NULL, NULL}, {0, nullptr, 0, nullptr, nullptr},
}; };
/* identifiers */ /* identifiers */

View File

@@ -35,7 +35,7 @@ void datadropper_win_area_find(const struct bContext *C,
* *
* Special check for image or nodes where we MAY have HDR pixels which don't display. * Special check for image or nodes where we MAY have HDR pixels which don't display.
* *
* \note Exposed by 'eyedropper_intern.h' for use with color band picking. * \note Exposed by 'eyedropper_intern.hh' for use with color band picking.
*/ */
void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3]); void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3]);

View File

@@ -19,9 +19,9 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "eyedropper_intern.h" /* own include */ #include "eyedropper_intern.hh" /* own include */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* Keymap /* Keymap
@@ -36,14 +36,14 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf)
{EYE_MODAL_SAMPLE_CONFIRM, "SAMPLE_CONFIRM", 0, "Confirm Sampling", ""}, {EYE_MODAL_SAMPLE_CONFIRM, "SAMPLE_CONFIRM", 0, "Confirm Sampling", ""},
{EYE_MODAL_SAMPLE_BEGIN, "SAMPLE_BEGIN", 0, "Start Sampling", ""}, {EYE_MODAL_SAMPLE_BEGIN, "SAMPLE_BEGIN", 0, "Start Sampling", ""},
{EYE_MODAL_SAMPLE_RESET, "SAMPLE_RESET", 0, "Reset Sampling", ""}, {EYE_MODAL_SAMPLE_RESET, "SAMPLE_RESET", 0, "Reset Sampling", ""},
{0, NULL, 0, NULL, NULL}, {0, nullptr, 0, nullptr, nullptr},
}; };
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Eyedropper Modal Map"); wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Eyedropper Modal Map");
/* This function is called for each space-type, only needs to add map once. */ /* This function is called for each space-type, only needs to add map once. */
if (keymap && keymap->modal_items) { if (keymap && keymap->modal_items) {
return NULL; return nullptr;
} }
keymap = WM_modalkeymap_ensure(keyconf, "Eyedropper Modal Map", modal_items); keymap = WM_modalkeymap_ensure(keyconf, "Eyedropper Modal Map", modal_items);
@@ -66,7 +66,7 @@ wmKeyMap *eyedropper_colorband_modal_keymap(wmKeyConfig *keyconf)
{EYE_MODAL_POINT_SAMPLE, "SAMPLE_SAMPLE", 0, "Sample a Point", ""}, {EYE_MODAL_POINT_SAMPLE, "SAMPLE_SAMPLE", 0, "Sample a Point", ""},
{EYE_MODAL_POINT_CONFIRM, "SAMPLE_CONFIRM", 0, "Confirm Sampling", ""}, {EYE_MODAL_POINT_CONFIRM, "SAMPLE_CONFIRM", 0, "Confirm Sampling", ""},
{EYE_MODAL_POINT_RESET, "SAMPLE_RESET", 0, "Reset Sampling", ""}, {EYE_MODAL_POINT_RESET, "SAMPLE_RESET", 0, "Reset Sampling", ""},
{0, NULL, 0, NULL, NULL}, {0, nullptr, 0, nullptr, nullptr},
}; };
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Eyedropper ColorRamp PointSampling Map"); wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Eyedropper ColorRamp PointSampling Map");
@@ -107,7 +107,7 @@ static void eyedropper_draw_cursor_text_ex(const int xy[2], const char *name)
UI_fontstyle_draw_simple_backdrop(fstyle, xy[0], xy[1] + U.widget_unit, name, col_fg, col_bg); UI_fontstyle_draw_simple_backdrop(fstyle, xy[0], xy[1] + U.widget_unit, name, col_fg, col_bg);
} }
void eyedropper_draw_cursor_text_window(const struct wmWindow *window, const char *name) void eyedropper_draw_cursor_text_window(const wmWindow *window, const char *name)
{ {
if (name[0] == '\0') { if (name[0] == '\0') {
return; return;
@@ -133,8 +133,8 @@ uiBut *eyedropper_get_property_button_under_mouse(bContext *C, const wmEvent *ev
uiBut *but = ui_but_find_mouse_over(region, event); uiBut *but = ui_but_find_mouse_over(region, event);
if (ELEM(NULL, but, but->rnapoin.data, but->rnaprop)) { if (ELEM(nullptr, but, but->rnapoin.data, but->rnaprop)) {
return NULL; return nullptr;
} }
return but; return but;
} }
@@ -146,7 +146,7 @@ void datadropper_win_area_find(
*r_win = CTX_wm_window(C); *r_win = CTX_wm_window(C);
*r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mval); *r_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mval);
if (*r_area == NULL) { if (*r_area == nullptr) {
*r_win = WM_window_find_under_cursor(*r_win, mval, r_mval); *r_win = WM_window_find_under_cursor(*r_win, mval, r_mval);
if (*r_win) { if (*r_win) {
screen = WM_window_get_active_screen(*r_win); screen = WM_window_get_active_screen(*r_win);

View File

@@ -73,7 +73,7 @@
#include "DEG_depsgraph_query.h" #include "DEG_depsgraph_query.h"
#include "interface_intern.h" #include "interface_intern.hh"
using blender::Vector; using blender::Vector;

View File

@@ -14,7 +14,7 @@
#include "UI_interface.h" #include "UI_interface.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
@@ -41,7 +41,7 @@
* This will probably not work in all possible cases, * This will probably not work in all possible cases,
* but not sure we want to support such exotic cases anyway. * but not sure we want to support such exotic cases anyway.
*/ */
typedef struct ButAlign { struct ButAlign {
uiBut *but; uiBut *but;
/* Neighbor buttons */ /* Neighbor buttons */
@@ -56,7 +56,7 @@ typedef struct ButAlign {
/* Flags, used to mark whether we should 'stitch' /* Flags, used to mark whether we should 'stitch'
* the corners of this button with its neighbors' ones. */ * the corners of this button with its neighbors' ones. */
char flags[4]; char flags[4];
} ButAlign; };
/* Side-related enums and flags. */ /* Side-related enums and flags. */
enum { enum {
@@ -168,7 +168,7 @@ static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other
/* We found an as close or closer neighbor. /* We found an as close or closer neighbor.
* If both buttons are alignable, we set them as each other neighbors. * 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 * 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. * is really lower with current one.
* *
* NOTE: We cannot only execute that piece of code in case we found a * 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; butal_other->neighbors[side_opp] = butal;
} }
else if (butal_can_align && (delta < butal->dists[side])) { 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])) { 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; 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 = STITCH(side);
const int stitch_opp = STITCH(side_opp); const int stitch_opp = STITCH(side_opp);
if (butal->neighbors[side] == NULL) { if (butal->neighbors[side] == nullptr) {
butal->neighbors[side] = butal_other; 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; 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) static int ui_block_align_butal_cmp(const void *a, const void *b)
{ {
const ButAlign *butal = a; const ButAlign *butal = static_cast<const ButAlign *>(a);
const ButAlign *butal_other = b; const ButAlign *butal_other = static_cast<const ButAlign *>(b);
/* Sort by align group. */ /* Sort by align group. */
if (butal->but->alignnr != butal_other->but->alignnr) { 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; butal_array = butal_array_buf;
} }
else { 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); 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) 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; int flag = 0, cols = 0, rows = 0;
/* auto align */ /* 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. /* NOTE: manipulation of 'flag' in the loop below is confusing.
* In some cases it's assigned, other times OR is used. */ * 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; next = but->next;
if (next && next->alignnr != nr) { if (next && next->alignnr != nr) {
next = NULL; next = nullptr;
} }
/* clear old flag */ /* 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 (prev) {
if (buts_are_horiz(prev, but)) { if (buts_are_horiz(prev, but)) {
if (rows == 0) { if (rows == 0) {
@@ -622,7 +623,7 @@ static void ui_block_align_calc_but(uiBut *first, short nr)
} }
bt = bt->next; bt = bt->next;
} }
if (bt == NULL || bt->alignnr != nr) { if (bt == nullptr || bt->alignnr != nr) {
flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT; 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; short nr;

View File

@@ -40,7 +40,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "interface_intern.h" #include "interface_intern.hh"
static FCurve *ui_but_get_fcurve( static FCurve *ui_but_get_fcurve(
uiBut *but, AnimData **adt, bAction **action, bool *r_driven, bool *r_special) uiBut *but, AnimData **adt, bAction **action, bool *r_driven, bool *r_special)

View File

@@ -8,7 +8,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "interface_intern.h" #include "interface_intern.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/** \name Button Groups /** \name Button Groups

View File

@@ -30,7 +30,7 @@
#include "UI_interface.h" #include "UI_interface.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_prototypes.h" #include "RNA_prototypes.h"

View File

@@ -8,7 +8,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "interface_intern.h" #include "interface_intern.hh"
void UI_but_drag_set_id(uiBut *but, ID *id) void UI_but_drag_set_id(uiBut *but, ID *id)
{ {

View File

@@ -48,7 +48,7 @@
#include "UI_interface.h" #include "UI_interface.h"
/* own include */ /* own include */
#include "interface_intern.h" #include "interface_intern.hh"
static int roundboxtype = UI_CNR_ALL; static int roundboxtype = UI_CNR_ALL;

View File

@@ -5,9 +5,9 @@
* \ingroup edinterface * \ingroup edinterface
*/ */
#include <math.h> #include <cmath>
#include <stdlib.h> #include <cstdlib>
#include <string.h> #include <cstring>
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
@@ -62,7 +62,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "interface_intern.h" #include "interface_intern.hh"
#ifndef WITH_HEADLESS #ifndef WITH_HEADLESS
# define ICON_GRID_COLS 26 # define ICON_GRID_COLS 26
@@ -74,15 +74,15 @@
# define ICON_GRID_H 32 # define ICON_GRID_H 32
#endif /* WITH_HEADLESS */ #endif /* WITH_HEADLESS */
typedef struct IconImage { struct IconImage {
int w; int w;
int h; int h;
uint *rect; uint *rect;
const uchar *datatoc_rect; const uchar *datatoc_rect;
int datatoc_size; 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_PREVIEW 0
#define ICON_TYPE_COLOR_TEXTURE 1 #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_GPLAYER 8
#define ICON_TYPE_BLANK 9 #define ICON_TYPE_BLANK 9
typedef struct DrawInfo { struct DrawInfo {
int type; int type;
union { union {
@@ -123,26 +123,26 @@ typedef struct DrawInfo {
struct DrawInfo *next; struct DrawInfo *next;
} input; } input;
} data; } data;
} DrawInfo; };
typedef struct IconTexture { struct IconTexture {
struct GPUTexture *tex[2]; GPUTexture *tex[2];
int num_textures; int num_textures;
int w; int w;
int h; int h;
float invw; float invw;
float invh; float invh;
} IconTexture; };
typedef struct IconType { struct IconType {
int type; int type;
int theme_color; int theme_color;
} IconType; };
/* ******************* STATIC LOCAL VARS ******************* */ /* ******************* STATIC LOCAL VARS ******************* */
/* Static here to cache results of icon directory scan, so it's not /* Static here to cache results of icon directory scan, so it's not
* scanning the file-system each time the menu is drawn. */ * 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}; static IconTexture icongltex = {{NULL, NULL}, 0, 0, 0, 0.0f, 0.0f};
#ifndef WITH_HEADLESS #ifndef WITH_HEADLESS
@@ -168,12 +168,12 @@ static const IconType icontypes[] = {
static DrawInfo *def_internal_icon( static DrawInfo *def_internal_icon(
ImBuf *bbuf, int icon_id, int xofs, int yofs, int size, int type, int theme_color) 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->obj = NULL; /* icon is not for library object */
new_icon->id_type = 0; new_icon->id_type = 0;
DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo"); DrawInfo *di = MEM_cnew<DrawInfo>(__func__);
di->type = type; di->type = type;
if (ELEM(type, ICON_TYPE_COLOR_TEXTURE, ICON_TYPE_MONO_TEXTURE)) { 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; di->data.texture.h = size;
} }
else if (type == ICON_TYPE_BUFFER) { else if (type == ICON_TYPE_BUFFER) {
IconImage *iimg = MEM_callocN(sizeof(IconImage), "icon_img"); IconImage *iimg = MEM_cnew<IconImage>(__func__);
iimg->w = size; iimg->w = size;
iimg->h = size; iimg->h = size;
@@ -192,7 +192,7 @@ static DrawInfo *def_internal_icon(
if (bbuf) { if (bbuf) {
int y, imgsize; 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 */ /* Here we store the rect in the icon - same as before */
if (size == bbuf->x && size == bbuf->y && xofs == 0 && yofs == 0) { 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) 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->obj = NULL; /* icon is not for library object */
new_icon->id_type = 0; new_icon->id_type = 0;
DrawInfo *di = MEM_callocN(sizeof(DrawInfo), "drawinfo"); DrawInfo *di = MEM_cnew<DrawInfo>("drawinfo");
di->type = ICON_TYPE_VECTOR; di->type = ICON_TYPE_VECTOR;
di->data.vector.func = drawFunc; 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 /* 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). */ * (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_Theme_Store(&theme_state);
UI_SetTheme(SPACE_ACTION, RGN_TYPE_WINDOW); 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 int offset_write = (sy + by) * buf->x + (sx + bx);
const float blurred_alpha = blurred_alpha_buffer[blurred_alpha_offset]; const float blurred_alpha = blurred_alpha_buffer[blurred_alpha_offset];
const float border_srgb[4] = { 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 uint color_read = buf->rect[offset_write];
const uchar *orig_color = (uchar *)&color_read; 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); 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); BLI_listbase_clear(list);
const char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons"); const char *icondir = BKE_appdir_folder_id(BLENDER_DATAFILES, "icons");
@@ -1045,7 +1045,7 @@ static void init_iconfile_list(struct ListBase *list)
return; return;
} }
struct direntry *dir; direntry *dir;
const int totfile = BLI_filelist_dir_contents(icondir, &dir); const int totfile = BLI_filelist_dir_contents(icondir, &dir);
int index = 1; int index = 1;
@@ -1083,7 +1083,7 @@ static void init_iconfile_list(struct ListBase *list)
# endif /* removed */ # endif /* removed */
/* found a potential icon file, so make an entry for it in the cache list */ /* 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)); BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename));
ifile->index = index; ifile->index = index;
@@ -1099,12 +1099,9 @@ static void init_iconfile_list(struct ListBase *list)
dir = NULL; dir = NULL;
} }
static void free_iconfile_list(struct ListBase *list) static void free_iconfile_list(ListBase *list)
{ {
IconFile *ifile = NULL, *next_ifile = NULL; LISTBASE_FOREACH_MUTABLE (IconFile *, ifile, &iconfilelist) {
for (ifile = list->first; ifile; ifile = next_ifile) {
next_ifile = ifile->next;
BLI_freelinkN(list, ifile); BLI_freelinkN(list, ifile);
} }
} }
@@ -1119,10 +1116,7 @@ void UI_icons_reload_internal_textures(void)
int UI_iconfile_get_index(const char *filename) int UI_iconfile_get_index(const char *filename)
{ {
IconFile *ifile; LISTBASE_FOREACH (const IconFile *, ifile, &iconfilelist) {
ListBase *list = &(iconfilelist);
for (ifile = list->first; ifile; ifile = ifile->next) {
if (BLI_path_cmp(filename, ifile->filename) == 0) { if (BLI_path_cmp(filename, ifile->filename) == 0) {
return ifile->index; return ifile->index;
} }
@@ -1149,7 +1143,7 @@ void UI_icons_free(void)
void UI_icons_free_drawinfo(void *drawinfo) void UI_icons_free_drawinfo(void *drawinfo)
{ {
DrawInfo *di = drawinfo; DrawInfo *di = static_cast<DrawInfo *>(drawinfo);
if (di == NULL) { if (di == NULL) {
return; return;
@@ -1179,7 +1173,7 @@ static DrawInfo *icon_create_drawinfo(Icon *icon)
{ {
const int icon_data_type = icon->obj_type; 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)) { if (ELEM(icon_data_type, ICON_DATA_ID, ICON_DATA_PREVIEW)) {
di->type = ICON_TYPE_PREVIEW; di->type = ICON_TYPE_PREVIEW;
@@ -1206,7 +1200,7 @@ static DrawInfo *icon_create_drawinfo(Icon *icon)
static DrawInfo *icon_ensure_drawinfo(Icon *icon) static DrawInfo *icon_ensure_drawinfo(Icon *icon)
{ {
if (icon->drawinfo) { if (icon->drawinfo) {
return icon->drawinfo; return static_cast<DrawInfo *>(icon->drawinfo);
} }
DrawInfo *di = icon_create_drawinfo(icon); DrawInfo *di = icon_create_drawinfo(icon);
icon->drawinfo = di; icon->drawinfo = di;
@@ -1287,7 +1281,7 @@ int UI_icon_preview_to_render_size(enum eIconSizes size)
/* Create rect for the icon /* 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); 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->h[size] = render_size;
prv_img->flag[size] |= PRV_CHANGED; prv_img->flag[size] |= PRV_CHANGED;
prv_img->changed_timestamp[size] = 0; 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 **tmp = (Icon **)customdata;
Icon *icon = *tmp; Icon *icon = *tmp;
DrawInfo *di = icon_ensure_drawinfo(icon); 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); 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) 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. */ /* Happens if job was canceled or already finished. */
if (wm == NULL) { if (wm == NULL) {
@@ -1355,7 +1350,7 @@ static void ui_studiolight_icon_job_end(void *customdata)
{ {
Icon **tmp = (Icon **)customdata; Icon **tmp = (Icon **)customdata;
Icon *icon = *tmp; 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); 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) { switch (di->type) {
case ICON_TYPE_PREVIEW: { case ICON_TYPE_PREVIEW: {
ID *id = (icon->id_type != 0) ? icon->obj : NULL; ID *id = (icon->id_type != 0) ? static_cast<ID *>(icon->obj) : NULL;
PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) : icon->obj; PreviewImage *prv = id ? BKE_previewimg_id_ensure(id) :
static_cast<PreviewImage *>(icon->obj);
/* Using jobs for screen previews crashes due to off-screen rendering. /* Using jobs for screen previews crashes due to off-screen rendering.
* XXX: would be nicer if #PreviewImage could store if it supports jobs. */ * XXX: would be nicer if #PreviewImage could store if it supports jobs. */
const bool use_jobs = !id || (GS(id->name) != ID_SCR); 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 (icon->obj_type == ICON_DATA_STUDIOLIGHT) {
if (di->data.buffer.image == NULL) { if (di->data.buffer.image == NULL) {
wmWindowManager *wm = CTX_wm_manager(C); 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); 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->w = STUDIOLIGHT_ICON_SIZE;
img->h = STUDIOLIGHT_ICON_SIZE; img->h = STUDIOLIGHT_ICON_SIZE;
const size_t size = STUDIOLIGHT_ICON_SIZE * STUDIOLIGHT_ICON_SIZE * sizeof(uint); 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); memset(img->rect, 0, size);
di->data.buffer.image = img; di->data.buffer.image = img;
wmJob *wm_job = WM_jobs_get( wmJob *wm_job = WM_jobs_get(wm,
wm, CTX_wm_window(C), icon, "StudioLight Icon", 0, WM_JOB_TYPE_STUDIOLIGHT); CTX_wm_window(C),
Icon **tmp = MEM_callocN(sizeof(Icon *), __func__); icon,
"StudioLight Icon",
eWM_JobFlag(0),
WM_JOB_TYPE_STUDIOLIGHT);
Icon **tmp = MEM_cnew<Icon *>(__func__);
*tmp = icon; *tmp = icon;
WM_jobs_customdata_set(wm_job, tmp, MEM_freeN); WM_jobs_customdata_set(wm_job, tmp, MEM_freeN);
WM_jobs_timer(wm_job, 0.01, 0, NC_WINDOW); 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) { if (di->type == ICON_TYPE_PREVIEW) {
PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : PreviewImage *prv = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
icon->obj; static_cast<PreviewImage *>(icon->obj);
if (prv) { if (prv) {
return BKE_previewimg_copy(prv); return BKE_previewimg_copy(prv);
@@ -1581,16 +1581,16 @@ static void icon_draw_rect(float x,
* efficient than simple glUniform calls. */ * efficient than simple glUniform calls. */
#define ICON_DRAW_CACHE_SIZE 16 #define ICON_DRAW_CACHE_SIZE 16
typedef struct IconDrawCall { struct IconDrawCall {
rctf pos; rctf pos;
rctf tex; rctf tex;
float color[4]; float color[4];
} IconDrawCall; };
typedef struct IconTextureDrawCall { struct IconTextureDrawCall {
IconDrawCall drawcall_cache[ICON_DRAW_CACHE_SIZE]; IconDrawCall drawcall_cache[ICON_DRAW_CACHE_SIZE];
int calls; /* Number of calls batched together */ int calls; /* Number of calls batched together */
} IconTextureDrawCall; };
static struct { static struct {
IconTextureDrawCall normal; 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"); const int data_binding = GPU_shader_get_uniform_block_binding(shader, "multi_rect_data");
GPUUniformBuf *ubo = GPU_uniformbuf_create_ex( 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); GPU_uniformbuf_bind(ubo, data_binding);
const int img_binding = GPU_shader_get_texture_binding(shader, "image"); 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 *= zoom_factor;
fstyle_small.points *= 0.8f; fstyle_small.points *= 0.8f;
rcti text_rect = { rcti text_rect{};
.xmax = x + UI_UNIT_X * zoom_factor, text_rect.xmax = x + UI_UNIT_X * zoom_factor;
.xmin = x, text_rect.xmin = x;
.ymax = y, text_rect.ymax = y;
.ymin = y, text_rect.ymin = y;
};
uiFontStyleDraw_Params params{};
params.align = UI_STYLE_TEXT_RIGHT;
UI_fontstyle_draw(&fstyle_small, UI_fontstyle_draw(&fstyle_small,
&text_rect, &text_rect,
text_overlay->text, text_overlay->text,
sizeof(text_overlay->text), sizeof(text_overlay->text),
text_color, text_color,
&(struct uiFontStyleDraw_Params){ &params);
.align = UI_STYLE_TEXT_RIGHT,
});
text_width = (float)UI_fontstyle_string_width(&fstyle_small, text_overlay->text) / UI_UNIT_X / text_width = (float)UI_fontstyle_string_width(&fstyle_small, text_overlay->text) / UI_UNIT_X /
zoom_factor; 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"); const int rect_geom_loc = GPU_shader_get_uniform(shader, "rect_geom");
if (rgb) { 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 { 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}); const float tex_color[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 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_shader_uniform_1f(shader, "text_width", text_width);
GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false); 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(); UI_widgetbase_draw_cache_flush();
if (di->type == ICON_TYPE_IMBUF) { if (di->type == ICON_TYPE_IMBUF) {
ImBuf *ibuf = icon->obj; ImBuf *ibuf = static_cast<ImBuf *>(icon->obj);
GPU_blend(GPU_BLEND_ALPHA_PREMULT); GPU_blend(GPU_BLEND_ALPHA_PREMULT);
icon_draw_rect(x, y, w, h, aspect, ibuf->x, ibuf->y, ibuf->rect, alpha, desaturate); 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); IMB_freeImBuf(ibuf);
} }
if (invert != geom_inverted) { 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.image_cache = ibuf;
di->data.geom.inverted = invert; di->data.geom.inverted = invert;
} }
@@ -1984,7 +1988,7 @@ static void icon_draw_size(float x,
} }
else if (di->type == ICON_TYPE_PREVIEW) { else if (di->type == ICON_TYPE_PREVIEW) {
PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) : PreviewImage *pi = (icon->id_type != 0) ? BKE_previewimg_id_ensure((ID *)icon->obj) :
icon->obj; static_cast<PreviewImage *>(icon->obj);
if (pi) { if (pi) {
/* no create icon on this level in code */ /* 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 */ /* changed only ever set by dynamic icons */
if ((pi->flag[size] & PRV_CHANGED) || !pi->rect[size]) { if ((pi->flag[size] & PRV_CHANGED) || !pi->rect[size]) {
/* create the rect if necessary */ /* 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; 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. */ /* For objects, first try if a preview can created via the object data. */
if (GS(id->name) == ID_OB) { if (GS(id->name) == ID_OB) {
Object *ob = (Object *)id; Object *ob = (Object *)id;
if (ED_preview_id_is_supported(ob->data)) { if (ED_preview_id_is_supported(static_cast<const ID *>(ob->data))) {
id_to_render = 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; 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); 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) { else if (space_type == SPACE_IMAGE) {
if (area->spacetype == space_type) { 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) { if (sima->mode == SI_MODE_PAINT) {
paint_mode = PAINT_MODE_TEXTURE_2D; 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; id = ptr->owner_id;
} }
else if (RNA_struct_is_a(ptr->type, &RNA_MaterialSlot)) { 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)) { 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)) { else if (RNA_struct_is_a(ptr->type, &RNA_FileBrowserFSMenuEntry)) {
return RNA_int_get(ptr, "icon"); return RNA_int_get(ptr, "icon");
} }
else if (RNA_struct_is_a(ptr->type, &RNA_DynamicPaintSurface)) { 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) { if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) {
return ICON_SHADING_TEXTURE; 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)) { 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) { switch (sl->flag & STUDIOLIGHT_FLAG_ORIENTATIONS) {
case STUDIOLIGHT_TYPE_STUDIO: case STUDIOLIGHT_TYPE_STUDIO:
return sl->icon_id_irradiance; return sl->icon_id_irradiance;
@@ -2550,7 +2554,7 @@ ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon)
return NULL; return NULL;
#else #else
const int ALERT_IMG_SIZE = 256; 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 int left = icon * ALERT_IMG_SIZE;
const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1}; const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1};
ImBuf *ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_alert_icons_png, ImBuf *ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_alert_icons_png,

View File

@@ -18,7 +18,7 @@
#include "UI_interface.h" #include "UI_interface.h"
#include "interface_intern.h" #include "interface_intern.hh"
static void icon_draw_rect_input_text( static void icon_draw_rect_input_text(
const rctf *rect, const float color[4], const char *str, float font_size, float v_offset) const rctf *rect, const float color[4], const char *str, float font_size, float v_offset)

View File

@@ -48,7 +48,7 @@
#include "UI_interface.h" #include "UI_interface.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"

View File

@@ -48,7 +48,7 @@
#include "GPU_matrix.h" #include "GPU_matrix.h"
#include "GPU_state.h" #include "GPU_state.h"
#include "interface_intern.h" #include "interface_intern.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/** \name Defines & Structs /** \name Defines & Structs

View File

@@ -19,7 +19,7 @@
#include "RNA_access.h" #include "RNA_access.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"

View File

@@ -34,7 +34,7 @@
#include "IMB_colormanagement.h" #include "IMB_colormanagement.h"
#include "interface_intern.h" #include "interface_intern.hh"
enum ePickerType { enum ePickerType {
PICKER_TYPE_RGB = 0, PICKER_TYPE_RGB = 0,

View File

@@ -36,7 +36,7 @@
#include "ED_undo.h" #include "ED_undo.h"
#include "GPU_framebuffer.h" #include "GPU_framebuffer.h"
#include "interface_intern.h" #include "interface_intern.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/** \name Utilities /** \name Utilities

View File

@@ -36,7 +36,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "interface_regions_intern.hh" #include "interface_regions_intern.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@@ -39,7 +39,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "interface_regions_intern.hh" #include "interface_regions_intern.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@@ -45,7 +45,7 @@
#include "UI_interface.h" #include "UI_interface.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "interface_regions_intern.hh" #include "interface_regions_intern.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@@ -30,7 +30,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "interface_regions_intern.hh" #include "interface_regions_intern.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */

View File

@@ -41,7 +41,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "GPU_state.h" #include "GPU_state.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "interface_regions_intern.hh" #include "interface_regions_intern.hh"
#define MENU_BORDER int(0.3f * U.widget_unit) #define MENU_BORDER int(0.3f * U.widget_unit)

View File

@@ -52,7 +52,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "interface_regions_intern.hh" #include "interface_regions_intern.hh"
#define UI_TIP_PAD_FAC 1.3f #define UI_TIP_PAD_FAC 1.3f

View File

@@ -30,7 +30,7 @@
#include "ED_datafiles.h" #include "ED_datafiles.h"
#include "interface_intern.h" #include "interface_intern.hh"
#ifdef WIN32 #ifdef WIN32
# include "BLI_math_base.h" /* M_PI */ # include "BLI_math_base.h" /* M_PI */

View File

@@ -28,7 +28,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "interface_intern.h" #include "interface_intern.hh"
struct AssetViewListData { struct AssetViewListData {
AssetLibraryReference asset_library_ref; AssetLibraryReference asset_library_ref;

View File

@@ -30,7 +30,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "interface_intern.h" #include "interface_intern.hh"
/** /**
* The validated data that was passed to #uiTemplateList (typically through Python). * The validated data that was passed to #uiTemplateList (typically through Python).

View File

@@ -47,7 +47,7 @@
#include "WM_types.h" #include "WM_types.h"
#include "UI_interface.h" #include "UI_interface.h"
#include "interface_intern.h" #include "interface_intern.hh"
/* For key-map item access. */ /* For key-map item access. */
#include "wm_event_system.h" #include "wm_event_system.h"

View File

@@ -28,7 +28,7 @@
#include "WM_types.h" #include "WM_types.h"
#include "UI_interface.h" #include "UI_interface.h"
#include "interface_intern.h" #include "interface_intern.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/** \name Operator Search Template Implementation /** \name Operator Search Template Implementation

View File

@@ -15,7 +15,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "interface_intern.h" #include "interface_intern.hh"
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/** \name Text Field Undo Stack /** \name Text Field Undo Stack

View File

@@ -40,7 +40,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "interface_intern.h" #include "interface_intern.hh"
/*************************** RNA Utilities ******************************/ /*************************** RNA Utilities ******************************/

View File

@@ -5,9 +5,9 @@
* \ingroup edinterface * \ingroup edinterface
*/ */
#include <limits.h> #include <climits>
#include <stdlib.h> #include <cstdlib>
#include <string.h> #include <cstring>
#include "DNA_brush_types.h" #include "DNA_brush_types.h"
#include "DNA_screen_types.h" #include "DNA_screen_types.h"
@@ -32,7 +32,7 @@
#include "UI_interface_icons.h" #include "UI_interface_icons.h"
#include "UI_view2d.h" #include "UI_view2d.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "GPU_batch.h" #include "GPU_batch.h"
#include "GPU_batch_presets.h" #include "GPU_batch_presets.h"
@@ -55,7 +55,7 @@
/* visual types for drawing */ /* visual types for drawing */
/* for time being separated from functional types */ /* for time being separated from functional types */
typedef enum { enum uiWidgetTypeEnum {
/* default */ /* default */
UI_WTYPE_REGULAR, UI_WTYPE_REGULAR,
@@ -105,12 +105,12 @@ typedef enum {
UI_WTYPE_PROGRESSBAR, UI_WTYPE_PROGRESSBAR,
UI_WTYPE_NODESOCKET, UI_WTYPE_NODESOCKET,
UI_WTYPE_VIEW_ITEM, UI_WTYPE_VIEW_ITEM,
} uiWidgetTypeEnum; };
/** /**
* The button's state information adapted for drawing. Use #STATE_INFO_NULL for empty state. * 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). */ /** Copy of #uiBut.flag (possibly with overrides for drawing). */
int but_flag; int but_flag;
/** Copy of #uiBut.drawflag (possibly with overrides for drawing). */ /** Copy of #uiBut.drawflag (possibly with overrides for drawing). */
@@ -120,7 +120,7 @@ typedef struct {
bool has_hold_action : 1; bool has_hold_action : 1;
/** The button is in text input mode. */ /** The button is in text input mode. */
bool is_text_input : 1; bool is_text_input : 1;
} uiWidgetStateInfo; };
static const uiWidgetStateInfo STATE_INFO_NULL = {0}; 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 */ /* fill this struct with polygon info to draw AA'ed */
/* it has outline, back, and two optional tria meshes */ /* it has outline, back, and two optional tria meshes */
typedef struct uiWidgetTrias { struct uiWidgetTrias {
uint tot; uint tot;
int type; int type;
float size, center[2]; float size, center[2];
float vec[16][2]; float vec[16][2];
const uint (*index)[3]; const uint (*index)[3];
};
} uiWidgetTrias;
/* max as used by round_box__edges */ /* max as used by round_box__edges */
/* Make sure to change widget_base_vert.glsl accordingly. */ /* Make sure to change widget_base_vert.glsl accordingly. */
#define WIDGET_CURVE_RESOLU 9 #define WIDGET_CURVE_RESOLU 9
#define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU * 4) #define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU * 4)
typedef struct uiWidgetBase { struct uiWidgetBase {
/* TODO: remove these completely. */ /* TODO: remove these completely. */
int totvert, halfwayvert; int totvert, halfwayvert;
float outer_v[WIDGET_SIZE_MAX][2]; float outer_v[WIDGET_SIZE_MAX][2];
@@ -241,13 +240,13 @@ typedef struct uiWidgetBase {
/* Widget shader parameters, must match the shader layout. */ /* Widget shader parameters, must match the shader layout. */
uiWidgetBaseParameters uniform_params; uiWidgetBaseParameters uniform_params;
} uiWidgetBase; };
/** /**
* For time being only for visual appearance, * For time being only for visual appearance,
* later, a handling callback can be added too. * later, a handling callback can be added too.
*/ */
typedef struct uiWidgetType { struct uiWidgetType {
/* pointer to theme color definition */ /* pointer to theme color definition */
const uiWidgetColors *wcol_theme; const uiWidgetColors *wcol_theme;
@@ -272,8 +271,7 @@ typedef struct uiWidgetType {
void (*draw_block)( void (*draw_block)(
uiWidgetColors *, rcti *, int block_flag, int roundboxalign, const float zoom); uiWidgetColors *, rcti *, int block_flag, int roundboxalign, const float zoom);
void (*text)(const uiFontStyle *, const uiWidgetColors *, uiBut *, rcti *); 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) 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; *data = d;
} }
@@ -436,7 +434,7 @@ static uint32_t set_roundbox_vertex(GPUVertBufRaw *vflag_step,
bool emboss, bool emboss,
int color) 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_id;
*data |= corner_v << 2; *data |= corner_v << 2;
*data |= jit_v << 6; *data |= jit_v << 6;
@@ -448,7 +446,7 @@ static uint32_t set_roundbox_vertex(GPUVertBufRaw *vflag_step,
GPUBatch *ui_batch_roundbox_widget_get(void) 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()); GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format());
GPU_vertbuf_data_alloc(vbo, 12); GPU_vertbuf_data_alloc(vbo, 12);
@@ -474,7 +472,7 @@ GPUBatch *ui_batch_roundbox_widget_get(void)
GPUBatch *ui_batch_roundbox_shadow_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; uint32_t last_data;
GPUVertBufRaw vflag_step; GPUVertBufRaw vflag_step;
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); 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( 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); gpu_batch_presets_register(g_ui_batch_cache.roundbox_shadow);
} }
return 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, static void widget_draw_vertex_buffer(uint pos,
uint col, uint col,
int mode, GPUPrimType mode,
const float quads_pos[WIDGET_SIZE_MAX][2], const float quads_pos[WIDGET_SIZE_MAX][2],
const uchar quads_col[WIDGET_SIZE_MAX][4], const uchar quads_col[WIDGET_SIZE_MAX][4],
uint totvert) 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_verts_to_triangle_strip(wtb, wtb->totvert, triangle_strip);
widget_draw_vertex_buffer( 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, 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]); BLI_assert(str[0]);
/* How many BYTES (not characters) of this utf-8 string can fit, along with appended ellipsis. */ /* 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) { if (l_end > 0) {
/* At least one character, so clip and add the ellipsis. */ /* 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 { else {
/* Otherwise fit as much as we can without adding an ellipsis. */ /* 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'; str[l_end] = '\0';
if (r_final_len) { if (r_final_len) {
*r_final_len = (size_t)l_end; *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 int sep_len = sizeof(sep) - 1;
const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 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; float rpart_width = 0.0f;
size_t rpart_len = 0; size_t rpart_len = 0;
size_t final_lpart_len; 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. /* Not enough place for actual label, just display protected right part.
* Here just for safety, should never happen in real life! */ * Here just for safety, should never happen in real life! */
memmove(str, rpart, rpart_len + 1); memmove(str, rpart, rpart_len + 1);
rpart = NULL; rpart = nullptr;
okwidth += rpart_width; okwidth += rpart_width;
strwidth = 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( 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 (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, /* If we really have no place, or we would clip a very small piece of string in the middle,
* only show start of string. * only show start of string.
@@ -1586,7 +1585,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
else { else {
size_t r_offset, r_len; 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'. */ r_len = strlen(str + r_offset) + 1; /* +1 for the trailing '\0'. */
if (l_end + sep_len + r_len + rpart_len > max_len) { 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; int drawstr_left_len = UI_MAX_DRAW_STR;
const char *drawstr = but->drawstr; const char *drawstr = but->drawstr;
const char *drawstr_right = NULL; const char *drawstr_right = nullptr;
bool use_right_only = false; bool use_right_only = false;
#ifdef WITH_INPUT_IME #ifdef WITH_INPUT_IME
@@ -1901,7 +1900,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
else { else {
if (but->editstr) { if (but->editstr) {
/* max length isn't used in this case, /* 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; drawstr_left_len = INT_MAX;
#ifdef WITH_INPUT_IME #ifdef WITH_INPUT_IME
@@ -2058,7 +2057,7 @@ static void widget_draw_text(const uiFontStyle *fstyle,
bool use_drawstr_right_as_hint = false; bool use_drawstr_right_as_hint = false;
/* cut string in 2 parts - only for menu entries */ /* 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); drawstr_right = strrchr(drawstr, UI_SEP_CHAR);
if (drawstr_right) { if (drawstr_right) {
use_drawstr_right_as_hint = true; 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) && if (!drawstr_right && (but->drawflag & UI_BUT_TEXT_LEFT) &&
ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) && ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) &&
/* if we're editing or multi-drag (fake editing), then use left alignment */ /* 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, ':'); drawstr_right = strrchr(drawstr + but->ofs, ':');
if (drawstr_right) { if (drawstr_right) {
drawstr_right++; drawstr_right++;
@@ -2097,17 +2096,17 @@ static void widget_draw_text(const uiFontStyle *fstyle,
(drawstr_left_len - but->ofs); (drawstr_left_len - but->ofs);
if (drawlen > 0) { if (drawlen > 0) {
uiFontStyleDraw_Params params{};
params.align = align;
UI_fontstyle_draw_ex(fstyle, UI_fontstyle_draw_ex(fstyle,
rect, rect,
drawstr + but->ofs, drawstr + but->ofs,
drawlen, drawlen,
wcol->text, wcol->text,
&(struct uiFontStyleDraw_Params){ &params,
.align = align,
},
&font_xofs, &font_xofs,
&font_yofs, &font_yofs,
NULL); nullptr);
if (but->menu_key != '\0') { if (but->menu_key != '\0') {
const char *drawstr_ofs = drawstr + but->ofs; 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. */ /* Find upper case, fallback to lower case. */
const char *drawstr_end = drawstr_ofs + drawlen; 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++) { for (int i = 0; i < ARRAY_SIZE(keys); i++) {
const char *drawstr_menu = strchr(drawstr_ofs, 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); ul_index = (int)(drawstr_menu - drawstr_ofs);
break; break;
} }
@@ -2153,14 +2152,9 @@ static void widget_draw_text(const uiFontStyle *fstyle,
} }
rect->xmax -= UI_TEXT_CLIP_MARGIN; rect->xmax -= UI_TEXT_CLIP_MARGIN;
UI_fontstyle_draw(fstyle, uiFontStyleDraw_Params params{};
rect, params.align = UI_STYLE_TEXT_RIGHT;
drawstr_right, UI_fontstyle_draw(fstyle, rect, drawstr_right, UI_MAX_DRAW_STR, col, &params);
UI_MAX_DRAW_STR,
col,
&(struct uiFontStyleDraw_Params){
.align = UI_STYLE_TEXT_RIGHT,
});
} }
} }
@@ -2219,7 +2213,7 @@ static void widget_draw_node_link_socket(const uiWidgetColors *wcol,
UI_widgetbase_draw_cache_flush(); UI_widgetbase_draw_cache_flush();
GPU_blend(GPU_BLEND_NONE); 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 { else {
widget_draw_icon(but, ICON_LAYER_USED, alpha, rect, wcol->text); 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 */ /* Big previews with optional text label below */
if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) { 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 icon_size = BLI_rcti_size_y(rect);
int text_size = 0; int text_size = 0;
@@ -2300,7 +2294,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
} }
#endif #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 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_size = icon_size_init / (but->block->aspect * U.inv_dpi_fac);
const float icon_padding = 2 * UI_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; rect->xmin += text_padding;
} }
else if (but->flag & UI_BUT_DRAG_MULTI) { 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)) { if (text_is_edited || (but->drawflag & UI_BUT_TEXT_LEFT)) {
rect->xmin += text_padding; 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. */ /* Explicitly require #UI_EMBOSS_NONE_OR_STATUS for color blending with no emboss. */
if (emboss == UI_EMBOSS_NONE) { if (emboss == UI_EMBOSS_NONE) {
return NULL; return nullptr;
} }
if (state->but_drawflag & UI_BUT_ANIMATED_CHANGED) { 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) { if (state->but_flag & UI_BUT_OVERRIDDEN) {
return wcol_state->inner_overridden_sel; return wcol_state->inner_overridden_sel;
} }
return NULL; return nullptr;
} }
/* copy colors from theme, and set changes in it based on state */ /* 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) { if (state->but_flag & UI_SELECT) {
copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); 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); 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.inner, wt->wcol.inner_sel);
copy_v4_v4_uchar(wt->wcol.text, wt->wcol.text_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); 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); widget_state(wt, state, emboss);
const uchar *color_blend = widget_color_blend_from_flags(wcol_state, 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. /* 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, * 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). */ * 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, static void widget_state_nothing(uiWidgetType *wt,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
eUIEmbossType UNUSED(emboss)) eUIEmbossType /*emboss*/)
{ {
wt->wcol = *(wt->wcol_theme); wt->wcol = *(wt->wcol_theme);
} }
/* special case, button that calls pulldown */ /* special case, button that calls pulldown */
static void widget_state_pulldown(uiWidgetType *wt, static void widget_state_pulldown(uiWidgetType *wt,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
eUIEmbossType UNUSED(emboss)) eUIEmbossType /*emboss*/)
{ {
wt->wcol = *(wt->wcol_theme); wt->wcol = *(wt->wcol_theme);
} }
@@ -2639,7 +2633,7 @@ static void widget_state_pulldown(uiWidgetType *wt,
/* special case, pie menu items */ /* special case, pie menu items */
static void widget_state_pie_menu_item(uiWidgetType *wt, static void widget_state_pie_menu_item(uiWidgetType *wt,
const uiWidgetStateInfo *state, const uiWidgetStateInfo *state,
eUIEmbossType UNUSED(emboss)) eUIEmbossType /*emboss*/)
{ {
wt->wcol = *(wt->wcol_theme); wt->wcol = *(wt->wcol_theme);
@@ -2673,7 +2667,7 @@ static void widget_state_pie_menu_item(uiWidgetType *wt,
/* special case, menu items */ /* special case, menu items */
static void widget_state_menu_item(uiWidgetType *wt, static void widget_state_menu_item(uiWidgetType *wt,
const uiWidgetStateInfo *state, const uiWidgetStateInfo *state,
eUIEmbossType UNUSED(emboss)) eUIEmbossType /*emboss*/)
{ {
wt->wcol = *(wt->wcol_theme); 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_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(); 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 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; 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]; float rgb[3], hsv[3], rgb_center[3];
const bool is_color_gamma = ui_but_is_color_gamma(but); 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; const uiButHSVCube *hsv_but = (uiButHSVCube *)but;
float rgb[3]; float rgb[3];
float x = 0.0f, y = 0.0f; 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 = cpicker->hsv_perceptual;
float hsv_n[3]; 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); round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
/* setup temp colors */ /* setup temp colors */
widgetbase_draw(&wtb, uiWidgetColors colors{};
&((uiWidgetColors){ colors.outline[0] = 0;
.outline = {0, 0, 0, 255}, colors.outline[1] = 0;
.inner = {128, 128, 128, 255}, colors.outline[2] = 0;
.shadetop = 127, colors.outline[3] = 255;
.shadedown = -128, colors.inner[0] = 128;
.shaded = 1, 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. */ /* We are drawing on top of widget bases. Flush cache. */
GPU_blend(GPU_BLEND_ALPHA); GPU_blend(GPU_BLEND_ALPHA);
@@ -3411,7 +3410,7 @@ static void widget_numbut(uiWidgetColors *wcol,
static void widget_menubut(uiWidgetColors *wcol, static void widget_menubut(uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int roundboxalign, int roundboxalign,
const float zoom) const float zoom)
{ {
@@ -3435,11 +3434,11 @@ static void widget_menubut(uiWidgetColors *wcol,
/** /**
* Draw menu buttons still with triangles when field is not embossed * 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, uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int UNUSED(roundboxalign)) int /*roundboxalign*/)
{ {
uiWidgetBase wtb; uiWidgetBase wtb;
widget_init(&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 * 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, uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *state, const uiWidgetStateInfo *state,
@@ -3548,8 +3547,8 @@ static void widget_scroll(uiBut *but,
uiWidgetColors *wcol, uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *state, const uiWidgetStateInfo *state,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float UNUSED(zoom)) const float /*zoom*/)
{ {
/* calculate slider part */ /* calculate slider part */
const float value = (float)ui_but_value_get(but); 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, static void widget_progressbar(uiBut *but,
uiWidgetColors *wcol, uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int roundboxalign, int roundboxalign,
const float zoom) const float zoom)
{ {
@@ -3638,7 +3637,7 @@ static void widget_progressbar(uiBut *but,
static void widget_view_item(uiWidgetColors *wcol, static void widget_view_item(uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *state, const uiWidgetStateInfo *state,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float zoom) const float zoom)
{ {
uiWidgetBase wtb; uiWidgetBase wtb;
@@ -3657,9 +3656,9 @@ static void widget_view_item(uiWidgetColors *wcol,
static void widget_nodesocket(uiBut *but, static void widget_nodesocket(uiBut *but,
uiWidgetColors *wcol, uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float UNUSED(zoom)) const float /*zoom*/)
{ {
const int radi = 0.25f * BLI_rcti_size_y(rect); 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, static void widget_unitvec(uiBut *but,
uiWidgetColors *wcol, uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float zoom) const float zoom)
{ {
const float rad = widget_radius_from_zoom(zoom, wcol); 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, static void widget_preview_tile(uiBut *but,
uiWidgetColors *wcol, uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float UNUSED(zoom)) const float /*zoom*/)
{ {
const uiStyle *style = UI_style_get(); const uiStyle *style = UI_style_get();
ui_draw_preview_item_stateless( ui_draw_preview_item_stateless(
@@ -3972,7 +3971,7 @@ static void widget_preview_tile(uiBut *but,
static void widget_menuiconbut(uiWidgetColors *wcol, static void widget_menuiconbut(uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int roundboxalign, int roundboxalign,
const float zoom) const float zoom)
{ {
@@ -4020,8 +4019,8 @@ static void widget_pulldownbut(uiWidgetColors *wcol,
static void widget_menu_itembut(uiWidgetColors *wcol, static void widget_menu_itembut(uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float zoom) const float zoom)
{ {
uiWidgetBase wtb; uiWidgetBase wtb;
@@ -4044,8 +4043,8 @@ static void widget_menu_itembut(uiWidgetColors *wcol,
static void widget_menu_itembut_unpadded(uiWidgetColors *wcol, static void widget_menu_itembut_unpadded(uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float zoom) const float zoom)
{ {
/* This function is used for menu items placed close to each other horizontally, e.g. the matcap /* 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, static void widget_menu_radial_itembut(uiBut *but,
uiWidgetColors *wcol, uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float zoom) const float zoom)
{ {
const float fac = but->block->pie_data.alphafac; 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, static void widget_list_itembut(uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float zoom) const float zoom)
{ {
uiWidgetBase wtb; uiWidgetBase wtb;
@@ -4110,8 +4109,8 @@ static void widget_list_itembut(uiWidgetColors *wcol,
static void widget_optionbut(uiWidgetColors *wcol, static void widget_optionbut(uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *state, const uiWidgetStateInfo *state,
int UNUSED(roundboxalign), int /*roundboxalign*/,
const float UNUSED(zoom)) const float /*zoom*/)
{ {
/* For a right aligned layout (signified by #UI_BUT_TEXT_RIGHT), draw the text on the left of the /* For a right aligned layout (signified by #UI_BUT_TEXT_RIGHT), draw the text on the left of the
* checkbox. */ * checkbox. */
@@ -4187,7 +4186,7 @@ static void widget_state_label(uiWidgetType *wt,
static void widget_radiobut(uiWidgetColors *wcol, static void widget_radiobut(uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int roundboxalign, int roundboxalign,
const float zoom) const float zoom)
{ {
@@ -4203,7 +4202,7 @@ static void widget_radiobut(uiWidgetColors *wcol,
static void widget_box(uiBut *but, static void widget_box(uiBut *but,
uiWidgetColors *wcol, uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int roundboxalign, int roundboxalign,
const float zoom) const float zoom)
{ {
@@ -4214,7 +4213,7 @@ static void widget_box(uiBut *but,
copy_v3_v3_uchar(old_col, wcol->inner); copy_v3_v3_uchar(old_col, wcol->inner);
/* abuse but->hsv - if it's non-zero, use this color as the box's background */ /* 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[0] = but->col[0];
wcol->inner[1] = but->col[1]; wcol->inner[1] = but->col[1];
wcol->inner[2] = but->col[2]; wcol->inner[2] = but->col[2];
@@ -4231,7 +4230,7 @@ static void widget_box(uiBut *but,
static void widget_but(uiWidgetColors *wcol, static void widget_but(uiWidgetColors *wcol,
rcti *rect, rcti *rect,
const uiWidgetStateInfo *UNUSED(state), const uiWidgetStateInfo * /*state*/,
int roundboxalign, int roundboxalign,
const float zoom) const float zoom)
{ {
@@ -4245,7 +4244,7 @@ static void widget_but(uiWidgetColors *wcol,
} }
#if 0 #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; uiWidgetBase wtb;
const float rad = wcol->roundness * U.widget_unit; 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.wcol_state = &btheme->tui.wcol_state;
wt.state = widget_state; wt.state = widget_state;
wt.draw = widget_but; wt.draw = widget_but;
wt.custom = NULL; wt.custom = nullptr;
wt.text = widget_draw_text_icon; wt.text = widget_draw_text_icon;
switch (type) { switch (type) {
@@ -4390,7 +4389,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break; break;
case UI_WTYPE_LABEL: case UI_WTYPE_LABEL:
wt.draw = NULL; wt.draw = nullptr;
wt.state = widget_state_label; wt.state = widget_state_label;
break; break;
@@ -4507,9 +4506,9 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break; break;
case UI_WTYPE_PREVIEW_TILE: case UI_WTYPE_PREVIEW_TILE:
wt.draw = NULL; wt.draw = nullptr;
/* Drawn via the `custom` callback. */ /* Drawn via the `custom` callback. */
wt.text = NULL; wt.text = nullptr;
wt.custom = widget_preview_tile; wt.custom = widget_preview_tile;
break; break;
@@ -4637,12 +4636,12 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
/** \name Public API /** \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(); bTheme *btheme = UI_GetTheme();
const ThemeUI *tui = &btheme->tui; const ThemeUI *tui = &btheme->tui;
const uiFontStyle *fstyle = &style->widget; const uiFontStyle *fstyle = &style->widget;
uiWidgetType *wt = NULL; uiWidgetType *wt = nullptr;
/* handle menus separately */ /* handle menus separately */
if (but->emboss == UI_EMBOSS_PULLDOWN) { 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; 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); 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); GPU_blend(GPU_BLEND_NONE);
} }
void ui_draw_popover_back(struct ARegion *region, void ui_draw_popover_back(ARegion *region, uiStyle * /*style*/, uiBlock *block, rcti *rect)
uiStyle *UNUSED(style),
uiBlock *block,
rcti *rect)
{ {
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK); uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
if (block) { 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_window_to_block_fl(region, block, &mval_origin[0], &mval_origin[1]);
ui_draw_popover_back_impl( ui_draw_popover_back_impl(
wt->wcol_theme, rect, block->direction, U.widget_unit / block->aspect, mval_origin); 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, pie_radius_external,
subd, subd,
btheme->tui.wcol_pie_menu.inner, btheme->tui.wcol_pie_menu.inner,
NULL, nullptr,
false); false);
} }
@@ -5231,7 +5227,7 @@ void ui_draw_pie_center(uiBlock *block)
pie_radius_external, pie_radius_external,
subd, subd,
btheme->tui.wcol_pie_menu.inner_sel, btheme->tui.wcol_pie_menu.inner_sel,
NULL, nullptr,
false); false);
} }
} }
@@ -5259,7 +5255,7 @@ void ui_draw_pie_center(uiBlock *block)
pie_confirm_external, pie_confirm_external,
subd, subd,
col, col,
NULL, nullptr,
false); 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) 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); uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
wt->state(wt, &STATE_INFO_NULL, UI_EMBOSS_UNDEFINED); 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); const int row_height = BLI_rcti_size_y(rect);
int max_hint_width = INT_MAX; int max_hint_width = INT_MAX;
int padding = 0.25f * row_height; int padding = 0.25f * row_height;
char *cpoin = NULL; char *cpoin = nullptr;
uiWidgetStateInfo state = {0}; uiWidgetStateInfo state = {0};
state.but_flag = but_flag; state.but_flag = but_flag;
@@ -5354,7 +5350,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
/* cut string in 2 parts? */ /* cut string in 2 parts? */
if (separator_type != UI_MENU_ITEM_SEPARATOR_NONE) { 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) { if (cpoin) {
*cpoin = 0; *cpoin = 0;
@@ -5400,19 +5396,12 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
} }
int xofs = 0, yofs = 0; int xofs = 0, yofs = 0;
struct ResultBLF info; ResultBLF info;
UI_fontstyle_draw_ex(fstyle, uiFontStyleDraw_Params params{};
rect, params.align = UI_STYLE_TEXT_LEFT;
drawstr, UI_fontstyle_draw_ex(
sizeof(drawstr), fstyle, rect, drawstr, sizeof(drawstr), wt->wcol.text, &params, &xofs, &yofs, &info);
wt->wcol.text, if (r_xmax != nullptr) {
&(struct uiFontStyleDraw_Params){
.align = UI_STYLE_TEXT_LEFT,
},
&xofs,
&yofs,
&info);
if (r_xmax != NULL) {
*r_xmax = xofs + info.width; *r_xmax = xofs + info.width;
} }
} }
@@ -5457,14 +5446,9 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
} }
rect->xmax = _rect.xmax - 5; rect->xmax = _rect.xmax - 5;
UI_fontstyle_draw(fstyle, uiFontStyleDraw_Params params{};
rect, params.align = UI_STYLE_TEXT_RIGHT;
hint_drawstr, UI_fontstyle_draw(fstyle, rect, hint_drawstr, sizeof(hint_drawstr), wt->wcol.text, &params);
sizeof(hint_drawstr),
wt->wcol.text,
&(struct uiFontStyleDraw_Params){
.align = UI_STYLE_TEXT_RIGHT,
});
*cpoin = UI_SEP_CHAR; *cpoin = UI_SEP_CHAR;
} }
} }
@@ -5487,7 +5471,7 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
rect->ymin += text_size; rect->ymin += text_size;
} }
GPU_blend(GPU_BLEND_ALPHA); 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); GPU_blend(GPU_BLEND_NONE);
if (!has_text) { if (!has_text) {
@@ -5513,14 +5497,9 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle,
BLI_strncpy(drawstr, name, sizeof(drawstr)); BLI_strncpy(drawstr, name, sizeof(drawstr));
UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0'); UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0');
UI_fontstyle_draw(fstyle, uiFontStyleDraw_Params params{};
&trect, params.align = text_align;
drawstr, UI_fontstyle_draw(fstyle, &trect, drawstr, sizeof(drawstr), text_col, &params);
sizeof(drawstr),
text_col,
&(struct uiFontStyleDraw_Params){
.align = text_align,
});
} }
} }

View File

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

View File

@@ -43,7 +43,7 @@
#include "UI_interface.h" #include "UI_interface.h"
#include "UI_view2d.h" #include "UI_view2d.h"
#include "interface_intern.h" #include "interface_intern.hh"
static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize); static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize);

View File

@@ -33,7 +33,7 @@
#include "UI_interface.h" #include "UI_interface.h"
#include "UI_view2d.h" #include "UI_view2d.h"
#include "interface_intern.h" #include "interface_intern.hh"
/* Compute display grid resolution /* Compute display grid resolution
********************************************************/ ********************************************************/

View File

@@ -4,7 +4,7 @@
* \ingroup edinterface * \ingroup edinterface
*/ */
#include "interface_intern.h" #include "interface_intern.hh"
#include "UI_abstract_view.hh" #include "UI_abstract_view.hh"

View File

@@ -12,7 +12,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "UI_interface.h" #include "UI_interface.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "UI_abstract_view.hh" #include "UI_abstract_view.hh"

View File

@@ -12,7 +12,7 @@
#include "WM_types.h" #include "WM_types.h"
#include "UI_interface.h" #include "UI_interface.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "UI_grid_view.hh" #include "UI_grid_view.hh"

View File

@@ -27,7 +27,7 @@
#include "ED_screen.h" #include "ED_screen.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "UI_interface.hh" #include "UI_interface.hh"

View File

@@ -11,7 +11,7 @@
#include "BLT_translation.h" #include "BLT_translation.h"
#include "interface_intern.h" #include "interface_intern.hh"
#include "UI_interface.h" #include "UI_interface.h"

View File

@@ -51,7 +51,7 @@
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "../interface/interface_intern.h" #include "../interface/interface_intern.hh"
#include "buttons_intern.h" /* own include */ #include "buttons_intern.h" /* own include */

View File

@@ -77,6 +77,8 @@
#include "FN_field.hh" #include "FN_field.hh"
#include "FN_field_cpp_type.hh" #include "FN_field_cpp_type.hh"
#include "../interface/interface_intern.hh" /* TODO: Remove */
#include "node_intern.hh" /* own include */ #include "node_intern.hh" /* own include */
namespace geo_log = blender::nodes::geo_eval_log; namespace geo_log = blender::nodes::geo_eval_log;
@@ -84,12 +86,6 @@ namespace geo_log = blender::nodes::geo_eval_log;
using blender::GPointer; using blender::GPointer;
using blender::Vector; using blender::Vector;
extern "C" {
/* XXX interface.h */
extern void ui_draw_dropshadow(
const rctf *rct, float radius, float aspect, float alpha, int select);
}
/** /**
* This is passed to many functions which draw the node editor. * This is passed to many functions which draw the node editor.
*/ */

View File

@@ -32,7 +32,7 @@
#include "NOD_socket.h" #include "NOD_socket.h"
#include "NOD_socket_declarations.hh" #include "NOD_socket_declarations.hh"
#include "../interface/interface_intern.h" /* XXX bad level */ #include "../interface/interface_intern.hh" /* XXX bad level */
#include "UI_interface.h" #include "UI_interface.h"
#include "ED_node.h" /* own include */ #include "ED_node.h" /* own include */