Merging r50049 through r50076 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 21 Aug 2012 10:44:04 +0000 (10:44 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 21 Aug 2012 10:44:04 +0000 (10:44 +0000)
115 files changed:
build_files/scons/tools/btools.py
intern/cycles/CMakeLists.txt
intern/guardedalloc/MEM_guardedalloc.h
intern/guardedalloc/intern/mallocn.c
source/blender/blenfont/intern/blf_dir.c
source/blender/blenfont/intern/blf_font.c
source/blender/blenfont/intern/blf_glyph.c
source/blender/blenkernel/BKE_colortools.h
source/blender/blenkernel/BKE_font.h
source/blender/blenkernel/BKE_mask.h
source/blender/blenkernel/BKE_packedFile.h
source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/font.c
source/blender/blenkernel/intern/mask.c
source/blender/blenkernel/intern/mask_rasterize.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/seqcache.c
source/blender/blenkernel/intern/texture.c
source/blender/blenlib/BLI_rect.h
source/blender/blenlib/BLI_vfontdata.h
source/blender/blenlib/intern/freetypefont.c
source/blender/blenlib/intern/rct.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_250.c
source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
source/blender/compositor/operations/COM_ColorCurveOperation.cpp
source/blender/compositor/operations/COM_ColorCurveOperation.h
source/blender/compositor/operations/COM_DilateErodeOperation.cpp
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/gpencil/gpencil_edit.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/include/ED_clip.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_ops.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_style.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/view2d.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/mask/mask_draw.c
source/blender/editors/mesh/editface.c
source/blender/editors/render/render_preview.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_action/action_draw.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_action/action_select.c
source/blender/editors/space_clip/clip_buttons.c
source/blender/editors/space_clip/clip_dopesheet_draw.c
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_clip/clip_editor.c
source/blender/editors/space_clip/clip_graph_ops.c
source/blender/editors/space_clip/clip_ops.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_console/space_console.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_graph/graph_draw.c
source/blender/editors/space_graph/graph_select.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_image/image_edit.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_logic/logic_buttons.c
source/blender/editors/space_nla/nla_edit.c
source/blender/editors/space_nla/nla_select.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_view.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_time/time_ops.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/makesdna/DNA_color_types.h
source/blender/makesdna/DNA_vfont_types.h
source/blender/makesrna/intern/rna_color.c
source/blender/nodes/SConscript
source/blender/nodes/composite/nodes/node_composite_alphaOver.c
source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
source/blender/nodes/composite/nodes/node_composite_blur.c
source/blender/nodes/composite/nodes/node_composite_brightness.c
source/blender/nodes/composite/nodes/node_composite_colorSpill.c
source/blender/nodes/composite/nodes/node_composite_composite.c
source/blender/nodes/composite/nodes/node_composite_keying.c
source/blender/nodes/composite/nodes/node_composite_keyingscreen.c
source/blender/nodes/composite/nodes/node_composite_mask.c
source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
source/blender/nodes/composite/nodes/node_composite_outputFile.c
source/blender/nodes/composite/nodes/node_composite_splitViewer.c
source/blender/nodes/composite/nodes/node_composite_viewer.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/render_result.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_gesture.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_playanim.c
source/blender/windowmanager/intern/wm_subwindow.c
source/blender/windowmanager/intern/wm_window.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp

index dbec5b3ba6c5c039dc3c1357d610bab41ebc0e01..633492ba0eeb6db871fa134946bf4590af0980e5 100644 (file)
@@ -108,7 +108,7 @@ def validate_arguments(args, bc):
             'WITH_BF_STATICFFMPEG', 'BF_FFMPEG_LIB_STATIC',
             'WITH_BF_OGG', 'BF_OGG', 'BF_OGG_LIB',
             'WITH_BF_FRAMESERVER',
-            'WITH_BF_COMPOSITOR',
+            'WITH_BF_COMPOSITOR', 'WITH_BF_COMPOSITOR_LEGACY',
             'WITH_BF_JPEG', 'BF_JPEG', 'BF_JPEG_INC', 'BF_JPEG_LIB', 'BF_JPEG_LIBPATH',
             'WITH_BF_OPENJPEG', 'BF_OPENJPEG', 'BF_OPENJPEG_INC', 'BF_OPENJPEG_LIB', 'BF_OPENJPEG_LIBPATH',
             'WITH_BF_REDCODE', 'BF_REDCODE', 'BF_REDCODE_INC', 'BF_REDCODE_LIB', 'BF_REDCODE_LIBPATH',
@@ -592,7 +592,8 @@ def read_opts(env, cfg, args):
         ('BF_BOOST_LIBPATH', 'Boost library path', ''),
         ('BF_BOOST_LIB_STATIC', 'Boost static library', ''),
 
-        (BoolVariable('WITH_GHOST_XDND', 'Build with drag-n-drop support on Linux platforms using XDND protocol', True))
+        (BoolVariable('WITH_GHOST_XDND', 'Build with drag-n-drop support on Linux platforms using XDND protocol', True)),
+        (BoolVariable('WITH_BF_COMPOSITOR_LEGACY', 'Enable the legacy compositor', True))
     ) # end of opts.AddOptions()
 
     return localopts
index 2127ad23bd3c2b6cd986f31fc2f0351c7d4dfcf7..697427081c3274d146b9523c44ee08a6231d4d20 100644 (file)
@@ -63,7 +63,6 @@ include_directories(
 # Subdirectories
 
 if(WITH_CYCLES_BLENDER)
-       add_definitions(-DBLENDER_PLUGIN)
        add_subdirectory(blender)
 endif()
 
index 149483e719f82e00aa2e34fefdee67d31f51c6ff..6973c19dea99018e1431329769645a95077425d8 100644 (file)
@@ -92,7 +92,7 @@ extern "C" {
        /**
         * Duplicates a block of memory, and returns a pointer to the
         * newly allocated block.  */
-       void *MEM_dupallocN(void *vmemh)
+       void *MEM_dupallocN(const void *vmemh)
 #if MEM_GNU_ATTRIBUTES
        __attribute__((warn_unused_result))
 #endif
index df6f4d59c7f5de08262cb261fb8601c23f848793..a65871f4410cbed7efaa717c3d2b7cc5562a2690 100644 (file)
@@ -248,12 +248,12 @@ size_t MEM_allocN_len(const void *vmemh)
        }
 }
 
-void *MEM_dupallocN(void *vmemh)
+void *MEM_dupallocN(const void *vmemh)
 {
        void *newp = NULL;
        
        if (vmemh) {
-               MemHead *memh = vmemh;
+               const MemHead *memh = vmemh;
                memh--;
 
 #ifndef DEBUG_MEMDUPLINAME
index 4fde9fe67871529185069a0ad4cb8af8f37d72ca..da9160673025483b2f73263cf3e56b158e107bbf 100644 (file)
 
 #include "BKE_utildefines.h"
 
-#include "BLI_blenlib.h"
+#include "BLI_fileops.h"
+#include "BLI_listbase.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
 
 #include "BIF_gl.h"
 
index dcefcc68d23cf58a4bd8f6510052879edf972fff..d47fa5383d44daa298e0f68413ba44d76e4489d6 100644 (file)
 
 #include "DNA_vec_types.h"
 
-
-#include "BLI_blenlib.h"
-#include "BLI_linklist.h"  /* linknode */
+#include "BLI_listbase.h"
 #include "BLI_math.h"
+#include "BLI_rect.h"
+#include "BLI_string.h"
+#include "BLI_string_utf8.h"
+#include "BLI_linklist.h"  /* linknode */
 
 #include "BIF_gl.h"
 #include "BLF_api.h"
@@ -152,7 +154,7 @@ static void blf_font_ensure_ascii_table(FontBLF *font)
                                   _kern_mode,                                           \
                                   &(_delta)) == 0)                                      \
                {                                                                        \
-                       _pen_x += delta.x >> 6;                                              \
+                       _pen_x += _delta.x >> 6;                                             \
                }                                                                        \
        }                                                                            \
 } (void)0
@@ -229,9 +231,9 @@ void blf_font_buffer(FontBLF *font, const char *str)
        FontBufInfoBLF *buf_info = &font->buf_info;
        float b_col_float[4];
        const unsigned char b_col_char[4] = {buf_info->col[0] * 255,
-                                                                                buf_info->col[1] * 255,
-                                                                                buf_info->col[2] * 255,
-                                                                                buf_info->col[3] * 255};
+                                            buf_info->col[1] * 255,
+                                            buf_info->col[2] * 255,
+                                            buf_info->col[3] * 255};
 
        unsigned char *cbuf;
        int chx, chy;
@@ -242,7 +244,7 @@ void blf_font_buffer(FontBLF *font, const char *str)
 
        blf_font_ensure_ascii_table(font);
 
-       /* another buffer spesific call for color conversion */
+       /* another buffer specific call for color conversion */
        if (buf_info->do_color_management) {
                srgb_to_linearrgb_v4(b_col_float, buf_info->col);
        }
@@ -425,8 +427,8 @@ void blf_font_width_and_height(FontBLF *font, const char *str, float *width, flo
        }
 
        blf_font_boundbox(font, str, &box);
-       *width = ((box.xmax - box.xmin) * xa);
-       *height = ((box.ymax - box.ymin) * ya);
+       *width  = (BLI_RCT_SIZE_X(&box) * xa);
+       *height = (BLI_RCT_SIZE_Y(&box) * ya);
 }
 
 float blf_font_width(FontBLF *font, const char *str)
@@ -440,7 +442,7 @@ float blf_font_width(FontBLF *font, const char *str)
                xa = 1.0f;
 
        blf_font_boundbox(font, str, &box);
-       return (box.xmax - box.xmin) * xa;
+       return BLI_RCT_SIZE_X(&box) * xa;
 }
 
 float blf_font_height(FontBLF *font, const char *str)
index 39945bf19b0e03a0a19db2c53ad621a05b388bee..302edd8d5330b8bb19abe8d579e9a124dfc339f2 100644 (file)
@@ -46,7 +46,8 @@
 #include "DNA_vec_types.h"
 #include "DNA_userdef_types.h"
 
-#include "BLI_blenlib.h"
+#include "BLI_listbase.h"
+#include "BLI_rect.h"
 
 #include "BIF_gl.h"
 #include "BLF_api.h"
@@ -314,13 +315,14 @@ static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, floa
 
 static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
 {
-       float soft[25] = {1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f,
-                         1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
-                         2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f,
-                         1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
-                         1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f};
+       const float soft[25] = {1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f,
+                               1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
+                               2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f,
+                               1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
+                               1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f};
        
-       float color[4], *fp = soft;
+       const float *fp = soft;
+       float color[4];
        int dx, dy;
 
        color[0] = shadow_col[0];
@@ -340,11 +342,12 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x
 
 static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2)
 {
-       float soft[9] = {1 / 16.0f, 2 / 16.0f, 1 / 16.0f,
-                        2 / 16.0f, 4 / 16.0f, 2 / 16.0f,
-                        1 / 16.0f, 2 / 16.0f, 1 / 16.0f};
+       const float soft[9] = {1 / 16.0f, 2 / 16.0f, 1 / 16.0f,
+                              2 / 16.0f, 4 / 16.0f, 2 / 16.0f,
+                              1 / 16.0f, 2 / 16.0f, 1 / 16.0f};
 
-       float color[4], *fp = soft;
+       const float *fp = soft;
+       float color[4];
        int dx, dy;
 
        color[0] = shadow_col[0];
@@ -412,7 +415,7 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y)
                g->uv[1][1] = ((float)(g->yoff + g->height)) / ((float)gc->p2_height);
 
                /* update the x offset for the next glyph. */
-               gc->x_offs += (int)(g->box.xmax - g->box.xmin + gc->pad);
+               gc->x_offs += (int)(BLI_RCT_SIZE_X(&g->box) + gc->pad);
 
                gc->rem_glyphs--;
                g->build_tex = 1;
index 22ad123866ccdc0ab5be3e4872302b129646076d..1e05c759ea72d4eb30c80ba5826e3d9564b53594 100644 (file)
@@ -56,12 +56,13 @@ void                curvemapping_free_data(struct CurveMapping *cumap);
 void                curvemapping_free(struct CurveMapping *cumap);
 void                curvemapping_copy_data(struct CurveMapping *target, struct CurveMapping *cumap);
 struct CurveMapping *curvemapping_copy(struct CurveMapping *cumap);
+void                curvemapping_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3]);
 void                curvemapping_set_black_white(struct CurveMapping *cumap, const float black[3], const float white[3]);
 
 #define CURVEMAP_SLOPE_NEGATIVE 0
 #define CURVEMAP_SLOPE_POSITIVE 1
 void                    curvemap_reset(struct CurveMap *cuma, struct rctf *clipr, int preset, int slope);
-void                    curvemap_remove(struct CurveMap *cuma, int flag);
+void                    curvemap_remove(struct CurveMap *cuma, const short flag);
 void                    curvemap_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp);
 struct CurveMapPoint    *curvemap_insert(struct CurveMap *cuma, float x, float y);
 void                    curvemap_sethandle(struct CurveMap *cuma, int type);
@@ -76,6 +77,8 @@ float               curvemapping_evaluateF(struct CurveMapping *cumap, int cur,
 void                curvemapping_evaluate3F(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
 void                curvemapping_evaluateRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
 void                curvemapping_evaluate_premulRGB(struct CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3]);
+void                curvemapping_evaluate_premulRGBF_ex(struct CurveMapping *cumap, float vecout[3], const float vecin[3],
+                                                        const float black[3], const float bwmul[3]);
 void                curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
 void                curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBuf *ibuf);
 void                curvemapping_premultiply(struct CurveMapping *cumap, int restore);
