1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) (C) 2009 Blender Foundation, Joshua Leung 17 * All rights reserved. 18 */ 19 20 /** \file 21 * \ingroup editors 22 */ 23 24 #pragma once 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 struct AnimData; 31 struct CacheFile; 32 struct DLRBT_Tree; 33 struct FCurve; 34 struct ListBase; 35 struct MaskLayer; 36 struct Object; 37 struct Scene; 38 struct View2D; 39 struct bAction; 40 struct bActionGroup; 41 struct bAnimContext; 42 struct bDopeSheet; 43 struct bGPDlayer; 44 45 /* ****************************** Base Structs ****************************** */ 46 47 /* Information about the stretch of time from current to the next column */ 48 typedef struct ActKeyBlockInfo { 49 /* Combination of flags from all curves. */ 50 short flag; 51 /* Mask of flags that differ between curves. */ 52 short conflict; 53 54 /* Selection flag. */ 55 char sel; 56 } ActKeyBlockInfo; 57 58 /* Keyframe Column Struct */ 59 typedef struct ActKeyColumn { 60 /* ListBase linkage */ 61 struct ActKeyColumn *next, *prev; 62 63 /* sorting-tree linkage */ 64 /** 'children' of this node, less than and greater than it (respectively) */ 65 struct ActKeyColumn *left, *right; 66 /** parent of this node in the tree */ 67 struct ActKeyColumn *parent; 68 /** DLRB_BLACK or DLRB_RED */ 69 char tree_col; 70 71 /* keyframe info */ 72 /** eBezTripe_KeyframeType */ 73 char key_type; 74 /** eKeyframeHandleDrawOpts */ 75 char handle_type; 76 /** eKeyframeExtremeDrawOpts */ 77 char extreme_type; 78 short sel; 79 float cfra; 80 81 /* key-block info */ 82 ActKeyBlockInfo block; 83 84 /* number of curves and keys in this column */ 85 short totcurve, totkey, totblock; 86 } ActKeyColumn; 87 88 /* ActKeyBlockInfo - Flag */ 89 typedef enum eActKeyBlock_Hold { 90 /* Key block represents a moving hold */ 91 ACTKEYBLOCK_FLAG_MOVING_HOLD = (1 << 0), 92 /* Key block represents a static hold */ 93 ACTKEYBLOCK_FLAG_STATIC_HOLD = (1 << 1), 94 /* Key block represents any kind of hold */ 95 ACTKEYBLOCK_FLAG_ANY_HOLD = (1 << 2), 96 /* The curve segment uses non-bezier interpolation */ 97 ACTKEYBLOCK_FLAG_NON_BEZIER = (1 << 3), 98 } eActKeyBlock_Flag; 99 100 /* *********************** Keyframe Drawing ****************************** */ 101 102 /* options for keyframe shape drawing */ 103 typedef enum eKeyframeShapeDrawOpts { 104 /* only the border */ 105 KEYFRAME_SHAPE_FRAME = 0, 106 /* only the inside filling */ 107 KEYFRAME_SHAPE_INSIDE, 108 /* the whole thing */ 109 KEYFRAME_SHAPE_BOTH, 110 } eKeyframeShapeDrawOpts; 111 112 /* Handle type. */ 113 typedef enum eKeyframeHandleDrawOpts { 114 /* Don't draw */ 115 KEYFRAME_HANDLE_NONE = 0, 116 /* Various marks in order of increasing display priority. */ 117 KEYFRAME_HANDLE_AUTO_CLAMP, 118 KEYFRAME_HANDLE_AUTO, 119 KEYFRAME_HANDLE_VECTOR, 120 KEYFRAME_HANDLE_ALIGNED, 121 KEYFRAME_HANDLE_FREE, 122 } eKeyframeHandleDrawOpts; 123 124 /* Extreme type. */ 125 typedef enum eKeyframeExtremeDrawOpts { 126 KEYFRAME_EXTREME_NONE = 0, 127 /* Minimum/maximum present. */ 128 KEYFRAME_EXTREME_MIN = (1 << 0), 129 KEYFRAME_EXTREME_MAX = (1 << 1), 130 /* Grouped keys have different states. */ 131 KEYFRAME_EXTREME_MIXED = (1 << 2), 132 /* Both neighbors are equal to this key. */ 133 KEYFRAME_EXTREME_FLAT = (1 << 3), 134 } eKeyframeExtremeDrawOpts; 135 136 /* draw simple diamond-shape keyframe */ 137 /* caller should set up vertex format, bind GPU_SHADER_KEYFRAME_DIAMOND, 138 * immBegin(GPU_PRIM_POINTS, n), then call this n times */ 139 void draw_keyframe_shape(float x, 140 float y, 141 float size, 142 bool sel, 143 short key_type, 144 short mode, 145 float alpha, 146 unsigned int pos_id, 147 unsigned int size_id, 148 unsigned int color_id, 149 unsigned int outline_color_id, 150 unsigned int flags_id, 151 short handle_type, 152 short extreme_type); 153 154 /* ******************************* Methods ****************************** */ 155 156 /* Channel Drawing ------------------ */ 157 /* F-Curve */ 158 void draw_fcurve_channel(struct View2D *v2d, 159 struct AnimData *adt, 160 struct FCurve *fcu, 161 float ypos, 162 float yscale_fac, 163 int saction_flag); 164 /* Action Group Summary */ 165 void draw_agroup_channel(struct View2D *v2d, 166 struct AnimData *adt, 167 struct bActionGroup *agrp, 168 float ypos, 169 float yscale_fac, 170 int saction_flag); 171 /* Action Summary */ 172 void draw_action_channel(struct View2D *v2d, 173 struct AnimData *adt, 174 struct bAction *act, 175 float ypos, 176 float yscale_fac, 177 int saction_flag); 178 /* Object Summary */ 179 void draw_object_channel(struct View2D *v2d, 180 struct bDopeSheet *ads, 181 struct Object *ob, 182 float ypos, 183 float yscale_fac, 184 int saction_flag); 185 /* Scene Summary */ 186 void draw_scene_channel(struct View2D *v2d, 187 struct bDopeSheet *ads, 188 struct Scene *sce, 189 float ypos, 190 float yscale_fac, 191 int saction_flag); 192 /* DopeSheet Summary */ 193 void draw_summary_channel( 194 struct View2D *v2d, struct bAnimContext *ac, float ypos, float yscale_fac, int saction_flag); 195 /* Grease Pencil datablock summary */ 196 void draw_gpencil_channel(struct View2D *v2d, 197 struct bDopeSheet *ads, 198 struct bGPdata *gpd, 199 float ypos, 200 float yscale_fac, 201 int saction_flag); 202 /* Grease Pencil Layer */ 203 void draw_gpl_channel(struct View2D *v2d, 204 struct bDopeSheet *ads, 205 struct bGPDlayer *gpl, 206 float ypos, 207 float yscale_fac, 208 int saction_flag); 209 /* Mask Layer */ 210 void draw_masklay_channel(struct View2D *v2d, 211 struct bDopeSheet *ads, 212 struct MaskLayer *masklay, 213 float ypos, 214 float yscale_fac, 215 int saction_flag); 216 217 /* Keydata Generation --------------- */ 218 /* F-Curve */ 219 void fcurve_to_keylist(struct AnimData *adt, 220 struct FCurve *fcu, 221 struct DLRBT_Tree *keys, 222 int saction_flag); 223 /* Action Group */ 224 void agroup_to_keylist(struct AnimData *adt, 225 struct bActionGroup *agrp, 226 struct DLRBT_Tree *keys, 227 int saction_flag); 228 /* Action */ 229 void action_to_keylist(struct AnimData *adt, 230 struct bAction *act, 231 struct DLRBT_Tree *keys, 232 int saction_flag); 233 /* Object */ 234 void ob_to_keylist(struct bDopeSheet *ads, 235 struct Object *ob, 236 struct DLRBT_Tree *keys, 237 int saction_flag); 238 /* Cache File */ 239 void cachefile_to_keylist(struct bDopeSheet *ads, 240 struct CacheFile *cache_file, 241 struct DLRBT_Tree *keys, 242 int saction_flag); 243 /* Scene */ 244 void scene_to_keylist(struct bDopeSheet *ads, 245 struct Scene *sce, 246 struct DLRBT_Tree *keys, 247 int saction_flag); 248 /* DopeSheet Summary */ 249 void summary_to_keylist(struct bAnimContext *ac, struct DLRBT_Tree *keys, int saction_flag); 250 /* Grease Pencil datablock summary */ 251 void gpencil_to_keylist(struct bDopeSheet *ads, 252 struct bGPdata *gpd, 253 struct DLRBT_Tree *keys, 254 const bool active); 255 /* Grease Pencil Layer */ 256 void gpl_to_keylist(struct bDopeSheet *ads, struct bGPDlayer *gpl, struct DLRBT_Tree *keys); 257 /* Mask */ 258 void mask_to_keylist(struct bDopeSheet *UNUSED(ads), 259 struct MaskLayer *masklay, 260 struct DLRBT_Tree *keys); 261 262 /* ActKeyColumn API ---------------- */ 263 /* Comparator callback used for ActKeyColumns and cframe float-value pointer */ 264 short compare_ak_cfraPtr(void *node, void *data); 265 266 /* Checks if ActKeyColumn has any block data */ 267 bool actkeyblock_is_valid(ActKeyColumn *ac); 268 269 /* Checks if ActKeyColumn can be used as a block (i.e. drawn/used to detect "holds") */ 270 int actkeyblock_get_valid_hold(ActKeyColumn *ac); 271 272 #ifdef __cplusplus 273 } 274 #endif 275