feat(config): Button to save ViewData options to the defaults in TracyConfig.

This commit is contained in:
Martijn Courteaux
2025-08-20 15:32:04 +02:00
parent ebc31f25e3
commit 577e7a3074
4 changed files with 39 additions and 0 deletions

View File

@@ -3795,6 +3795,9 @@ Function names in the remaining places across the UI will be normalized unless t
Disabling the display of some events is especially recommended when the profiler performance drops below acceptable levels for interactive usage.
It is possible to store defaults for certain settings to the global Tracy configuration file.
This can be done using the \emph{Save defaults} button at the bottom of the window, or by manually editing this configuration file indicated in the tooltip.
\subsection{Messages window}
\label{messages}

View File

@@ -23,8 +23,12 @@ struct Config
bool forceColors = false;
bool ghostZones = true;
int shortenName = (int)ShortenName::NoSpaceAndNormalize;
bool drawSamples = true;
bool drawContextSwitches = true;
bool saveUserScale = false;
float userScale = 1.0f;
// LLM assistant settings
#ifdef __EMSCRIPTEN__
bool llm = false;
#else

View File

@@ -135,11 +135,14 @@ void View::InitTextEditor()
void View::SetupConfig()
{
// Keep in sync with TracyView_Options.cpp View::DrawOptions(), bottom of the file.
m_vd.frameTarget = s_config.targetFps;
m_vd.dynamicColors = s_config.dynamicColors;
m_vd.forceColors = s_config.forceColors;
m_vd.ghostZones = s_config.ghostZones;
m_vd.shortenName = (ShortenName)s_config.shortenName;
m_vd.drawSamples = s_config.drawSamples;
m_vd.drawContextSwitches = s_config.drawContextSwitches;
}
void View::Achieve( const char* id )

View File

@@ -8,6 +8,7 @@
#include "TracyTimelineItemGpu.hpp"
#include "TracyUtility.hpp"
#include "TracyView.hpp"
#include "TracyStorage.hpp"
#include "tracy_pdqsort.h"
#include "../Fonts.hpp"
@@ -824,6 +825,34 @@ void View::DrawOptions()
ImGui::TreePop();
}
}
ImGui::Spacing();
if( ImGui::Button( "Save defaults" ) )
{
// Keep in sync with TracyView.cpp View::SetupConfig()
s_config.targetFps = m_vd.frameTarget;
s_config.dynamicColors = m_vd.dynamicColors;
s_config.forceColors = m_vd.forceColors;
s_config.ghostZones = m_vd.ghostZones;
s_config.shortenName = (int)m_vd.shortenName;
s_config.drawSamples = m_vd.drawSamples;
s_config.drawContextSwitches = m_vd.drawContextSwitches;
SaveConfig();
}
if( ImGui::IsItemHovered() )
{
ImGui::BeginTooltip();
const auto fn = tracy::GetSavePath( "tracy.ini" );
ImGui::TextUnformatted(
"A handful of the options above have configurable default values.\n"
"There is no UI yet to set those items, except this button which saves the default for all of them.\n\n"
"For now, you can also manually adjust those defaults by editing the config file at:"
);
TextDisabledUnformatted(fn);
ImGui::EndTooltip();
}
ImGui::End();
}