From e3d7a90a13f36d89205e53caa129b9f1897c0592 Mon Sep 17 00:00:00 2001 From: Peter Slattery Date: Mon, 22 Jun 2020 17:39:58 -0700 Subject: [PATCH] app_state.Interface_ -> app_state.Interface --- src/app/foldhaus_app.cpp | 36 +++++++++---------- src/app/foldhaus_app.h | 2 +- src/app/foldhaus_interface.cpp | 4 +-- .../foldhaus_panel_animation_timeline.h | 8 ++--- src/app/panels/foldhaus_panel_hierarchy.h | 15 ++++---- src/app/panels/foldhaus_panel_node_graph.h | 10 +++--- src/app/panels/foldhaus_panel_profiler.h | 20 +++++------ 7 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/app/foldhaus_app.cpp b/src/app/foldhaus_app.cpp index 1c429bb..99b0246 100644 --- a/src/app/foldhaus_app.cpp +++ b/src/app/foldhaus_app.cpp @@ -139,7 +139,7 @@ INITIALIZE_APPLICATION(InitializeApplication) AddCodepointToFont(Font, Codepoint, 0, 0, CodepointW, CodepointH, CodepointX, CodepointY); } - State->Interface_.Style.Font = Font; + State->Interface.Style.Font = Font; Font->BitmapTextureHandle = Context.PlatformGetGPUTextureHandle(Font->BitmapMemory, Font->BitmapWidth, Font->BitmapHeight); @@ -150,21 +150,21 @@ INITIALIZE_APPLICATION(InitializeApplication) } } - State->Interface_.Style.FontSize = FontSize; - State->Interface_.Style.PanelBGColors[0] = v4{.3f, .3f, .3f, 1}; - State->Interface_.Style.PanelBGColors[1] = v4{.4f, .4f, .4f, 1}; - State->Interface_.Style.PanelBGColors[2] = v4{.5f, .5f, .5f, 1}; - State->Interface_.Style.PanelBGColors[3] = v4{.6f, .6f, .6f, 1}; - State->Interface_.Style.ButtonColor_Inactive = BlackV4; - State->Interface_.Style.ButtonColor_Active = v4{.1f, .1f, .1f, 1}; - State->Interface_.Style.ButtonColor_Selected = v4{.1f, .1f, .3f, 1}; - State->Interface_.Style.TextColor = WhiteV4; - State->Interface_.Style.ListBGColors[0] = v4{ .16f, .16f, .16f, 1.f }; - State->Interface_.Style.ListBGColors[1] = v4{ .18f, .18f, .18f, 1.f }; - State->Interface_.Style.ListBGHover = v4{ .22f, .22f, .22f, 1.f }; - State->Interface_.Style.ListBGSelected = v4{.44f, .44f, .44f, 1.f }; - State->Interface_.Style.Margin = v2{5, 5}; - State->Interface_.Style.RowHeight = ui_GetTextLineHeight(State->Interface_); + State->Interface.Style.FontSize = FontSize; + State->Interface.Style.PanelBGColors[0] = v4{.3f, .3f, .3f, 1}; + State->Interface.Style.PanelBGColors[1] = v4{.4f, .4f, .4f, 1}; + State->Interface.Style.PanelBGColors[2] = v4{.5f, .5f, .5f, 1}; + State->Interface.Style.PanelBGColors[3] = v4{.6f, .6f, .6f, 1}; + State->Interface.Style.ButtonColor_Inactive = BlackV4; + State->Interface.Style.ButtonColor_Active = v4{.1f, .1f, .1f, 1}; + State->Interface.Style.ButtonColor_Selected = v4{.1f, .1f, .3f, 1}; + State->Interface.Style.TextColor = WhiteV4; + State->Interface.Style.ListBGColors[0] = v4{ .16f, .16f, .16f, 1.f }; + State->Interface.Style.ListBGColors[1] = v4{ .18f, .18f, .18f, 1.f }; + State->Interface.Style.ListBGHover = v4{ .22f, .22f, .22f, 1.f }; + State->Interface.Style.ListBGSelected = v4{.44f, .44f, .44f, 1.f }; + State->Interface.Style.Margin = v2{5, 5}; + State->Interface.Style.RowHeight = ui_GetTextLineHeight(State->Interface); State->SACN = InitializeSACN(Context); State->NetworkProtocolHeaderSize = STREAM_HEADER_SIZE; @@ -504,8 +504,8 @@ UPDATE_AND_RENDER(UpdateAndRender) PushRenderClearScreen(RenderBuffer); State->WindowBounds = Context->WindowBounds; - State->Interface_.RenderBuffer = RenderBuffer; - State->Interface_.Mouse = Context->Mouse; + State->Interface.RenderBuffer = RenderBuffer; + State->Interface.Mouse = Context->Mouse; panel_layout PanelsToRender = GetPanelLayout(&State->PanelSystem, State->WindowBounds, &State->Transient); DrawAllPanels(PanelsToRender, RenderBuffer, &Context->Mouse, State, *Context); diff --git a/src/app/foldhaus_app.h b/src/app/foldhaus_app.h index c0fbc66..4241d77 100644 --- a/src/app/foldhaus_app.h +++ b/src/app/foldhaus_app.h @@ -71,7 +71,7 @@ struct app_state input_command_queue CommandQueue; text_entry ActiveTextEntry; - ui_interface Interface_; + ui_interface Interface; animation_system AnimationSystem; gs_list_handle SelectedAnimationBlockHandle; diff --git a/src/app/foldhaus_interface.cpp b/src/app/foldhaus_interface.cpp index b69ca36..b8c762e 100644 --- a/src/app/foldhaus_interface.cpp +++ b/src/app/foldhaus_interface.cpp @@ -422,7 +422,7 @@ DrawPanelFooter(panel* Panel, render_command_buffer* RenderBuffer, rect FooterBo { panel_definition Def = GlobalPanelDefs[i]; string DefName = MakeString(Def.PanelName, Def.PanelNameLength); - if (ui_Button(&State->Interface_, DefName, ButtonBounds)) + if (ui_Button(&State->Interface, DefName, ButtonBounds)) { SetPanelDefinition(Panel, i, State); Panel->PanelSelectionMenuOpen = false; @@ -432,7 +432,7 @@ DrawPanelFooter(panel* Panel, render_command_buffer* RenderBuffer, rect FooterBo } } - if (ui_Button(&State->Interface_, MakeStringLiteral("Select"), PanelSelectBtnBounds)) + if (ui_Button(&State->Interface, MakeStringLiteral("Select"), PanelSelectBtnBounds)) { Panel->PanelSelectionMenuOpen = !Panel->PanelSelectionMenuOpen; } diff --git a/src/app/panels/foldhaus_panel_animation_timeline.h b/src/app/panels/foldhaus_panel_animation_timeline.h index ff1999f..1f243fa 100644 --- a/src/app/panels/foldhaus_panel_animation_timeline.h +++ b/src/app/panels/foldhaus_panel_animation_timeline.h @@ -317,7 +317,7 @@ DrawFrameBar (animation_system* AnimationSystem, render_command_buffer* RenderBu r32 FramePercent = FrameToPercentRange(Frame, VisibleFrames); r32 FrameX = GSLerp(BarBounds.Min.x, BarBounds.Max.x, FramePercent); v2 FrameTextPos = v2{FrameX, BarBounds.Min.y + 2}; - DrawString(RenderBuffer, TempString, State->Interface_.Style.Font, FrameTextPos, WhiteV4); + DrawString(RenderBuffer, TempString, State->Interface.Style.Font, FrameTextPos, WhiteV4); } // Time Slider @@ -335,7 +335,7 @@ DrawFrameBar (animation_system* AnimationSystem, render_command_buffer* RenderBu PushRenderQuad2D(RenderBuffer, HeadMin, HeadMax, TimeSliderColor); PrintF(&TempString, "%d", AnimationSystem->CurrentFrame); - DrawString(RenderBuffer, TempString, State->Interface_.Style.Font, HeadMin + v2{6, 4}, WhiteV4); + DrawString(RenderBuffer, TempString, State->Interface.Style.Font, HeadMin + v2{6, 4}, WhiteV4); } } @@ -418,7 +418,7 @@ DrawLayerMenu(animation_system* AnimationSystem, rect PanelDim, render_command_b { PushRenderBoundingBox2D(RenderBuffer, gs_RectExpand(LayerBounds), 1, WhiteV4); } - DrawString(RenderBuffer, Layer->Name, State->Interface_.Style.Font, LayerTextPos, WhiteV4); + DrawString(RenderBuffer, Layer->Name, State->Interface.Style.Font, LayerTextPos, WhiteV4); } } @@ -577,7 +577,7 @@ AnimationTimeline_Render(panel Panel, rect PanelBounds, render_command_buffer* R animation_timeline_state* TimelineState = (animation_timeline_state*)Panel.PanelStateMemory; gs_list_handle SelectedBlockHandle = State->SelectedAnimationBlockHandle; - ui_interface* Interface = &State->Interface_; + ui_interface* Interface = &State->Interface; animation_system* AnimationSystem = &State->AnimationSystem; rect TitleBarBounds, PanelContentsBounds; diff --git a/src/app/panels/foldhaus_panel_hierarchy.h b/src/app/panels/foldhaus_panel_hierarchy.h index 4808cdb..7b56c47 100644 --- a/src/app/panels/foldhaus_panel_hierarchy.h +++ b/src/app/panels/foldhaus_panel_hierarchy.h @@ -29,7 +29,7 @@ GSMetaTag(panel_type_hierarchy); internal void HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuffer, app_state* State, context Context, mouse_state Mouse) { - ui_layout Layout = ui_CreateLayout(State->Interface_, PanelBounds); + ui_layout Layout = ui_CreateLayout(State->Interface, PanelBounds); string TempString = PushString(&State->Transient, 256); u32 LineCount = (u32)(gs_Height(PanelBounds) / Layout.RowHeight) + 1; u32 AssembliesToDraw = GSMin(LineCount, State->Assemblies.Count); @@ -39,8 +39,8 @@ HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* Rende for (u32 Line = 0; Line < LineCount; Line++) { LineBounds[Line] = ui_ReserveElementBounds(&Layout); - v4 ListItemBGColor = ui_GetListItemBGColor(State->Interface_.Style, Line); - ui_FillRect(&State->Interface_, LineBounds[Line], ListItemBGColor); + v4 ListItemBGColor = ui_GetListItemBGColor(State->Interface.Style, Line); + ui_FillRect(&State->Interface, LineBounds[Line], ListItemBGColor); } for (u32 AssemblyIndex = 0; AssemblyIndex < AssembliesToDraw; AssemblyIndex++) @@ -48,11 +48,11 @@ HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* Rende assembly Assembly = State->Assemblies.Values[AssemblyIndex]; PrintF(&TempString, "%S", Assembly.Name); - ui_layout ItemLayout = ui_CreateLayout(State->Interface_, LineBounds[AssemblyIndex]); + ui_layout ItemLayout = ui_CreateLayout(State->Interface, LineBounds[AssemblyIndex]); ui_StartRow(&ItemLayout, 2); { - ui_LayoutDrawString(&State->Interface_, &ItemLayout, TempString, State->Interface_.Style.TextColor); - if (ui_LayoutListButton(&State->Interface_, &ItemLayout, MakeStringLiteral("X"), AssemblyIndex)) + ui_LayoutDrawString(&State->Interface, &ItemLayout, TempString, State->Interface.Style.TextColor); + if (ui_LayoutListButton(&State->Interface, &ItemLayout, MakeStringLiteral("X"), AssemblyIndex)) { UnloadAssembly(AssemblyIndex, State, Context); } @@ -62,8 +62,9 @@ HierarchyView_Render(panel Panel, rect PanelBounds, render_command_buffer* Rende if (AssembliesToDraw < LineCount) { + // NOTE(Peter): Add assembly button PrintF(&TempString, "+ Add Assembly"); - if (ui_ListButton(&State->Interface_, TempString, LineBounds[AssembliesToDraw], AssembliesToDraw)) + if (ui_ListButton(&State->Interface, TempString, LineBounds[AssembliesToDraw], AssembliesToDraw)) { string FilePath = PushString(&State->Transient, 256); b32 Success = GetFilePath(Context, &FilePath, "Foldhaus Files\0*.fold\0\0"); diff --git a/src/app/panels/foldhaus_panel_node_graph.h b/src/app/panels/foldhaus_panel_node_graph.h index 332257c..3bc27c4 100644 --- a/src/app/panels/foldhaus_panel_node_graph.h +++ b/src/app/panels/foldhaus_panel_node_graph.h @@ -436,7 +436,7 @@ NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuf r32 NodeWidth = 150; r32 LayerDistance = 100; - r32 LineHeight = ui_GetTextLineHeight(State->Interface_); + r32 LineHeight = ui_GetTextLineHeight(State->Interface); if (GraphState->LayoutIsDirty) { @@ -477,7 +477,7 @@ NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuf { visual_node VisualNode = GraphState->Layout.VisualNodes[i]; gs_list_handle NodeHandle = State->NodeWorkspace.SortedNodeHandles[i]; - DrawNode(VisualNode.Position + GraphState->ViewOffset, VisualNode.Spec, NodeHandle, NodeWidth, LineHeight, State->Interface_.Style, RenderBuffer, Mouse, &State->Transient); + DrawNode(VisualNode.Position + GraphState->ViewOffset, VisualNode.Spec, NodeHandle, NodeWidth, LineHeight, State->Interface.Style, RenderBuffer, Mouse, &State->Transient); } for (u32 p = 0; p < GraphState->Layout.VisualPortsCount; p++) @@ -514,17 +514,17 @@ NodeGraph_Render(panel Panel, rect PanelBounds, render_command_buffer* RenderBuf List.ListBounds = NodeSelectionWindowBounds; List.ListElementDimensions = v2{ gs_Width(NodeSelectionWindowBounds), - ui_GetTextLineHeight(State->Interface_) + ui_GetTextLineHeight(State->Interface) }; List.ElementLabelIndent = v2{10, 4}; string TitleString = MakeStringLiteral("Available Nodes"); - DrawListElement(TitleString, &List, Mouse, RenderBuffer, State->Interface_.Style); + DrawListElement(TitleString, &List, Mouse, RenderBuffer, State->Interface.Style); for (u32 i = 0; i < NodeType_Count; i++) { node_specification_ Spec = NodeSpecifications[i]; - rect ElementBounds = DrawListElement(Spec.Identifier, &List, Mouse, RenderBuffer, State->Interface_.Style); + rect ElementBounds = DrawListElement(Spec.Identifier, &List, Mouse, RenderBuffer, State->Interface.Style); if (MouseButtonTransitionedDown(Mouse.LeftButtonState) && gs_PointIsInRect(Mouse.DownPos, ElementBounds)) diff --git a/src/app/panels/foldhaus_panel_profiler.h b/src/app/panels/foldhaus_panel_profiler.h index d4e25aa..a6eadfd 100644 --- a/src/app/panels/foldhaus_panel_profiler.h +++ b/src/app/panels/foldhaus_panel_profiler.h @@ -148,7 +148,7 @@ ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* Render r32 SingleFrameStep = gs_Width(FrameListInner) / DEBUG_FRAME_COUNT; r32 SingleFrameWidth = (r32)((s32)SingleFrameStep - 2); - ui_OutlineRect(&State->Interface_, FrameListBounds, 2, WhiteV4); + ui_OutlineRect(&State->Interface, FrameListBounds, 2, WhiteV4); if (gs_PointIsInRect(Mouse.Pos, FrameListBounds) && MouseButtonHeldDown(Mouse.LeftButtonState)) { v2 LocalMouse = gs_TransformPointIntoRectSpace(Mouse.Pos, FrameListBounds); @@ -167,28 +167,28 @@ ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* Render s32 FramesAgo = (GlobalDebugServices->CurrentDebugFrame - F); if (FramesAgo < 0) { FramesAgo += DEBUG_FRAME_COUNT; } v4 Color = FrameColors[GSClamp(0, FramesAgo, 3)]; - ui_FillRect(&State->Interface_, PositionedFrameBounds, Color); + ui_FillRect(&State->Interface, PositionedFrameBounds, Color); } debug_frame* VisibleFrame = GetLastDebugFrame(GlobalDebugServices); - ui_layout Layout = ui_CreateLayout(State->Interface_, ProcListBounds); + ui_layout Layout = ui_CreateLayout(State->Interface, ProcListBounds); ui_StartRow(&Layout, 4); { s64 FrameStartCycles = 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); + ui_LayoutDrawString(&State->Interface, &Layout, String, WhiteV4); PrintF(&String, "Total Cycles: %lld", FrameTotalCycles); - ui_LayoutDrawString(&State->Interface_, &Layout, String, WhiteV4); + ui_LayoutDrawString(&State->Interface, &Layout, String, WhiteV4); // NOTE(NAME): Skipping a space for aesthetic reasons, not functional, and could // be removed, or used for something else ui_ReserveElementBounds(&Layout); - if (ui_LayoutButton(&State->Interface_, &Layout, MakeString("Resume Recording"))) + if (ui_LayoutButton(&State->Interface, &Layout, MakeString("Resume Recording"))) { GlobalDebugServices->RecordFrames = true; } @@ -197,11 +197,11 @@ ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* Render ui_StartRow(&Layout, 8); { - if (ui_LayoutButton(&State->Interface_, &Layout, MakeString("Scope View"))) + if (ui_LayoutButton(&State->Interface, &Layout, MakeString("Scope View"))) { GlobalDebugServices->Interface.FrameView = FRAME_VIEW_PROFILER; } - if (ui_LayoutButton(&State->Interface_, &Layout, MakeString("List View"))) + if (ui_LayoutButton(&State->Interface, &Layout, MakeString("List View"))) { GlobalDebugServices->Interface.FrameView = FRAME_VIEW_SCOPE_LIST; } @@ -210,11 +210,11 @@ ProfilerView_Render(panel Panel, rect PanelBounds, render_command_buffer* Render if (GlobalDebugServices->Interface.FrameView == FRAME_VIEW_PROFILER) { - RenderProfiler_ScopeVisualization(&State->Interface_, Layout, VisibleFrame, Memory); + RenderProfiler_ScopeVisualization(&State->Interface, Layout, VisibleFrame, Memory); } else { - RenderProfiler_ListVisualization(&State->Interface_, Layout, VisibleFrame, Memory); + RenderProfiler_ListVisualization(&State->Interface, Layout, VisibleFrame, Memory); } }