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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-01-16 02:09:52 +0300
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-01-16 02:09:52 +0300
commitc7a122aa27662a2fb528663ddd3dd652cdda2010 (patch)
treea014a8601c20ccd4d48dd82e9b0f88245b4beddd /source/blender/editors/animation/anim_channels_defines.c
parentbc1e26e4965877533902aa5d0e51537deeb319c4 (diff)
parent86bbab7de53b07ad9a45b11dbff6bd5c0ee40c14 (diff)
Merged changes in the trunk up to revision 34335.
Diffstat (limited to 'source/blender/editors/animation/anim_channels_defines.c')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c286
1 files changed, 158 insertions, 128 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index cc1e8bd9eb8..14babe7ce00 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -50,6 +50,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"
@@ -80,6 +81,8 @@
/* size of indent steps */
#define INDENT_STEP_SIZE 7
+#define ANIM_CHAN_NAME_SIZE 256
+
/* macros used for type defines */
/* get the pointer used for some flag */
#define GET_ACF_FLAG_PTR(ptr) \
@@ -304,7 +307,7 @@ static void acf_generic_idblock_name(bAnimListElem *ale, char *name)
/* just copy the name... */
if (id && name)
- strcpy(name, id->name+2);
+ BLI_strncpy(name, id->name+2, ANIM_CHAN_NAME_SIZE);
}
/* Settings ------------------------------------------- */
@@ -413,7 +416,7 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name)
{
if (name)
- strcpy(name, "DopeSheet Summary");
+ BLI_strncpy(name, "DopeSheet Summary", ANIM_CHAN_NAME_SIZE);
}
// TODO: this is really a temp icon I think
@@ -629,7 +632,7 @@ static void acf_object_name(bAnimListElem *ale, char *name)
/* just copy the name... */
if (ob && name)
- strcpy(name, ob->id.name+2);
+ BLI_strncpy(name, ob->id.name+2, ANIM_CHAN_NAME_SIZE);
}
/* check if some setting exists for this channel */
@@ -766,7 +769,7 @@ static void acf_group_name(bAnimListElem *ale, char *name)
/* just copy the name... */
if (agrp && name)
- strcpy(name, agrp->name);
+ BLI_strncpy(name, agrp->name, ANIM_CHAN_NAME_SIZE);
}
/* check if some setting exists for this channel */
@@ -1026,7 +1029,7 @@ static int acf_filldrivers_icon(bAnimListElem *UNUSED(ale))
static void acf_filldrivers_name(bAnimListElem *UNUSED(ale), char *name)
{
- strcpy(name, "Drivers");
+ BLI_strncpy(name, "Drivers", ANIM_CHAN_NAME_SIZE);
}
/* check if some setting exists for this channel */
@@ -1104,7 +1107,7 @@ static int acf_fillmatd_icon(bAnimListElem *UNUSED(ale))
static void acf_fillmatd_name(bAnimListElem *UNUSED(ale), char *name)
{
- strcpy(name, "Materials");
+ BLI_strncpy(name, "Materials", ANIM_CHAN_NAME_SIZE);
}
/* get the appropriate flag(s) for the setting when it is valid */
@@ -1150,7 +1153,7 @@ static int acf_fillpartd_icon(bAnimListElem *UNUSED(ale))
static void acf_fillpartd_name(bAnimListElem *UNUSED(ale), char *name)
{
- strcpy(name, "Particles");
+ BLI_strncpy(name, "Particles", ANIM_CHAN_NAME_SIZE);
}
/* get the appropriate flag(s) for the setting when it is valid */
@@ -1218,7 +1221,7 @@ static int acf_filltexd_icon(bAnimListElem *UNUSED(ale))
static void acf_filltexd_name(bAnimListElem *UNUSED(ale), char *name)
{
- strcpy(name, "Textures");
+ BLI_strncpy(name, "Textures", ANIM_CHAN_NAME_SIZE);
}
/* get pointer to the setting (category only) */
@@ -2402,9 +2405,9 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name)
if (kb && name) {
/* if the KeyBlock had a name, use it, otherwise use the index */
if (kb->name[0])
- strcpy(name, kb->name);
+ BLI_strncpy(name, kb->name, ANIM_CHAN_NAME_SIZE);
else
- sprintf(name, "Key %d", ale->index);
+ BLI_snprintf(name, ANIM_CHAN_NAME_SIZE, "Key %d", ale->index);
}
}
@@ -2481,126 +2484,154 @@ 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 *UNUSED(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;
+ /* these are ID-blocks, but not exactly standalone... */
+ UI_GetThemeColorShade3fv(TH_DOPESHEET_CHANNELSUBOB, 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 *UNUSED(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 *UNUSED(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)
+ BLI_strncpy(name, gpl->info, ANIM_CHAN_NAME_SIZE);
+}
+
+/* check if some setting exists for this channel */
+static short acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(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 */
@@ -2652,9 +2683,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...
@@ -2693,14 +2723,14 @@ void ANIM_channel_debug_print_info (bAnimListElem *ale, short indent_level)
/* print info */
if (acf) {
- char name[256]; /* hopefully this will be enough! */
+ char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
/* get UI name */
if (acf->name)
acf->name(ale, name);
else
- sprintf(name, "<No name>");
-
+ BLI_strncpy(name, "<No name>", sizeof(name));
+
/* print type name + ui name */
printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name);
}
@@ -2932,7 +2962,7 @@ void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float
/* step 5) draw name ............................................... */
if (acf->name) {
- char name[256]; /* hopefully this will be enough! */
+ char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
/* set text color */
if (selected)