index 938a13483d548264afa24a456f52b6e2912fab80..cd52dd75f26e91c712a29b297912ba2f3bca38b6 100644 (file)
@@ -76,13 +76,9 @@ void BKE_vfont_builtin_register(void *mem, int size);
 
 void BKE_vfont_free_data(struct VFont *vfont);
 void BKE_vfont_free(struct VFont *sc); 
-void BKE_vfont_free_global_ttf(void);
 struct VFont *BKE_vfont_builtin_get(void);
 struct VFont *BKE_vfont_load(struct Main *bmain, const char *name);
 
-struct TmpFont *BKE_vfont_tmpfont_find(struct VFont *vfont);
-void            BKE_vfont_tmpfont_remove(struct VFont *vfont);
-
 struct CharTrans *BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode);
 
 int BKE_vfont_select_get(struct Object *ob, int *start, int *end);
index 1836a88555be639080f85b076e3ef90bcac4bdaa..b46aefe4e985f7319ad323b91ee35b57a4a42b46 100644 (file)
@@ -74,10 +74,12 @@ float (*BKE_mask_spline_feather_differentiated_points(struct MaskSpline *spline,
 
 float (*BKE_mask_spline_differentiate_with_resolution_ex(struct MaskSpline *spline, int *tot_diff_point,
                                                          const unsigned int resol))[2];
+void    BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point);
 float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_diff_point))[2];
 float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(struct MaskSpline *spline, int *tot_feather_point,
-                                                                         const unsigned int resol))[2];
-float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height, int *tot_feather_point))[2];
+                                                                         const unsigned int resol, const int do_feather_isect))[2];
+float (*BKE_mask_spline_feather_differentiated_points_with_resolution(struct MaskSpline *spline, int width, int height,
+                                                                      int *tot_feather_point, const int do_feather_isect))[2];
 
 float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2];
 
index 1891840f497edc246bc04561c1c0a0fcc43bf945..ecbd2e7536bbec503ab9f8191be3a7dfe05d29cb 100644 (file)
@@ -43,6 +43,7 @@ struct ReportList;
 struct VFont;
 
 /* pack */
+struct PackedFile *dupPackedFileMemory(const struct PackedFile *pf_src);
 struct PackedFile *newPackedFile(struct ReportList *reports, const char *filename, const char *relabase);
 struct PackedFile *newPackedFileMemory(void *mem, int memlen);
 
index e79644da9672e2787735db1bca71e4026ab6481e..76a0e9c2880fbd37ec8182db52a1d58f59a4b35d 100644 (file)
@@ -246,6 +246,7 @@ void BKE_sequencer_cache_cleanup_sequence(struct Sequence *seq);
 
 struct ImBuf *BKE_sequencer_preprocessed_cache_get(SeqRenderData context, struct Sequence *seq, float cfra, seq_stripelem_ibuf_t type);
 void BKE_sequencer_preprocessed_cache_put(SeqRenderData context, struct Sequence *seq, float cfra, seq_stripelem_ibuf_t type, struct ImBuf *ibuf);
+void BKE_sequencer_preprocessed_cache_cleanup(void);
 void BKE_sequencer_preprocessed_cache_cleanup_sequence(struct Sequence *seq);
 
 /* **********************************************************************
index 468861242d0e03416deb6f612fdc798e653a3972..fc4df9594f30b583f074af3d8ca3542accd5cb63 100644 (file)
@@ -421,7 +421,7 @@ void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/ int preset)
 
        b->curve->preset = preset;
        curvemap_reset(cm, &b->curve->clipr, b->curve->preset, CURVEMAP_SLOPE_NEGATIVE);
-       curvemapping_changed(b->curve, 0);
+       curvemapping_changed(b->curve, FALSE);
 }
 
 int BKE_brush_texture_set_nr(Brush *brush, int nr)
index 3b24ac0f856e19c7cd40d0dfbece5b730f238f79..0df27532af2b7860a2b44404dcff2c4d9c052cc4 100644 (file)
@@ -146,21 +146,31 @@ CurveMapping *curvemapping_copy(CurveMapping *cumap)
        return NULL;
 }
 
-void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3])
+void curvemapping_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3])
 {
        int a;
-       
-       if (white)
+
+       for (a = 0; a < 3; a++) {
+               const float delta = white[a] - black[a];
+               if (delta != 0.0f) {
+                       r_bwmul[a] = 1.0f / delta;
+               }
+               else {
+                       r_bwmul[a] = 0.0f;
+               }
+       }
+}
+
+void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3])
+{
+       if (white) {
                copy_v3_v3(cumap->white, white);
-       if (black)
+       }
+       if (black) {
                copy_v3_v3(cumap->black, black);
-       
-       for (a = 0; a < 3; a++) {
-               if (cumap->white[a] == cumap->black[a])
-                       cumap->bwmul[a] = 0.0f;
-               else
-                       cumap->bwmul[a] = 1.0f / (cumap->white[a] - cumap->black[a]);
-       }       
+       }
+
+       curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul);
 }
 
 /* ***************** operations on single curve ************* */
@@ -193,7 +203,7 @@ void curvemap_remove_point(CurveMap *cuma, CurveMapPoint *point)
 }
 
 /* removes with flag set */
-void curvemap_remove(CurveMap *cuma, int flag)
+void curvemap_remove(CurveMap *cuma, const short flag)
 {
        CurveMapPoint *cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points");
        int a, b, removed = 0;
@@ -702,12 +712,12 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles)
                        dy = cmp[a].y - cmp[a + 1].y;
                        if (sqrtf(dx * dx + dy * dy) < thresh) {
                                if (a == 0) {
-                                       cmp[a + 1].flag |= 2;
+                                       cmp[a + 1].flag |= CUMA_VECTOR;
                                        if (cmp[a + 1].flag & CUMA_SELECT)
                                                cmp[a].flag |= CUMA_SELECT;
                                }
                                else {
-                                       cmp[a].flag |= 2;
+                                       cmp[a].flag |= CUMA_VECTOR;
                                        if (cmp[a].flag & CUMA_SELECT)
                                                cmp[a + 1].flag |= CUMA_SELECT;
                                }
@@ -727,7 +737,7 @@ void curvemapping_changed_all(CurveMapping *cumap)
        for (a = 0; a < CM_TOT; a++) {
                if (cumap->cm[a].curve) {
                        cumap->cur = a;
-                       curvemapping_changed(cumap, 0);
+                       curvemapping_changed(cumap, FALSE);
                }
        }
 
@@ -786,20 +796,29 @@ void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float
        vecout[2] = curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2]));
 }
 
+/** same as #curvemapping_evaluate_premulRGBF
+ * but black/bwmul are passed as args for the compositor
+ * where they can change per pixel.
+ *
+ * Use in conjunction with #curvemapping_set_black_white_ex
+ *
+ * \param black Use instead of cumap->black
+ * \param bwmul Use instead of cumap->bwmul
+ */
+void curvemapping_evaluate_premulRGBF_ex(CurveMapping *cumap, float vecout[3], const float vecin[3],
+                                         const float black[3], const float bwmul[3])
+{
+       vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - black[0]) * bwmul[0]);
+       vecout[1] = curvemap_evaluateF(&cumap->cm[1], (vecin[1] - black[1]) * bwmul[1]);
+       vecout[2] = curvemap_evaluateF(&cumap->cm[2], (vecin[2] - black[2]) * bwmul[2]);
+}
 
 /* RGB with black/white points and premult. tables are checked */
 void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3])
 {
-       float fac;
-       
-       fac = (vecin[0] - cumap->black[0]) * cumap->bwmul[0];
-       vecout[0] = curvemap_evaluateF(cumap->cm, fac);
-       
-       fac = (vecin[1] - cumap->black[1]) * cumap->bwmul[1];
-       vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac);
-       
-       fac = (vecin[2] - cumap->black[2]) * cumap->bwmul[2];
-       vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac);
+       vecout[0] = curvemap_evaluateF(&cumap->cm[0], (vecin[0] - cumap->black[0]) * cumap->bwmul[0]);
+       vecout[1] = curvemap_evaluateF(&cumap->cm[1], (vecin[1] - cumap->black[1]) * cumap->bwmul[1]);
+       vecout[2] = curvemap_evaluateF(&cumap->cm[2], (vecin[2] - cumap->black[2]) * cumap->bwmul[2]);
 }
 
 /* same as above, byte version */
index 49c3d77a527cdabe42863e0e7bf2ffe7eb0e5a44..8689d6648a9a52d0821955851766860825e44e1c 100644 (file)
 #include "BKE_curve.h"
 #include "BKE_displist.h"
 
-static ListBase ttfdata = {NULL, NULL};
+//static ListBase ttfdata = {NULL, NULL};
 
 /* The vfont code */
-
 void BKE_vfont_free_data(struct VFont *vfont)
 {
        if (vfont->data) {
@@ -83,7 +82,10 @@ void BKE_vfont_free_data(struct VFont *vfont)
                vfont->data = NULL;
        }
 
-       BKE_vfont_tmpfont_remove(vfont);
+       if (vfont->temp_pf) {
+               freePackedFile(vfont->temp_pf);  /* NULL when the font file can't be found on disk */
+               vfont->temp_pf = NULL;
+       }
 }
 
 void BKE_vfont_free(struct VFont *vf)
@@ -91,7 +93,7 @@ void BKE_vfont_free(struct VFont *vf)
        if (vf == NULL) return;
 
        BKE_vfont_free_data(vf);
-       
+
        if (vf->packedfile) {
                freePackedFile(vf->packedfile);
                vf->packedfile = NULL;
@@ -128,63 +130,11 @@ static PackedFile *get_builtin_packedfile(void)
        }
 }
 
-static void vfont_tmpfont_free(struct TmpFont *tf)
-{
-       if (tf->pf) {
-               freePackedFile(tf->pf);  /* NULL when the font file can't be found on disk */
-       }
-       MEM_freeN(tf);
-}
-
-void BKE_vfont_free_global_ttf(void)
-{
-       struct TmpFont *tf, *tf_next;
-
-       for (tf = ttfdata.first; tf; tf = tf_next) {
-               tf_next = tf->next;
-               vfont_tmpfont_free(tf);
-       }
-       ttfdata.first = ttfdata.last = NULL;
-}
-
-struct TmpFont *BKE_vfont_tmpfont_find(VFont *vfont)
-{
-       struct TmpFont *tmpfnt = NULL;
-       
-       if (vfont == NULL) return NULL;
-       
-       /* Try finding the font from font list */
-       for (tmpfnt = ttfdata.first; tmpfnt; tmpfnt = tmpfnt->next) {
-               if (tmpfnt->vfont == vfont) {
-                       break;
-               }
-       }
-
-       return tmpfnt;
-}
-
-/* assumes a VFont's tmpfont can't be in the database more then once */
-void BKE_vfont_tmpfont_remove(VFont *vfont)
-{
-       struct TmpFont *tmpfnt;
-
-       tmpfnt = BKE_vfont_tmpfont_find(vfont);
-
-       if (tmpfnt) {
-               vfont_tmpfont_free(tmpfnt);
-               BLI_remlink(&ttfdata, tmpfnt);
-       }
-}
-
 static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
 {
-       struct TmpFont *tmpfnt = NULL;
-       PackedFile *tpf;
-       
-       if (vfont == NULL) return NULL;
-       
-       /* Try finding the font from font list */
-       tmpfnt = BKE_vfont_tmpfont_find(vfont);
+       if (vfont == NULL) {
+               return NULL;
+       }
 
        /* And then set the data */
        if (!vfont->data) {
@@ -198,30 +148,15 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
                                pf = vfont->packedfile;
 
                                /* We need to copy a tmp font to memory unless it is already there */
-                               if (!tmpfnt) {
-                                       tpf = MEM_callocN(sizeof(*tpf), "PackedFile");
-                                       tpf->data = MEM_mallocN(pf->size, "packFile");
-                                       tpf->size = pf->size;
-                                       memcpy(tpf->data, pf->data, pf->size);
-
-                                       /* Add temporary packed file to globals */
-                                       tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
-                                       tmpfnt->pf = tpf;
-                                       tmpfnt->vfont = vfont;
-                                       BLI_addtail(&ttfdata, tmpfnt);
+                               if (vfont->temp_pf == NULL) {
+                                       vfont->temp_pf = dupPackedFileMemory(pf);
                                }
                        }
                        else {
                                pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));
 
-                               if (!tmpfnt) {
-                                       tpf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));
-
-                                       /* Add temporary packed file to globals */
-                                       tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
-                                       tmpfnt->pf = tpf;
-                                       tmpfnt->vfont = vfont;
-                                       BLI_addtail(&ttfdata, tmpfnt);
+                               if (vfont->temp_pf == NULL) {
+                                       vfont->temp_pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));
                                }
                        }
                        if (!pf) {
@@ -252,9 +187,8 @@ VFont *BKE_vfont_load(Main *bmain, const char *name)
        char filename[FILE_MAXFILE];
        VFont *vfont = NULL;
        PackedFile *pf;
-       PackedFile *tpf = NULL; 
+       PackedFile *temp_pf = NULL;
        int is_builtin;
-       struct TmpFont *tmpfnt;
        
        if (strcmp(name, FO_BUILTIN_NAME) == 0) {
                BLI_strncpy(filename, name, sizeof(filename));
@@ -269,7 +203,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *name)
                BLI_splitdirstring(dir, filename);
 
                pf = newPackedFile(NULL, name, bmain->name);
-               tpf = newPackedFile(NULL, name, bmain->name);
+               temp_pf = newPackedFile(NULL, name, bmain->name);
                
                is_builtin = FALSE;
        }
