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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-09-25 08:14:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-09-25 08:15:38 +0300
commit518451757e3a809978417e1ef30cf85a725dae86 (patch)
tree36abd09724a4a1f316c3cb08b39dcf65f3b084bd /source
parent1040e4008ca84936c1e051686a29d810d76c7ca2 (diff)
Gizmo: dial support for a click setting a value
Useful for click w/o drag to spin a full revolution.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c31
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c12
2 files changed, 42 insertions, 1 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
index d09acfa8761..48ac16290df 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
@@ -88,6 +88,7 @@ typedef struct DialInteraction {
/* Number of full rotations. */
int rotations;
+ bool has_drag;
/* Final output values, used for drawing. */
struct {
@@ -445,6 +446,10 @@ static int gizmo_dial_modal(
if (tweak_flag & WM_GIZMO_TWEAK_PRECISE) {
angle_delta *= 0.1f;
}
+ if (angle_delta != 0.0f) {
+ inter->has_drag = true;
+ }
+
inter->output.angle_delta = angle_delta;
inter->output.angle_ofs = angle_ofs;
@@ -462,13 +467,33 @@ static int gizmo_dial_modal(
static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel)
{
DialInteraction *inter = gz->interaction_data;
+ bool use_reset_value = false;
+ float reset_value = 0.0f;
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);
+ use_reset_value = true;
+ reset_value = inter->init.prop_angle;
+ }
+ }
+ else {
+ if (inter->has_drag == false) {
+ PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "click_value");
+ if (RNA_property_is_set(gz->ptr, prop)) {
+ use_reset_value = true;
+ reset_value = RNA_property_float_get(gz->ptr, prop);
+ }
+ }
+ }
+
+ if (use_reset_value) {
+ 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, reset_value);
}
}
+
}
@@ -531,6 +556,10 @@ static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
RNA_def_boolean(gzt->srna, "wrap_angle", true, "Wrap Angle", "");
RNA_def_float_factor(gzt->srna, "arc_inner_factor", 0.0f, 0.0f, 1.0f, "Arc Inner Factor", "", 0.0f, 1.0f);
RNA_def_float_factor(gzt->srna, "arc_partial_angle", 0.0f, 0.0f, M_PI * 2, "Show Partial Dial", "", 0.0f, M_PI * 2);
+ RNA_def_float(
+ gzt->srna, "click_value", 0.0f, -FLT_MAX, FLT_MAX,
+ "Click Value", "Value to use for a single click action",
+ -FLT_MAX, FLT_MAX);
WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1);
}
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index 5978f521bb9..6c8deb42a7a 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -426,6 +426,8 @@ typedef struct GizmoGroupData_SpinRedo {
float plane_no[3];
} prev;
+ bool is_init;
+
/* We could store more vars here! */
struct {
bContext *context;
@@ -457,6 +459,13 @@ typedef struct GizmoGroupData_SpinRedo {
*/
static void gizmo_spin_exec(GizmoGroupData_SpinRedo *ggd)
{
+ if (ggd->is_init) {
+ wmGizmo *gz = ggd->angle_z;
+ PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "click_value");
+ RNA_property_unset(gz->ptr, prop);
+ ggd->is_init = false;
+ }
+
wmOperator *op = ggd->data.op;
if (op == WM_operator_last_redo((bContext *)ggd->data.context)) {
ED_undo_operator_repeat((bContext *)ggd->data.context, op);
@@ -729,6 +738,8 @@ static void gizmo_mesh_spin_redo_modal_from_setup(
}
#endif
+ ggd->is_init = true;
+
WM_gizmo_modal_set_from_setup(
gzmap, (bContext *)C, gz, 0, win->eventstate);
}
@@ -784,6 +795,7 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup)
RNA_boolean_set(gz->ptr, "wrap_angle", false);
RNA_enum_set(gz->ptr, "draw_options", ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE);
RNA_float_set(gz->ptr, "arc_inner_factor", 0.9f);
+ RNA_float_set(gz->ptr, "click_value", M_PI * 2);
WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_VALUE, true);
WM_gizmo_set_scale(gz, 2.0f);
WM_gizmo_set_line_width(gz, 1.0f);