diff options
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 306 |
1 files changed, 179 insertions, 127 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 026f02d1089..f3539af821e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -259,8 +259,8 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r rad += step; - if (2.0f * rad > BLI_RCT_SIZE_Y(rect)) - rad = 0.5f * BLI_RCT_SIZE_Y(rect); + if (2.0f * rad > BLI_rcti_size_y(rect)) + rad = 0.5f * BLI_rcti_size_y(rect); minx = rect->xmin - step; miny = rect->ymin - step; @@ -345,8 +345,8 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl const int vnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) || (roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2; - minsize = mini(BLI_RCT_SIZE_X(rect) * hnum, - BLI_RCT_SIZE_Y(rect) * vnum); + minsize = mini(BLI_rcti_size_x(rect) * hnum, + BLI_rcti_size_y(rect) * vnum); if (2.0f * rad > minsize) rad = 0.5f * minsize; @@ -491,7 +491,7 @@ static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, cha float centx, centy, sizex, sizey, minsize; int a, i1 = 0, i2 = 1; - minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); + minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -526,7 +526,7 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize float centx, centy, sizex, sizey, minsize; int a, i1 = 0, i2 = 1; - minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect)); + minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -570,14 +570,14 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect) int a; /* center position and size */ - centx = rect->xmax - 0.5f * BLI_RCT_SIZE_Y(rect); - centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect); - size = 0.4f * BLI_RCT_SIZE_Y(rect); + centx = rect->xmax - 0.5f * BLI_rcti_size_y(rect); + centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect); + size = 0.4f * BLI_rcti_size_y(rect); /* XXX exception */ - asp = ((float)BLI_RCT_SIZE_X(rect)) / ((float)BLI_RCT_SIZE_Y(rect)); + asp = ((float)BLI_rcti_size_x(rect)) / ((float)BLI_rcti_size_y(rect)); if (asp > 1.2f && asp < 2.6f) - centx = rect->xmax - 0.3f * BLI_RCT_SIZE_Y(rect); + centx = rect->xmax - 0.3f * BLI_rcti_size_y(rect); for (a = 0; a < 6; a++) { tria->vec[a][0] = size * menu_tria_vert[a][0] + centx; @@ -594,9 +594,9 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect) int a; /* center position and size */ - centx = rect->xmin + 0.5f * BLI_RCT_SIZE_Y(rect); - centy = rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect); - size = 0.5f * BLI_RCT_SIZE_Y(rect); + centx = rect->xmin + 0.5f * BLI_rcti_size_y(rect); + centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect); + size = 0.5f * BLI_rcti_size_y(rect); for (a = 0; a < 6; a++) { tria->vec[a][0] = size * check_tria_vert[a][0] + centx; @@ -840,8 +840,8 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect) if (icon == ICON_NONE) return; - w = BLI_RCT_SIZE_X(rect); - h = BLI_RCT_SIZE_Y(rect); + w = BLI_rcti_size_x(rect); + h = BLI_rcti_size_y(rect); size = MIN2(w, h); size -= PREVIEW_PAD * 2; /* padding */ @@ -965,48 +965,77 @@ static void ui_text_clip_give_next_off(uiBut *but) but->ofs += bytes; } -/* sets but->ofs to make sure text is correctly visible */ -static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) +/** + * Cut off the start of the text to fit into the width of \a rect + * + * \note Sets but->ofs to make sure text is correctly visible. + * \note Clips right in some cases, this function could be cleaned up. + */ +static void ui_text_clip_left(uiFontStyle *fstyle, uiBut *but, rcti *rect) { int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; - int okwidth = BLI_RCT_SIZE_X(rect) - border; - + int okwidth = BLI_rcti_size_x(rect) - border; if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE; - + /* need to set this first */ uiStyleFontSet(fstyle); if (fstyle->kerning == 1) /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); - /* if text editing we define ofs dynamically */ - if (but->editstr && but->pos >= 0) { + but->ofs = 0; + but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr); + + while (but->strwidth > okwidth) { + ui_text_clip_give_next_off(but); + but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); + if (but->strwidth < 10) break; + } + + if (fstyle->kerning == 1) { + BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } +} + +/** + * Cut off the text, taking into account the cursor location (text display while editing). + */ +static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, rcti *rect) +{ + int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; + int okwidth = BLI_rcti_size_x(rect) - border; + if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE; + + BLI_assert(but->editstr && but->pos >= 0); + + /* need to set this first */ + uiStyleFontSet(fstyle); + + if (fstyle->kerning == 1) /* for BLF_width */ + BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + + if ((but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr)) <= okwidth) { + but->ofs = 0; + } + else { + /* define ofs dynamically */ if (but->ofs > but->pos) but->ofs = but->pos; - if (BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth) - but->ofs = 0; - } - else but->ofs = 0; - - but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); - - while (but->strwidth > okwidth) { - - /* textbut exception, clip right when... */ - if (but->editstr && but->pos >= 0) { + while (but->strwidth > okwidth) { float width; char buf[UI_MAX_DRAW_STR]; - + /* copy draw string */ BLI_strncpy_utf8(buf, but->drawstr, sizeof(buf)); /* string position of cursor */ buf[but->pos] = 0; width = BLF_width(fstyle->uifont_id, buf + but->ofs); - + /* if cursor is at 20 pixels of right side button we clip left */ - if (width > okwidth - 20) + if (width > okwidth - 20) { ui_text_clip_give_next_off(but); + } else { int len, bytes; /* shift string to the left */ @@ -1016,25 +1045,30 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len)); but->drawstr[len - bytes] = 0; } - } - else - ui_text_clip_give_next_off(but); - but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); - - if (but->strwidth < 10) break; + but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); + + if (but->strwidth < 10) break; + } } - - if (fstyle->kerning == 1) + + if (fstyle->kerning == 1) { BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + } } -static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) +/** + * Cut off the end of text to fit into the width of \a rect. + * + * \note deals with ': ' especially for number buttons + */ +static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, rcti *rect) { int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10; - int okwidth = BLI_RCT_SIZE_X(rect) - border; + int okwidth = BLI_rcti_size_x(rect) - border; char *cpoin = NULL; - char *cpend = but->drawstr + strlen(but->drawstr); + int drawstr_len = strlen(but->drawstr); + char *cpend = but->drawstr + drawstr_len; /* need to set this first */ uiStyleFontSet(fstyle); @@ -1045,6 +1079,13 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr); but->ofs = 0; + + /* First shorten num-buttopns eg, + * Translucency: 0.000 + * becomes + * Trans: 0.000 + */ + /* find the space after ':' separator */ cpoin = strrchr(but->drawstr, ':'); @@ -1057,8 +1098,11 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) int bytes = cp2 - prev_utf8; /* shift the text after and including cp2 back by 1 char, +1 to include null terminator */ - memmove(cp2 - bytes, cp2, strlen(cp2) + 1); + memmove(cp2 - bytes, cp2, drawstr_len + 1); cp2 -= bytes; + + drawstr_len -= bytes; + // BLI_assert(strlen(but->drawstr) == drawstr_len); but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); if (but->strwidth < 10) break; @@ -1074,14 +1118,17 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) } + + /* Now just remove trailing chars */ /* once the label's gone, chop off the least significant digits */ while (but->strwidth > okwidth) { - int len = strlen(but->drawstr); - int bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len)); + int bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + drawstr_len)); if (bytes < 0) bytes = 1; - but->drawstr[len - bytes] = 0; + drawstr_len -= bytes; + but->drawstr[drawstr_len] = 0; + // BLI_assert(strlen(but->drawstr) == drawstr_len); but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); if (but->strwidth < 10) break; @@ -1229,30 +1276,31 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b /* draws text and icons for buttons */ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) { - - if (but == NULL) return; + if (but == NULL) { + return; + } /* clip but->drawstr to fit in available space */ if (but->editstr && but->pos >= 0) { - ui_text_leftclip(fstyle, but, rect); + ui_text_clip_cursor(fstyle, but, rect); } else if (ELEM4(but->type, NUM, NUMABS, NUMSLI, SLI)) { - ui_text_label_rightclip(fstyle, but, rect); + ui_text_clip_right_label(fstyle, but, rect); } else if (ELEM(but->type, TEX, SEARCH_MENU)) { - ui_text_leftclip(fstyle, but, rect); + ui_text_clip_left(fstyle, but, rect); } else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) { - ui_text_leftclip(fstyle, but, rect); + ui_text_clip_left(fstyle, but, rect); } else but->ofs = 0; - + /* check for button text label */ if (but->type == ICONTEXTROW) { widget_draw_icon(but, (BIFIconID) (but->icon + but->iconadd), 1.0f, rect); } else { - + if (but->type == BUT_TOGDUAL) { int dualset = 0; if (but->pointype == UI_BUT_POIN_SHORT) { @@ -1261,30 +1309,30 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB else if (but->pointype == UI_BUT_POIN_INT) { dualset = UI_BITBUT_TEST(*(((int *)but->poin) + 1), but->bitnr); } - + widget_draw_icon(but, ICON_DOT, dualset ? 1.0f : 0.25f, rect); } else if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) { int tmp = rect->xmin; - rect->xmin = rect->xmax - BLI_RCT_SIZE_Y(rect) - 1; + rect->xmin = rect->xmax - BLI_rcti_size_y(rect) - 1; widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect); rect->xmin = tmp; } - + /* If there's an icon too (made with uiDefIconTextBut) then draw the icon * and offset the text label to accommodate it */ - + if (but->flag & UI_HAS_ICON) { widget_draw_icon(but, but->icon + but->iconadd, 1.0f, rect); - + rect->xmin += (int)((float)UI_icon_get_width(but->icon + but->iconadd) * UI_DPI_ICON_FAC); - - if (but->editstr || (but->flag & UI_TEXT_LEFT)) + + if (but->editstr || (but->flag & UI_TEXT_LEFT)) rect->xmin += 5; } - else if ((but->flag & UI_TEXT_LEFT)) + else if ((but->flag & UI_TEXT_LEFT)) rect->xmin += 5; - + /* always draw text for textbutton cursor */ widget_draw_text(fstyle, wcol, but, rect); @@ -1761,8 +1809,8 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float float quad_strip[WIDGET_SIZE_MAX * 2][2]; /* prevent tooltips to not show round shadow */ - if (2.0f * radout > 0.2f * BLI_RCT_SIZE_Y(&rect1)) - rect1.ymax -= 0.2f * BLI_RCT_SIZE_Y(&rect1); + if (2.0f * radout > 0.2f * BLI_rcti_size_y(&rect1)) + rect1.ymax -= 0.2f * BLI_rcti_size_y(&rect1); else rect1.ymax -= 2.0f * radout; @@ -1844,14 +1892,14 @@ static void ui_hsv_cursor(float x, float y) void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my) { /* duplication of code... well, simple is better now */ - float centx = BLI_RCT_CENTER_X_FL(rect); - float centy = BLI_RCT_CENTER_Y_FL(rect); + float centx = BLI_rcti_cent_x_fl(rect); + float centy = BLI_rcti_cent_y_fl(rect); float radius, dist; - if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)) - radius = (float)BLI_RCT_SIZE_Y(rect) / 2; + if (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect)) + radius = (float)BLI_rcti_size_y(rect) / 2; else - radius = (float)BLI_RCT_SIZE_X(rect) / 2; + radius = (float)BLI_rcti_size_x(rect) / 2; mx -= centx; my -= centy; @@ -1874,30 +1922,33 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) int color_profile = but->block->color_profile; if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = BLI_PR_NONE; + color_profile = FALSE; radstep = 2.0f * (float)M_PI / (float)tot; - centx = BLI_RCT_CENTER_X_FL(rect); - centy = BLI_RCT_CENTER_Y_FL(rect); + centx = BLI_rcti_cent_x_fl(rect); + centy = BLI_rcti_cent_y_fl(rect); - if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)) - radius = (float)BLI_RCT_SIZE_Y(rect) / 2; + if (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect)) + radius = (float)BLI_rcti_size_y(rect) / 2; else - radius = (float)BLI_RCT_SIZE_X(rect) / 2; + radius = (float)BLI_rcti_size_x(rect) / 2; /* color */ ui_get_but_vectorf(but, rgb); - copy_v3_v3(hsv, ui_block_hsv_get(but->block)); + /* copy_v3_v3(hsv, ui_block_hsv_get(but->block)); */ /* UNUSED */ + + rgb_to_hsv_compat_v(rgb, hsvo); + + if (color_profile) + ui_block_to_display_space_v3(but->block, rgb); + rgb_to_hsv_compat_v(rgb, hsv); - copy_v3_v3(hsvo, hsv); /* exception: if 'lock' is set * lock the value of the color wheel to 1. * Useful for color correction tools where you're only interested in hue. */ if (but->flag & UI_BUT_COLOR_LOCK) hsv[2] = 1.f; - else if (color_profile) - hsv[2] = linearrgb_to_srgb(hsv[2]); hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent + 1, colcent + 2); @@ -2059,10 +2110,10 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa } /* rect */ - sx1 = rect->xmin + dx * BLI_RCT_SIZE_X(rect); - sx2 = rect->xmin + (dx + color_step) * BLI_RCT_SIZE_X(rect); + sx1 = rect->xmin + dx * BLI_rcti_size_x(rect); + sx2 = rect->xmin + (dx + color_step) * BLI_rcti_size_x(rect); sy = rect->ymin; - dy = BLI_RCT_SIZE_Y(rect) / 3.0; + dy = BLI_rcti_size_y(rect) / 3.0; glBegin(GL_QUADS); for (a = 0; a < 3; a++, sy += dy) { @@ -2117,8 +2168,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) } /* cursor */ - x = rect->xmin + x * BLI_RCT_SIZE_X(rect); - y = rect->ymin + y * BLI_RCT_SIZE_Y(rect); + x = rect->xmin + x * BLI_rcti_size_x(rect); + y = rect->ymin + y * BLI_rcti_size_y(rect); CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f); CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); @@ -2133,21 +2184,22 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) { uiWidgetBase wtb; - float rad = 0.5f * BLI_RCT_SIZE_X(rect); + float rad = 0.5f * BLI_rcti_size_x(rect); float x, y; float rgb[3], hsv[3], v, range; int color_profile = but->block->color_profile; if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = BLI_PR_NONE; + color_profile = FALSE; ui_get_but_vectorf(but, rgb); + + if (color_profile) + ui_block_to_display_space_v3(but->block, rgb); + rgb_to_hsv_v(rgb, hsv); v = hsv[2]; - if (color_profile) - v = linearrgb_to_srgb(v); - /* map v from property range to [0,1] */ range = but->softmax - but->softmin; v = (v - but->softmin) / range; @@ -2167,8 +2219,8 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) widgetbase_draw(&wtb, &wcol_tmp); /* cursor */ - x = rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect); - y = rect->ymin + v * BLI_RCT_SIZE_Y(rect); + x = rect->xmin + 0.5f * BLI_rcti_size_x(rect); + y = rect->ymin + v * BLI_rcti_size_y(rect); CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); ui_hsv_cursor(x, y); @@ -2179,7 +2231,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) /* ************ separator, for menus etc ***************** */ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol) { - int y = rect->ymin + BLI_RCT_SIZE_Y(rect) / 2 - 1; + int y = rect->ymin + BLI_rcti_size_y(rect) / 2 - 1; unsigned char col[4]; col[0] = wcol->text[0]; @@ -2198,7 +2250,7 @@ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol) static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { uiWidgetBase wtb; - float rad = 0.5f * BLI_RCT_SIZE_Y(rect); + float rad = 0.5f * BLI_rcti_size_y(rect); float textofs = rad * 0.75f; if (state & UI_SELECT) @@ -2279,12 +2331,12 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat widget_init(&wtb); /* determine horizontal/vertical */ - horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)); + horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect)); if (horizontal) - rad = 0.5f * BLI_RCT_SIZE_Y(rect); + rad = 0.5f * BLI_rcti_size_y(rect); else - rad = 0.5f * BLI_RCT_SIZE_X(rect); + rad = 0.5f * BLI_rcti_size_x(rect); wtb.shadedir = (horizontal) ? 1 : 0; @@ -2296,7 +2348,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat widgetbase_draw(&wtb, wcol); /* slider */ - if ((BLI_RCT_SIZE_X(slider) < 2) || (BLI_RCT_SIZE_Y(slider) < 2)) { + if ((BLI_rcti_size_x(slider) < 2) || (BLI_rcti_size_y(slider) < 2)) { /* pass */ } else { @@ -2362,17 +2414,17 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat rect1 = *rect; /* determine horizontal/vertical */ - horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect)); + horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect)); if (horizontal) { - fac = BLI_RCT_SIZE_X(rect) / size; + fac = BLI_rcti_size_x(rect) / size; rect1.xmin = rect1.xmin + ceilf(fac * ((float)value - but->softmin)); rect1.xmax = rect1.xmin + ceilf(fac * (but->a1 - but->softmin)); /* ensure minimium size */ - min = BLI_RCT_SIZE_Y(rect); + min = BLI_rcti_size_y(rect); - if (BLI_RCT_SIZE_X(&rect1) < min) { + if (BLI_rcti_size_x(&rect1) < min) { rect1.xmax = rect1.xmin + min; if (rect1.xmax > rect->xmax) { @@ -2382,14 +2434,14 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat } } else { - fac = BLI_RCT_SIZE_Y(rect) / size; + fac = BLI_rcti_size_y(rect) / size; rect1.ymax = rect1.ymax - ceilf(fac * ((float)value - but->softmin)); rect1.ymin = rect1.ymax - ceilf(fac * (but->a1 - but->softmin)); /* ensure minimium size */ - min = BLI_RCT_SIZE_X(rect); + min = BLI_rcti_size_x(rect); - if (BLI_RCT_SIZE_Y(&rect1) < min) { + if (BLI_rcti_size_y(&rect1) < min) { rect1.ymax = rect1.ymin + min; if (rect1.ymax > rect->ymax) { @@ -2417,10 +2469,10 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int rect_prog.ymax = rect_prog.ymin + 4; rect_bar.ymax = rect_bar.ymin + 4; - w = value * BLI_RCT_SIZE_X(&rect_prog); + w = value * BLI_rcti_size_x(&rect_prog); /* ensure minimium size */ - min = BLI_RCT_SIZE_Y(&rect_prog); + min = BLI_rcti_size_y(&rect_prog); w = MAX2(w, min); rect_bar.xmax = rect_bar.xmin + w; @@ -2440,8 +2492,8 @@ static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, in UI_ThemeColor(TH_TEXT_HI); - rectlink.xmin = BLI_RCT_CENTER_X(rect); - rectlink.ymin = BLI_RCT_CENTER_Y(rect); + rectlink.xmin = BLI_rcti_cent_x(rect); + rectlink.ymin = BLI_rcti_cent_y(rect); rectlink.xmax = but->linkto[0]; rectlink.ymax = but->linkto[1]; @@ -2463,7 +2515,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s /* backdrop first */ /* fully rounded */ - offs = 0.5f * BLI_RCT_SIZE_Y(rect); + offs = 0.5f * BLI_rcti_size_y(rect); toffs = offs * 0.75f; round_box_edges(&wtb, roundboxalign, rect, offs); @@ -2484,7 +2536,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s rect1 = *rect; value = ui_get_but_val(but); - fac = ((float)value - but->softmin) * (BLI_RCT_SIZE_X(&rect1) - offs) / (but->softmax - but->softmin); + fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin); /* left part of slider, always rounded */ rect1.xmax = rect1.xmin + ceil(offs + 1.0f); @@ -2531,7 +2583,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat if (but->rnaprop) { if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) - color_profile = BLI_PR_NONE; + color_profile = FALSE; if (RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4) { col[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3); @@ -2559,7 +2611,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat } if (color_profile) - linearrgb_to_srgb_v3_v3(col, col); + ui_block_to_display_space_v3(but->block, col); rgba_float_to_uchar((unsigned char *)wcol->inner, col); @@ -2617,7 +2669,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), widgetbase_draw(&wtb, wcol); /* text space */ - rect->xmax -= BLI_RCT_SIZE_Y(rect); + rect->xmax -= BLI_rcti_size_y(rect); } static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) @@ -2660,7 +2712,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int { if (state & UI_ACTIVE) { uiWidgetBase wtb; - float rad = 0.5f * BLI_RCT_SIZE_Y(rect); /* 4.0f */ + float rad = 0.5f * BLI_rcti_size_y(rect); /* 4.0f */ widget_init(&wtb); @@ -2706,10 +2758,10 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN widget_init(&wtb); /* square */ - recttemp.xmax = recttemp.xmin + BLI_RCT_SIZE_Y(&recttemp); + recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp); /* smaller */ - delta = 1 + BLI_RCT_SIZE_Y(&recttemp) / 8; + delta = 1 + BLI_rcti_size_y(&recttemp) / 8; recttemp.xmin += delta; recttemp.ymin += delta; recttemp.xmax -= delta; @@ -2726,7 +2778,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN widgetbase_draw(&wtb, wcol); /* text space */ - rect->xmin += BLI_RCT_SIZE_Y(rect) * 0.7 + delta; + rect->xmin += BLI_rcti_size_y(rect) * 0.7 + delta; } @@ -2788,7 +2840,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) { uiWidgetBase wtb; - float rad = 5.0f; /* 0.5f * BLI_RCT_SIZE_Y(rect); */ + float rad = 5.0f; /* 0.5f * BLI_rcti_size_y(rect); */ widget_init(&wtb); @@ -3271,12 +3323,12 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) if (block->flag & UI_BLOCK_CLIPTOP) { /* XXX no scaling for UI here yet */ glColor3ubv((unsigned char *)wt->wcol.text); - UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymax - 8, 't'); + UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymax - 8, 't'); } if (block->flag & UI_BLOCK_CLIPBOTTOM) { /* XXX no scaling for UI here yet */ glColor3ubv((unsigned char *)wt->wcol.text); - UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymin + 10, 'v'); + UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v'); } } } |