Added a mouse hover layout and used it in the profiler

This commit is contained in:
PS 2020-11-15 17:07:59 -08:00
parent 8d737fd961
commit 6e24051982
2 changed files with 22 additions and 16 deletions

View File

@ -25,7 +25,7 @@ ProfilerView_Cleanup(panel* Panel, app_state* State)
} }
internal void internal void
RenderProfiler_ScopeVisualization(ui_interface* Interface, ui_widget* Layout, debug_frame* VisibleFrame, gs_memory_arena* Memory) RenderProfiler_ScopeVisualization(ui_interface* Interface, ui_widget* Layout, debug_frame* VisibleFrame, gs_memory_arena* Transient)
{ {
v4 ThreadColors[] = { v4 ThreadColors[] = {
v4{.73f, .33f, .83f, 1}, v4{.73f, .33f, .83f, 1},
@ -45,11 +45,7 @@ RenderProfiler_ScopeVisualization(ui_interface* Interface, ui_widget* Layout, de
debug_scope_record_list* ThreadScopeCalls = GetScopeListForThreadInFrame(GlobalDebugServices, debug_scope_record_list* ThreadScopeCalls = GetScopeListForThreadInFrame(GlobalDebugServices,
VisibleFrame); VisibleFrame);
scope_record* HotRecord = 0; gs_string String = PushString(Transient, 256);
scope_name* HotRecordName = 0;
char Backbuffer[256];
gs_string String = MakeString(Backbuffer, 0, 256);
for (s32 i = 0; i < ThreadScopeCalls->Count; i++) for (s32 i = 0; i < ThreadScopeCalls->Count; i++)
{ {
scope_record* Record = ThreadScopeCalls->Calls + i; scope_record* Record = ThreadScopeCalls->Calls + i;
@ -70,22 +66,19 @@ RenderProfiler_ScopeVisualization(ui_interface* Interface, ui_widget* Layout, de
if (PointIsInRect(ScopeBounds, Interface->Mouse.Pos)) if (PointIsInRect(ScopeBounds, Interface->Mouse.Pos))
{ {
Color = GreenV4; Color = GreenV4;
HotRecord = Record;
HotRecordName = Name; ui_BeginMousePopup(Interface, rect2{ 25, 25, 300, 57 }, LayoutDirection_TopDown, MakeString("Hover"));
{
PrintF(&String, "%S : %d - %d", Name->Name, Record->StartCycles, Record->EndCycles);
ui_Label(Interface, String);
}
ui_EndMousePopup(Interface);
} }
ui_FillRect(Interface, ScopeBounds, Color); ui_FillRect(Interface, ScopeBounds, Color);
ui_OutlineRect(Interface, ScopeBounds, 1, BlackV4); ui_OutlineRect(Interface, ScopeBounds, 1, BlackV4);
} }
} }
if (HotRecord != 0)
{
PrintF(&String, "%S : %d - %d", HotRecordName->Name, HotRecord->StartCycles, HotRecord->EndCycles);
rect2 TextBounds = MakeRect2MinDim(Interface->Mouse.Pos, v2{256, 32});
ui_Label(Interface, String, TextBounds);
}
} }
internal void internal void

View File

@ -1244,6 +1244,19 @@ ui_EndList(ui_interface* Interface)
ui_EndRow(Interface); ui_EndRow(Interface);
} }
internal void
ui_BeginMousePopup(ui_interface* Interface, rect2 Bounds, ui_layout_direction FillDir, gs_string Text)
{
rect2 FollowMouseBounds = Rect2Translate(Bounds, Interface->Mouse.Pos);
ui_widget* Layout = ui_PushOverlayLayout(Interface, FollowMouseBounds, FillDir, Text);
ui_WidgetSetFlag(Layout, UIWidgetFlag_DrawBackground);
}
internal void
ui_EndMousePopup(ui_interface* Interface)
{
ui_PopLayout(Interface);
}
#define INTERFACE_H #define INTERFACE_H
#endif // INTERFACE_H #endif // INTERFACE_H