diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2015-08-18 10:03:19 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2015-08-18 10:03:19 +0300 |
commit | 43284f1a1b5b2cc663b199c16f2706cc4ae4aba7 (patch) | |
tree | 0946996c245cdffdfafaf2433d2eb2f4915eb79f /source/blender/windowmanager | |
parent | 81545372fe1452e1efe30a70188ab02013210f57 (diff) |
Allow widgets to define custom line width (and use for manipulator)
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_generic_widgets.c | 33 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_widgets.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/wm.h | 8 |
4 files changed, 28 insertions, 20 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index ae6b4a4e649..42a3f52524e 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -519,6 +519,7 @@ void WM_widget_flag_set(struct wmWidget *widget, const int flag, const bool enab void WM_widget_set_draw_on_hover_only(struct wmWidget *widget, const bool draw); void WM_widget_set_scene_depth(struct wmWidget *widget, const bool scene); void WM_widget_set_scale(struct wmWidget *widget, float scale); +void WM_widget_set_line_width(struct wmWidget *widget, const float line_width); struct wmWidgetMapType *WM_widgetmaptype_find(const char *idname, const int spaceid, const int regionid, const bool is_3d, const bool create); diff --git a/source/blender/windowmanager/intern/wm_generic_widgets.c b/source/blender/windowmanager/intern/wm_generic_widgets.c index b2c08ef6207..bd63edab6d3 100644 --- a/source/blender/windowmanager/intern/wm_generic_widgets.c +++ b/source/blender/windowmanager/intern/wm_generic_widgets.c @@ -79,8 +79,6 @@ /* to use custom dials exported to arrow_widget.c */ //#define WIDGET_USE_CUSTOM_DIAS -#define WIDGET_LINE_WIDTH 2.0 - const float highlight_col[] = {1.0f, 1.0f, 0.45f, 1.0f}; @@ -186,7 +184,7 @@ static void widget_arrow_get_final_pos(wmWidget *widget, float r_pos[3]) add_v3_v3(r_pos, arrow->widget.origin); } -static void arrow_draw_geom(ArrowWidget *arrow, const bool select) +static void arrow_draw_geom(const ArrowWidget *arrow, const bool select) { glEnable(GL_MULTISAMPLE_ARB); @@ -210,7 +208,7 @@ static void arrow_draw_geom(ArrowWidget *arrow, const bool select) const float len = 0.25f; const float width = 0.06f; - glLineWidth(WIDGET_LINE_WIDTH); + glLineWidth(arrow->widget.line_width); glBegin(GL_LINES); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 0.0, 1.0); @@ -557,7 +555,7 @@ typedef struct DialWidget { float color[4]; } DialWidget; -static void dial_draw_geom(const bool select) +static void dial_draw_geom(const DialWidget *dial, const bool select) { GLUquadricObj *qobj = gluNewQuadric(); const float width = 1.0f; @@ -571,7 +569,7 @@ static void dial_draw_geom(const bool select) (void)qobj; (void)width; (void)resol; #else - glLineWidth(WIDGET_LINE_WIDTH); + glLineWidth(dial->widget.line_width); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluDisk(qobj, 0.0, width, resol, 1); glLineWidth(1.0); @@ -601,7 +599,7 @@ static void dial_draw_intern(DialWidget *dial, const bool select, const bool hig else glColor4fv(dial->color); - dial_draw_geom(select); + dial_draw_geom(dial, select); glPopMatrix(); @@ -744,11 +742,11 @@ static void rect_transform_draw_corners(rctf *r, const float offsetx, const floa glVertex2f(r->xmin, r->ymax); glVertex2f(r->xmin, r->ymax); glVertex2f(r->xmin + offsetx, r->ymax); - glEnd(); + glEnd(); } static void rect_transform_draw_interaction(const int highlighted, const float half_w, const float half_h, - const float w, const float h) + const float w, const float h, const float line_width) { float verts[4][2]; unsigned short elems[4] = {0, 1, 3, 2}; @@ -804,12 +802,13 @@ static void rect_transform_draw_interaction(const int highlighted, const float h glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, verts); - glLineWidth(3.0); + glLineWidth(line_width + 3.0); glColor3f(0.0, 0.0, 0.0); glDrawArrays(GL_LINE_STRIP, 0, 3); - glLineWidth(1.0); + glLineWidth(line_width); glColor3f(1.0, 1.0, 1.0); glDrawArrays(GL_LINE_STRIP, 0, 3); + glLineWidth(1.0); (void)elems; } @@ -846,16 +845,18 @@ static void widget_rect_transform_draw(const bContext *UNUSED(C), wmWidget *widg /* corner widgets */ glColor3f(0.0, 0.0, 0.0); - glLineWidth(3.0); - + glLineWidth(cage->widget.line_width + 3.0f); + rect_transform_draw_corners(&r, w, h); /* corner widgets */ glColor3f(1.0, 1.0, 1.0); - glLineWidth(1.0); + glLineWidth(cage->widget.line_width); rect_transform_draw_corners(&r, w, h); - - rect_transform_draw_interaction(widget->highlighted_part, half_w, half_h, w, h); + + rect_transform_draw_interaction(widget->highlighted_part, half_w, half_h, w, h, cage->widget.line_width); + + glLineWidth(1.0); glPopMatrix(); } diff --git a/source/blender/windowmanager/intern/wm_widgets.c b/source/blender/windowmanager/intern/wm_widgets.c index d5b53eb7860..3446bb4763f 100644 --- a/source/blender/windowmanager/intern/wm_widgets.c +++ b/source/blender/windowmanager/intern/wm_widgets.c @@ -444,6 +444,7 @@ bool wm_widget_register(wmWidgetGroup *wgroup, wmWidget *widget, const char *nam widget_unique_idname_set(wgroup, widget, name); widget->user_scale = 1.0f; + widget->line_width = 1.0f; /* create at least one property for interaction */ if (widget->max_prop == 0) { @@ -508,6 +509,11 @@ void WM_widget_set_scale(wmWidget *widget, const float scale) widget->user_scale = scale; } +void WM_widget_set_line_width(wmWidget *widget, const float line_width) +{ + widget->line_width = line_width; +} + wmWidgetMapType *WM_widgetmaptype_find( const char *idname, const int spaceid, const int regionid, const bool is_3d, const bool create) diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h index a19ba21abe1..3feb8439ab8 100644 --- a/source/blender/windowmanager/wm.h +++ b/source/blender/windowmanager/wm.h @@ -91,6 +91,9 @@ typedef struct wmWidget { /* user defined scale, in addition to the original one */ float user_scale; + /* user defined width for line drawing */ + float line_width; + /* data used during interaction */ void *interaction_data; @@ -113,13 +116,10 @@ enum widgetflags { /* states */ WM_WIDGET_HIGHLIGHT = (1 << 0), WM_WIDGET_ACTIVE = (1 << 1), - WM_WIDGET_DRAW_HOVER = (1 << 2), - WM_WIDGET_SCALE_3D = (1 << 3), WM_WIDGET_SCENE_DEPTH = (1 << 4), /* widget is depth culled with scene objects*/ - - WM_WIDGET_HIDDEN = (1 << 5), /* prevent widget drawing */ + WM_WIDGET_HIDDEN = (1 << 5), }; extern void wm_close_and_free(bContext *C, wmWindowManager *); |