mirror of
https://github.com/wolfpld/tracy.git
synced 2026-09-15 23:04:25 +00:00
Represent the user interface scale as a preset table index.
Replace the userScale float with a zoomLevel index into s_zoomPresets; the ini key changes accordingly and previously saved floats are ignored.
This commit is contained in:
@@ -169,10 +169,10 @@ static void ScaleWindow(ImGuiWindow* window, float scale)
|
||||
|
||||
static void SetupDPIScale()
|
||||
{
|
||||
auto scale = dpiScale * tracy::s_config.userScale;
|
||||
auto scale = dpiScale * tracy::s_zoomPresets[tracy::s_config.zoomLevel];
|
||||
|
||||
#ifdef __APPLE__
|
||||
scale = tracy::s_config.userScale;
|
||||
scale = tracy::s_zoomPresets[tracy::s_config.zoomLevel];
|
||||
#endif
|
||||
|
||||
if( !dpiFirstSetup && prevScale == scale ) return;
|
||||
@@ -218,9 +218,10 @@ static int IsBusy()
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SetupScaleCallback( float scale )
|
||||
static void SetupScaleCallback( int preset )
|
||||
{
|
||||
tracy::s_config.userScale = scale;
|
||||
assert( preset >= 0 && preset < tracy::s_zoomPresetCount );
|
||||
tracy::s_config.zoomLevel = preset;
|
||||
if ( tracy::s_config.saveUserScale ) tracy::SaveConfig();
|
||||
RunOnMainThread( []{ SetupDPIScale(); }, true );
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ void LoadConfig()
|
||||
if( ini_sget( ini, "achievements", "enabled", "%d", &v ) ) s_config.achievements = v;
|
||||
if( ini_sget( ini, "achievements", "asked", "%d", &v ) ) s_config.achievementsAsked = v;
|
||||
if( ini_sget( ini, "ui", "saveUserScale", "%d", &v ) ) s_config.saveUserScale = v;
|
||||
if( ini_sget( ini, "ui", "userScale", "%lf", &v1 ) && v1 > 0.0 && s_config.saveUserScale ) s_config.userScale = v1;
|
||||
if( ini_sget( ini, "ui", "zoomLevel", "%d", &v ) && v >= 0 && v < s_zoomPresetCount ) s_config.zoomLevel = v;
|
||||
if( ini_sget( ini, "llm", "enabled", "%d", &v ) ) s_config.llm = v;
|
||||
if( v2 = ini_get( ini, "llm", "address" ); v2 ) s_config.llmAddress = v2;
|
||||
if( v2 = ini_get( ini, "llm", "model" ); v2 ) s_config.llmModel = v2;
|
||||
@@ -92,7 +92,7 @@ bool SaveConfig()
|
||||
|
||||
fprintf( f, "\n[ui]\n" );
|
||||
fprintf( f, "saveUserScale = %i\n", (int)s_config.saveUserScale );
|
||||
fprintf( f, "userScale = %lf\n", s_config.userScale );
|
||||
fprintf( f, "zoomLevel = %i\n", s_config.zoomLevel );
|
||||
|
||||
fprintf( f, "\n[llm]\n" );
|
||||
fprintf( f, "enabled = %i\n", (int)s_config.llm );
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
inline constexpr float s_zoomPresets[] = {
|
||||
1.f/2, 1.f/1.75f, 1.f/1.5f, 1.f/1.25f, 1.f, 1.25f, 1.5f, 1.75f, 2.f, 2.25f, 2.5f, 2.75f, 3.f
|
||||
};
|
||||
constexpr int s_zoomPresetCount = sizeof( s_zoomPresets ) / sizeof( *s_zoomPresets );
|
||||
constexpr int s_zoomPreset100 = 4;
|
||||
|
||||
struct Config
|
||||
{
|
||||
bool threadedRendering = true;
|
||||
@@ -28,7 +34,7 @@ struct Config
|
||||
bool drawContextSwitches = true;
|
||||
int plotHeight = 100;
|
||||
bool saveUserScale = false;
|
||||
float userScale = 1.0f;
|
||||
int zoomLevel = s_zoomPreset100;
|
||||
|
||||
// LLM assistant settings
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
||||
@@ -163,6 +163,12 @@ void View::SaveUserData()
|
||||
m_userData.Save();
|
||||
}
|
||||
|
||||
void View::SetZoomPreset( int idx )
|
||||
{
|
||||
assert( idx >= 0 && idx < s_zoomPresetCount );
|
||||
if( m_sscb ) m_sscb( idx );
|
||||
}
|
||||
|
||||
void View::ViewSource( const char* fileName, int line )
|
||||
{
|
||||
assert( fileName );
|
||||
@@ -995,19 +1001,12 @@ bool View::DrawImpl()
|
||||
if( ImGui::Button( ICON_FA_MAGNIFYING_GLASS_PLUS ) ) ImGui::OpenPopup( "ZoomPopup" );
|
||||
if( ImGui::BeginPopup( "ZoomPopup" ) )
|
||||
{
|
||||
if( ImGui::Button( "50%" ) ) m_sscb( 1.f/2 );
|
||||
if( ImGui::Button( "57%" ) ) m_sscb( 1.f/1.75f );
|
||||
if( ImGui::Button( "66%" ) ) m_sscb( 1.f/1.5f );
|
||||
if( ImGui::Button( "80%" ) ) m_sscb( 1.f/1.25f );
|
||||
if( ImGui::Button( "100%" ) ) m_sscb( 1.f );
|
||||
if( ImGui::Button( "125%" ) ) m_sscb( 1.25f );
|
||||
if( ImGui::Button( "150%" ) ) m_sscb( 1.5f );
|
||||
if( ImGui::Button( "175%" ) ) m_sscb( 1.75f );
|
||||
if( ImGui::Button( "200%" ) ) m_sscb( 2.f );
|
||||
if( ImGui::Button( "225%" ) ) m_sscb( 2.25f );
|
||||
if( ImGui::Button( "250%" ) ) m_sscb( 2.5f );
|
||||
if( ImGui::Button( "275%" ) ) m_sscb( 2.75f );
|
||||
if( ImGui::Button( "300%" ) ) m_sscb( 3.f );
|
||||
for( int i=0; i<s_zoomPresetCount; i++ )
|
||||
{
|
||||
char label[32];
|
||||
sprintf( label, "%i%%", int( s_zoomPresets[i] * 100.f + 0.001f ) );
|
||||
if( ImGui::RadioButton( label, i == s_config.zoomLevel ) ) SetZoomPreset( i );
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
};
|
||||
|
||||
using SetTitleCallback = void(*)( const char* );
|
||||
using SetScaleCallback = void(*)( float );
|
||||
using SetScaleCallback = void(*)( int );
|
||||
using AttentionCallback = void(*)();
|
||||
|
||||
View( void(*cbMainThread)(const std::function<void()>&, bool), const char* addr, uint16_t port, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, AchievementsMgr* amgr );
|
||||
@@ -304,6 +304,7 @@ private:
|
||||
void SetupRanges();
|
||||
void Achieve( const char* id );
|
||||
void SaveUserData();
|
||||
void SetZoomPreset( int idx );
|
||||
|
||||
bool DrawImpl();
|
||||
void DrawFrameImage( FrameImageCache& cache, const FrameImage& fi, float scale = GetScale() );
|
||||
|
||||
Reference in New Issue
Block a user