Added ui for adding layers
This commit is contained in:
parent
59cb48c9f0
commit
01d960ca8f
|
@ -191,6 +191,7 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
|||
blumen_lumen_state* BLState = (blumen_lumen_state*)UserData.Memory;
|
||||
|
||||
MotorTimeElapsed += Context->DeltaTime;
|
||||
#if 0
|
||||
BLState->TimeElapsed += Context->DeltaTime;
|
||||
|
||||
if (BLState->TimeElapsed > 5)
|
||||
|
@ -200,6 +201,7 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context)
|
|||
AnimationFadeGroup_FadeTo(&State->AnimationSystem.ActiveFadeGroup, Next, 5);
|
||||
BLState->TimeElapsed = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
gs_string BlueString = MakeString("blue");
|
||||
gs_string GreenString = MakeString("green");
|
||||
|
|
|
@ -602,6 +602,28 @@ FrameCount_Render(animation_timeline_state* TimelineState, animation* ActiveAnim
|
|||
}
|
||||
}
|
||||
|
||||
internal bool
|
||||
LayerList_DrawLayerButton (ui_interface* Interface, gs_string Name, rect2 Bounds, bool Selected)
|
||||
{
|
||||
bool Result = ui_MouseClickedRect(*Interface, Bounds);
|
||||
v2 TextPos = { Bounds.Min.x + 6, Bounds.Max.y - 16};
|
||||
|
||||
v4 BoxColor = WhiteV4;
|
||||
bool DrawBox = Selected;
|
||||
if (PointIsInRect(Bounds, Interface->Mouse.Pos))
|
||||
{
|
||||
DrawBox = true;
|
||||
BoxColor = PinkV4;
|
||||
}
|
||||
|
||||
if (DrawBox)
|
||||
{
|
||||
PushRenderBoundingBox2D(Interface->RenderBuffer, Bounds.Min, Bounds.Max, 1, BoxColor);
|
||||
}
|
||||
DrawString(Interface->RenderBuffer, Name, Interface->Style.Font, TextPos, WhiteV4);
|
||||
return Result;
|
||||
}
|
||||
|
||||
internal void
|
||||
LayerList_Render(animation_timeline_state* TimelineState, animation* ActiveAnim, rect2 Bounds, panel* Panel, render_command_buffer* RenderBuffer, app_state* State, context Context)
|
||||
{
|
||||
|
@ -616,24 +638,23 @@ LayerList_Render(animation_timeline_state* TimelineState, animation* ActiveAnim,
|
|||
|
||||
if (ActiveAnim)
|
||||
{
|
||||
v2 LayerTextPos = {};
|
||||
for (u32 i = 0; i < ActiveAnim->Layers.Count; i++)
|
||||
{
|
||||
anim_layer* Layer = ActiveAnim->Layers.Values + i;
|
||||
|
||||
if (ui_MouseClickedRect(*Interface, LayerBounds))
|
||||
bool Selected = (TimelineState->SelectedAnimationLayer == i);
|
||||
if (LayerList_DrawLayerButton(Interface, Layer->Name, LayerBounds, Selected))
|
||||
{
|
||||
TimelineState->SelectedAnimationLayer = i;
|
||||
}
|
||||
|
||||
v2 LayerTextPos = { LayerBounds.Min.x + 6, LayerBounds.Max.y - 16};
|
||||
if (TimelineState->SelectedAnimationLayer == i)
|
||||
{
|
||||
PushRenderBoundingBox2D(Interface->RenderBuffer, LayerBounds.Min, LayerBounds.Max, 1, WhiteV4);
|
||||
}
|
||||
DrawString(Interface->RenderBuffer, Layer->Name, Interface->Style.Font, LayerTextPos, WhiteV4);
|
||||
|
||||
LayerBounds = Rect2TranslateY(LayerBounds, LayerDim.y);
|
||||
}
|
||||
|
||||
if (LayerList_DrawLayerButton(Interface, MakeString("+ Add Layer"), LayerBounds, false))
|
||||
{
|
||||
u32 NewLayer = Animation_AddLayer(ActiveAnim, MakeString("[New Layer]"), BlendMode_Add, &State->AnimationSystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -830,6 +851,21 @@ AnimInfoView_Render(animation_timeline_state* TimelineState, animation* ActiveAn
|
|||
}
|
||||
ui_EndRow(Interface);
|
||||
|
||||
u32 LayerIndex = TimelineState->SelectedAnimationLayer;
|
||||
anim_layer* SelectedLayer = ActiveAnim->Layers.Values + LayerIndex;
|
||||
gs_string BlendStr = BlendModeStrings[SelectedLayer->BlendMode];
|
||||
if (ui_BeginLabeledDropdown(Interface, MakeString("Blend Mode"), BlendStr))
|
||||
{
|
||||
for (u32 i = 0; i < BlendMode_Count; i++)
|
||||
{
|
||||
if (ui_Button(Interface, BlendModeStrings[i]))
|
||||
{
|
||||
SelectedLayer->BlendMode = (blend_mode)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
ui_EndLabeledDropdown(Interface);
|
||||
|
||||
animation_block* SelectedBlock = Animation_GetBlockFromHandle(ActiveAnim, TimelineState->SelectedBlockHandle);
|
||||
if (SelectedBlock)
|
||||
{
|
||||
|
|
|
@ -47,11 +47,11 @@ enum blend_mode
|
|||
};
|
||||
|
||||
// TODO(pjs): This really doesn't belong here
|
||||
global gs_const_string BlendModeStrings[] = {
|
||||
ConstString("Overwrite"),
|
||||
ConstString("Add"),
|
||||
ConstString("Multiply"),
|
||||
ConstString("Count"),
|
||||
global gs_string BlendModeStrings[] = {
|
||||
MakeString("Overwrite"),
|
||||
MakeString("Add"),
|
||||
MakeString("Multiply"),
|
||||
MakeString("Count"),
|
||||
};
|
||||
|
||||
struct anim_layer
|
||||
|
|
|
@ -32,7 +32,7 @@ AnimSerializer_Serialize(animation Anim, animation_pattern_array Patterns, gs_me
|
|||
Serializer_OpenStruct(&Serializer, AnimField_Layer);
|
||||
{
|
||||
Serializer_WriteStringValue(&Serializer, AnimField_LayerName, LayerAt.Name.ConstString);
|
||||
Serializer_WriteStringValue(&Serializer, AnimField_LayerBlendMode, BlendModeStrings[LayerAt.BlendMode]);
|
||||
Serializer_WriteStringValue(&Serializer, AnimField_LayerBlendMode, BlendModeStrings[LayerAt.BlendMode].ConstString);
|
||||
}
|
||||
Serializer_CloseStruct(&Serializer);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ AnimParser_Parse(gs_string File, gs_memory_arena* Arena, animation_pattern_array
|
|||
gs_string BlendModeName = Parser_ReadStringValue(&Parser, AnimField_LayerBlendMode);
|
||||
for (u32 i = 0; i < BlendMode_Count; i++)
|
||||
{
|
||||
if (StringsEqual(BlendModeName.ConstString, BlendModeStrings[i]))
|
||||
if (StringsEqual(BlendModeName, BlendModeStrings[i]))
|
||||
{
|
||||
Layer.BlendMode = (blend_mode)i;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue