code cleanup: use rect size macros

This commit is contained in:
2012-08-21 20:34:05 +00:00
parent abd031bb4e
commit c92ab5c3ef
32 changed files with 142 additions and 136 deletions

View File

@@ -456,7 +456,7 @@ float blf_font_height(FontBLF *font, const char *str)
ya = 1.0f;
blf_font_boundbox(font, str, &box);
return (box.ymax - box.ymin) * ya;
return BLI_RCT_SIZE_Y(&box) * ya;
}
float blf_font_fixed_width(FontBLF *font)

View File

@@ -668,7 +668,7 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
CurveMap *cuma = cumap->cm + cumap->cur;
CurveMapPoint *cmp = cuma->curve;
rctf *clipr = &cumap->clipr;
float thresh = 0.01f * (clipr->xmax - clipr->xmin);
float thresh = 0.01f * BLI_RCT_SIZE_X(clipr);
float dx = 0.0f, dy = 0.0f;
int a;

View File

@@ -366,9 +366,9 @@ int BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest)
void BLI_rcti_rctf_copy(rcti *dst, const rctf *src)
{
dst->xmin = floorf(src->xmin + 0.5f);
dst->xmax = dst->xmin + floorf((src->xmax - src->xmin) + 0.5f);
dst->xmax = dst->xmin + floorf(BLI_RCT_SIZE_X(src) + 0.5f);
dst->ymin = floorf(src->ymin + 0.5f);
dst->ymax = dst->ymin + floorf((src->ymax - src->ymin) + 0.5f);
dst->ymax = dst->ymin + floorf(BLI_RCT_SIZE_Y(src) + 0.5f);
}
void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)

View File

