Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_gpencil_modifier.c
| Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = { | ||||
| "GP_OPACITY", | "GP_OPACITY", | ||||
| ICON_MOD_OPACITY, | ICON_MOD_OPACITY, | ||||
| "Opacity", | "Opacity", | ||||
| "Opacity of the strokes"}, | "Opacity of the strokes"}, | ||||
| {eGpencilModifierType_Tint, "GP_TINT", ICON_MOD_TINT, "Tint", "Tint strokes with new color"}, | {eGpencilModifierType_Tint, "GP_TINT", ICON_MOD_TINT, "Tint", "Tint strokes with new color"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| static const EnumPropertyItem gpencil_build_time_mode_items[] = { | |||||
| {GP_BUILD_TIMEMODE_DRAWSPEED, | |||||
| "DRAWSPEED", | |||||
| 0, | |||||
| "Natural Drawing Speed", | |||||
| "Use recorded speed multiplied by a factor"}, | |||||
| {GP_BUILD_TIMEMODE_FRAMES, | |||||
| "FRAMES", | |||||
| 0, | |||||
| "Number of Frames", | |||||
| "Set a fixed number of frames for all build animations"}, | |||||
| {GP_BUILD_TIMEMODE_PERCENTAGE, | |||||
| "PERCENTAGE", | |||||
| 0, | |||||
| "Percentage Factor", | |||||
| "Set a manual percentage to build"}, | |||||
| {0, NULL, 0, NULL, NULL}, | |||||
| }; | |||||
| #ifndef RNA_RUNTIME | #ifndef RNA_RUNTIME | ||||
| static const EnumPropertyItem modifier_modify_color_items[] = { | static const EnumPropertyItem modifier_modify_color_items[] = { | ||||
| {GP_MODIFY_COLOR_BOTH, "BOTH", 0, "Stroke & Fill", "Modify fill and stroke colors"}, | {GP_MODIFY_COLOR_BOTH, "BOTH", 0, "Stroke & Fill", "Modify fill and stroke colors"}, | ||||
| {GP_MODIFY_COLOR_STROKE, "STROKE", 0, "Stroke", "Modify stroke color only"}, | {GP_MODIFY_COLOR_STROKE, "STROKE", 0, "Stroke", "Modify stroke color only"}, | ||||
| {GP_MODIFY_COLOR_FILL, "FILL", 0, "Fill", "Modify fill color only"}, | {GP_MODIFY_COLOR_FILL, "FILL", 0, "Fill", "Modify fill color only"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 751 Lines • ▼ Show 20 Lines | static void rna_EnvelopeGpencilModifier_material_set(PointerRNA *ptr, | ||||
| struct ReportList *reports) | struct ReportList *reports) | ||||
| { | { | ||||
| EnvelopeGpencilModifierData *emd = (EnvelopeGpencilModifierData *)ptr->data; | EnvelopeGpencilModifierData *emd = (EnvelopeGpencilModifierData *)ptr->data; | ||||
| Material **ma_target = &emd->material; | Material **ma_target = &emd->material; | ||||
| rna_GpencilModifier_material_set(ptr, value, ma_target, reports); | rna_GpencilModifier_material_set(ptr, value, ma_target, reports); | ||||
| } | } | ||||
| const EnumPropertyItem *gpencil_build_time_mode_filter(bContext *UNUSED(C), | |||||
| PointerRNA *ptr, | |||||
| PropertyRNA *prop, | |||||
| bool *r_free) | |||||
| { | |||||
| GpencilModifierData *md = ptr->data; | |||||
| BuildGpencilModifierData *mmd = (BuildGpencilModifierData *)md; | |||||
| const bool is_concurrent = (mmd->mode == GP_BUILD_MODE_CONCURRENT); | |||||
| EnumPropertyItem *item_list = NULL; | |||||
| int totitem = 0; | |||||
| for (const EnumPropertyItem *item = gpencil_build_time_mode_items; item->identifier != NULL; | |||||
| item++) { | |||||
| if (is_concurrent && item->identifier == "DRAWSPEED") { | |||||
| continue; | |||||
| } | |||||
| RNA_enum_item_add(&item_list, &totitem, item); | |||||
| } | |||||
| RNA_enum_item_end(&item_list, &totitem); | |||||
| *r_free = true; | |||||
| return item_list; | |||||
| } | |||||
| #else | #else | ||||
| static void rna_def_modifier_gpencilnoise(BlenderRNA *brna) | static void rna_def_modifier_gpencilnoise(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| srna = RNA_def_struct(brna, "NoiseGpencilModifier", "GpencilModifier"); | srna = RNA_def_struct(brna, "NoiseGpencilModifier", "GpencilModifier"); | ||||
| ▲ Show 20 Lines • Show All 1,525 Lines • ▼ Show 20 Lines | static void rna_def_modifier_gpencilbuild(BlenderRNA *brna) | ||||
| RNA_def_struct_sdna(srna, "BuildGpencilModifierData"); | RNA_def_struct_sdna(srna, "BuildGpencilModifierData"); | ||||
| RNA_def_struct_ui_icon(srna, ICON_MOD_BUILD); | RNA_def_struct_ui_icon(srna, ICON_MOD_BUILD); | ||||
| RNA_define_lib_overridable(true); | RNA_define_lib_overridable(true); | ||||
| /* Mode */ | /* Mode */ | ||||
| prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_items(prop, prop_gpencil_build_mode_items); | RNA_def_property_enum_items(prop, prop_gpencil_build_mode_items); | ||||
| RNA_def_property_ui_text(prop, "Mode", "How many strokes are being animated at a time"); | RNA_def_property_ui_text(prop, "Mode", "How strokes are being built"); | ||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | ||||
| /* Direction */ | /* Direction */ | ||||
| prop = RNA_def_property(srna, "transition", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "transition", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_items(prop, prop_gpencil_build_transition_items); | RNA_def_property_enum_items(prop, prop_gpencil_build_transition_items); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Transition", "How are strokes animated (i.e. are they appearing or disappearing)"); | prop, "Transition", "How are strokes animated (i.e. are they appearing or disappearing)"); | ||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | ||||
| /* Transition Onset Delay + Length */ | /* Transition Onset Delay + Length */ | ||||
| prop = RNA_def_property(srna, "start_delay", PROP_FLOAT, PROP_NONE); | prop = RNA_def_property(srna, "start_delay", PROP_FLOAT, PROP_NONE); | ||||
| RNA_def_property_float_sdna(prop, NULL, "start_delay"); | RNA_def_property_float_sdna(prop, NULL, "start_delay"); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, | prop, "Delay", "Number of frames after each GP keyframe before the modifier has any effect"); | ||||
| "Start Delay", | |||||
| "Number of frames after each GP keyframe before the modifier has any effect"); | |||||
| RNA_def_property_range(prop, 0, MAXFRAMEF); | RNA_def_property_range(prop, 0, MAXFRAMEF); | ||||
| RNA_def_property_ui_range(prop, 0, 200, 1, -1); | RNA_def_property_ui_range(prop, 0, 200, 1, -1); | ||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | ||||
| prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE); | prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_NONE); | ||||
| RNA_def_property_float_sdna(prop, NULL, "length"); | RNA_def_property_float_sdna(prop, NULL, "length"); | ||||
| RNA_def_property_ui_text(prop, | RNA_def_property_ui_text(prop, | ||||
| "Length", | "Length", | ||||
| "Maximum number of frames that the build effect can run for " | "Maximum number of frames that the build effect can run for " | ||||
| "(unless another GP keyframe occurs before this time has elapsed)"); | "(unless another GP keyframe occurs before this time has elapsed)"); | ||||
| RNA_def_property_range(prop, 1, MAXFRAMEF); | RNA_def_property_range(prop, 1, MAXFRAMEF); | ||||
| RNA_def_property_ui_range(prop, 1, 1000, 1, -1); | RNA_def_property_ui_range(prop, 1, 1000, 1, -1); | ||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | ||||
| /* Concurrent Mode Settings */ | /* Concurrent Mode Settings */ | ||||
| prop = RNA_def_property(srna, "concurrent_time_alignment", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "concurrent_time_alignment", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_sdna(prop, NULL, "time_alignment"); | RNA_def_property_enum_sdna(prop, NULL, "time_alignment"); | ||||
| RNA_def_property_enum_items(prop, prop_gpencil_build_time_align_items); | RNA_def_property_enum_items(prop, prop_gpencil_build_time_align_items); | ||||
| RNA_def_property_ui_text(prop, "Time Alignment", "How should strokes start to appear/disappear"); | |||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | |||||
| /* Which time mode to use: Current frames, manual percentage, or drawspeed. */ | |||||
| prop = RNA_def_property(srna, "time_mode", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_enum_sdna(prop, NULL, "time_mode"); | |||||
| RNA_def_property_enum_items(prop, gpencil_build_time_mode_items); | |||||
| RNA_def_property_enum_funcs(prop, NULL, NULL, "gpencil_build_time_mode_filter"); | |||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Time Alignment", "When should strokes start to appear/disappear"); | prop, | ||||
| "Timing", | |||||
| "Use drawing speed, a number of frames, or a manual factor to build strokes"); | |||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | |||||
| /* Speed factor for GP_BUILD_TIMEMODE_DRAWSPEED. */ | |||||
| /* Todo: Does it work? */ | |||||
| prop = RNA_def_property(srna, "speed_factor", PROP_FLOAT, PROP_FACTOR); | |||||
| RNA_def_property_float_sdna(prop, NULL, "speed_fac"); | |||||
HooglyBoogly: Usually instead of defining the min and max at 0 and 100, we use 0 and 1. The UI should take… | |||||
Done Inline ActionsI do need the upper limit to be substantially more than a factor of one. A factor of 100 should suffice, that's why I put it to 100. You're right that in many other places it's like this RNA_def_property_range(prop, 0.0f, 1.0f); I adapted the code to better reflect that formatting and put in 0.0f, 100.0f Thanks for the input! marcluzmedia: I do need the upper limit to be substantially more than a factor of one. A factor of 100 should… | |||||
Done Inline ActionsLooking again, it's possible that my comment was completely wrong, I should have actually built this and looked at the UI. Seeing the 100 made me assume the patch was manually building the percentage. HooglyBoogly: Looking again, it's possible that my comment was completely wrong, I should have actually built… | |||||
Done Inline ActionsAh ok, thanks for clarifying! marcluzmedia: Ah ok, thanks for clarifying! | |||||
| RNA_def_property_ui_text(prop, "Speed Factor", "Multiply recorded drawing speed by a factor"); | |||||
| RNA_def_property_range(prop, 0.0f, 100.0f); | |||||
| RNA_def_property_ui_range(prop, 0, 5, 0.001, -1); | |||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | |||||
| /* Max gap in seconds between strokes for GP_BUILD_TIMEMODE_DRAWSPEED. */ | |||||
| prop = RNA_def_property(srna, "speed_maxgap", PROP_FLOAT, PROP_NONE); | |||||
| RNA_def_property_float_sdna(prop, NULL, "speed_maxgap"); | |||||
| RNA_def_property_ui_text(prop, "Maximum Gap", "The maximum gap between strokes in seconds"); | |||||
| RNA_def_property_range(prop, 0.0f, 100.0f); | |||||
| RNA_def_property_ui_range(prop, 0, 4, 0.01, -1); | |||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | ||||
| /* Time Limits */ | /* Time Limits */ | ||||
| prop = RNA_def_property(srna, "use_restrict_frame_range", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_restrict_frame_range", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BUILD_RESTRICT_TIME); | RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BUILD_RESTRICT_TIME); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Restrict Frame Range", "Only modify strokes during the specified frame range"); | prop, "Restrict Frame Range", "Only modify strokes during the specified frame range"); | ||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | ||||
| /* Use percentage */ | /* Use percentage bool (used by sequential & concurrent modes) */ | ||||
| prop = RNA_def_property(srna, "use_percentage", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_percentage", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BUILD_PERCENTAGE); | RNA_def_property_boolean_sdna(prop, NULL, "time_mode", GP_BUILD_TIMEMODE_PERCENTAGE); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Restrict Visible Points", "Use a percentage factor to determine the visible points"); | prop, "Restrict Visible Points", "Use a percentage factor to determine the visible points"); | ||||
| RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); | ||||
| /* Percentage factor. */ | /* Percentage factor. */ | ||||
| prop = RNA_def_property(srna, "percentage_factor", PROP_FLOAT, PROP_FACTOR); | prop = RNA_def_property(srna, "percentage_factor", PROP_FLOAT, PROP_FACTOR); | ||||
| RNA_def_property_float_sdna(prop, NULL, "percentage_fac"); | RNA_def_property_float_sdna(prop, NULL, "percentage_fac"); | ||||
| RNA_def_property_ui_text(prop, "Factor", "Defines how much of the stroke is visible"); | RNA_def_property_ui_text(prop, "Factor", "Defines how much of the stroke is visible"); | ||||
| ▲ Show 20 Lines • Show All 2,125 Lines • Show Last 20 Lines | |||||
Usually instead of defining the min and max at 0 and 100, we use 0 and 1. The UI should take care of drawing that as a percentage on its own, and there's even a preference for displaying percentages or factors. You might have to set PROP_PERCENTAGE for that to work, I forget.