Cleanup: use 'const' style argument

This commit is contained in:
Campbell Barton 2020-03-15 17:32:25 +11:00
parent b037816980
commit aa60b9338a
24 changed files with 69 additions and 67 deletions

View File

@ -1807,7 +1807,7 @@ uiLayout *UI_block_layout(uiBlock *block,
int size,
int em,
int padding,
struct uiStyle *style);
const struct uiStyle *style);
void UI_block_layout_set_current(uiBlock *block, uiLayout *layout);
void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y);
@ -2433,8 +2433,8 @@ int UI_fontstyle_height_max(const struct uiFontStyle *fs);
void UI_draw_icon_tri(float x, float y, char dir, const float[4]);
struct uiStyle *UI_style_get(void); /* use for fonts etc */
struct uiStyle *UI_style_get_dpi(void); /* DPI scaled settings for drawing */
const struct uiStyle *UI_style_get(void); /* use for fonts etc */
const struct uiStyle *UI_style_get_dpi(void); /* DPI scaled settings for drawing */
/* linker workaround ack! */
void UI_template_fix_linking(void);

View File

@ -366,7 +366,7 @@ void UI_block_translate(uiBlock *block, int x, int y)
static void ui_block_bounds_calc_text(uiBlock *block, float offset)
{
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
uiBut *bt, *init_col_bt, *col_bt;
int i = 0, j, x1addval = offset;

View File

@ -169,7 +169,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *region, void *arg)
wmKeyMapItem *kmi;
PointerRNA ptr;
uiLayout *layout;
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
IDProperty *prop;
const char *idname = shortcut_get_operator_property(C, but, &prop);
@ -225,7 +225,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg)
wmKeyMapItem *kmi;
PointerRNA ptr;
uiLayout *layout;
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
int kmi_id;
IDProperty *prop;
const char *idname = shortcut_get_operator_property(C, but, &prop);

View File

