Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2015-08-18 10:03:19 +0300
committerJulian Eisel <eiseljulian@gmail.com>2015-08-18 10:03:19 +0300
commit43284f1a1b5b2cc663b199c16f2706cc4ae4aba7 (patch)
tree0946996c245cdffdfafaf2433d2eb2f4915eb79f
parent81545372fe1452e1efe30a70188ab02013210f57 (diff)
Allow widgets to define custom line width (and use for manipulator)
-rw-r--r--source/blender/editors/transform/manipulator_widget.c4
-rw-r--r--source/blender/windowmanager/WM_api.h1
-rw-r--r--source/blender/windowmanager/intern/wm_generic_widgets.c33
-rw-r--r--source/blender/windowmanager/intern/wm_widgets.c6
-rw-r--r--source/blender/windowmanager/wm.h8
5 files changed, 32 insertions, 20 deletions
diff --git a/source/blender/editors/transform/manipulator_widget.c b/source/blender/editors/transform/manipulator_widget.c
index 73056f685ce..bc07a4a51f2 100644
--- a/source/blender/editors/transform/manipulator_widget.c
+++ b/source/blender/editors/transform/manipulator_widget.c
@@ -147,6 +147,8 @@ enum {
#define TW_AXIS_DOT_MIN 0.02f
#define TW_AXIS_DOT_MAX 0.1f
+#define MAN_AXIS_LINE_WIDTH 2.0
+
/* **************** Utilities **************** */
@@ -949,6 +951,7 @@ void WIDGETGROUP_manipulator_draw(const struct bContext *C, struct wmWidgetGroup
WIDGET_dial_set_color(axis, col);
}
else {
+ WM_widget_set_line_width(axis, MAN_AXIS_LINE_WIDTH);
WIDGET_arrow_set_direction(axis, rv3d->twmat[axis_idx]);
WIDGET_arrow_set_color(axis, col);
}
@@ -958,6 +961,7 @@ void WIDGETGROUP_manipulator_draw(const struct bContext *C, struct wmWidgetGroup
WIDGET_dial_set_direction(axis, rv3d->viewinv[2]);
}
else {
+ WM_widget_set_line_width(axis, MAN_AXIS_LINE_WIDTH);
WIDGET_dial_set_direction(axis, rv3d->twmat[manipulator_index_normalize(axis_idx)]);
}
WIDGET_dial_set_color(axis, col);
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 *);