Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Utils/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../WeatherEditor/EditorWindow.h"
#include "FileSystem.h"
#include "Menu.h"
#include "Menu/Fonts.h"
#include "Menu/IconLoader.h"
#include "Menu/ThemeManager.h"
#include "ShaderCache.h"
Expand Down Expand Up @@ -41,18 +42,29 @@

namespace Util
{
HoverTooltipWrapper::HoverTooltipWrapper()
HoverTooltipWrapper::HoverTooltipWrapper() :
previousFont(nullptr)
{
hovered = ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal | ImGuiHoveredFlags_AllowWhenDisabled);
if (hovered) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
// Apply Subtext font for consistent tooltip styling
if (auto* menu = globals::menu) {
if (auto* subtextFont = menu->GetFont(Menu::FontRole::Subtext)) {
previousFont = ImGui::GetFont();
ImGui::PushFont(subtextFont);
}
}
}
}

HoverTooltipWrapper::~HoverTooltipWrapper()
{
if (hovered) {
if (previousFont) {
ImGui::PopFont();
}
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/UI.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ namespace Util
* if (auto _tt = Util::HoverTooltipWrapper()){
* ImGui::Text("What the tooltip says.");
* }
*
* Automatically applies the Subtext font role for consistent tooltip styling.
*/
class HoverTooltipWrapper
{
private:
bool hovered;
ImFont* previousFont;

public:
HoverTooltipWrapper();
Expand Down