diff options
author | Hans Goudey <h.goudey@me.com> | 2020-06-19 21:42:08 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-06-19 21:42:08 +0300 |
commit | ec963d9d7d179e3ba12f5bdf748818939c2f17d8 (patch) | |
tree | 099996a967053ba95d14eaeaa1df8d602ebbfd23 /source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c | |
parent | fb7d8e2f4b87307a749537f16e80800af09cf5ae (diff) |
UI: Grease Pencil Modifier Drag and Drop, Layout Changes
This patch implements the list panel system D7490 for grease pencil
modifiers. It also moves their drawing to a callback in
GpencilModifierTypeInfo in line with the extensible architecture
refactoring goal T75724.
This also adds the "set_error" function for grease pencil modifiers,
which hadn't been copied from mesh modifiers yet.
The implementation is basically exactly the same as for the modifier
patch (9b099c86123fc82).
Thanks to Matias Mendiola (mendio) for providing mockups for many
of the layout changes.
Differential Revision: https://developer.blender.org/D7978
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c | 97 |
1 files changed, 96 insertions, 1 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c index 85400b56cad..49396f56d26 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c @@ -26,20 +26,31 @@ #include "BLI_utildefines.h" +#include "BLT_translation.h" + #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_screen_types.h" #include "BKE_colortools.h" +#include "BKE_context.h" #include "BKE_deform.h" #include "BKE_gpencil.h" #include "BKE_gpencil_modifier.h" +#include "BKE_screen.h" #include "DEG_depsgraph.h" +#include "UI_interface.h" +#include "UI_resources.h" + +#include "RNA_access.h" + #include "MOD_gpencil_modifiertypes.h" +#include "MOD_gpencil_ui_common.h" #include "MOD_gpencil_util.h" static void initData(GpencilModifierData *md) @@ -165,8 +176,91 @@ static int remapTime(struct GpencilModifierData *md, return cfra + offset; } +static void panel_draw(const bContext *C, Panel *panel) +{ + uiLayout *row, *col; + uiLayout *layout = panel->layout; + + PointerRNA ptr; + gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + + int mode = RNA_enum_get(&ptr, "mode"); + + uiLayoutSetPropSep(layout, true); + + uiItemR(layout, &ptr, "mode", 0, NULL, ICON_NONE); + + col = uiLayoutColumn(layout, false); + + const char *text = (mode == GP_TIME_MODE_FIX) ? IFACE_("Frame") : IFACE_("Frame Offset"); + uiItemR(col, &ptr, "offset", 0, text, ICON_NONE); + + row = uiLayoutRow(col, false); + uiLayoutSetActive(row, mode != GP_TIME_MODE_FIX); + uiItemR(row, &ptr, "frame_scale", 0, IFACE_("Scale"), ICON_NONE); + + row = uiLayoutRow(layout, false); + uiLayoutSetActive(row, mode != GP_TIME_MODE_FIX); + uiItemR(row, &ptr, "use_keep_loop", 0, NULL, ICON_NONE); + + gpencil_modifier_panel_end(layout, &ptr); +} + +static void custom_range_header_draw(const bContext *C, Panel *panel) +{ + uiLayout *layout = panel->layout; + + PointerRNA ptr; + gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + + int mode = RNA_enum_get(&ptr, "mode"); + + uiLayoutSetActive(layout, mode != GP_TIME_MODE_FIX); + + uiItemR(layout, &ptr, "use_custom_frame_range", 0, NULL, ICON_NONE); +} + +static void custom_range_panel_draw(const bContext *C, Panel *panel) +{ + uiLayout *col; + uiLayout *layout = panel->layout; + + PointerRNA ptr; + gpencil_modifier_panel_get_property_pointers(C, panel, NULL, &ptr); + + int mode = RNA_enum_get(&ptr, "mode"); + + uiLayoutSetPropSep(layout, true); + + uiLayoutSetActive( + layout, (mode != GP_TIME_MODE_FIX) && (RNA_boolean_get(&ptr, "use_custom_frame_range"))); + + col = uiLayoutColumn(layout, false); + uiItemR(col, &ptr, "frame_start", 0, IFACE_("Frame Start"), ICON_NONE); + uiItemR(col, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); +} + +static void mask_panel_draw(const bContext *C, Panel *panel) +{ + gpencil_modifier_masking_panel_draw(C, panel, false, false); +} + +static void panelRegister(ARegionType *region_type) +{ + PanelType *panel_type = gpencil_modifier_panel_register( + region_type, eGpencilModifierType_Time, panel_draw); + gpencil_modifier_subpanel_register(region_type, + "custom_range", + "", + custom_range_header_draw, + custom_range_panel_draw, + panel_type); + gpencil_modifier_subpanel_register( + region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type); +} + GpencilModifierTypeInfo modifierType_Gpencil_Time = { - /* name */ "Time Offset", + /* name */ "TimeOffset", /* structName */ "TimeGpencilModifierData", /* structSize */ sizeof(TimeGpencilModifierData), /* type */ eGpencilModifierTypeType_Gpencil, @@ -187,4 +281,5 @@ GpencilModifierTypeInfo modifierType_Gpencil_Time = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* panelRegister */ panelRegister, }; |