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:
authorHans Goudey <h.goudey@me.com>2020-06-24 18:50:01 +0300
committerHans Goudey <h.goudey@me.com>2020-06-24 18:50:01 +0300
commitbaff05ad1c156ca477375c440e2c5b92cad214e9 (patch)
treeb89d9d5a9e9611247d964d5e9b0ccd098bf88c2d /source/blender/makesrna/intern/rna_curveprofile.c
parentec7510b458528eb8dcdf2c538a2b805813940447 (diff)
UI: Add Free Handle Types to CurveProfile Widget
Under the hood the CurveProfile widget (used for bevel custom profiles) uses a bezier curve, but right now though it only supports two of the bezier curve handle types, vector and auto. This patch adds support for free handles and adds all of the logic for editing them. This is the first step to the ability to import and export curve objects in the widget. There's some code cleanup in curveprofile.c. Movement for handles and control points is abstracted to functions there rather than happening in interface_handlers.c. An "Apply Preset" button is also added, which solves a confusing issue where you apply a preset, then change the number of samples and the preset doesn't change. The button makes it clear that the preset needs to be reapplied. Reviewed By: Severin Differential Revision: https://developer.blender.org/D6470
Diffstat (limited to 'source/blender/makesrna/intern/rna_curveprofile.c')
-rw-r--r--source/blender/makesrna/intern/rna_curveprofile.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_curveprofile.c b/source/blender/makesrna/intern/rna_curveprofile.c
index 94a35bdede8..ce91fc79085 100644
--- a/source/blender/makesrna/intern/rna_curveprofile.c
+++ b/source/blender/makesrna/intern/rna_curveprofile.c
@@ -62,6 +62,22 @@
# include "IMB_colormanagement.h"
# include "IMB_imbuf.h"
+/**
+ * Set both handle types for all selected points in the profile-- faster than changing types
+ * for many points individually. Also set both handles for the points.
+ */
+static void rna_CurveProfilePoint_handle_type_set(PointerRNA *ptr, int value)
+{
+ CurveProfilePoint *point = ptr->data;
+ CurveProfile *profile = point->profile;
+
+ if (profile) {
+ BKE_curveprofile_selected_handle_set(profile, value, value);
+ BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
+ WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
+ }
+}
+
static void rna_CurveProfile_clip_set(PointerRNA *ptr, bool value)
{
CurveProfile *profile = (CurveProfile *)ptr->data;
@@ -73,7 +89,7 @@ static void rna_CurveProfile_clip_set(PointerRNA *ptr, bool value)
profile->flag &= ~PROF_USE_CLIP;
}
- BKE_curveprofile_update(profile, false);
+ BKE_curveprofile_update(profile, PROF_UPDATE_CLIP);
}
static void rna_CurveProfile_sample_straight_set(PointerRNA *ptr, bool value)
@@ -87,7 +103,7 @@ static void rna_CurveProfile_sample_straight_set(PointerRNA *ptr, bool value)
profile->flag &= ~PROF_SAMPLE_STRAIGHT_EDGES;
}
- BKE_curveprofile_update(profile, false);
+ BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
}
static void rna_CurveProfile_sample_even_set(PointerRNA *ptr, bool value)
@@ -101,7 +117,7 @@ static void rna_CurveProfile_sample_even_set(PointerRNA *ptr, bool value)
profile->flag &= ~PROF_SAMPLE_EVEN_LENGTHS;
}
- BKE_curveprofile_update(profile, false);
+ BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
}
static void rna_CurveProfile_remove_point(CurveProfile *profile,
@@ -135,14 +151,16 @@ static void rna_CurveProfile_initialize(struct CurveProfile *profile, int segmen
static void rna_CurveProfile_update(struct CurveProfile *profile)
{
- BKE_curveprofile_update(profile, false);
+ BKE_curveprofile_update(profile, PROF_UPDATE_REMOVE_DOUBLES | PROF_UPDATE_CLIP);
}
#else
static const EnumPropertyItem prop_handle_type_items[] = {
- {HD_AUTO, "AUTO", 0, "Auto Handle", ""},
- {HD_VECT, "VECTOR", 0, "Vector Handle", ""},
+ {HD_AUTO, "AUTO", ICON_HANDLE_AUTO, "Auto Handle", ""},
+ {HD_VECT, "VECTOR", ICON_HANDLE_VECTOR, "Vector Handle", ""},
+ {HD_FREE, "FREE", ICON_HANDLE_FREE, "Free Handle", ""},
+ {HD_ALIGN, "ALIGN", ICON_HANDLE_ALIGNED, "Aligned Free Handles", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -162,14 +180,14 @@ static void rna_def_curveprofilepoint(BlenderRNA *brna)
prop = RNA_def_property(srna, "handle_type_1", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "h1");
RNA_def_property_enum_items(prop, prop_handle_type_items);
- RNA_def_property_ui_text(
- prop, "First Handle Type", "Path interpolation at this point: Bezier or vector");
+ RNA_def_property_enum_funcs(prop, NULL, "rna_CurveProfilePoint_handle_type_set", NULL);
+ RNA_def_property_ui_text(prop, "First Handle Type", "Path interpolation at this point");
prop = RNA_def_property(srna, "handle_type_2", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "h2");
RNA_def_property_enum_items(prop, prop_handle_type_items);
- RNA_def_property_ui_text(
- prop, "Second Handle Type", "Path interpolation at this point: Bezier or vector");
+ RNA_def_property_enum_funcs(prop, NULL, "rna_CurveProfilePoint_handle_type_set", NULL);
+ RNA_def_property_ui_text(prop, "Second Handle Type", "Path interpolation at this point");
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", PROF_SELECT);
@@ -260,7 +278,7 @@ static void rna_def_curveprofile(BlenderRNA *brna)
RNA_def_property_boolean_funcs(prop, NULL, "rna_CurveProfile_sample_even_set");
func = RNA_def_function(srna, "update", "rna_CurveProfile_update");
- RNA_def_function_ui_description(func, "Update the profile");
+ RNA_def_function_ui_description(func, "Refresh internal data, remove doubles and clip points");
func = RNA_def_function(srna, "initialize", "rna_CurveProfile_initialize");
parm = RNA_def_int(func,