Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenlib/intern/rct.c4
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp6
-rw-r--r--source/blender/editors/animation/anim_markers.c2
-rw-r--r--source/blender/editors/interface/interface.c22
-rw-r--r--source/blender/editors/interface/interface_draw.c38
-rw-r--r--source/blender/editors/interface/interface_handlers.c62
-rw-r--r--source/blender/editors/interface/interface_panel.c12
-rw-r--r--source/blender/editors/interface/interface_regions.c18
-rw-r--r--source/blender/editors/interface/interface_style.c12
-rw-r--r--source/blender/editors/interface/interface_templates.c23
-rw-r--r--source/blender/editors/interface/interface_widgets.c101
-rw-r--r--source/blender/editors/interface/view2d.c98
-rw-r--r--source/blender/editors/interface/view2d_ops.c52
-rw-r--r--source/blender/editors/mask/mask_draw.c9
-rw-r--r--source/blender/editors/mesh/editface.c4
-rw-r--r--source/blender/editors/render/render_preview.c7
-rw-r--r--source/blender/editors/screen/area.c30
-rw-r--r--source/blender/editors/screen/screen_ops.c2
-rw-r--r--source/blender/editors/space_action/action_draw.c2
-rw-r--r--source/blender/editors/space_action/action_edit.c4
-rw-r--r--source/blender/editors/space_action/action_select.c2
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c3
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c3
-rw-r--r--source/blender/editors/space_clip/clip_draw.c8
-rw-r--r--source/blender/editors/space_clip/clip_editor.c9
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c6
-rw-r--r--source/blender/editors/space_clip/clip_ops.c9
-rw-r--r--source/blender/editors/space_clip/space_clip.c4
-rw-r--r--source/blender/editors/space_console/space_console.c2
-rw-r--r--source/blender/editors/space_file/filesel.c8
-rw-r--r--source/blender/editors/space_file/space_file.c2
-rw-r--r--source/blender/editors/space_graph/graph_draw.c4
-rw-r--r--source/blender/editors/space_graph/graph_select.c2
-rw-r--r--source/blender/editors/space_image/image_buttons.c2
-rw-r--r--source/blender/editors/space_image/image_draw.c3
-rw-r--r--source/blender/editors/space_image/image_edit.c5
-rw-r--r--source/blender/editors/space_image/image_ops.c8
-rw-r--r--source/blender/editors/space_image/space_image.c4
-rw-r--r--source/blender/editors/space_nla/nla_edit.c4
-rw-r--r--source/blender/editors/space_nla/nla_select.c2
-rw-r--r--source/blender/editors/space_node/drawnode.c4
-rw-r--r--source/blender/editors/space_node/node_draw.c2
-rw-r--r--source/blender/editors/space_node/node_view.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c14
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c14
-rw-r--r--source/blender/editors/space_time/time_ops.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c4
-rw-r--r--source/blender/editors/transform/transform.c16
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c4
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp2
53 files changed, 346 insertions, 334 deletions
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index 61408610520..92cbcd485b6 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -382,11 +382,11 @@ void BLI_rctf_rcti_copy(rctf *dst, const rcti *src)
void print_rctf(const char *str, const rctf *rect)
{
printf("%s: xmin %.3f, xmax %.3f, ymin %.3f, ymax %.3f (%.3fx%.3f)\n", str,
- rect->xmin, rect->xmax, rect->ymin, rect->ymax, rect->xmax - rect->xmin, rect->ymax - rect->ymin);
+ rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
}
void print_rcti(const char *str, const rcti *rect)
{
printf("%s: xmin %d, xmax %d, ymin %d, ymax %d (%dx%d)\n", str,
- rect->xmin, rect->xmax, rect->ymin, rect->ymax, rect->xmax - rect->xmin, rect->ymax - rect->ymin);
+ rect->xmin, rect->xmax, rect->ymin, rect->ymax, BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
}
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index 2687fee28ce..c4b4452fbb0 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -79,7 +79,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
- const int bufferWidth = rect->xmax - rect->xmin;
+ const int bufferWidth = BLI_RCT_SIZE_X(rect);
int offset;
this->m_inputProgram->read(inputValue, x, y, NULL);
@@ -199,7 +199,7 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
- const int bufferWidth = rect->xmax - rect->xmin;
+ const int bufferWidth = BLI_RCT_SIZE_X(rect);
int offset;
float value = 0.0f;
@@ -273,7 +273,7 @@ void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *d
const int miny = max(y - this->m_scope, rect->ymin);
const int maxx = min(x + this->m_scope, rect->xmax);
const int maxy = min(y + this->m_scope, rect->ymax);
- const int bufferWidth = rect->xmax - rect->xmin;
+ const int bufferWidth = BLI_RCT_SIZE_X(rect);
int offset;
float value = 1.0f;
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index c75024a469e..95adaa01b94 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -354,7 +354,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
xpos = marker->frame;
/* no time correction for framelen! space is drawn with old values */
- ypixels = v2d->mask.ymax - v2d->mask.ymin;
+ ypixels = BLI_RCT_SIZE_Y(&v2d->mask);
UI_view2d_getscale(v2d, &xscale, &yscale);
glScalef(1.0f / xscale, 1.0f, 1.0f);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index f728e999667..10917f23cdd 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -99,8 +99,8 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y
float gx, gy;
int sx, sy, getsizex, getsizey;
- getsizex = ar->winrct.xmax - ar->winrct.xmin + 1;
- getsizey = ar->winrct.ymax - ar->winrct.ymin + 1;
+ getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
sx = ar->winrct.xmin;
sy = ar->winrct.ymin;
@@ -145,8 +145,8 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y
float a, b, c, d, e, f, px, py;
int sx, sy, getsizex, getsizey;
- getsizex = ar->winrct.xmax - ar->winrct.xmin + 1;
- getsizey = ar->winrct.ymax - ar->winrct.ymin + 1;
+ getsizex = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ getsizey = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
sx = ar->winrct.xmin;
sy = ar->winrct.ymin;
@@ -272,7 +272,7 @@ void ui_bounds_block(uiBlock *block)
block->rect.ymax += block->bounds;
}
- block->rect.xmax = block->rect.xmin + maxf(block->rect.xmax - block->rect.xmin, block->minbounds);
+ block->rect.xmax = block->rect.xmin + maxf(BLI_RCT_SIZE_X(&block->rect), block->minbounds);
/* hardcoded exception... but that one is annoying with larger safety */
bt = block->buttons.first;
@@ -325,8 +325,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_
wm_window_get_size(window, &xmax, &ymax);
- oldwidth = block->rect.xmax - block->rect.xmin;
- oldheight = block->rect.ymax - block->rect.ymin;
+ oldwidth = BLI_RCT_SIZE_X(&block->rect);
+ oldheight = BLI_RCT_SIZE_Y(&block->rect);
/* first we ensure wide enough text bounds */
if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) {
@@ -341,8 +341,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_
ui_bounds_block(block);
/* and we adjust the position to fit within window */
- width = block->rect.xmax - block->rect.xmin;
- height = block->rect.ymax - block->rect.ymin;
+ width = BLI_RCT_SIZE_X(&block->rect);
+ height = BLI_RCT_SIZE_Y(&block->rect);
/* avoid divide by zero below, caused by calling with no UI, but better not crash */
oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width);
@@ -2204,7 +2204,7 @@ void ui_check_but(uiBut *but)
/* safety is 4 to enable small number buttons (like 'users') */
- // okwidth= -4 + (but->rect.xmax - but->rect.xmin); // UNUSED
+ // okwidth= -4 + (BLI_RCT_SIZE_X(&but->rect)); // UNUSED
/* name: */
switch (but->type) {
@@ -2212,7 +2212,7 @@ void ui_check_but(uiBut *but)
case MENU:
case ICONTEXTROW:
- if (but->rect.xmax - but->rect.xmin > 24) {
+ if (BLI_RCT_SIZE_X(&but->rect) > 24.0f) {
UI_GET_BUT_VALUE_INIT(but, value);
ui_set_name_menu(but, (int)value);
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 109978780c2..e66c0409192 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 = abs(rect->xmax - rect->xmin);
- height = abs(rect->ymax - rect->ymin);
+ width = absBLI_RCT_SIZE_X(rect);
+ height = absBLI_RCT_SIZE_Y(rect);
butw = floor(width / 12);
buth = floor(height / 6);
@@ -642,8 +642,8 @@ static void draw_scope_end(rctf *rect, GLint *scissor)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* scale widget */
- scaler_x1 = rect->xmin + (rect->xmax - rect->xmin) / 2 - SCOPE_RESIZE_PAD;
- scaler_x2 = rect->xmin + (rect->xmax - rect->xmin) / 2 + SCOPE_RESIZE_PAD;
+ scaler_x1 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 - SCOPE_RESIZE_PAD;
+ scaler_x2 = rect->xmin + BLI_RCT_SIZE_X(rect) / 2 + SCOPE_RESIZE_PAD;
glColor4f(0.f, 0.f, 0.f, 0.25f);
fdrawline(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4);
@@ -805,9 +805,9 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
if (scopes->wavefrm_yfac < 0.5f)
scopes->wavefrm_yfac = 0.98f;
- w = rect.xmax - rect.xmin - 7;
- h = (rect.ymax - rect.ymin) * scopes->wavefrm_yfac;
- yofs = rect.ymin + (rect.ymax - rect.ymin - h) / 2.0f;
+ w = BLI_RCT_SIZE_X(&rect) - 7;
+ h = BLI_RCT_SIZE_Y(&rect) * scopes->wavefrm_yfac;
+ yofs = rect.ymin + (BLI_RCT_SIZE_Y(&rect) - h) / 2.0f;
w3 = w / 3.0f;
/* log scale for alpha */
@@ -1033,8 +1033,8 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
rect.ymax = (float)recti->ymax - 1;
- w = rect.xmax - rect.xmin;
- h = rect.ymax - rect.ymin;
+ w = BLI_RCT_SIZE_X(&rect);
+ h = BLI_RCT_SIZE_Y(&rect);
centerx = rect.xmin + w / 2;
centery = rect.ymin + h / 2;
diam = (w < h) ? w : h;
@@ -1262,12 +1262,12 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* transform to button */
glPushMatrix();
- glTranslatef(rect->xmin + 0.5f * (rect->xmax - rect->xmin), rect->ymin + 0.5f * (rect->ymax - rect->ymin), 0.0f);
+ glTranslatef(rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect), rect->ymin + 0.5f * BLI_RCT_SIZE_Y(rect), 0.0f);
- if (rect->xmax - rect->xmin < rect->ymax - rect->ymin)
- size = (rect->xmax - rect->xmin) / 200.f;
+ if (BLI_RCT_SIZE_X(rect) < BLI_RCT_SIZE_Y(rect))
+ size = BLI_RCT_SIZE_X(rect) / 200.f;
else
- size = (rect->ymax - rect->ymin) / 200.f;
+ size = BLI_RCT_SIZE_Y(rect) / 200.f;
glScalef(size, size, size);
@@ -1368,8 +1368,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax - scissor_new.xmin, scissor_new.ymax - scissor_new.ymin);
/* calculate offset and zoom */
- zoomx = (rect->xmax - rect->xmin - 2.0f * but->aspect) / (cumap->curr.xmax - cumap->curr.xmin);
- zoomy = (rect->ymax - rect->ymin - 2.0f * but->aspect) / (cumap->curr.ymax - cumap->curr.ymin);
+ 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);
offsx = cumap->curr.xmin - but->aspect / zoomx;
offsy = cumap->curr.ymin - but->aspect / zoomy;
@@ -1545,8 +1545,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
rect.ymax = (float)recti->ymax - 1;
- width = rect.xmax - rect.xmin + 1;
- height = rect.ymax - rect.ymin;
+ width = BLI_RCT_SIZE_X(&rect) + 1;
+ height = BLI_RCT_SIZE_Y(&rect);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1621,8 +1621,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
glTranslatef(rect.xmin + track_pos[0], rect.ymin + track_pos[1], 0.f);
glScissor(ar->winrct.xmin + rect.xmin,
ar->winrct.ymin + rect.ymin,
- rect.xmax - rect.xmin,
- rect.ymax - rect.ymin);
+ BLI_RCT_SIZE_X(&rect),
+ BLI_RCT_SIZE_Y(&rect));
for (a = 0; a < 2; a++) {
if (a == 1) {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 50b6de5ce46..d78a677ea58 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -690,7 +690,7 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event)
if (but->imb) ; /* use button size itself */
else if (but->flag & UI_ICON_LEFT) {
- rect.xmax = rect.xmin + (rect.ymax - rect.ymin);
+ rect.xmax = rect.xmin + (BLI_RCT_SIZE_Y(&rect));
}
else {
int delta = BLI_RCT_SIZE_X(&rect) - BLI_RCT_SIZE_Y(&rect);
@@ -714,7 +714,7 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data,
drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but));
if (but->imb)
- WM_event_drag_image(drag, but->imb, but->imb_scale, but->rect.xmax - but->rect.xmin, but->rect.ymax - but->rect.ymin);
+ WM_event_drag_image(drag, but->imb, but->imb_scale, BLI_RCT_SIZE_X(&but->rect), BLI_RCT_SIZE_Y(&but->rect));
return 1;
}
@@ -1295,7 +1295,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
/* XXX solve generic */
if (but->type == NUM || but->type == NUMSLI)
- startx += (int)(0.5f * (but->rect.ymax - but->rect.ymin));
+ startx += (int)(0.5f * (BLI_RCT_SIZE_Y(&but->rect)));
else if (ELEM(but->type, TEX, SEARCH_MENU)) {
startx += 5;
if (but->flag & UI_HAS_ICON)
@@ -2610,7 +2610,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
softmax = but->softmax;
if (!ui_is_but_float(but)) {
- if (mx < (but->rect.xmin + (but->rect.xmax - but->rect.xmin) / 3 - 3)) {
+ if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value - 1;
@@ -2621,7 +2621,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (mx > (but->rect.xmin + (2 * (but->rect.xmax - but->rect.xmin) / 3) + 3)) {
+ else if (mx > (but->rect.xmin + (2 * BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
temp = (int)data->value + 1;
@@ -2636,7 +2636,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
}
else {
- if (mx < (but->rect.xmin + (but->rect.xmax - but->rect.xmin) / 3 - 3)) {
+ if (mx < (but->rect.xmin + BLI_RCT_SIZE_X(&but->rect) / 3 - 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value - 0.01f * but->a1;
@@ -2645,7 +2645,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (mx > but->rect.xmin + (2 * ((but->rect.xmax - but->rect.xmin) / 3) + 3)) {
+ else if (mx > but->rect.xmin + (2 * (BLI_RCT_SIZE_X(&but->rect) / 3) + 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
tempf = (float)data->value + 0.01f * but->a1;
@@ -2673,14 +2673,14 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, const short
softmax = but->softmax;
softrange = softmax - softmin;
- if (but->type == NUMSLI) deler = ((but->rect.xmax - but->rect.xmin) - 5.0f * but->aspect);
- else if (but->type == HSVSLI) deler = ((but->rect.xmax - but->rect.xmin) / 2.0f - 5.0f * but->aspect);
+ if (but->type == NUMSLI) deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect);
+ else if (but->type == HSVSLI) deler = (BLI_RCT_SIZE_X(&but->rect) / 2.0f - 5.0f * but->aspect);
else if (but->type == SCROLL) {
- int horizontal = (but->rect.xmax - but->rect.xmin > but->rect.ymax - but->rect.ymin);
- float size = (horizontal) ? (but->rect.xmax - but->rect.xmin) : -(but->rect.ymax - but->rect.ymin);
+ int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect));
+ float size = (horizontal) ? BLI_RCT_SIZE_X(&but->rect) : -BLI_RCT_SIZE_Y(&but->rect);
deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1);
}
- else deler = (but->rect.xmax - but->rect.xmin - 5.0f * but->aspect);
+ else deler = (BLI_RCT_SIZE_X(&but->rect) - 5.0f * but->aspect);
f = (float)(mx - data->dragstartx) / deler + data->dragfstart;
@@ -2830,12 +2830,12 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
#if 0
if (but->type == SLI) {
- f = (float)(mx - but->rect.xmin) / (but->rect.xmax - but->rect.xmin); /* same as below */
+ f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect)); /* same as below */
}
else
#endif
{
- f = (float)(mx - but->rect.xmin) / (but->rect.xmax - but->rect.xmin);
+ f = (float)(mx - but->rect.xmin) / (BLI_RCT_SIZE_X(&but->rect));
}
f = softmin + f * softrange;
@@ -2876,7 +2876,7 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
{
int mx, my /*, click= 0 */;
int retval = WM_UI_HANDLER_CONTINUE;
- int horizontal = (but->rect.xmax - but->rect.xmin > but->rect.ymax - but->rect.ymin);
+ int horizontal = (BLI_RCT_SIZE_X(&but->rect) > BLI_RCT_SIZE_Y(&but->rect));
mx = event->x;
my = event->y;
@@ -3033,7 +3033,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i
* else we'll get a harmless but annoying jump when first clicking */
fp = data->origvec;
- rad = (but->rect.xmax - but->rect.xmin);
+ rad = BLI_RCT_SIZE_X(&but->rect);
radsq = rad * rad;
if (fp[2] > 0.0f) {
@@ -3141,8 +3141,8 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
/* relative position within box */
- x = ((float)mx_fl - but->rect.xmin) / (but->rect.xmax - but->rect.xmin);
- y = ((float)my_fl - but->rect.ymin) / (but->rect.ymax - but->rect.ymin);
+ x = ((float)mx_fl - but->rect.xmin) / BLI_RCT_SIZE_X(&but->rect);
+ y = ((float)my_fl - but->rect.ymin) / BLI_RCT_SIZE_Y(&but->rect);
CLAMP(x, 0.0f, 1.0f);
CLAMP(y, 0.0f, 1.0f);
@@ -3539,7 +3539,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx
if (data->draglastx == mx)
return changed;
- dx = ((float)(mx - data->draglastx)) / (but->rect.xmax - but->rect.xmin);
+ dx = ((float)(mx - data->draglastx)) / BLI_RCT_SIZE_X(&but->rect);
data->dragcbd->pos += dx;
CLAMP(data->dragcbd->pos, 0.0f, 1.0f);
@@ -3568,7 +3568,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
if (event->ctrl) {
/* insert new key on mouse location */
- float pos = ((float)(mx - but->rect.xmin)) / (but->rect.xmax - but->rect.xmin);
+ float pos = ((float)(mx - but->rect.xmin)) / BLI_RCT_SIZE_X(&but->rect);
colorband_element_add(coba, pos);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -3580,7 +3580,7 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* activate new key when mouse is close */
for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) {
- xco = but->rect.xmin + (cbd->pos * (but->rect.xmax - but->rect.xmin));
+ xco = but->rect.xmin + (cbd->pos * BLI_RCT_SIZE_X(&but->rect));
xco = ABS(xco - mx);
if (a == coba->cur) xco += 5; // selected one disadvantage
if (xco < mindist) {
@@ -3621,8 +3621,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */;
int a, changed = 0;
- zoomx = (but->rect.xmax - but->rect.xmin) / (cumap->curr.xmax - cumap->curr.xmin);
- zoomy = (but->rect.ymax - but->rect.ymin) / (cumap->curr.ymax - cumap->curr.ymin);
+ zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr);
+ zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr);
/* offsx= cumap->curr.xmin; */
/* offsy= cumap->curr.ymin; */
@@ -3717,8 +3717,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
float dist, mindist = 200.0f; // 14 pixels radius
int sel = -1;
- zoomx = (but->rect.xmax - but->rect.xmin) / (cumap->curr.xmax - cumap->curr.xmin);
- zoomy = (but->rect.ymax - but->rect.ymin) / (cumap->curr.ymax - cumap->curr.ymin);
+ zoomx = BLI_RCT_SIZE_X(&but->rect) / BLI_RCT_SIZE_X(&cumap->curr);
+ zoomy = BLI_RCT_SIZE_Y(&but->rect) / BLI_RCT_SIZE_Y(&cumap->curr);
offsx = cumap->curr.xmin;
offsy = cumap->curr.ymin;
@@ -3862,7 +3862,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize histogram widget itself */
- hist->height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my);
+ hist->height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
}
else {
/* scale histogram values (dy / 10 for better control) */
@@ -3946,7 +3946,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx,
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize waveform widget itself */
- scopes->wavefrm_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my);
+ scopes->wavefrm_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
}
else {
/* scale waveform values */
@@ -4028,7 +4028,7 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize vectorscope widget itself */
- scopes->vecscope_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my);
+ scopes->vecscope_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
}
data->draglastx = mx;
@@ -4098,8 +4098,8 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
/* Calculate the size of the button */
- width = abs(but->rect.xmax - but->rect.xmin);
- height = abs(but->rect.ymax - but->rect.ymin);
+ width = abs(BLI_RCT_SIZE_X(&but->rect));
+ height = abs(BLI_RCT_SIZE_Y(&but->rect));
butw = floor(width / 12);
buth = floor(height / 6);
@@ -4231,7 +4231,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
/* resize preview widget itself */
- scopes->track_preview_height = (but->rect.ymax - but->rect.ymin) + (data->dragstarty - my);
+ scopes->track_preview_height = BLI_RCT_SIZE_Y(&but->rect) + (data->dragstarty - my);
}
else {
if (!scopes->track_locked) {
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 3bbf5b17312..512cda13df1 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -360,11 +360,11 @@ void UI_DrawTriIcon(float x, float y, char dir)
static void ui_draw_tria_rect(rctf *rect, char dir)
{
if (dir == 'h') {
- float half = 0.5f * (rect->ymax - rect->ymin);
+ float half = 0.5f * BLI_RCT_SIZE_Y(rect);
ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half);
}
else {
- float half = 0.5f * (rect->xmax - rect->xmin);
+ float half = 0.5f * BLI_RCT_SIZE_X(rect);
ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin);
}
}
@@ -483,8 +483,8 @@ static void rectf_scale(rctf *rect, float scale)
{
float centx = 0.5f * (rect->xmin + rect->xmax);
float centy = 0.5f * (rect->ymin + rect->ymax);
- float sizex = 0.5f * scale * (rect->xmax - rect->xmin);
- float sizey = 0.5f * scale * (rect->ymax - rect->ymin);
+ float sizex = 0.5f * scale * BLI_RCT_SIZE_X(rect);
+ float sizey = 0.5f * scale * BLI_RCT_SIZE_Y(rect);
rect->xmin = centx - sizex;
rect->xmax = centx + sizex;
@@ -985,8 +985,8 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
dx = (event->x - data->startx) & ~(PNL_GRID - 1);
dy = (event->y - data->starty) & ~(PNL_GRID - 1);
- dx *= (float)(ar->v2d.cur.xmax - ar->v2d.cur.xmin) / (float)(ar->winrct.xmax - ar->winrct.xmin);
- dy *= (float)(ar->v2d.cur.ymax - ar->v2d.cur.ymin) / (float)(ar->winrct.ymax - ar->winrct.ymin);
+ dx *= (float)BLI_RCT_SIZE_X(&ar->v2d.cur) / (float)BLI_RCT_SIZE_X(&ar->winrct);
+ dy *= (float)BLI_RCT_SIZE_Y(&ar->v2d.cur) / (float)BLI_RCT_SIZE_Y(&ar->winrct);
if (data->state == PANEL_STATE_DRAG_SCALE) {
panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index c44a45c2150..35488430b22 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1095,13 +1095,13 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
if (data->items.more) {
ui_searchbox_butrect(&rect, data, data->items.maxitem - 1);
glEnable(GL_BLEND);
- UI_icon_draw((rect.xmax - rect.xmin) / 2, rect.ymin - 9, ICON_TRIA_DOWN);
+ UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymin - 9, ICON_TRIA_DOWN);
glDisable(GL_BLEND);
}
if (data->items.offset) {
ui_searchbox_butrect(&rect, data, 0);
glEnable(GL_BLEND);
- UI_icon_draw((rect.xmax - rect.xmin) / 2, rect.ymax - 7, ICON_TRIA_UP);
+ UI_icon_draw((BLI_RCT_SIZE_X(&rect)) / 2, rect.ymax - 7, ICON_TRIA_UP);
glDisable(GL_BLEND);
}
}
@@ -1176,16 +1176,16 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = (ar->winrct.xmax - ar->winrct.xmin) - MENU_SHADOW_SIDE;
+ data->bbox.xmax = BLI_RCT_SIZE_X(&ar->winrct) - MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = (ar->winrct.ymax - ar->winrct.ymin) - MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = BLI_RCT_SIZE_Y(&ar->winrct) - MENU_SHADOW_BOTTOM;
/* check if button is lower half */
if (but->rect.ymax < BLI_RCT_CENTER_Y(&but->block->rect)) {
- data->bbox.ymin += (but->rect.ymax - but->rect.ymin);
+ data->bbox.ymin += BLI_RCT_SIZE_Y(&but->rect);
}
else {
- data->bbox.ymax -= (but->rect.ymax - but->rect.ymin);
+ data->bbox.ymax -= BLI_RCT_SIZE_Y(&but->rect);
}
}
else {
@@ -1356,15 +1356,15 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
}
}
- /* aspect = (float)(block->rect.xmax - block->rect.xmin + 4);*/ /*UNUSED*/
+ /* aspect = (float)(BLI_RCT_SIZE_X(&block->rect) + 4);*/ /*UNUSED*/
ui_block_to_window_fl(butregion, but->block, &block->rect.xmin, &block->rect.ymin);
ui_block_to_window_fl(butregion, but->block, &block->rect.xmax, &block->rect.ymax);
//block->rect.xmin -= 2.0; block->rect.ymin -= 2.0;
//block->rect.xmax += 2.0; block->rect.ymax += 2.0;
- xsize = block->rect.xmax - block->rect.xmin + 4; /* 4 for shadow */
- ysize = block->rect.ymax - block->rect.ymin + 4;
+ xsize = BLI_RCT_SIZE_X(&block->rect) + 4; /* 4 for shadow */
+ ysize = BLI_RCT_SIZE_Y(&block->rect) + 4;
/* aspect /= (float)xsize;*/ /*UNUSED*/
{
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 779341160c5..ee0613ea0d0 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -152,17 +152,17 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
uiStyleFontSet(fs);
height = BLF_ascender(fs->uifont_id);
- yofs = ceil(0.5f * (rect->ymax - rect->ymin - height));
+ yofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height));
if (fs->align == UI_STYLE_TEXT_CENTER) {
- xofs = floor(0.5f * (rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str)));
+ xofs = floor(0.5f * (BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str)));
/* don't center text if it chops off the start of the text, 2 gives some margin */
if (xofs < 2) {
xofs = 2;
}
}
else if (fs->align == UI_STYLE_TEXT_RIGHT) {
- xofs = rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1;
+ xofs = BLI_RCT_SIZE_X(rect) - BLF_width(fs->uifont_id, str) - 1;
}
/* clip is very strict, so we give it some space */
@@ -209,7 +209,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
height = BLF_ascender(fs->uifont_id);
/* becomes x-offset when rotated */
- xofs = ceil(0.5f * (rect->ymax - rect->ymin - height));
+ xofs = ceil(0.5f * (BLI_RCT_SIZE_Y(rect) - height));
/* ignore UI_STYLE, always aligned to top */
@@ -219,8 +219,8 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
angle = 90.0f;
/* translate rect to vertical */
- txtrect.xmin = rect->xmin - (rect->ymax - rect->ymin);
- txtrect.ymin = rect->ymin - (rect->xmax - rect->xmin);
+ txtrect.xmin = rect->xmin - BLI_RCT_SIZE_Y(rect);
+ txtrect.ymin = rect->ymin - BLI_RCT_SIZE_X(rect);
txtrect.xmax = rect->xmin;
txtrect.ymax = rect->ymin;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 7c4f181b9de..24dccb2eecf 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -40,6 +40,7 @@
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BLI_ghash.h"
+#include "BLI_rect.h"
#include "BLF_translation.h"
@@ -1378,7 +1379,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb)
{
uiBut *bt;
- float unit = (butr->xmax - butr->xmin) / 14.0f;
+ float unit = BLI_RCT_SIZE_X(butr) / 14.0f;
float xs = butr->xmin;
uiBlockBeginAlign(block);
@@ -1404,7 +1405,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand
TIP_("Set interpolation between color stops"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, butr->xmax - butr->xmin, UI_UNIT_Y, coba, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_RCT_SIZE_X(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
uiBlockEndAlign(block);
@@ -1479,7 +1480,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height;
- bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, hist->height, hist, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), hist->height, hist, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
@@ -1516,7 +1517,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height;
- bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
(void)bt; /* UNUSED */
MEM_freeN(cb);
@@ -1553,7 +1554,7 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height;
- bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect), scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
@@ -1568,11 +1569,11 @@ static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(ar
float d;
/* we allow 20 times zoom */
- if ( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f * (cumap->clipr.xmax - cumap->clipr.xmin) ) {
- d = 0.1154f * (cumap->curr.xmax - cumap->curr.xmin);
+ if (BLI_RCT_SIZE_X(&cumap->curr) > 0.04f * BLI_RCT_SIZE_X(&cumap->clipr)) {
+ d = 0.1154f * BLI_RCT_SIZE_X(&cumap->curr);
cumap->curr.xmin += d;
cumap->curr.xmax -= d;
- d = 0.1154f * (cumap->curr.ymax - cumap->curr.ymin);
+ d = 0.1154f * BLI_RCT_SIZE_Y(&cumap->curr);
cumap->curr.ymin += d;
cumap->curr.ymax -= d;
}
@@ -1586,8 +1587,8 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
float d, d1;
/* we allow 20 times zoom, but don't view outside clip */
- if ( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f * (cumap->clipr.xmax - cumap->clipr.xmin) ) {
- d = d1 = 0.15f * (cumap->curr.xmax - cumap->curr.xmin);
+ if (BLI_RCT_SIZE_X(&cumap->curr) < 20.0f * BLI_RCT_SIZE_X(&cumap->clipr)) {
+ d = d1 = 0.15f * BLI_RCT_SIZE_X(&cumap->curr);
if (cumap->flag & CUMA_DO_CLIP)
if (cumap->curr.xmin - d < cumap->clipr.xmin)
@@ -1600,7 +1601,7 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
d1 = -cumap->curr.xmax + cumap->clipr.xmax;
cumap->curr.xmax += d1;
- d = d1 = 0.15f * (cumap->curr.ymax - cumap->curr.ymin);
+ d = d1 = 0.15f * BLI_RCT_SIZE_Y(&cumap->curr);
if (cumap->flag & CUMA_DO_CLIP)
if (cumap->curr.ymin - d < cumap->clipr.ymin)
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 3c944781d80..bf5b3fbe8c7 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -260,8 +260,8 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r
rad += step;
- if (2.0f * rad > rect->ymax - rect->ymin)
- rad = 0.5f * (rect->ymax - rect->ymin);
+ if (2.0f * rad > BLI_RCT_SIZE_Y(rect))
+ rad = 0.5f * BLI_RCT_SIZE_Y(rect);
minx = rect->xmin - step;
miny = rect->ymin - step;
@@ -346,8 +346,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((rect->xmax - rect->xmin) * hnum,
- (rect->ymax - rect->ymin) * vnum);
+ minsize = mini(BLI_RCT_SIZE_X(rect) * hnum,
+ BLI_RCT_SIZE_Y(rect) * vnum);
if (2.0f * rad > minsize)
rad = 0.5f * minsize;
@@ -492,7 +492,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 = MIN2(rect->xmax - rect->xmin, rect->ymax - rect->ymin);
+ minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
/* center position and size */
centx = (float)rect->xmin + 0.5f * minsize;
@@ -527,7 +527,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 = MIN2(rect->xmax - rect->xmin, rect->ymax - rect->ymin);
+ minsize = mini(BLI_RCT_SIZE_X(rect), BLI_RCT_SIZE_Y(rect));
/* center position and size */
centx = (float)rect->xmin + 0.5f * minsize;
@@ -571,14 +571,14 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect)
int a;
/* center position and size */
- centx = rect->xmax - 0.5f * (rect->ymax - rect->ymin);
- centy = rect->ymin + 0.5f * (rect->ymax - rect->ymin);
- size = 0.4f * (rect->ymax - rect->ymin);
+ 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);
/* XXX exception */
- asp = ((float)rect->xmax - rect->xmin) / ((float)rect->ymax - rect->ymin);
+ asp = ((float)BLI_RCT_SIZE_X(rect)) / ((float)BLI_RCT_SIZE_Y(rect));
if (asp > 1.2f && asp < 2.6f)
- centx = rect->xmax - 0.3f * (rect->ymax - rect->ymin);
+ centx = rect->xmax - 0.3f * BLI_RCT_SIZE_Y(rect);
for (a = 0; a < 6; a++) {
tria->vec[a][0] = size * menu_tria_vert[a][0] + centx;
@@ -595,9 +595,9 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect)
int a;
/* center position and size */
- centx = rect->xmin + 0.5f * (rect->ymax - rect->ymin);
- centy = rect->ymin + 0.5f * (rect->ymax - rect->ymin);
- size = 0.5f * (rect->ymax - rect->ymin);
+ 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);
for (a = 0; a < 6; a++) {
tria->vec[a][0] = size * check_tria_vert[a][0] + centx;
@@ -841,8 +841,8 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect)
if (icon == ICON_NONE)
return;
- w = rect->xmax - rect->xmin;
- h = rect->ymax - rect->ymin;
+ w = BLI_RCT_SIZE_X(rect);
+ h = BLI_RCT_SIZE_Y(rect);
size = MIN2(w, h);
size -= PREVIEW_PAD * 2; /* padding */
@@ -970,7 +970,7 @@ static void ui_text_clip_give_next_off(uiBut *but)
static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
{
int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
- int okwidth = rect->xmax - rect->xmin - border;
+ int okwidth = BLI_RCT_SIZE_X(rect) - border;
if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
@@ -1033,7 +1033,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
{
int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
- int okwidth = rect->xmax - rect->xmin - border;
+ int okwidth = BLI_RCT_SIZE_X(rect) - border;
char *cpoin = NULL;
char *cpend = but->drawstr + strlen(but->drawstr);
@@ -1265,7 +1265,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
}
else if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) {
int tmp = rect->xmin;
- rect->xmin = rect->xmax - (rect->ymax - rect->ymin) - 1;
+ rect->xmin = rect->xmax - BLI_RCT_SIZE_Y(rect) - 1;
widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect);
rect->xmin = tmp;
}
@@ -1847,10 +1847,10 @@ void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float
float centy = BLI_RCT_CENTER_Y_FL(rect);
float radius, dist;
- if (rect->xmax - rect->xmin > rect->ymax - rect->ymin)
- radius = (float)(rect->ymax - rect->ymin) / 2;
+ if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect))
+ radius = (float)BLI_RCT_SIZE_Y(rect) / 2;
else
- radius = (float)(rect->xmax - rect->xmin) / 2;
+ radius = (float)BLI_RCT_SIZE_X(rect) / 2;
mx -= centx;
my -= centy;
@@ -1879,10 +1879,10 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
centx = BLI_RCT_CENTER_X_FL(rect);
centy = BLI_RCT_CENTER_Y_FL(rect);
- if (rect->xmax - rect->xmin > rect->ymax - rect->ymin)
- radius = (float)(rect->ymax - rect->ymin) / 2;
+ if (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect))
+ radius = (float)BLI_RCT_SIZE_Y(rect) / 2;
else
- radius = (float)(rect->xmax - rect->xmin) / 2;
+ radius = (float)BLI_RCT_SIZE_X(rect) / 2;
/* color */
ui_get_but_vectorf(but, rgb);
@@ -2058,10 +2058,10 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], const int type, const floa
}
/* rect */
- sx1 = rect->xmin + dx * (rect->xmax - rect->xmin);
- sx2 = rect->xmin + (dx + color_step) * (rect->xmax - rect->xmin);
+ sx1 = rect->xmin + dx * BLI_RCT_SIZE_X(rect);
+ sx2 = rect->xmin + (dx + color_step) * BLI_RCT_SIZE_X(rect);
sy = rect->ymin;
- dy = (rect->ymax - rect->ymin) / 3.0;
+ dy = BLI_RCT_SIZE_Y(rect) / 3.0;
glBegin(GL_QUADS);
for (a = 0; a < 3; a++, sy += dy) {
@@ -2116,8 +2116,8 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
}
/* cursor */
- x = rect->xmin + x * (rect->xmax - rect->xmin);
- y = rect->ymin + y * (rect->ymax - rect->ymin);
+ x = rect->xmin + x * BLI_RCT_SIZE_X(rect);
+ y = rect->ymin + y * BLI_RCT_SIZE_Y(rect);
CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
@@ -2132,7 +2132,7 @@ 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 * (rect->xmax - rect->xmin);
+ float rad = 0.5f * BLI_RCT_SIZE_X(rect);
float x, y;
float rgb[3], hsv[3], v, range;
int color_profile = but->block->color_profile;
@@ -2166,8 +2166,8 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
widgetbase_draw(&wtb, &wcol_tmp);
/* cursor */
- x = rect->xmin + 0.5f * (rect->xmax - rect->xmin);
- y = rect->ymin + v * (rect->ymax - rect->ymin);
+ x = rect->xmin + 0.5f * BLI_RCT_SIZE_X(rect);
+ y = rect->ymin + v * BLI_RCT_SIZE_Y(rect);
CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
ui_hsv_cursor(x, y);
@@ -2178,7 +2178,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 + (rect->ymax - rect->ymin) / 2 - 1;
+ int y = rect->ymin + BLI_RCT_SIZE_Y(rect) / 2 - 1;
unsigned char col[4];
col[0] = wcol->text[0];
@@ -2197,7 +2197,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 * (rect->ymax - rect->ymin);
+ float rad = 0.5f * BLI_RCT_SIZE_Y(rect);
float textofs = rad * 0.75f;
if (state & UI_SELECT)
@@ -2278,12 +2278,12 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
widget_init(&wtb);
/* determine horizontal/vertical */
- horizontal = (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
+ horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect));
if (horizontal)
- rad = 0.5f * (rect->ymax - rect->ymin);
+ rad = 0.5f * BLI_RCT_SIZE_Y(rect);
else
- rad = 0.5f * (rect->xmax - rect->xmin);
+ rad = 0.5f * BLI_RCT_SIZE_X(rect);
wtb.shadedir = (horizontal) ? 1 : 0;
@@ -2295,9 +2295,10 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
widgetbase_draw(&wtb, wcol);
/* slider */
- if (slider->xmax - slider->xmin < 2 || slider->ymax - slider->ymin < 2) ;
+ if ((BLI_RCT_SIZE_X(slider) < 2) || (BLI_RCT_SIZE_Y(slider) < 2)) {
+ /* pass */
+ }
else {
-
SWAP(short, wcol->shadetop, wcol->shadedown);
copy_v4_v4_char(wcol->inner, wcol->item);
@@ -2360,15 +2361,15 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
rect1 = *rect;
/* determine horizontal/vertical */
- horizontal = (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
+ horizontal = (BLI_RCT_SIZE_X(rect) > BLI_RCT_SIZE_Y(rect));
if (horizontal) {
- fac = (rect->xmax - rect->xmin) / (size);
+ fac = BLI_RCT_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 = rect->ymax - rect->ymin;
+ min = BLI_RCT_SIZE_Y(rect);
if (rect1.xmax - rect1.xmin < min) {
rect1.xmax = rect1.xmin + min;
@@ -2380,12 +2381,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
}
}
else {
- fac = (rect->ymax - rect->ymin) / (size);
+ fac = BLI_RCT_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 = rect->xmax - rect->xmin;
+ min = BLI_RCT_SIZE_X(rect);
if (rect1.ymax - rect1.ymin < min) {
rect1.ymax = rect1.ymin + min;
@@ -2461,7 +2462,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
/* backdrop first */
/* fully rounded */
- offs = 0.5f * (rect->ymax - rect->ymin);
+ offs = 0.5f * BLI_RCT_SIZE_Y(rect);
toffs = offs * 0.75f;
round_box_edges(&wtb, roundboxalign, rect, offs);
@@ -2615,7 +2616,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
widgetbase_draw(&wtb, wcol);
/* text space */
- rect->xmax -= (rect->ymax - rect->ymin);
+ rect->xmax -= BLI_RCT_SIZE_Y(rect);
}
static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
@@ -2658,7 +2659,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
{
if (state & UI_ACTIVE) {
uiWidgetBase wtb;
- float rad = 0.5f * (rect->ymax - rect->ymin); /* 4.0f */
+ float rad = 0.5f * BLI_RCT_SIZE_Y(rect); /* 4.0f */
widget_init(&wtb);
@@ -2724,7 +2725,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
widgetbase_draw(&wtb, wcol);
/* text space */
- rect->xmin += (rect->ymax - rect->ymin) * 0.7 + delta;
+ rect->xmin += BLI_RCT_SIZE_Y(rect) * 0.7 + delta;
}
@@ -2786,7 +2787,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 * (rect->ymax - rect->ymin); */
+ float rad = 5.0f; /* 0.5f * BLI_RCT_SIZE_Y(rect); */
widget_init(&wtb);
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index d498f57e8e3..86322b0c0ea 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -96,11 +96,11 @@ static void view2d_masks(View2D *v2d)
/* check size if: */
if (v2d->scroll & V2D_SCROLL_HORIZONTAL)
if (!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL))
- if (v2d->tot.xmax - v2d->tot.xmin <= v2d->cur.xmax - v2d->cur.xmin)
+ if (BLI_RCT_SIZE_X(&v2d->tot) <= BLI_RCT_SIZE_X(&v2d->cur))
v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
if (v2d->scroll & V2D_SCROLL_VERTICAL)
if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL))
- if (v2d->tot.ymax - v2d->tot.ymin <= v2d->cur.ymax - v2d->cur.ymin)
+ if (BLI_RCT_SIZE_Y(&v2d->tot) <= BLI_RCT_SIZE_Y(&v2d->cur))
v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE;
#endif
scroll = view2d_scroll_mapped(v2d->scroll);
@@ -328,8 +328,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
rctf *cur, *tot;
/* use mask as size of region that View2D resides in, as it takes into account scrollbars already */
- winx = (float)(v2d->mask.xmax - v2d->mask.xmin + 1);
- winy = (float)(v2d->mask.ymax - v2d->mask.ymin + 1);
+ winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1);
+ winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1);
/* get pointers to rcts for less typing */
cur = &v2d->cur;
@@ -347,10 +347,10 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
* - firstly, we calculate the sizes of the rects
* - curwidth and curheight are saved as reference... modify width and height values here
*/
- totwidth = tot->xmax - tot->xmin;
- totheight = tot->ymax - tot->ymin;
- curwidth = width = cur->xmax - cur->xmin;
- curheight = height = cur->ymax - cur->ymin;
+ totwidth = BLI_RCT_SIZE_X(tot);
+ totheight = BLI_RCT_SIZE_Y(tot);
+ curwidth = width = BLI_RCT_SIZE_X(cur);
+ curheight = height = BLI_RCT_SIZE_Y(cur);
/* if zoom is locked, size on the appropriate axis is reset to mask size */
if (v2d->keepzoom & V2D_LOCKZOOM_X)
@@ -499,13 +499,13 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
/* resize from centerpoint, unless otherwise specified */
if (width != curwidth) {
if (v2d->keepofs & V2D_LOCKOFS_X) {
- cur->xmax += width - (cur->xmax - cur->xmin);
+ cur->xmax += width - BLI_RCT_SIZE_X(cur);
}
else if (v2d->keepofs & V2D_KEEPOFS_X) {
if (v2d->align & V2D_ALIGN_NO_POS_X)
- cur->xmin -= width - (cur->xmax - cur->xmin);
+ cur->xmin -= width - BLI_RCT_SIZE_X(cur);
else
- cur->xmax += width - (cur->xmax - cur->xmin);
+ cur->xmax += width - BLI_RCT_SIZE_X(cur);
}
else {
temp = BLI_RCT_CENTER_X(cur);
@@ -517,13 +517,13 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
}
if (height != curheight) {
if (v2d->keepofs & V2D_LOCKOFS_Y) {
- cur->ymax += height - (cur->ymax - cur->ymin);
+ cur->ymax += height - BLI_RCT_SIZE_Y(cur);
}
else if (v2d->keepofs & V2D_KEEPOFS_Y) {
if (v2d->align & V2D_ALIGN_NO_POS_Y)
- cur->ymin -= height - (cur->ymax - cur->ymin);
+ cur->ymin -= height - BLI_RCT_SIZE_Y(cur);
else
- cur->ymax += height - (cur->ymax - cur->ymin);
+ cur->ymax += height - BLI_RCT_SIZE_Y(cur);
}
else {
temp = BLI_RCT_CENTER_Y(cur);
@@ -540,8 +540,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
float temp, diff;
/* recalculate extents of cur */
- curwidth = cur->xmax - cur->xmin;
- curheight = cur->ymax - cur->ymin;
+ curwidth = BLI_RCT_SIZE_X(cur);
+ curheight = BLI_RCT_SIZE_Y(cur);
/* width */
if ( (curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM)) ) {
@@ -791,8 +791,8 @@ void UI_view2d_curRect_reset(View2D *v2d)
float width, height;
/* assume width and height of 'cur' rect by default, should be same size as mask */
- width = (float)(v2d->mask.xmax - v2d->mask.xmin + 1);
- height = (float)(v2d->mask.ymax - v2d->mask.ymin + 1);
+ width = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1);
+ height = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1);
/* handle width - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
@@ -958,8 +958,8 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
*curmasked = v2d->cur;
if (view2d_scroll_mapped(v2d->scroll)) {
- float dx = (v2d->cur.xmax - v2d->cur.xmin) / ((float)(v2d->mask.xmax - v2d->mask.xmin + 1));
- float dy = (v2d->cur.ymax - v2d->cur.ymin) / ((float)(v2d->mask.ymax - v2d->mask.ymin + 1));
+ float dx = BLI_RCT_SIZE_X(&v2d->cur) / ((float)(BLI_RCT_SIZE_X(&v2d->mask) + 1));
+ float dy = BLI_RCT_SIZE_Y(&v2d->cur) / ((float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1));
if (v2d->mask.xmin != 0)
curmasked->xmin -= dx * (float)v2d->mask.xmin;
@@ -985,8 +985,8 @@ void UI_view2d_view_ortho(View2D *v2d)
*/
/* XXX brecht: instead of zero at least use a tiny offset, otherwise
* pixel rounding is effectively random due to float inaccuracy */
- xofs = 0.001f * (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin);
- yofs = 0.001f * (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin);
+ xofs = 0.001f * BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
+ yofs = 0.001f * BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask);
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
view2d_map_cur_using_mask(v2d, &curmasked);
@@ -1044,8 +1044,8 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis)
void UI_view2d_view_restore(const bContext *C)
{
ARegion *ar = CTX_wm_region(C);
- int width = ar->winrct.xmax - ar->winrct.xmin + 1;
- int height = ar->winrct.ymax - ar->winrct.ymin + 1;
+ int width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
glLoadIdentity();
@@ -1140,8 +1140,8 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x
/* calculate x-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
- space = v2d->cur.xmax - v2d->cur.xmin;
- pixels = (float)(v2d->mask.xmax - v2d->mask.xmin);
+ space = BLI_RCT_SIZE_X(&v2d->cur);
+ pixels = (float)BLI_RCT_SIZE_X(&v2d->mask);
if (pixels != 0.0f) {
grid->dx = (U.v2d_min_gridsize * space) / (seconddiv * pixels);
@@ -1158,7 +1158,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x
/* calculate y-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
- space = v2d->cur.ymax - v2d->cur.ymin;
+ space = BLI_RCT_SIZE_Y(&v2d->cur);
pixels = (float)winy;
grid->dy = U.v2d_min_gridsize * space / pixels;
@@ -1206,7 +1206,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vec2[1] = v2d->cur.ymax;
/* minor gridlines */
- step = (v2d->mask.xmax - v2d->mask.xmin + 1) / U.v2d_min_gridsize;
+ step = (BLI_RCT_SIZE_X(&v2d->mask) + 1) / U.v2d_min_gridsize;
UI_ThemeColor(TH_GRID);
for (a = 0; a < step; a++) {
@@ -1240,7 +1240,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
vec1[0] = grid->startx;
vec2[0] = v2d->cur.xmax;
- step = (v2d->mask.ymax - v2d->mask.ymin + 1) / U.v2d_min_gridsize;
+ step = (BLI_RCT_SIZE_Y(&v2d->mask) + 1) / U.v2d_min_gridsize;
UI_ThemeColor(TH_GRID);
for (a = 0; a <= step; a++) {
@@ -1457,7 +1457,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* horizontal scrollers */
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
- totsize = v2d->tot.xmax - v2d->tot.xmin;
+ totsize = BLI_RCT_SIZE_X(&v2d->tot);
scrollsize = (float)(hor.xmax - hor.xmin);
if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
@@ -1498,7 +1498,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* vertical scrollers */
if (scroll & V2D_SCROLL_VERTICAL) {
/* scroller 'button' extents */
- totsize = v2d->tot.ymax - v2d->tot.ymin;
+ totsize = BLI_RCT_SIZE_Y(&v2d->tot);
scrollsize = (float)(vert.ymax - vert.ymin);
if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
@@ -1649,10 +1649,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - fac is x-coordinate to draw to
* - dfac is gap between scale markings
*/
- fac = (grid->startx - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
+ fac = (grid->startx - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
fac = (float)hor.xmin + fac * (hor.xmax - hor.xmin);
- dfac = (grid->dx) / (v2d->cur.xmax - v2d->cur.xmin);
+ dfac = grid->dx / BLI_RCT_SIZE_X(&v2d->cur);
dfac = dfac * (hor.xmax - hor.xmin);
/* set starting value, and text color */
@@ -1763,10 +1763,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - these involve a correction for horizontal scrollbar
* NOTE: it's assumed that that scrollbar is there if this is involved!
*/
- fac = (grid->starty - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+ fac = (grid->starty - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
fac = vert.ymin + fac * (vert.ymax - vert.ymin);
- dfac = (grid->dy) / (v2d->cur.ymax - v2d->cur.ymin);
+ dfac = grid->dy / BLI_RCT_SIZE_Y(&v2d->cur);
dfac = dfac * (vert.ymax - vert.ymin);
/* set starting value, and text color */
@@ -1925,17 +1925,17 @@ void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *r_viewx, float *
float div, ofs;
if (r_viewx) {
- div = (float)(v2d->mask.xmax - v2d->mask.xmin);
+ div = (float)BLI_RCT_SIZE_X(&v2d->mask);
ofs = (float)v2d->mask.xmin;
- *r_viewx = v2d->cur.xmin + (v2d->cur.xmax - v2d->cur.xmin) * ((float)x - ofs) / div;
+ *r_viewx = v2d->cur.xmin + BLI_RCT_SIZE_X(&v2d->cur) * ((float)x - ofs) / div;
}
if (r_viewy) {
- div = (float)(v2d->mask.ymax - v2d->mask.ymin);
+ div = (float)BLI_RCT_SIZE_Y(&v2d->mask);
ofs = (float)v2d->mask.ymin;
- *r_viewy = v2d->cur.ymin + (v2d->cur.ymax - v2d->cur.ymin) * ((float)y - ofs) / div;
+ *r_viewy = v2d->cur.ymin + BLI_RCT_SIZE_Y(&v2d->cur) * ((float)y - ofs) / div;
}
}
@@ -1954,15 +1954,15 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *
*regiony = V2D_IS_CLIPPED;
/* express given coordinates as proportional values */
- x = (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
- y = (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+ x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
+ y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
/* check if values are within bounds */
if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) {
if (regionx)
- *regionx = (int)(v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin));
+ *regionx = (int)(v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask));
if (regiony)
- *regiony = (int)(v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin));
+ *regiony = (int)(v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask));
}
}
@@ -1975,12 +1975,12 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *
void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, int *regiony)
{
/* step 1: express given coordinates as proportional values */
- x = (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
- y = (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+ x = (x - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
+ y = (y - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
/* step 2: convert proportional distances to screen coordinates */
- x = v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin);
- y = v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin);
+ x = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask);
+ y = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask);
/* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */
if (regionx) {
@@ -2033,8 +2033,8 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
*/
void UI_view2d_getscale(View2D *v2d, float *x, float *y)
{
- if (x) *x = (v2d->mask.xmax - v2d->mask.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
- if (y) *y = (v2d->mask.ymax - v2d->mask.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+ if (x) *x = BLI_RCT_SIZE_X(&v2d->mask) / BLI_RCT_SIZE_X(&v2d->cur);
+ if (y) *y = BLI_RCT_SIZE_Y(&v2d->mask) / BLI_RCT_SIZE_Y(&v2d->cur);
}
/* Check if mouse is within scrollers
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index f12a9e06312..258025eefc9 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -119,10 +119,10 @@ static int view_pan_init(bContext *C, wmOperator *op)
vpd->ar = ar;
/* calculate translation factor - based on size of view */
- winx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1);
- winy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1);
- vpd->facx = (v2d->cur.xmax - v2d->cur.xmin) / winx;
- vpd->facy = (v2d->cur.ymax - v2d->cur.ymin) / winy;
+ winx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1);
+ winy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1);
+ vpd->facx = (BLI_RCT_SIZE_X(&v2d->cur)) / winx;
+ vpd->facy = (BLI_RCT_SIZE_Y(&v2d->cur)) / winy;
return 1;
}
@@ -590,12 +590,12 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
facy = RNA_float_get(op->ptr, "zoomfacy");
if (facx >= 0.0f) {
- dx = (v2d->cur.xmax - v2d->cur.xmin) * facx;
- dy = (v2d->cur.ymax - v2d->cur.ymin) * facy;
+ dx = BLI_RCT_SIZE_X(&v2d->cur) * facx;
+ dy = BLI_RCT_SIZE_Y(&v2d->cur) * facy;
}
else {
- dx = ((v2d->cur.xmax - v2d->cur.xmin) / (1.0f + 2.0f * facx)) * facx;
- dy = ((v2d->cur.ymax - v2d->cur.ymin) / (1.0f + 2.0f * facy)) * facy;
+ dx = (BLI_RCT_SIZE_X(&v2d->cur) / (1.0f + 2.0f * facx)) * facx;
+ dy = (BLI_RCT_SIZE_Y(&v2d->cur) / (1.0f + 2.0f * facy)) * facy;
}
/* only resize view on an axis if change is allowed */
@@ -611,7 +611,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
+ float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dx) - (mval_faci * dx);
@@ -636,7 +636,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+ float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dy) - (mval_faci * dy);
@@ -821,7 +821,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
+ float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / BLI_RCT_SIZE_X(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dx) - (mval_faci * dx);
@@ -840,7 +840,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+ float mval_fac = (vzd->my_2d - v2d->cur.ymin) / BLI_RCT_SIZE_Y(&v2d->cur);
float mval_faci = 1.0f - mval_fac;
float ofs = (mval_fac * dy) - (mval_faci * dy);
@@ -918,8 +918,8 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
* with magnify information that is stored in x axis
*/
fac = 0.01f * (event->x - event->prevx);
- dx = fac * (v2d->cur.xmax - v2d->cur.xmin) / 10.0f;
- dy = fac * (v2d->cur.ymax - v2d->cur.ymin) / 10.0f;
+ dx = fac * BLI_RCT_SIZE_X(&v2d->cur) / 10.0f;
+ dy = fac * BLI_RCT_SIZE_Y(&v2d->cur) / 10.0f;
RNA_float_set(op->ptr, "deltax", dx);
RNA_float_set(op->ptr, "deltay", dy);
@@ -985,14 +985,14 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
float dist;
/* x-axis transform */
- dist = (v2d->mask.xmax - v2d->mask.xmin) / 2.0f;
+ dist = BLI_RCT_SIZE_X(&v2d->mask) / 2.0f;
dx = 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f);
- dx *= 0.5f * (v2d->cur.xmax - v2d->cur.xmin);
+ dx *= 0.5f * BLI_RCT_SIZE_X(&v2d->cur);
/* y-axis transform */
- dist = (v2d->mask.ymax - v2d->mask.ymin) / 2.0f;
+ dist = BLI_RCT_SIZE_Y(&v2d->mask) / 2.0f;
dy = 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f);
- dy *= 0.5f * (v2d->cur.ymax - v2d->cur.ymin);
+ dy *= 0.5f * BLI_RCT_SIZE_Y(&v2d->cur);
}
else {
/* 'continuous' or 'dolly' */
@@ -1000,11 +1000,11 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
/* x-axis transform */
fac = 0.01f * (event->x - vzd->lastx);
- dx = fac * (v2d->cur.xmax - v2d->cur.xmin);
+ dx = fac * BLI_RCT_SIZE_X(&v2d->cur);
/* y-axis transform */
fac = 0.01f * (event->y - vzd->lasty);
- dy = fac * (v2d->cur.ymax - v2d->cur.ymin);
+ dy = fac * BLI_RCT_SIZE_Y(&v2d->cur);
#if 0
/* continuous zoom shouldn't move that fast... */
if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
@@ -1138,7 +1138,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);
- zoom = size / (rect.xmax - rect.xmin);
+ zoom = size / BLI_RCT_SIZE_X(&rect);
center = BLI_RCT_CENTER_X(&cur_new);
cur_new.xmin = center - (size * zoom);
@@ -1146,7 +1146,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
}
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
size = (cur_new.ymax - cur_new.ymin);
- zoom = size / (rect.ymax - rect.ymin);
+ zoom = size / BLI_RCT_SIZE_Y(&rect);
center = BLI_RCT_CENTER_Y(&cur_new);
cur_new.ymin = center - (size * zoom);
@@ -1478,7 +1478,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);
- vsm->fac = (v2d->tot.xmax - v2d->tot.xmin) / mask_size;
+ vsm->fac = BLI_RCT_SIZE_X(&v2d->tot) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
vsm->zone = mouse_in_scroller_handle(event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max);
@@ -1494,7 +1494,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);
- vsm->fac = (v2d->tot.ymax - v2d->tot.ymin) / mask_size;
+ vsm->fac = BLI_RCT_SIZE_Y(&v2d->tot) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
vsm->zone = mouse_in_scroller_handle(event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
@@ -1774,8 +1774,8 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
int winx, winy;
/* zoom 1.0 */
- winx = (float)(v2d->mask.xmax - v2d->mask.xmin + 1);
- winy = (float)(v2d->mask.ymax - v2d->mask.ymin + 1);
+ winx = (float)(BLI_RCT_SIZE_X(&v2d->mask) + 1);
+ winy = (float)(BLI_RCT_SIZE_Y(&v2d->mask) + 1);
v2d->cur.xmax = v2d->cur.xmin + winx;
v2d->cur.ymax = v2d->cur.ymin + winy;
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 703ae70eb0f..9c2e70a836e 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -33,6 +33,7 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLI_rect.h"
#include "BKE_context.h"
#include "BKE_mask.h"
@@ -512,12 +513,12 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar,
UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y);
- /* w = v2d->tot.xmax - v2d->tot.xmin; */
- /* h = v2d->tot.ymax - v2d->tot.ymin;/*/
+ /* w = BLI_RCT_SIZE_X(&v2d->tot); */
+ /* h = BLI_RCT_SIZE_Y(&v2d->tot);/*/
- zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin));
- zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin));
+ zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur));
+ zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur));
if (do_scale_applied) {
zoomx /= width;
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 62600c7fe6b..3431bea18ea 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -570,8 +570,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
unsigned int *rt;
char *selar;
int a, index;
- int sx = rect->xmax - rect->xmin + 1;
- int sy = rect->ymax - rect->ymin + 1;
+ int sx = BLI_RCT_SIZE_X(rect) + 1;
+ int sy = BLI_RCT_SIZE_Y(rect) + 1;
me = BKE_mesh_from_object(ob);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 4f62974a3e1..84319061d52 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -474,7 +474,9 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
RenderResult rres;
char name[32];
int do_gamma_correct = FALSE, do_predivide = FALSE;
- int offx = 0, newx = rect->xmax - rect->xmin, newy = rect->ymax - rect->ymin;
+ int offx = 0;
+ int newx = BLI_RCT_SIZE_X(rect);
+ int newy = BLI_RCT_SIZE_Y(rect);
if (id && GS(id->name) != ID_TE) {
/* exception: don't color manage texture previews - show the raw values */
@@ -547,7 +549,8 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
SpaceButs *sbuts = sa->spacedata.first;
rcti newrect;
int ok;
- int newx = rect->xmax - rect->xmin, newy = rect->ymax - rect->ymin;
+ int newx = BLI_RCT_SIZE_X(rect);
+ int newy = BLI_RCT_SIZE_Y(rect);
newrect.xmin = rect->xmin;
newrect.xmax = rect->xmin;
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 2c32295fe36..10bc17ff59e 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -104,8 +104,8 @@ static void region_draw_emboss(ARegion *ar, rcti *scirct)
void ED_region_pixelspace(ARegion *ar)
{
- int width = ar->winrct.xmax - ar->winrct.xmin + 1;
- int height = ar->winrct.ymax - ar->winrct.ymin + 1;
+ int width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ int height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
glLoadIdentity();
@@ -901,10 +901,10 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment)
static int rct_fits(rcti *rect, char dir, int size)
{
if (dir == 'h') {
- return rect->xmax - rect->xmin - size;
+ return BLI_RCT_SIZE_X(rect) - size;
}
- else { // 'v'
- return rect->ymax - rect->ymin - size;
+ else { /* 'v' */
+ return BLI_RCT_SIZE_Y(rect) - size;
}
}
@@ -1073,8 +1073,8 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
}
/* for speedup */
- ar->winx = ar->winrct.xmax - ar->winrct.xmin + 1;
- ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1;
+ ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
/* set winrect for azones */
if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) {
@@ -1133,8 +1133,8 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
else sa->totrct.ymax = sa->v2->vec.y;
/* for speedup */
- sa->winx = sa->totrct.xmax - sa->totrct.xmin + 1;
- sa->winy = sa->totrct.ymax - sa->totrct.ymin + 1;
+ sa->winx = BLI_RCT_SIZE_X(&sa->totrct) + 1;
+ sa->winy = BLI_RCT_SIZE_Y(&sa->totrct) + 1;
}
@@ -1268,8 +1268,8 @@ void ED_region_init(bContext *C, ARegion *ar)
/* refresh can be called before window opened */
region_subwindow(CTX_wm_window(C), ar);
- ar->winx = ar->winrct.xmax - ar->winrct.xmin + 1;
- ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1;
+ ar->winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ ar->winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
/* UI convention */
wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
@@ -1574,7 +1574,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
newcontext = UI_view2d_tab_set(v2d, contextnr);
if (vertical) {
- w = v2d->cur.xmax - v2d->cur.xmin;
+ w = BLI_RCT_SIZE_X(&v2d->cur);
em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y;
}
else {
@@ -1798,16 +1798,16 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
/* background box */
rect = ar->winrct;
rect.xmin = 0;
- rect.ymin = ar->winrct.ymax - ar->winrct.ymin - header_height;
+ rect.ymin = BLI_RCT_SIZE_Y(&ar->winrct) - header_height;
if (block) {
- rect.xmax = ar->winrct.xmax - ar->winrct.xmin;
+ rect.xmax = BLI_RCT_SIZE_X(&ar->winrct);
}
else {
rect.xmax = rect.xmin + BLF_width(fontid, text) + 24;
}
- rect.ymax = ar->winrct.ymax - ar->winrct.ymin;
+ rect.ymax = BLI_RCT_SIZE_Y(&ar->winrct);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index e92f7b7a3c2..97a63bb0df0 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1612,7 +1612,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
int dist;
if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) {
- dist = sa->totrct.xmax - sa->totrct.xmin;
+ dist = BLI_RCT_SIZE_X(&sa->totrct);
}
else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */
dist = sa->totrct.ymax - sa->totrct.ymin;
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index edec57d9e93..878fd20b27e 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -89,7 +89,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
* start of list offset, and the second is as a correction for the scrollers.
*/
height = ((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2));
- if (height > (v2d->mask.ymax - v2d->mask.ymin)) {
+ if (height > BLI_RCT_SIZE_Y(&v2d->mask)) {
/* don't use totrect set, as the width stays the same
* (NOTE: this is ok here, the configuration is pretty straightforward)
*/
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index dbde950188d..c95f1dba31d 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -365,13 +365,13 @@ static int actkeys_viewall(bContext *C, const short onlySel)
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
- extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
+ extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
/* set vertical range */
v2d->cur.ymax = 0.0f;
- v2d->cur.ymin = (float)-(v2d->mask.ymax - v2d->mask.ymin);
+ v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask);
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 6b61990d485..c9f765ac3db 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -309,7 +309,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op)
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
*/
- if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin))
+ if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect))
mode = ACTKEYS_BORDERSEL_FRAMERANGE;
else
mode = ACTKEYS_BORDERSEL_CHANNELS;
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index e561b2a9e79..e66faa88b93 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -41,6 +41,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
+#include "BLI_rect.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
@@ -168,7 +169,7 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
scopes->track_preview_height =
(scopes->track_preview_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->track_preview_height;
- uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin,
+ uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, BLI_RCT_SIZE_X(&rect),
scopes->track_preview_height, scopes, 0, 0, 0, 0, "");
}
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index 83d895067cc..5d890155e25 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -44,6 +44,7 @@
#include "BLI_string.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
+#include "BLI_rect.h"
#include "ED_screen.h"
#include "ED_clip.h"
@@ -273,7 +274,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
dopesheet = &tracking->dopesheet;
height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT * 2);
- if (height > (v2d->mask.ymax - v2d->mask.ymin)) {
+ if (height > BLI_RCT_SIZE_Y(&v2d->mask)) {
/* don't use totrect set, as the width stays the same
* (NOTE: this is ok here, the configuration is pretty straightforward)
*/
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index c24cdab29e5..2353f8f8c12 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -958,12 +958,12 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
static void view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony)
{
/* express given coordinates as proportional values */
- x = -v2d->cur.xmin / (v2d->cur.xmax - v2d->cur.xmin);
- y = -v2d->cur.ymin / (v2d->cur.ymax - v2d->cur.ymin);
+ x = -v2d->cur.xmin / BLI_RCT_SIZE_X(&v2d->cur);
+ y = -v2d->cur.ymin / BLI_RCT_SIZE_Y(&v2d->cur);
/* convert proportional distances to screen coordinates */
- *regionx = v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin);
- *regiony = v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin);
+ *regionx = v2d->mask.xmin + x * BLI_RCT_SIZE_X(&v2d->mask);
+ *regiony = v2d->mask.ymin + y * BLI_RCT_SIZE_Y(&v2d->mask);
}
static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip,
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 5b4849a425f..7a54a39ee48 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -44,6 +44,7 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLI_rect.h"
#include "GPU_extensions.h"
@@ -148,8 +149,8 @@ void ED_space_clip_get_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoo
ED_space_clip_get_size(sc, &width, &height);
- *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width);
- *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height);
+ *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width);
+ *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height);
}
void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy)
@@ -393,8 +394,8 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit)
ED_space_clip_get_aspect(sc, &aspx, &aspy);
- width = ar->winrct.xmax - ar->winrct.xmin + 1;
- height = ar->winrct.ymax - ar->winrct.ymin + 1;
+ width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
zoomx = (float)width / w / aspx;
zoomy = (float)height / h / aspy;
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index a2cb812d51c..e94b28d22fa 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -580,11 +580,11 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
}
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
- extra = 0.01f * (v2d->cur.xmax - v2d->cur.xmin);
+ extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
- extra = 0.01f * (v2d->cur.ymax - v2d->cur.ymin);
+ extra = 0.01f * BLI_RCT_SIZE_Y(&v2d->cur);
v2d->cur.ymin -= extra;
v2d->cur.ymax += extra;
@@ -610,7 +610,7 @@ void CLIP_OT_graph_view_all(wmOperatorType *ot)
void ED_clip_graph_center_current_frame(Scene *scene, ARegion *ar)
{
View2D *v2d = &ar->v2d;
- float extra = (v2d->cur.xmax - v2d->cur.xmin) / 2.0f;
+ float extra = BLI_RCT_SIZE_X(&v2d->cur) / 2.0f;
/* set extents of view to start/end frames */
v2d->cur.xmin = (float)CFRA - extra;
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 36199b1908d..20b0ad509d3 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -39,6 +39,7 @@
#include "BLI_path_util.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLI_rect.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -89,9 +90,9 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2])
if ((width < 4) && (height < 4))
sc->zoom = oldzoom;
- else if ((ar->winrct.xmax - ar->winrct.xmin) <= sc->zoom)
+ else if (BLI_RCT_SIZE_X(&ar->winrct) <= sc->zoom)
sc->zoom = oldzoom;
- else if ((ar->winrct.ymax - ar->winrct.ymin) <= sc->zoom)
+ else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sc->zoom)
sc->zoom = oldzoom;
}
@@ -725,8 +726,8 @@ static int view_all_exec(bContext *C, wmOperator *op)
h = h * aspy;
/* check if the image will fit in the image with zoom == 1 */
- width = ar->winrct.xmax - ar->winrct.xmin + 1;
- height = ar->winrct.ymax - ar->winrct.ymin + 1;
+ width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
if (fit_view) {
const int margin = 5; /* margin from border */
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index bf65429b9f4..bb06104d442 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -1036,8 +1036,8 @@ static void movieclip_main_area_set_view2d(const bContext *C, ARegion *ar)
if (clip)
h *= clip->aspy / clip->aspx / clip->tracking.camera.pixel_aspect;
- winx = ar->winrct.xmax - ar->winrct.xmin + 1;
- winy = ar->winrct.ymax - ar->winrct.ymin + 1;
+ winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
ar->v2d.tot.xmin = 0;
ar->v2d.tot.ymin = 0;
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 490a3b45990..a4f7e30ed7b 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -142,7 +142,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
/* always keep the bottom part of the view aligned, less annoying */
if (prev_y_min != ar->v2d.cur.ymin) {
- const float cur_y_range = ar->v2d.cur.ymax - ar->v2d.cur.ymin;
+ const float cur_y_range = BLI_RCT_SIZE_Y(&ar->v2d.cur);
ar->v2d.cur.ymin = prev_y_min;
ar->v2d.cur.ymax = prev_y_min + cur_y_range;
}
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 34f16c11537..09231efd367 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -270,12 +270,12 @@ int ED_fileselect_layout_numfiles(FileLayout *layout, ARegion *ar)
int numfiles;
if (layout->flag & FILE_LAYOUT_HOR) {
- int width = (int)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2 * layout->tile_border_x);
+ int width = (int)(BLI_RCT_SIZE_X(&ar->v2d.cur) - 2 * layout->tile_border_x);
numfiles = (int)((float)width / (float)layout->tile_w + 0.5f);
return numfiles * layout->rows;
}
else {
- int height = (int)(ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2 * layout->tile_border_y);
+ int height = (int)(BLI_RCT_SIZE_Y(&ar->v2d.cur) - 2 * layout->tile_border_y);
numfiles = (int)((float)height / (float)layout->tile_h + 0.5f);
return numfiles * layout->columns;
}
@@ -503,7 +503,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->prv_border_y = 6;
layout->tile_w = layout->prv_w + 2 * layout->prv_border_x;
layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight;
- layout->width = (int)(v2d->cur.xmax - v2d->cur.xmin - 2 * layout->tile_border_x);
+ layout->width = (int)(BLI_RCT_SIZE_X(&v2d->cur) - 2 * layout->tile_border_x);
layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x);
if (layout->columns > 0)
layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero
@@ -522,7 +522,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->prv_border_x = 0;
layout->prv_border_y = 0;
layout->tile_h = textheight * 3 / 2;
- layout->height = (int)(v2d->cur.ymax - v2d->cur.ymin - 2 * layout->tile_border_y);
+ layout->height = (int)(BLI_RCT_SIZE_Y(&v2d->cur) - 2 * layout->tile_border_y);
layout->rows = layout->height / (layout->tile_h + 2 * layout->tile_border_y);
column_widths(sfile->files, layout);
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 17669dfa8f9..8c5ecb48613 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -525,7 +525,7 @@ static void file_ui_area_draw(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
/* scrolling here is just annoying, disable it */
- ar->v2d.cur.ymax = ar->v2d.cur.ymax - ar->v2d.cur.ymin;
+ ar->v2d.cur.ymax = BLI_RCT_SIZE_Y(&ar->v2d.cur);
ar->v2d.cur.ymin = 0;
/* set view2d view matrix for scrolling (without scrollers) */
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 870e9bb8168..ad97b7853c4 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -88,7 +88,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
{
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
FCM_EnvelopeData *fed;
- const float fac = 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
+ const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur);
int i;
/* draw two black lines showing the standard reference levels */
@@ -137,7 +137,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel)
{
BezTriple *bezt = fcu->bezt;
- const float fac = 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
+ const float fac = 0.05f * BLI_RCT_SIZE_X(&v2d->cur);
int i;
/* we use bgl points not standard gl points, to workaround vertex
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 781099f6a68..32abad86828 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -325,7 +325,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
*/
- if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin))
+ if ((BLI_RCT_SIZE_X(&rect)) >= (BLI_RCT_SIZE_Y(&rect)))
mode = BEZT_OK_FRAMERANGE;
else
mode = BEZT_OK_VALUERANGE;
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index b8ca0deb770..56b340aac09 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -274,7 +274,7 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block)
/* while dragging we need to update the rects, otherwise it doesn't end with correct one */
- BLI_rctf_init(&dispf, 15.0f, (block->rect.xmax - block->rect.xmin) - 15.0f, 15.0f, (block->rect.ymax - block->rect.ymin) - 15.0f);
+ BLI_rctf_init(&dispf, 15.0f, BLI_RCT_SIZE_X(&block->rect) - 15.0f, 15.0f, (BLI_RCT_SIZE_Y(&block->rect)) - 15.0f);
ui_graphics_to_window_rct(sa->win, &dispf, disprect);
/* correction for gla draw */
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 52ed7fd1d0b..e293264c021 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -44,6 +44,7 @@
#include "PIL_time.h"
#include "BLI_math.h"
+#include "BLI_rect.h"
#include "BLI_threads.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
@@ -135,7 +136,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
/* noisy, high contrast make impossible to read if lower alpha is used. */
glColor4ub(0, 0, 0, 190);
- glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20);
+ glRecti(0.0, 0.0, BLI_RCT_SIZE_X(&ar->winrct) + 1, 20);
glDisable(GL_BLEND);
BLF_size(blf_mono_font, 11, 72);
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index 036e70913b6..bb31ba42716 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -33,6 +33,7 @@
#include "DNA_scene_types.h"
#include "BLI_math.h"
+#include "BLI_rect.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -229,8 +230,8 @@ void ED_space_image_get_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float
ED_space_image_get_size(sima, &width, &height);
- *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width);
- *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height);
+ *zoomx = (float)(BLI_RCT_SIZE_X(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_X(&ar->v2d.cur) * width);
+ *zoomy = (float)(BLI_RCT_SIZE_Y(&ar->winrct) + 1) / (float)(BLI_RCT_SIZE_Y(&ar->v2d.cur) * height);
}
void ED_space_image_get_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index b969d898882..3d6b316b743 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -98,9 +98,9 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat
if ((width < 4) && (height < 4))
sima->zoom = oldzoom;
- else if ((ar->winrct.xmax - ar->winrct.xmin) <= sima->zoom)
+ else if (BLI_RCT_SIZE_X(&ar->winrct) <= sima->zoom)
sima->zoom = oldzoom;
- else if ((ar->winrct.ymax - ar->winrct.ymin) <= sima->zoom)
+ else if (BLI_RCT_SIZE_Y(&ar->winrct) <= sima->zoom)
sima->zoom = oldzoom;
}
@@ -581,8 +581,8 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op))
h = height * aspy;
/* check if the image will fit in the image with (zoom == 1) */
- width = ar->winrct.xmax - ar->winrct.xmin + 1;
- height = ar->winrct.ymax - ar->winrct.ymin + 1;
+ width = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ height = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
if ((w >= width || h >= height) && (width > 0 && height > 0)) {
/* find the zoom value that will fit the image in the image space */
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index cc8940201e2..1f655884b73 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -556,8 +556,8 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
if (ima)
h *= ima->aspy / ima->aspx;
- winx = ar->winrct.xmax - ar->winrct.xmin + 1;
- winy = ar->winrct.ymax - ar->winrct.ymin + 1;
+ winx = BLI_RCT_SIZE_X(&ar->winrct) + 1;
+ winy = BLI_RCT_SIZE_Y(&ar->winrct) + 1;
ar->v2d.tot.xmin = 0;
ar->v2d.tot.ymin = 0;
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index a3e9ca1c4a2..775dd5445c3 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -304,13 +304,13 @@ static int nlaedit_viewall(bContext *C, const short onlySel)
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
- extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
+ extra = 0.1f * BLI_RCT_SIZE_X(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
/* set vertical range */
v2d->cur.ymax = 0.0f;
- v2d->cur.ymin = (float)-(v2d->mask.ymax - v2d->mask.ymin);
+ v2d->cur.ymin = (float)-BLI_RCT_SIZE_Y(&v2d->mask);
/* do View2D syncing */
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index b6bef651af3..e7610210881 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -309,7 +309,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op)
* - the frame-range select option is favored over the channel one (x over y), as frame-range one is often
* used for tweaking timing when "blocking", while channels is not that useful...
*/
- if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin))
+ if (BLI_RCT_SIZE_X(&rect) >= BLI_RCT_SIZE_Y(&rect))
mode = NLA_BORDERSEL_FRAMERANGE;
else
mode = NLA_BORDERSEL_CHANNELS;
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 68286554093..2816b55651f 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -386,7 +386,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *
bt = uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "",
(int)butr->xmin, (int)butr->xmin,
- (short)(butr->xmax - butr->xmin), (short)(butr->xmax - butr->xmin),
+ (short)BLI_RCT_SIZE_X(butr), (short)BLI_RCT_SIZE_X(butr),
nor, 0.0f, 1.0f, 0, 0, "");
uiButSetFunc(bt, node_normal_cb, ntree, node);
}
@@ -837,7 +837,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
(int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + (group_header - (2.5f * dpi_fac))),
- mini((int)(rect.xmax - rect.xmin - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
+ mini((int)(BLI_RCT_SIZE_X(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
uiTemplateIDBrowse(layout, (bContext *)C, &ptr, "node_tree", NULL, NULL, NULL);
uiBlockLayoutResolve(gnode->block, NULL, NULL);
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 1a4c302124f..f58448b39ac 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1110,7 +1110,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
glEnable(GL_MAP1_VERTEX_3);
/* aspect+font, set each time */
- snode->aspect = (v2d->cur.xmax - v2d->cur.xmin) / ((float)ar->winx);
+ snode->aspect = BLI_RCT_SIZE_X(&v2d->cur) / (float)ar->winx;
snode->aspect_sqrt = sqrtf(snode->aspect);
// XXX snode->curfont= uiSetCurFont_ext(snode->aspect);
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index 27b57885b2b..6f549bd252f 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -72,8 +72,8 @@ static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, cons
int tot = 0;
int has_frame = FALSE;
- oldwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin;
- oldheight = ar->v2d.cur.ymax - ar->v2d.cur.ymin;
+ oldwidth = BLI_RCT_SIZE_X(&ar->v2d.cur);
+ oldheight = BLI_RCT_SIZE_Y(&ar->v2d.cur);
BLI_rctf_init_minmax(&cur_new);
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index 4fa8686bce3..b669e705a25 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -579,11 +579,11 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
te = outliner_find_id(so, &so->tree, (ID *)OBACT);
if (te) {
/* make te->ys center of view */
- ytop = (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin) / 2);
+ ytop = (int)(te->ys + BLI_RCT_SIZE_Y(&v2d->mask) / 2);
if (ytop > 0) ytop = 0;
v2d->cur.ymax = (float)ytop;
- v2d->cur.ymin = (float)(ytop - (v2d->mask.ymax - v2d->mask.ymin));
+ v2d->cur.ymin = (float)(ytop - BLI_RCT_SIZE_Y(&v2d->mask));
/* make te->xs ==> te->xend center of view */
xdelta = (int)(te->xs - v2d->cur.xmin);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 7dd98c39e4c..25514b3168b 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -428,7 +428,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq)
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
- pixely = (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin);
+ pixely = BLI_RCT_SIZE_Y(&v2d->cur) / BLI_RCT_SIZE_Y(&v2d->mask);
if (pixely <= 0) return; /* can happen when the view is split/resized */
@@ -721,7 +721,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline
/* draw sound wave */
if (seq->type == SEQ_TYPE_SOUND_RAM) {
- drawseqwave(scene, seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin) / ar->winx);
+ drawseqwave(scene, seq, x1, y1, x2, y2, BLI_RCT_SIZE_X(&ar->v2d.cur) / ar->winx);
}
/* draw lock */
@@ -929,10 +929,10 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (draw_overlay) {
if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
rctf tot_clip;
- tot_clip.xmin = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin);
- tot_clip.ymin = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin);
- tot_clip.xmax = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmax);
- tot_clip.ymax = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymax);
+ tot_clip.xmin = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmin);
+ tot_clip.ymin = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymin);
+ tot_clip.xmax = v2d->tot.xmin + (ABS(BLI_RCT_SIZE_X(&v2d->tot)) * scene->ed->over_border.xmax);
+ tot_clip.ymax = v2d->tot.ymin + (ABS(BLI_RCT_SIZE_Y(&v2d->tot)) * scene->ed->over_border.ymax);
glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymin); glVertex2f(tot_clip.xmin, tot_clip.ymin);
glTexCoord2f(scene->ed->over_border.xmin, scene->ed->over_border.ymax); glVertex2f(tot_clip.xmin, tot_clip.ymax);
@@ -1114,7 +1114,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar)
View2D *v2d = &ar->v2d;
Sequence *last_seq = BKE_sequencer_active_get(scene);
int sel = 0, j;
- float pixelx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin);
+ float pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
/* loop through twice, first unselected, then selected */
for (j = 0; j < 2; j++) {
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 144de1f9d5e..2dc26a9d5b8 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -372,7 +372,7 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[
if (ed == NULL) return NULL;
- pixelx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin);
+ pixelx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
@@ -2142,8 +2142,8 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
float winx = (int)(rd->size * rd->xsch) / 100;
float winy = (int)(rd->size * rd->ysch) / 100;
- float facx = (v2d->mask.xmax - v2d->mask.xmin) / winx;
- float facy = (v2d->mask.ymax - v2d->mask.ymin) / winy;
+ float facx = BLI_RCT_SIZE_X(&v2d->mask) / winx;
+ float facy = BLI_RCT_SIZE_Y(&v2d->mask) / winy;
BLI_rctf_resize(&v2d->cur, (int)(winx * facx * ratio) + 1, (int)(winy * facy * ratio) + 1);
@@ -2769,11 +2769,11 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op)
if (ed == NULL)
return OPERATOR_CANCELLED;
- rect.xmin /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin));
- rect.ymin /= (float)(ABS(v2d->tot.ymax - v2d->tot.ymin));
+ rect.xmin /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot)));
+ rect.ymin /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot)));
- rect.xmax /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin));
- rect.ymax /= (float)(ABS(v2d->tot.ymax - v2d->tot.ymin));
+ rect.xmax /= (float)(ABS(BLI_RCT_SIZE_X(&v2d->tot)));
+ rect.ymax /= (float)(ABS(BLI_RCT_SIZE_Y(&v2d->tot)));
rect.xmin += 0.5f;
rect.xmax += 0.5f;
diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c
index 189c8bfc7d0..733fd27135b 100644
--- a/source/blender/editors/space_time/time_ops.c
+++ b/source/blender/editors/space_time/time_ops.c
@@ -151,7 +151,7 @@ static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op))
v2d->cur.xmax = (float)PEFRA;
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
- extra = 0.01f * (v2d->cur.xmax - v2d->cur.xmin);
+ extra = 0.01f * BLI_RCT_SIZE_X(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 199a1751f9d..93f8457e7a3 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2038,8 +2038,8 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect)
x = rect->xmin;
y = rect->ymin;
- w = rect->xmax - rect->xmin;
- h = rect->ymax - rect->ymin;
+ w = BLI_RCT_SIZE_X(rect);
+ h = BLI_RCT_SIZE_Y(rect);
if (w <= 0 || h <= 0) {
if (d->depths)
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 4fe859adf45..6e0c598d0ce 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -383,9 +383,9 @@ static void calctrackballvec(rcti *rect, int mx, int my, float vec[3])
/* normalize x and y */
x = BLI_RCT_CENTER_X(rect) - mx;
- x /= (float)((rect->xmax - rect->xmin) / 4);
+ x /= (float)(BLI_RCT_SIZE_X(rect) / 4);
y = BLI_RCT_CENTER_Y(rect) - my;
- y /= (float)((rect->ymax - rect->ymin) / 2);
+ y /= (float)(BLI_RCT_SIZE_Y(rect) / 2);
d = sqrt(x * x + y * y);
if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */
@@ -2784,8 +2784,8 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
}
/* work out the ratios, so that everything selected fits when we zoom */
- xscale = ((rect.xmax - rect.xmin) / vb[0]);
- yscale = ((rect.ymax - rect.ymin) / vb[1]);
+ xscale = (BLI_RCT_SIZE_X(&rect) / vb[0]);
+ yscale = (BLI_RCT_SIZE_Y(&rect) / vb[1]);
new_dist *= maxf(xscale, yscale);
/* zoom in as required, or as far as we can go */
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 8ef1b481143..49d7c9ba28c 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -654,8 +654,8 @@ int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend)
unsigned int *rt;
int a, index;
char *selar;
- int sx = rect->xmax - rect->xmin + 1;
- int sy = rect->ymax - rect->ymin + 1;
+ int sx = BLI_RCT_SIZE_X(rect) + 1;
+ int sy = BLI_RCT_SIZE_Y(rect) + 1;
me = vc->obact->data;
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index f88d4becc74..6b6da99cf39 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -125,11 +125,11 @@ static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
{
float divx, divy;
- divx = v2d->mask.xmax - v2d->mask.xmin;
- divy = v2d->mask.ymax - v2d->mask.ymin;
+ divx = BLI_RCT_SIZE_X(&v2d->mask);
+ divy = BLI_RCT_SIZE_Y(&v2d->mask);
- r_vec[0] = (v2d->cur.xmax - v2d->cur.xmin) * dx / divx;
- r_vec[1] = (v2d->cur.ymax - v2d->cur.ymin) * dy / divy;
+ r_vec[0] = BLI_RCT_SIZE_X(&v2d->cur) * dx / divx;
+ r_vec[1] = BLI_RCT_SIZE_Y(&v2d->cur) * dy / divy;
r_vec[2] = 0.0f;
}
@@ -138,11 +138,11 @@ static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
float divx, divy;
float mulx, muly;
- divx = v2d->mask.xmax - v2d->mask.xmin;
- divy = v2d->mask.ymax - v2d->mask.ymin;
+ divx = BLI_RCT_SIZE_X(&v2d->mask);
+ divy = BLI_RCT_SIZE_Y(&v2d->mask);
- mulx = (v2d->cur.xmax - v2d->cur.xmin);
- muly = (v2d->cur.ymax - v2d->cur.ymin);
+ mulx = BLI_RCT_SIZE_X(&v2d->cur);
+ muly = BLI_RCT_SIZE_Y(&v2d->cur);
/* difference with convertViewVec2D */
/* clamp w/h, mask only */
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index c9fb2644cfa..0fa29bf3f14 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -116,8 +116,8 @@ void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y)
wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) {
- *x = swin->winrct.xmax - swin->winrct.xmin + 1;
- *y = swin->winrct.ymax - swin->winrct.ymin + 1;
+ *x = BLI_RCT_SIZE_X(&swin->winrct) + 1;
+ *y = BLI_RCT_SIZE_Y(&swin->winrct) + 1;
}
}
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index cef068ccbaa..1b8f857c2cb 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -458,7 +458,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
// itself is unaware of the extra space, so we clear the whole region for it.
glClearColor(scene->gm.framing.col[0], scene->gm.framing.col[1], scene->gm.framing.col[2], 1.0f);
glViewport(ar->winrct.xmin, ar->winrct.ymin,
- ar->winrct.xmax - ar->winrct.xmin, ar->winrct.ymax - ar->winrct.ymin);
+ BLI_RCT_SIZE_X(&ar->winrct), BLI_RCT_SIZE_Y(&ar->winrct));
glClear(GL_COLOR_BUFFER_BIT);
}