@@ -295,10 +229,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *name)
 
                        /* Do not add FO_BUILTIN_NAME to temporary listbase */
                        if (strcmp(filename, FO_BUILTIN_NAME)) {
-                               tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
-                               tmpfnt->pf = tpf;
-                               tmpfnt->vfont = vfont;
-                               BLI_addtail(&ttfdata, tmpfnt);
+                               vfont->temp_pf = temp_pf;
                        }
                }
 
@@ -324,7 +255,7 @@ static VFont *which_vfont(Curve *cu, CharInfo *info)
                        if (cu->vfontbi) return(cu->vfontbi); else return(cu->vfont);
                default:
                        return(cu->vfont);
-       }                       
+       }
 }
 
 VFont *BKE_vfont_builtin_get(void)
@@ -344,6 +275,7 @@ static VChar *find_vfont_char(VFontData *vfd, intptr_t character)
 {
        VChar *che = NULL;
 
+       /* TODO: use ghash */
        for (che = vfd->characters.first; che; che = che->next) {
                if (che->index == character)
                        break;
index 3c46e7bcd47537c31fd674085e81951c20dd0ab0..1e1cbf8610edb7ae9cd58b61ede5efec901a1c3a 100644 (file)
@@ -559,7 +559,7 @@ static void feather_bucket_get_diagonal(FeatherEdgesBucket *buckets, int start_b
        *diagonal_bucket_b_r = &buckets[diagonal_bucket_b_index];
 }
 
-static void spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], int tot_feather_point)
+void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feather_points)[2], const int tot_feather_point)
 {
 #define BUCKET_INDEX(co) \
        feather_bucket_index_from_coord(co, min, bucket_scale, buckets_per_side)
@@ -721,7 +721,8 @@ static void spline_feather_collapse_inner_loops(MaskSpline *spline, float (*feat
  */
 float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpline *spline,
                                                                          int *tot_feather_point,
-                                                                         const unsigned int resol
+                                                                         const unsigned int resol,
+                                                                         const int do_feather_isect
                                                                          ))[2]
 {
        MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
@@ -783,23 +784,24 @@ float (*BKE_mask_spline_feather_differentiated_points_with_resolution_ex(MaskSpl
 
        *tot_feather_point = tot;
 
-       if (spline->flag & MASK_SPLINE_NOINTERSECT)
-               spline_feather_collapse_inner_loops(spline, feather, tot);
+       if ((spline->flag & MASK_SPLINE_NOINTERSECT) && do_feather_isect) {
+               BKE_mask_spline_feather_collapse_inner_loops(spline, feather, tot);
+       }
 
        return feather;
 }
 
 float (*BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, int width, int height,
-                                                                      int *tot_feather_point))[2]
+                                                                      int *tot_feather_point, const int do_feather_isect))[2]
 {
        unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height);
 
-       return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol);
+       return BKE_mask_spline_feather_differentiated_points_with_resolution_ex(spline, tot_feather_point, resol, do_feather_isect);
 }
 
 float (*BKE_mask_spline_feather_differentiated_points(MaskSpline *spline, int *tot_feather_point))[2]
 {
-       return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point);
+       return BKE_mask_spline_feather_differentiated_points_with_resolution(spline, 0, 0, tot_feather_point, TRUE);
 }
 
 float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point))[2]
index 1fde1168999f38c6a2837c83b28c8081c1644a43..d39be3b8ed62679f3f0672b850d1a92e48c2bdcf 100644 (file)
@@ -370,8 +370,8 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
 {
        MemArena *arena = BLI_memarena_new(1 << 16, __func__);
 
-       const float bucket_dim_x = layer->bounds.xmax - layer->bounds.xmin;
-       const float bucket_dim_y = layer->bounds.ymax - layer->bounds.ymin;
+       const float bucket_dim_x = BLI_RCT_SIZE_X(&layer->bounds);
+       const float bucket_dim_y = BLI_RCT_SIZE_Y(&layer->bounds);
 
        layer->buckets_x = (bucket_dim_x / pixel_size) / (float)BUCKET_PIXELS_PER_CELL;
        layer->buckets_y = (bucket_dim_y / pixel_size) / (float)BUCKET_PIXELS_PER_CELL;
@@ -575,6 +575,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
                        int tot_diff_point;
 
                        float (*diff_feather_points)[2];
+                       float (*diff_feather_points_flip)[2];
                        int tot_diff_feather_points;
 
                        const unsigned int resol_a = BKE_mask_spline_resolution(spline, width, height) / 4;
@@ -586,7 +587,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
 
                        if (do_feather) {
                                diff_feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution_ex(
-                                                         spline, &tot_diff_feather_points, resol);
+                                                         spline, &tot_diff_feather_points, resol, FALSE);
                                BLI_assert(diff_feather_points);
                        }
                        else {
@@ -649,6 +650,11 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
                                }
 
                                if (is_fill) {
+                                       /* applt intersections depending on fill settings */
+                                       if (spline->flag & MASK_SPLINE_NOINTERSECT) {
+                                               BKE_mask_spline_feather_collapse_inner_loops(spline, diff_feather_points, tot_diff_feather_points);
+                                       }
+
                                        copy_v2_v2(co, diff_points[0]);
                                        sf_vert_prev = BLI_scanfill_vert_add(&sf_ctx, co);
                                        sf_vert_prev->tmp.u = sf_vert_tot;
@@ -710,11 +716,27 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
                                        /* unfilled spline */
                                        if (diff_feather_points) {
 
-                                               float co_diff[3];
+                                               float co_diff[2];
 
                                                float co_feather[3];
                                                co_feather[2] = 1.0f;
 
+                                               if (spline->flag & MASK_SPLINE_NOINTERSECT) {
+                                                       diff_feather_points_flip = MEM_mallocN(sizeof(float) * 2 * tot_diff_feather_points, "diff_feather_points_flip");
+
+                                                       for (j = 0; j < tot_diff_point; j++) {
+                                                               sub_v2_v2v2(co_diff, diff_points[j], diff_feather_points[j]);
+                                                               add_v2_v2v2(diff_feather_points_flip[j], diff_points[j], co_diff);
+                                                       }
+
+                                                       BKE_mask_spline_feather_collapse_inner_loops(spline, diff_feather_points,      tot_diff_feather_points);
+                                                       BKE_mask_spline_feather_collapse_inner_loops(spline, diff_feather_points_flip, tot_diff_feather_points);
+                                               }
+                                               else {
+                                                       diff_feather_points_flip = NULL;
+                                               }
+
+
                                                open_spline_ranges[open_spline_index].vertex_offset = sf_vert_tot;
                                                open_spline_ranges[open_spline_index].vertex_total = tot_diff_point;
 
@@ -738,8 +760,14 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
 
 
                                                        /* feather vert B */
-                                                       sub_v2_v2v2(co_diff, co, co_feather);
-                                                       add_v2_v2v2(co_feather, co, co_diff);
+                                                       if (diff_feather_points_flip) {
+                                                               copy_v2_v2(co_feather, diff_feather_points_flip[j]);
+                                                       }
+                                                       else {
+                                                               sub_v2_v2v2(co_diff, co, co_feather);
+                                                               add_v2_v2v2(co_feather, co, co_diff);
+                                                       }
+
                                                        sf_vert = BLI_scanfill_vert_add(&sf_ctx, co_feather);
                                                        sf_vert->tmp.u = sf_vert_tot;
                                                        sf_vert->keyindex = SF_KEYINDEX_TEMP_ID;
@@ -752,6 +780,11 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas
                                                        tot_feather_quads -= 2;
                                                }
 
+                                               if (diff_feather_points_flip) {
+                                                       MEM_freeN(diff_feather_points_flip);
+                                                       diff_feather_points_flip = NULL;
+                                               }
+
                                                /* cap ends */
 
                                                /* dummy init value */
index f115a41d4192278d2935a92f0d935a75bc38583c..ed2f4af0c51dce00901324234db1408d89b0f41e 100644 (file)
@@ -158,7 +158,17 @@ void freePackedFile(PackedFile *pf)
        else
                printf("freePackedFile: Trying to free a NULL pointer\n");
 }
-       
+
+PackedFile *dupPackedFileMemory(const PackedFile *pf_src)
+{
+       PackedFile *pf_dst;
+
+       pf_dst       = MEM_dupallocN(pf_src);
+       pf_dst->data = MEM_dupallocN(pf_src->data);
+
+       return pf_dst;
+}
+
 PackedFile *newPackedFileMemory(void *mem, int memlen)
 {
        PackedFile *pf = MEM_callocN(sizeof(*pf), "PackedFile");
index 57db188472ceb2f071b6a4f260a4a9a902ae6c49..e3f0226c86368146105ecfb4aa2dac36f2d0e0e9 100644 (file)
@@ -68,7 +68,6 @@ static struct MovieCache *moviecache = NULL;
 static struct SeqPreprocessCache *preprocess_cache = NULL;
 
 static void preprocessed_cache_destruct(void);
-static void preprocessed_cache_clean(void);
 
 static int seq_cmp_render_data(const SeqRenderData *a, const SeqRenderData *b)
 {
@@ -193,7 +192,7 @@ void BKE_sequencer_cache_cleanup(void)
                moviecache = IMB_moviecache_create("seqcache", sizeof(SeqCacheKey), seqcache_hashhash, seqcache_hashcmp);
        }
 
-       preprocessed_cache_clean();
+       BKE_sequencer_preprocessed_cache_cleanup();
 }
 
 static int seqcache_key_check_seq(void *userkey, void *userdata)
@@ -246,7 +245,7 @@ void BKE_sequencer_cache_put(SeqRenderData context, Sequence *seq, float cfra, s
        IMB_moviecache_put(moviecache, &key, i);
 }
 
-static void preprocessed_cache_clean(void)
+void BKE_sequencer_preprocessed_cache_cleanup(void)
 {
        SeqPreprocessCacheElem *elem;
 
@@ -266,7 +265,7 @@ static void preprocessed_cache_destruct(void)
        if (!preprocess_cache)
                return;
 
-       preprocessed_cache_clean();
+       BKE_sequencer_preprocessed_cache_cleanup();
 
        MEM_freeN(preprocess_cache);
        preprocess_cache = NULL;
@@ -308,7 +307,7 @@ void BKE_sequencer_preprocessed_cache_put(SeqRenderData context, Sequence *seq,
        }
        else {
                if (preprocess_cache->cfra != cfra)
-                       preprocessed_cache_clean();
+                       BKE_sequencer_preprocessed_cache_cleanup();
        }
 
        elem = MEM_callocN(sizeof(SeqPreprocessCacheElem), "sequencer preprocessed cache element");
index 5bad69c2e8dbd56c46015a61b52dcf607e7027ce..2f54fe6cebd79ba7caa96a1793f39d7c56aa4253 100644 (file)
@@ -1292,7 +1292,7 @@ PointDensity *BKE_add_pointdensity(void)
        pd->falloff_curve->preset = CURVE_PRESET_LINE;
        pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
        curvemap_reset(pd->falloff_curve->cm, &pd->falloff_curve->clipr, pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
-       curvemapping_changed(pd->falloff_curve, 0);
+       curvemapping_changed(pd->falloff_curve, FALSE);
 
        return pd;
 } 
index d6579afcd0d11ebfcf8219384342d97ccff21c58..43639b141e1940ce1a640404ed0a42deee2ec384 100644 (file)
@@ -75,6 +75,15 @@ void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src);
 void print_rctf(const char *str, const struct rctf *rect);
 void print_rcti(const char *str, const struct rcti *rect);
 
+#define BLI_RCT_SIZE_X(rct)       ((rct)->xmax - (rct)->xmin)
+#define BLI_RCT_SIZE_Y(rct)       ((rct)->ymax - (rct)->ymin)
+
+#define BLI_RCT_CENTER_X(rct)     (((rct)->xmin + (rct)->xmax) / 2)
+#define BLI_RCT_CENTER_Y(rct)     (((rct)->ymin + (rct)->ymax) / 2)
+
+#define BLI_RCT_CENTER_X_FL(rct)  ((float)((rct)->xmin + (rct)->xmax) / 2.0f)
+#define BLI_RCT_CENTER_Y_FL(rct)  ((float)((rct)->ymin + (rct)->ymax) / 2.0f)
+
 #ifdef __cplusplus
 }
 #endif
index a63ec8e9f61568fd02ee1f6309554486fb911750..ed7d10ab257c2941c8f659f78382f886ceb05dcf 100644 (file)
 struct PackedFile;
 struct VFont;
 
-#define MAX_VF_CHARS 256
-
 typedef struct VFontData {
        ListBase characters;
-       // ListBase nurbsbase[MAX_VF_CHARS];
-       // float            resol[MAX_VF_CHARS];
-       // float            width[MAX_VF_CHARS];
-       // float            *points[MAX_VF_CHARS];
        char name[128];
 } VFontData;
 
@@ -59,12 +53,6 @@ typedef struct VChar {
        float           *points;
 } VChar;
 
-struct TmpFont {
-       struct TmpFont *next, *prev;
-       struct PackedFile *pf;
-       struct VFont *vfont;
-};
-
 /**
  * Construct a new VFontData structure from 
  * Freetype font data in a PackedFile.
index 60999e76c47333441880dfcd025626cef72bcbd0..597a645eb9cd2da328e2b8ba1784eff620d4585e 100644 (file)
@@ -293,19 +293,12 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode)
 {
        /* Freetype2 */
        FT_Face face;
-       struct TmpFont *tf;
-
-       /* Find the correct FreeType font */
-       tf = BKE_vfont_tmpfont_find(vfont);
-
-       /* What, no font found. Something strange here */
-       if (!tf) return FALSE;
 
        /* Load the font to memory */
