summaryrefslogtreecommitdiff
path: root/main.h
diff options
context:
space:
mode:
Diffstat (limited to 'main.h')
-rw-r--r--main.h355
1 files changed, 113 insertions, 242 deletions
diff --git a/main.h b/main.h
index 30025b3..1c9a69b 100644
--- a/main.h
+++ b/main.h
@@ -8,119 +8,6 @@ enum instruction_mode {
#endif
};
-enum memory_table_list {
-
- // F = file attributes
- // P = persistent data, but not file-based
- // B = cached data, often cleared
-
- P_AVInfo,
- P_VectorPoints,
- P_UndoBuffer,
- P_MiscCache,
-
- // The structs that these four blocks correspond to (project_layer, effect,
- // keyframe_block, char[STRING_SIZE]) are guranteed equal size.
- F_Layers,
- F_Effects,
- F_Keyframes,
- F_Strings,
-
- B_LayerBitmaps,
- B_LoadedBitmaps,
-};
-
-struct memory_table {
- char *Name;
- void *Address;
- uint64 CurrentPosition;
- uint64 Size;
- uint32 NumberOfPointers;
- uint32 PointerIndex;
-};
-
-struct global_memory {
- void *Address;
- uint64 CurrentPosition;
- uint64 Size;
-};
-
-struct source;
-
-struct cached_bitmap {
- source *SourceOwner; // Which source it belongs to. Currently used to dereference the bitmap.
- void *Data; // Unpacked data loaded from the source file.
- uint32 Frame; // What frame it is.
-};
-
-struct action_shift_data {
- void *StartingAddress;
- uint32 Size;
- uint16 NumberOf;
- uint16 Index;
- int16 Direction;
-};
-
-enum action_type {
- action_type_change_u16,
- action_type_change_i16,
- action_type_change_u32,
- action_type_change_i32,
- action_type_change_r32,
- action_type_change_u64,
- action_type_change_ptr,
- action_type_change_string,
- action_type_shift_keyframe,
- action_type_shift_bezier,
- action_type_shift,
- action_type_storedata
-};
-
-enum action_entry_type {
- action_entry_layerinit,
- action_entry_default
-};
-
-struct action_entry {
- char *Name;
- action_entry_type Type;
- void *ExtraPointer;
- uint16 NumberOfActions;
-};
-
-struct action_entries {
- action_entry Entry[1024];
- uint16 Index;
- uint16 NumberOfEntries;
-};
-
-struct memory {
- memory_table Slot[16];
- cached_bitmap Bitmap[4096];
- void *Scratch; // 64 MB of data
- action_entries Action;
-};
-
-struct property_channel;
-struct project_layer;
-
-enum keyframe_type
-{
- linear,
- bezier,
- hold
-};
-
-// NOTE(fox): One val slot holds 16 bytes of data.
-
-enum var_type
-{
- type_real,
- type_color,
- type_blendmode
-};
-
-
static char* BlendmodeNames[] = {
"Normal",
"Multiply",
@@ -153,57 +40,72 @@ enum blend_mode
};
-union val {
- v4 col;
- real32 f;
- blend_mode blendmode;
+enum interpolation_type
+{
+ interpolation_type_linear,
+ interpolation_type_bezier,
+ interpolation_type_hold
};
-struct keyframe {
- val Value;
- // NOTE(fox): Frame values are relative to the layer's FrameOffset! This is
- // done to reduce the footprint of layer moving in the undo tree.
- int32 FrameNumber;
- keyframe_type Type;
- bool32 IsSelected;
- // The X coordinate for the tangent is in keyframes, and the Y is in units.
- // Probably should think of something smarter.
- v2 TangentLeft;
- v2 TangentRight;
- // NOTE(fox): We need some sort of unique constant to give to ImGui in
- // order for dragging to work.
- uint32 ImguiID;
+struct bezier_point {
+ v2 Pos[3];
+ interpolation_type Type;
+ uint16 ImguiID;
+ uint8 IsSelected;
};
-struct keyframe_block {
- keyframe Keyframe[MAX_KEYFRAMES_PER_BLOCK];
+struct block_bezier {
+ uint8 Occupied;
+ bezier_point Point[MAX_KEYFRAMES_PER_BLOCK];
};
-struct property_channel {
- char *Name;
- keyframe_block *KeyframeBlock[MAX_KEYFRAME_BLOCKS];
- uint16 NumberOfKeyframeBlocks;
- uint16 NumberOfSelectedKeyframes;
- uint16 NumberOfTotalKeyframes;
- val CurrentValue;
- val MaxVal;
- val MinVal;
- val ScrubVal; // increment when dragging on sliders, etc.
- var_type VarType;
+struct project_state
+{
+ bool32 UpdateKeyframes = 1;
+ bool32 UpdateFrame = 1; // only refreshes frame; set UpdateKeyframes to update animation
+ bool32 DebugDisableCache = 1;
- bool32 IsToggled;
+ // tool Tool = tool_default;
+ // pen_state Pen = {};
+
+ bool32 IsRunning = 1;
+ bool32 IsPlaying;
+
+ int16 MostRecentlySelectedLayer = -1;
+ // selection_type RecentSelectionType = selection_none;
+
+ bool32 IsInteracting;
+ real32 InteractCache[6];
+ // interact_type InteractType;
+
+ int32 MsgTime; // currently in "frames"
+ char *Msg;
+
+ ImGuiTextFilter filter; // This filter API is pretty ballin'.
+ bool32 RerouteEffects; // Allows shift+space hotkey to gain focus on the effects panel.
};
-struct property_header
+struct project_data
{
- char *Name;
- val Value;
- var_type VarType;
- val MinVal;
- val MaxVal;
+ uint8 Occupied;
+ uint16 Layer_Count;
+ uint16 Source_Count;
+ uint16 PrincipalCompIndex;
};
-// Information about a particular file.
+struct block_composition
+{
+ uint8 Occupied;
+ uint16 Width;
+ uint16 Height;
+ uint16 FPS;
+ uint16 BytesPerPixel;
+
+ uint32 Frame_Count;
+ int32 Frame_Current;
+ int32 Frame_Start;
+ int32 Frame_End;
+};
enum source_type {
source_type_none,
@@ -211,10 +113,11 @@ enum source_type {
source_type_image
};
-// Probably best to consider source_info a part of the file data so we don't
-// have to re-check each source on every project load. (except for AVInfo)
+struct block_source
+{
+ uint8 Occupied;
-struct source_info {
+ uint16 Block_String_Index;
// Image and video
uint16 Width;
uint16 Height;
@@ -223,15 +126,41 @@ struct source_info {
// Video only
real32 FPS;
real32 AvgPTSPerFrame; // set by Libav
-};
-struct source {
- char *Path;
source_type SourceType;
- source_info Info;
};
-// Bitmaps from files are loaded into these temporary cache blocks.
+struct property_header
+{
+ char *Name;
+ real32 DefaultVal;
+ real32 MinVal;
+ real32 MaxVal;
+};
+
+struct property_channel {
+ char *Name;
+ uint16 Block_Bezier_Index[MAX_KEYFRAME_BLOCKS];
+ uint16 Block_Bezier_Count;
+ uint16 Keyframe_Count;
+
+ real32 CurrentValue;
+ real32 MaxVal;
+ real32 MinVal;
+ real32 ScrubVal; // increment when dragging on sliders, etc.
+
+ bool32 IsToggled;
+};
+
+
+
+#if 0
+
+struct cached_bitmap {
+ uint32 SourceIndex; // Which source it belongs to. Currently used to dereference the bitmap.
+ void *Data; // Unpacked data loaded from the source file.
+ uint32 Frame; // What frame it is.
+};
struct gl_effect_layer {
bool32 Initialized;
@@ -250,16 +179,15 @@ struct layer_bitmap_info {
gl_effect_layer Test;
gl_effect_layer TestM;
- // TODO(fox): Find a better place to store this. Either give effects a more
- // fleshed-out API to add things to a struct like this or integrate into ImGui.
- void *HistogramVals; // 256*5 floats (all channel average + RGBA).
- uint16 LevelsSelector; // Which channel is currently active
-
// Video only
int32 CurrentFrame = -1; // The last frame number rendered to the bitmap. -1 gurantees a load upon layer creation.
void *AVInfo; // Internal data containing current frame info
};
+
+// Bitmaps from files are loaded into these temporary cache blocks.
+
+
// NOTE(fox): I use the term "comp" (composition) to mean the canvas that is
// being rendered to, since it's what I'm used to from AE.
struct comp_buffer {
@@ -347,51 +275,6 @@ struct project_layer {
};
-// NOTE(fox): I have no idea how people normally do selection; currently I'm
-// treating it more "immediate." Instead of updating a selection state as
-// things are selected, I'm just calling functions that go through all the
-// layers and keyframes to look for the IsSelected bool. If this causes
-// lag I'll switch it to the former.
-
-struct temp_layer_list {
- int16 LayerIndex[MAX_LAYERS];
-};
-
-struct temp_keyframe_list {
- keyframe *SelectedKeyframe[50];
- uint16 Amount;
-};
-
-struct project_data
-{
- uint16 Width;
- uint16 Height;
- uint16 FPS;
- uint32 NumberOfFrames;
- int32 StartFrame;
- int32 EndFrame;
- int32 CurrentFrame;
-
- // NOTE(fox): Currently I'm handling layer sorting by just saying that
- // their order in memory is the order of the index and manually moving
- // their positions.
-
- project_layer *Layer[MAX_LAYERS];
- uint16 NumberOfSelectedLayers;
- uint16 NumberOfLayers;
-
- source Source[MAX_SOURCES];
- uint32 SourceSelected;
- uint16 NumberOfSources;
-};
-
-enum transforms_hotkey_interact {
- sliding_position,
- sliding_anchorpoint,
- sliding_scale,
- sliding_rotation
-};
-
struct main_sdl
{
SDL_Texture *Texture;
@@ -426,37 +309,13 @@ struct pen_state {
bool32 IsActive;
};
-struct project_state
+enum interact_type
{
- bool32 UpdateKeyframes = 1;
- bool32 UpdateFrame = 1; // only refreshes frame; set UpdateKeyframes to update animation
- bool32 DebugDisableCache = 1;
+ interact_type_keyframe_move,
+ interact_type_keyframe_rotate,
+ interact_type_keyframe_scale
+}
- tool Tool = tool_default;
- pen_state Pen = {};
-
- uint16 LayersToRender[MAX_LAYERS];
- uint16 NumberOfLayersToRender;
-
- bool32 IsRunning = 1;
- bool32 IsPlaying;
- bool32 DemoButton = 1;
- bool32 GridButton = 1;
-
- uint16 NumberOfSelectedLayers;
- int16 MostRecentlySelectedLayer = -1; // convenience for the properties panel
- selection_type RecentSelectionType = selection_none;
-
- bool32 IsInteracting;
- real32 InteractCache[4]; // we need to store the initial position in order to record it in the undo tree
- transforms_hotkey_interact TransformsHotkeyInteract;
-
- int32 MsgTime; // currently in "frames"
- char *Msg;
-
- ImGuiTextFilter filter; // This filter API is pretty ballin'.
- bool32 RerouteEffects; // Allows shift+space hotkey to gain focus on the effects panel.
-};
struct brush_tool
{
@@ -489,16 +348,21 @@ struct ui
// Under 1 is zoomed in!
real32 TimelinePercentZoomed = 1.0f;
- real32 TimelinePercentOffset = 0.0f;
+ real32 TimelinePercentOffset = 0.3f;
- real32 Default_Y_TimelinePercentZoomed = 2.0f;
- real32 Default_Y_TimelinePercentOffset = 0.5f;
+ real32 Default_Y_TimelinePercentZoomed = 1.2f;
+ real32 Default_Y_TimelinePercentOffset = 0.0f;
real32 Y_TimelinePercentZoomed;
real32 Y_TimelinePercentOffset;
bool32 IsDragging;
+ bool32 IsTransforming;
+ int32 Wrap_X = 0;
+ int32 Wrap_Y = 0;
real32 TempVal;
+ real32 TempVal_X;
+ real32 OldVal[4];
real32 Y_MaxVal;
real32 Y_MinVal;
@@ -506,6 +370,11 @@ struct ui
real32 Display_Y_MaxVal;
real32 Display_Y_MinVal;
+ bool32 WantSetPos = false;
+ ImVec2 SetPos;
+ real32 InitPos;
+ int32 WrapDirection;
+
// Note that I don't use "zoom" to mean the scale in relation to the
// original (i.e. default = 1.0f); it's the literal screen size in pixels
// of the composition in the UI.
@@ -622,3 +491,5 @@ struct render_entry {
rectangle RenderRegion;
};
+#endif
+