From 37bf7dd98a494c1dd80459aa017bb796f699261b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 2 Apr 2013 10:48:11 +0000 Subject: draw helper lines for inset and bevel operators, the mouse distance from the selection center was used, but often it was hard to tell where this was and you'd have to guess. adds ED_region_draw_mouse_line_cb() generic draw callback for mouse helper lines. --- source/blender/editors/util/ed_util.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/blender/editors/util') diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 73062c57526..7e14e8cf2a3 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -37,11 +37,15 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" +#include "DNA_screen_types.h" #include "DNA_scene_types.h" #include "DNA_packedFile_types.h" #include "BLI_blenlib.h" +#include "BIF_gl.h" +#include "BIF_glutil.h" + #include "BLF_translation.h" #include "BKE_context.h" @@ -54,6 +58,7 @@ #include "ED_mesh.h" #include "ED_object.h" #include "ED_sculpt.h" +#include "ED_space_api.h" #include "ED_util.h" #include "UI_interface.h" @@ -255,3 +260,24 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha uiPupMenuEnd(C, pup); } + +/* ********************* generic callbacks for drawcall api *********************** */ + +/** + * Callback that draws a line between the mouse and a position given as the initial argument. + */ +void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info) +{ + wmWindow *win = CTX_wm_window(C); + const int *mval_src = (int *)arg_info; + const int mval_dst[2] = {win->eventstate->x - ar->winrct.xmin, + win->eventstate->y - ar->winrct.ymin}; + + UI_ThemeColor(TH_WIRE); + setlinestyle(3); + glBegin(GL_LINE_STRIP); + glVertex2iv(mval_dst); + glVertex2iv(mval_src); + glEnd(); + setlinestyle(0); +} -- cgit v1.2.3