-       if (tf->pf) {
+       if (vfont->temp_pf) {
                err = FT_New_Memory_Face(library,
-                                        tf->pf->data,
-                                        tf->pf->size,
+                                        vfont->temp_pf->data,
+                                        vfont->temp_pf->size,
                                         0,
                                         &face);
                if (err) return FALSE;
index 9c65c26c72bfa2ff80b0aba09e1d6cdefeedbd74..92cbcd485b6f384001b2484064f3f6eae4940f4c 100644 (file)
@@ -252,8 +252,8 @@ void BLI_rctf_translate(rctf *rect, float x, float y)
 /* change width & height around the central location */
 void BLI_rcti_resize(rcti *rect, int x, int y)
 {
-       rect->xmin = rect->xmax = (rect->xmax + rect->xmin) / 2;
-       rect->ymin = rect->ymax = (rect->ymax + rect->ymin) / 2;
+       rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect);
+       rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect);
        rect->xmin -= x / 2;
        rect->ymin -= y / 2;
        rect->xmax = rect->xmin + x;
@@ -262,8 +262,8 @@ void BLI_rcti_resize(rcti *rect, int x, int y)
 
 void BLI_rctf_resize(rctf *rect, float x, float y)
 {
-       rect->xmin = rect->xmax = (rect->xmax + rect->xmin) * 0.5f;
-       rect->ymin = rect->ymax = (rect->ymax + rect->ymin) * 0.5f;
+       rect->xmin = rect->xmax = BLI_RCT_CENTER_X(rect);
+       rect->ymin = rect->ymax = BLI_RCT_CENTER_Y(rect);
        rect->xmin -= x * 0.5f;
        rect->ymin -= y * 0.5f;
        rect->xmax = rect->xmin + x;
@@ -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));
 }
index eb22b9a2e2e3d550129e04effeba583e7ae7aae8..719081e378d4432aafdbd2cf3cd3a3b9ca0eabd8 100644 (file)
@@ -2913,6 +2913,7 @@ static void lib_link_vfont(FileData *UNUSED(fd), Main *main)
 static void direct_link_vfont(FileData *fd, VFont *vf)
 {
        vf->data = NULL;
+       vf->temp_pf = NULL;
        vf->packedfile = direct_link_packedfile(fd, vf->packedfile);
 }
 
index d551caea425766f50df09a9286eaf9321b535706..ed5ffbf463ea7039a0c1d3fc7dcdb8230479594c 100644 (file)
@@ -2435,7 +2435,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
                                                tex->pd->falloff_curve->preset = CURVE_PRESET_LINE;
                                                tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
                                                curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
-                                               curvemapping_changed(tex->pd->falloff_curve, 0);
+                                               curvemapping_changed(tex->pd->falloff_curve, FALSE);
                                        }
                                }
                        }
index dfbbef8c56e3a0be0aa6ac8a9d392fff35c76089..aa4d0932c92ebd74df5afab7030cbfc8777902fb 100644 (file)
@@ -61,9 +61,9 @@ void ColorBalanceASCCDLOperation::executePixel(float output[4], float x, float y
        fac = min(1.0f, fac);
        const float mfac = 1.0f - fac;
        
-       output[0] = mfac * inputColor[0] + fac *colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]);
-       output[1] = mfac * inputColor[1] + fac *colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]);
-       output[2] = mfac * inputColor[2] + fac *colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]);
+       output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]);
+       output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]);
+       output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]);
        output[3] = inputColor[3];
 
 }
index 44784837301f5630e85f05d80fe5f974703e4fbc..81205514040853869e585150121ace85760e69da 100644 (file)
@@ -61,35 +61,39 @@ void ColorCurveOperation::initExecution()
 void ColorCurveOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
 {
        CurveMapping *cumap = this->m_curveMapping;
-       CurveMapping *workingCopy = (CurveMapping *)MEM_dupallocN(cumap);
        
-       float black[4];
-       float white[4];
        float fac[4];
        float image[4];
 
+       /* local versions of cumap->black, cumap->white, cumap->bwmul */
+       float black[4];
+       float white[4];
+       float bwmul[3];
+
        this->m_inputBlackProgram->read(black, x, y, sampler);
        this->m_inputWhiteProgram->read(white, x, y, sampler);
 
-       curvemapping_set_black_white(workingCopy, black, white);
+       /* get our own local bwmul value,
+        * since we can't be threadsafe and use cumap->bwmul & friends */
+       curvemapping_set_black_white_ex(black, white, bwmul);
 
        this->m_inputFacProgram->read(fac, x, y, sampler);
        this->m_inputImageProgram->read(image, x, y, sampler);
 
-       if (*fac >= 1.0f)
-               curvemapping_evaluate_premulRGBF(workingCopy, output, image);
+       if (*fac >= 1.0f) {
+               curvemapping_evaluate_premulRGBF_ex(cumap, output, image,
+                                                   black, bwmul);
+       }
        else if (*fac <= 0.0f) {
                copy_v3_v3(output, image);
        }
        else {
-               float col[4], mfac = 1.0f - *fac;
-               curvemapping_evaluate_premulRGBF(workingCopy, col, image);
-               output[0] = mfac * image[0] + *fac * col[0];
-               output[1] = mfac * image[1] + *fac * col[1];
-               output[2] = mfac * image[2] + *fac * col[2];
+               float col[4];
+               curvemapping_evaluate_premulRGBF_ex(cumap, col, image,
+                                                   black, bwmul);
+               interp_v3_v3v3(output, image, col, *fac);
        }
        output[3] = image[3];
-       MEM_freeN(workingCopy);
 }
 
 void ColorCurveOperation::deinitExecution()
@@ -131,21 +135,19 @@ void ConstantLevelColorCurveOperation::executePixel(float output[4], float x, fl
        float fac[4];
        float image[4];
 
-
        this->m_inputFacProgram->read(fac, x, y, sampler);
        this->m_inputImageProgram->read(image, x, y, sampler);
 
-       if (*fac >= 1.0f)
+       if (*fac >= 1.0f) {
                curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image);
+       }
        else if (*fac <= 0.0f) {
                copy_v3_v3(output, image);
        }
        else {
-               float col[4], mfac = 1.0f - *fac;
+               float col[4];
                curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image);
-               output[0] = mfac * image[0] + *fac * col[0];
-               output[1] = mfac * image[1] + *fac * col[1];
-               output[2] = mfac * image[2] + *fac * col[2];
+               interp_v3_v3v3(output, image, col, *fac);
        }
        output[3] = image[3];
 }
index 063873c6443e431c1f8604efa370ec731dad5bfa..7dc1913b85af04887dca4be3cb852b745fba40e0 100644 (file)
@@ -82,8 +82,8 @@ public:
         */
        void deinitExecution();
        
-       void setBlackLevel(float black[3]) { this->m_black[0] = black[0]; this->m_black[1] = black[1]; this->m_black[2] = black[2]; }
-       void setWhiteLevel(float white[3]) { this->m_white[0] = white[0]; this->m_white[1] = white[1]; this->m_white[2] = white[2]; }
+       void setBlackLevel(float black[3]) { copy_v3_v3(this->m_black, black); }
+       void setWhiteLevel(float white[3]) { copy_v3_v3(this->m_white, white); }
 };
 
 #endif
index 2687fee28ce7773f7c42ddf764ba5e6d42158315..c4b4452fbb030c3192f33212d4bab101ab19f3e3 100644 (file)
@@ -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;
index 837230d9719724a477601c38d640af16f4fe3e35..16168888573999b387431076c45cdbbff88b2b65 100644 (file)
@@ -3067,9 +3067,9 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
                                break;
                        }
                }
-               
+
                /* check if there's enough space for the toggles if the sliders are drawn too */
-               if (!(draw_sliders) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) {
+               if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
                        /* protect... */
                        if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT))
                                offset += ICON_WIDTH;
@@ -3461,7 +3461,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
                }
                
                /* check if there's enough space for the toggles if the sliders are drawn too */
-               if (!(draw_sliders) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) {
+               if (!(draw_sliders) || (BLI_RCT_SIZE_X(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) {
                        /* protect... */
                        if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
                                offset += ICON_WIDTH; 
index a8daf852ddab96469e1af350775cf7495985baf5..95adaa01b94e87ee169b37a00b40e255cbc9db32 100644 (file)
@@ -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);
@@ -773,8 +773,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
                        if (hasNumInput(&mm->num))
                                break;
                        
-                       dx = v2d->mask.xmax - v2d->mask.xmin;
-                       dx = (v2d->cur.xmax - v2d->cur.xmin) / dx;
+                       dx = BLI_RCT_SIZE_X(&v2d->cur) / BLI_RCT_SIZE_X(&v2d->mask);
                        
                        if (evt->x != mm->evtx) {   /* XXX maybe init for first time */
                                int a, offs, totmark = 0;
index 949f92c68e94fee9142d35c0027ae6d262fc3d9a..5d67b63af18e36451dfda9a93859b726e57d6682 100644 (file)
@@ -422,8 +422,8 @@ static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoin
                }
                else {
                        if (subrect) {
-                               mvalf[0] = (((float)pt->x / 100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin;
-                               mvalf[1] = (((float)pt->y / 100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin;
+                               mvalf[0] = (((float)pt->x / 100.0f) * BLI_RCT_SIZE_X(subrect)) + subrect->xmin;
+                               mvalf[1] = (((float)pt->y / 100.0f) * BLI_RCT_SIZE_Y(subrect)) + subrect->ymin;
                        }
                        else {
                                mvalf[0] = (float)pt->x / 100.0f * ar->winx;
index d98f4891dc5b1524cb94532681c3a6215b4b2e68..1f317fa4f045c7d45ff1254158ce4afc482fb879 100644 (file)
@@ -300,8 +300,8 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
                        out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100;
                }
                else { /* camera view, use subrect */
-                       out[0] = ((mval[0] - p->subrect->xmin) / ((p->subrect->xmax - p->subrect->xmin))) * 100;
-                       out[1] = ((mval[1] - p->subrect->ymin) / ((p->subrect->ymax - p->subrect->ymin))) * 100;
+                       out[0] = ((mval[0] - p->subrect->xmin) / BLI_RCT_SIZE_X(p->subrect)) * 100;
+                       out[1] = ((mval[1] - p->subrect->ymin) / BLI_RCT_SIZE_Y(p->subrect)) * 100;
                }
        }
 }
index 7cd1afd468c0c1d0e3278f05b2dc05dc60335548..28727c913cbf6986165bffed038906e46c798a75 100644 (file)
@@ -62,6 +62,8 @@ int ED_space_clip_get_clip_frame_number(struct SpaceClip *sc);
 struct ImBuf *ED_space_clip_get_buffer(struct SpaceClip *sc);
 struct ImBuf *ED_space_clip_get_stable_buffer(struct SpaceClip *sc, float loc[2], float *scale, float *angle);
 
+int ED_space_clip_color_sample(struct SpaceClip *sc, struct ARegion *ar, int mval[2], float r_col[3]);
+
 void ED_clip_update_frame(const struct Main *mainp, int cfra);
 int ED_clip_view_selection(const struct bContext *C, struct ARegion *ar, int fit);
 
index 62b26f5a8c1d52ee5dc8232d90d8f31d709a52aa..10917f23cdd7891f7b9cc36a2e1b8f44f99b715f 100644 (file)
@@ -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;
@@ -300,8 +300,8 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
        
        ui_bounds_block(block);
        
-       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);
        
        startx = (xmax * 0.5f) - (width * 0.5f);
        starty = (ymax * 0.5f) - (height * 0.5f);
@@ -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);
@@ -488,10 +488,10 @@ static void ui_draw_linkline(uiLinkLine *line, int highlightActiveLines)
 
        if (line->from == NULL || line->to == NULL) return;
        
-       rect.xmin = (line->from->rect.xmin + line->from->rect.xmax) / 2.0f;
-       rect.ymin = (line->from->rect.ymin + line->from->rect.ymax) / 2.0f;
-       rect.xmax = (line->to->rect.xmin + line->to->rect.xmax) / 2.0f;
-       rect.ymax = (line->to->rect.ymin + line->to->rect.ymax) / 2.0f;
+       rect.xmin = BLI_RCT_CENTER_X(&line->from->rect);
+       rect.ymin = BLI_RCT_CENTER_Y(&line->from->rect);
+       rect.xmax = BLI_RCT_CENTER_X(&line->to->rect);
+       rect.ymax = BLI_RCT_CENTER_Y(&line->to->rect);
        
        if (line->flag & UI_SELECT)
                glColor3ub(100, 100, 100);
@@ -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);
                        }
index 41a827bbda91b3da0ee55e39500990f1ce1f32d7..c9a6ba0abe7c12c4c12722731b783071e5fe2072 100644 (file)
@@ -439,8 +439,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
        //glColor4f(1.0, 0.f, 0.f, 1.f);
        //fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax)
 
-       w = (rect->xmax - rect->xmin);
-       h = (rect->ymax - rect->ymin);
+       w = BLI_RCT_SIZE_X(rect);
+       h = BLI_RCT_SIZE_Y(rect);
        /* prevent drawing outside widget area */
        glGetIntegerv(GL_SCISSOR_BOX, scissor);
        glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h);
@@ -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);
@@ -732,8 +732,8 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
        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) * hist->ymax;
+       w = BLI_RCT_SIZE_X(&rect);
+       h = BLI_RCT_SIZE_Y(&rect) * hist->ymax;
        
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -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;
        
@@ -1481,7 +1481,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
        glBegin(GL_LINE_STRIP);
        
        if (cuma->table == NULL)
-               curvemapping_changed(cumap, 0);  /* 0 = no remove doubles */
+               curvemapping_changed(cumap, FALSE);
        cmp = cuma->table;
        
        /* first point */
