[Bf-blender-cvs] [e15819d] wiggly-widgets: Green widget handles y translation properly.
Antony Riakiotakis
noreply at git.blender.org
Wed Oct 8 18:32:19 CEST 2014
Commit: e15819daf36eb473e5fe0c0e50fcc475a6dc65d1
Author: Antony Riakiotakis
Date: Wed Oct 8 18:32:06 2014 +0200
Branches: wiggly-widgets
https://developer.blender.org/rBe15819daf36eb473e5fe0c0e50fcc475a6dc65d1
Green widget handles y translation properly.
===================================================================
M source/blender/editors/include/ED_transform.h
M source/blender/editors/space_view3d/space_view3d.c
M source/blender/editors/transform/transform_manipulator.c
M source/blender/windowmanager/intern/wm_widgets.c
===================================================================
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index dcb9583..c1b20b8 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -164,6 +164,9 @@ typedef struct ManipulatorGroup {
} ManipulatorGroup;
int WIDGET_manipulator_handler(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget);
+
+int WIDGET_manipulator_handler_trans_y(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget);
+
void WIDGET_manipulator_render_3d_intersect(const struct bContext *C, struct wmWidget *widget, int selectionbase);
void WIDGET_manipulator_draw(struct wmWidget *widget, const struct bContext *C);
bool WIDGETGROUP_manipulator_poll(struct wmWidgetGroup *wgroup, const struct bContext *C);
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 6d3be4c..5c5c6b3 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -709,7 +709,7 @@ static void view3d_widgets(void)
WM_widget_register(wgroup_manipulator, widget);
- manipulator->translate_y = WIDGET_arrow_new(0, NULL);
+ manipulator->translate_y = WIDGET_arrow_new(0, WIDGET_manipulator_handler_trans_y);
WIDGET_arrow_set_color(manipulator->translate_y, color_green);
widget = WM_widget_new(WIDGET_lamp_draw,
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 0729e36..a2aefb6 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1685,13 +1685,15 @@ void WIDGET_manipulator_draw(wmWidget *UNUSED(widget), const bContext *C)
}
}
-void WIDGETGROUP_manipulator_update(struct wmWidgetGroup *UNUSED(wgroup), const struct bContext *C)
+void WIDGETGROUP_manipulator_update(struct wmWidgetGroup *wgroup, const struct bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
+ ManipulatorGroup *manipulator = WM_widgetgroup_customdata(wgroup);
+
int totsel;
v3d->twflag &= ~V3D_DRAW_MANIPULATOR;
@@ -1735,6 +1737,11 @@ void WIDGETGROUP_manipulator_update(struct wmWidgetGroup *UNUSED(wgroup), const
test_manipulator_axis(C);
drawflags = rv3d->twdrawflag; /* set in calc_manipulator_stats */
+
+ if (drawflags & MAN_TRANS_Y)
+ WM_widget_register(wgroup, manipulator->translate_y);
+ else
+ WM_widget_unregister(wgroup, manipulator->translate_y);
}
@@ -1906,6 +1913,47 @@ int WIDGET_manipulator_handler(bContext *C, const struct wmEvent *event, wmWidge
return (val) ? OPERATOR_FINISHED : OPERATOR_PASS_THROUGH;
}
+/* return 0; nothing happened */
+int WIDGET_manipulator_handler_trans_y(bContext *C, const struct wmEvent *event, wmWidget *UNUSED(widget))
+{
+ ScrArea *sa = CTX_wm_area(C);
+ View3D *v3d = sa->spacedata.first;
+ int constraint_axis[3] = {0, 0, 0};
+ int shift = event->shift;
+
+ struct IDProperty *properties = NULL; /* operator properties, assigned to ptr->data and can be written to a file */
+ struct PointerRNA *ptr = NULL; /* rna pointer to access properties */
+
+ if (!((v3d->twflag & V3D_USE_MANIPULATOR) && (v3d->twflag & V3D_DRAW_MANIPULATOR)) ||
+ !(event->keymodifier == 0 || event->keymodifier == KM_SHIFT) ||
+ !((event->val == KM_PRESS) && (event->type == LEFTMOUSE)))
+ {
+ return OPERATOR_PASS_THROUGH;
+ }
+
+ if (shift) {
+ constraint_axis[1] = 1;
+ constraint_axis[0] = 1;
+ }
+ else
+ constraint_axis[1] = 1;
+
+ WM_operator_properties_alloc(&ptr, &properties, "TRANSFORM_OT_translate");
+ /* Force orientation */
+ RNA_boolean_set(ptr, "release_confirm", true);
+ RNA_enum_set(ptr, "constraint_orientation", v3d->twmode);
+ RNA_boolean_set_array(ptr, "constraint_axis", constraint_axis);
+ WM_operator_name_call(C, "TRANSFORM_OT_translate", WM_OP_INVOKE_DEFAULT, ptr);
+ //wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL, false);
+
+ if (ptr) {
+ WM_operator_properties_free(ptr);
+ MEM_freeN(ptr);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
void WIDGETGROUP_manipulator_free(struct wmWidgetGroup *wgroup)
{
diff --git a/source/blender/windowmanager/intern/wm_widgets.c b/source/blender/windowmanager/intern/wm_widgets.c
index f8e793e..403853c 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -228,11 +228,13 @@ bool WM_widgetgroup_register(struct wmWidgetMap *wmap, wmWidgetGroup *wgroup)
void WM_widgetgroup_unregister(struct wmWidgetMap *wmap, wmWidgetGroup *wgroup)
{
BLI_remlink(&wmap->widgetgroups, wgroup);
+ wmap->prev = wmap->next = NULL;
}
void WM_widget_unregister(struct wmWidgetGroup *wgroup, wmWidget *widget)
{
BLI_remlink(&wgroup->widgets, widget);
+ widget->prev = widget->next = NULL;
}
wmWidgetMap *WM_widgetmap_find(const char *idname, int spaceid, int regionid, bool is_3d)
More information about the Bf-blender-cvs
mailing list