Gizmo: reset dial value on cancel
authorCampbell Barton <ideasman42@gmail.com>
Tue, 25 Sep 2018 04:37:19 +0000 (14:37 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 25 Sep 2018 04:37:19 +0000 (14:37 +1000)
source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c

index cb474255fd49da4c32586a218c4dfc8844436e76..d09acfa87613f3483479145108d08a6639caad99 100644 (file)
@@ -459,6 +459,18 @@ static int gizmo_dial_modal(
        return OPERATOR_RUNNING_MODAL;
 }
 
+static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel)
+{
+       DialInteraction *inter = gz->interaction_data;
+       if (cancel) {
+               /* Set the property for the operator and call its modal function. */
+               wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
+               if (WM_gizmo_target_property_is_valid(gz_prop)) {
+                       WM_gizmo_target_property_float_set(C, gz, gz_prop, inter->init.prop_angle);
+               }
+       }
+}
+
 
 static void gizmo_dial_setup(wmGizmo *gz)
 {
@@ -502,6 +514,7 @@ static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
        gzt->setup = gizmo_dial_setup;
        gzt->invoke = gizmo_dial_invoke;
        gzt->modal = gizmo_dial_modal;
+       gzt->exit = gizmo_dial_exit;
 
        gzt->struct_size = sizeof(wmGizmo);