From f1a5270a79cb93c925ef16cea03083ddf92f1112 Mon Sep 17 00:00:00 2001 From: aiekick Date: Sun, 1 Dec 2024 00:35:59 +0100 Subject: [PATCH] add a settings do enable/disbale auto resize columns in log and log 2nd views for #17 --- src/headers/LogToGraphBuild.h | 4 ++-- src/panes/LogPane.cpp | 17 +++++++++++------ src/panes/LogPaneSecondView.cpp | 16 +++++++++++----- src/project/ProjectFile.cpp | 10 ++++++++-- src/project/ProjectFile.h | 2 ++ 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/headers/LogToGraphBuild.h b/src/headers/LogToGraphBuild.h index adc51f9..46747b5 100644 --- a/src/headers/LogToGraphBuild.h +++ b/src/headers/LogToGraphBuild.h @@ -1,7 +1,7 @@ #pragma once #define LogToGraph_Prefix "LogToGraph" -#define LogToGraph_BuildNumber 1061 +#define LogToGraph_BuildNumber 1063 #define LogToGraph_MinorNumber 2 #define LogToGraph_MajorNumber 0 -#define LogToGraph_BuildId "0.2.1061" +#define LogToGraph_BuildId "0.2.1063" diff --git a/src/panes/LogPane.cpp b/src/panes/LogPane.cpp index 5c7ccfc..6bc7fb1 100644 --- a/src/panes/LogPane.cpp +++ b/src/panes/LogPane.cpp @@ -108,11 +108,14 @@ void LogPane::CheckItem(SignalTickPtr vSignalTick) { void LogPane::DrawMenuBar() { bool need_update = false; if (ImGui::BeginMenu("Settings")) { - if (ImGui::MenuItem("Show variable signals only", nullptr, &ProjectFile::Instance()->m_ShowVariableSignalsInLogView)) { - LogEngine::Instance()->SetHoveredTime(LogEngine::Instance()->GetHoveredTime()); + if (ImGui::MenuItem("Collapse Selection", nullptr, &ProjectFile::Instance()->m_CollapseLogSelection)) { need_update = true; } - if (ImGui::MenuItem("Collapse Selection", nullptr, &ProjectFile::Instance()->m_CollapseLogSelection)) { + if (ImGui::MenuItem("Auto resize columns", nullptr, &ProjectFile::Instance()->m_AutoResizeLogColumns)) { + need_update = true; + } + if (ImGui::MenuItem("Show variable signals only", nullptr, &ProjectFile::Instance()->m_ShowVariableSignalsInLogView)) { + LogEngine::Instance()->SetHoveredTime(LogEngine::Instance()->GetHoveredTime()); need_update = true; } if (ImGui::MenuItem("Hide some values", nullptr, &ProjectFile::Instance()->m_HideSomeLogValues)) { @@ -147,11 +150,13 @@ void LogPane::DrawMenuBar() { } void LogPane::DrawTable() { - - static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY | - ImGuiTableFlags_Resizable | + ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY | ImGuiTableFlags_NoHostExtendY; + if (!ProjectFile::Instance()->m_AutoResizeLogColumns) { + flags |= ImGuiTableFlags_Resizable; + } + // first display if (m_LogDatas.empty()) { PrepareLog(); diff --git a/src/panes/LogPaneSecondView.cpp b/src/panes/LogPaneSecondView.cpp index 546aed3..af6fa19 100644 --- a/src/panes/LogPaneSecondView.cpp +++ b/src/panes/LogPaneSecondView.cpp @@ -105,11 +105,14 @@ void LogPaneSecondView::CheckItem(const SignalTickPtr& vSignalTick) { void LogPaneSecondView::DrawMenuBar() { bool need_update = false; if (ImGui::BeginMenu("Settings")) { - if (ImGui::MenuItem("Show variable signals only", nullptr, &ProjectFile::Instance()->m_ShowVariableSignalsInLog2ndView)) { - LogEngine::Instance()->SetHoveredTime(LogEngine::Instance()->GetHoveredTime()); + if (ImGui::MenuItem("Collapse Selection", nullptr, &ProjectFile::Instance()->m_CollapseLog2ndSelection)) { need_update = true; } - if (ImGui::MenuItem("Collapse Selection", nullptr, &ProjectFile::Instance()->m_CollapseLog2ndSelection)) { + if (ImGui::MenuItem("Auto resize columns", nullptr, &ProjectFile::Instance()->m_AutoResizeLog2ndColumns)) { + need_update = true; + } + if (ImGui::MenuItem("Show variable signals only", nullptr, &ProjectFile::Instance()->m_ShowVariableSignalsInLog2ndView)) { + LogEngine::Instance()->SetHoveredTime(LogEngine::Instance()->GetHoveredTime()); need_update = true; } if (ImGui::MenuItem("Hide some values", nullptr, &ProjectFile::Instance()->m_HideSomeLog2ndValues)) { @@ -144,10 +147,13 @@ void LogPaneSecondView::DrawMenuBar() { } void LogPaneSecondView::DrawTable() { - static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY | - ImGuiTableFlags_Resizable | + ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable | ImGuiTableFlags_ScrollY | ImGuiTableFlags_NoHostExtendY; + if (!ProjectFile::Instance()->m_AutoResizeLog2ndColumns) { + flags |= ImGuiTableFlags_Resizable; + } + // first display if (m_LogDatas.empty()) { PrepareLog(); diff --git a/src/project/ProjectFile.cpp b/src/project/ProjectFile.cpp index 0f01080..3f81faf 100644 --- a/src/project/ProjectFile.cpp +++ b/src/project/ProjectFile.cpp @@ -282,7 +282,9 @@ ez::xml::Nodes ProjectFile::getXmlNodes(const std::string& /*vUserDatas*/) { node.addChild("show_variable_signals_in_graph_view").setContent(m_ShowVariableSignalsInGraphView); node.addChild("show_variable_signals_in_hovered_list_view").setContent(m_ShowVariableSignalsInHoveredListView); node.addChild("show_variable_signals_in_log_view").setContent(m_ShowVariableSignalsInLogView); - node.addChild("show_variable_signals_in_log2nd_view").setContent(m_ShowVariableSignalsInLog2ndView); + node.addChild("show_variable_signals_in_log_2nd_view").setContent(m_ShowVariableSignalsInLog2ndView); + node.addChild("auto_resize_columns_log_view").setContent(m_AutoResizeLogColumns); + node.addChild("auto_resize_columns_log_2nd_view").setContent(m_AutoResizeLog2ndColumns); node.addChild("last_log_file_path").setContent(m_LastLogFilePath); node.addChild("script_file").setContent(m_ScriptFilePathName); auto& childNode = node.addChild("log_files"); @@ -356,8 +358,12 @@ bool ProjectFile::setFromXmlNodes(const ez::xml::Node& vNode, const ez::xml::Nod m_ShowVariableSignalsInHoveredListView = ez::dvariant(strValue).GetB(); } else if (strName == "show_variable_signals_in_log_view") { m_ShowVariableSignalsInLogView = ez::dvariant(strValue).GetB(); - } else if (strName == "show_variable_signals_in_log2nd_view") { + } else if (strName == "show_variable_signals_in_log_2nd_view") { m_ShowVariableSignalsInLog2ndView = ez::dvariant(strValue).GetB(); + } else if (strName == "auto_resize_columns_log_view") { + m_AutoResizeLogColumns = ez::dvariant(strValue).GetB(); + } else if (strName == "auto_resize_columns_log_2nd_view") { + m_AutoResizeLog2ndColumns = ez::dvariant(strValue).GetB(); } else if (strName == "last_log_file_path") { m_LastLogFilePath = strValue; } else if (strName == "script_file") { diff --git a/src/project/ProjectFile.h b/src/project/ProjectFile.h index 900a75e..dcf332f 100644 --- a/src/project/ProjectFile.h +++ b/src/project/ProjectFile.h @@ -67,6 +67,8 @@ class ProjectFile : public Ltg::IProject, public ez::xml::Config { bool m_ShowVariableSignalsInAllGraphView = false; bool m_ShowVariableSignalsInGraphView = false; bool m_ShowVariableSignalsInHoveredListView = false; + bool m_AutoResizeLogColumns = false; + bool m_AutoResizeLog2ndColumns = false; private: // dont save bool m_IsLoaded = false;