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:
authorJoshua Leung <aligorith@gmail.com>2011-01-11 01:10:28 +0300
committerJoshua Leung <aligorith@gmail.com>2011-01-11 01:10:28 +0300
commitcf25b10eb5bb61662ce0db6b3ef54a3e3e73a328 (patch)
tree0d7ffcdd0735d1788bfb3e679b6f7489605c1aab /source/blender/editors/animation/anim_channels_defines.c
parentd841a206314922eec0a0fed0b87e3078b68487c9 (diff)
Todo #22395: Restoring Grease Pencil Editing Mode in DopeSheet Editor
This commit restores some basic functionality for retiming Grease Pencil sketches. Some of the functionality that existed before still hasn't been restored (namely snap/mirror tools as well as copy+paste), though it should be possible to use this for basic retiming and sketch-frame management again. - There's still a lot of work required to get this up to the standard of the rest of the animation editor code, as some of this code was originally just hacked in based on the old-style code. - Work is already required to not have to directly access the main db global to get the list of Grease Pencil datablocks to show, but that can come along with pending cleanups of the filtering code.
Diffstat (limited to 'source/blender/editors/animation/anim_channels_defines.c')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c259
1 files changed, 145 insertions, 114 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 298fd9102ec..66f574a4b70 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -49,6 +49,7 @@
#include "DNA_meta_types.h"
#include "DNA_node_types.h"
#include "DNA_world_types.h"
+#include "DNA_gpencil_types.h"
#include "RNA_access.h"
@@ -2404,126 +2405,157 @@ static bAnimChannelType ACF_SHAPEKEY=
acf_shapekey_setting_ptr /* pointer for setting */
};
-/* Grease Pencil entries ------------------------------------------- */
-// XXX ... this is currently not restored yet
+/* GPencil Datablock ------------------------------------------- */
-#if 0
-static void dummy_olddraw_gpencil ()
+/* get backdrop color for gpencil datablock widget */
+static void acf_gpd_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float *color)
{
- /* determine what needs to be drawn */
- switch (ale->type) {
- case ANIMTYPE_GPDATABLOCK: /* gpencil datablock */
- {
- bGPdata *gpd = (bGPdata *)ale->data;
- ScrArea *sa = (ScrArea *)ale->owner; // XXX depreceated...
-
- indent = 0;
- group= 3;
+ /* highlight only for datablock channels */
+ //if (ale->flag & AGRP_ACTIVE)
+ // UI_GetThemeColorShade3fv(TH_GROUP_ACTIVE, 10, color);
+ //else
+ UI_GetThemeColorShade3fv(TH_GROUP, 20, color);
+}
+
+// TODO: just get this from RNA?
+static int acf_gpd_icon(bAnimListElem *UNUSED(ale))
+{
+ return ICON_GREASEPENCIL;
+}
+
+/* check if some setting exists for this channel */
+static short acf_gpd_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale), int setting)
+{
+ switch (setting) {
+ /* only select and expand supported */
+ case ACHANNEL_SETTING_SELECT:
+ case ACHANNEL_SETTING_EXPAND:
+ return 1;
- /* only show expand if there are any channels */
- if (gpd->layers.first) {
- if (gpd->flag & GP_DATA_EXPAND)
- expand = ICON_TRIA_DOWN;
- else
- expand = ICON_TRIA_RIGHT;
- }
+ default:
+ return 0;
+ }
+}
+
+/* get the appropriate flag(s) for the setting when it is valid */
+static int acf_gpd_setting_flag(bAnimContext *ac, int setting, short *neg)
+{
+ /* clear extra return data first */
+ *neg= 0;
+
+ switch (setting) {
+ case ACHANNEL_SETTING_SELECT: /* selected */
+ return AGRP_SELECTED;
- switch (sa->spacetype) {
- case SPACE_VIEW3D:
- {
- /* this shouldn't cause any overflow... */
- //sprintf(name, "View3D:%s", view3d_get_name(sa->spacedata.first)); // XXX missing func..
- strcpy(name, "View3D");
- special= ICON_VIEW3D;
- }
- break;
- case SPACE_NODE:
- {
- SpaceNode *snode= sa->spacedata.first;
- char treetype[12];
-
- if (snode->treetype == 1)
- strcpy(treetype, "Composite");
- else
- strcpy(treetype, "Material");
- sprintf(name, "Nodes:%s", treetype);
-
- special= ICON_NODETREE;
- }
- break;
- case SPACE_SEQ:
- {
- SpaceSeq *sseq= sa->spacedata.first;
- char imgpreview[10];
-
- switch (sseq->mainb) {
- case 1: sprintf(imgpreview, "Image..."); break;
- case 2: sprintf(imgpreview, "Luma..."); break;
- case 3: sprintf(imgpreview, "Chroma..."); break;
- case 4: sprintf(imgpreview, "Histogram"); break;
-
- default: sprintf(imgpreview, "Sequence"); break;
- }
- sprintf(name, "Sequencer:%s", imgpreview);
-
- special= ICON_SEQUENCE;
- }
- break;
- case SPACE_IMAGE:
- {
- SpaceImage *sima= sa->spacedata.first;
-
- if (sima->image)
- sprintf(name, "Image:%s", sima->image->id.name+2);
- else
- strcpy(name, "Image:<None>");
-
- special= ICON_IMAGE_COL;
- }
- break;
-
- default:
- {
- sprintf(name, "<Unknown GP-Data Source>");
- special= -1;
- }
- break;
- }
- }
- break;
- case ANIMTYPE_GPLAYER: /* gpencil layer */
- {
- bGPDlayer *gpl = (bGPDlayer *)ale->data;
+ case ACHANNEL_SETTING_EXPAND: /* expanded */
+ return GP_DATA_EXPAND;
+ }
+
+ /* this shouldn't happen */
+ return 0;
+}
+
+/* get pointer to the setting */
+static void *acf_gpd_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+{
+ bGPdata *gpd= (bGPdata *)ale->data;
+
+ /* all flags are just in gpd->flag for now... */
+ GET_ACF_FLAG_PTR(gpd->flag);
+}
+
+/* gpencil datablock type define */
+static bAnimChannelType ACF_GPD =
+{
+ "GPencil Datablock", /* type name */
+
+ acf_gpd_color, /* backdrop color */
+ acf_group_backdrop, /* backdrop */
+ acf_generic_indention_0, /* indent level */
+ acf_generic_group_offset, /* offset */
+
+ acf_generic_idblock_name, /* name */
+ acf_gpd_icon, /* icon */
+
+ acf_gpd_setting_valid, /* has setting */
+ acf_gpd_setting_flag, /* flag for setting */
+ acf_gpd_setting_ptr /* pointer for setting */
+};
+
+/* GPencil Layer ------------------------------------------- */
+
+/* name for grase pencil layer entries */
+static void acf_gpl_name(bAnimListElem *ale, char *name)
+{
+ bGPDlayer *gpl = (bGPDlayer *)ale->data;
+
+ if (gpl && name)
+ sprintf(name, gpl->info);
+}
+
+/* check if some setting exists for this channel */
+static short acf_gpl_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting)
+{
+ switch (setting) {
+ /* unsupported */
+ case ACHANNEL_SETTING_EXPAND: /* gpencil layers are more like F-Curves than groups */
+ case ACHANNEL_SETTING_VISIBLE: /* graph editor only */
+ return 0;
+
+ /* always available */
+ default:
+ return 1;
+ }
+}
+
+/* get the appropriate flag(s) for the setting when it is valid */
+static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg)
+{
+ /* clear extra return data first */
+ *neg= 0;
+
+ switch (setting) {
+ case ACHANNEL_SETTING_SELECT: /* selected */
+ return GP_LAYER_SELECT;
- indent = 0;
- special = -1;
- expand = -1;
- group = 1;
+ case ACHANNEL_SETTING_MUTE: /* muted */
+ return GP_LAYER_HIDE;
- if (EDITABLE_GPL(gpl))
- protect = ICON_UNLOCKED;
- else
- protect = ICON_LOCKED;
-
- if (gpl->flag & GP_LAYER_HIDE)
- mute = ICON_MUTE_IPO_ON;
- else
- mute = ICON_MUTE_IPO_OFF;
+ case ACHANNEL_SETTING_PROTECT: /* protected */
+ //*neg= 1; - if we change this to edtiability
+ return GP_LAYER_LOCKED;
- sel = SEL_GPL(gpl);
- BLI_snprintf(name, 32, gpl->info);
- }
- break;
- }
-
- if (group == 3) {
- /* only for gp-data channels */
- UI_ThemeColorShade(TH_GROUP, 20);
- uiSetRoundBox((expand == ICON_TRIA_DOWN)? (1):(1|8));
- gl_round_box(GL_POLYGON, x+offset, yminc, (float)ACHANNEL_NAMEWIDTH, ymaxc, 8);
+ default: /* unsupported */
+ return 0;
}
}
-#endif
+
+/* get pointer to the setting */
+static void *acf_gpl_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type)
+{
+ bGPDlayer *gpl= (bGPDlayer *)ale->data;
+
+ /* all flags are just in agrp->flag for now... */
+ GET_ACF_FLAG_PTR(gpl->flag);
+}
+
+/* grease pencil layer type define */
+static bAnimChannelType ACF_GPL =
+{
+ "GPencil Layer", /* type name */
+
+ acf_generic_channel_color, /* backdrop color */
+ acf_generic_channel_backdrop, /* backdrop */
+ acf_generic_indention_flexible, /* indent level */
+ acf_generic_group_offset, /* offset */
+
+ acf_gpl_name, /* name */
+ NULL, /* icon */
+
+ acf_gpl_setting_valid, /* has setting */
+ acf_gpl_setting_flag, /* flag for setting */
+ acf_gpl_setting_ptr /* pointer for setting */
+};
/* *********************************************** */
/* Type Registration and General Access */
@@ -2574,9 +2606,8 @@ void ANIM_init_channel_typeinfo_data (void)
animchannelTypeInfo[type++]= &ACF_SHAPEKEY; /* ShapeKey */
- // XXX not restored yet
- animchannelTypeInfo[type++]= NULL; /* Grease Pencil Datablock */
- animchannelTypeInfo[type++]= NULL; /* Grease Pencil Layer */
+ animchannelTypeInfo[type++]= &ACF_GPD; /* Grease Pencil Datablock */
+ animchannelTypeInfo[type++]= &ACF_GPL; /* Grease Pencil Layer */
// TODO: these types still need to be implemented!!!
// probably need a few extra flags for these special cases...