@@ -1514,7 +1514,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
        glPointSize(3.0f);
        bglBegin(GL_POINTS);
        for (a = 0; a < cuma->totpoint; a++) {
-               if (cmp[a].flag & SELECT)
+               if (cmp[a].flag & CUMA_SELECT)
                        UI_ThemeColor(TH_TEXT_HI);
                else
                        UI_ThemeColor(TH_TEXT);
@@ -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) {
index 4010274f687a9f5188bc852e40db32871b97cb4a..ce0ec310ac3707dea60642cc9fbac5cb0238d058 100644 (file)
@@ -690,10 +690,10 @@ 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 = (rect.xmax - rect.xmin) - (rect.ymax - rect.ymin);
+               int delta = BLI_RCT_SIZE_X(&rect) - BLI_RCT_SIZE_Y(&rect);
                rect.xmin += delta / 2;
                rect.xmax -= delta / 2;
        }
@@ -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;
        
@@ -2763,7 +2763,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
                        }
                        /* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */
                        else if (event->type == LEFTMOUSE && event->alt) {
-                               int halfpos = (but->rect.xmin + but->rect.xmax) / 2;
+                               int halfpos = BLI_RCT_CENTER_X(&but->rect);
                                click = 2;
                                if (mx < halfpos)
                                        mx = but->rect.xmin;
@@ -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; */
 
@@ -3647,7 +3647,7 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
                fy *= mval_factor;
 
                for (a = 0; a < cuma->totpoint; a++) {
-                       if (cmp[a].flag & SELECT) {
+                       if (cmp[a].flag & CUMA_SELECT) {
                                float origx = cmp[a].x, origy = cmp[a].y;
                                cmp[a].x += fx;
                                cmp[a].y += fy;
@@ -3660,7 +3660,7 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
                        }
                }
 
-               curvemapping_changed(cumap, 0); /* no remove doubles */
+               curvemapping_changed(cumap, FALSE);
                
                if (moved_point) {
                        data->draglastx = mx;
@@ -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;
 
@@ -3727,7 +3727,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
                                fy = ((float)my - but->rect.ymin) / zoomy + offsy;
                                
                                curvemap_insert(cuma, fx, fy);
-                               curvemapping_changed(cumap, 0);
+                               curvemapping_changed(cumap, FALSE);
                                changed = 1;
                        }
 
@@ -3756,12 +3756,12 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
                                /* loop through the curve segment table and find what's near the mouse.
                                 * 0.05 is kinda arbitrary, but seems to be what works nicely. */
                                for (i = 0; i <= CM_TABLE; i++) {
-                                       if ( (fabsf(fx - cmp[i].x) < 0.05f) &&
-                                            (fabsf(fy - cmp[i].y) < 0.05f))
+                                       if ((fabsf(fx - cmp[i].x) < 0.05f) &&
+                                           (fabsf(fy - cmp[i].y) < 0.05f))
                                        {
                                        
                                                curvemap_insert(cuma, fx, fy);
-                                               curvemapping_changed(cumap, 0);
+                                               curvemapping_changed(cumap, FALSE);
 
                                                changed = 1;
                                                
@@ -3783,11 +3783,11 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
                                /* deselect all if this one is deselect. except if we hold shift */
                                if (event->shift == FALSE) {
                                        for (a = 0; a < cuma->totpoint; a++)
-                                               cmp[a].flag &= ~SELECT;
-                                       cmp[sel].flag |= SELECT;
+                                               cmp[a].flag &= ~CUMA_SELECT;
+                                       cmp[sel].flag |= CUMA_SELECT;
                                }
                                else
-                                       cmp[sel].flag ^= SELECT;
+                                       cmp[sel].flag ^= CUMA_SELECT;
                        }
                        else {
                                /* move the view */
@@ -3822,12 +3822,13 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
                                        /* deselect all, select one */
                                        if (event->shift == FALSE) {
                                                for (a = 0; a < cuma->totpoint; a++)
-                                                       cmp[a].flag &= ~SELECT;
-                                               cmp[data->dragsel].flag |= SELECT;
+                                                       cmp[a].flag &= ~CUMA_SELECT;
+                                               cmp[data->dragsel].flag |= CUMA_SELECT;
                                        }
                                }
-                               else
-                                       curvemapping_changed(cumap, 1);  /* remove doubles */
+                               else {
+                                       curvemapping_changed(cumap, TRUE);  /* remove doubles */
+                               }
                        }
 
                        button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -3862,7 +3863,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 +3947,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 +4029,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 +4099,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 +4232,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) {
index 802000567da389444fd21b12e64df7c3d5cb8902..d3b8197447951fb43ea3358eccb96b94f46c9c14 100644 (file)
@@ -27,7 +27,6 @@
  *  \ingroup edinterface
  */
 
-
 #include <stdio.h>
 #include <math.h>
 #include <string.h>
@@ -71,6 +70,7 @@
 
 #include "ED_image.h"  /* for HDR color sampling */
 #include "ED_node.h"   /* for HDR color sampling */
+#include "ED_clip.h"   /* for HDR color sampling */
 
 /* ********************************************************** */
 
@@ -165,6 +165,18 @@ static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int
                                        }
                                }
                        }
+                       else if (sa->spacetype == SPACE_CLIP) {
+                               ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+                               if (BLI_in_rcti(&ar->winrct, mx, my)) {
+                                       SpaceClip *sc = sa->spacedata.first;
+                                       int mval[2] = {mx - ar->winrct.xmin,
+                                                      my - ar->winrct.ymin};
+
+                                       if (ED_space_clip_color_sample(sc, ar, mval, r_col)) {
+                                               return;
+                                       }
+                               }
+                       }
                }
        }
 
index 3bbf5b17312500cb73d8bee9e22e84016d3375cc..512cda13df1576ab2f9387a4ac67a16d72d8980d 100644 (file)
@@ -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);
index be118e1982e2f39ff46e0cb2e3095baa14d38529..35488430b22dbcef289bb27d75e9adb8a7e8eabb 100644 (file)
@@ -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 < (but->block->rect.ymin + but->block->rect.ymax) / 2) {
-                       data->bbox.ymin += (but->rect.ymax - but->rect.ymin);
+               if (but->rect.ymax < BLI_RCT_CENTER_Y(&but->block->rect)) {
+                       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*/
 
        {
@@ -1495,8 +1495,8 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
 
        /* safety calculus */
        if (but) {
-               float midx = (butrct.xmin + butrct.xmax) / 2.0f;
-               float midy = (butrct.ymin + butrct.ymax) / 2.0f;
+               const float midx = BLI_RCT_CENTER_X(&butrct);
+               const float midy = BLI_RCT_CENTER_Y(&butrct);
                
                /* when you are outside parent button, safety there should be smaller */
                
index 779341160c5787d0bf4a6dc832dac094ca85d1fc..ee0613ea0d0d63a7912d5624a471941e87b527a3 100644 (file)
@@ -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;
 
index 49990b75ddb9f7af5ed741e252438410fca10536..a7934687e9a6676b800b753b44b035938f562d32 100644 (file)
@@ -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)
@@ -1621,7 +1622,7 @@ static void curvemap_buttons_setclip(bContext *UNUSED(C), void *cumap_v, void *U
 {
        CurveMapping *cumap = cumap_v;
 
-       curvemapping_changed(cumap, 0);
+       curvemapping_changed(cumap, FALSE);
 }      
 
 static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v)
@@ -1629,7 +1630,7 @@ static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v)
        CurveMapping *cumap = cumap_v;
 
        curvemap_remove(cumap->cm + cumap->cur, SELECT);
-       curvemapping_changed(cumap, 0);
+       curvemapping_changed(cumap, FALSE);
 
        rna_update_cb(C, cb_v, NULL);
 }
@@ -1671,26 +1672,26 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
        switch (event) {
                case 0: /* reset */
                        curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
-                       curvemapping_changed(cumap, 0);
+                       curvemapping_changed(cumap, FALSE);
                        break;
                case 1:
                        cumap->curr = cumap->clipr;
                        break;
                case 2: /* set vector */
                        curvemap_sethandle(cuma, 1);
-                       curvemapping_changed(cumap, 0);
+                       curvemapping_changed(cumap, FALSE);
                        break;
                case 3: /* set auto */
                        curvemap_sethandle(cuma, 0);
-                       curvemapping_changed(cumap, 0);
+                       curvemapping_changed(cumap, FALSE);
                        break;
                case 4: /* extend horiz */
                        cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
-                       curvemapping_changed(cumap, 0);
+                       curvemapping_changed(cumap, FALSE);
                        break;
                case 5: /* extend extrapolate */
                        cuma->flag |= CUMA_EXTEND_EXTRAPOLATE;
-                       curvemapping_changed(cumap, 0);
+                       curvemapping_changed(cumap, FALSE);
                        break;
        }
        ED_region_tag_redraw(CTX_wm_region(C));
@@ -1763,7 +1764,7 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
        cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
        curvemapping_set_black_white(cumap, NULL, NULL);
        
-       curvemapping_changed(cumap, 0);
+       curvemapping_changed(cumap, FALSE);
 
        rna_update_cb(C, cb_v, NULL);
 }
index aebdb349bd57034527458d5f7be09bfc7d180719..bf5b3fbe8c792ba71e3e27b7d1eecacbc8763527 100644 (file)
@@ -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;
                }
@@ -1843,14 +1843,14 @@ static void ui_hsv_cursor(float x, float y)
 void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my)
 {
        /* duplication of code... well, simple is better now */
-       float centx = (float)(rect->xmin + rect->xmax) / 2;
-       float centy = (float)(rect->ymin + rect->ymax) / 2;
+       float centx = BLI_RCT_CENTER_X_FL(rect);
+       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;
@@ -1876,13 +1876,13 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
                color_profile = BLI_PR_NONE;
        
        radstep = 2.0f * (float)M_PI / (float)tot;
-       centx = (float)(rect->xmin + rect->xmax) / 2;
-       centy = (float)(rect->ymin + rect->ymax) / 2;
+       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;
@@ -2438,8 +2439,8 @@ static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, in
                
                UI_ThemeColor(TH_TEXT_HI);
                
-               rectlink.xmin = (rect->xmin + rect->xmax) / 2;
-               rectlink.ymin = (rect->ymin + rect->ymax) / 2;
+               rectlink.xmin = BLI_RCT_CENTER_X(rect);
+               rectlink.ymin = BLI_RCT_CENTER_Y(rect);
                rectlink.xmax = but->linkto[0];
                rectlink.ymax = but->linkto[1];
                
@@ -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);
        
@@ -3269,12 +3270,12 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
                if (block->flag & UI_BLOCK_CLIPTOP) {
                        /* XXX no scaling for UI here yet */
                        glColor3ubv((unsigned char *)wt->wcol.text);
-                       UI_DrawTriIcon((rect->xmax + rect->xmin) / 2, rect->ymax - 8, 't');
+                       UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymax - 8, 't');
                }
                if (block->flag & UI_BLOCK_CLIPBOTTOM) {
                        /* XXX no scaling for UI here yet */
                        glColor3ubv((unsigned char *)wt->wcol.text);
-                       UI_DrawTriIcon((rect->xmax + rect->xmin) / 2, rect->ymin + 10, 'v');
+                       UI_DrawTriIcon(BLI_RCT_CENTER_X(rect), rect->ymin + 10, 'v');
                }
        }       
 }
index 8ae08c08693c125984ce0b736b9541e312d2e99b..86322b0c0ea9c7776cf6f0959f47b112b890abab 100644 (file)
@@ -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,16 +499,16 @@ 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 = (cur->xmax + cur->xmin) * 0.5f;
+                               temp = BLI_RCT_CENTER_X(cur);
                                dh = width * 0.5f;
                                
                                cur->xmin = temp - dh;
@@ -517,16 +517,16 @@ 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 = (cur->ymax + cur->ymin) * 0.5f;
+                               temp = BLI_RCT_CENTER_Y(cur);
                                dh = height * 0.5f;
                                
                                cur->ymin = temp - dh;