@@ -819,8 +819,8 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor
y0 = (int)(gps->points->y / 100 * p->ar->winy);
}
else { /* camera view, use subrect */
x0 = (int)((gps->points->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin;
y0 = (int)((gps->points->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin;
x0 = (int)((gps->points->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
y0 = (int)((gps->points->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
}
}
@@ -866,10 +866,10 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], shor
y1 = (int)(pt2->y / 100 * p->ar->winy);
}
else { /* camera view, use subrect */
x0 = (int)((pt1->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin;
y0 = (int)((pt1->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin;
x1 = (int)((pt2->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin;
y1 = (int)((pt2->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin;
x0 = (int)((pt1->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
y0 = (int)((pt1->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
x1 = (int)((pt2->x / 100) * BLI_RCT_SIZE_X(p->subrect)) + p->subrect->xmin;
y1 = (int)((pt2->y / 100) * BLI_RCT_SIZE_Y(p->subrect)) + p->subrect->ymin;
}
}

View File

@@ -1733,8 +1733,8 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int UNUSE
glEnable(GL_BLEND);
if (radius > (rct->ymax - rct->ymin - 10.0f) / 2.0f)
rad = (rct->ymax - rct->ymin - 10.0f) / 2.0f;
if (radius > (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f)
rad = (BLI_RCT_SIZE_Y(rct) - 10.0f) / 2.0f;
else
rad = radius;

View File

@@ -1458,7 +1458,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
totsize = BLI_RCT_SIZE_X(&v2d->tot);
scrollsize = (float)(hor.xmax - hor.xmin);
scrollsize = (float)BLI_RCT_SIZE_X(&hor);
if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize;
@@ -1498,8 +1498,8 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* vertical scrollers */
if (scroll & V2D_SCROLL_VERTICAL) {
/* scroller 'button' extents */
totsize = BLI_RCT_SIZE_Y(&v2d->tot);
scrollsize = (float)(vert.ymax - vert.ymin);
totsize = BLI_RCT_SIZE_Y(&v2d->tot);
scrollsize = (float)BLI_RCT_SIZE_Y(&vert);
if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize;
@@ -1545,7 +1545,9 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
scrollers->yclamp = yclamp;
scrollers->yunits = yunits;
scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, xunits, xclamp, yunits, yclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d,
xunits, xclamp, yunits, yclamp,
BLI_RCT_SIZE_X(&hor), BLI_RCT_SIZE_Y(&vert));
}
/* return scrollers */
@@ -1629,7 +1631,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
*/
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 &&
(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) &&
(slider.xmax - slider.xmin > V2D_SCROLLER_HANDLE_SIZE))
(BLI_RCT_SIZE_X(&slider) > V2D_SCROLLER_HANDLE_SIZE))
{
state |= UI_SCROLL_ARROWS;
}
@@ -1650,10 +1652,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - dfac is gap between scale markings
*/
fac = (grid->startx - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
fac = (float)hor.xmin + fac * (hor.xmax - hor.xmin);
fac = (float)hor.xmin + fac * BLI_RCT_SIZE_X(&hor);
dfac = grid->dx / BLI_RCT_SIZE_X(&v2d->cur);
dfac = dfac * (hor.xmax - hor.xmin);
dfac = dfac * BLI_RCT_SIZE_X(&hor);
/* set starting value, and text color */
UI_ThemeColor(TH_TEXT);
@@ -1740,7 +1742,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
*/
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 &&
(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) &&
(slider.ymax - slider.ymin > V2D_SCROLLER_HANDLE_SIZE))
(BLI_RCT_SIZE_Y(&slider) > V2D_SCROLLER_HANDLE_SIZE))
{
state |= UI_SCROLL_ARROWS;
}
@@ -1764,10 +1766,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* NOTE: it's assumed that that scrollbar is there if this is involved!
*/
fac = (grid->starty - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
fac = vert.ymin + fac * (vert.ymax - vert.ymin);
fac = vert.ymin + fac * BLI_RCT_SIZE_Y(&vert);
dfac = grid->dy / BLI_RCT_SIZE_Y(&v2d->cur);
dfac = dfac * (vert.ymax - vert.ymin);
dfac = dfac * BLI_RCT_SIZE_Y(&vert);
/* set starting value, and text color */
UI_ThemeColor(TH_TEXT);
@@ -2140,7 +2142,7 @@ void UI_view2d_text_cache_draw(ARegion *ar)
const char *str = (const char *)(v2s + 1);
int xofs = 0, yofs;
yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - default_height));
yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(&v2s->rect) - default_height));
if (yofs < 1) yofs = 1;
if (col_pack_prev != v2s->col.pack) {

View File

@@ -471,7 +471,7 @@ static int view_scrollup_exec(bContext *C, wmOperator *op)
if (RNA_boolean_get(op->ptr, "page")) {
ARegion *ar = CTX_wm_region(C);
RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymax - ar->v2d.mask.ymin);
RNA_int_set(op->ptr, "deltay", BLI_RCT_SIZE_Y(&ar->v2d.mask));
}
/* apply movement, then we're done */
@@ -1137,7 +1137,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
/* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
size = (cur_new.xmax - cur_new.xmin);
size = BLI_RCT_SIZE_X(&cur_new);
zoom = size / BLI_RCT_SIZE_X(&rect);
center = BLI_RCT_CENTER_X(&cur_new);
@@ -1145,7 +1145,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
cur_new.xmax = center + (size * zoom);
}
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
size = (cur_new.ymax - cur_new.ymin);
size = BLI_RCT_SIZE_Y(&cur_new);
zoom = size / BLI_RCT_SIZE_Y(&rect);
center = BLI_RCT_CENTER_Y(&cur_new);
@@ -1197,10 +1197,10 @@ struct SmoothView2DStore {
*/
static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
{
float size_a[2] = {rect_a->xmax - rect_a->xmin,
rect_a->ymax - rect_a->ymin};
float size_b[2] = {rect_b->xmax - rect_b->xmin,
rect_b->ymax - rect_b->ymin};
float size_a[2] = {BLI_RCT_SIZE_X(rect_a),
BLI_RCT_SIZE_Y(rect_a)};
float size_b[2] = {BLI_RCT_SIZE_X(rect_b),
BLI_RCT_SIZE_Y(rect_b)};
float cent_a[2] = {BLI_RCT_CENTER_X(rect_a),
BLI_RCT_CENTER_Y(rect_a)};
float cent_b[2] = {BLI_RCT_CENTER_X(rect_b),
@@ -1477,7 +1477,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
if (in_scroller == 'h') {
/* horizontal scroller - calculate adjustment factor first */
mask_size = (float)(v2d->hor.xmax - v2d->hor.xmin);
mask_size = (float)BLI_RCT_SIZE_X(&v2d->hor);
vsm->fac = BLI_RCT_SIZE_X(&v2d->tot) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
@@ -1493,7 +1493,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
}
else {
/* vertical scroller - calculate adjustment factor first */
mask_size = (float)(v2d->vert.ymax - v2d->vert.ymin);
mask_size = (float)BLI_RCT_SIZE_Y(&v2d->vert);
vsm->fac = BLI_RCT_SIZE_Y(&v2d->tot) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */

View File

@@ -1096,8 +1096,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
if (ar->alignment & RGN_SPLIT_PREV) {
if (ar->prev) {
remainder = remainder_prev;
ar->prev->winx = ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1;
ar->prev->winy = ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1;
ar->prev->winx = BLI_RCT_SIZE_X(&ar->prev->winrct) + 1;
ar->prev->winy = BLI_RCT_SIZE_Y(&ar->prev->winrct) + 1;
}
}
@@ -1769,7 +1769,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
}
/* always as last */
UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, ar->v2d.tot.ymax - ar->v2d.tot.ymin);
UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_RCT_SIZE_Y(&ar->v2d.tot));
/* restore view matrix? */
UI_view2d_view_restore(C);

View File

@@ -35,6 +35,7 @@
#include "DNA_vec_types.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "BKE_colortools.h"
@@ -668,8 +669,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo
void glaDefine2DArea(rcti *screen_rect)
{
int sc_w = screen_rect->xmax - screen_rect->xmin + 1;
int sc_h = screen_rect->ymax - screen_rect->ymin + 1;
const int sc_w = BLI_RCT_SIZE_X(screen_rect) + 1;
const int sc_h = BLI_RCT_SIZE_Y(screen_rect) + 1;
glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h);
@@ -713,10 +714,10 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect)
di->world_rect = *rect;
sc_w = (di->screen_rect.xmax - di->screen_rect.xmin);
sc_h = (di->screen_rect.ymax - di->screen_rect.ymin);
wo_w = (di->world_rect.xmax - di->world_rect.xmin);
wo_h = (di->world_rect.ymax - di->world_rect.ymin);
sc_w = BLI_RCT_SIZE_X(&di->screen_rect);
sc_h = BLI_RCT_SIZE_Y(&di->screen_rect);
wo_w = BLI_RCT_SIZE_X(&di->world_rect);
wo_h = BLI_RCT_SIZE_Y(&di->world_rect);
di->wo_to_sc[0] = sc_w / wo_w;
di->wo_to_sc[1] = sc_h / wo_h;
@@ -744,10 +745,10 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect)
di->world_rect.ymax = di->screen_rect.ymax;
}
sc_w = (di->screen_rect.xmax - di->screen_rect.xmin);
sc_h = (di->screen_rect.ymax - di->screen_rect.ymin);
wo_w = (di->world_rect.xmax - di->world_rect.xmin);
wo_h = (di->world_rect.ymax - di->world_rect.ymin);
sc_w = BLI_RCT_SIZE_X(&di->screen_rect);
sc_h = BLI_RCT_SIZE_Y(&di->screen_rect);
wo_w = BLI_RCT_SIZE_X(&di->world_rect);
wo_h = BLI_RCT_SIZE_Y(&di->world_rect);
di->wo_to_sc[0] = sc_w / wo_w;
di->wo_to_sc[1] = sc_h / wo_h;

View File

@@ -1615,7 +1615,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
dist = BLI_RCT_SIZE_X(&sa->totrct);
}
else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
dist = sa->totrct.ymax - sa->totrct.ymin;
dist = BLI_RCT_SIZE_Y(&sa->totrct);
}
/* subtractwidth of regions on opposite side

View File

@@ -149,14 +149,16 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop)
{
unsigned int *to = ibuf->rect;
unsigned int *from = ibuf->rect + crop.ymin * ibuf->x + crop.xmin;
int y, cropw = crop.xmax - crop.xmin, croph = crop.ymax - crop.ymin;
int crop_x = BLI_RCT_SIZE_X(&crop);
int crop_y = BLI_RCT_SIZE_Y(&crop);
int y;
if (cropw > 0 && croph > 0) {
for (y = 0; y < croph; y++, to += cropw, from += ibuf->x)
memmove(to, from, sizeof(unsigned int) * cropw);
if (crop_x > 0 && crop_y > 0) {
for (y = 0; y < crop_y; y++, to += crop_x, from += ibuf->x)
memmove(to, from, sizeof(unsigned int) * crop_x);
ibuf->x = cropw;
ibuf->y = croph;
ibuf->x = crop_x;
ibuf->y = crop_y;
}
}

View File

@@ -31,6 +31,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "DNA_brush_types.h"
@@ -440,8 +441,8 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
else {
quad.xmin = 0;
quad.ymin = 0;
quad.xmax = vc->ar->winrct.xmax - vc->ar->winrct.xmin;
quad.ymax = vc->ar->winrct.ymax - vc->ar->winrct.ymin;
quad.xmax = BLI_RCT_SIZE_X(&vc->ar->winrct);
quad.ymax = BLI_RCT_SIZE_Y(&vc->ar->winrct);
}
/* set quad color */

View File

@@ -148,7 +148,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar)
uiBlockEndAlign(block);
/* always as last */
UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), ar->v2d.tot.ymax - ar->v2d.tot.ymin);
UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_RCT_SIZE_Y(&ar->v2d.tot));
uiEndBlock(C, block);
uiDrawBlock(C, block);

View File

@@ -224,16 +224,16 @@ static int graphkeys_viewall(bContext *C, const short do_sel_only, const short i
return OPERATOR_CANCELLED;
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_graph_keyframe_extents(&ac,
&cur_new.xmin, &cur_new.xmax,
&cur_new.ymin, &cur_new.ymax,
do_sel_only, include_handles);
get_graph_keyframe_extents(&ac,
&cur_new.xmin, &cur_new.xmax,
&cur_new.ymin, &cur_new.ymax,
do_sel_only, include_handles);
extra = 0.1f * (cur_new.xmax - cur_new.xmin);
extra = 0.1f * BLI_RCT_SIZE_X(&cur_new);
cur_new.xmin -= extra;
cur_new.xmax += extra;
extra = 0.1f * (cur_new.ymax - cur_new.ymin);
extra = 0.1f * BLI_RCT_SIZE_Y(&cur_new);
cur_new.ymin -= extra;
cur_new.ymax += extra;

View File

@@ -268,8 +268,8 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block)
int mval[2];
if (G.scene->r.mode & R_BORDER) {
winx *= (G.scene->r.border.xmax - G.scene->r.border.xmin);
winy *= (G.scene->r.border.ymax - G.scene->r.border.ymin);
winx *= BLI_RCT_SIZE_X(&G.scene->r.border);
winy *= BLI_RCT_SIZE_Y(&G.scene->r.border);
}
/* while dragging we need to update the rects, otherwise it doesn't end with correct one */

View File

@@ -182,8 +182,8 @@ void ED_space_image_get_size(SpaceImage *sima, int *width, int *height)
*height = (scene->r.ysch * scene->r.size) / 100;
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
*width *= (scene->r.border.xmax - scene->r.border.xmin);
*height *= (scene->r.border.ymax - scene->r.border.ymin);
*width *= BLI_RCT_SIZE_X(&scene->r.border);
*height *= BLI_RCT_SIZE_Y(&scene->r.border);
}
}

