mirror of
https://github.com/Ed94/Cog.git
synced 2026-08-08 16:48:16 +00:00
CogEngine: Improve plot window UI
Make docking of plots optional
This commit is contained in:
@@ -47,8 +47,19 @@ void FCogEngineWindow_Plots::RenderContent()
|
||||
{
|
||||
Super::RenderContent();
|
||||
|
||||
TArray<FCogDebugPlotEntry*> VisiblePlots;
|
||||
for (FCogDebugPlotEntry& Plot : FCogDebugPlot::Plots)
|
||||
{
|
||||
if (Plot.CurrentYAxis != ImAxis_COUNT && Plot.CurrentRow != INDEX_NONE)
|
||||
{
|
||||
VisiblePlots.Add(&Plot);
|
||||
}
|
||||
}
|
||||
|
||||
RenderMenu();
|
||||
|
||||
if (Config->DockPlotList)
|
||||
{
|
||||
if (ImGui::BeginTable("PlotTable", 2, ImGuiTableFlags_RowBg
|
||||
| ImGuiTableFlags_Resizable
|
||||
| ImGuiTableFlags_BordersV
|
||||
@@ -60,10 +71,9 @@ void FCogEngineWindow_Plots::RenderContent()
|
||||
ImGui::TableSetupColumn("Plots", ImGuiTableColumnFlags_WidthStretch, 0.0f);
|
||||
ImGui::TableNextRow();
|
||||
|
||||
TArray<FCogDebugPlotEntry*> VisiblePlots;
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
RenderPlotsList(VisiblePlots);
|
||||
RenderPlotsList(ImVec2(0, -1));
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
RenderPlots(VisiblePlots);
|
||||
@@ -71,6 +81,12 @@ void FCogEngineWindow_Plots::RenderContent()
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderPlots(VisiblePlots);
|
||||
}
|
||||
|
||||
bApplyTimeScale = false;
|
||||
}
|
||||
|
||||
@@ -79,6 +95,15 @@ void FCogEngineWindow_Plots::RenderMenu()
|
||||
{
|
||||
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::MenuItem("Clear data"))
|
||||
@@ -119,6 +144,9 @@ void FCogEngineWindow_Plots::RenderMenu()
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::Checkbox("Show value at cursor", &Config->ShowValueAtCursor);
|
||||
|
||||
FCogWindowWidgets::SetNextItemToShortWidth();
|
||||
ImGui::Checkbox("Dock plots", &Config->DockPlotList);
|
||||
|
||||
constexpr ImGuiColorEditFlags ColorEditFlags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
FCogImguiHelper::ColorEdit4("Pause background color", Config->PauseBackgroundColor, ColorEditFlags);
|
||||
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;
|
||||
|
||||
@@ -143,11 +171,6 @@ void FCogEngineWindow_Plots::RenderPlotsList(TArray<FCogDebugPlotEntry*>& Visibl
|
||||
|
||||
for (FCogDebugPlotEntry& Plot : FCogDebugPlot::Plots)
|
||||
{
|
||||
if (Plot.CurrentYAxis != ImAxis_COUNT && Plot.CurrentRow != INDEX_NONE)
|
||||
{
|
||||
VisiblePlots.Add(&Plot);
|
||||
}
|
||||
|
||||
ImGui::PushID(Index);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, Plot.IsEventPlot ? IM_COL32(128, 128, 255, 255) : IM_COL32(255, 255, 255, 255));
|
||||
@@ -451,7 +474,8 @@ void FCogEngineWindow_Plots::RenderValues(FCogDebugPlotEntry& Entry, const char*
|
||||
float Value;
|
||||
if (Entry.FindValue(ImPlot::GetPlotMousePos().x, Value))
|
||||
{
|
||||
FCogWindowWidgets::BeginTableTooltip();
|
||||
if (FCogWindowWidgets::BeginTableTooltip())
|
||||
{
|
||||
if (ImGui::BeginTable("Params", 2, ImGuiTableFlags_Borders))
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
@@ -464,6 +488,7 @@ void FCogEngineWindow_Plots::RenderValues(FCogDebugPlotEntry& Entry, const char*
|
||||
FCogWindowWidgets::EndTableTooltip();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Entry.ShowValuesMarkers)
|
||||
{
|
||||
@@ -567,7 +592,8 @@ void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugPlotEvent* Hovere
|
||||
{
|
||||
if (ImPlot::IsPlotHovered() && HoveredEvent != nullptr)
|
||||
{
|
||||
FCogWindowWidgets::BeginTableTooltip();
|
||||
if (FCogWindowWidgets::BeginTableTooltip())
|
||||
{
|
||||
if (ImGui::BeginTable("Params", 2, ImGuiTableFlags_Borders))
|
||||
{
|
||||
//------------------------
|
||||
@@ -635,4 +661,5 @@ void FCogEngineWindow_Plots::RenderEventTooltip(const FCogDebugPlotEvent* Hovere
|
||||
}
|
||||
FCogWindowWidgets::EndTableTooltip();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ protected:
|
||||
|
||||
virtual void RenderContent() override;
|
||||
|
||||
static void RenderPlotsList(TArray<FCogDebugPlotEntry*>& VisiblePlots);
|
||||
static void RenderPlotsList(const ImVec2& InSize);
|
||||
|
||||
void RenderPlots(const TArray<FCogDebugPlotEntry*>& VisiblePlots) const;
|
||||
|
||||
@@ -75,6 +75,9 @@ public:
|
||||
UPROPERTY(Config)
|
||||
FColor PauseBackgroundColor = FColor(10, 0, 0, 255);
|
||||
|
||||
UPROPERTY(Config)
|
||||
bool DockPlotList = false;
|
||||
|
||||
virtual void Reset() override
|
||||
{
|
||||
Rows = 1;
|
||||
@@ -84,5 +87,6 @@ public:
|
||||
ShowValueAtCursor = true;
|
||||
DragViewSensitivity = 10.0f;
|
||||
PauseBackgroundColor = FColor(10, 0, 0, 255);
|
||||
DockPlotList = false;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user