@@ -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)) ) {
@@ -592,7 +592,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
                         */
                        if ((cur->xmin < tot->xmin) && (cur->xmax > tot->xmax)) {
                                /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
-                               temp = (tot->xmax + tot->xmin) * 0.5f;
+                               temp = BLI_RCT_CENTER_X(tot);
                                diff = curheight * 0.5f;
                                
                                cur->xmin = temp - diff;
@@ -642,7 +642,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
                         */
                        if ((cur->ymin < tot->ymin) && (cur->ymax > tot->ymax)) {
                                /* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
-                               temp = (tot->ymax + tot->ymin) * 0.5f;
+                               temp = BLI_RCT_CENTER_Y(tot);
                                diff = curheight * 0.5f;
                                
                                cur->ymin = temp - diff;
@@ -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
index 33b72b3478465e519d0f3510991db3e24f848057..258025eefc929d7e793e4ed7a8d42e9f28cf52b5 100644 (file)
@@ -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,16 +1138,16 @@ 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);
-                       center = (cur_new.xmax + cur_new.xmin) * 0.5f;
+                       zoom = size / BLI_RCT_SIZE_X(&rect);
+                       center = BLI_RCT_CENTER_X(&cur_new);
                        
                        cur_new.xmin = center - (size * zoom);
                        cur_new.xmax = center + (size * zoom);
                }
                if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
                        size = (cur_new.ymax - cur_new.ymin);
-                       zoom = size / (rect.ymax - rect.ymin);
-                       center = (cur_new.ymax + cur_new.ymin) * 0.5f;
+                       zoom = size / BLI_RCT_SIZE_Y(&rect);
+                       center = BLI_RCT_CENTER_Y(&cur_new);
                        
                        cur_new.ymin = center - (size * zoom);
                        cur_new.ymax = center + (size * zoom);
@@ -1201,10 +1201,10 @@ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
                           rect_a->ymax - rect_a->ymin};
        float size_b[2] = {rect_b->xmax - rect_b->xmin,
                           rect_b->ymax - rect_b->ymin};
-       float cent_a[2] = {(rect_a->xmax + rect_a->xmin) * 0.5f,
-                          (rect_a->ymax + rect_a->ymin) * 0.5f};
-       float cent_b[2] = {(rect_b->xmax + rect_b->xmin) * 0.5f,
-                          (rect_b->ymax + rect_b->ymin) * 0.5f};
+       float cent_a[2] = {BLI_RCT_CENTER_X(rect_a),
+                          BLI_RCT_CENTER_Y(rect_a)};
+       float cent_b[2] = {BLI_RCT_CENTER_X(rect_b),
+                          BLI_RCT_CENTER_Y(rect_b)};
 
        float fac_max = 0.0f;
        float tfac;
@@ -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;
index 703ae70eb0f7dbc99d155a5781ddc0ee2b261a62..c6b19e51de99cb0e1e92e6a3b5b8cc6efa7e7a37 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "BLI_utildefines.h"
 #include "BLI_math.h"
+#include "BLI_rect.h"
 
 #include "BKE_context.h"
 #include "BKE_mask.h"
@@ -387,7 +388,7 @@ static void draw_spline_curve(MaskLayer *masklay, MaskSpline *spline,
                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        }
 
-       feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_feather_point);
+       feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(spline, width, height, &tot_feather_point, (is_fill != FALSE));
 
        /* draw feather */
        mask_spline_feather_color_get(masklay, spline, is_spline_sel, rgb_tmp);
@@ -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;
index 62600c7fe6b15344eda6ecde8fe1f59fee118b14..3431bea18eabc28ebbd271d97fc3c8e960871927 100644 (file)
@@ -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);
 
index 4f62974a3e1806cb3b87bfc9ffdf21259a6cabf2..84319061d52951d4087742ed37f579535dcc54d8 100644 (file)
@@ -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;
index 6f5f5c7dfa3d05da508d258b5dd612d305b65fcd..10bc17ff59e64e1235290f81008a003ab5e4ae90 100644 (file)
@@ -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;
        }
 }
 
@@ -1010,7 +1010,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                
                if (alignment == RGN_ALIGN_HSPLIT) {
                        if (rct_fits(remainder, 'h', prefsizex) > 4) {
-                               ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2;
+                               ar->winrct.xmax = BLI_RCT_CENTER_X(remainder);
                                remainder->xmin = ar->winrct.xmax + 1;
                        }
                        else {
@@ -1019,7 +1019,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                }
                else {
                        if (rct_fits(remainder, 'v', prefsizey) > 4) {
-                               ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2;
+                               ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder);
                                remainder->ymin = ar->winrct.ymax + 1;
                        }
                        else {
@@ -1051,20 +1051,20 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int
                }
                if (quad) {
                        if (quad == 1) { /* left bottom */
-                               ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2;
-                               ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2;
+                               ar->winrct.xmax = BLI_RCT_CENTER_X(remainder);
+                               ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder);
                        }
                        else if (quad == 2) { /* left top */
-                               ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2;
-                               ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2;
+                               ar->winrct.xmax = BLI_RCT_CENTER_X(remainder);
+                               ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1;
                        }
                        else if (quad == 3) { /* right bottom */
-                               ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2;
-                               ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2;
+                               ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1;
+                               ar->winrct.ymax = BLI_RCT_CENTER_Y(remainder);
                        }
                        else {  /* right top */
-                               ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2;
-                               ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2;
+                               ar->winrct.xmin = BLI_RCT_CENTER_X(remainder) + 1;
+                               ar->winrct.ymin = BLI_RCT_CENTER_Y(remainder) + 1;
                                BLI_rcti_init(remainder, 0, 0, 0, 0);
                        }
 
@@ -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);
index 4ec54f82f185bcccc90ef13ed54bac7e630a2d16..9bb5fb34140f29296a229646f6900a2ad2f43cb9 100644 (file)
@@ -1617,7 +1617,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;
index edec57d9e93eb22b7cb47e645f3b7ac98ef20dca..878fd20b27ee7dbbfc358f1ee4a7f5448bc12006 100644 (file)
@@ -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) 
                 */
index dbde950188d5978d61d2e9bbbca47d9c9b4ac34e..c95f1dba31d2e78a0b81b8df2751a98948872ff1 100644 (file)
@@ -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);
index 6b61990d4854234e8346c464fae0ac2a089dcea0..c9f765ac3db1ba46a64eb5a6177f0de43a9be82f 100644 (file)
@@ -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;
index 5bf6bcc047f38a38e71fcebe3bb8a27d78eb4e8e..0a1e1d750985ae504744c0e805edaa591ef495a1 100644 (file)
@@ -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"
@@ -173,7 +174,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, "");
 }
 
index 83d895067cc1f6a7ab4526fbae3ad885ace5a70f..5d890155e25aca4119d93c39e816ebe7835f45c8 100644 (file)
@@ -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)
                 */
index 60ef32da00fd83428d501e2a9ef0a63ea8f68d5f..14197a46663192097b094fcea6d4644e0dd947b9 100644 (file)
@@ -975,12 +975,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,
index 59fabf44dd4a772643ce1d9617c4b3cc1c9ac122..c730712deb23cd27de87ec87809f700df522529f 100644 (file)
@@ -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)
@@ -247,6 +248,54 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale
        return NULL;
 }
 
+/* returns color in SRGB */
+/* matching ED_space_image_color_sample() */
+int ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r_col[3])
+{
+       ImBuf *ibuf;
+       float fx, fy, co[2];
+       int ret = FALSE;
+
+       ibuf = ED_space_clip_get_buffer(sc);
+       if (!ibuf) {
+               return FALSE;
+       }
+
+       /* map the mouse coords to the backdrop image space */
+       ED_clip_mouse_pos(sc, ar, mval, co);
+
+       fx = co[0];
+       fy = co[1];
+
+       if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
+               float *fp;
+               unsigned char *cp;
+               int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y);
+
+               CLAMP(x, 0, ibuf->x - 1);
+               CLAMP(y, 0, ibuf->y - 1);
+
+               if (ibuf->rect_float) {
+                       fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x));
+                       /* IB_PROFILE_NONE is default but infact its linear */
+                       if (ELEM(ibuf->profile, IB_PROFILE_LINEAR_RGB, IB_PROFILE_NONE)) {
+                               linearrgb_to_srgb_v3_v3(r_col, fp);
+                       }
+                       else {
+                               copy_v3_v3(r_col, fp);
+                       }
+                       ret = TRUE;
+               }
+               else if (ibuf->rect) {
+                       cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
+                       rgb_uchar_to_float(r_col, cp);
+                       ret = TRUE;
+               }
+       }
+
+       return ret;
+}
+
 void ED_clip_update_frame(const Main *mainp, int cfra)
 {
        wmWindowManager *wm;
@@ -345,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;
index a2cb812d51cc6cf80dfb3f87ed742948f5884c70..e94b28d22fa2816a03f14652e0ef5e60e679e870 100644 (file)
@@ -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;
index 36199b1908d48b4675383d70fd906db7ddb56470..20b0ad509d3270c58083c1b660620d4c254d0b67 100644 (file)
@@ -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 */
index 3da9f1b018f318392bc55465f1b4fe512ad23875..b2186891df0b857722fcb64b162411899a5f0a6d 100644 (file)
@@ -1042,8 +1042,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;
index 490a3b459901cc178bbdadd30f39a7576a514656..a4f7e30ed7b376a4b014d1313c8d737730b65c75 100644 (file)
@@ -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;
        }
index 34f16c11537c7313eb6f267d2f57c45f3a1ef46c..09231efd36787ab0546b28d4f05107b1d6bd537b 100644 (file)
@@ -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);
index 17669dfa8f9e2f41d11c11ec0f857a35cf66b629..8c5ecb486136886fb1a7437a69d396069455068f 100644 (file)
@@ -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) */
index 870e9bb816823392d13b08b56529dad6fe61f09a..ad97b7853c4f8668833e10bb6e2891b8d7183566 100644 (file)
@@ -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 
index 781099f6a68a6a39e8fecb72e1034729e5e2f27c..32abad86828fc79e734f2f945b12c62a5ff7dc8a 100644 (file)
@@ -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;
index d858e05132d52ef1b09101c72d6a19d8efabe55b..9c9e94d4ce499caede35c4cdb9996cd515a3c304 100644 (file)
@@ -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 */
index c02c1ffe867fba12ab0f1ffee1c2cc394d566841..8867f5bba0db6d109d6dc4474f92d63b5c9dd28f 100644 (file)
@@ -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"
@@ -147,7 +148,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);
index 036e70913b6dc4555d8a202137c4d21ce51a158f..bb31ba42716634c8801fe3ef38dbe005565864bc 100644 (file)
@@ -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)
index 439299ddcda0d5968f0488e5dea72818028b8209..6d88fa02b4a26f4abf40f6b0e342e622de953de5 100644 (file)
@@ -99,9 +99,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;
        }
 
@@ -582,8 +582,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 */
index 86048a704668a4f917baecf90dd7e6851df78405..f7b45d5eb2ace98231287e36533ac81bbbd30e07 100644 (file)
@@ -561,8 +561,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;
index 999a8baf34b873fc2618038292841debdc1b6454..abffb9554052cfd9b7254c20bdf745dc687419b2 100644 (file)
@@ -84,10 +84,10 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot)
        int i, b;
        rcti rectlink;
 
-       rectlink.xmin = (int) (line->from->rect.xmin + line->from->rect.xmax) / 2;
-       rectlink.ymin = (int) (line->from->rect.ymin + line->from->rect.ymax) / 2;
-       rectlink.xmax = (int) (line->to->rect.xmin + line->to->rect.xmax) / 2;
-       rectlink.ymax = (int) (line->to->rect.ymin + line->to->rect.ymax) / 2;
+       rectlink.xmin = (int)BLI_RCT_CENTER_X(&line->from->rect);
+       rectlink.ymin = (int)BLI_RCT_CENTER_Y(&line->from->rect);
+       rectlink.xmax = (int)BLI_RCT_CENTER_X(&line->to->rect);
+       rectlink.ymax = (int)BLI_RCT_CENTER_Y(&line->to->rect);
 
        if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) {
                for (i=0; i<tot-1; i++)
index a3e9ca1c4a26cd0aaf7cca74b97cf66b4c2a2aa2..775dd5445c3c2c8110cacfce6d63379057040770 100644 (file)
@@ -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);
index b6bef651af3a70b047ef7de7f1fb581cbe2faf5b..e76102108815ad17a983362914b29862e0f7e520 100644 (file)
@@ -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;
index cde7e494927766c2c74e989ba92737d14c3dd6d2..2a6fd3b8417cfb0fc647c4c64b208fdc7aae5b78 100644 (file)
@@ -387,7 +387,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);
 }
@@ -523,7 +523,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
                rect->ymax += NODE_DY;
                
                /* input sockets */
-               dy = 0.5f * (rect->ymin + rect->ymax) + NODE_DY * (BLI_countlist(&gnode->inputs) - 1);
+               dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1));
                gsock = ngroup->inputs.first;
                sock = gnode->inputs.first;
                while (gsock || sock) {
@@ -571,7 +571,7 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
                }
                
                /* output sockets */
-               dy = 0.5f * (rect->ymin + rect->ymax) + NODE_DY * (BLI_countlist(&gnode->outputs) - 1);
+               dy = BLI_RCT_CENTER_Y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1));
                gsock = ngroup->outputs.first;
                sock = gnode->outputs.first;
                while (gsock || sock) {
@@ -838,7 +838,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);
@@ -980,7 +980,7 @@ static void node_draw_frame_label(bNode *node, const float aspect)
        ascender = BLF_ascender(fontid);
        
        /* 'x' doesn't need aspect correction */
-       x = 0.5f * (rct->xmin + rct->xmax) - 0.5f * width;
+       x = BLI_RCT_CENTER_X(rct) - (0.5f * width);
        y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect));
 
        BLF_position(fontid, x, y, 0);
index 643ac177933640150da048d60ed1322af05a834f..087f86e4497d1fea236f577200a5bb2e83a442b1 100644 (file)
@@ -1108,7 +1108,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);
 
index 245c9cefd1f3394b77f0d5d6020ad1bd4b66af55..4423b340d77e136b68539ef8bd5d934d735d27ef 100644 (file)
@@ -2063,8 +2063,8 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
        /* calculate "barycenter" for placing on mouse cursor */
        zero_v2(center);
        for (node = clipboard_nodes_lb->first, num_nodes = 0; node; node = node->next, num_nodes++) {
-               center[0] += 0.5f * (node->totr.xmin + node->totr.xmax);
-               center[1] += 0.5f * (node->totr.ymin + node->totr.ymax);
+               center[0] += BLI_RCT_CENTER_X(&node->totr);
+               center[1] += BLI_RCT_CENTER_Y(&node->totr);
        }
        mul_v2_fl(center, 1.0 / num_nodes);
 
index 27b57885b2bceda7259c009f4eed1f547f5bf169..6f549bd252f5d2910a30742ce6d717eccf25abf1 100644 (file)
@@ -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);
 
index 4fa8686bce3dab4b076d1cbdb5c7d7160a7611cd..b669e705a25efa503dd8d52cc088784874ccca94 100644 (file)
@@ -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);
index 8fa43bfabb101bcb02f3684e6529c6e42f806882..19da6e9124768c3b619a8b71ae1140484a6874f8 100644 (file)
@@ -432,7 +432,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 */
        