View File

@@ -343,7 +343,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node)
if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin);
}
else {
float oldh = node->prvr.ymax - node->prvr.ymin;
float oldh = BLI_RCT_SIZE_Y(&node->prvr);
if (oldh == 0.0f)
oldh = 0.6f * node->width - NODE_DY;
dy -= NODE_DYS / 2;
@@ -584,9 +584,9 @@ void node_socket_circle_draw(bNodeTree *UNUSED(ntree), bNodeSocket *sock, float
/* not a callback */
static void node_draw_preview(bNodePreview *preview, rctf *prv)
{
float xscale = (prv->xmax - prv->xmin) / ((float)preview->xsize);
float yscale = (prv->ymax - prv->ymin) / ((float)preview->ysize);
float tile = (prv->xmax - prv->xmin) / 10.0f;
float xscale = BLI_RCT_SIZE_X(prv) / ((float)preview->xsize);
float yscale = BLI_RCT_SIZE_Y(prv) / ((float)preview->ysize);
float tile = BLI_RCT_SIZE_X(prv) / 10.0f;
float x, y;
/* draw checkerboard backdrop to show alpha */
@@ -852,8 +852,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
{
bNodeSocket *sock;
rctf *rct = &node->totr;
float dx, centy = 0.5f * (rct->ymax + rct->ymin);
float hiddenrad = 0.5f * (rct->ymax - rct->ymin);
float dx, centy = BLI_RCT_CENTER_Y(rct);
float hiddenrad = BLI_RCT_SIZE_Y(rct) / 2.0f;
float socket_size = NODE_SOCKSIZE * U.dpi / 72;
int color_id = node_get_colorid(node);
char showname[128]; /* 128 is used below */
@@ -932,7 +932,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
uiDefBut(node->block, LABEL, 0, showname,
(int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10),
(short)(rct->xmax - rct->xmin - 18.0f - 12.0f), (short)NODE_DY,
(short)(BLI_RCT_SIZE_X(rct) - 18.0f - 12.0f), (short)NODE_DY,
NULL, 0, 0, 0, 0, "");
}

View File

@@ -91,8 +91,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons
}
if (tot) {
width = cur_new.xmax - cur_new.xmin;
height = cur_new.ymax - cur_new.ymin;
width = BLI_RCT_SIZE_X(&cur_new);
height = BLI_RCT_SIZE_Y(&cur_new);
/* for single non-frame nodes, don't zoom in, just pan view,
* but do allow zooming out, this allows for big nodes to be zoomed out */
@@ -104,9 +104,6 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons
BLI_rctf_resize(&cur_new, oldwidth, oldheight);
}
else {
width = cur_new.xmax - cur_new.xmin;
height = cur_new.ymax - cur_new.ymin;
if (width > height) {
float newheight;
newheight = oldheight * width / oldwidth;

View File

@@ -615,7 +615,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot)
static int outliner_scroll_page_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
int dy = ar->v2d.mask.ymax - ar->v2d.mask.ymin;
int dy = BLI_RCT_SIZE_Y(&ar->v2d.mask);
int up = 0;
if (RNA_boolean_get(op->ptr, "up"))
@@ -760,10 +760,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
tselem->flag |= TSE_SELECTED;
/* make te->ys center of view */
ytop = (int)(te->ys + (ar->v2d.mask.ymax - ar->v2d.mask.ymin) / 2);
ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&ar->v2d.mask) / 2);
if (ytop > 0) ytop = 0;
ar->v2d.cur.ymax = (float)ytop;
ar->v2d.cur.ymin = (float)(ytop - (ar->v2d.mask.ymax - ar->v2d.mask.ymin));
ar->v2d.cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&ar->v2d.mask));
/* make te->xs ==> te->xend center of view */
xdelta = (int)(te->xs - ar->v2d.cur.xmin);

