[Bf-blender-cvs] [8b90c08] wiggly-widgets: Ring widgets:
Antony Riakiotakis
noreply at git.blender.org
Wed Oct 15 15:45:32 CEST 2014
Commit: 8b90c081b0575d923674e96dc89160025296d02e
Author: Antony Riakiotakis
Date: Wed Oct 15 15:45:17 2014 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB8b90c081b0575d923674e96dc89160025296d02e
Ring widgets:
Add a clipping style, just like manipulator
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_generic_widgets.c
M source/blender/editors/space_view3d/space_view3d.c
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 560f511..4ca7a1d 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1001,8 +1001,13 @@ int uiFloatPrecisionCalc(int prec, double value);
/* ui_generic_widgets.c */
enum {
- UI_ARROW_STYLE_SHADED = 0,
- UI_ARROW_STYLE_COLORED = 0,
+ UI_ARROW_STYLE_NORMAL = 0,
+ UI_ARROW_STYLE_NO_AXIS = 1,
+};
+
+enum {
+ UI_DIAL_STYLE_RING = 0,
+ UI_DIAL_STYLE_RING_CLIPPED = 1,
};
struct wmWidget *WIDGET_arrow_new(int style, int (*handler)(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget));
diff --git a/source/blender/editors/interface/interface_generic_widgets.c b/source/blender/editors/interface/interface_generic_widgets.c
index f8c7e02..e6d1f7b 100644
--- a/source/blender/editors/interface/interface_generic_widgets.c
+++ b/source/blender/editors/interface/interface_generic_widgets.c
@@ -253,15 +253,49 @@ static void dial_draw_intern(DialWidget *dial, bool select, bool highlight, floa
}
-static void widget_dial_render_3d_intersect(const struct bContext *UNUSED(C), struct wmWidget *widget, float scale, int selectionbase)
+static void widget_dial_render_3d_intersect(const struct bContext *C, struct wmWidget *widget, float scale, int selectionbase)
{
+ DialWidget *dial = (DialWidget *)widget;
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
+
+ /* enable clipping if needed */
+ if (dial->style == UI_DIAL_STYLE_RING_CLIPPED) {
+ double plane[4];
+ copy_v3db_v3fl(plane, rv3d->viewinv[2]);
+ plane[3] = -dot_v3v3(rv3d->viewinv[2], widget->origin);
+ glClipPlane(GL_CLIP_PLANE0, plane);
+ glEnable(GL_CLIP_PLANE0);
+ }
+
GPU_select_load_id(selectionbase);
- dial_draw_intern((DialWidget *)widget, true, false, scale);
+ dial_draw_intern(dial, true, false, scale);
+
+ if (dial->style == UI_DIAL_STYLE_RING_CLIPPED) {
+ glDisable(GL_CLIP_PLANE0);
+ }
}
-static void widget_dial_draw(struct wmWidget *widget, const struct bContext *UNUSED(C), float scale)
+static void widget_dial_draw(struct wmWidget *widget, const struct bContext *C, float scale)
{
- dial_draw_intern((DialWidget *)widget, false, (widget->flag & WM_WIDGET_HIGHLIGHT) != 0, scale);
+ DialWidget *dial = (DialWidget *)widget;
+ ARegion *ar = CTX_wm_region(C);
+ RegionView3D *rv3d = ar->regiondata;
+
+ /* enable clipping if needed */
+ if (dial->style == UI_DIAL_STYLE_RING_CLIPPED) {
+ double plane[4];
+ copy_v3db_v3fl(plane, rv3d->viewinv[2]);
+ plane[3] = -dot_v3v3(rv3d->viewinv[2], widget->origin);
+ glClipPlane(GL_CLIP_PLANE0, plane);
+ glEnable(GL_CLIP_PLANE0);
+ }
+
+ dial_draw_intern(dial, false, (widget->flag & WM_WIDGET_HIGHLIGHT) != 0, scale);
+
+ if (dial->style == UI_DIAL_STYLE_RING_CLIPPED) {
+ glDisable(GL_CLIP_PLANE0);
+ }
}
wmWidget *WIDGET_dial_new(int style, int (*handler)(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget))
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index bcdb612..a435293 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -727,16 +727,16 @@ static void view3d_widgets(void)
WIDGET_arrow_set_color(manipulator->translate_z, color_blue);
WM_widget_register(wgroup_manipulator, manipulator->translate_z);
- manipulator->rotate_x = WIDGET_dial_new(0, WIDGET_manipulator_handler_rot);
+ manipulator->rotate_x = WIDGET_dial_new(UI_DIAL_STYLE_RING_CLIPPED, WIDGET_manipulator_handler_rot);
WIDGET_dial_set_color(manipulator->rotate_x, color_red);
WM_widget_register(wgroup_manipulator, manipulator->rotate_x);
- manipulator->rotate_y = WIDGET_dial_new(0, WIDGET_manipulator_handler_rot);
+ manipulator->rotate_y = WIDGET_dial_new(UI_DIAL_STYLE_RING_CLIPPED, WIDGET_manipulator_handler_rot);
manipulator->rotate_y->customdata = SET_INT_IN_POINTER(1);
WIDGET_dial_set_color(manipulator->rotate_y, color_green);
WM_widget_register(wgroup_manipulator, manipulator->rotate_y);
- manipulator->rotate_z = WIDGET_dial_new(0, WIDGET_manipulator_handler_rot);
+ manipulator->rotate_z = WIDGET_dial_new(UI_DIAL_STYLE_RING_CLIPPED, WIDGET_manipulator_handler_rot);
manipulator->rotate_z->customdata = SET_INT_IN_POINTER(2);
WIDGET_dial_set_color(manipulator->rotate_z, color_blue);
WM_widget_register(wgroup_manipulator, manipulator->rotate_z);
More information about the Bf-blender-cvs
mailing list