@@ -725,7 +725,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 */
@@ -946,10 +946,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);
@@ -1133,7 +1133,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++) {
index 64fd2cbf3bf11226a5667c5770ac2821d6376c84..cdd135b0755b1cc4d881284da69ca5242fc4e0a4 100644 (file)
@@ -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);
 
@@ -2256,7 +2256,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
 
                /* only zoom out vertically */
                if (orig_height > cur_new.ymax - cur_new.ymin) {
-                       ymid = (cur_new.ymax + cur_new.ymin) / 2;
+                       ymid = BLI_RCT_CENTER_Y(&cur_new);
 
                        cur_new.ymin = ymid - (orig_height / 2);
                        cur_new.ymax = ymid + (orig_height / 2);
@@ -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;
index df90ce24ddaf6a2d725a3c5d7947b55e9ed9e1ba..5af44f93d062f937f864bd55b48fe36605cfd624 100644 (file)
@@ -2409,8 +2409,8 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        /* jump scroll, works in v2d but needs to be added here too :S */
        if (event->type == MIDDLEMOUSE) {
-               tsc->old[0] = ar->winrct.xmin + (st->txtbar.xmax + st->txtbar.xmin) / 2;
-               tsc->old[1] = ar->winrct.ymin + (st->txtbar.ymax + st->txtbar.ymin) / 2;
+               tsc->old[0] = ar->winrct.xmin + BLI_RCT_CENTER_X(&st->txtbar);
+               tsc->old[1] = ar->winrct.ymin + BLI_RCT_CENTER_Y(&st->txtbar);
 
                tsc->delta[0] = 0;
                tsc->delta[1] = 0;
index 189c8bfc7d04c1b396f6c2d2f6c08646587c67aa..733fd27135bf7aee5f2de7e44e5deba1d6737261 100644 (file)
@@ -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;
        
index 9d988fbef4aea3d2f638c09395136e2641654302..39403d83b421a97a32cadf86d99df0dd0f163e88 100644 (file)
@@ -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)
index e5730e0f69b8402bb016d6046bc1de25a89fb228..6e0c598d0cee597aac4553a2b5c5154f81343073 100644 (file)
@@ -382,10 +382,10 @@ static void calctrackballvec(rcti *rect, int mx, int my, float vec[3])
        radius = TRACKBALLSIZE;
 
        /* normalize x and y */
-       x = (rect->xmax + rect->xmin) / 2 - mx;
-       x /= (float)((rect->xmax - rect->xmin) / 4);
-       y = (rect->ymax + rect->ymin) / 2 - my;
-       y /= (float)((rect->ymax - rect->ymin) / 2);
+       x = BLI_RCT_CENTER_X(rect) - mx;
+       x /= (float)(BLI_RCT_SIZE_X(rect) / 4);
+       y = BLI_RCT_CENTER_Y(rect) - my;
+       y /= (float)(BLI_RCT_SIZE_Y(rect) / 2);
 
        d = sqrt(x * x + y * y);
        if (d < radius * (float)M_SQRT1_2) { /* Inside sphere */
@@ -1666,8 +1666,8 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom,
                int ctr[2], len1, len2;
                /* method which zooms based on how far you move the mouse */
 
-               ctr[0] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin) / 2;
-               ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin) / 2;
+               ctr[0] = BLI_RCT_CENTER_X(&vod->ar->winrct);
+               ctr[1] = BLI_RCT_CENTER_Y(&vod->ar->winrct);
 
                len1 = (int)sqrt((ctr[0] - x) * (ctr[0] - x) + (ctr[1] - y) * (ctr[1] - y)) + 5;
                len2 = (int)sqrt((ctr[0] - vod->origx) * (ctr[0] - vod->origx) + (ctr[1] - vod->origy) * (ctr[1] - vod->origy)) + 5;
@@ -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 */
index 69fa42b0abb768fe9c5786eadfae93f55f261e50..49d7c9ba28c5e7f35b8f43691b8c65587bca95b3 100644 (file)
@@ -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;
 
@@ -765,9 +765,8 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select)
        
        /* store selection in temp test flag */
        for (node = snode->edittree->nodes.first; node; node = node->next) {
-               
-               node_centf[0] = (node->totr.xmin + node->totr.xmax) / 2;
-               node_centf[1] = (node->totr.ymin + node->totr.ymax) / 2;
+               node_centf[0] = BLI_RCT_CENTER_X(&node->totr);
+               node_centf[1] = BLI_RCT_CENTER_Y(&node->totr);
                
                ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent);
                if (BLI_in_rcti_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) {
index f88d4becc7418a76a90e294bf44c72f0237db2a5..6b6da99cf393d569fcec26ca7ce9eb2d8e2d93e7 100644 (file)
@@ -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 */
index c22a645eb53447baee959933f3ae6b90f36b9a21..120394aa7c1da5a48e6d32868727eab7fa0e519d 100644 (file)
@@ -5548,8 +5548,8 @@ static void createTransObject(bContext *C, TransInfo *t)
 static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
 {
        /* hold original location */
-       float locxy[2] = {(node->totr.xmax + node->totr.xmin) / 2.0f,
-                         (node->totr.ymax + node->totr.ymin) / 2.0f};
+       float locxy[2] = {BLI_RCT_CENTER_X(&node->totr),
+                         BLI_RCT_CENTER_Y(&node->totr)};
 
        copy_v2_v2(td2d->loc, locxy);
        td2d->loc[2] = 0.0f;
index 8e73fb8b8cbca033619fd9dfa266adc696f43a4a..bcebca52ce8bb1d47ff19c91b10ccdbd72d4b076 100644 (file)
@@ -71,6 +71,7 @@
 #include "BKE_mesh.h"
 #include "BKE_nla.h"
 #include "BKE_context.h"
+#include "BKE_sequencer.h"
 #include "BKE_tessmesh.h"
 #include "BKE_tracking.h"
 #include "BKE_mask.h"
@@ -890,6 +891,14 @@ static void recalcData_view3d(TransInfo *t)
        }
 }
 
+/* helper for recalcData() - for sequencer transforms */
+static void recalcData_sequencer(TransInfo *t)
+{
+       BKE_sequencer_preprocessed_cache_cleanup();
+
+       flushTransSeq(t);
+}
+
 /* called for updating while transform acts, once per redraw */
 void recalcData(TransInfo *t)
 {
@@ -897,7 +906,7 @@ void recalcData(TransInfo *t)
                flushTransNodes(t);
        }
        else if (t->spacetype == SPACE_SEQ) {
-               flushTransSeq(t);
+               recalcData_sequencer(t);
        }
        else if (t->spacetype == SPACE_ACTION) {
                recalcData_actedit(t);
index c386f912636acb6480ef7261de2c1216521eee26..f2702980bb7501cf685a934a9bd27e0caaf1d779 100644 (file)
@@ -47,8 +47,10 @@ typedef struct CurveMapPoint {
 } CurveMapPoint;
 
 /* curvepoint->flag */
-#define CUMA_SELECT            1
-#define CUMA_VECTOR            2
+enum {
+       CUMA_SELECT = 1,
+       CUMA_VECTOR = 2
+};
 
 typedef struct CurveMap {
        short totpoint, flag;
index 3cccfe6a19f4d085e93acb42f993596028f872f5..7aaeaf23db27ad187cdd4757ca39f16850bc1a47 100644 (file)
@@ -46,6 +46,10 @@ typedef struct VFont {
        
        struct VFontData *data;
        struct PackedFile *packedfile;
+
+       /* runtime only, holds memory for freetype to read from
+        * TODO, replace this with blf_font_new() style loading */
+       struct PackedFile *temp_pf;
 } VFont;
 
 /* *************** FONT ****************** */
index 390c43f175bcaccd03aea1e00a5b60b60a46dd97..69a6feb561caca3fdc8ed0b51c5f19cf8a97817d 100644 (file)
@@ -95,7 +95,7 @@ static void rna_CurveMapping_clip_set(PointerRNA *ptr, int value)
        if (value) cumap->flag |= CUMA_DO_CLIP;
        else cumap->flag &= ~CUMA_DO_CLIP;
 
-       curvemapping_changed(cumap, 0);
+       curvemapping_changed(cumap, FALSE);
 }
 
 static void rna_CurveMapping_black_level_set(PointerRNA *ptr, const float *values)
index f42dfdd2e1e1138283c77f550b16d6c27bfd40dd..ec4f00a199a432ae2d7c42a9a4166b404dfe7caf 100644 (file)
@@ -40,8 +40,8 @@ if env['WITH_BF_COMPOSITOR']:
     incs += ' ../compositor '
     defs.append("WITH_COMPOSITOR")
 
-# TODO, make optional
-defs.append("WITH_COMPOSITOR_LEGACY")
+if env['WITH_BF_COMPOSITOR_LEGACY']:
+    defs.append("WITH_COMPOSITOR_LEGACY")
 
 env.BlenderLib ( libname = 'bf_nodes', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [190,105] )
 env.BlenderLib ( libname = 'bf_cmpnodes', sources = cmpsources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [175,101] )
index 92702ef29407bf61fb5c56f1b851dc6c7c435d9e..6fbff76e2dda4c03ad25c16cc727840a6861f7e0 100644 (file)
@@ -157,5 +157,6 @@ void register_node_type_cmp_alphaover(bNodeTreeType *ttype)
 #ifdef WITH_COMPOSITOR_LEGACY
        node_type_exec(&ntype, node_composit_exec_alphaover);
 #endif
+
        nodeRegisterType(ttype, &ntype);
 }
index 0562ff5a8a96bafbe1ca7af0d9dc1bb1fbc08fb5..e05ef1ea5a5ab4e816481d73b94397e1f1312af8 100644 (file)
@@ -278,5 +278,6 @@ void register_node_type_cmp_bilateralblur(bNodeTreeType *ttype)
 #ifdef WITH_COMPOSITOR_LEGACY
        node_type_exec(&ntype, node_composit_exec_bilateralblur);
 #endif
+
        nodeRegisterType(ttype, &ntype);
 }
index 551164b8d2622d2cc32af617e6018e9656d64574..b9b2406631bfe7958ac2500348edbef05ae1c241 100644 (file)
@@ -741,5 +741,6 @@ void register_node_type_cmp_blur(bNodeTreeType *ttype)
 #ifdef WITH_COMPOSITOR_LEGACY
        node_type_exec(&ntype, node_composit_exec_blur);
 #endif
+
        nodeRegisterType(ttype, &ntype);
 }
index f92fdd1ab9aa7c603ba89ad89995d7b2e9ea45de..2b8a394d6f28e481d4b3e7d298dd675590c5ba08 100644 (file)
@@ -106,6 +106,6 @@ void register_node_type_cmp_brightcontrast(bNodeTreeType *ttype)
 #ifdef WITH_COMPOSITOR_LEGACY
        node_type_exec(&ntype, node_composit_exec_brightcontrast);
 #endif
-       
+
        nodeRegisterType(ttype, &ntype);
 }
index b8ad5bdfc7ef179b579967dd38b0e55043fa71bc..9456ef8e9d9393d4de1d5c199ab949061373aec2 100644 (file)
@@ -342,6 +342,6 @@ void register_node_type_cmp_color_spill(bNodeTreeType *ttype)
 #ifdef WITH_COMPOSITOR_LEGACY
        node_type_exec(&ntype, node_composit_exec_color_spill);
 #endif
-       
+
        nodeRegisterType(ttype, &ntype);
 }
index 74f2e5c5b46cfad8354970ad9b46b3d53759b5b1..dadc863873da250d8b2731a1da1a27ef8eb3c68f 100644 (file)
@@ -108,6 +108,7 @@ void register_node_type_cmp_composite(bNodeTreeType *ttype)
 #ifdef WITH_COMPOSITOR_LEGACY
        node_type_exec(&ntype, node_composit_exec_composite);
 #endif
+
        /* Do not allow muting for this node. */
        node_type_internal_connect(&ntype, NULL);
 
index f3074bc8ed37d7d46699cc895f5d31df040db871..b9721910fd15a2bfc9598e99ccf37c403d9a7c11 100644 (file)
@@ -60,9 +60,12 @@ static bNodeSocketTemplate cmp_node_keying_out[] = {
        {       -1, 0, ""       }
 };
 
