Skip to content

Commit fbcd3c1

Browse files
committed
Make markers subtle, and only clear when you hover the save-defaults button.
1 parent ae523c9 commit fbcd3c1

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

‎manual/tracy.tex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3795,7 +3795,7 @@ \subsection{Options menu}
37953795

37963796
Disabling the display of some events is especially recommended when the profiler performance drops below acceptable levels for interactive usage.
37973797

3798-
It is possible to store defaults for the settings marked with a red \emph{\textcolor{red}{*}} to the global Tracy configuration file.
3798+
It is possible to store defaults for the settings marked with a \emph{*} to the global Tracy configuration file.
37993799
This can be done using the \emph{Save current options as defaults} button at the bottom of the window, or by manually editing this configuration file (for which the path is indicated in the tooltip).
38003800
Next time you use Tracy, these stored default options will be used instead.
38013801
For now, restoring the defaults can be done by deleting the configuration file.

‎profiler/src/profiler/TracyView_Options.cpp‎

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,22 @@
1515
namespace tracy
1616
{
1717

18-
static void DefaultMarker() {
18+
static void DefaultMarker( bool active, bool tooltip = true )
19+
{
1920
// Add a red * to indicate that the default value for this setting can be configured.
2021
ImGui::SameLine( 0.0f, 2.0f );
21-
TextColoredUnformatted( ImVec4( 0.9f, 0.05f, 0.1f, 0.8f ), "*" );
22+
TextColoredUnformatted( active ? ImVec4( 0.9f, 0.05f, 0.1f, 0.8f ) : ImVec4( 0.6f, 0.6f, 0.6f, 0.4f ), "*" );
23+
if( tooltip && ImGui::IsItemHovered() )
24+
{
25+
ImGui::BeginTooltip();
26+
ImGui::TextUnformatted( "Has a default value loaded when starting Tracy (see below)." );
27+
ImGui::EndTooltip();
28+
}
2229
}
2330

2431
void View::DrawOptions()
2532
{
33+
static bool default_markers_active = false;
2634

2735
ImGui::Begin( "Options", &m_showOptions, ImGuiWindowFlags_AlwaysAutoResize );
2836
if( ImGui::GetCurrentWindowRead()->SkipItems ) { ImGui::End(); return; }
@@ -34,7 +42,7 @@ void View::DrawOptions()
3442
val = m_vd.drawFrameTargets;
3543
ImGui::Checkbox( ICON_FA_FLAG_CHECKERED " Draw frame targets", &val );
3644
m_vd.drawFrameTargets = val;
37-
DefaultMarker();
45+
DefaultMarker(default_markers_active);
3846
ImGui::Indent();
3947
int tmp = m_vd.frameTarget;
4048
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
@@ -44,7 +52,7 @@ void View::DrawOptions()
4452
if( tmp < 1 ) tmp = 1;
4553
m_vd.frameTarget = tmp;
4654
}
47-
DefaultMarker();
55+
DefaultMarker(default_markers_active);
4856
ImGui::SameLine();
4957
TextDisabledUnformatted( TimeToString( 1000*1000*1000 / tmp ) );
5058
ImGui::PopStyleVar();
@@ -70,7 +78,7 @@ void View::DrawOptions()
7078
val = m_vd.drawContextSwitches;
7179
ImGui::Checkbox( ICON_FA_PERSON_HIKING " Draw context switches", &val );
7280
m_vd.drawContextSwitches = val;
73-
DefaultMarker();
81+
DefaultMarker(default_markers_active);
7482
ImGui::Indent();
7583
val = m_vd.darkenContextSwitches;
7684
SmallCheckbox( ICON_FA_MOON " Darken inactive threads", &val );
@@ -91,7 +99,7 @@ void View::DrawOptions()
9199
val = m_vd.drawSamples;
92100
ImGui::Checkbox( ICON_FA_EYE_DROPPER " Draw stack samples", &val );
93101
m_vd.drawSamples = val;
94-
DefaultMarker();
102+
DefaultMarker(default_markers_active);
95103
}
96104

97105
const auto& gpuData = m_worker.GetGpuData();
@@ -231,7 +239,7 @@ void View::DrawOptions()
231239
val = m_vd.ghostZones;
232240
SmallCheckbox( ICON_FA_GHOST " Draw ghost zones", &val );
233241
m_vd.ghostZones = val;
234-
DefaultMarker();
242+
DefaultMarker(default_markers_active);
235243
}
236244
#endif
237245

@@ -240,7 +248,7 @@ void View::DrawOptions()
240248
ImGui::SameLine();
241249
bool forceColors = m_vd.forceColors;
242250
if( SmallCheckbox( "Ignore custom", &forceColors ) ) m_vd.forceColors = forceColors;
243-
DefaultMarker();
251+
DefaultMarker(default_markers_active);
244252
ImGui::SameLine();
245253
bool inheritColors = m_vd.inheritParentColors;
246254
if( SmallCheckbox( "Inherit parent colors", &inheritColors ) ) m_vd.inheritParentColors = inheritColors;
@@ -254,7 +262,7 @@ void View::DrawOptions()
254262
m_vd.dynamicColors = ival;
255263
ival = (int)m_vd.shortenName;
256264
ImGui::TextUnformatted( ICON_FA_RULER_HORIZONTAL " Zone name shortening" );
257-
DefaultMarker();
265+
DefaultMarker(default_markers_active);
258266
ImGui::Indent();
259267
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
260268
ImGui::RadioButton( "Disabled", &ival, (uint8_t)ShortenName::Never );
@@ -611,7 +619,7 @@ void View::DrawOptions()
611619
int pH = m_vd.plotHeight;
612620
ImGui::SliderInt("Plot heights", &pH, 30, 200);
613621
m_vd.plotHeight = pH;
614-
DefaultMarker();
622+
DefaultMarker(default_markers_active);
615623

616624
const auto expand = ImGui::TreeNode( "Plots" );
617625
ImGui::SameLine();
@@ -844,9 +852,13 @@ void View::DrawOptions()
844852
ImGui::Separator();
845853

846854
ImGui::TextUnformatted( "" );
847-
DefaultMarker();
855+
DefaultMarker( default_markers_active, false );
848856
ImGui::SameLine( 0.0f, 1.0f );
849857
ImGui::TextUnformatted( ": The default value for this option is configurable." );
858+
if( ImGui::IsItemHovered() )
859+
{
860+
default_markers_active = true;
861+
}
850862

851863
if( ImGui::Button( "Save current options as defaults" ) )
852864
{
@@ -862,11 +874,12 @@ void View::DrawOptions()
862874
}
863875
if( ImGui::IsItemHovered() )
864876
{
877+
default_markers_active = true;
865878
ImGui::BeginTooltip();
866879
const auto fn = tracy::GetSavePath( "tracy.ini" );
867880

868881
ImGui::TextUnformatted( "The options above marked with " );
869-
DefaultMarker();
882+
DefaultMarker( true, false );
870883
ImGui::SameLine();
871884
ImGui::TextUnformatted( "have configurable default values." );
872885
ImGui::TextUnformatted(
@@ -877,6 +890,10 @@ void View::DrawOptions()
877890
ImGui::TextUnformatted( "For now, to restore the default values, you may delete this configuration file." );
878891
ImGui::EndTooltip();
879892
}
893+
else
894+
{
895+
default_markers_active = false;
896+
}
880897

881898
ImGui::End();
882899
}

0 commit comments

Comments
 (0)