Cleanup: use const variables
This commit is contained in:
parent
cd29d76ab6
commit
dcdc0f177a
@ -132,10 +132,10 @@ static bool ui_but_is_unit_radians(const uiBut *but)
|
|||||||
|
|
||||||
void ui_block_to_window_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y)
|
void ui_block_to_window_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y)
|
||||||
{
|
{
|
||||||
int getsizex = BLI_rcti_size_x(®ion->winrct) + 1;
|
const int getsizex = BLI_rcti_size_x(®ion->winrct) + 1;
|
||||||
int getsizey = BLI_rcti_size_y(®ion->winrct) + 1;
|
const int getsizey = BLI_rcti_size_y(®ion->winrct) + 1;
|
||||||
int sx = region->winrct.xmin;
|
const int sx = region->winrct.xmin;
|
||||||
int sy = region->winrct.ymin;
|
const int sy = region->winrct.ymin;
|
||||||
|
|
||||||
float gx = *r_x;
|
float gx = *r_x;
|
||||||
float gy = *r_y;
|
float gy = *r_y;
|
||||||
@ -188,21 +188,21 @@ float ui_block_to_window_scale(const ARegion *region, uiBlock *block)
|
|||||||
/* for mouse cursor */
|
/* for mouse cursor */
|
||||||
void ui_window_to_block_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y)
|
void ui_window_to_block_fl(const ARegion *region, uiBlock *block, float *r_x, float *r_y)
|
||||||
{
|
{
|
||||||
int getsizex = BLI_rcti_size_x(®ion->winrct) + 1;
|
const int getsizex = BLI_rcti_size_x(®ion->winrct) + 1;
|
||||||
int getsizey = BLI_rcti_size_y(®ion->winrct) + 1;
|
const int getsizey = BLI_rcti_size_y(®ion->winrct) + 1;
|
||||||
int sx = region->winrct.xmin;
|
const int sx = region->winrct.xmin;
|
||||||
int sy = region->winrct.ymin;
|
const int sy = region->winrct.ymin;
|
||||||
|
|
||||||
float a = 0.5f * ((float)getsizex) * block->winmat[0][0];
|
const float a = 0.5f * ((float)getsizex) * block->winmat[0][0];
|
||||||
float b = 0.5f * ((float)getsizex) * block->winmat[1][0];
|
const float b = 0.5f * ((float)getsizex) * block->winmat[1][0];
|
||||||
float c = 0.5f * ((float)getsizex) * (1.0f + block->winmat[3][0]);
|
const float c = 0.5f * ((float)getsizex) * (1.0f + block->winmat[3][0]);
|
||||||
|
|
||||||
float d = 0.5f * ((float)getsizey) * block->winmat[0][1];
|
const float d = 0.5f * ((float)getsizey) * block->winmat[0][1];
|
||||||
float e = 0.5f * ((float)getsizey) * block->winmat[1][1];
|
const float e = 0.5f * ((float)getsizey) * block->winmat[1][1];
|
||||||
float f = 0.5f * ((float)getsizey) * (1.0f + block->winmat[3][1]);
|
const float f = 0.5f * ((float)getsizey) * (1.0f + block->winmat[3][1]);
|
||||||
|
|
||||||
float px = *r_x - sx;
|
const float px = *r_x - sx;
|
||||||
float py = *r_y - sy;
|
const float py = *r_y - sy;
|
||||||
|
|
||||||
*r_y = (a * (py - f) + d * (c - px)) / (a * e - d * b);
|
*r_y = (a * (py - f) + d * (c - px)) / (a * e - d * b);
|
||||||
*r_x = (px - b * (*r_y) - c) / a;
|
*r_x = (px - b * (*r_y) - c) / a;
|
||||||
@ -387,7 +387,7 @@ static void ui_block_bounds_calc_text(uiBlock *block, float offset)
|
|||||||
* offsets). */
|
* offsets). */
|
||||||
if (bt->next && ui_but_is_row_alignment_group(bt, bt->next)) {
|
if (bt->next && ui_but_is_row_alignment_group(bt, bt->next)) {
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int alignnr = bt->alignnr;
|
const int alignnr = bt->alignnr;
|
||||||
for (col_bt = bt; col_bt && col_bt->alignnr == alignnr; col_bt = col_bt->next) {
|
for (col_bt = bt; col_bt && col_bt->alignnr == alignnr; col_bt = col_bt->next) {
|
||||||
width += BLI_rctf_size_x(&col_bt->rect);
|
width += BLI_rctf_size_x(&col_bt->rect);
|
||||||
col_bt->rect.xmin += x1addval;
|
col_bt->rect.xmin += x1addval;
|
||||||
@ -421,7 +421,7 @@ static void ui_block_bounds_calc_text(uiBlock *block, float offset)
|
|||||||
for (col_bt = init_col_bt; col_bt; col_bt = col_bt->next) {
|
for (col_bt = init_col_bt; col_bt; col_bt = col_bt->next) {
|
||||||
/* Recognize a horizontally arranged alignment group and skip its items. */
|
/* Recognize a horizontally arranged alignment group and skip its items. */
|
||||||
if (col_bt->next && ui_but_is_row_alignment_group(col_bt, col_bt->next)) {
|
if (col_bt->next && ui_but_is_row_alignment_group(col_bt, col_bt->next)) {
|
||||||
int alignnr = col_bt->alignnr;
|
const int alignnr = col_bt->alignnr;
|
||||||
for (; col_bt && col_bt->alignnr == alignnr; col_bt = col_bt->next) {
|
for (; col_bt && col_bt->alignnr == alignnr; col_bt = col_bt->next) {
|
||||||
/* pass */
|
/* pass */
|
||||||
}
|
}
|
||||||
@ -465,7 +465,7 @@ void ui_block_bounds_calc(uiBlock *block)
|
|||||||
|
|
||||||
/* hardcoded exception... but that one is annoying with larger safety */
|
/* hardcoded exception... but that one is annoying with larger safety */
|
||||||
uiBut *bt = block->buttons.first;
|
uiBut *bt = block->buttons.first;
|
||||||
int xof = ((bt && STRPREFIX(bt->str, "ERROR")) ? 10 : 40) * U.dpi_fac;
|
const int xof = ((bt && STRPREFIX(bt->str, "ERROR")) ? 10 : 40) * U.dpi_fac;
|
||||||
|
|
||||||
block->safety.xmin = block->rect.xmin - xof;
|
block->safety.xmin = block->rect.xmin - xof;
|
||||||
block->safety.ymin = block->rect.ymin - xof;
|
block->safety.ymin = block->rect.ymin - xof;
|
||||||
@ -478,16 +478,16 @@ static void ui_block_bounds_calc_centered(wmWindow *window, uiBlock *block)
|
|||||||
/* note: this is used for the splash where window bounds event has not been
|
/* note: this is used for the splash where window bounds event has not been
|
||||||
* updated by ghost, get the window bounds from ghost directly */
|
* updated by ghost, get the window bounds from ghost directly */
|
||||||
|
|
||||||
int xmax = WM_window_pixels_x(window);
|
const int xmax = WM_window_pixels_x(window);
|
||||||
int ymax = WM_window_pixels_y(window);
|
const int ymax = WM_window_pixels_y(window);
|
||||||
|
|
||||||
ui_block_bounds_calc(block);
|
ui_block_bounds_calc(block);
|
||||||
|
|
||||||
int width = BLI_rctf_size_x(&block->rect);
|
const int width = BLI_rctf_size_x(&block->rect);
|
||||||
int height = BLI_rctf_size_y(&block->rect);
|
const int height = BLI_rctf_size_y(&block->rect);
|
||||||
|
|
||||||
int startx = (xmax * 0.5f) - (width * 0.5f);
|
const int startx = (xmax * 0.5f) - (width * 0.5f);
|
||||||
int starty = (ymax * 0.5f) - (height * 0.5f);
|
const int starty = (ymax * 0.5f) - (height * 0.5f);
|
||||||
|
|
||||||
UI_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin);
|
UI_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin);
|
||||||
|
|
||||||
@ -511,13 +511,13 @@ static void ui_block_bounds_calc_centered_pie(uiBlock *block)
|
|||||||
static void ui_block_bounds_calc_popup(
|
static void ui_block_bounds_calc_popup(
|
||||||
wmWindow *window, uiBlock *block, eBlockBoundsCalc bounds_calc, const int xy[2], int r_xy[2])
|
wmWindow *window, uiBlock *block, eBlockBoundsCalc bounds_calc, const int xy[2], int r_xy[2])
|
||||||
{
|
{
|
||||||
int oldbounds = block->bounds;
|
const int oldbounds = block->bounds;
|
||||||
|
|
||||||
/* compute mouse position with user defined offset */
|
/* compute mouse position with user defined offset */
|
||||||
ui_block_bounds_calc(block);
|
ui_block_bounds_calc(block);
|
||||||
|
|
||||||
int xmax = WM_window_pixels_x(window);
|
const int xmax = WM_window_pixels_x(window);
|
||||||
int ymax = WM_window_pixels_y(window);
|
const int ymax = WM_window_pixels_y(window);
|
||||||
|
|
||||||
int oldwidth = BLI_rctf_size_x(&block->rect);
|
int oldwidth = BLI_rctf_size_x(&block->rect);
|
||||||
int oldheight = BLI_rctf_size_y(&block->rect);
|
int oldheight = BLI_rctf_size_y(&block->rect);
|
||||||
@ -535,8 +535,8 @@ static void ui_block_bounds_calc_popup(
|
|||||||
ui_block_bounds_calc(block);
|
ui_block_bounds_calc(block);
|
||||||
|
|
||||||
/* and we adjust the position to fit within window */
|
/* and we adjust the position to fit within window */
|
||||||
int width = BLI_rctf_size_x(&block->rect);
|
const int width = BLI_rctf_size_x(&block->rect);
|
||||||
int height = BLI_rctf_size_y(&block->rect);
|
const int height = BLI_rctf_size_y(&block->rect);
|
||||||
|
|
||||||
/* avoid divide by zero below, caused by calling with no UI, but better not crash */
|
/* avoid divide by zero below, caused by calling with no UI, but better not crash */
|
||||||
oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width);
|
oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width);
|
||||||
@ -545,7 +545,8 @@ static void ui_block_bounds_calc_popup(
|
|||||||
/* offset block based on mouse position, user offset is scaled
|
/* offset block based on mouse position, user offset is scaled
|
||||||
* along in case we resized the block in ui_block_bounds_calc_text */
|
* along in case we resized the block in ui_block_bounds_calc_text */
|
||||||
rcti rect;
|
rcti rect;
|
||||||
int raw_x = rect.xmin = xy[0] + block->rect.xmin + (block->bounds_offset[0] * width) / oldwidth;
|
const int raw_x = rect.xmin = xy[0] + block->rect.xmin +
|
||||||
|
(block->bounds_offset[0] * width) / oldwidth;
|
||||||
int raw_y = rect.ymin = xy[1] + block->rect.ymin +
|
int raw_y = rect.ymin = xy[1] + block->rect.ymin +
|
||||||
(block->bounds_offset[1] * height) / oldheight;
|
(block->bounds_offset[1] * height) / oldheight;
|
||||||
rect.xmax = rect.xmin + width;
|
rect.xmax = rect.xmin + width;
|
||||||
@ -1700,7 +1701,7 @@ static bool ui_but_icon_extra_is_visible_search_eyedropper(uiBut *but)
|
|||||||
}
|
}
|
||||||
|
|
||||||
StructRNA *type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop);
|
StructRNA *type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop);
|
||||||
short idcode = RNA_type_to_ID_code(type);
|
const short idcode = RNA_type_to_ID_code(type);
|
||||||
|
|
||||||
return ((but->editstr == NULL) && (idcode == ID_OB || OB_DATA_SUPPORT_ID(idcode)));
|
return ((but->editstr == NULL) && (idcode == ID_OB || OB_DATA_SUPPORT_ID(idcode)));
|
||||||
}
|
}
|
||||||
@ -2739,7 +2740,7 @@ void ui_but_string_get_ex(uiBut *but,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TAB)) {
|
if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TAB)) {
|
||||||
PropertyType type = RNA_property_type(but->rnaprop);
|
const PropertyType type = RNA_property_type(but->rnaprop);
|
||||||
|
|
||||||
int buf_len;
|
int buf_len;
|
||||||
const char *buf = NULL;
|
const char *buf = NULL;
|
||||||
@ -2798,7 +2799,7 @@ void ui_but_string_get_ex(uiBut *but,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* number editing */
|
/* number editing */
|
||||||
double value = ui_but_value_get(but);
|
const double value = ui_but_value_get(but);
|
||||||
|
|
||||||
PropertySubType subtype = PROP_NONE;
|
PropertySubType subtype = PROP_NONE;
|
||||||
if (but->rnaprop) {
|
if (but->rnaprop) {
|
||||||
@ -2864,7 +2865,7 @@ char *ui_but_string_get_dynamic(uiBut *but, int *r_str_size)
|
|||||||
*r_str_size = 1;
|
*r_str_size = 1;
|
||||||
|
|
||||||
if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
|
if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
|
||||||
PropertyType type = RNA_property_type(but->rnaprop);
|
const PropertyType type = RNA_property_type(but->rnaprop);
|
||||||
|
|
||||||
if (type == PROP_STRING) {
|
if (type == PROP_STRING) {
|
||||||
/* RNA string */
|
/* RNA string */
|
||||||
@ -3031,7 +3032,7 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
|
|||||||
{
|
{
|
||||||
if (but->rnaprop && but->rnapoin.data && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
|
if (but->rnaprop && but->rnapoin.data && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
|
||||||
if (RNA_property_editable(&but->rnapoin, but->rnaprop)) {
|
if (RNA_property_editable(&but->rnapoin, but->rnaprop)) {
|
||||||
PropertyType type = RNA_property_type(but->rnaprop);
|
const PropertyType type = RNA_property_type(but->rnaprop);
|
||||||
|
|
||||||
if (type == PROP_STRING) {
|
if (type == PROP_STRING) {
|
||||||
/* RNA string */
|
/* RNA string */
|
||||||
@ -3719,7 +3720,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
|
|||||||
case UI_BTYPE_LABEL:
|
case UI_BTYPE_LABEL:
|
||||||
if (ui_but_is_float(but)) {
|
if (ui_but_is_float(but)) {
|
||||||
UI_GET_BUT_VALUE_INIT(but, value);
|
UI_GET_BUT_VALUE_INIT(but, value);
|
||||||
int prec = ui_but_calc_float_precision(but, value);
|
const int prec = ui_but_calc_float_precision(but, value);
|
||||||
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
|
BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -4020,7 +4021,7 @@ static uiBut *ui_def_but(uiBlock *block,
|
|||||||
|
|
||||||
but->retval = retval;
|
but->retval = retval;
|
||||||
|
|
||||||
int slen = strlen(str);
|
const int slen = strlen(str);
|
||||||
ui_but_string_set_internal(but, str, slen);
|
ui_but_string_set_internal(but, str, slen);
|
||||||
|
|
||||||
but->rect.xmin = x;
|
but->rect.xmin = x;
|
||||||
@ -4448,7 +4449,7 @@ static uiBut *ui_def_but_rna(uiBlock *block,
|
|||||||
value = (int)max;
|
value = (int)max;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = RNA_enum_from_value(item, value);
|
const int i = RNA_enum_from_value(item, value);
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
@ -6709,7 +6710,7 @@ static void operator_enum_search_update_fn(const struct bContext *C,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const EnumPropertyItem **filtered_items;
|
const EnumPropertyItem **filtered_items;
|
||||||
int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_items);
|
const int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_items);
|
||||||
|
|
||||||
for (int i = 0; i < filtered_amount; i++) {
|
for (int i = 0; i < filtered_amount; i++) {
|
||||||
const EnumPropertyItem *item = filtered_items[i];
|
const EnumPropertyItem *item = filtered_items[i];
|
||||||
|
@ -230,7 +230,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg)
|
|||||||
* than being found on adding later... */
|
* than being found on adding later... */
|
||||||
wmKeyMap *km = WM_keymap_guess_opname(C, idname);
|
wmKeyMap *km = WM_keymap_guess_opname(C, idname);
|
||||||
wmKeyMapItem *kmi = WM_keymap_add_item(km, idname, EVT_AKEY, KM_PRESS, 0, 0);
|
wmKeyMapItem *kmi = WM_keymap_add_item(km, idname, EVT_AKEY, KM_PRESS, 0, 0);
|
||||||
int kmi_id = kmi->id;
|
const int kmi_id = kmi->id;
|
||||||
|
|
||||||
/* This takes ownership of prop, or prop can be NULL for reset. */
|
/* This takes ownership of prop, or prop can be NULL for reset. */
|
||||||
WM_keymap_item_properties_reset(kmi, prop);
|
WM_keymap_item_properties_reset(kmi, prop);
|
||||||
@ -280,7 +280,7 @@ static void menu_add_shortcut_cancel(struct bContext *C, void *arg1)
|
|||||||
|
|
||||||
#ifdef USE_KEYMAP_ADD_HACK
|
#ifdef USE_KEYMAP_ADD_HACK
|
||||||
wmKeyMap *km = WM_keymap_guess_opname(C, idname);
|
wmKeyMap *km = WM_keymap_guess_opname(C, idname);
|
||||||
int kmi_id = g_kmi_id_hack;
|
const int kmi_id = g_kmi_id_hack;
|
||||||
UNUSED_VARS(but);
|
UNUSED_VARS(but);
|
||||||
#else
|
#else
|
||||||
int kmi_id = WM_key_event_operator_id(C, idname, but->opcontext, prop, true, &km);
|
int kmi_id = WM_key_event_operator_id(C, idname, but->opcontext, prop, true, &km);
|
||||||
|
@ -505,7 +505,7 @@ bool ui_but_is_editing(const uiBut *but)
|
|||||||
void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
|
void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
|
||||||
{
|
{
|
||||||
static int lastdy = 0;
|
static int lastdy = 0;
|
||||||
int dy = WM_event_absolute_delta_y(event);
|
const int dy = WM_event_absolute_delta_y(event);
|
||||||
|
|
||||||
/* This event should be originally from event->type,
|
/* This event should be originally from event->type,
|
||||||
* converting wrong event into wheel is bad, see T33803. */
|
* converting wrong event into wheel is bad, see T33803. */
|
||||||
|
@ -1010,7 +1010,7 @@ static void init_iconfile_list(struct ListBase *list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct direntry *dir;
|
struct direntry *dir;
|
||||||
int totfile = BLI_filelist_dir_contents(icondir, &dir);
|
const int totfile = BLI_filelist_dir_contents(icondir, &dir);
|
||||||
|
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (int i = 0; i < totfile; i++) {
|
for (int i = 0; i < totfile; i++) {
|
||||||
@ -1716,10 +1716,10 @@ static void icon_draw_texture(float x,
|
|||||||
|
|
||||||
GPU_blend(GPU_BLEND_ALPHA_PREMULT);
|
GPU_blend(GPU_BLEND_ALPHA_PREMULT);
|
||||||
|
|
||||||
float x1 = ix * icongltex.invw;
|
const float x1 = ix * icongltex.invw;
|
||||||
float x2 = (ix + ih) * icongltex.invw;
|
const float x2 = (ix + ih) * icongltex.invw;
|
||||||
float y1 = iy * icongltex.invh;
|
const float y1 = iy * icongltex.invh;
|
||||||
float y2 = (iy + ih) * icongltex.invh;
|
const float y2 = (iy + ih) * icongltex.invh;
|
||||||
|
|
||||||
GPUTexture *texture = with_border ? icongltex.tex[1] : icongltex.tex[0];
|
GPUTexture *texture = with_border ? icongltex.tex[1] : icongltex.tex[0];
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
|
|||||||
uiBut *but = arg_but;
|
uiBut *but = arg_but;
|
||||||
PointerRNA *ptr = &but->rnapoin;
|
PointerRNA *ptr = &but->rnapoin;
|
||||||
PropertyRNA *prop = but->rnaprop;
|
PropertyRNA *prop = but->rnaprop;
|
||||||
int index = POINTER_AS_INT(arg_index);
|
const int index = POINTER_AS_INT(arg_index);
|
||||||
const int shift = win->eventstate->shift;
|
const int shift = win->eventstate->shift;
|
||||||
const int len = RNA_property_array_length(ptr, prop);
|
const int len = RNA_property_array_length(ptr, prop);
|
||||||
|
|
||||||
@ -1807,8 +1807,8 @@ static void ui_item_rna_size(uiLayout *layout,
|
|||||||
int w = 0, h;
|
int w = 0, h;
|
||||||
|
|
||||||
/* arbitrary extended width by type */
|
/* arbitrary extended width by type */
|
||||||
PropertyType type = RNA_property_type(prop);
|
const PropertyType type = RNA_property_type(prop);
|
||||||
PropertySubType subtype = RNA_property_subtype(prop);
|
const PropertySubType subtype = RNA_property_subtype(prop);
|
||||||
const int len = RNA_property_array_length(ptr, prop);
|
const int len = RNA_property_array_length(ptr, prop);
|
||||||
|
|
||||||
bool is_checkbox_only = false;
|
bool is_checkbox_only = false;
|
||||||
@ -2857,7 +2857,7 @@ static uiBut *ui_item_menu(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int w = ui_text_icon_width(layout, name, icon, 1);
|
int w = ui_text_icon_width(layout, name, icon, 1);
|
||||||
int h = UI_UNIT_Y;
|
const int h = UI_UNIT_Y;
|
||||||
|
|
||||||
if (layout->root->type == UI_LAYOUT_HEADER) { /* ugly .. */
|
if (layout->root->type == UI_LAYOUT_HEADER) { /* ugly .. */
|
||||||
if (icon == ICON_NONE && force_menu) {
|
if (icon == ICON_NONE && force_menu) {
|
||||||
@ -3553,7 +3553,7 @@ static void ui_litem_layout_row(uiLayout *litem)
|
|||||||
float extra_pixel;
|
float extra_pixel;
|
||||||
|
|
||||||
/* x = litem->x; */ /* UNUSED */
|
/* x = litem->x; */ /* UNUSED */
|
||||||
int y = litem->y;
|
const int y = litem->y;
|
||||||
int w = litem->w;
|
int w = litem->w;
|
||||||
int totw = 0;
|
int totw = 0;
|
||||||
int tot = 0;
|
int tot = 0;
|
||||||
@ -3722,7 +3722,7 @@ static void ui_litem_estimate_column(uiLayout *litem, bool is_box)
|
|||||||
|
|
||||||
static void ui_litem_layout_column(uiLayout *litem, bool is_box, bool is_menu)
|
static void ui_litem_layout_column(uiLayout *litem, bool is_box, bool is_menu)
|
||||||
{
|
{
|
||||||
int x = litem->x;
|
const int x = litem->x;
|
||||||
int y = litem->y;
|
int y = litem->y;
|
||||||
|
|
||||||
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
|
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
|
||||||
@ -3756,7 +3756,7 @@ static RadialDirection ui_get_radialbut_vec(float vec[2], short itemnum)
|
|||||||
PIE_MAX_ITEMS);
|
PIE_MAX_ITEMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
RadialDirection dir = ui_radial_dir_order[itemnum];
|
const RadialDirection dir = ui_radial_dir_order[itemnum];
|
||||||
ui_but_pie_dir(dir, vec);
|
ui_but_pie_dir(dir, vec);
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
@ -3795,8 +3795,8 @@ static void ui_litem_layout_radial(uiLayout *litem)
|
|||||||
|
|
||||||
const int pie_radius = U.pie_menu_radius * UI_DPI_FAC;
|
const int pie_radius = U.pie_menu_radius * UI_DPI_FAC;
|
||||||
|
|
||||||
int x = litem->x;
|
const int x = litem->x;
|
||||||
int y = litem->y;
|
const int y = litem->y;
|
||||||
|
|
||||||
int minx = x, miny = y, maxx = x, maxy = y;
|
int minx = x, miny = y, maxx = x, maxy = y;
|
||||||
|
|
||||||
@ -3922,8 +3922,8 @@ static void ui_litem_layout_box(uiLayout *litem)
|
|||||||
boxspace = 0;
|
boxspace = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w = litem->w;
|
const int w = litem->w;
|
||||||
int h = litem->h;
|
const int h = litem->h;
|
||||||
|
|
||||||
litem->x += boxspace;
|
litem->x += boxspace;
|
||||||
litem->y -= boxspace;
|
litem->y -= boxspace;
|
||||||
@ -3993,7 +3993,7 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
|
|||||||
int miny = 0;
|
int miny = 0;
|
||||||
|
|
||||||
maxw = 0;
|
maxw = 0;
|
||||||
int emh = toth / flow->totcol;
|
const int emh = toth / flow->totcol;
|
||||||
|
|
||||||
/* create column per column */
|
/* create column per column */
|
||||||
int col = 0;
|
int col = 0;
|
||||||
@ -4546,11 +4546,11 @@ static void ui_litem_layout_split(uiLayout *litem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int x = litem->x;
|
int x = litem->x;
|
||||||
int y = litem->y;
|
const int y = litem->y;
|
||||||
|
|
||||||
float percentage = (split->percentage == 0.0f) ? 1.0f / (float)tot : split->percentage;
|
const float percentage = (split->percentage == 0.0f) ? 1.0f / (float)tot : split->percentage;
|
||||||
|
|
||||||
int w = (litem->w - (tot - 1) * litem->space);
|
const int w = (litem->w - (tot - 1) * litem->space);
|
||||||
int colw = w * percentage;
|
int colw = w * percentage;
|
||||||
colw = MAX2(colw, 0);
|
colw = MAX2(colw, 0);
|
||||||
|
|
||||||
@ -4595,8 +4595,8 @@ static void ui_litem_estimate_overlap(uiLayout *litem)
|
|||||||
static void ui_litem_layout_overlap(uiLayout *litem)
|
static void ui_litem_layout_overlap(uiLayout *litem)
|
||||||
{
|
{
|
||||||
|
|
||||||
int x = litem->x;
|
const int x = litem->x;
|
||||||
int y = litem->y;
|
const int y = litem->y;
|
||||||
|
|
||||||
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
|
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
|
||||||
int itemw, itemh;
|
int itemw, itemh;
|
||||||
|
@ -1001,7 +1001,7 @@ static void menu_search_update_fn(const bContext *UNUSED(C),
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct MenuSearch_Item **filtered_items;
|
struct MenuSearch_Item **filtered_items;
|
||||||
int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_items);
|
const int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_items);
|
||||||
|
|
||||||
for (int i = 0; i < filtered_amount; i++) {
|
for (int i = 0; i < filtered_amount; i++) {
|
||||||
struct MenuSearch_Item *item = filtered_items[i];
|
struct MenuSearch_Item *item = filtered_items[i];
|
||||||
|
@ -420,7 +420,7 @@ static void id_search_cb(const bContext *C,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ID **filtered_ids;
|
ID **filtered_ids;
|
||||||
int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_ids);
|
const int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_ids);
|
||||||
|
|
||||||
for (int i = 0; i < filtered_amount; i++) {
|
for (int i = 0; i < filtered_amount; i++) {
|
||||||
if (!id_search_add(C, template_ui, items, filtered_ids[i])) {
|
if (!id_search_add(C, template_ui, items, filtered_ids[i])) {
|
||||||
@ -457,7 +457,7 @@ static void id_search_cb_tagged(const bContext *C,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ID **filtered_ids;
|
ID **filtered_ids;
|
||||||
int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_ids);
|
const int filtered_amount = BLI_string_search_query(search, str, (void ***)&filtered_ids);
|
||||||
|
|
||||||
for (int i = 0; i < filtered_amount; i++) {
|
for (int i = 0; i < filtered_amount; i++) {
|
||||||
if (!id_search_add(C, template_ui, items, filtered_ids[i])) {
|
if (!id_search_add(C, template_ui, items, filtered_ids[i])) {
|
||||||
@ -781,7 +781,8 @@ static void template_id_linked_operation_button(
|
|||||||
const char *tip = (operation == UI_ID_MAKE_LOCAL) ?
|
const char *tip = (operation == UI_ID_MAKE_LOCAL) ?
|
||||||
N_("Make library linked data-block local to this file") :
|
N_("Make library linked data-block local to this file") :
|
||||||
N_("Create a local override of this library linked data-block");
|
N_("Create a local override of this library linked data-block");
|
||||||
BIFIconID icon = (operation == UI_ID_MAKE_LOCAL) ? ICON_BLANK1 : ICON_LIBRARY_DATA_OVERRIDE;
|
const BIFIconID icon = (operation == UI_ID_MAKE_LOCAL) ? ICON_BLANK1 :
|
||||||
|
ICON_LIBRARY_DATA_OVERRIDE;
|
||||||
|
|
||||||
uiBut *but = uiDefIconTextBut(block,
|
uiBut *but = uiDefIconTextBut(block,
|
||||||
UI_BTYPE_BUT,
|
UI_BTYPE_BUT,
|
||||||
@ -1342,7 +1343,7 @@ static void template_id_name_button(
|
|||||||
{
|
{
|
||||||
PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
|
PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
|
||||||
ID *id = idptr.data;
|
ID *id = idptr.data;
|
||||||
BIFIconID lib_icon = UI_icon_from_library(id);
|
const BIFIconID lib_icon = UI_icon_from_library(id);
|
||||||
|
|
||||||
char name[UI_MAX_NAME_STR] = "";
|
char name[UI_MAX_NAME_STR] = "";
|
||||||
uiBut *but = uiDefIconTextButR(block,
|
uiBut *but = uiDefIconTextButR(block,
|
||||||
@ -2252,7 +2253,7 @@ static bool constraint_panel_is_bone(Panel *panel)
|
|||||||
*/
|
*/
|
||||||
static void constraint_reorder(bContext *C, Panel *panel, int new_index)
|
static void constraint_reorder(bContext *C, Panel *panel, int new_index)
|
||||||
{
|
{
|
||||||
bool constraint_from_bone = constraint_panel_is_bone(panel);
|
const bool constraint_from_bone = constraint_panel_is_bone(panel);
|
||||||
|
|
||||||
PointerRNA *con_ptr = UI_panel_custom_data_get(panel);
|
PointerRNA *con_ptr = UI_panel_custom_data_get(panel);
|
||||||
bConstraint *con = (bConstraint *)con_ptr->data;
|
bConstraint *con = (bConstraint *)con_ptr->data;
|
||||||
@ -3319,7 +3320,7 @@ static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v)
|
|||||||
const uiStyle *style = UI_style_get_dpi();
|
const uiStyle *style = UI_style_get_dpi();
|
||||||
ColorBand *coba = coba_v;
|
ColorBand *coba = coba_v;
|
||||||
short yco = 0;
|
short yco = 0;
|
||||||
short menuwidth = 10 * UI_UNIT_X;
|
const short menuwidth = 10 * UI_UNIT_X;
|
||||||
|
|
||||||
uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS_PULLDOWN);
|
uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS_PULLDOWN);
|
||||||
UI_block_func_butmenu_set(block, colorband_tools_dofunc, coba);
|
UI_block_func_butmenu_set(block, colorband_tools_dofunc, coba);
|
||||||
@ -3634,7 +3635,7 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
||||||
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp)) {
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3710,8 +3711,8 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_lit
|
|||||||
|
|
||||||
/* arg_litem is malloced, can be freed by parent button */
|
/* arg_litem is malloced, can be freed by parent button */
|
||||||
args = *((IconViewMenuArgs *)arg_litem);
|
args = *((IconViewMenuArgs *)arg_litem);
|
||||||
int w = UI_UNIT_X * (args.icon_scale);
|
const int w = UI_UNIT_X * (args.icon_scale);
|
||||||
int h = UI_UNIT_X * (args.icon_scale + args.show_labels);
|
const int h = UI_UNIT_X * (args.icon_scale + args.show_labels);
|
||||||
|
|
||||||
uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS_PULLDOWN);
|
uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS_PULLDOWN);
|
||||||
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NO_FLIP);
|
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NO_FLIP);
|
||||||
@ -3722,11 +3723,11 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_lit
|
|||||||
RNA_property_enum_items(C, &args.ptr, args.prop, &item, NULL, &free);
|
RNA_property_enum_items(C, &args.ptr, args.prop, &item, NULL, &free);
|
||||||
|
|
||||||
for (int a = 0; item[a].identifier; a++) {
|
for (int a = 0; item[a].identifier; a++) {
|
||||||
int x = (a % 8) * w;
|
const int x = (a % 8) * w;
|
||||||
int y = -(a / 8) * h;
|
const int y = -(a / 8) * h;
|
||||||
|
|
||||||
int icon = item[a].icon;
|
const int icon = item[a].icon;
|
||||||
int value = item[a].value;
|
const int value = item[a].value;
|
||||||
uiBut *but;
|
uiBut *but;
|
||||||
if (args.show_labels) {
|
if (args.show_labels) {
|
||||||
but = uiDefIconTextButR_prop(block,
|
but = uiDefIconTextButR_prop(block,
|
||||||
@ -3802,7 +3803,7 @@ void uiTemplateIconView(uiLayout *layout,
|
|||||||
bool free_items;
|
bool free_items;
|
||||||
const EnumPropertyItem *items;
|
const EnumPropertyItem *items;
|
||||||
RNA_property_enum_items(block->evil_C, ptr, prop, &items, &tot_items, &free_items);
|
RNA_property_enum_items(block->evil_C, ptr, prop, &items, &tot_items, &free_items);
|
||||||
int value = RNA_property_enum_get(ptr, prop);
|
const int value = RNA_property_enum_get(ptr, prop);
|
||||||
int icon = ICON_NONE;
|
int icon = ICON_NONE;
|
||||||
RNA_enum_icon_from_value(items, value, &icon);
|
RNA_enum_icon_from_value(items, value, &icon);
|
||||||
|
|
||||||
@ -3862,7 +3863,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
||||||
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram)) {
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3912,7 +3913,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
||||||
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3974,7 +3975,7 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
||||||
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4634,7 +4635,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
|
|||||||
|
|
||||||
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
|
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
|
||||||
|
|
||||||
int icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
|
const int icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
|
||||||
bt = uiDefIconBlockBut(
|
bt = uiDefIconBlockBut(
|
||||||
block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
|
block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
|
||||||
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
|
UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
|
||||||
@ -4660,7 +4661,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
|
|||||||
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
|
UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
|
||||||
|
|
||||||
/* curve itself */
|
/* curve itself */
|
||||||
int size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
|
const int size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
|
||||||
row = uiLayoutRow(layout, false);
|
row = uiLayoutRow(layout, false);
|
||||||
uiButCurveMapping *curve_but = (uiButCurveMapping *)uiDefBut(
|
uiButCurveMapping *curve_but = (uiButCurveMapping *)uiDefBut(
|
||||||
block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, 0, 0, "");
|
block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, 0, 0, "");
|
||||||
@ -5188,7 +5189,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
|
|||||||
UI_but_funcN_set(bt, CurveProfile_buttons_reverse, MEM_dupallocN(cb), profile);
|
UI_but_funcN_set(bt, CurveProfile_buttons_reverse, MEM_dupallocN(cb), profile);
|
||||||
|
|
||||||
/* Clipping toggle */
|
/* Clipping toggle */
|
||||||
int icon = (profile->flag & PROF_USE_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
|
const int icon = (profile->flag & PROF_USE_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT;
|
||||||
bt = uiDefIconBut(block,
|
bt = uiDefIconBut(block,
|
||||||
UI_BTYPE_BUT,
|
UI_BTYPE_BUT,
|
||||||
0,
|
0,
|
||||||
@ -5210,7 +5211,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp
|
|||||||
/* The path itself */
|
/* The path itself */
|
||||||
int path_width = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
|
int path_width = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
|
||||||
path_width = min_ii(path_width, (int)(16.0f * UI_UNIT_X));
|
path_width = min_ii(path_width, (int)(16.0f * UI_UNIT_X));
|
||||||
int path_height = path_width;
|
const int path_height = path_width;
|
||||||
uiLayoutRow(layout, false);
|
uiLayoutRow(layout, false);
|
||||||
uiDefBut(block,
|
uiDefBut(block,
|
||||||
UI_BTYPE_CURVEPROFILE,
|
UI_BTYPE_CURVEPROFILE,
|
||||||
@ -5635,7 +5636,7 @@ void uiTemplatePalette(uiLayout *layout,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
|
||||||
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette)) {
|
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Palette)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -5775,10 +5776,10 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
|
|||||||
uiBut *but = arg1;
|
uiBut *but = arg1;
|
||||||
const int cur = POINTER_AS_INT(arg2);
|
const int cur = POINTER_AS_INT(arg2);
|
||||||
wmWindow *win = CTX_wm_window(C);
|
wmWindow *win = CTX_wm_window(C);
|
||||||
int shift = win->eventstate->shift;
|
const int shift = win->eventstate->shift;
|
||||||
|
|
||||||
if (!shift) {
|
if (!shift) {
|
||||||
int tot = RNA_property_array_length(&but->rnapoin, but->rnaprop);
|
const int tot = RNA_property_array_length(&but->rnapoin, but->rnaprop);
|
||||||
|
|
||||||
/* Normally clicking only selects one layer */
|
/* Normally clicking only selects one layer */
|
||||||
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, true);
|
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, true);
|
||||||
@ -6120,7 +6121,7 @@ static void uilist_prepare(uiList *ui_list,
|
|||||||
ui_list->flag &= ~UILST_SCROLL_TO_ACTIVE_ITEM;
|
ui_list->flag &= ~UILST_SCROLL_TO_ACTIVE_ITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
int max_scroll = max_ii(0, dyn_data->height - rows);
|
const int max_scroll = max_ii(0, dyn_data->height - rows);
|
||||||
CLAMP(ui_list->list_scroll, 0, max_scroll);
|
CLAMP(ui_list->list_scroll, 0, max_scroll);
|
||||||
ui_list->list_last_len = len;
|
ui_list->list_last_len = len;
|
||||||
dyn_data->visual_height = rows;
|
dyn_data->visual_height = rows;
|
||||||
@ -6225,14 +6226,14 @@ void uiTemplateList(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (prop) {
|
if (prop) {
|
||||||
PropertyType type = RNA_property_type(prop);
|
const PropertyType type = RNA_property_type(prop);
|
||||||
if (type != PROP_COLLECTION) {
|
if (type != PROP_COLLECTION) {
|
||||||
RNA_warning("Expected a collection data property");
|
RNA_warning("Expected a collection data property");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyType activetype = RNA_property_type(activeprop);
|
const PropertyType activetype = RNA_property_type(activeprop);
|
||||||
if (activetype != PROP_INT) {
|
if (activetype != PROP_INT) {
|
||||||
RNA_warning("Expected an integer active data property");
|
RNA_warning("Expected an integer active data property");
|
||||||
return;
|
return;
|
||||||
|
@ -746,7 +746,7 @@ static void round_box__edges(
|
|||||||
1 :
|
1 :
|
||||||
2;
|
2;
|
||||||
|
|
||||||
int minsize = min_ii(BLI_rcti_size_x(rect) * hnum, BLI_rcti_size_y(rect) * vnum);
|
const int minsize = min_ii(BLI_rcti_size_x(rect) * hnum, BLI_rcti_size_y(rect) * vnum);
|
||||||
|
|
||||||
if (2.0f * rad > minsize) {
|
if (2.0f * rad > minsize) {
|
||||||
rad = 0.5f * minsize;
|
rad = 0.5f * minsize;
|
||||||
@ -911,7 +911,7 @@ static void shape_preset_init_trias_ex(uiWidgetTrias *tria,
|
|||||||
float sizex, sizey;
|
float sizex, sizey;
|
||||||
int i1 = 0, i2 = 1;
|
int i1 = 0, i2 = 1;
|
||||||
|
|
||||||
float minsize = ELEM(where, 'r', 'l') ? BLI_rcti_size_y(rect) : BLI_rcti_size_x(rect);
|
const float minsize = ELEM(where, 'r', 'l') ? BLI_rcti_size_y(rect) : BLI_rcti_size_x(rect);
|
||||||
|
|
||||||
/* center position and size */
|
/* center position and size */
|
||||||
float centx = (float)rect->xmin + 0.4f * minsize;
|
float centx = (float)rect->xmin + 0.4f * minsize;
|
||||||
@ -1396,8 +1396,8 @@ static void widget_draw_icon(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float aspect = but->block->aspect * U.inv_dpi_fac;
|
const float aspect = but->block->aspect * U.inv_dpi_fac;
|
||||||
float height = ICON_DEFAULT_HEIGHT / aspect;
|
const float height = ICON_DEFAULT_HEIGHT / aspect;
|
||||||
|
|
||||||
/* calculate blend color */
|
/* calculate blend color */
|
||||||
if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_ROW, UI_BTYPE_TOGGLE_N, UI_BTYPE_LISTROW)) {
|
if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_ROW, UI_BTYPE_TOGGLE_N, UI_BTYPE_LISTROW)) {
|
||||||
@ -1622,7 +1622,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float parts_strwidth = (okwidth - sep_strwidth) / 2.0f;
|
const float parts_strwidth = (okwidth - sep_strwidth) / 2.0f;
|
||||||
|
|
||||||
if (rpart) {
|
if (rpart) {
|
||||||
strcpy(rpart_buf, rpart);
|
strcpy(rpart_buf, rpart);
|
||||||
@ -1630,7 +1630,8 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
|
|||||||
rpart = rpart_buf;
|
rpart = rpart_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, parts_strwidth, NULL);
|
const size_t l_end = BLF_width_to_strlen(
|
||||||
|
fstyle->uifont_id, str, max_len, parts_strwidth, NULL);
|
||||||
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.
|
||||||
@ -2413,7 +2414,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!no_text_padding) {
|
if (!no_text_padding) {
|
||||||
int text_padding = (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
|
const int text_padding = (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect;
|
||||||
if (but->editstr) {
|
if (but->editstr) {
|
||||||
rect->xmin += text_padding;
|
rect->xmin += text_padding;
|
||||||
}
|
}
|
||||||
@ -2883,7 +2884,7 @@ void ui_hsvcircle_pos_from_vals(
|
|||||||
/* duplication of code... well, simple is better now */
|
/* duplication of code... well, simple is better now */
|
||||||
const float centx = BLI_rcti_cent_x_fl(rect);
|
const float centx = BLI_rcti_cent_x_fl(rect);
|
||||||
const float centy = BLI_rcti_cent_y_fl(rect);
|
const float centy = BLI_rcti_cent_y_fl(rect);
|
||||||
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;
|
||||||
|
|
||||||
const float ang = 2.0f * (float)M_PI * hsv[0] + (float)M_PI_2;
|
const float ang = 2.0f * (float)M_PI * hsv[0] + (float)M_PI_2;
|
||||||
|
|
||||||
@ -2895,7 +2896,7 @@ void ui_hsvcircle_pos_from_vals(
|
|||||||
radius_t = hsv[1];
|
radius_t = hsv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
float rad = clamp_f(radius_t, 0.0f, 1.0f) * radius;
|
const float rad = clamp_f(radius_t, 0.0f, 1.0f) * radius;
|
||||||
*r_xpos = centx + cosf(-ang) * rad;
|
*r_xpos = centx + cosf(-ang) * rad;
|
||||||
*r_ypos = centy + sinf(-ang) * rad;
|
*r_ypos = centy + sinf(-ang) * rad;
|
||||||
}
|
}
|
||||||
@ -3505,7 +3506,7 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
|
|||||||
widget_init(&wtb);
|
widget_init(&wtb);
|
||||||
|
|
||||||
/* determine horizontal/vertical */
|
/* determine horizontal/vertical */
|
||||||
bool horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
|
const bool horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
|
||||||
|
|
||||||
const float rad = (horizontal) ? wcol->roundness * BLI_rcti_size_y(rect) :
|
const float rad = (horizontal) ? wcol->roundness * BLI_rcti_size_y(rect) :
|
||||||
wcol->roundness * BLI_rcti_size_x(rect);
|
wcol->roundness * BLI_rcti_size_x(rect);
|
||||||
@ -3621,7 +3622,7 @@ static void widget_scroll(
|
|||||||
rect1.ymin = rect1.ymax - ceilf(fac * (but->a1 - but->softmin));
|
rect1.ymin = rect1.ymax - ceilf(fac * (but->a1 - but->softmin));
|
||||||
|
|
||||||
/* ensure minimium size */
|
/* ensure minimium size */
|
||||||
float min = BLI_rcti_size_x(rect);
|
const float min = BLI_rcti_size_x(rect);
|
||||||
|
|
||||||
if (BLI_rcti_size_y(&rect1) < min) {
|
if (BLI_rcti_size_y(&rect1) < min) {
|
||||||
rect1.ymax = rect1.ymin + min;
|
rect1.ymax = rect1.ymin + min;
|
||||||
@ -5012,7 +5013,7 @@ static void draw_disk_shaded(float start,
|
|||||||
|
|
||||||
uint col;
|
uint col;
|
||||||
GPUVertFormat *format = immVertexFormat();
|
GPUVertFormat *format = immVertexFormat();
|
||||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
||||||
if (shaded) {
|
if (shaded) {
|
||||||
col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
||||||
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
||||||
@ -5024,15 +5025,15 @@ static void draw_disk_shaded(float start,
|
|||||||
|
|
||||||
immBegin(GPU_PRIM_TRI_STRIP, subd * 2);
|
immBegin(GPU_PRIM_TRI_STRIP, subd * 2);
|
||||||
for (int i = 0; i < subd; i++) {
|
for (int i = 0; i < subd; i++) {
|
||||||
float a = start + ((i) / (float)(subd - 1)) * angle;
|
const float a = start + ((i) / (float)(subd - 1)) * angle;
|
||||||
float s = sinf(a);
|
const float s = sinf(a);
|
||||||
float c = cosf(a);
|
const float c = cosf(a);
|
||||||
float y1 = s * radius_int;
|
const float y1 = s * radius_int;
|
||||||
float y2 = s * radius_ext;
|
const float y2 = s * radius_ext;
|
||||||
|
|
||||||
if (shaded) {
|
if (shaded) {
|
||||||
uchar r_col[4];
|
uchar r_col[4];
|
||||||
float fac = (y1 + radius_ext) * radius_ext_scale;
|
const float fac = (y1 + radius_ext) * radius_ext_scale;
|
||||||
color_blend_v4_v4v4(r_col, col1, col2, fac);
|
color_blend_v4_v4v4(r_col, col1, col2, fac);
|
||||||
immAttr4ubv(col, r_col);
|
immAttr4ubv(col, r_col);
|
||||||
}
|
}
|
||||||
@ -5040,7 +5041,7 @@ static void draw_disk_shaded(float start,
|
|||||||
|
|
||||||
if (shaded) {
|
if (shaded) {
|
||||||
uchar r_col[4];
|
uchar r_col[4];
|
||||||
float fac = (y2 + radius_ext) * radius_ext_scale;
|
const float fac = (y2 + radius_ext) * radius_ext_scale;
|
||||||
color_blend_v4_v4v4(r_col, col1, col2, fac);
|
color_blend_v4_v4v4(r_col, col1, col2, fac);
|
||||||
immAttr4ubv(col, r_col);
|
immAttr4ubv(col, r_col);
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,8 @@ static void view_pan_init(bContext *C, wmOperator *op)
|
|||||||
vpd->v2d = &vpd->region->v2d;
|
vpd->v2d = &vpd->region->v2d;
|
||||||
|
|
||||||
/* calculate translation factor - based on size of view */
|
/* calculate translation factor - based on size of view */
|
||||||
float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1);
|
const float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1);
|
||||||
float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1);
|
const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1);
|
||||||
vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx;
|
vpd->facx = (BLI_rctf_size_x(&vpd->v2d->cur)) / winx;
|
||||||
vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy;
|
vpd->facy = (BLI_rctf_size_y(&vpd->v2d->cur)) / winy;
|
||||||
}
|
}
|
||||||
@ -1991,7 +1991,7 @@ static void scroller_activate_init(bContext *C,
|
|||||||
|
|
||||||
if (in_scroller == 'h') {
|
if (in_scroller == 'h') {
|
||||||
/* horizontal scroller - calculate adjustment factor first */
|
/* horizontal scroller - calculate adjustment factor first */
|
||||||
float mask_size = (float)BLI_rcti_size_x(&v2d->hor);
|
const float mask_size = (float)BLI_rcti_size_x(&v2d->hor);
|
||||||
vsm->fac = BLI_rctf_size_x(&tot_cur_union) / mask_size;
|
vsm->fac = BLI_rctf_size_x(&tot_cur_union) / mask_size;
|
||||||
|
|
||||||
/* pixel rounding */
|
/* pixel rounding */
|
||||||
@ -2011,7 +2011,7 @@ static void scroller_activate_init(bContext *C,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* vertical scroller - calculate adjustment factor first */
|
/* vertical scroller - calculate adjustment factor first */
|
||||||
float mask_size = (float)BLI_rcti_size_y(&v2d->vert);
|
const float mask_size = (float)BLI_rcti_size_y(&v2d->vert);
|
||||||
vsm->fac = BLI_rctf_size_y(&tot_cur_union) / mask_size;
|
vsm->fac = BLI_rctf_size_y(&tot_cur_union) / mask_size;
|
||||||
|
|
||||||
/* pixel rounding */
|
/* pixel rounding */
|
||||||
|
Loading…
Reference in New Issue
Block a user