View File

@@ -2246,7 +2246,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
ymax += ymargin;
ymin -= ymargin;
orig_height = cur_new.ymax - cur_new.ymin;
orig_height = BLI_RCT_SIZE_Y(&cur_new);
cur_new.xmin = xmin;
cur_new.xmax = xmax;
@@ -2255,7 +2255,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
cur_new.ymax = ymax;
/* only zoom out vertically */
if (orig_height > cur_new.ymax - cur_new.ymin) {
if (orig_height > BLI_RCT_SIZE_Y(&cur_new)) {
ymid = BLI_RCT_CENTER_Y(&cur_new);
cur_new.ymin = ymid - (orig_height / 2);

View File

@@ -39,6 +39,7 @@
#include "BLF_api.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_text_types.h"
@@ -1231,7 +1232,7 @@ static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back)
uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0);
uiSetRoundBox(UI_CNR_ALL);
rad = 0.4f * MIN2(st->txtscroll.xmax - st->txtscroll.xmin, st->txtscroll.ymax - st->txtscroll.ymin);
rad = 0.4f * mini(BLI_RCT_SIZE_X(&st->txtscroll), BLI_RCT_SIZE_Y(&st->txtscroll));
UI_GetThemeColor3ubv(TH_HILITE, col);
col[3] = 48;
glColor4ubv(col);