@ -2848,10 +2848,9 @@ static bool ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
*/
static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, const float x)
{
uiStyle *style = UI_style_get(); // XXX pass on as arg
uiFontStyle *fstyle = &style->widget;
/* XXX pass on as arg. */
uiFontStyle fstyle = UI_style_get()->widget;
const float aspect = but->block->aspect;
const short fstyle_points_prev = fstyle->points;
float startx = but->rect.xmin;
float starty_dummy = 0.0f;
@ -2861,13 +2860,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
ui_block_to_window_fl(data->region, but->block, &startx, &starty_dummy);
ui_fontscale(&fstyle->points, aspect);
ui_fontscale(&fstyle.points, aspect);
UI_fontstyle_set(fstyle);
UI_fontstyle_set(&fstyle);
if (fstyle->kerning == 1) {
if (fstyle.kerning == 1) {
/* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
BLF_enable(fstyle.uifont_id, BLF_KERNING_DEFAULT);
}
ui_but_text_password_hide(password_str, but, false);
@ -2889,7 +2888,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
while (i > 0) {
if (BLI_str_cursor_step_prev_utf8(str, but->ofs, &i)) {
/* 0.25 == scale factor for less sensitivity */
if (BLF_width(fstyle->uifont_id, str + i, (str_last - str) - i) > (startx - x) * 0.25f) {
if (BLF_width(fstyle.uifont_id, str + i, (str_last - str) - i) > (startx - x) * 0.25f) {
break;
}
}
@ -2913,7 +2912,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
but->pos = pos_prev = ((str_last - str) - but->ofs);
while (true) {
cdist = startx + BLF_width(fstyle->uifont_id, str + but->ofs, (str_last - str) - but->ofs);
cdist = startx + BLF_width(fstyle.uifont_id, str + but->ofs, (str_last - str) - but->ofs);
/* check if position is found */
if (cdist < x) {
@ -2945,13 +2944,11 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
}
}
if (fstyle->kerning == 1) {
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
if (fstyle.kerning == 1) {
BLF_disable(fstyle.uifont_id, BLF_KERNING_DEFAULT);
}
ui_but_text_password_hide(password_str, but, true);
fstyle->points = fstyle_points_prev;
}
static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data, const float x)

View File

@ -839,7 +839,7 @@ const struct uiWidgetColors *ui_tooltip_get_theme(void);
void ui_draw_widget_menu_back_color(const rcti *rect, bool use_shadow, const float color[4]);
void ui_draw_widget_menu_back(const rcti *rect, bool use_shadow);
void ui_draw_tooltip_background(struct uiStyle *UNUSED(style), uiBlock *block, rcti *rect);
void ui_draw_tooltip_background(const struct uiStyle *UNUSED(style), uiBlock *block, rcti *rect);
extern void ui_draw_but(
const struct bContext *C, ARegion *region, struct uiStyle *style, uiBut *but, rcti *rect);

View File

@ -91,7 +91,7 @@ typedef struct uiLayoutRoot {
uiMenuHandleFunc handlefunc;
void *argv;
uiStyle *style;
const uiStyle *style;
uiBlock *block;
uiLayout *layout;
} uiLayoutRoot;
@ -499,7 +499,7 @@ static void ui_item_array(uiLayout *layout,
bool compact,
bool show_text)
{
uiStyle *style = layout->root->style;
const uiStyle *style = layout->root->style;
uiBut *but;
PropertyType type;
PropertySubType subtype;
@ -3707,7 +3707,7 @@ static void ui_litem_layout_root(uiLayout *litem)
/* box layout */
static void ui_litem_estimate_box(uiLayout *litem)
{
uiStyle *style = litem->root->style;
const uiStyle *style = litem->root->style;
ui_litem_estimate_column(litem, true);
@ -3722,7 +3722,7 @@ static void ui_litem_estimate_box(uiLayout *litem)
static void ui_litem_layout_box(uiLayout *litem)
{
uiLayoutItemBx *box = (uiLayoutItemBx *)litem;
uiStyle *style = litem->root->style;
const uiStyle *style = litem->root->style;
uiBut *but;
int w, h;
@ -3767,7 +3767,7 @@ static void ui_litem_layout_box(uiLayout *litem)
/* multi-column layout, automatically flowing to the next */
static void ui_litem_estimate_column_flow(uiLayout *litem)
{
uiStyle *style = litem->root->style;
const uiStyle *style = litem->root->style;
uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
uiItem *item;
int col, x, y, emh, emy, miny, itemw, itemh, maxw = 0;
@ -3832,7 +3832,7 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
static void ui_litem_layout_column_flow(uiLayout *litem)
{
uiStyle *style = litem->root->style;
const uiStyle *style = litem->root->style;
uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
uiItem *item;
int col, x, y, w, emh, emy, miny, itemw, itemh;
@ -4071,7 +4071,7 @@ static void ui_litem_grid_flow_compute(ListBase *items,
static void ui_litem_estimate_grid_flow(uiLayout *litem)
{
uiStyle *style = litem->root->style;
const uiStyle *style = litem->root->style;
uiLayoutItemGridFlow *gflow = (uiLayoutItemGridFlow *)litem;
const int space_x = style->columnspace;
@ -4199,7 +4199,7 @@ static void ui_litem_estimate_grid_flow(uiLayout *litem)
static void ui_litem_layout_grid_flow(uiLayout *litem)
{
int i;
uiStyle *style = litem->root->style;
const uiStyle *style = litem->root->style;
uiLayoutItemGridFlow *gflow = (uiLayoutItemGridFlow *)litem;
uiItem *item;
@ -5092,8 +5092,15 @@ static void ui_layout_add_padding_button(uiLayoutRoot *root)
}
}
uiLayout *UI_block_layout(
uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, uiStyle *style)
uiLayout *UI_block_layout(uiBlock *block,
int dir,
int type,
int x,
int y,
int size,
int em,
int padding,
const uiStyle *style)
{
uiLayout *layout;
uiLayoutRoot *root;

View File

@ -434,7 +434,7 @@ void UI_panel_end(
static void ui_offset_panel_block(uiBlock *block)
{
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
/* compute bounds and offset */
ui_block_bounds_calc(block);
@ -1938,7 +1938,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
// #define USE_FLAT_INACTIVE
const bool is_left = RGN_ALIGN_ENUM_FROM_MASK(region->alignment != RGN_ALIGN_RIGHT);
View2D *v2d = &region->v2d;
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
const uiFontStyle *fstyle = &style->widget;
const int fontid = fstyle->uifont_id;
short fstyle_points = fstyle->points;

View File

@ -104,13 +104,12 @@ static float ui_pie_menu_title_width(const char *name, int icon)
uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, const wmEvent *event)
{
uiStyle *style;
const uiStyle *style = UI_style_get_dpi();
uiPieMenu *pie;
short event_type;
wmWindow *win = CTX_wm_window(C);
style = UI_style_get_dpi();
pie = MEM_callocN(sizeof(*pie), "pie menu");
pie->block_radial = UI_block_begin(C, NULL, __func__, UI_EMBOSS);

View File

@ -310,7 +310,7 @@ uiPopupBlockHandle *ui_popup_menu_create(
bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg)
{
wmWindow *window = CTX_wm_window(C);
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
uiPopupBlockHandle *handle;
uiPopupMenu *pup;
@ -380,7 +380,7 @@ uiPopupMenu *UI_popup_menu_begin_ex(bContext *C,
const char *block_name,
int icon)
{
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu");
uiBut *but;

View File

@ -94,7 +94,7 @@ static void ui_popover_create_block(bContext *C, uiPopover *pup, int opcontext)
{
BLI_assert(pup->ui_size_x != 0);
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
pup->block = UI_block_begin(C, NULL, __func__, UI_EMBOSS);
UI_block_flag_enable(pup->block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_POPOVER);

View File

@ -498,7 +498,7 @@ static void ui_searchbox_region_free_cb(ARegion *region)
ARegion *ui_searchbox_create_generic(bContext *C, ARegion *butregion, uiBut *but)
{
wmWindow *win = CTX_wm_window(C);
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
static ARegionType type;
ARegion *region;
uiSearchboxData *data;

View File

@ -1158,7 +1158,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C,
wmWindow *win = CTX_wm_window(C);
const int winx = WM_window_pixels_x(win);
const int winy = WM_window_pixels_y(win);
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
static ARegionType type;
ARegion *region;
int fonth, fontw;

View File

@ -351,7 +351,7 @@ void UI_fontstyle_draw_simple_backdrop(const uiFontStyle *fs,
/* ************** helpers ************************ */
/* XXX: read a style configure */
uiStyle *UI_style_get(void)
const uiStyle *UI_style_get(void)
{
#if 0
uiStyle *style = NULL;
@ -364,9 +364,9 @@ uiStyle *UI_style_get(void)
}
/* for drawing, scaled with DPI setting */
uiStyle *UI_style_get_dpi(void)
const uiStyle *UI_style_get_dpi(void)
{
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
static uiStyle _style;
_style = *style;

View File

@ -1137,7 +1137,7 @@ static void template_ID_tabs(bContext *C,
const int but_height = UI_UNIT_Y * 1.1;
uiBlock *block = uiLayoutGetBlock(layout);
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
ListBase ordered;
BKE_id_ordered_list(&ordered, template->idlb);
@ -3049,7 +3049,7 @@ static void colorband_tools_dofunc(bContext *C, void *coba_v, int event)
static uiBlock *colorband_tools_func(bContext *C, ARegion *region, void *coba_v)
{
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
ColorBand *coba = coba_v;
uiBlock *block;
short yco = 0, menuwidth = 10 * UI_UNIT_X;
@ -7135,7 +7135,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
uiLayout *ui_abs;
uiBlock *block;
uiBut *but;
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
int width;
int icon;

View File

@ -5235,7 +5235,7 @@ 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);
}
void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect)
void ui_draw_tooltip_background(const uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect)
{
uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
wt->state(wt, 0, 0);

View File

@ -243,7 +243,7 @@ static void view2d_masks(View2D *v2d, bool check_scrollers, const rcti *mask_scr
void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
{
bool tot_changed = false, do_init;
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
do_init = (v2d->flag & V2D_IS_INITIALISED) == 0;

View File

@ -2155,7 +2155,7 @@ static void VIEW2D_OT_scroller_activate(wmOperatorType *ot)
static int reset_exec(bContext *C, wmOperator *UNUSED(op))
{
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
ARegion *region = CTX_wm_region(C);
View2D *v2d = &region->v2d;
int winx, winy;

View File

@ -2351,7 +2351,7 @@ static void ed_panel_draw(const bContext *C,
int em,
bool vertical)
{
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
/* draw panel */
uiBlock *block = UI_block_begin(C, region, pt->idname, UI_EMBOSS);
@ -2734,7 +2734,7 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *region)
void ED_region_header_layout(const bContext *C, ARegion *region)
{
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
uiBlock *block;
uiLayout *layout;
HeaderType *ht;
@ -2960,7 +2960,7 @@ void ED_region_info_draw_multiline(ARegion *region,
const bool full_redraw)
{
const int header_height = UI_UNIT_Y;
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
int fontid = style->widget.uifont_id;
int scissor[4];
int num_lines = 0;
@ -3266,7 +3266,7 @@ void ED_region_image_metadata_draw(
{
float box_y;
rctf rect;
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
if (!ibuf->metadata) {
return;
@ -3521,7 +3521,7 @@ void ED_region_cache_draw_background(ARegion *region)
void ED_region_cache_draw_curfra_label(const int framenr, const float x, const float y)
{
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
int fontid = style->widget.uifont_id;
char numstr[32];
float font_dims[2] = {0.0f, 0.0f};

View File

@ -296,7 +296,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *region)
SpaceClip *sc = CTX_wm_space_clip(C);
View2D *v2d = &region->v2d;
MovieClip *clip = ED_space_clip_get_clip(sc);
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
int fontid = style->widget.uifont_id;
if (!clip) {

View File

@ -170,7 +170,6 @@ static void file_draw_string(int sx,
eFontStyle_Align align,
const uchar col[4])
{
uiStyle *style;
uiFontStyle fs;
rcti rect;
char fname[FILE_MAXFILE];
@ -179,7 +178,7 @@ static void file_draw_string(int sx,
return;
}
style = UI_style_get();
const uiStyle *style = UI_style_get();
fs = style->widgetlabel;
BLI_strncpy(fname, string, FILE_MAXFILE);

View File

@ -639,7 +639,7 @@ FileAttributeColumnType file_attribute_column_type_find_isect(const View2D *v2d,
float file_string_width(const char *str)
{
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
float width;
UI_fontstyle_set(&style->widget);
@ -661,12 +661,12 @@ float file_font_pointsize(void)
#if 0
float s;
char tmp[2] = "X";
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
UI_fontstyle_set(&style->widget);
s = BLF_height(style->widget.uifont_id, tmp);
return style->widget.points;
#else
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
UI_fontstyle_set(&style->widget);
return style->widget.points * UI_DPI_FAC;
#endif

View File

@ -2818,7 +2818,7 @@ static uiBlock *block_create_autorun_warning(struct bContext *C,
void *UNUSED(arg1))
{
wmWindowManager *wm = CTX_wm_manager(C);
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
uiBlock *block = UI_block_begin(C, region, "autorun_warning_popup", UI_EMBOSS);
UI_block_flag_enable(
@ -3056,7 +3056,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
{
wmGenericCallback *post_action = (wmGenericCallback *)arg1;
Main *bmain = CTX_data_main(C);
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
const int dialog_width = U.widget_unit * 22;
const short icon_size = 64 * U.dpi_fac;

View File

@ -1319,7 +1319,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *region, void *arg_op)
wmOperator *op = arg_op;
uiBlock *block;
uiLayout *layout;
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
int width = 15 * UI_UNIT_X;
block = UI_block_begin(C, region, __func__, UI_EMBOSS);
@ -1401,7 +1401,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *region, void *userD
wmOperator *op = data->op;
uiBlock *block;
uiLayout *layout;
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
block = UI_block_begin(C, region, __func__, UI_EMBOSS);
UI_block_flag_disable(block, UI_BLOCK_LOOP);
@ -1450,7 +1450,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *region, void *userDa
wmOperator *op = data->op;
uiBlock *block;
uiLayout *layout;
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
block = UI_block_begin(C, region, __func__, UI_EMBOSS);
UI_block_flag_disable(block, UI_BLOCK_LOOP);
@ -2308,7 +2308,7 @@ static void radial_control_paint_curve(uint pos, Brush *br, float radius, int li
static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void *customdata)
{
RadialControl *rc = customdata;
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
const uiFontStyle *fstyle = &style->widget;
const int fontid = fstyle->uifont_id;
short fstyle_points = fstyle->points;

View File

@ -81,7 +81,7 @@ static void wm_block_splash_add_label(uiBlock *block, const char *label, int x,
return;
}
uiStyle *style = UI_style_get();
const uiStyle *style = UI_style_get();
BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi);
int label_width = BLF_width(style->widgetlabel.uifont_id, label, strlen(label));
@ -259,7 +259,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE
{
uiBlock *block;
uiBut *but;
uiStyle *style = UI_style_get_dpi();
const uiStyle *style = UI_style_get_dpi();
block = UI_block_begin(C, region, "splash", UI_EMBOSS);