refactor(ui): app-wide compact, translucent tooltips

Add material::Tooltip / BeginTooltip / EndTooltip wrappers (tooltip_style.h)
that scope a small window padding (8x4, dpi-scaled) and ~85% opacity to
tooltips only, then route the tooltip call sites through them. Menus and combo
dropdowns are untouched (they keep the global opaque PopupBg).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-27 21:26:52 -05:00
parent 69a6fb3e64
commit 2e8e214689
24 changed files with 160 additions and 92 deletions

View File

@@ -7,6 +7,7 @@
#include "../colors.h"
#include "../typography.h"
#include "../layout.h"
#include "../tooltip_style.h"
#include "imgui.h"
#include "imgui_internal.h"
@@ -271,7 +272,7 @@ inline bool IconButton(const char* icon, const char* tooltip, bool enabled) {
// Tooltip
if (tooltip && hovered) {
ImGui::SetTooltip("%s", tooltip);
material::Tooltip("%s", tooltip);
}
return pressed && enabled;

View File

@@ -6,6 +6,7 @@
#include "colors.h"
#include "type.h"
#include "tooltip_style.h"
#include "../layout.h"
#include "../schema/element_styles.h"
#include "../schema/color_var_resolver.h"

View File

@@ -0,0 +1,66 @@
// DragonX Wallet - ImGui Edition
// Copyright 2024-2026 The Hush Developers
// Released under the GPLv3
//
// App-wide tooltip styling: a compact (small padding) and slightly-translucent tooltip. ImGui has
// no tooltip-specific padding (tooltips inherit WindowPadding, shared with every window) and PopupBg
// is shared with menus/combos, so we can't restyle tooltips via the global style without side
// effects. Instead, every tooltip goes through these wrappers, which scope the style to the tooltip:
// dragonx::ui::material::Tooltip("fmt", ...); // replaces ImGui::SetTooltip
// if (material::BeginTooltip()) { ...; material::EndTooltip(); } // replaces ImGui::Begin/EndTooltip
#pragma once
#include <cstdarg>
#include "imgui.h"
#include "../layout.h"
namespace dragonx {
namespace ui {
namespace material {
// Scope tooltip-only styling: small padding + a slightly-transparent background.
inline void PushTooltipStyle()
{
const float s = Layout::dpiScale();
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.0f * s, 4.0f * s));
ImVec4 bg = ImGui::GetStyle().Colors[ImGuiCol_PopupBg];
bg.w = 0.85f; // slightly transparent (the global PopupBg is ~0.98 opaque)
ImGui::PushStyleColor(ImGuiCol_PopupBg, bg);
}
inline void PopTooltipStyle()
{
ImGui::PopStyleColor();
ImGui::PopStyleVar();
}
// Drop-in replacement for ImGui::SetTooltip (same printf-style signature). (No IM_FMTARGS: GCC
// rejects the format attribute on an inline definition; call sites already passed SetTooltip's check.)
inline void Tooltip(const char* fmt, ...)
{
PushTooltipStyle();
va_list args;
va_start(args, fmt);
ImGui::SetTooltipV(fmt, args);
va_end(args);
PopTooltipStyle();
}
// Drop-in replacements for ImGui::BeginTooltip / ImGui::EndTooltip (must be paired, as before).
inline bool BeginTooltip()
{
PushTooltipStyle();
return ImGui::BeginTooltip();
}
inline void EndTooltip()
{
ImGui::EndTooltip();
PopTooltipStyle();
}
} // namespace material
} // namespace ui
} // namespace dragonx