View File

@@ -971,10 +971,10 @@ static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionV
rect_camera = params.viewplane;
/* get camera border within viewport */
viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx;
viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / (rect_view.xmax - rect_view.xmin)) * ar->winx;
viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy;
viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / (rect_view.ymax - rect_view.ymin)) * ar->winy;
viewborder_r->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx;
viewborder_r->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_RCT_SIZE_X(&rect_view)) * ar->winx;
viewborder_r->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy;
viewborder_r->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_RCT_SIZE_Y(&rect_view)) * ar->winy;
}
void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, float size_r[2])
@@ -982,8 +982,8 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R
rctf viewborder;
view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE);
size_r[0] = viewborder.xmax - viewborder.xmin;
size_r[1] = viewborder.ymax - viewborder.ymin;
size_r[0] = BLI_RCT_SIZE_X(&viewborder);
size_r[1] = BLI_RCT_SIZE_Y(&viewborder);
}
void ED_view3d_calc_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d,
@@ -1339,7 +1339,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
glDisable(GL_MULTISAMPLE_ARB);
region_scissor_winrct(ar, &winrct);
glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin);
glScissor(winrct.xmin, winrct.ymin, BLI_RCT_SIZE_X(&winrct), BLI_RCT_SIZE_Y(&winrct));
glClearColor(0.0, 0.0, 0.0, 0.0);
if (v3d->zbuf) {
@@ -2846,10 +2846,10 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE);
cliprct.xmin = viewborder.xmin + scene->r.border.xmin * (viewborder.xmax - viewborder.xmin);
cliprct.ymin = viewborder.ymin + scene->r.border.ymin * (viewborder.ymax - viewborder.ymin);
cliprct.xmax = viewborder.xmin + scene->r.border.xmax * (viewborder.xmax - viewborder.xmin);
cliprct.ymax = viewborder.ymin + scene->r.border.ymax * (viewborder.ymax - viewborder.ymin);
cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_RCT_SIZE_X(&viewborder);
cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_RCT_SIZE_Y(&viewborder);
cliprct.xmax = viewborder.xmin + scene->r.border.xmax * BLI_RCT_SIZE_X(&viewborder);
cliprct.ymax = viewborder.ymin + scene->r.border.ymax * BLI_RCT_SIZE_Y(&viewborder);
cliprct.xmin += ar->winrct.xmin;
cliprct.xmax += ar->winrct.xmin;
@@ -2863,7 +2863,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw
if (cliprct.xmax > cliprct.xmin && cliprct.ymax > cliprct.ymin) {
glGetIntegerv(GL_SCISSOR_BOX, scissor);
glScissor(cliprct.xmin, cliprct.ymin, cliprct.xmax - cliprct.xmin, cliprct.ymax - cliprct.ymin);
glScissor(cliprct.xmin, cliprct.ymin, BLI_RCT_SIZE_X(&cliprct), BLI_RCT_SIZE_Y(&cliprct));
}
else
return 0;