-static void exec(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
+#ifdef WITH_COMPOSITOR_LEGACY
+static void node_composit_exec_keying(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
 {
+       /* pass */
 }
+#endif  /* WITH_COMPOSITOR_LEGACY */
 
 static void node_composit_init_keying(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
@@ -91,7 +94,9 @@ void register_node_type_cmp_keying(bNodeTreeType *ttype)
        node_type_size(&ntype, 140, 100, 320);
        node_type_init(&ntype, node_composit_init_keying);
        node_type_storage(&ntype, "NodeKeyingData", node_free_standard_storage, node_copy_standard_storage);
-       node_type_exec(&ntype, exec);
+#ifdef WITH_COMPOSITOR_LEGACY
+       node_type_exec(&ntype, node_composit_exec_keying);
+#endif
 
        nodeRegisterType(ttype, &ntype);
 }
index 73423e2bdd315c07f2149bbf4bdd3c95d0159131..3fc4781fdc31e2974043953be83d951f62e19f33 100644 (file)
@@ -50,6 +50,7 @@ static bNodeSocketTemplate cmp_node_keyingscreen_out[] = {
        {       -1, 0, ""       }
 };
 
+#ifdef WITH_COMPOSITOR_LEGACY
 
 static void compute_gradient_screen(RenderData *rd, NodeKeyingScreenData *keyingscreen_data, MovieClip *clip, CompBuf *screenbuf)
 {
@@ -157,7 +158,7 @@ static void compute_gradient_screen(RenderData *rd, NodeKeyingScreenData *keying
        BLI_freelistN(&edges);
 }
 
-static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
+static void node_composit_exec_keyingscreen(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
 {
        NodeKeyingScreenData *keyingscreen_data = node->storage;
        RenderData *rd = data;
@@ -178,6 +179,8 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **
        out[0]->data = screenbuf;
 }
 
+#endif  /* WITH_COMPOSITOR_LEGACY */
+
 static void node_composit_init_keyingscreen(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
        NodeKeyingScreenData *data;
@@ -196,7 +199,9 @@ void register_node_type_cmp_keyingscreen(bNodeTreeType *ttype)
        node_type_size(&ntype, 140, 100, 320);
        node_type_init(&ntype, node_composit_init_keyingscreen);
        node_type_storage(&ntype, "NodeKeyingScreenData", node_free_standard_storage, node_copy_standard_storage);
-       node_type_exec(&ntype, exec);
+#ifdef WITH_COMPOSITOR_LEGACY
+       node_type_exec(&ntype, node_composit_exec_keyingscreen);
+#endif
 
        nodeRegisterType(ttype, &ntype);
 }
index f4cbd1b7f6fea0d6b6584d4bb39095313328f7dc..5c5bc2a97781bcfd6ab2d704e023bc805945cda1 100644 (file)
@@ -45,7 +45,8 @@ static bNodeSocketTemplate cmp_node_mask_out[] = {
        {   -1, 0, ""   }
 };
 
-static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
+#ifdef WITH_COMPOSITOR_LEGACY
+static void node_composit_exec_mask(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out)
 {
        if (node->id) {
                Mask *mask = (Mask *)node->id;
@@ -84,6 +85,7 @@ static void exec(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **
                out[0]->data = stackbuf;
        }
 }
+#endif  /* WITH_COMPOSITOR_LEGACY */
 
 static void node_composit_init_mask(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
 {
@@ -103,7 +105,9 @@ void register_node_type_cmp_mask(bNodeTreeType *ttype)
        node_type_socket_templates(&ntype, NULL, cmp_node_mask_out);
        node_type_size(&ntype, 140, 100, 320);
        node_type_init(&ntype, node_composit_init_mask);
-       node_type_exec(&ntype, exec);
+#ifdef WITH_COMPOSITOR_LEGACY
+       node_type_exec(&ntype, node_composit_exec_mask);
+#endif
 
        node_type_storage(&ntype, "NodeMask", node_free_standard_storage, node_copy_standard_storage);
 
index 65fe3b251d064038cb1cb482c1578b4d30bd36b7..9f4cd467c9478baa7bedfccb7b76984e2ce1a1e3 100644 (file)
@@ -47,7 +47,8 @@ static bNodeSocketTemplate cmp_node_moviedistortion_out[] = {
        {       -1, 0, ""       }
 };
 
-static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+#ifdef WITH_COMPOSITOR_LEGACY
+static void node_composit_exec_moviedistortion(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 {
        if (in[0]->data) {
                if (node->id) {
@@ -104,6 +105,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
                }
        }
 }
+#endif  /* WITH_COMPOSITOR_LEGACY */
 
 static const char *label(bNode *node)
 {
@@ -135,7 +137,10 @@ void register_node_type_cmp_moviedistortion(bNodeTreeType *ttype)
        node_type_socket_templates(&ntype, cmp_node_moviedistortion_in, cmp_node_moviedistortion_out);
        node_type_size(&ntype, 140, 100, 320);
        node_type_label(&ntype, label);
-       node_type_exec(&ntype, exec);
+#ifdef WITH_COMPOSITOR_LEGACY
+       node_type_exec(&ntype, node_composit_exec_moviedistortion);
+#endif
+
        node_type_storage(&ntype, NULL, storage_free, storage_copy);
 
        nodeRegisterType(ttype, &ntype);
index 8a0d7200079363a4bd92f23e93d33ade7f82853e..aa92e713adfb047eb71de5bffd290f11ad60ffd1 100644 (file)
@@ -227,6 +227,8 @@ static void update_output_file(bNodeTree *UNUSED(ntree), bNode *node)
        }
 }
 
+#ifdef WITH_COMPOSITOR_LEGACY
+
 /* write input data into individual files */
 static void exec_output_file_singlelayer(RenderData *rd, bNode *node, bNodeStack **in)
 {
@@ -386,7 +388,7 @@ static void exec_output_file_multilayer(RenderData *rd, bNode *node, bNodeStack
        IMB_exr_close(exrhandle);
 }
 
-static void exec_output_file(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out))
+static void node_composit_exec_outputfile(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out))
 {
        RenderData *rd= data;
        NodeImageMultiFile *nimf= node->storage;
@@ -403,6 +405,7 @@ static void exec_output_file(void *data, bNode *node, bNodeStack **in, bNodeStac
        else
                exec_output_file_singlelayer(rd, node, in);
 }
+#endif  /* WITH_COMPOSITOR_LEGACY */
 
 void register_node_type_cmp_output_file(bNodeTreeType *ttype)
 {
@@ -414,7 +417,9 @@ void register_node_type_cmp_output_file(bNodeTreeType *ttype)
        node_type_init(&ntype, init_output_file);
        node_type_storage(&ntype, "NodeImageMultiFile", free_output_file, copy_output_file);
        node_type_update(&ntype, update_output_file, NULL);
-       node_type_exec(&ntype, exec_output_file);
+#ifdef WITH_COMPOSITOR_LEGACY
+       node_type_exec(&ntype, node_composit_exec_outputfile);
+#endif
 
        nodeRegisterType(ttype, &ntype);
 }
index af115c25c140d9a1662a5edb6d006eed442aebb6..420718f8dd9b6cfdd66b3562713a99ce06349b09 100644 (file)
@@ -165,6 +165,7 @@ void register_node_type_cmp_splitviewer(bNodeTreeType *ttype)
 #ifdef WITH_COMPOSITOR_LEGACY
        node_type_exec(&ntype, node_composit_exec_splitviewer);
 #endif
+
        /* Do not allow muting for this node. */
        node_type_internal_connect(&ntype, NULL);
 
index 0bdab75fc5f44f92b5cb4c6b802cbf1b07659561..6321b1def4d29d7085efea2325cd2446cead4157 100644 (file)
@@ -148,6 +148,7 @@ void register_node_type_cmp_viewer(bNodeTreeType *ttype)
 #ifdef WITH_COMPOSITOR_LEGACY
        node_type_exec(&ntype, node_composit_exec_viewer);
 #endif
+
        node_type_internal_connect(&ntype, NULL);
 
        nodeRegisterType(ttype, &ntype);
index abb52efe2da36d944a38e22dd198f710cb7d6a49..17a7bed4498127b36d858521beceb4e4e3e871d9 100644 (file)
@@ -59,6 +59,7 @@
 #include "BKE_writeavi.h"  /* <------ should be replaced once with generic movie module */
 
 #include "BLI_math.h"
+#include "BLI_rect.h"
 #include "BLI_listbase.h"
 #include "BLI_string.h"
 #include "BLI_path_util.h"
@@ -740,8 +741,8 @@ static RenderPart *find_next_part(Render *re, int minx)
        /* find center of rendered parts, image center counts for 1 too */
        for (pa = re->parts.first; pa; pa = pa->next) {
                if (pa->ready) {
-                       centx += (pa->disprect.xmin + pa->disprect.xmax) / 2;
-                       centy += (pa->disprect.ymin + pa->disprect.ymax) / 2;
+                       centx += BLI_RCT_CENTER_X(&pa->disprect);
+                       centy += BLI_RCT_CENTER_Y(&pa->disprect);
                        tot++;
                }
        }
@@ -751,8 +752,8 @@ static RenderPart *find_next_part(Render *re, int minx)
        /* closest of the non-rendering parts */
        for (pa = re->parts.first; pa; pa = pa->next) {
                if (pa->ready == 0 && pa->nr == 0) {
-                       long long int distx = centx - (pa->disprect.xmin + pa->disprect.xmax) / 2;
-                       long long int disty = centy - (pa->disprect.ymin + pa->disprect.ymax) / 2;
+                       long long int distx = centx - BLI_RCT_CENTER_X(&pa->disprect);
+                       long long int disty = centy - BLI_RCT_CENTER_Y(&pa->disprect);
                        distx = (long long int)sqrt(distx * distx + disty * disty);
                        if (distx < mindist) {
                                if (re->r.mode & R_PANORAMA) {
index f1c4c0b15afd5d418a42436b972211af86e3bf57..022d7846d80d673b5029043e54150fd083772029 100644 (file)
@@ -43,6 +43,7 @@
 #include "BLI_fileops.h"
 #include "BLI_listbase.h"
 #include "BLI_path_util.h"
+#include "BLI_rect.h"
 #include "BLI_string.h"
 #include "BLI_threads.h"
 #include "BLI_utildefines.h"
@@ -420,8 +421,8 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
        SceneRenderLayer *srl;
        int rectx, recty, nr;
        
-       rectx = partrct->xmax - partrct->xmin;
-       recty = partrct->ymax - partrct->ymin;
+       rectx = BLI_RCT_SIZE_X(partrct);
+       recty = BLI_RCT_SIZE_Y(partrct);
        
        if (rectx <= 0 || recty <= 0)
                return NULL;
@@ -566,8 +567,8 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
        }
        
        /* border render; calculate offset for use in compositor. compo is centralized coords */
-       rr->xof = re->disprect.xmin + (re->disprect.xmax - re->disprect.xmin) / 2 - re->winx / 2;
-       rr->yof = re->disprect.ymin + (re->disprect.ymax - re->disprect.ymin) / 2 - re->winy / 2;
+       rr->xof = re->disprect.xmin + BLI_RCT_CENTER_X(&re->disprect) - (re->winx / 2);
+       rr->yof = re->disprect.ymin + BLI_RCT_CENTER_Y(&re->disprect) - (re->winy / 2);
        
        return rr;
 }
index 660117de9f74af1626246750881daa8782f18e2b..48b552acf269e206623d5cf0bdde459549ba3a86 100644 (file)
@@ -380,8 +380,6 @@ void WM_file_read(bContext *C, const char *filepath, ReportList *reports)
                /* assume automated tasks with background, don't write recent file list */
                const int do_history = (G.background == FALSE) && (CTX_wm_manager(C)->op_undo_depth == 0);
 
-               BKE_vfont_free_global_ttf();
-
                /* put aside screens to match with persistent windows later */
                /* also exit screens and editors */
                wm_window_match_init(C, &wmbase); 
@@ -490,9 +488,7 @@ int WM_homefile_read(bContext *C, ReportList *UNUSED(reports), short from_memory
        ListBase wmbase;
        char tstr[FILE_MAX];
        int success = 0;
-       
-       BKE_vfont_free_global_ttf();
-               
+
        G.relbase_valid = 0;
        if (!from_memory) {
                char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL);
index c9f1a2587dfe4a2e632fdcc5ccb5dbb23fef5c7d..2928ba024e5714dce34384dee26b5b0ae0185d0e 100644 (file)
@@ -130,8 +130,8 @@ int wm_gesture_evaluate(wmGesture *gesture)
 {
        if (gesture->type == WM_GESTURE_TWEAK) {
                rcti *rect = gesture->customdata;
-               int dx = rect->xmax - rect->xmin;
-               int dy = rect->ymax - rect->ymin;
+               int dx = BLI_RCT_SIZE_X(rect);
+               int dy = BLI_RCT_SIZE_Y(rect);
                if (ABS(dx) + ABS(dy) > U.tweak_threshold) {
                        int theta = (int)floor(4.0f * atan2f((float)dy, (float)dx) / (float)M_PI + 0.5f);
                        int val = EVT_GESTURE_W;
index a892b1c686144697d932f474eefbb7da892840f0..a1c46e4e6a277b5db85f8d0a49101c712eae5067 100644 (file)
@@ -402,8 +402,6 @@ void WM_exit_ext(bContext *C, const short do_python)
 //     BIF_GlobalReebFree();
 //     BIF_freeRetarget();
        BIF_freeTemplates(C);
-       
-       BKE_vfont_free_global_ttf(); /* bke_font.h */
 
        free_openrecent();
        
index 3c791cb6e5d42861749967a0ff088894fcbc0699..9fc3bf9cecee7d903dfce36706a85e97b4cf5e28 100644 (file)
 
 #include "PIL_time.h"
 
+#include "BLI_fileops.h"
 #include "BLI_listbase.h"
-#include "BLI_string.h"
 #include "BLI_path_util.h"
-#include "BLI_fileops.h"
 #include "BLI_rect.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
 
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
-#ifdef WITH_QUICKTIME
-#  ifdef _WIN32
-#    include <QTML.h>
-#    include <Movies.h>
-#  elif defined(__APPLE__)
-#    include <QuickTime/Movies.h>
-#  endif /* __APPLE__ */
-#endif /* WITH_QUICKTIME */
-
 #include "DNA_scene_types.h"
-#include "BLI_utildefines.h"
 #include "ED_datafiles.h" /* for fonts */
-#include "wm_event_types.h"
 #include "GHOST_C-api.h"
 #include "BLF_api.h"
 
+#include "wm_event_types.h"
 
 typedef struct PlayState {
 
@@ -827,26 +818,6 @@ void playanim(int argc, const char **argv)
                }
        }
 
-#ifdef WITH_QUICKTIME
-#if defined(_WIN32) || defined(__APPLE__) && !defined(GHOST_COCOA)
-       /* Initialize QuickTime */
-#ifndef noErr
-#define noErr 0
-#endif
-
-#ifdef _WIN32
-       if (InitializeQTML(0) != noErr)
-               G.have_quicktime = FALSE;
-       else
-               G.have_quicktime = TRUE;
-#endif /* _WIN32 */
-       if (EnterMov