mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-06 07:38:46 +00:00
CogEngine: Improve plot window UI
Make docking of plots optional
This commit is contained in:
@@ -47,28 +47,44 @@ void FCogEngineWindow_Plots::RenderContent()
|
|||||||
{
|
{
|
||||||
Super::RenderContent();
|
Super::RenderContent();
|
||||||
|
|
||||||
|
TArray<FCogDebugPlotEntry*> VisiblePlots;
|
||||||
|
for (FCogDebugPlotEntry& Plot : FCogDebugPlot::Plots)
|
||||||
|
{
|
||||||
|
if (Plot.CurrentYAxis != ImAxis_COUNT && Plot.CurrentRow != INDEX_NONE)
|
||||||
|
{
|
||||||
|
VisiblePlots.Add(&Plot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RenderMenu();
|
RenderMenu();
|
||||||
|
|
||||||
if (ImGui::BeginTable("PlotTable", 2, ImGuiTableFlags_RowBg
|
if (Config->DockPlotList)
|
||||||
| ImGuiTableFlags_Resizable
|
|
||||||
| ImGuiTableFlags_BordersV
|
|
||||||
| ImGuiTableFlags_NoPadInnerX
|
|
||||||
| ImGuiTableFlags_NoPadOuterX))
|
|
||||||
{
|
{
|
||||||
|
if (ImGui::BeginTable("PlotTable", 2, ImGuiTableFlags_RowBg
|
||||||
|
| ImGuiTableFlags_Resizable
|
||||||
|
| ImGuiTableFlags_BordersV
|
||||||
|
| ImGuiTableFlags_NoPadInnerX
|
||||||
|
| ImGuiTableFlags_NoPadOuterX))
|
||||||
|
{
|
||||||
|
|
||||||
ImGui::TableSetupColumn("PlotsList", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 20.0f);
|
ImGui::TableSetupColumn("PlotsList", ImGuiTableColumnFlags_WidthFixed, FCogWindowWidgets::GetFontWidth() * 20.0f);
|
||||||
ImGui::TableSetupColumn("Plots", ImGuiTableColumnFlags_WidthStretch, 0.0f);
|
ImGui::TableSetupColumn("Plots", ImGuiTableColumnFlags_WidthStretch, 0.0f);
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
TArray<FCogDebugPlotEntry*> VisiblePlots;
|
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
RenderPlotsList(VisiblePlots);
|
RenderPlotsList(ImVec2(0, -1));
|
||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
RenderPlots(VisiblePlots);
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
RenderPlots(VisiblePlots);
|
RenderPlots(VisiblePlots);
|
||||||
|
|
||||||
ImGui::EndTable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bApplyTimeScale = false;
|
bApplyTimeScale = false;
|
||||||
@@ -79,6 +95,15 @@ void FCogEngineWindow_Plots::RenderMenu()
|
|||||||
{
|
{
|
||||||
if (ImGui::BeginMenuBar())
|
if (ImGui::BeginMenuBar())
|
||||||
{
|
{
|
||||||
|
if (Config->DockPlotList == false)
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenu("Plots"))
|
||||||
|
{
|
||||||
|
RenderPlotsList(ImVec2(ImGui::GetFontSize() * 15, ImGui::GetFontSize() * 20));
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::BeginMenu("Options"))
|
if (ImGui::BeginMenu("Options"))
|
||||||
{
|
{
|
||||||
if (ImGui::MenuItem("Clear data"))
|
if (ImGui::MenuItem("Clear data"))
|
||||||
@@ -119,6 +144,9 @@ void FCogEngineWindow_Plots::RenderMenu()
|
|||||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||||
ImGui::Checkbox("Show value at cursor", &Config->ShowValueAtCursor);
|
ImGui::Checkbox("Show value at cursor", &Config->ShowValueAtCursor);
|
||||||
|
|
||||||
|
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||||
|
ImGui::Checkbox("Dock plots", &Config->DockPlotList);
|
||||||
|
|
||||||
constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf;
|
constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||||
FCogImguiHelper::ColorEdit4("Pause background color", Config->PauseBackgroundColor, ColorEditFlags);
|
FCogImguiHelper::ColorEdit4("Pause background color", Config->PauseBackgroundColor, ColorEditFlags);
|
||||||
ImGui::SetItemTooltip("Background color of the plot when paused.");
|
ImGui::SetItemTooltip("Background color of the plot when paused.");
|
||||||
@@ -133,9 +161,9 @@ void FCogEngineWindow_Plots::RenderMenu()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
void FCogEngineWindow_Plots::RenderPlotsList(TArray<FCogDebugPlotEntry*>& VisiblePlots)
|
void FCogEngineWindow_Plots::RenderPlotsList(const ImVec2& InSize)
|
||||||
{
|
{
|
||||||
if (ImGui::BeginChild("Plots", ImVec2(0, -1)))
|
if (ImGui::BeginChild("Plots", InSize))
|
||||||
{
|
{
|
||||||
int Index = 0;
|
int Index = 0;
|
||||||
|
|
||||||
@@ -143,11 +171,6 @@ void FCogEngineWindow_Plots::RenderPlotsList(TArray<FCogDebugPlotEntry*>& Visibl
|
|||||||
|
|
||||||
for (FCogDebugPlotEntry& Plot : FCogDebugPlot::Plots)
|
for (FCogDebugPlotEntry& Plot : FCogDebugPlot::Plots)
|
||||||
{
|
{
|
||||||
if (Plot.CurrentYAxis != ImAxis_COUNT && Plot.CurrentRow != INDEX_NONE)
|
|
||||||
{
|
|
||||||
VisiblePlots.Add(&Plot);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::PushID(Index);
|
ImGui::PushID(Index);
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, Plot.IsEventPlot ? IM_COL32(128, 128, 255, 255) : IM_COL32(255, 255, 255, 255));
|
ImGui::PushStyleColor(ImGuiCol_Text, Plot.IsEventPlot ? IM_COL32(128, 128, 255, 255) : IM_COL32(255, 255, 255, 255));
|
||||||
@@ -451,17 +474,19 @@ void FCogEngineWindow_Plots::RenderValues(FCogDebugPlotEntry& Entry, const char*
|
|||||||
float Value;
|
float Value;
|
||||||
if (Entry.FindValue(ImPlot::GetPlotMousePos().x, Value))
|
if (Entry.FindValue(ImPlot::GetPlotMousePos().x, Value))
|
||||||
{
|
{
|
||||||
FCogWindowWidgets::BeginTableTooltip();
|
if (FCogWindowWidgets::BeginTableTooltip())
|
||||||
if (ImGui::BeginTable("Params", 2, ImGuiTableFlags_Borders))
|
|
||||||
{
|
{
|
||||||
ImGui::TableNextRow();
|
if (ImGui::BeginTable("Params", 2, ImGuiTableFlags_Borders))
|
||||||
ImGui::TableNextColumn();
|
{
|
||||||
ImGui::Text("%s", Label);
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("%0.2f", Value);
|
ImGui::Text("%s", Label);
|
||||||
ImGui::EndTable();
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%0.2f", Value);
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
FCogWindowWidgets::EndTableTooltip();
|
||||||
}
|
}
|
||||||
FCogWindowWidgets::EndTableTooltip();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,72 +592,74 @@ void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugPlotEvent* Hovere
|
|||||||
{
|
{
|
||||||
if (ImPlot::IsPlotHovered() && HoveredEvent != nullptr)
|
if (ImPlot::IsPlotHovered() && HoveredEvent != nullptr)
|
||||||
{
|
{
|
||||||
FCogWindowWidgets::BeginTableTooltip();
|
if (FCogWindowWidgets::BeginTableTooltip())
|
||||||
if (ImGui::BeginTable("Params", 2, ImGuiTableFlags_Borders))
|
|
||||||
{
|
{
|
||||||
//------------------------
|
if (ImGui::BeginTable("Params", 2, ImGuiTableFlags_Borders))
|
||||||
// Event Name
|
|
||||||
//------------------------
|
|
||||||
ImGui::TableNextRow();
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::Text("Name");
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::Text("%s", TCHAR_TO_ANSI(*HoveredEvent->DisplayName));
|
|
||||||
|
|
||||||
//------------------------
|
|
||||||
// Owner Name
|
|
||||||
//------------------------
|
|
||||||
ImGui::TableNextRow();
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::Text("Owner");
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::Text("%s", TCHAR_TO_ANSI(*HoveredEvent->OwnerName));
|
|
||||||
|
|
||||||
//------------------------
|
|
||||||
// Times
|
|
||||||
//------------------------
|
|
||||||
if (HoveredEvent->EndTime != HoveredEvent->StartTime)
|
|
||||||
{
|
{
|
||||||
const float ActualEndTime = HoveredEvent->GetActualEndTime(Entry);
|
//------------------------
|
||||||
const uint64 ActualEndFrame = HoveredEvent->GetActualEndFrame(Entry);
|
// Event Name
|
||||||
|
//------------------------
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("Name");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%s", TCHAR_TO_ANSI(*HoveredEvent->DisplayName));
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Owner Name
|
||||||
|
//------------------------
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("Duration");
|
ImGui::Text("Owner");
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("%0.2fs", ActualEndTime - HoveredEvent->StartTime);
|
ImGui::Text("%s", TCHAR_TO_ANSI(*HoveredEvent->OwnerName));
|
||||||
|
|
||||||
ImGui::TableNextRow();
|
//------------------------
|
||||||
ImGui::TableNextColumn();
|
// Times
|
||||||
ImGui::Text("Frames");
|
//------------------------
|
||||||
ImGui::TableNextColumn();
|
if (HoveredEvent->EndTime != HoveredEvent->StartTime)
|
||||||
ImGui::Text("%d [%d-%d]",
|
{
|
||||||
(int32)(ActualEndFrame - HoveredEvent->StartFrame),
|
const float ActualEndTime = HoveredEvent->GetActualEndTime(Entry);
|
||||||
(int32)(HoveredEvent->StartFrame % 1000),
|
const uint64 ActualEndFrame = HoveredEvent->GetActualEndFrame(Entry);
|
||||||
(int32)(ActualEndFrame % 1000));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ImGui::TableNextRow();
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::Text("Frame");
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::Text("%d", (int32)(HoveredEvent->StartFrame % 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------
|
ImGui::TableNextRow();
|
||||||
// Params
|
ImGui::TableNextColumn();
|
||||||
//------------------------
|
ImGui::Text("Duration");
|
||||||
for (FCogDebugPlotEventParams Param : HoveredEvent->Params)
|
ImGui::TableNextColumn();
|
||||||
{
|
ImGui::Text("%0.2fs", ActualEndTime - HoveredEvent->StartTime);
|
||||||
ImGui::TableNextRow();
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextRow();
|
||||||
ImGui::Text("%s", TCHAR_TO_ANSI(*Param.Name.ToString()));
|
ImGui::TableNextColumn();
|
||||||
ImGui::TableNextColumn();
|
ImGui::Text("Frames");
|
||||||
ImGui::Text("%s", TCHAR_TO_ANSI(*Param.Value));
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%d [%d-%d]",
|
||||||
|
(int32)(ActualEndFrame - HoveredEvent->StartFrame),
|
||||||
|
(int32)(HoveredEvent->StartFrame % 1000),
|
||||||
|
(int32)(ActualEndFrame % 1000));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("Frame");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%d", (int32)(HoveredEvent->StartFrame % 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------
|
||||||
|
// Params
|
||||||
|
//------------------------
|
||||||
|
for (FCogDebugPlotEventParams Param : HoveredEvent->Params)
|
||||||
|
{
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%s", TCHAR_TO_ANSI(*Param.Name.ToString()));
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%s", TCHAR_TO_ANSI(*Param.Value));
|
||||||
|
}
|
||||||
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
ImGui::EndTable();
|
FCogWindowWidgets::EndTableTooltip();
|
||||||
}
|
}
|
||||||
FCogWindowWidgets::EndTableTooltip();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ protected:
|
|||||||
|
|
||||||
virtual void RenderContent() override;
|
virtual void RenderContent() override;
|
||||||
|
|
||||||
static void RenderPlotsList(TArray<FCogDebugPlotEntry*>& VisiblePlots);
|
static void RenderPlotsList(const ImVec2& InSize);
|
||||||
|
|
||||||
void RenderPlots(const TArray<FCogDebugPlotEntry*>& VisiblePlots) const;
|
void RenderPlots(const TArray<FCogDebugPlotEntry*>& VisiblePlots) const;
|
||||||
|
|
||||||
@@ -75,6 +75,9 @@ public:
|
|||||||
UPROPERTY(Config)
|
UPROPERTY(Config)
|
||||||
FColor PauseBackgroundColor = FColor(10, 0, 0, 255);
|
FColor PauseBackgroundColor = FColor(10, 0, 0, 255);
|
||||||
|
|
||||||
|
UPROPERTY(Config)
|
||||||
|
bool DockPlotList = false;
|
||||||
|
|
||||||
virtual void Reset() override
|
virtual void Reset() override
|
||||||
{
|
{
|
||||||
Rows = 1;
|
Rows = 1;
|
||||||
@@ -84,5 +87,6 @@ public:
|
|||||||
ShowValueAtCursor = true;
|
ShowValueAtCursor = true;
|
||||||
DragViewSensitivity = 10.0f;
|
DragViewSensitivity = 10.0f;
|
||||||
PauseBackgroundColor = FColor(10, 0, 0, 255);
|
PauseBackgroundColor = FColor(10, 0, 0, 255);
|
||||||
|
DockPlotList = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user