View File

@@ -2617,10 +2617,10 @@ static int render_border_exec(bContext *C, wmOperator *op)
/* calculate range */
ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE);
scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / (vb.xmax - vb.xmin);
scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / (vb.ymax - vb.ymin);
scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / (vb.xmax - vb.xmin);
scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / (vb.ymax - vb.ymin);
scene->r.border.xmin = ((float)rect.xmin - vb.xmin) / BLI_RCT_SIZE_X(&vb);
scene->r.border.ymin = ((float)rect.ymin - vb.ymin) / BLI_RCT_SIZE_Y(&vb);
scene->r.border.xmax = ((float)rect.xmax - vb.xmin) / BLI_RCT_SIZE_X(&vb);
scene->r.border.ymax = ((float)rect.ymax - vb.ymin) / BLI_RCT_SIZE_Y(&vb);
/* actually set border */
CLAMP(scene->r.border.xmin, 0.0f, 1.0f);

View File

@@ -961,8 +961,8 @@ static void TargetSnapOffset(TransInfo *t, TransData *td)
if (t->spacetype == SPACE_NODE && td != NULL) {
bNode *node = td->extra;
char border = t->tsnap.snapNodeBorder;
float width = node->totr.xmax - node->totr.xmin;
float height = node->totr.ymax - node->totr.ymin;
float width = BLI_RCT_SIZE_X(&node->totr);
float height = BLI_RCT_SIZE_Y(&node->totr);
if (border & NODE_LEFT)
t->tsnap.snapTarget[0] -= 0.5f * width;

View File

@@ -146,7 +146,7 @@ CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, in
if (disprect.xmin>= disprect.xmax) return NULL;
if (disprect.ymin>= disprect.ymax) return NULL;
cbuf= alloc_compbuf(disprect.xmax-disprect.xmin, disprect.ymax-disprect.ymin, type, 1);
cbuf= alloc_compbuf(BLI_RCT_SIZE_X(&disprect), BLI_RCT_SIZE_Y(&disprect), type, 1);
outfp= cbuf->rect;
rectf += type*(disprect.ymin*rectx + disprect.xmin);
dx= type*cbuf->x;

View File

@@ -5247,13 +5247,15 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con
/* precalculate amount of radians 1 pixel rotates */
if (pano) {
/* size of 1 pixel mapped to viewplane coords */
float psize= (re->viewplane.xmax-re->viewplane.xmin)/(float)re->winx;
float psize;
psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx;
/* x angle of a pixel */
pixelphix= atan(psize/re->clipsta);
pixelphix = atan(psize / re->clipsta);
psize= (re->viewplane.ymax-re->viewplane.ymin)/(float)re->winy;
psize = BLI_RCT_SIZE_Y(&re->viewplane) / (float)re->winy;
/* y angle of a pixel */
pixelphiy= atan(psize/re->clipsta);
pixelphiy = atan(psize / re->clipsta);
}
zmulx= re->winx/2;
zmuly= re->winy/2;

View File

@@ -396,16 +396,16 @@ static float square_rctf(rctf *rf)
{
float x, y;
x= rf->xmax- rf->xmin;
y= rf->ymax- rf->ymin;
return (x*y);
x = BLI_RCT_SIZE_X(rf);
y = BLI_RCT_SIZE_Y(rf);
return x * y;
}
static float clipx_rctf(rctf *rf, float x1, float x2)
{
float size;
size= rf->xmax - rf->xmin;
size = BLI_RCT_SIZE_X(rf);
if (rf->xmin<x1) {
rf->xmin = x1;
@@ -418,7 +418,7 @@ static float clipx_rctf(rctf *rf, float x1, float x2)
return 0.0;
}
else if (size!=0.0f) {
return (rf->xmax - rf->xmin)/size;
return BLI_RCT_SIZE_X(rf) / size;
}
return 1.0;
}
@@ -427,7 +427,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2)
{
float size;
size= rf->ymax - rf->ymin;
size = BLI_RCT_SIZE_Y(rf);
if (rf->ymin<y1) {
rf->ymin = y1;
@@ -440,8 +440,8 @@ static float clipy_rctf(rctf *rf, float y1, float y2)
rf->ymin = rf->ymax;
return 0.0;
}
else if (size!=0.0f) {
return (rf->ymax - rf->ymin)/size;
else if (size != 0.0f) {
return BLI_RCT_SIZE_Y(rf) / size;
}
return 1.0;

View File

@@ -610,8 +610,8 @@ void initparts(Render *re)
}
else disprect.ymax = ymaxb;
rectx = disprect.xmax - disprect.xmin;
recty = disprect.ymax - disprect.ymin;
rectx = BLI_RCT_SIZE_X(&disprect);
recty = BLI_RCT_SIZE_Y(&disprect);
/* so, now can we add this part? */
if (rectx > 0 && recty > 0) {

View File

@@ -439,8 +439,8 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer *
re->winy = winy;
if (disprect) {
re->disprect = *disprect;
re->rectx = disprect->xmax - disprect->xmin;
re->recty = disprect->ymax - disprect->ymin;
re->rectx = BLI_RCT_SIZE_X(disprect);
re->recty = BLI_RCT_SIZE_Y(disprect);
}
else {
re->disprect.xmin = re->disprect.ymin = 0;
@@ -672,15 +672,15 @@ static void *do_part_thread(void *pa_v)
float panorama_pixel_rot(Render *re)
{
float psize, phi, xfac;
float borderfac = (float)(re->disprect.xmax - re->disprect.xmin) / (float)re->winx;
float borderfac = (float)BLI_RCT_SIZE_X(&re->disprect) / (float)re->winx;
/* size of 1 pixel mapped to viewplane coords */
psize = (re->viewplane.xmax - re->viewplane.xmin) / (float)(re->winx);
psize = BLI_RCT_SIZE_X(&re->viewplane) / (float)re->winx;
/* angle of a pixel */
phi = atan(psize / re->clipsta);
/* correction factor for viewplane shifting, first calculate how much the viewplane angle is */
xfac = borderfac * ((re->viewplane.xmax - re->viewplane.xmin)) / (float)re->xparts;
xfac = borderfac * BLI_RCT_SIZE_X(&re->viewplane) / (float)re->xparts;
xfac = atan(0.5f * xfac / re->clipsta);
/* and how much the same viewplane angle is wrapped */
psize = 0.5f * phi * ((float)re->partx);
@@ -713,7 +713,7 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane)
float phi = panorama_pixel_rot(re);
R.panodxp = (re->winx - (best->disprect.xmin + best->disprect.xmax) ) / 2;
R.panodxv = ((viewplane->xmax - viewplane->xmin) * R.panodxp) / (float)(re->winx);
R.panodxv = (BLI_RCT_SIZE_X(viewplane) * R.panodxp) / (float)(re->winx);
/* shift viewplane */
R.viewplane.xmin = viewplane->xmin + R.panodxv;

View File

@@ -107,11 +107,11 @@ void calc_view_vector(float *view, float x, float y)
}
/* move x and y to real viewplane coords */
x= (x/(float)R.winx);
view[0]= R.viewplane.xmin + x*(R.viewplane.xmax - R.viewplane.xmin);
x = (x / (float)R.winx);
view[0] = R.viewplane.xmin + x * BLI_RCT_SIZE_X(&R.viewplane);
y= (y/(float)R.winy);
view[1]= R.viewplane.ymin + y*(R.viewplane.ymax - R.viewplane.ymin);
y = (y / (float)R.winy);
view[1] = R.viewplane.ymin + y * BLI_RCT_SIZE_Y(&R.viewplane);
// if (R.flag & R_SEC_FIELD) {
// if (R.r.mode & R_ODDFIELD) view[1]= (y+R.ystart)*R.ycor;

View File

@@ -1506,10 +1506,10 @@ static void isb_bsp_split_init(ISBBranch *root, MemArena *mem, int level)
root->divider[1]= 0.5f*(root->box.ymin+root->box.ymax);
/* find best splitpoint */
if (root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin)
i= root->index= 0;
if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box))
i = root->index = 0;
else
i= root->index= 1;
i = root->index = 1;
left= root->left= BLI_memarena_alloc(mem, sizeof(ISBBranch));
right= root->right= BLI_memarena_alloc(mem, sizeof(ISBBranch));
@@ -1551,10 +1551,10 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem)
root->divider[1]/= BSPMAX_SAMPLE;
/* find best splitpoint */
if (root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin)
i= root->index= 0;
if (BLI_RCT_SIZE_X(&root->box) > BLI_RCT_SIZE_Y(&root->box))
i = root->index = 0;
else
i= root->index= 1;
i = root->index = 1;
/* new branches */
left= root->left= BLI_memarena_alloc(mem, sizeof(ISBBranch));

View File

@@ -256,13 +256,13 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
win->curswin = _curswin;
_curwindow = win;
width = _curswin->winrct.xmax - _curswin->winrct.xmin + 1;
height = _curswin->winrct.ymax - _curswin->winrct.ymin + 1;
width = BLI_RCT_SIZE_X(&_curswin->winrct) + 1;
height = BLI_RCT_SIZE_Y(&_curswin->winrct) + 1;
glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
if (srct) {
width = srct->xmax - srct->xmin + 1;
height = srct->ymax - srct->ymin + 1;
width = BLI_RCT_SIZE_X(srct) + 1;
height = BLI_RCT_SIZE_Y(srct) + 1;
glScissor(srct->xmin, srct->ymin, width, height);
}
else