diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-11-12 16:03:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-11-12 16:03:12 +0300 |
commit | 46f452e96baaf9424582003e87736840ccbbffca (patch) | |
tree | 473504617269380df580b584854b6ef8feaad570 /source/blender/editors | |
parent | 833ef0cfdd0ac9154f018c17a80ca8cdc7c15bc9 (diff) |
Fix error cutting node links
Accessing theme from outside drawing code isn't reliable, pass space-type.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/UI_resources.h | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_relationships.c | 2 |
5 files changed, 25 insertions, 4 deletions
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 2b19b6180e5..cd68425cc33 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -334,6 +334,9 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int float UI_GetThemeValuef(int colorid); int UI_GetThemeValue(int colorid); +float UI_GetThemeValueTypef(int colorid, int spacetype); +int UI_GetThemeValueType(int colorid, int spacetype); + // get three color values, scaled to 0.0-1.0 range void UI_GetThemeColor3fv(int colorid, float col[3]); void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index f4051da10ca..92ef0d0ab37 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1382,6 +1382,23 @@ int UI_GetThemeValue(int colorid) return ((int) cp[0]); } +/* versions of the function above, which take a space-type */ +float UI_GetThemeValueTypef(int colorid, int spacetype) +{ + const unsigned char *cp; + + cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid); + return ((float)cp[0]); +} + +int UI_GetThemeValueType(int colorid, int spacetype) +{ + const unsigned char *cp; + + cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid); + return ((int)cp[0]); +} + /* get the color, range 0.0-1.0 */ void UI_GetThemeColor3fv(int colorid, float col[3]) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 960a5614097..caee0cac8fb 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3335,7 +3335,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b /* if v2d not NULL, it clips and returns 0 if not visible */ -int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol) +bool node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol) { float dist, vec[4][2]; float deltax, deltay; @@ -3371,7 +3371,8 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa toreroute = 0; } - dist = UI_GetThemeValue(TH_NODE_CURVING) * 0.10f * fabsf(vec[0][0] - vec[3][0]); + /* may be called outside of drawing (so pass spacetype) */ + dist = UI_GetThemeValueType(TH_NODE_CURVING, SPACE_NODE) * 0.10f * fabsf(vec[0][0] - vec[3][0]); deltax = vec[3][0] - vec[0][0]; deltay = vec[3][1] - vec[0][1]; /* check direction later, for top sockets */ diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index b08c9b10eeb..444e81155d8 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -133,7 +133,7 @@ void NODE_OT_backimage_sample(struct wmOperatorType *ot); /* drawnode.c */ void node_draw_link(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link); void node_draw_link_bezier(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link, int th_col1, bool do_shaded, int th_col2, bool do_triple, int th_col3); -int node_link_bezier_points(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link, float coord_array[][2], int resol); +bool node_link_bezier_points(struct View2D *v2d, struct SpaceNode *snode, struct bNodeLink *link, float coord_array[][2], int resol); // void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 ); void draw_nodespace_back_pix(const struct bContext *C, struct ARegion *ar, struct SpaceNode *snode, bNodeInstanceKey parent_key); diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 4097db29e5a..3bd72370f5f 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -849,7 +849,7 @@ void NODE_OT_link_make(wmOperatorType *ot) } /* ********************** Cut Link operator ***************** */ -static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) +static bool cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) { float coord_array[NODE_LINK_RESOL + 1][2]; int i, b; |