diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index a8b50f5c76e..c3edd38f8d9 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -493,8 +493,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) charmax = G.charmax = 0xffff; /* Calculate the size of the button */ - width = absBLI_RCT_SIZE_X(rect); - height = absBLI_RCT_SIZE_Y(rect); + width = abs(BLI_RCT_SIZE_X(rect)); + height = abs(BLI_RCT_SIZE_Y(rect)); butw = floor(width / 12); buth = floor(height / 6); @@ -1371,8 +1371,11 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect scissor_new.xmax = ar->winrct.xmin + rect->xmax; scissor_new.ymax = ar->winrct.ymin + rect->ymax; BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new); - glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax - scissor_new.xmin, scissor_new.ymax - scissor_new.ymin); - + glScissor(scissor_new.xmin, + scissor_new.ymin, + BLI_RCT_SIZE_X(&scissor_new), + BLI_RCT_SIZE_Y(&scissor_new)); + /* calculate offset and zoom */ zoomx = (BLI_RCT_SIZE_X(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_X(&cumap->curr); zoomy = (BLI_RCT_SIZE_Y(rect) - 2.0f * but->aspect) / BLI_RCT_SIZE_Y(&cumap->curr); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 957482bb379..f0d2cb183b5 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4241,8 +4241,8 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa scopes->marker = BKE_tracking_marker_ensure(scopes->track, scopes->framenr); scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED); - scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / (but->block->rect.xmax - but->block->rect.xmin); - scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / (but->block->rect.ymax - but->block->rect.ymin); + scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / BLI_RCT_SIZE_X(&but->block->rect); + scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / BLI_RCT_SIZE_Y(&but->block->rect); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 350aab728c4..deef36de561 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -39,6 +39,7 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_rect.h" #include "BLI_utildefines.h" #include "BLF_translation.h" @@ -238,8 +239,10 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h) if (item->type == ITEM_BUTTON) { uiButtonItem *bitem = (uiButtonItem *)item; - if (r_w) *r_w = bitem->but->rect.xmax - bitem->but->rect.xmin; - if (r_h) *r_h = bitem->but->rect.ymax - bitem->but->rect.ymin; + + + if (r_w) *r_w = BLI_RCT_SIZE_X(&bitem->but->rect); + if (r_h) *r_h = BLI_RCT_SIZE_Y(&bitem->but->rect); } else { uiLayout *litem = (uiLayout *)item; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 512cda13df1..d0e66f532cc 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -547,7 +547,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* itemrect smaller */ itemrect.xmax = headrect.xmax - 5.0f / block->aspect; - itemrect.xmin = itemrect.xmax - (headrect.ymax - headrect.ymin); + itemrect.xmin = itemrect.xmax - BLI_RCT_SIZE_Y(&headrect); itemrect.ymin = headrect.ymin; itemrect.ymax = headrect.ymax; @@ -596,7 +596,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* itemrect smaller */ itemrect.xmin = headrect.xmin + 5.0f / block->aspect; - itemrect.xmax = itemrect.xmin + (headrect.ymax - headrect.ymin); + itemrect.xmax = itemrect.xmin + BLI_RCT_SIZE_Y(&headrect); itemrect.ymin = headrect.ymin; itemrect.ymax = headrect.ymax; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 35488430b22..8dee1ff6a13 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -391,7 +391,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) /* draw text */ uiStyleFontSet(&data->fstyle); - bbox.ymax = bbox.ymax - 0.5f * ((bbox.ymax - bbox.ymin) - data->toth); + bbox.ymax = bbox.ymax - 0.5f * (BLI_RCT_SIZE_Y(&bbox) - data->toth); bbox.ymin = bbox.ymax - data->lineh; for (i = 0; i < data->totline; i++) { @@ -730,9 +730,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; @@ -865,8 +865,8 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) { /* thumbnail preview */ if (data->preview) { - int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / data->prv_rows; - int butw = (data->bbox.xmax - data->bbox.xmin) / data->prv_cols; + int butw = BLI_RCT_SIZE_X(&data->bbox) / data->prv_cols; + int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / data->prv_rows; int row, col; *rect = data->bbox; @@ -882,7 +882,7 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) } /* list view */ else { - int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / SEARCH_ITEMS; + int buth = (BLI_RCT_SIZE_Y(&data->bbox) - 2 * MENU_TOP) / SEARCH_ITEMS; *rect = data->bbox; rect->xmin = data->bbox.xmin + 3.0f; @@ -1200,7 +1200,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) BLI_rctf_translate(&rect_fl, ofsx, ofsy); /* minimal width */ - if (rect_fl.xmax - rect_fl.xmin < 150) { + if (BLI_RCT_SIZE_X(&rect_fl) < 150) { rect_fl.xmax = rect_fl.xmin + 150; /* XXX arbitrary */ } @@ -1233,15 +1233,15 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->rect.ymax + ofsy, NULL, &newy1); newy1 += butregion->winrct.ymin; - rect_i.ymax = rect_i.ymax - rect_i.ymin + newy1; + rect_i.ymax = BLI_RCT_SIZE_Y(&rect_i) + newy1; rect_i.ymin = newy1; } /* widget rect, in region coords */ data->bbox.xmin = MENU_SHADOW_SIDE; - data->bbox.xmax = rect_i.xmax - rect_i.xmin + MENU_SHADOW_SIDE; + data->bbox.xmax = BLI_RCT_SIZE_X(&rect_i) + MENU_SHADOW_SIDE; data->bbox.ymin = MENU_SHADOW_BOTTOM; - data->bbox.ymax = rect_i.ymax - rect_i.ymin + MENU_SHADOW_BOTTOM; + data->bbox.ymax = BLI_RCT_SIZE_Y(&rect_i) + MENU_SHADOW_BOTTOM; /* region bigger for shadow */ ar->winrct.xmin = rect_i.xmin - MENU_SHADOW_SIDE; @@ -2341,7 +2341,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi if (pup->but) { /* minimum width to enforece */ - minwidth = pup->but->rect.xmax - pup->but->rect.xmin; + minwidth = BLI_RCT_SIZE_X(&pup->but->rect); if (pup->but->type == PULLDOWN || pup->but->menu_create_func) { direction = UI_DOWN; @@ -2383,7 +2383,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi * button, so it doesn't overlap the text too much, also note * the offset is negative because we are inverse moving the * block to be under the mouse */ - offset[0] = -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin)); + offset[0] = -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect)); offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y); } else { @@ -2391,7 +2391,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi * on the first item */ offset[0] = 0; for (bt = block->buttons.first; bt; bt = bt->next) - offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * (bt->rect.xmax - bt->rect.xmin))); + offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_RCT_SIZE_X(&bt->rect))); offset[1] = 1.5 * UI_UNIT_Y; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index bf5b3fbe8c7..ef8d8302fa7 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1760,8 +1760,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 * (rect1.ymax - rect1.ymin) ) - rect1.ymax -= 0.2f * (rect1.ymax - rect1.ymin); + if (2.0f * radout > 0.2f * BLI_RCT_SIZE_Y(&rect1)) + rect1.ymax -= 0.2f * BLI_RCT_SIZE_Y(&rect1); else rect1.ymax -= 2.0f * radout; @@ -2371,12 +2371,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat /* ensure minimium size */ min = BLI_RCT_SIZE_Y(rect); - if (rect1.xmax - rect1.xmin < min) { + if (BLI_RCT_SIZE_X(&rect1) < min) { rect1.xmax = rect1.xmin + min; if (rect1.xmax > rect->xmax) { rect1.xmax = rect->xmax; - rect1.xmin = MAX2(rect1.xmax - min, rect->xmin); + rect1.xmin = maxi(rect1.xmax - min, rect->xmin); } } } @@ -2388,7 +2388,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat /* ensure minimium size */ min = BLI_RCT_SIZE_X(rect); - if (rect1.ymax - rect1.ymin < min) { + if (BLI_RCT_SIZE_Y(&rect1) < min) { rect1.ymax = rect1.ymin + min; if (rect1.ymax > rect->ymax) { @@ -2416,10 +2416,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 * (rect_prog.xmax - rect_prog.xmin); + w = value * BLI_RCT_SIZE_X(&rect_prog); /* ensure minimium size */ - min = rect_prog.ymax - rect_prog.ymin; + min = BLI_RCT_SIZE_Y(&rect_prog); w = MAX2(w, min); rect_bar.xmax = rect_bar.xmin + w; @@ -2483,7 +2483,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) * (rect1.xmax - rect1.xmin - offs) / (but->softmax - but->softmin); + fac = ((float)value - but->softmin) * (BLI_RCT_SIZE_X(&rect1) - offs) / (but->softmax - but->softmin); /* left part of slider, always rounded */ rect1.xmax = rect1.xmin + ceil(offs + 1.0f); @@ -2705,10 +2705,10 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN widget_init(&wtb); /* square */ - recttemp.xmax = recttemp.xmin + (recttemp.ymax - recttemp.ymin); + recttemp.xmax = recttemp.xmin + BLI_RCT_SIZE_Y(&recttemp); /* smaller */ - delta = 1 + (recttemp.ymax - recttemp.ymin) / 8; + delta = 1 + BLI_RCT_SIZE_Y(&recttemp) / 8; recttemp.xmin += delta; recttemp.ymin += delta; recttemp.xmax -= delta;