diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-10-26 02:47:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-10-26 02:47:54 +0400 |
commit | b32bf2c462970912c2e8013fcf6f0ee5e3eaadd5 (patch) | |
tree | 1f676fef36a65b7f9f55ffbf63bf3f68e4a727e0 /source/blender/editors/screen | |
parent | 2223ca1c20cf480ca77365ff3593066c655de9fa (diff) |
code cleanup: use min_/max_ math functions, add minmax_v2_v2v2.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 16 | ||||
-rw-r--r-- | source/blender/editors/screen/glutil.c | 4 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 7 |
3 files changed, 13 insertions, 14 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 586f734129f..fa0ce8c4d07 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -465,11 +465,11 @@ void ED_region_do_draw(bContext *C, ARegion *ar) if (ar->drawrct.xmin == ar->drawrct.xmax) ar->drawrct = winrct; else { - /* extra clip for safety */ - ar->drawrct.xmin = MAX2(winrct.xmin, ar->drawrct.xmin); - ar->drawrct.ymin = MAX2(winrct.ymin, ar->drawrct.ymin); - ar->drawrct.xmax = MIN2(winrct.xmax, ar->drawrct.xmax); - ar->drawrct.ymax = MIN2(winrct.ymax, ar->drawrct.ymax); + /* extra clip for safety (intersect the rects, could use API func) */ + ar->drawrct.xmin = max_ii(winrct.xmin, ar->drawrct.xmin); + ar->drawrct.ymin = max_ii(winrct.ymin, ar->drawrct.ymin); + ar->drawrct.xmax = min_ii(winrct.xmax, ar->drawrct.xmax); + ar->drawrct.ymax = min_ii(winrct.ymax, ar->drawrct.ymax); } /* note; this sets state, so we can use wmOrtho and friends */ @@ -1664,8 +1664,8 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE; /* ensure tot is set correctly, to keep views on bottons, with sliders */ - y = MAX2(-y, -v2d->cur.ymin); - + y = min_ii(y, v2d->cur.ymin); + y = -y; } else { /* for now, allow scrolling in both directions (since layouts are optimized for vertical, @@ -1679,7 +1679,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * /* don't jump back when panels close or hide */ if (!newcontext) - x = MAX2(x, v2d->cur.xmax); + x = max_ii(x, v2d->cur.xmax); y = -y; } diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index c1811adf2d8..ce2d045dc80 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -600,8 +600,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo /* The maximum pixel amounts the image can be cropped * at the lower left without exceeding the origin. */ - int off_x = floor(MAX2(ix, 0)); - int off_y = floor(MAX2(iy, 0)); + int off_x = floor(max_ff(ix, 0.0f)); + int off_y = floor(max_ff(iy, 0.0f)); /* The zoomed space coordinate of the raster position * (starting at the lower left most unclipped pixel). diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index ff53a6b9e92..60aad14efcf 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -36,6 +36,7 @@ #include "DNA_scene_types.h" #include "DNA_userdef_types.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" @@ -631,10 +632,8 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) max[0] = max[1] = 0.0f; for (sv = sc->vertbase.first; sv; sv = sv->next) { - min[0] = MIN2(min[0], sv->vec.x); - min[1] = MIN2(min[1], sv->vec.y); - max[0] = MAX2(max[0], sv->vec.x); - max[1] = MAX2(max[1], sv->vec.y); + const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y}; + minmax_v2v2_v2(min, max, fv); } /* always make 0.0 left under */ |