diff --git a/cmake/vendor.cmake b/cmake/vendor.cmake index 11482c4c..59d00a88 100644 --- a/cmake/vendor.cmake +++ b/cmake/vendor.cmake @@ -159,6 +159,7 @@ add_library(TracyImGui STATIC EXCLUDE_FROM_ALL ${IMGUI_SOURCES}) target_include_directories(TracyImGui PUBLIC ${ImGui_SOURCE_DIR}) target_link_libraries(TracyImGui PUBLIC TracyFreetype) target_compile_definitions(TracyImGui PRIVATE "IMGUI_ENABLE_FREETYPE") +#target_compile_definitions(TracyImGui PUBLIC "IMGUI_DISABLE_OBSOLETE_FUNCTIONS") if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") target_compile_definitions(TracyImGui PRIVATE "IMGUI_DISABLE_DEBUG_TOOLS" "IMGUI_DISABLE_DEMO_WINDOWS") diff --git a/profiler/src/BackendWayland.cpp b/profiler/src/BackendWayland.cpp index 4cff3490..4c7f74cc 100644 --- a/profiler/src/BackendWayland.cpp +++ b/profiler/src/BackendWayland.cpp @@ -928,7 +928,7 @@ static void SetupCursor() s_cursorY = cursor->images[0]->hotspot_y * 120 / s_maxScale; } -static void SetClipboard( void*, const char* text ) +static void SetClipboard( ImGuiContext*, const char* text ) { s_clipboard = text; @@ -939,7 +939,7 @@ static void SetClipboard( void*, const char* text ) wl_data_device_set_selection( s_dataDev, s_dataSource, s_dataSerial ); } -static const char* GetClipboard( void* ) +static const char* GetClipboard( ImGuiContext* ) { if( !s_dataOffer ) return nullptr; int fd[2]; @@ -1069,8 +1069,9 @@ Backend::Backend( const char* title, const std::function& redraw, const s_dataDev = wl_data_device_manager_get_data_device( s_dataDevMgr, s_seat ); wl_data_device_add_listener( s_dataDev, &dataDeviceListener, nullptr ); - io.SetClipboardTextFn = SetClipboard; - io.GetClipboardTextFn = GetClipboard; + auto& platform = ImGui::GetPlatformIO(); + platform.Platform_SetClipboardTextFn = SetClipboard; + platform.Platform_GetClipboardTextFn = GetClipboard; } s_time = std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); diff --git a/profiler/src/Fonts.cpp b/profiler/src/Fonts.cpp index 3acbf04c..19fbb984 100644 --- a/profiler/src/Fonts.cpp +++ b/profiler/src/Fonts.cpp @@ -16,19 +16,21 @@ FontData g_fonts; +float FontNormal, FontSmall, FontBig; + void LoadFonts( float scale ) { ImGuiIO& io = ImGui::GetIO(); ImFontConfig configBasic; - configBasic.FontLoaderFlags = ImGuiFreeTypeBuilderFlags_LightHinting; + configBasic.FontLoaderFlags = ImGuiFreeTypeLoaderFlags_LightHinting; configBasic.FontDataOwnedByAtlas = false; ImFontConfig configMerge; configMerge.MergeMode = true; - configMerge.FontLoaderFlags = ImGuiFreeTypeBuilderFlags_LightHinting; + configMerge.FontLoaderFlags = ImGuiFreeTypeLoaderFlags_LightHinting; configMerge.FontDataOwnedByAtlas = false; ImFontConfig configFixed; - configFixed.FontLoaderFlags = ImGuiFreeTypeBuilderFlags_LightHinting; + configFixed.FontLoaderFlags = ImGuiFreeTypeLoaderFlags_LightHinting; configFixed.GlyphExtraAdvanceX = -1; configFixed.FontDataOwnedByAtlas = false; @@ -41,22 +43,22 @@ void LoadFonts( float scale ) io.Fonts->Clear(); - io.Fonts->AddFontFromMemoryTTF( (void*)fontNormal->data(), fontNormal->size(), round( 15.0f * scale ), &configBasic ); + g_fonts.normal = io.Fonts->AddFontFromMemoryTTF( (void*)fontNormal->data(), fontNormal->size(), round( 15.0f * scale ), &configBasic ); io.Fonts->AddFontFromMemoryTTF( (void*)fontIcons->data(), fontIcons->size(), round( 14.0f * scale ), &configMerge ); g_fonts.mono = io.Fonts->AddFontFromMemoryTTF( (void*)fontFixed->data(), fontFixed->size(), round( 15.0f * scale ), &configFixed ); - - g_fonts.big = io.Fonts->AddFontFromMemoryTTF( (void*)fontNormal->data(), fontNormal->size(), round( 21.0f * scale ), &configBasic ); - io.Fonts->AddFontFromMemoryTTF( (void*)fontIcons->data(), fontIcons->size(), round( 20.0f * scale ), &configMerge ); - - g_fonts.small = io.Fonts->AddFontFromMemoryTTF( (void*)fontNormal->data(), fontNormal->size(), round( 10.0f * scale ), &configBasic ); + io.Fonts->AddFontFromMemoryTTF( (void*)fontIcons->data(), fontIcons->size(), round( 14.0f * scale ), &configMerge ); g_fonts.bold = io.Fonts->AddFontFromMemoryTTF( (void*)fontBold->data(), fontBold->size(), round( 15.0f * scale ), &configBasic ); - io.Fonts->AddFontFromMemoryTTF( (void*)fontIcons->data(), fontIcons->size(), round( 20.0f * scale ), &configMerge ); + io.Fonts->AddFontFromMemoryTTF( (void*)fontIcons->data(), fontIcons->size(), round( 14.0f * scale ), &configMerge ); g_fonts.boldItalic = io.Fonts->AddFontFromMemoryTTF( (void*)fontBoldItalic->data(), fontBoldItalic->size(), round( 15.0f * scale ), &configBasic ); - io.Fonts->AddFontFromMemoryTTF( (void*)fontIcons->data(), fontIcons->size(), round( 20.0f * scale ), &configMerge ); + io.Fonts->AddFontFromMemoryTTF( (void*)fontIcons->data(), fontIcons->size(), round( 14.0f * scale ), &configMerge ); g_fonts.italic = io.Fonts->AddFontFromMemoryTTF( (void*)fontItalic->data(), fontItalic->size(), round( 15.0f * scale ), &configBasic ); - io.Fonts->AddFontFromMemoryTTF( (void*)fontIcons->data(), fontIcons->size(), round( 20.0f * scale ), &configMerge ); + io.Fonts->AddFontFromMemoryTTF( (void*)fontIcons->data(), fontIcons->size(), round( 14.0f * scale ), &configMerge ); + + FontNormal = round( scale * 15.f ); + FontSmall = round( scale * 15 * 2.f / 3.f ); + FontBig = round( scale * 15 * 1.4f ); } diff --git a/profiler/src/Fonts.hpp b/profiler/src/Fonts.hpp index fd879698..6c6d5fd0 100644 --- a/profiler/src/Fonts.hpp +++ b/profiler/src/Fonts.hpp @@ -5,8 +5,7 @@ struct ImFont; struct FontData { - ImFont* big; - ImFont* small; + ImFont* normal; ImFont* mono; ImFont* bold; ImFont* boldItalic; @@ -14,6 +13,7 @@ struct FontData }; extern FontData g_fonts; +extern float FontNormal, FontSmall, FontBig; void LoadFonts( float scale ); diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index ff723e4a..4207c6b7 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -526,7 +526,7 @@ static void UpdateBroadcastClients() static void TextComment( const char* str ) { ImGui::SameLine(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::AlignTextToFramePadding(); tracy::TextDisabledUnformatted( str ); ImGui::PopFont(); @@ -640,12 +640,12 @@ static void DrawContents() ImGui::Begin( "Get started", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings ); char buf[128]; sprintf( buf, "Tracy Profiler %i.%i.%i", tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch ); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.bold, FontNormal * 1.6f ); tracy::TextCentered( buf ); ImGui::PopFont(); if( dpiChanged == 0 ) { - ImGui::SameLine( ImGui::GetWindowContentRegionMax().x - ImGui::CalcTextSize( ICON_FA_WRENCH ).x - ImGui::GetStyle().FramePadding.x * 2 ); + ImGui::SameLine( ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize( ICON_FA_WRENCH ).x ); if( ImGui::Button( ICON_FA_WRENCH ) ) { ImGui::OpenPopup( "About Tracy" ); @@ -656,10 +656,11 @@ static void DrawContents() { tracy::ImageCentered( iconTex, ImVec2( iconTexSz, iconTexSz ) ); ImGui::Spacing(); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.bold, FontNormal * 2.f ); tracy::TextCentered( buf ); + ImGui::Spacing(); ImGui::PopFont(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] ); tracy::TextCentered( tracy::GitRef ); ImGui::PopStyleColor(); @@ -675,7 +676,7 @@ static void DrawContents() } } #ifndef NDEBUG - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 1.f, 0.5f, 0.5f, 1.f ) ); tracy::TextCentered( "Debug build" ); ImGui::PopStyleColor(); @@ -790,7 +791,7 @@ static void DrawContents() ImGui::TreePop(); } ImGui::Separator(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); tracy::TextFocused( "Protocol version", tracy::RealToString( tracy::ProtocolVersion ) ); ImGui::SameLine(); ImGui::SeparatorEx( ImGuiSeparatorFlags_Vertical ); @@ -897,7 +898,7 @@ static void DrawContents() ImGui::Separator(); ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 1.f, 0.25f, 0.25f, 1.f ) ); tracy::TextCentered( ICON_FA_TRIANGLE_EXCLAMATION " Profiler has elevated privileges! " ICON_FA_TRIANGLE_EXCLAMATION ); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); tracy::TextCentered( "You are running the profiler interface with admin privileges. This is" ); tracy::TextCentered( "most likely a mistake, as there is no reason to do so. Instead, you" ); tracy::TextCentered( "probably wanted to run the client (the application you are profiling)" ); @@ -1025,7 +1026,7 @@ static void DrawContents() if( badVer.state != tracy::BadVersionState::Ok ) { if( loadThread.joinable() ) { loadThread.join(); } - tracy::BadVersion( badVer, g_fonts.big ); + tracy::BadVersion( badVer ); } if( !clients.empty() ) @@ -1174,7 +1175,7 @@ static void DrawContents() } else { - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); ImGui::TextUnformatted( releaseNotes.c_str() ); ImGui::PopFont(); } @@ -1215,8 +1216,10 @@ static void DrawContents() } if( ImGui::BeginPopupModal( "Loading trace...", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings) ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontNormal * 2.f ); + ImGui::Spacing(); tracy::TextCentered( ICON_FA_HOURGLASS_HALF ); + ImGui::Spacing(); ImGui::PopFont(); animTime += ImGui::GetIO().DeltaTime; @@ -1301,8 +1304,10 @@ static void DrawContents() if( ImGui::BeginPopupModal( "Capture cleanup...", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { if( viewShutdown.load( std::memory_order_relaxed ) != ViewShutdown::True ) ImGui::CloseCurrentPopup(); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontNormal * 2.f ); + ImGui::Spacing(); tracy::TextCentered( ICON_FA_BROOM ); + ImGui::Spacing(); ImGui::PopFont(); animTime += ImGui::GetIO().DeltaTime; tracy::DrawWaitingDots( animTime ); @@ -1337,7 +1342,7 @@ static void DrawContents() ImGui::TextUnformatted( "easy-to-handle manner." ); ImGui::Separator(); ImGui::TextUnformatted( "Would you like to enable achievements?" ); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); tracy::TextDisabledUnformatted( "You can change this setting later in the global settings." ); ImGui::PopFont(); ImGui::Separator(); @@ -1361,7 +1366,7 @@ static void DrawContents() { ImGui::PushStyleVar( ImGuiStyleVar_WindowRounding, 16 * dpiScale ); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); const auto starSize = ImGui::CalcTextSize( ICON_FA_STAR ); ImGui::PopFont(); @@ -1438,7 +1443,7 @@ static void DrawContents() } } } - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); tracy::TextColoredUnformatted( color, ICON_FA_STAR ); ImGui::PopFont(); @@ -1449,7 +1454,7 @@ static void DrawContents() const auto th = ImGui::GetTextLineHeight(); ImGui::SetCursorPosY( cursor.y - th * 0.175f ); ImGui::TextUnformatted( aItem->name ); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::SetCursorPos( cursor + ImVec2( starSize.x + ImGui::GetStyle().ItemSpacing.x, th ) ); tracy::TextDisabledUnformatted( "Click to open" ); ImGui::PopFont(); diff --git a/profiler/src/profiler/TracyAchievementData.cpp b/profiler/src/profiler/TracyAchievementData.cpp index 5bf167bb..36e3c257 100644 --- a/profiler/src/profiler/TracyAchievementData.cpp +++ b/profiler/src/profiler/TracyAchievementData.cpp @@ -12,7 +12,7 @@ AchievementItem ai_samplingIntro = { "samplingIntro", "Sampling program executio ImGui::TextWrapped( "Sampling program execution is a great way to find out where the hot spots are in your program. It can be used to find out which functions take the most time, or which lines of code are executed the most often." ); ImGui::TextWrapped( "While instrumentation requires changes to your code, sampling does not. However, because of the way it works, the results are coarser and it's not possible to know when functions are called or when they return." ); ImGui::TextWrapped( "Sampling is automatic on Linux. On Windows, you must run the profiled application as an administrator for it to work." ); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] ); ImGui::TextWrapped( "Depending on your system configuration, some additional steps may be required. Please refer to the user manual for more information." ); ImGui::PopStyleColor(); @@ -27,7 +27,7 @@ AchievementItem ai_100million = { "100million", "It's over 100 million!", [](){ ImGui::TextWrapped( "Tracy can handle a lot of data. How about 100 million zones in a single trace? Add a lot of zones to your program and see how it handles it!" ); ImGui::TextWrapped( "Capturing a long-running profile trace is easy. Need to profile an hour of your program execution? You can do it." ); ImGui::TextWrapped( "Note that it doesn't make much sense to instrument every little function you might have. The cost of the instrumentation itself will be higher than the cost of the function in such a case." ); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] ); ImGui::TextWrapped( "Keep in mind that the more zones you have, the more memory and CPU time the profiler will use. Be careful not to run out of memory." ); ImGui::TextWrapped( "To capture 100 million zones, you will need approximately 4 GB of RAM." ); @@ -70,11 +70,11 @@ void SomeFunction() ImGui::TextWrapped( "Instrumentation is a powerful feature that allows you to see the exact runtime of each call to the selected set of functions. The downside is that it takes a bit of manual work to get it set up." ); ImGui::TextWrapped( "To get started, open a source file and include the Tracy.hpp header. This will give you access to a variety of macros provided by Tracy. Next, add the ZoneScoped macro to the beginning of one of your functions, like this:" ); - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); PrintSource( sc.get() ); ImGui::PopFont(); ImGui::TextWrapped( "Now, when you profile your application, you will see a new zone appear on the timeline for each call to the function. This allows you to see how much time is spent in each call and how many times the function is called." ); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] ); ImGui::TextWrapped( "Note: The ZoneScoped macro is just one of the many macros provided by Tracy. See the documentation for more information." ); ImGui::TextWrapped( "The above description applies to C++ code, but things are done similarly in other programming languages. Refer to the documentation for your language for more information." ); @@ -111,7 +111,7 @@ void Render() ImGui::TextWrapped( "In addition to instrumenting functions, you can also instrument frames. This allows you to see how much time is spent in each frame of your application." ); ImGui::TextWrapped( "To instrument frames, you need to add the FrameMark macro at the beginning of each frame. This can be done in the main loop of your application, or in a separate function that is called at the beginning of each frame." ); - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); PrintSource( sc.get() ); ImGui::PopFont(); ImGui::TextWrapped( "When you profile your application, you will see a new frame appear on the timeline each time the FrameMark macro is called. This allows you to see how much time is spent in each frame and how many frames are rendered per second." ); diff --git a/profiler/src/profiler/TracyBadVersion.cpp b/profiler/src/profiler/TracyBadVersion.cpp index 91560553..901f36d2 100644 --- a/profiler/src/profiler/TracyBadVersion.cpp +++ b/profiler/src/profiler/TracyBadVersion.cpp @@ -1,6 +1,7 @@ #include #include "imgui.h" +#include "../Fonts.hpp" #include "IconsFontAwesome6.h" #include "TracyBadVersion.hpp" @@ -13,7 +14,7 @@ namespace tracy namespace detail { -void BadVersionImpl( BadVersionState& badVer, ImFont* big ) +void BadVersionImpl( BadVersionState& badVer ) { assert( badVer.state != BadVersionState::Ok ); @@ -40,7 +41,7 @@ void BadVersionImpl( BadVersionState& badVer, ImFont* big ) } if( ImGui::BeginPopupModal( "Bad file", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_TRIANGLE_EXCLAMATION ); ImGui::PopFont(); ImGui::Text( "The file you are trying to open is not a Tracy dump." ); @@ -54,7 +55,7 @@ void BadVersionImpl( BadVersionState& badVer, ImFont* big ) } if( ImGui::BeginPopupModal( "File read error", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_TRIANGLE_EXCLAMATION ); ImGui::PopFont(); ImGui::Text( "The file you are trying to open cannot be mapped to memory." ); @@ -68,7 +69,7 @@ void BadVersionImpl( BadVersionState& badVer, ImFont* big ) } if( ImGui::BeginPopupModal( "Unsupported file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_CLOUD_ARROW_DOWN ); ImGui::PopFont(); ImGui::Text( "The file you are trying to open is unsupported.\nYou should update to Tracy %i.%i.%i or newer and try again.", badVer.version >> 16, ( badVer.version >> 8 ) & 0xFF, badVer.version & 0xFF ); @@ -89,7 +90,7 @@ void BadVersionImpl( BadVersionState& badVer, ImFont* big ) } if( ImGui::BeginPopupModal( "Legacy file version", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_GHOST ); ImGui::PopFont(); ImGui::Text( "You are trying to open a file which was created by legacy version %i.%i.%i.\nUse the update utility from an older version of the profiler to convert the file to a supported version.", badVer.version >> 16, ( badVer.version >> 8 ) & 0xFF, badVer.version & 0xFF ); @@ -103,7 +104,7 @@ void BadVersionImpl( BadVersionState& badVer, ImFont* big ) } if( ImGui::BeginPopupModal( "Trace load failure", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_BOMB ); ImGui::PopFont(); ImGui::TextUnformatted( "The file you are trying to open is corrupted." ); diff --git a/profiler/src/profiler/TracyBadVersion.hpp b/profiler/src/profiler/TracyBadVersion.hpp index 100584f3..42223e0f 100644 --- a/profiler/src/profiler/TracyBadVersion.hpp +++ b/profiler/src/profiler/TracyBadVersion.hpp @@ -5,8 +5,6 @@ #include "../public/common/TracyForceInline.hpp" -struct ImFont; - namespace tracy { @@ -29,10 +27,10 @@ struct BadVersionState namespace detail { -void BadVersionImpl( BadVersionState& badVer, ImFont* big ); +void BadVersionImpl( BadVersionState& badVer ); } -tracy_force_inline void BadVersion( BadVersionState& badVer, ImFont* big ) { if( badVer.state != BadVersionState::Ok ) detail::BadVersionImpl( badVer, big ); } +tracy_force_inline void BadVersion( BadVersionState& badVer ) { if( badVer.state != BadVersionState::Ok ) detail::BadVersionImpl( badVer ); } } diff --git a/profiler/src/profiler/TracyImGui.cpp b/profiler/src/profiler/TracyImGui.cpp index 97d33dba..06284bbf 100644 --- a/profiler/src/profiler/TracyImGui.cpp +++ b/profiler/src/profiler/TracyImGui.cpp @@ -135,16 +135,16 @@ bool PrintTextWrapped( const char* text, const char* end ) auto firstWord = text; while( firstWord < end && *firstWord != ' ' && *firstWord != '\n' ) firstWord++; - auto scale = ImGui::GetIO().FontGlobalScale; + auto fontSize = ImGui::GetFontSize(); auto left = ImGui::GetContentRegionAvail().x; - auto fwLen = ImGui::CalcTextSize( text, firstWord ).x * scale; + auto fwLen = ImGui::CalcTextSize( text, firstWord ).x; if( fwLen > left ) { ImGui::NewLine(); left = ImGui::GetContentRegionAvail().x; } - auto endLine = ImGui::GetFont()->CalcWordWrapPositionA( scale, text, end, left ); + auto endLine = ImGui::GetFont()->CalcWordWrapPosition( fontSize, text, end, left ); ImGui::TextUnformatted( text, endLine ); if( !hovered ) hovered = ImGui::IsItemHovered(); @@ -153,7 +153,7 @@ bool PrintTextWrapped( const char* text, const char* end ) { text = endLine; if( *text == ' ' ) text++; - endLine = ImGui::GetFont()->CalcWordWrapPositionA( scale, text, end, left ); + endLine = ImGui::GetFont()->CalcWordWrapPosition( fontSize, text, end, left ); if( text == endLine ) endLine++; ImGui::TextUnformatted( text, endLine ); if( !hovered ) hovered = ImGui::IsItemHovered(); diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index 0697354a..ebf0ab3c 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -80,7 +80,7 @@ void TracyLlm::Draw() if( IsBusy() ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 ) * 0.5f ) ); TextCentered( ICON_FA_HOURGLASS ); TextCentered( "Please wait..." ); @@ -95,7 +95,7 @@ void TracyLlm::Draw() const auto manualEmbeddingsState = m_tools->GetManualEmbeddingsState(); if( manualEmbeddingsState.inProgress ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 7 ) * 0.5f ) ); TextCentered( ICON_FA_BOOK_BOOKMARK ); ImGui::Spacing(); @@ -317,7 +317,7 @@ void TracyLlm::Draw() if( !m_api->IsConnected() ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 ) * 0.5f ) ); TextCentered( ICON_FA_PLUG_CIRCLE_XMARK ); TextCentered( "No connection to LLM API" ); @@ -329,7 +329,7 @@ void TracyLlm::Draw() const auto& models = m_api->GetModels(); if( models.empty() || m_modelIdx < 0 ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 ) * 0.5f ) ); TextCentered( ICON_FA_WORM ); ImGui::Spacing(); diff --git a/profiler/src/profiler/TracyLlmChat.cpp b/profiler/src/profiler/TracyLlmChat.cpp index ba7d3f76..6af0b7da 100644 --- a/profiler/src/profiler/TracyLlmChat.cpp +++ b/profiler/src/profiler/TracyLlmChat.cpp @@ -137,7 +137,7 @@ bool TracyLlmChat::Turn( TurnRole role, const std::string& content ) ImGui::PushStyleColor( ImGuiCol_Text, roleData.textColor ); if( role == TurnRole::Error ) { - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); ImGui::TextWrapped( "%s", content.c_str() ); ImGui::PopFont(); } @@ -155,7 +155,7 @@ bool TracyLlmChat::Turn( TurnRole role, const std::string& content ) ImGui::TextDisabled( "(%s)", type.c_str() ); if( expand ) { - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); ImGui::TextWrapped( "%s", content.c_str() + tagSize ); ImGui::PopFont(); ImGui::TreePop(); @@ -182,7 +182,7 @@ bool TracyLlmChat::Turn( TurnRole role, const std::string& content ) ImGui::PushID( m_subIdx++ ); if( ImGui::TreeNode( ICON_FA_REPLY " Tool response..." ) ) { - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); ImGui::TextWrapped( "%s", content.c_str() + sizeof( "\n" ) - 1 ); ImGui::PopFont(); ImGui::TreePop(); @@ -312,7 +312,7 @@ void TracyLlmChat::PrintThink( const char* str, size_t size ) void TracyLlmChat::PrintToolCall( const char* str, size_t size ) { ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 0.5f, 0.5f, 0.5f, 1.f ) ); - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); ImGui::TextWrapped( "%.*s", (int)size, str ); ImGui::PopFont(); ImGui::PopStyleColor(); diff --git a/profiler/src/profiler/TracyLlmMarkdown.hpp b/profiler/src/profiler/TracyLlmMarkdown.hpp index a0702d5c..9b5ad698 100644 --- a/profiler/src/profiler/TracyLlmMarkdown.hpp +++ b/profiler/src/profiler/TracyLlmMarkdown.hpp @@ -179,15 +179,15 @@ public: if( header > 0 ) { if( !first && !glue ) ImGui::Dummy( ImVec2( 0, ImGui::GetTextLineHeight() * 0.5f ) ); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); } else if( bold > 0 ) { - ImGui::PushFont( italic > 0 ? g_fonts.boldItalic : g_fonts.bold ); + ImGui::PushFont( italic > 0 ? g_fonts.boldItalic : g_fonts.bold, FontNormal ); } else if( italic > 0 ) { - ImGui::PushFont( g_fonts.italic ); + ImGui::PushFont( g_fonts.italic, FontNormal ); } if( !link.empty() ) ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 0.55f, 0.55f, 1.f, 1.f ) ); Glue(); @@ -229,7 +229,7 @@ public: else { Glue(); - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); PrintTextWrapped( text, text + size ); ImGui::PopFont(); } diff --git a/profiler/src/profiler/TracySourceView.cpp b/profiler/src/profiler/TracySourceView.cpp index 64f1875c..c79948b8 100644 --- a/profiler/src/profiler/TracySourceView.cpp +++ b/profiler/src/profiler/TracySourceView.cpp @@ -1060,7 +1060,7 @@ void SourceView::Render( Worker& worker, View& view ) if( m_symAddr == 0 ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); if( ClipboardButton() ) { std::ostringstream stream; @@ -1073,7 +1073,7 @@ void SourceView::Render( Worker& worker, View& view ) ImGui::SameLine(); if( m_source.filename() ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextFocused( ICON_FA_FILE " File:", m_source.filename() ); ImGui::PopFont(); } @@ -1159,7 +1159,7 @@ void SourceView::RenderSymbolView( Worker& worker, View& view ) const auto shortenName = view.GetShortenName(); auto sym = worker.GetSymbolData( m_symAddr ); assert( sym ); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); if( ButtonDisablable( " " ICON_FA_CARET_LEFT " ", m_historyCursor <= 1 ) ) { @@ -1192,7 +1192,7 @@ void SourceView::RenderSymbolView( Worker& worker, View& view ) TextFocused( ICON_FA_PUZZLE_PIECE " Symbol:", normalized ); ImGui::PopFont(); TooltipNormalizedName( symName, normalized ); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); } } else @@ -1215,7 +1215,7 @@ void SourceView::RenderSymbolView( Worker& worker, View& view ) TextFocused( ICON_FA_PUZZLE_PIECE " Symbol:", normalized ); ImGui::PopFont(); TooltipNormalizedName( symName, normalized ); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); } } ImGui::SameLine(); @@ -1253,7 +1253,7 @@ void SourceView::RenderSymbolView( Worker& worker, View& view ) const auto imageName = worker.GetString( sym->imageName ); char tmp[1024]; snprintf( tmp, 1024, "%s 0x%" PRIx64, imageName, m_baseAddr ); - ImGui::SameLine( ImGui::GetWindowContentRegionMax().x - ImGui::CalcTextSize( tmp ).x - ImGui::GetStyle().FramePadding.x * 2 ); + ImGui::SameLine( ImGui::GetContentRegionAvail().x + ImGui::GetCursorPos().x - ImGui::CalcTextSize( tmp ).x ); ImGui::AlignTextToFramePadding(); TextDisabledUnformatted( tmp ); } @@ -2657,7 +2657,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker if( symData ) { ImGui::SameLine(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::AlignTextToFramePadding(); const auto symName = worker.GetString( symData->name ); const auto normalized = shortenName != ShortenName::Never ? ShortenZoneName( ShortenName::OnlyNormalize, symName ) : symName; @@ -2694,7 +2694,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker if( symData ) { ImGui::SameLine(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::AlignTextToFramePadding(); const auto symName = worker.GetString( symData->name ); const auto normalized = shortenName != ShortenName::Never ? ShortenZoneName( ShortenName::OnlyNormalize, symName ) : symName; @@ -2965,7 +2965,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker } if( ImGui::BeginPopup( "localCallstackPopup" ) ) { - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( "Local call stack:" ); ImGui::PopFont(); const auto lcs = m_localCallstackPopup; @@ -2985,7 +2985,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker m_sourceTooltip.Parse( fn, worker, view ); if( !m_sourceTooltip.empty() ) { - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::TextDisabled( "%s:%i", fn, srcline ); ImGui::PopFont(); ImGui::Separator(); @@ -4005,7 +4005,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr ImGui::TextDisabled( "(0x%" PRIx64 ")", symAddr ); if( normalized != symName && strcmp( normalized, symName ) != 0 ) { - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( symName ); ImGui::PopFont(); } @@ -4038,7 +4038,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr const auto normalized = view.GetShortenName() != ShortenName::Never ? ShortenZoneName( ShortenName::OnlyNormalize, symName ) : symName; ImGui::Text( "%s", normalized ); ImGui::SameLine(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::AlignTextToFramePadding(); ImGui::TextDisabled( "%s:%i", worker.GetString( frame->data[i].file ), frame->data[i].line ); ImGui::PopFont(); @@ -4334,7 +4334,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr } if( normalized != jumpName ) { - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( jumpName ); ImGui::PopFont(); } @@ -4486,7 +4486,7 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr } if( normalized != jumpName && strcmp( normalized, jumpName ) != 0 ) { - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( jumpName ); ImGui::PopFont(); } @@ -5829,7 +5829,7 @@ void SourceView::Save( const Worker& worker, size_t start, size_t stop ) void SourceView::SetFont() { - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 0, 0 ) ); } diff --git a/profiler/src/profiler/TracyTimelineController.cpp b/profiler/src/profiler/TracyTimelineController.cpp index 8796f908..164ce01e 100644 --- a/profiler/src/profiler/TracyTimelineController.cpp +++ b/profiler/src/profiler/TracyTimelineController.cpp @@ -6,6 +6,8 @@ #include "TracyTimelineController.hpp" #include "TracyView.hpp" +#include "../Fonts.hpp" + namespace tracy { @@ -97,7 +99,7 @@ std::optional TimelineController::CalculateScrollPosition() const return std::nullopt; } -void TimelineController::End( double pxns, const ImVec2& wpos, bool hover, bool vcenter, float yMin, float yMax, ImFont* smallFont ) +void TimelineController::End( double pxns, const ImVec2& wpos, bool hover, bool vcenter, float yMin, float yMax ) { auto shouldUpdateCenterItem = [&] () { const auto imguiChangedScroll = m_scroll != ImGui::GetScrollY(); @@ -123,7 +125,7 @@ void TimelineController::End( double pxns, const ImVec2& wpos, bool hover, bool TimelineContext ctx; ctx.w = ImGui::GetContentRegionAvail().x - 1; ctx.ty = ImGui::GetTextLineHeight(); - ImGui::PushFont( smallFont ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ctx.sty = ImGui::GetTextLineHeight(); ImGui::PopFont(); ctx.scale = GetScale(); diff --git a/profiler/src/profiler/TracyTimelineController.hpp b/profiler/src/profiler/TracyTimelineController.hpp index 9bf06433..aebc6073 100644 --- a/profiler/src/profiler/TracyTimelineController.hpp +++ b/profiler/src/profiler/TracyTimelineController.hpp @@ -25,7 +25,7 @@ public: void FirstFrameExpired(); void Begin(); - void End( double pxns, const ImVec2& wpos, bool hover, bool vcenter, float yMin, float yMax, ImFont* smallFont ); + void End( double pxns, const ImVec2& wpos, bool hover, bool vcenter, float yMin, float yMax ); template void AddItem( U* data ) diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index 2aaa4738..10a89865 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -319,7 +319,7 @@ bool View::Draw() if( ImGui::BeginPopupModal( "Protocol mismatch", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_TRIANGLE_EXCLAMATION ); ImGui::PopFont(); ImGui::TextUnformatted( "The client you are trying to connect to uses incompatible protocol version.\nMake sure you are using the same Tracy version on both client and server." ); @@ -345,7 +345,7 @@ bool View::Draw() if( ImGui::BeginPopupModal( "Client not ready", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_LIGHTBULB ); ImGui::PopFont(); ImGui::TextUnformatted( "The client you are trying to connect to is no longer able to sent profiling data,\nbecause another server was already connected to it.\nYou can do the following:\n\n 1. Restart the client application.\n 2. Rebuild the client application with on-demand mode enabled." ); @@ -371,7 +371,7 @@ bool View::Draw() if( ImGui::BeginPopupModal( "Client disconnected", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_HANDSHAKE ); ImGui::PopFont(); ImGui::TextUnformatted( "The client you are trying to connect to has disconnected during the initial\nconnection handshake. Please check your network configuration." ); @@ -398,7 +398,7 @@ bool View::Draw() if( ImGui::BeginPopupModal( "Instrumentation failure", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { const auto& data = m_worker.GetFailureData(); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_SKULL ); ImGui::PopFont(); ImGui::TextUnformatted( "Profiling session terminated due to improper instrumentation.\nPlease correct your program and try again." ); @@ -581,7 +581,7 @@ bool View::Draw() { assert( !m_filenameStaging.empty() ); auto fn = m_filenameStaging.c_str(); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextFocused( "Path:", fn ); ImGui::PopFont(); ImGui::Separator(); @@ -646,7 +646,7 @@ bool View::Draw() if( saveFailed ) ImGui::OpenPopup( "Save failed" ); if( ImGui::BeginPopupModal( "Save failed", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_TRIANGLE_EXCLAMATION ); ImGui::PopFont(); ImGui::TextUnformatted( "Could not save trace at the specified location. Try again somewhere else." ); @@ -685,8 +685,10 @@ bool View::DrawImpl() char tmp[2048]; sprintf( tmp, "%s###Connection", m_worker.GetAddr().c_str() ); ImGui::Begin( tmp, &keepOpen, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse ); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontNormal * 2.f ); + ImGui::Spacing(); TextCentered( ICON_FA_WIFI ); + ImGui::Spacing(); ImGui::PopFont(); ImGui::TextUnformatted( "Waiting for connection..." ); DrawWaitingDots( s_time ); @@ -1329,7 +1331,7 @@ bool View::DrawImpl() } if( ImGui::BeginPopupModal( "Connection lost!", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_PLUG ); ImGui::PopFont(); ImGui::TextUnformatted( @@ -1373,7 +1375,7 @@ void View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before if( m_srcHintCache.empty() ) return; ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 0, 0 ) ); if( separateTooltip ) ImGui::BeginTooltip(); - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); auto& lines = m_srcHintCache.get(); const int start = std::max( 0, (int)srcline - ( before+1 ) ); const int end = std::min( m_srcHintCache.get().size(), srcline + after ); diff --git a/profiler/src/profiler/TracyView_Annotations.cpp b/profiler/src/profiler/TracyView_Annotations.cpp index de3ec717..1b7bfce4 100644 --- a/profiler/src/profiler/TracyView_Annotations.cpp +++ b/profiler/src/profiler/TracyView_Annotations.cpp @@ -84,7 +84,7 @@ void View::DrawAnnotationList() if( m_annotations.empty() ) { ImGui::Separator(); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 ) * 0.5f ) ); TextCentered( ICON_FA_HORSE ); TextCentered( "No annotations" ); diff --git a/profiler/src/profiler/TracyView_Callstack.cpp b/profiler/src/profiler/TracyView_Callstack.cpp index 1658348e..b4d38895 100644 --- a/profiler/src/profiler/TracyView_Callstack.cpp +++ b/profiler/src/profiler/TracyView_Callstack.cpp @@ -288,7 +288,7 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton ) { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( "external" ); ImGui::TableNextColumn(); if( external == 1 ) @@ -312,7 +312,7 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton ) } else { - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( "inline" ); ImGui::PopFont(); } @@ -493,7 +493,7 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton ) { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( "external" ); ImGui::TableNextColumn(); if( external == 1 ) @@ -640,7 +640,7 @@ void View::CallstackTooltipContents( uint32_t idx ) if( frameData->imageName.Active() ) { ImGui::SameLine(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::AlignTextToFramePadding(); TextDisabledUnformatted( m_worker.GetString( frameData->imageName ) ); ImGui::PopFont(); diff --git a/profiler/src/profiler/TracyView_Compare.cpp b/profiler/src/profiler/TracyView_Compare.cpp index e8f32e7c..4c09e8d3 100644 --- a/profiler/src/profiler/TracyView_Compare.cpp +++ b/profiler/src/profiler/TracyView_Compare.cpp @@ -213,7 +213,7 @@ void View::DrawCompare() if( !m_compare.second ) { const auto ty = ImGui::GetTextLineHeight(); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 5 ) * 0.5f ) ); TextCentered( ICON_FA_SCALE_BALANCED ); TextCentered( "Please load a second trace to compare results" ); @@ -252,7 +252,7 @@ void View::DrawCompare() } } ); } - tracy::BadVersion( m_compare.badVer, g_fonts.big ); + tracy::BadVersion( m_compare.badVer ); ImGui::End(); return; } @@ -262,7 +262,7 @@ void View::DrawCompare() if( !m_worker.AreSourceLocationZonesReady() || !m_compare.second->AreSourceLocationZonesReady() ) { const auto ty = ImGui::GetTextLineHeight(); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 - ty ) * 0.5f ) ); TextCentered( ICON_FA_FROG ); TextCentered( "Please wait, computing data..." ); @@ -412,7 +412,7 @@ void View::DrawCompare() { auto it = tfc.find( v ); assert( it != tfc.end() ); - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 0, 0 ) ); PrintFile( it->second.data, it->second.len, 0xFF6666FF ); ImGui::PopStyleVar(); @@ -436,7 +436,7 @@ void View::DrawCompare() { auto it = ofc.find( v ); assert( it != ofc.end() ); - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 0, 0 ) ); PrintFile( it->second.data, it->second.len, 0xFF66DD66 ); ImGui::PopStyleVar(); @@ -458,7 +458,7 @@ void View::DrawCompare() { if( ImGui::TreeNode( v.first ) ) { - ImGui::PushFont( g_fonts.mono ); + ImGui::PushFont( g_fonts.mono, FontNormal ); ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 0, 0 ) ); PrintDiff( v.second ); ImGui::PopStyleVar(); diff --git a/profiler/src/profiler/TracyView_ConnectionState.cpp b/profiler/src/profiler/TracyView_ConnectionState.cpp index bc1daf58..5d618234 100644 --- a/profiler/src/profiler/TracyView_ConnectionState.cpp +++ b/profiler/src/profiler/TracyView_ConnectionState.cpp @@ -16,7 +16,6 @@ bool View::DrawConnection() { const auto scale = GetScale(); const auto ty = ImGui::GetTextLineHeight(); - const auto cs = ty * 0.9f; const auto isConnected = m_worker.IsConnected(); size_t sendQueue; @@ -34,7 +33,8 @@ bool View::DrawConnection() { sprintf( buf, "%6.2f Mbps", mbps ); } - ImGui::Dummy( ImVec2( cs, 0 ) ); + ImGui::AlignTextToFramePadding(); + TextColoredUnformatted( isConnected ? 0xFF2222CC : 0xFF444444, ICON_FA_CIRCLE ); ImGui::SameLine(); ImGui::PlotLines( buf, mbpsVector.data(), mbpsVector.size(), 0, nullptr, 0, std::numeric_limits::max(), ImVec2( 150 * scale, 0 ) ); TextDisabledUnformatted( "Ratio" ); @@ -77,9 +77,6 @@ bool View::DrawConnection() } } - const auto wpos = ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin(); - ImGui::GetWindowDrawList()->AddCircleFilled( wpos + ImVec2( 1 + cs * 0.5, 3 + ty * 1.75 ), cs * 0.5, isConnected ? 0xFF2222CC : 0xFF444444, 10 ); - { std::lock_guard lock( m_worker.GetDataLock() ); ImGui::SameLine(); @@ -169,7 +166,7 @@ bool View::DrawConnection() if( ImGui::BeginPopupModal( "Confirm trace discard", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextCentered( ICON_FA_TRIANGLE_EXCLAMATION ); ImGui::PopFont(); ImGui::TextUnformatted( "All unsaved profiling data will be lost!" ); diff --git a/profiler/src/profiler/TracyView_ContextSwitch.cpp b/profiler/src/profiler/TracyView_ContextSwitch.cpp index 4977153a..0be3f9e5 100644 --- a/profiler/src/profiler/TracyView_ContextSwitch.cpp +++ b/profiler/src/profiler/TracyView_ContextSwitch.cpp @@ -237,14 +237,14 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector< { TextFocused( "Wait reason:", DecodeContextSwitchReasonCode( prev.Reason() ) ); ImGui::SameLine(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::AlignTextToFramePadding(); TextDisabledUnformatted( DecodeContextSwitchReason( prev.Reason() ) ); ImGui::PopFont(); } TextFocused( "Wait state:", DecodeContextSwitchStateCode( prev.State() ) ); ImGui::SameLine(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::AlignTextToFramePadding(); TextDisabledUnformatted( DecodeContextSwitchState( prev.State() ) ); ImGui::PopFont(); @@ -540,7 +540,7 @@ void View::DrawWaitStacks() ImGui::BeginChild( "##waitstacks" ); if( stacks.empty() ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 ) * 0.5f ) ); TextCentered( ICON_FA_KIWI_BIRD ); TextCentered( "No wait stacks to display" ); diff --git a/profiler/src/profiler/TracyView_CpuData.cpp b/profiler/src/profiler/TracyView_CpuData.cpp index 2f4a49dc..42a3a5e1 100644 --- a/profiler/src/profiler/TracyView_CpuData.cpp +++ b/profiler/src/profiler/TracyView_CpuData.cpp @@ -150,7 +150,7 @@ bool View::DrawCpuData( const TimelineContext& ctx, const std::vector& vec, const std::functiontype], item.GetIdx() ); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); ImGui::TextUnformatted( buf ); ImGui::PopFont(); } diff --git a/profiler/src/profiler/TracyView_Samples.cpp b/profiler/src/profiler/TracyView_Samples.cpp index b7c2b46f..b18d2fca 100644 --- a/profiler/src/profiler/TracyView_Samples.cpp +++ b/profiler/src/profiler/TracyView_Samples.cpp @@ -110,7 +110,7 @@ void View::DrawSamplesStatistics( Vector& data, int64_t timeRange, Accu if( data.empty() ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 ) * 0.5f ) ); TextCentered( ICON_FA_HIPPO ); TextCentered( "No entries to be displayed" ); @@ -844,13 +844,13 @@ void View::DrawSampleParents() const auto symName = m_worker.GetString( symbol->name ); const char* normalized = m_vd.shortenName != ShortenName::Never ? ShortenZoneName( ShortenName::OnlyNormalize, symName ) : nullptr; - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextFocused( "Function:", normalized ? normalized : symName ); if( normalized ) { ImGui::PopFont(); TooltipNormalizedName( symName, normalized ); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); } if( symbol->isInline ) { @@ -1013,7 +1013,7 @@ void View::DrawSampleParents() { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( "external" ); ImGui::TableNextColumn(); if( external == 1 ) @@ -1037,7 +1037,7 @@ void View::DrawSampleParents() } else { - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( "inline" ); ImGui::PopFont(); } @@ -1213,7 +1213,7 @@ void View::DrawSampleParents() { ImGui::TableNextRow(); ImGui::TableNextColumn(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); TextDisabledUnformatted( "external" ); ImGui::TableNextColumn(); if( external == 1 ) diff --git a/profiler/src/profiler/TracyView_Statistics.cpp b/profiler/src/profiler/TracyView_Statistics.cpp index 6386ead3..f8101897 100644 --- a/profiler/src/profiler/TracyView_Statistics.cpp +++ b/profiler/src/profiler/TracyView_Statistics.cpp @@ -48,7 +48,7 @@ void View::DrawStatistics() if( !m_worker.AreSourceLocationZonesReady() && ( !m_worker.AreCallstackSamplesReady() || m_worker.GetCallstackSampleCount() == 0 ) ) { const auto ty = ImGui::GetTextLineHeight(); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 - ty ) * 0.5f ) ); TextCentered( ICON_FA_HIPPO ); TextCentered( "Please wait, computing data..." ); @@ -597,7 +597,7 @@ void View::DrawStatistics() { if( srcloc.empty() ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 2 ) * 0.5f ) ); TextCentered( ICON_FA_HIPPO ); TextCentered( "No entries to be displayed" ); diff --git a/profiler/src/profiler/TracyView_Timeline.cpp b/profiler/src/profiler/TracyView_Timeline.cpp index 9fde9c8d..803fcb69 100644 --- a/profiler/src/profiler/TracyView_Timeline.cpp +++ b/profiler/src/profiler/TracyView_Timeline.cpp @@ -404,7 +404,7 @@ void View::DrawTimeline() } const auto vcenter = verticallyCenterTimeline && drawMouseLine && m_viewMode == ViewMode::Paused; - m_tc.End( pxns, wpos, hover, vcenter, yMin, yMax, g_fonts.small ); + m_tc.End( pxns, wpos, hover, vcenter, yMin, yMax ); ImGui::EndChild(); m_lockHighlight = m_nextLockHighlight; diff --git a/profiler/src/profiler/TracyView_TraceInfo.cpp b/profiler/src/profiler/TracyView_TraceInfo.cpp index 5736c8f1..1b7a8425 100644 --- a/profiler/src/profiler/TracyView_TraceInfo.cpp +++ b/profiler/src/profiler/TracyView_TraceInfo.cpp @@ -17,7 +17,7 @@ void View::DrawInfo() ImGui::SetNextWindowSize( ImVec2( 400 * scale, 650 * scale ), ImGuiCond_FirstUseEver ); ImGui::Begin( "Trace information", &m_showInfo, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse ); if( ImGui::GetCurrentWindowRead()->SkipItems ) { ImGui::End(); return; } - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextFocused( "Program:", m_worker.GetCaptureProgram().c_str() ); ImGui::PopFont(); const auto exectime = m_worker.GetExecutableTime(); @@ -696,7 +696,7 @@ void View::DrawInfo() char buf[128]; const auto ty = ImGui::GetFontSize(); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); const auto sty = ImGui::GetFontSize(); ImGui::PopFont(); const float margin = round( ty * 0.5 ); @@ -711,7 +711,7 @@ void View::DrawInfo() for( auto& package : topology ) { sprintf( buf, ICON_FA_BOX " Package %" PRIu32, package.first ); - ImGui::PushFont( g_fonts.small ); + ImGui::PushFont( g_fonts.normal, FontSmall ); const auto psz = ImGui::CalcTextSize( buf ).x; if( psz > ptsz ) ptsz = psz; ImGui::PopFont(); diff --git a/profiler/src/profiler/TracyView_ZoneInfo.cpp b/profiler/src/profiler/TracyView_ZoneInfo.cpp index e3f754c2..e4c68c79 100644 --- a/profiler/src/profiler/TracyView_ZoneInfo.cpp +++ b/profiler/src/profiler/TracyView_ZoneInfo.cpp @@ -381,7 +381,7 @@ void View::DrawZoneInfoWindow() const auto tid = threadData->id; if( m_worker.HasZoneExtra( ev ) && m_worker.GetZoneExtra( ev ).name.Active() ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextFocused( "Zone name:", m_worker.GetString( m_worker.GetZoneExtra( ev ).name ) ); ImGui::PopFont(); if( srcloc.name.active ) @@ -409,7 +409,7 @@ void View::DrawZoneInfoWindow() } else if( srcloc.name.active ) { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextFocused( "Zone name:", m_worker.GetString( srcloc.name ) ); ImGui::PopFont(); ImGui::SameLine(); @@ -420,7 +420,7 @@ void View::DrawZoneInfoWindow() } else { - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextFocused( "Function:", m_worker.GetString( srcloc.function ) ); ImGui::PopFont(); ImGui::SameLine(); @@ -1513,7 +1513,7 @@ void View::DrawGpuInfoWindow() ImGui::Separator(); const auto tid = GetZoneThread( ev ); - ImGui::PushFont( g_fonts.big ); + ImGui::PushFont( g_fonts.normal, FontBig ); TextFocused( "Zone name:", m_worker.GetString( srcloc.name ) ); ImGui::PopFont(); ImGui::SameLine(); diff --git a/profiler/src/profiler/TracyView_ZoneTimeline.cpp b/profiler/src/profiler/TracyView_ZoneTimeline.cpp index 9406d8b0..a3099194 100644 --- a/profiler/src/profiler/TracyView_ZoneTimeline.cpp +++ b/profiler/src/profiler/TracyView_ZoneTimeline.cpp @@ -570,7 +570,7 @@ void View::DrawZoneList( const TimelineContext& ctx, const std::vector