Refactored rect functionality of gs_vector_matrix to make it not conflict with windows headers (just added gs_ to all functions). refactored Profiler interface code to use the new interface layout system.

This commit is contained in:
Peter Slattery 2020-03-21 22:44:44 -07:00
parent 5922a4bf27
commit b843937295
12 changed files with 2643 additions and 2579 deletions

File diff suppressed because it is too large Load Diff

View File

@ -667,10 +667,10 @@ PointToPercentRange (v2 P, v2 Min, v2 Max)
// you can just do: // you can just do:
// Foo(RectExpand(MyRect)) // Foo(RectExpand(MyRect))
// which makes refactoring easier as you only have to change the identifier in one place // which makes refactoring easier as you only have to change the identifier in one place
#define RectExpand(r) (r).Min, (r).Max #define gs_RectExpand(r) (r).Min, (r).Max
static rect static rect
MakeRectMinWidth(v2 Min, v2 Width) gs_MakeRectMinWidth(v2 Min, v2 Width)
{ {
rect Rect = {0}; rect Rect = {0};
Rect.Min = Min; Rect.Min = Min;
@ -679,21 +679,21 @@ MakeRectMinWidth(v2 Min, v2 Width)
} }
inline float inline float
Width (rect Rect) gs_Width (rect Rect)
{ {
float Result = Rect.Max.x - Rect.Min.x; float Result = Rect.Max.x - Rect.Min.x;
return Result; return Result;
} }
inline float inline float
Height (rect Rect) gs_Height (rect Rect)
{ {
float Result = Rect.Max.y - Rect.Min.y; float Result = Rect.Max.y - Rect.Min.y;
return Result; return Result;
} }
inline v2 inline v2
TopLeft(rect Rect) gs_TopLeft(rect Rect)
{ {
v2 Result = {0}; v2 Result = {0};
Result.x = Rect.Min.x; Result.x = Rect.Min.x;
@ -702,19 +702,19 @@ TopLeft(rect Rect)
} }
inline v2 inline v2
TopRight(rect Rect) gs_TopRight(rect Rect)
{ {
return Rect.Max; return Rect.Max;
} }
inline v2 inline v2
BottomLeft(rect Rect) gs_BottomLeft(rect Rect)
{ {
return Rect.Min; return Rect.Min;
} }
inline v2 inline v2
BottomRight(rect Rect) gs_BottomRight(rect Rect)
{ {
v2 Result = {0}; v2 Result = {0};
Result.x = Rect.Max.x; Result.x = Rect.Max.x;
@ -723,21 +723,21 @@ BottomRight(rect Rect)
} }
inline float inline float
AspectRatio (rect Rect) gs_AspectRatio (rect Rect)
{ {
float Result = Width(Rect) / Height(Rect); float Result = gs_Width(Rect) / gs_Height(Rect);
return Result; return Result;
} }
inline v2 inline v2
CalculateRectCenter (rect Rect) gs_CalculateRectCenter (rect Rect)
{ {
v2 Result = (Rect.Min + Rect.Max) / 2.0f; v2 Result = (Rect.Min + Rect.Max) / 2.0f;
return Result; return Result;
} }
inline b32 inline b32
PointIsInRect (v2 Point, rect Rect) gs_PointIsInRect (v2 Point, rect Rect)
{ {
b32 Result = ((Point.x >= Rect.Min.x && Point.x <= Rect.Max.x) && b32 Result = ((Point.x >= Rect.Min.x && Point.x <= Rect.Max.x) &&
(Point.y >= Rect.Min.y && Point.y <= Rect.Max.y)); (Point.y >= Rect.Min.y && Point.y <= Rect.Max.y));
@ -745,7 +745,7 @@ PointIsInRect (v2 Point, rect Rect)
} }
inline rect inline rect
RectOffsetByVector(rect R, v2 V) gs_RectOffsetByVector(rect R, v2 V)
{ {
rect Result = R; rect Result = R;
Result.Min += V; Result.Min += V;
@ -754,7 +754,7 @@ RectOffsetByVector(rect R, v2 V)
} }
static void static void
HSplitRectAtValue(rect Bounds, r32 YValue, rect* Top, rect* Bottom) gs_HSplitRectAtValue(rect Bounds, r32 YValue, rect* Top, rect* Bottom)
{ {
if (YValue <= Bounds.Min.y) if (YValue <= Bounds.Min.y)
{ {
@ -776,29 +776,28 @@ HSplitRectAtValue(rect Bounds, r32 YValue, rect* Top, rect* Bottom)
} }
static void static void
HSplitRectAtDistanceFromTop(rect Bounds, r32 YDist, rect* Top, rect* Bottom) gs_HSplitRectAtDistanceFromTop(rect Bounds, r32 YDist, rect* Top, rect* Bottom)
{ {
r32 YValue = Bounds.Max.y - YDist; r32 YValue = Bounds.Max.y - YDist;
HSplitRectAtValue(Bounds, YValue, Top, Bottom); gs_HSplitRectAtValue(Bounds, YValue, Top, Bottom);
} }
static void static void
HSplitRectAtDistanceFromBottom(rect Bounds, r32 YDist, rect* Top, rect* Bottom) gs_HSplitRectAtDistanceFromBottom(rect Bounds, r32 YDist, rect* Top, rect* Bottom)
{ {
r32 YValue = Bounds.Min.y + YDist; r32 YValue = Bounds.Min.y + YDist;
HSplitRectAtValue(Bounds, YValue, Top, Bottom); gs_HSplitRectAtValue(Bounds, YValue, Top, Bottom);
} }
static void static void
HSplitRectAtPercent(rect Bounds, r32 YPercent, rect* Top, rect* Bottom) gs_HSplitRectAtPercent(rect Bounds, r32 YPercent, rect* Top, rect* Bottom)
{ {
r32 YValue = GSLerp(Bounds.Min.y, Bounds.Max.y, YPercent); r32 YValue = GSLerp(Bounds.Min.y, Bounds.Max.y, YPercent);
HSplitRectAtValue(Bounds, YValue, Top, Bottom); gs_HSplitRectAtValue(Bounds, YValue, Top, Bottom);
} }
static void static void
VSplitRectAtValue(rect Bounds, r32 XValue, rect* Left, rect* Right) gs_VSplitRectAtValue(rect Bounds, r32 XValue, rect* Left, rect* Right)
{ {
if (XValue <= Bounds.Min.x) if (XValue <= Bounds.Min.x)
{ {
@ -820,30 +819,46 @@ VSplitRectAtValue(rect Bounds, r32 XValue, rect* Left, rect* Right)
} }
static void static void
VSplitRectAtDistanceFromRight(rect Bounds, r32 XDist, rect* Left, rect* Right) gs_VSplitRectAtDistanceFromRight(rect Bounds, r32 XDist, rect* Left, rect* Right)
{ {
r32 XValue = Bounds.Max.x - XDist; r32 XValue = Bounds.Max.x - XDist;
VSplitRectAtValue(Bounds, XValue, Left, Right); gs_VSplitRectAtValue(Bounds, XValue, Left, Right);
} }
static void static void
VSplitRectAtDistanceFromLeft(rect Bounds, r32 XDist, rect* Left, rect* Right) gs_VSplitRectAtDistanceFromLeft(rect Bounds, r32 XDist, rect* Left, rect* Right)
{ {
r32 XValue = Bounds.Min.x + XDist; r32 XValue = Bounds.Min.x + XDist;
VSplitRectAtValue(Bounds, XValue, Left, Right); gs_VSplitRectAtValue(Bounds, XValue, Left, Right);
} }
static void static void
VSplitRectAtPercent(rect Bounds, r32 XPercent, rect* Left, rect* Right) gs_VSplitRectAtPercent(rect Bounds, r32 XPercent, rect* Left, rect* Right)
{ {
r32 XValue = GSLerp(Bounds.Min.x, Bounds.Max.x, XPercent); r32 XValue = GSLerp(Bounds.Min.x, Bounds.Max.x, XPercent);
VSplitRectAtValue(Bounds, XValue, Left, Right); gs_VSplitRectAtValue(Bounds, XValue, Left, Right);
} }
#define TranslateRectX(r, d) TranslateRect((r), v2{(d), 0})
#define TranslateRectY(r, d) TranslateRect((r), v2{0, (d)})
static rect static rect
TranslateRect(rect R, v2 Delta) gs_InsetRect(rect Rect, v2 Amount)
{
rect Result = {0};
Result.Min = Rect.Min + Amount;
Result.Max = Rect.Max - Amount;
return Result;
}
static rect
gs_InsetRect(rect Rect, float Amount)
{
rect Result = gs_InsetRect(Rect, v2{Amount, Amount});
return Result;
}
#define gs_TranslateRectX(r, d) gs_TranslateRect((r), v2{(d), 0})
#define gs_TranslateRectY(r, d) gs_TranslateRect((r), v2{0, (d)})
static rect
gs_TranslateRect(rect R, v2 Delta)
{ {
rect Result = R; rect Result = R;
Result.Min += Delta; Result.Min += Delta;
@ -851,6 +866,13 @@ TranslateRect(rect R, v2 Delta)
return Result; return Result;
} }
static v2
gs_TransformPointIntoRectSpace(v2 Point, rect Rect)
{
v2 Result = Point - Rect.Min;
return Point;
}
////////////////////////////////////// //////////////////////////////////////
// MATRIX // MATRIX
////////////////////////////////////// //////////////////////////////////////

View File

@ -5,7 +5,6 @@
// //
#ifndef ASSEMBLY_PARSER_CPP #ifndef ASSEMBLY_PARSER_CPP
internal assembly_token internal assembly_token
ParseToken (tokenizer* Tokenizer) ParseToken (tokenizer* Tokenizer)
{ {

View File

@ -12,8 +12,8 @@ internal v4
MouseToWorldRay(r32 MouseX, r32 MouseY, camera* Camera, rect WindowBounds) MouseToWorldRay(r32 MouseX, r32 MouseY, camera* Camera, rect WindowBounds)
{ {
DEBUG_TRACK_SCOPE(MouseToWorldRay); DEBUG_TRACK_SCOPE(MouseToWorldRay);
r32 X = ((2.0f * MouseX) / Width(WindowBounds)) - 1; r32 X = ((2.0f * MouseX) / gs_Width(WindowBounds)) - 1;
r32 Y = ((2.0f * MouseY) / Height(WindowBounds)) - 1; r32 Y = ((2.0f * MouseY) / gs_Height(WindowBounds)) - 1;
v4 ScreenPos = v4{X, Y, -1, 1}; v4 ScreenPos = v4{X, Y, -1, 1};
@ -169,7 +169,7 @@ INITIALIZE_APPLICATION(InitializeApplication)
State->NetworkProtocolHeaderSize = STREAM_HEADER_SIZE; State->NetworkProtocolHeaderSize = STREAM_HEADER_SIZE;
State->Camera.FieldOfView = DegreesToRadians(45.0f); State->Camera.FieldOfView = DegreesToRadians(45.0f);
State->Camera.AspectRatio = AspectRatio(State->WindowBounds); State->Camera.AspectRatio = gs_AspectRatio(State->WindowBounds);
State->Camera.Near = 1.0f; State->Camera.Near = 1.0f;
State->Camera.Far = 100.0f; State->Camera.Far = 100.0f;
State->Camera.Position = v3{0, 0, -250}; State->Camera.Position = v3{0, 0, -250};
@ -498,7 +498,7 @@ UPDATE_AND_RENDER(UpdateAndRender)
} }
} }
PushRenderOrthographic(RenderBuffer, 0, 0, Width(State->WindowBounds), Height(State->WindowBounds)); PushRenderOrthographic(RenderBuffer, 0, 0, gs_Width(State->WindowBounds), gs_Height(State->WindowBounds));
PushRenderClearScreen(RenderBuffer); PushRenderClearScreen(RenderBuffer);
State->WindowBounds = Context->WindowBounds; State->WindowBounds = Context->WindowBounds;

View File

@ -123,7 +123,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(EndDragPanelBorderOperation)
} }
else else
{ {
Panel->SplitPercent = (NewSplitY - PanelBounds.Min.y) / Height(PanelBounds); Panel->SplitPercent = (NewSplitY - PanelBounds.Min.y) / gs_Height(PanelBounds);
} }
} }
else if (Panel->SplitDirection == PanelSplit_Vertical) else if (Panel->SplitDirection == PanelSplit_Vertical)
@ -139,7 +139,7 @@ FOLDHAUS_INPUT_COMMAND_PROC(EndDragPanelBorderOperation)
} }
else else
{ {
Panel->SplitPercent = (NewSplitX - PanelBounds.Min.x) / Width(PanelBounds); Panel->SplitPercent = (NewSplitX - PanelBounds.Min.x) / gs_Width(PanelBounds);
} }
} }
} }
@ -241,12 +241,12 @@ FOLDHAUS_INPUT_COMMAND_PROC(EndSplitPanelOperation)
if (XDistance > YDistance) if (XDistance > YDistance)
{ {
r32 XPercent = (Mouse.Pos.x - PanelBounds.Min.x) / Width(PanelBounds); r32 XPercent = (Mouse.Pos.x - PanelBounds.Min.x) / gs_Width(PanelBounds);
SplitPanelVertically(Panel, XPercent, PanelBounds, &State->PanelSystem); SplitPanelVertically(Panel, XPercent, PanelBounds, &State->PanelSystem);
} }
else else
{ {
r32 YPercent = (Mouse.Pos.y - PanelBounds.Min.y) / Height(PanelBounds); r32 YPercent = (Mouse.Pos.y - PanelBounds.Min.y) / gs_Height(PanelBounds);
SplitPanelHorizontally(Panel, YPercent, PanelBounds, &State->PanelSystem); SplitPanelHorizontally(Panel, YPercent, PanelBounds, &State->PanelSystem);
} }
@ -301,11 +301,11 @@ HandleMouseDownPanelInteractionOrRecurse(panel* Panel, panel_edit_mode PanelEdit
{ {
rect TopPanelBounds = GetTopPanelBounds(Panel, PanelBounds); rect TopPanelBounds = GetTopPanelBounds(Panel, PanelBounds);
rect BottomPanelBounds = GetBottomPanelBounds(Panel, PanelBounds); rect BottomPanelBounds = GetBottomPanelBounds(Panel, PanelBounds);
if (PointIsInRect(Mouse.DownPos, BottomPanelBounds)) if (gs_PointIsInRect(Mouse.DownPos, BottomPanelBounds))
{ {
HandleMouseDownPanelInteractionOrRecurse(&Panel->Bottom->Panel, PanelEditMode, BottomPanelBounds, Mouse, State); HandleMouseDownPanelInteractionOrRecurse(&Panel->Bottom->Panel, PanelEditMode, BottomPanelBounds, Mouse, State);
} }
if (PointIsInRect(Mouse.DownPos, TopPanelBounds)) if (gs_PointIsInRect(Mouse.DownPos, TopPanelBounds))
{ {
HandleMouseDownPanelInteractionOrRecurse(&Panel->Top->Panel, PanelEditMode, TopPanelBounds, Mouse, State); HandleMouseDownPanelInteractionOrRecurse(&Panel->Top->Panel, PanelEditMode, TopPanelBounds, Mouse, State);
} }
@ -324,11 +324,11 @@ HandleMouseDownPanelInteractionOrRecurse(panel* Panel, panel_edit_mode PanelEdit
{ {
rect LeftPanelBounds = GetLeftPanelBounds(Panel, PanelBounds); rect LeftPanelBounds = GetLeftPanelBounds(Panel, PanelBounds);
rect RightPanelBounds = GetRightPanelBounds(Panel, PanelBounds); rect RightPanelBounds = GetRightPanelBounds(Panel, PanelBounds);
if (PointIsInRect(Mouse.DownPos, LeftPanelBounds)) if (gs_PointIsInRect(Mouse.DownPos, LeftPanelBounds))
{ {
HandleMouseDownPanelInteractionOrRecurse(&Panel->Left->Panel, PanelEditMode, LeftPanelBounds, Mouse, State); HandleMouseDownPanelInteractionOrRecurse(&Panel->Left->Panel, PanelEditMode, LeftPanelBounds, Mouse, State);
} }
if (PointIsInRect(Mouse.DownPos, RightPanelBounds)) if (gs_PointIsInRect(Mouse.DownPos, RightPanelBounds))
{ {
HandleMouseDownPanelInteractionOrRecurse(&Panel->Right->Panel, PanelEditMode, RightPanelBounds, Mouse, State); HandleMouseDownPanelInteractionOrRecurse(&Panel->Right->Panel, PanelEditMode, RightPanelBounds, Mouse, State);
} }
@ -403,14 +403,14 @@ DrawPanelFooter(panel* Panel, render_command_buffer* RenderBuffer, rect FooterBo
PushRenderQuad2D(RenderBuffer, FooterBounds.Min, v2{FooterBounds.Max.x, FooterBounds.Min.y + 25}, v4{.5f, .5f, .5f, 1.f}); PushRenderQuad2D(RenderBuffer, FooterBounds.Min, v2{FooterBounds.Max.x, FooterBounds.Min.y + 25}, v4{.5f, .5f, .5f, 1.f});
PushRenderQuad2D(RenderBuffer, FooterBounds.Min, FooterBounds.Min + v2{25, 25}, WhiteV4); PushRenderQuad2D(RenderBuffer, FooterBounds.Min, FooterBounds.Min + v2{25, 25}, WhiteV4);
rect PanelSelectBtnBounds = MakeRectMinWidth(FooterBounds.Min + v2{30, 1}, v2{100, 23}); rect PanelSelectBtnBounds = gs_MakeRectMinWidth(FooterBounds.Min + v2{30, 1}, v2{100, 23});
if (Panel->PanelSelectionMenuOpen) if (Panel->PanelSelectionMenuOpen)
{ {
rect ButtonBounds = MakeRectMinWidth(v2{ PanelSelectBtnBounds.Min.x, FooterBounds.Max.y }, v2{ 100, 25 }); rect ButtonBounds = gs_MakeRectMinWidth(v2{ PanelSelectBtnBounds.Min.x, FooterBounds.Max.y }, v2{ 100, 25 });
v2 MenuMin = ButtonBounds.Min; v2 MenuMin = ButtonBounds.Min;
v2 MenuMax = v2{ButtonBounds.Min.x + Width(ButtonBounds), ButtonBounds.Min.y + (Height(ButtonBounds) * GlobalPanelDefsCount)}; v2 MenuMax = v2{ButtonBounds.Min.x + gs_Width(ButtonBounds), ButtonBounds.Min.y + (gs_Height(ButtonBounds) * GlobalPanelDefsCount)};
if (MouseButtonTransitionedDown(Mouse.LeftButtonState) if (MouseButtonTransitionedDown(Mouse.LeftButtonState)
&& !PointIsInRange(Mouse.DownPos, MenuMin, MenuMax)) && !PointIsInRange(Mouse.DownPos, MenuMin, MenuMax))
{ {
@ -428,7 +428,7 @@ DrawPanelFooter(panel* Panel, render_command_buffer* RenderBuffer, rect FooterBo
Panel->PanelSelectionMenuOpen = false; Panel->PanelSelectionMenuOpen = false;
} }
ButtonBounds = TranslateRectY(ButtonBounds, Height(ButtonBounds)); ButtonBounds = gs_TranslateRectY(ButtonBounds, gs_Height(ButtonBounds));
} }
} }

View File

@ -207,8 +207,9 @@ struct ui_layout
r32 RowYAt; r32 RowYAt;
b32 DrawHorizontal; b32 DrawHorizontal;
u32 RowDivisions; u32 ColumnsMax;
u32 RowElementsCount; r32* ColumnWidths;
u32 ColumnsCount;
}; };
struct ui_interface struct ui_interface
@ -230,11 +231,12 @@ ui_CreateLayout(ui_interface Interface, rect Bounds)
} }
static void static void
ui_StartRow(ui_layout* Layout, u32 RowDivisions) ui_StartRow(ui_layout* Layout, u32 ColumnsMax)
{ {
Layout->DrawHorizontal = true; Layout->DrawHorizontal = true;
Layout->RowDivisions = RowDivisions; Layout->ColumnsMax = ColumnsMax;
Layout->RowElementsCount = 0; Layout->ColumnWidths = 0;
Layout->ColumnsCount = 0;
} }
static void static void
@ -243,10 +245,21 @@ ui_StartRow(ui_layout* Layout)
ui_StartRow(Layout, 0); ui_StartRow(Layout, 0);
} }
static void
ui_StartRow(ui_layout* Layout, u32 ColumnsMax, r32* ColumnWidths)
{
Layout->DrawHorizontal = true;
Layout->ColumnsMax = ColumnsMax;
Layout->ColumnWidths = ColumnWidths;
Layout->ColumnsCount = 0;
}
static void static void
ui_EndRow(ui_layout* Layout) ui_EndRow(ui_layout* Layout)
{ {
Layout->DrawHorizontal = false; Layout->DrawHorizontal = false;
Layout->ColumnWidths = 0;
Layout->RowYAt -= Layout->RowHeight;
} }
static b32 static b32
@ -261,19 +274,32 @@ ui_TryReserveElementBounds(ui_layout* Layout, rect* Bounds)
} }
else else
{ {
if (Layout->RowDivisions > 0) if (Layout->ColumnsMax > 0)
{ {
Assert(Layout->RowElementsCount < Layout->RowDivisions); Assert(Layout->ColumnsCount < Layout->ColumnsMax);
r32 ElementWidth = Width(Layout->Bounds) / Layout->RowDivisions; if (Layout->ColumnWidths != 0)
{
v2 Min = { Layout->Bounds.Min.x, Layout->RowYAt };
for (u32 i = 0; i < Layout->ColumnsCount; i++)
{
Min.x += Layout->ColumnWidths[i];
}
Bounds->Min = Min;
Bounds->Max = Bounds->Min + v2{ Layout->ColumnWidths[Layout->ColumnsCount], Layout->RowHeight };
}
else
{
r32 ElementWidth = gs_Width(Layout->Bounds) / Layout->ColumnsMax;
Bounds->Min = { Bounds->Min = {
Layout->Bounds.Min.x + (ElementWidth * Layout->RowElementsCount) + Layout->Margin.x, Layout->Bounds.Min.x + (ElementWidth * Layout->ColumnsCount) + Layout->Margin.x,
Layout->RowYAt Layout->RowYAt
}; };
Bounds->Max = { Bounds->Max = {
Bounds->Min.x + ElementWidth - Layout->Margin.x, Bounds->Min.x + ElementWidth - Layout->Margin.x,
Bounds->Min.y + Layout->RowHeight Bounds->Min.y + Layout->RowHeight
}; };
Layout->RowElementsCount++; }
Layout->ColumnsCount++;
} }
else else
{ {
@ -302,6 +328,17 @@ ui_ReserveElementBounds(ui_layout* Layout)
return Bounds; return Bounds;
} }
static rect
ui_LayoutRemaining(ui_layout Layout)
{
rect Result = Layout.Bounds;
Result.Max.y = Layout.RowYAt;
if (Layout.DrawHorizontal)
{
Result.Max.y -= Layout.RowHeight;
}
return Result;
}
// //
// Drawing Functions // Drawing Functions
// //
@ -309,7 +346,7 @@ ui_ReserveElementBounds(ui_layout* Layout)
static void static void
ui_FillRect(ui_interface* Interface, rect Bounds, v4 Color) ui_FillRect(ui_interface* Interface, rect Bounds, v4 Color)
{ {
PushRenderQuad2D(Interface->RenderBuffer, RectExpand(Bounds), Color); PushRenderQuad2D(Interface->RenderBuffer, gs_RectExpand(Bounds), Color);
} }
static void static void
@ -371,7 +408,7 @@ ui_Button(ui_interface* Interface, string Text, rect Bounds, v4 InactiveColor, v
{ {
b32 Pressed = false; b32 Pressed = false;
v4 ButtonBG = InactiveColor; v4 ButtonBG = InactiveColor;
if (PointIsInRect(Interface->Mouse.Pos, Bounds)) if (gs_PointIsInRect(Interface->Mouse.Pos, Bounds))
{ {
ButtonBG = HoverColor; ButtonBG = HoverColor;
if (MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState)) if (MouseButtonTransitionedDown(Interface->Mouse.LeftButtonState))

View File

@ -27,7 +27,7 @@ inline s32
GetXPositionFromFrameInAnimationPanel (u32 Frame, rect PanelBounds, frame_range VisibleRange) GetXPositionFromFrameInAnimationPanel (u32 Frame, rect PanelBounds, frame_range VisibleRange)
{ {
r32 PercentOfTimeline = (r32)(Frame - VisibleRange.Min) / (r32)GetFrameCount(VisibleRange); r32 PercentOfTimeline = (r32)(Frame - VisibleRange.Min) / (r32)GetFrameCount(VisibleRange);
s32 XPositionAtFrame = (PercentOfTimeline * Width(PanelBounds)) + PanelBounds.Min.x; s32 XPositionAtFrame = (PercentOfTimeline * gs_Width(PanelBounds)) + PanelBounds.Min.x;
return XPositionAtFrame; return XPositionAtFrame;
} }
@ -295,14 +295,14 @@ DrawFrameBar (animation_system* AnimationSystem, render_command_buffer* RenderBu
s32 VisibleFrameCount = VisibleFrames.Max - VisibleFrames.Min; s32 VisibleFrameCount = VisibleFrames.Max - VisibleFrames.Min;
r32 BarHeight = Height(BarBounds); r32 BarHeight = gs_Height(BarBounds);
r32 BarWidth = Width(BarBounds); r32 BarWidth = gs_Width(BarBounds);
PushRenderQuad2D(RenderBuffer, RectExpand(BarBounds), v4{.16f, .16f, .16f, 1.f}); PushRenderQuad2D(RenderBuffer, gs_RectExpand(BarBounds), v4{.16f, .16f, .16f, 1.f});
// Mouse clicked inside frame nubmer bar -> change current frame on timeline // Mouse clicked inside frame nubmer bar -> change current frame on timeline
if (MouseButtonTransitionedDown(Mouse.LeftButtonState) && if (MouseButtonTransitionedDown(Mouse.LeftButtonState) &&
PointIsInRange(Mouse.DownPos, RectExpand(BarBounds))) PointIsInRange(Mouse.DownPos, gs_RectExpand(BarBounds)))
{ {
StartDragTimeMarker(BarBounds, VisibleFrames, State); StartDragTimeMarker(BarBounds, VisibleFrames, State);
} }
@ -344,9 +344,9 @@ DrawTimelineRangeBar (animation_system* AnimationSystem, animation_timeline_stat
{ {
frame_range Result = {0}; frame_range Result = {0};
r32 BarHeight = Height(BarBounds); r32 BarHeight = gs_Height(BarBounds);
r32 BarWidth = Width(BarBounds); r32 BarWidth = gs_Width(BarBounds);
PushRenderQuad2D(RenderBuffer, RectExpand(BarBounds), v4{.16f, .16f, .16f, 1.f}); PushRenderQuad2D(RenderBuffer, gs_RectExpand(BarBounds), v4{.16f, .16f, .16f, 1.f});
r32 PlayableFrames = (r32)GetFrameCount(AnimationSystem->PlayableRange); r32 PlayableFrames = (r32)GetFrameCount(AnimationSystem->PlayableRange);
v2 SliderBarDim = v2{25, BarHeight}; v2 SliderBarDim = v2{25, BarHeight};
@ -354,8 +354,8 @@ DrawTimelineRangeBar (animation_system* AnimationSystem, animation_timeline_stat
// Convert Frames To Pixels // Convert Frames To Pixels
r32 VisibleMinPercentPlayable = FrameToPercentRange(TimelineState->VisibleRange.Min, AnimationSystem->PlayableRange); r32 VisibleMinPercentPlayable = FrameToPercentRange(TimelineState->VisibleRange.Min, AnimationSystem->PlayableRange);
r32 VisibleMaxPercentPlayable = FrameToPercentRange(TimelineState->VisibleRange.Max, AnimationSystem->PlayableRange); r32 VisibleMaxPercentPlayable = FrameToPercentRange(TimelineState->VisibleRange.Max, AnimationSystem->PlayableRange);
v2 RangeMinSliderMin = v2{BarBounds.Min.x + (VisibleMinPercentPlayable * Width(BarBounds)), BarBounds.Min.y}; v2 RangeMinSliderMin = v2{BarBounds.Min.x + (VisibleMinPercentPlayable * gs_Width(BarBounds)), BarBounds.Min.y};
v2 RangeMaxSliderMin = v2{BarBounds.Min.x + (VisibleMaxPercentPlayable * Width(BarBounds)) - 25, BarBounds.Min.y}; v2 RangeMaxSliderMin = v2{BarBounds.Min.x + (VisibleMaxPercentPlayable * gs_Width(BarBounds)) - 25, BarBounds.Min.y};
if (MouseButtonHeldDown(Mouse.LeftButtonState) || if (MouseButtonHeldDown(Mouse.LeftButtonState) ||
MouseButtonTransitionedUp(Mouse.LeftButtonState)) MouseButtonTransitionedUp(Mouse.LeftButtonState))
@ -398,7 +398,7 @@ DrawTimelineRangeBar (animation_system* AnimationSystem, animation_timeline_stat
internal void internal void
DrawLayerMenu(animation_system* AnimationSystem, rect PanelDim, render_command_buffer* RenderBuffer, app_state* State, mouse_state Mouse) DrawLayerMenu(animation_system* AnimationSystem, rect PanelDim, render_command_buffer* RenderBuffer, app_state* State, mouse_state Mouse)
{ {
v2 LayerDim = { Width(PanelDim), LAYER_HEIGHT }; v2 LayerDim = { gs_Width(PanelDim), LAYER_HEIGHT };
v2 LayerListMin = PanelDim.Min + v2{0, 24}; v2 LayerListMin = PanelDim.Min + v2{0, 24};
for (u32 LayerIndex = 0; LayerIndex < AnimationSystem->LayersCount; LayerIndex++) for (u32 LayerIndex = 0; LayerIndex < AnimationSystem->LayersCount; LayerIndex++)
{ {
@ -408,7 +408,7 @@ DrawLayerMenu(animation_system* AnimationSystem, rect PanelDim, render_command_b
LayerBounds.Max = LayerBounds.Min + LayerDim; LayerBounds.Max = LayerBounds.Min + LayerDim;
if (MouseButtonTransitionedDown(Mouse.LeftButtonState) && if (MouseButtonTransitionedDown(Mouse.LeftButtonState) &&
PointIsInRect(Mouse.Pos, LayerBounds)) gs_PointIsInRect(Mouse.Pos, LayerBounds))
{ {
State->SelectedAnimationLayer = LayerIndex; State->SelectedAnimationLayer = LayerIndex;
} }
@ -416,7 +416,7 @@ DrawLayerMenu(animation_system* AnimationSystem, rect PanelDim, render_command_b
v2 LayerTextPos = { LayerBounds.Min.x + 6, LayerBounds.Max.y - 16}; v2 LayerTextPos = { LayerBounds.Min.x + 6, LayerBounds.Max.y - 16};
if (State->SelectedAnimationLayer == LayerIndex) if (State->SelectedAnimationLayer == LayerIndex)
{ {
PushRenderBoundingBox2D(RenderBuffer, RectExpand(LayerBounds), 1, WhiteV4); PushRenderBoundingBox2D(RenderBuffer, gs_RectExpand(LayerBounds), 1, WhiteV4);
} }
DrawString(RenderBuffer, Layer->Name, State->Interface.Font, LayerTextPos, WhiteV4); DrawString(RenderBuffer, Layer->Name, State->Interface.Font, LayerTextPos, WhiteV4);
} }
@ -427,7 +427,7 @@ DrawAnimationBlock (animation_block AnimationBlock, v4 BlockColor, frame_range V
{ {
rect BlockBounds = {}; rect BlockBounds = {};
r32 TimelineWidth = Width(TimelineBounds); r32 TimelineWidth = gs_Width(TimelineBounds);
u32 ClampedBlockStartFrame = ClampFrameToRange(AnimationBlock.Range.Min, VisibleFrames); u32 ClampedBlockStartFrame = ClampFrameToRange(AnimationBlock.Range.Min, VisibleFrames);
r32 StartFramePercent = FrameToPercentRange(ClampedBlockStartFrame, VisibleFrames); r32 StartFramePercent = FrameToPercentRange(ClampedBlockStartFrame, VisibleFrames);
@ -454,12 +454,12 @@ DrawAnimationTimeline (animation_system* AnimationSystem, animation_timeline_sta
gs_list_handle Result = SelectedBlockHandle; gs_list_handle Result = SelectedBlockHandle;
rect LayerMenuBounds, TimelineBounds; rect LayerMenuBounds, TimelineBounds;
VSplitRectAtDistanceFromLeft(PanelBounds, 256, &LayerMenuBounds, &TimelineBounds); gs_VSplitRectAtDistanceFromLeft(PanelBounds, 256, &LayerMenuBounds, &TimelineBounds);
// In Top To Bottom Order // In Top To Bottom Order
rect TimelineFrameBarBounds, TimelineBlockDisplayBounds, TimelineRangeBarBounds; rect TimelineFrameBarBounds, TimelineBlockDisplayBounds, TimelineRangeBarBounds;
HSplitRectAtDistanceFromTop(TimelineBounds, 32, &TimelineFrameBarBounds, &TimelineBounds); gs_HSplitRectAtDistanceFromTop(TimelineBounds, 32, &TimelineFrameBarBounds, &TimelineBounds);
HSplitRectAtDistanceFromBottom(TimelineBounds, 24, &TimelineBlockDisplayBounds, &TimelineRangeBarBounds); gs_HSplitRectAtDistanceFromBottom(TimelineBounds, 24, &TimelineBlockDisplayBounds, &TimelineRangeBarBounds);
// TODO(Peter): Clean Up // TODO(Peter): Clean Up
DrawLayerMenu(AnimationSystem, LayerMenuBounds, Interface->RenderBuffer, State, Interface->Mouse); DrawLayerMenu(AnimationSystem, LayerMenuBounds, Interface->RenderBuffer, State, Interface->Mouse);
@ -501,7 +501,7 @@ DrawAnimationTimeline (animation_system* AnimationSystem, animation_timeline_sta
} }
// TODO(Peter): Clean Up // TODO(Peter): Clean Up
rect BlockBounds = DrawAnimationBlock(AnimationBlockAt, BlockColor, AdjustedViewRange, TimelineBounds, Interface->RenderBuffer); rect BlockBounds = DrawAnimationBlock(AnimationBlockAt, BlockColor, AdjustedViewRange, TimelineBounds, Interface->RenderBuffer);
if (PointIsInRect(Interface->Mouse.Pos, BlockBounds)) if (gs_PointIsInRect(Interface->Mouse.Pos, BlockBounds))
{ {
DragBlockHandle = CurrentBlockHandle; DragBlockHandle = CurrentBlockHandle;
} }
@ -531,7 +531,7 @@ DrawAnimationTimeline (animation_system* AnimationSystem, animation_timeline_sta
ui_OutlineRect(Interface, TimelineFrameBarBounds, 1.f, RedV4); ui_OutlineRect(Interface, TimelineFrameBarBounds, 1.f, RedV4);
ui_OutlineRect(Interface, TimelineBlockDisplayBounds, 1.f, RedV4); ui_OutlineRect(Interface, TimelineBlockDisplayBounds, 1.f, RedV4);
if (MouseDownAndNotHandled && PointIsInRect(Interface->Mouse.Pos, TimelineBounds)) if (MouseDownAndNotHandled && gs_PointIsInRect(Interface->Mouse.Pos, TimelineBounds))
{ {
DeselectCurrentAnimationBlock(State); DeselectCurrentAnimationBlock(State);
} }
@ -581,9 +581,9 @@ AnimationTimeline_Render(panel Panel, rect PanelBounds, render_command_buffer* R
animation_system* AnimationSystem = &State->AnimationSystem; animation_system* AnimationSystem = &State->AnimationSystem;
rect TitleBarBounds, PanelContentsBounds; rect TitleBarBounds, PanelContentsBounds;
HSplitRectAtDistanceFromTop(PanelBounds, Interface->Style.RowHeight, &TitleBarBounds, &PanelContentsBounds); gs_HSplitRectAtDistanceFromTop(PanelBounds, Interface->Style.RowHeight, &TitleBarBounds, &PanelContentsBounds);
rect AnimationListBounds, TimelineBounds; rect AnimationListBounds, TimelineBounds;
VSplitRectAtDistanceFromLeft(PanelContentsBounds, 300, &AnimationListBounds, &TimelineBounds); gs_VSplitRectAtDistanceFromLeft(PanelContentsBounds, 300, &AnimationListBounds, &TimelineBounds);
ui_FillRect(Interface, TitleBarBounds, Interface->Style.PanelBGColors[0]); ui_FillRect(Interface, TitleBarBounds, Interface->Style.PanelBGColors[0]);
ui_layout TitleBarLayout = ui_CreateLayout(*Interface, TitleBarBounds); ui_layout TitleBarLayout = ui_CreateLayout(*Interface, TitleBarBounds);
@ -605,7 +605,7 @@ AnimationTimeline_Render(panel Panel, rect PanelBounds, render_command_buffer* R
} }
ui_EndRow(&TitleBarLayout); ui_EndRow(&TitleBarLayout);
if (Height(TimelineBounds) > 0) if (gs_Height(TimelineBounds) > 0)
{ {
SelectedBlockHandle = DrawAnimationTimeline(AnimationSystem, TimelineState, TimelineBounds, SelectedBlockHandle, Interface, State); SelectedBlockHandle = DrawAnimationTimeline(AnimationSystem, TimelineState, TimelineBounds, SelectedBlockHandle, Interface, State);
DrawAnimationClipsList(AnimationListBounds, Interface, State->SelectedAnimationLayer, &State->AnimationSystem); DrawAnimationClipsList(AnimationListBounds, Interface, State->SelectedAnimationLayer, &State->AnimationSystem);

View File

@ -44,10 +44,10 @@ FileView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuff
rect ListBounds = {0}; rect ListBounds = {0};
ListBounds.Min = PanelBounds.Min; ListBounds.Min = PanelBounds.Min;
ListBounds.Max = BottomRight(HeaderBounds); ListBounds.Max = gs_BottomRight(HeaderBounds);
PushRenderQuad2D(RenderBuffer, RectExpand(HeaderBounds), PinkV4); PushRenderQuad2D(RenderBuffer, gs_RectExpand(HeaderBounds), PinkV4);
PushRenderQuad2D(RenderBuffer, RectExpand(ListBounds), RedV4); PushRenderQuad2D(RenderBuffer, gs_RectExpand(ListBounds), RedV4);
} }

View File

@ -35,7 +35,7 @@ HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* Rende
string TempString = MakeString(PushArray(&State->Transient, char, 256), 0, 256); string TempString = MakeString(PushArray(&State->Transient, char, 256), 0, 256);
u32 LineCount = (u32)(Height(PanelBounds) / Layout.RowHeight) + 1; u32 LineCount = (u32)(gs_Height(PanelBounds) / Layout.RowHeight) + 1;
u32 LinesDrawn = 0; u32 LinesDrawn = 0;
u32 AssembliesToDraw = GSMin(LineCount, State->ActiveAssemblyIndecies.Used); u32 AssembliesToDraw = GSMin(LineCount, State->ActiveAssemblyIndecies.Used);
for (; LinesDrawn < AssembliesToDraw; LinesDrawn++) for (; LinesDrawn < AssembliesToDraw; LinesDrawn++)

View File

@ -128,8 +128,8 @@ FOLDHAUS_INPUT_COMMAND_PROC(EndConnectNodesOperation)
for (u32 p = 0; p < GraphState->Layout.VisualPortsCount; p++) for (u32 p = 0; p < GraphState->Layout.VisualPortsCount; p++)
{ {
visual_port VisualPort = GraphState->Layout.VisualPorts[p]; visual_port VisualPort = GraphState->Layout.VisualPorts[p];
rect ViewAdjustedBounds = RectOffsetByVector(VisualPort.PortBounds, GraphState->ViewOffset); rect ViewAdjustedBounds = gs_RectOffsetByVector(VisualPort.PortBounds, GraphState->ViewOffset);
if (PointIsInRect(Mouse.Pos, ViewAdjustedBounds)) if (gs_PointIsInRect(Mouse.Pos, ViewAdjustedBounds))
{ {
visual_port UpstreamPort = (OpState->IsInput & IsInputMember) ? VisualPort : OpState->VisualPort; visual_port UpstreamPort = (OpState->IsInput & IsInputMember) ? VisualPort : OpState->VisualPort;
visual_port DownstreamPort = (OpState->IsInput & IsInputMember) ? OpState->VisualPort : VisualPort; visual_port DownstreamPort = (OpState->IsInput & IsInputMember) ? OpState->VisualPort : VisualPort;
@ -161,7 +161,7 @@ BeginConnectNodesOperation(visual_port VisualPort, u32 VisualPortIndex, mouse_st
node_graph_state* GraphState = (node_graph_state*)NodeGraphPanel.Panel->PanelStateMemory; node_graph_state* GraphState = (node_graph_state*)NodeGraphPanel.Panel->PanelStateMemory;
GraphState->Layout.ConnectionIsInProgress = true; GraphState->Layout.ConnectionIsInProgress = true;
GraphState->Layout.InProgressConnectionStart = CalculateRectCenter(VisualPort.PortBounds); GraphState->Layout.InProgressConnectionStart = gs_CalculateRectCenter(VisualPort.PortBounds);
} }
// //
@ -410,8 +410,8 @@ ArrangeNodes(pattern_node_workspace Workspace, r32 NodeWidth, r32 LayerDistance,
visual_port UpstreamPort = Result.VisualPorts[VisualConnection->UpstreamVisualPortIndex]; visual_port UpstreamPort = Result.VisualPorts[VisualConnection->UpstreamVisualPortIndex];
visual_port DownstreamPort = Result.VisualPorts[VisualConnection->DownstreamVisualPortIndex]; visual_port DownstreamPort = Result.VisualPorts[VisualConnection->DownstreamVisualPortIndex];
VisualConnection->UpstreamPosition = CalculateRectCenter(UpstreamPort.PortBounds); VisualConnection->UpstreamPosition = gs_CalculateRectCenter(UpstreamPort.PortBounds);
VisualConnection->DownstreamPosition = CalculateRectCenter(DownstreamPort.PortBounds); VisualConnection->DownstreamPosition = gs_CalculateRectCenter(DownstreamPort.PortBounds);
} }
return Result; return Result;
@ -513,7 +513,7 @@ NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuf
List.TextColor = WhiteV4; List.TextColor = WhiteV4;
List.ListBounds = NodeSelectionWindowBounds; List.ListBounds = NodeSelectionWindowBounds;
List.ListElementDimensions = v2{ List.ListElementDimensions = v2{
Width(NodeSelectionWindowBounds), gs_Width(NodeSelectionWindowBounds),
(r32)(State->Interface.Font->PixelHeight + 8), (r32)(State->Interface.Font->PixelHeight + 8),
}; };
List.ElementLabelIndent = v2{10, 4}; List.ElementLabelIndent = v2{10, 4};
@ -527,7 +527,7 @@ NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuf
rect ElementBounds = DrawListElement(Spec.Identifier, &List, Mouse, RenderBuffer, State->Interface); rect ElementBounds = DrawListElement(Spec.Identifier, &List, Mouse, RenderBuffer, State->Interface);
if (MouseButtonTransitionedDown(Mouse.LeftButtonState) if (MouseButtonTransitionedDown(Mouse.LeftButtonState)
&& PointIsInRect(Mouse.DownPos, ElementBounds)) && gs_PointIsInRect(Mouse.DownPos, ElementBounds))
{ {
PushNodeOnWorkspace(i, &State->NodeWorkspace, &State->Transient); PushNodeOnWorkspace(i, &State->NodeWorkspace, &State->Transient);
GraphState->LayoutIsDirty = true; GraphState->LayoutIsDirty = true;

View File

@ -25,10 +25,7 @@ ProfilerView_Cleanup(panel* Panel, app_state* State)
} }
internal void internal void
RenderProfiler_ScopeVisualization(render_command_buffer* RenderBuffer, RenderProfiler_ScopeVisualization(ui_interface* Interface, ui_layout Layout, debug_frame* VisibleFrame, memory_arena* Memory)
interface_config Interface, mouse_state Mouse,
v2 Min, v2 Max,
debug_frame* VisibleFrame, memory_arena* Memory)
{ {
v4 ThreadColors[] = { v4 ThreadColors[] = {
v4{.73f, .33f, .83f, 1}, v4{.73f, .33f, .83f, 1},
@ -38,7 +35,8 @@ RenderProfiler_ScopeVisualization(render_command_buffer* RenderBuffer,
v4{.74f, .40f, .25f, 1}, v4{.74f, .40f, .25f, 1},
}; };
r32 Width = Max.x - Min.x; rect Bounds = ui_LayoutRemaining(Layout);
r32 Width = gs_Width(Bounds);
r32 DepthHeight = 64; r32 DepthHeight = 64;
s64 FrameStartCycles = VisibleFrame->FrameStartCycles; s64 FrameStartCycles = VisibleFrame->FrameStartCycles;
@ -47,6 +45,9 @@ RenderProfiler_ScopeVisualization(render_command_buffer* RenderBuffer,
debug_scope_record_list* ThreadScopeCalls = GetScopeListForThreadInFrame(GlobalDebugServices, debug_scope_record_list* ThreadScopeCalls = GetScopeListForThreadInFrame(GlobalDebugServices,
VisibleFrame); VisibleFrame);
scope_record* HotRecord = 0;
scope_name* HotRecordName = 0;
MakeStringBuffer(String, 256); MakeStringBuffer(String, 256);
for (s32 i = 0; i < ThreadScopeCalls->Count; i++) for (s32 i = 0; i < ThreadScopeCalls->Count; i++)
{ {
@ -55,44 +56,50 @@ RenderProfiler_ScopeVisualization(render_command_buffer* RenderBuffer,
r32 PercentStart = (r32)(Record->StartCycles - FrameStartCycles) / (r32)FrameTotalCycles; r32 PercentStart = (r32)(Record->StartCycles - FrameStartCycles) / (r32)FrameTotalCycles;
r32 PercentEnd = (r32)(Record->EndCycles - FrameStartCycles) / (r32)FrameTotalCycles; r32 PercentEnd = (r32)(Record->EndCycles - FrameStartCycles) / (r32)FrameTotalCycles;
v2 ScopeMin = v2{Min.x + (Width * PercentStart), Max.y - ((Record->CallDepth + 1) * DepthHeight)}; r32 PixelStart = Bounds.Min.x + (Width * PercentStart);
v2 ScopeMax = v2{Min.x + (Width * PercentEnd), ScopeMin.y + (DepthHeight - 4)}; r32 PixelEnd = Bounds.Min.x + (Width * PercentEnd);
r32 MinY = Bounds.Max.y - ((Record->CallDepth + 1) * DepthHeight);
if ((ScopeMax.x - ScopeMin.x) >= 1) rect ScopeBounds = {
v2{ PixelStart, MinY },
v2{ PixelEnd, MinY + (DepthHeight - 4) }
};
if (gs_Width(ScopeBounds) >= 1)
{ {
v4 Color = ThreadColors[0]; v4 Color = ThreadColors[0];
if (PointIsInRange(Mouse.Pos, ScopeMin, ScopeMax)) if (gs_PointIsInRect(Interface->Mouse.Pos, ScopeBounds))
{ {
Color = GreenV4; Color = GreenV4;
HotRecord = Record;
HotRecordName = Name;
} }
PushRenderQuad2D(RenderBuffer, ScopeMin, ScopeMax, Color); ui_FillRect(Interface, ScopeBounds, Color);
PushRenderBoundingBox2D(RenderBuffer, ScopeMin, ScopeMax, 1, BlackV4); ui_OutlineRect(Interface, ScopeBounds, 1, BlackV4);
}
}
if (PointIsInRange(Mouse.Pos, ScopeMin, ScopeMax)) if (HotRecord != 0)
{ {
PushRenderQuad2D(RenderBuffer, Mouse.Pos, Mouse.Pos + v2{256, 32}, BlackV4); PrintF(&String, "%S : %d - %d", HotRecordName->Name, HotRecord->StartCycles, HotRecord->EndCycles);
PrintF(&String, "%.*s : %d - %d", Name->Name.Length, Name->Name.Memory, Record->StartCycles, Record->EndCycles); ui_TextBox(Interface, gs_MakeRectMinWidth(Interface->Mouse.Pos, v2{256, 32}), String, BlackV4, WhiteV4);
DrawString(RenderBuffer, String, Interface.Font, Mouse.Pos, WhiteV4);
}
}
} }
} }
internal void internal void
RenderProfiler_ListVisualization(render_command_buffer* RenderBuffer, RenderProfiler_ListVisualization(ui_interface* Interface, ui_layout Layout, debug_frame* VisibleFrame, memory_arena* Memory)
interface_config Interface, mouse_state Mouse,
v2 Min, v2 Max,
debug_frame* VisibleFrame, memory_arena* Memory)
{ {
MakeStringBuffer(String, 256); MakeStringBuffer(String, 256);
r32 YAt = Max.y - Interface.Font->PixelHeight; r32 ColumnWidths[] = {256, 128, 128, 128, 128};
r32 Column0X = Min.x; ui_StartRow(&Layout, 5, &ColumnWidths[0]);
r32 Column1X = Column0X + 256; {
r32 Column2X = Column1X + 128; ui_LayoutDrawString(Interface, &Layout, MakeStringLiteral("Procedure"), Interface->Style.TextColor);
r32 Column3X = Column2X + 128; ui_LayoutDrawString(Interface, &Layout, MakeStringLiteral("% Frame"), Interface->Style.TextColor);
r32 Column4X = Column3X + 100; ui_LayoutDrawString(Interface, &Layout, MakeStringLiteral("Seconds"), Interface->Style.TextColor);
ui_LayoutDrawString(Interface, &Layout, MakeStringLiteral("Cycles"), Interface->Style.TextColor);
ui_LayoutDrawString(Interface, &Layout, MakeStringLiteral("Calls"), Interface->Style.TextColor);
}
ui_EndRow(&Layout);
for (s32 n = 0; n < VisibleFrame->ScopeNamesMax; n++) for (s32 n = 0; n < VisibleFrame->ScopeNamesMax; n++)
{ {
@ -101,24 +108,24 @@ RenderProfiler_ListVisualization(render_command_buffer* RenderBuffer,
{ {
collated_scope_record* CollatedRecord = VisibleFrame->CollatedScopes + n; collated_scope_record* CollatedRecord = VisibleFrame->CollatedScopes + n;
PrintF(&String, "%.*s", NameEntry.Name.Length, NameEntry.Name.Memory); ui_StartRow(&Layout, 5, &ColumnWidths[0]);
DrawString(RenderBuffer, String, Interface.Font, v2{Column0X, YAt}, WhiteV4); {
PrintF(&String, "%S", NameEntry.Name);
ui_LayoutDrawString(Interface, &Layout, String, Interface->Style.TextColor);
PrintF(&String, "%f", CollatedRecord->PercentFrameTime); PrintF(&String, "%f%%", CollatedRecord->PercentFrameTime);
DrawString(RenderBuffer, String, Interface.Font, v2{Column1X, YAt}, WhiteV4); ui_LayoutDrawString(Interface, &Layout, String, Interface->Style.TextColor);
PrintF(&String, "%fs", CollatedRecord->TotalSeconds); PrintF(&String, "%fs", CollatedRecord->TotalSeconds);
DrawString(RenderBuffer, String, Interface.Font, v2{Column2X, YAt}, WhiteV4); ui_LayoutDrawString(Interface, &Layout, String, Interface->Style.TextColor);
PrintF(&String, "%dcy", CollatedRecord->TotalCycles); PrintF(&String, "%dcy", CollatedRecord->TotalCycles);
DrawString(RenderBuffer, String, Interface.Font, v2{Column3X, YAt}, WhiteV4); ui_LayoutDrawString(Interface, &Layout, String, Interface->Style.TextColor);
PrintF(&String, "%d calls", CollatedRecord->CallCount); PrintF(&String, "%d", CollatedRecord->CallCount);
DrawString(RenderBuffer, String, Interface.Font, v2{Column4X, YAt}, WhiteV4); ui_LayoutDrawString(Interface, &Layout, String, Interface->Style.TextColor);
}
YAt -= Interface.Font->PixelHeight + 4; ui_EndRow(&Layout);
if (YAt < Min.y) { break; }
} }
} }
} }
@ -134,23 +141,18 @@ ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* Render
v4 FrameColors[] = { GreenV4, YellowV4, RedV4, WhiteV4 }; v4 FrameColors[] = { GreenV4, YellowV4, RedV4, WhiteV4 };
r32 FrameListHeight = 64; r32 FrameListHeight = 64;
v2 FrameListMin = v2{PanelBounds.Min.x + 16, PanelBounds.Max.y - (16 + FrameListHeight)}; rect FrameListBounds, ProcListBounds;
v2 FrameListMax = v2{PanelBounds.Max.x - 16, PanelBounds.Max.y - 16}; gs_HSplitRectAtDistanceFromTop(PanelBounds, FrameListHeight, &FrameListBounds, &ProcListBounds);
rect FrameListInner = gs_InsetRect(FrameListBounds, 4);
r32 FrameListPadding = 4; r32 SingleFrameStep = gs_Width(FrameListInner) / DEBUG_FRAME_COUNT;
r32 FrameListInnerWidth = (FrameListMax.x - FrameListMin.x) - (FrameListPadding * 2);
r32 SingleFrameStep = FrameListInnerWidth / DEBUG_FRAME_COUNT;
r32 SingleFrameWidth = (r32)((s32)SingleFrameStep - 2); r32 SingleFrameWidth = (r32)((s32)SingleFrameStep - 2);
PushRenderBoundingBox2D(RenderBuffer, FrameListMin, FrameListMax, 2, WhiteV4); ui_OutlineRect(&State->Interface_, FrameListBounds, 2, WhiteV4);
if (gs_PointIsInRect(Mouse.Pos, FrameListBounds) && MouseButtonHeldDown(Mouse.LeftButtonState))
if (PointIsInRange(Mouse.Pos, FrameListMin, FrameListMax) &&
MouseButtonHeldDown(Mouse.LeftButtonState))
{ {
r32 LocalMouseX = (Mouse.Pos.x - FrameListMin.x) + FrameListPadding; v2 LocalMouse = gs_TransformPointIntoRectSpace(Mouse.Pos, FrameListBounds);
s32 ClosestFrameIndex = (LocalMouseX / SingleFrameStep); s32 ClosestFrameIndex = (LocalMouse.x / SingleFrameStep);
if (ClosestFrameIndex >= 0 && ClosestFrameIndex < DEBUG_FRAME_COUNT) if (ClosestFrameIndex >= 0 && ClosestFrameIndex < DEBUG_FRAME_COUNT)
{ {
GlobalDebugServices->RecordFrames = false; GlobalDebugServices->RecordFrames = false;
@ -158,60 +160,61 @@ ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* Render
} }
} }
rect FrameBounds = gs_MakeRectMinWidth(FrameListInner.Min, v2{SingleFrameWidth, gs_Height(FrameListInner)});
for (s32 F = 0; F < DEBUG_FRAME_COUNT; F++) for (s32 F = 0; F < DEBUG_FRAME_COUNT; F++)
{ {
v2 Min = v2{FrameListMin.x + FrameListPadding + (F * SingleFrameStep), FrameListMin.y + 4}; rect PositionedFrameBounds = gs_TranslateRectX(FrameBounds, F * SingleFrameStep);
v2 Max = v2{Min.x + SingleFrameWidth, FrameListMax.y - 4};
s32 FramesAgo = (GlobalDebugServices->CurrentDebugFrame - F); s32 FramesAgo = (GlobalDebugServices->CurrentDebugFrame - F);
if (FramesAgo < 0) { FramesAgo += DEBUG_FRAME_COUNT; } if (FramesAgo < 0) { FramesAgo += DEBUG_FRAME_COUNT; }
v4 Color = FrameColors[GSClamp(0, FramesAgo, 3)]; v4 Color = FrameColors[GSClamp(0, FramesAgo, 3)];
PushRenderQuad2D(RenderBuffer, Min, Max, Color); ui_FillRect(&State->Interface_, PositionedFrameBounds, Color);
} }
debug_frame* VisibleFrame = GetLastDebugFrame(GlobalDebugServices); debug_frame* VisibleFrame = GetLastDebugFrame(GlobalDebugServices);
ui_layout Layout = ui_CreateLayout(State->Interface_, ProcListBounds);
ui_StartRow(&Layout, 4);
{
s64 FrameStartCycles = VisibleFrame->FrameStartCycles; s64 FrameStartCycles = VisibleFrame->FrameStartCycles;
s64 FrameTotalCycles = VisibleFrame->FrameEndCycles - VisibleFrame->FrameStartCycles; s64 FrameTotalCycles = VisibleFrame->FrameEndCycles - VisibleFrame->FrameStartCycles;
u32 CurrentDebugFrame = GlobalDebugServices->CurrentDebugFrame - 1;
PrintF(&String, "Frame %d", CurrentDebugFrame);
ui_LayoutDrawString(&State->Interface_, &Layout, String, WhiteV4);
PrintF(&String, "Frame %d - Total Cycles: %lld", PrintF(&String, "Total Cycles: %lld", FrameTotalCycles);
GlobalDebugServices->CurrentDebugFrame - 1, ui_LayoutDrawString(&State->Interface_, &Layout, String, WhiteV4);
FrameTotalCycles);
DrawString(RenderBuffer, String, State->Interface.Font, FrameListMin - v2{0, 32}, WhiteV4);
rect ResumeRecordingBtnBounds = MakeRectMinWidth(v2{ FrameListMax.x - 128, FrameListMin.y - 32 }, v2{ 128, 28 }); // NOTE(NAME): Skipping a space for aesthetic reasons, not functional, and could
if (ui_Button(&State->Interface_, MakeString("Resume Recording"), ResumeRecordingBtnBounds)) // be removed, or used for something else
ui_ReserveElementBounds(&Layout);
if (ui_LayoutButton(&State->Interface_, &Layout, MakeString("Resume Recording")))
{ {
GlobalDebugServices->RecordFrames = true; GlobalDebugServices->RecordFrames = true;
} }
}
ui_EndRow(&Layout);
rect ScopeViewBtnBounds = { ui_StartRow(&Layout, 8);
v2{ FrameListMin.x, FrameListMin.y - 60 }, {
v2{ FrameListMin.x + 128, FrameListMin.y - 42 } if (ui_LayoutButton(&State->Interface_, &Layout, MakeString("Scope View")))
};
if (ui_Button(&State->Interface_, MakeString("Scope View"), ScopeViewBtnBounds))
{ {
GlobalDebugServices->Interface.FrameView = FRAME_VIEW_PROFILER; GlobalDebugServices->Interface.FrameView = FRAME_VIEW_PROFILER;
} }
if (ui_LayoutButton(&State->Interface_, &Layout, MakeString("List View")))
rect ListViewBtnBounds = TranslateRectX(ScopeViewBtnBounds, 152);
if (ui_Button(&State->Interface_, MakeString("List View"), ListViewBtnBounds))
{ {
GlobalDebugServices->Interface.FrameView = FRAME_VIEW_SCOPE_LIST; GlobalDebugServices->Interface.FrameView = FRAME_VIEW_SCOPE_LIST;
} }
}
ui_EndRow(&Layout);
rect ViewModeBounds = {
v2{ FrameListMin.x, PanelBounds.Min.y },
v2{ FrameListMax.x, FrameListMin.y - 96 }
};
if (GlobalDebugServices->Interface.FrameView == FRAME_VIEW_PROFILER) if (GlobalDebugServices->Interface.FrameView == FRAME_VIEW_PROFILER)
{ {
RenderProfiler_ScopeVisualization(RenderBuffer, State->Interface, Mouse, RectExpand(ViewModeBounds), RenderProfiler_ScopeVisualization(&State->Interface_, Layout, VisibleFrame, Memory);
VisibleFrame, Memory);
} }
else else
{ {
RenderProfiler_ListVisualization(RenderBuffer, State->Interface, Mouse, RectExpand(ViewModeBounds), RenderProfiler_ListVisualization(&State->Interface_, Layout, VisibleFrame, Memory);
VisibleFrame, Memory);
} }
} }

View File

@ -1,33 +1,22 @@
TODO FOLDHAUS TODO FOLDHAUS
STREAM #0: Metaprogramming
- Metaprogramming - Metaprogramming
- fix memory layout (remeber to profile before and after) - fix memory layout (remeber to profile before and after)
- Make everything truly platform agnostic
- Make the DLL truly platform agnostic - Application DLL
- math.h: present for trig functions (though this is part of the c-std lib, so it should be everywhere) - math.h: present for trig functions (though this is part of the c-std lib, so it should be everywhere)
- windows.h: only thing left is InterlockedIncrement and InterlockedAdd - windows.h: only thing left is InterlockedIncrement and InterlockedAdd
- Meta Layer
- ???
- Win32 Platform Layer STREAM #1: 3D Overhaul
- Enumerate Directory Contents (you started this in win32_foldhaus_fileio.h)
- Internal Log File
NOTE: This should not be a part of the debug system
- Save output log to a file continuously
- Have a window where we can view the log within the app
- Create a bar that displays the most recent error message
- :ErrorLogging
- Make sure it works without building in Debug Mode
- Buckets & Lists
- On second thought, I just really don't like these. Lets get rid of them, and put custom structures in place
- Rendering (Working on this elsewhere) - Rendering (Working on this elsewhere)
- OpenGL 3 - OpenGL 3
- Vertex Buffers - Vertex Buffers
- Clipping in shaders
- Layers - Layers
- Lighting - Lighting
- Clipping (with error checking)
- Camera - Camera
- pan - pan
@ -43,28 +32,22 @@ TODO FOLDHAUS
- led groups & subgroups - defined in file - led groups & subgroups - defined in file
- motion - motion
- Network
- Handle Error Cases
- Handle connecting a sculpture after launch
- Artnet
- Universe offsets (per sculpture)
- Interface
- Layout functionality
- styling
- text input
- lister with icon options
- panel system: destroy panel by extending it beyond its max, not just its min
- Asset Loading
- Need to figure out which textures are currently in graphics memory and which need to be resubmitted
- images
- icon system - integrate with interface
- Sculpture View - Sculpture View
- mouse spatial interaction - handles, and hover for info - mouse spatial interaction - handles, and hover for info
- debug capabilities (toggle strip/led/universe colors) - debug capabilities (toggle strip/led/universe colors)
STREAM #2: Memory
- Buckets & Lists
- On second thought, I just really don't like these. Lets get rid of them, and put custom structures in place
- Internal Log File
NOTE: This should not be a part of the debug system
- Save output log to a file continuously
- Have a window where we can view the log within the app
- Create a bar that displays the most recent error message
- :ErrorLogging
STREAM #3: Nodes
- Animation System - Animation System
- blending between animation - blending between animation
- layers - layers
@ -91,11 +74,32 @@ TODO FOLDHAUS
- saving animation timelines - saving animation timelines
- saving projects - saving projects
- Settings STRAM #4: Completeness
- Win32 Platform Layer
- Enumerate Directory Contents (you started this in win32_foldhaus_fileio.h)
- Platform Layer - Platform Layer
- Mac Platform Layer - Mac Platform Layer
- Make sure it works without building in Debug Mode
- Network
- Handle Error Cases
- Handle connecting a sculpture after launch
- Artnet
- Universe offsets (per sculpture)
- Interface
- text input
- lister with icon options
- Asset Loading
- Need to figure out which textures are currently in graphics memory and which need to be resubmitted
- images
- icon system - integrate with interface
- Settings
Assembly -> SACN interface Assembly -> SACN interface
- need to create a data structure in CreateDMXBuffers that prevents duplication of DMXBuffers. - need to create a data structure in CreateDMXBuffers that prevents duplication of DMXBuffers.
- - thinking about a dictionary. Key is Universe, length is 256, create parallel arrays as necessary - - thinking about a dictionary. Key is Universe, length is 256, create parallel arrays as necessary