Skip to content

Commit 2213d34

Browse files
committed
MainWindow/Dialog: prevent mouse cursor from obscuring tooltip text
1 parent b397e0e commit 2213d34

5 files changed

Lines changed: 18 additions & 3 deletions

File tree

release-notes/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ We try to maintain compatibility with older versions of ngscopeclient but occasi
3232

3333
## Other changes since v0.1.1
3434

35-
* General UI overhaul of stream browser to make things more intuitive and reduce the number of clicks needed to perform common tasks
35+
* GUI: General UI overhaul of stream browser to make things more intuitive and reduce the number of clicks needed to perform common tasks
36+
* GUI: Adjusted tooltip layout code to prevent mouse cursor from blocking the first character of a tooltip

src/ngscopeclient/Dialog.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* *
33
* ngscopeclient *
44
* *
5-
* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
5+
* Copyright (c) 2012-2026 Andrew D. Zonenberg and contributors *
66
* All rights reserved. *
77
* *
88
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -34,6 +34,7 @@
3434
*/
3535
#include "ngscopeclient.h"
3636
#include "Dialog.h"
37+
#include "MainWindow.h"
3738

3839
using namespace std;
3940

@@ -185,6 +186,8 @@ void Dialog::Tooltip(const string& str, bool allowDisabled)
185186

186187
if(ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort | extraFlags))
187188
{
189+
MainWindow::SetTooltipPosition();
190+
188191
ImGui::BeginTooltip();
189192
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50);
190193
ImGui::TextUnformatted(str.c_str());
@@ -202,6 +205,8 @@ void Dialog::HelpMarker(const string& header, const vector<string>& bullets)
202205
ImGui::TextDisabled("(?)");
203206
if(ImGui::IsItemHovered(ImGuiHoveredFlags_DelayShort))
204207
{
208+
MainWindow::SetTooltipPosition();
209+
205210
ImGui::BeginTooltip();
206211
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50);
207212
ImGui::TextUnformatted(header.c_str());

src/ngscopeclient/MainWindow.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ class MainWindow : public VulkanWindow
137137

138138
void OnCursorMoved(int64_t offset);
139139

140+
///@brief Helper for making sure tooltips aren't obscured by the mouse
141+
static void SetTooltipPosition()
142+
{
143+
auto pos = ImGui::GetIO().MousePos;
144+
ImGui::SetNextWindowPos(ImVec2(pos.x + ImGui::GetFontSize(), pos.y), ImGuiCond_Always, ImVec2(0.0, 0.5));
145+
}
146+
140147
void NavigateToTimestamp(
141148
int64_t stamp,
142149
int64_t duration = 0,

src/ngscopeclient/WaveformArea.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,6 +2971,7 @@ void WaveformArea::RenderEyePatternTooltip(ImVec2 start, ImVec2 size)
29712971
}
29722972
auto ber = eyedata->GetBERAtPoint(delta.x, delta.y, eyedata->GetWidth() / 2, ymid);
29732973

2974+
MainWindow::SetTooltipPosition();
29742975
ImGui::BeginTooltip();
29752976
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50);
29762977

@@ -3916,6 +3917,7 @@ void WaveformArea::ChannelButton(shared_ptr<DisplayedChannel> chan, size_t index
39163917
}
39173918
tooltip = Trim(tooltip);
39183919

3920+
MainWindow::SetTooltipPosition();
39193921
ImGui::BeginTooltip();
39203922
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50);
39213923
ImGui::TextUnformatted(tooltip.c_str());

0 commit comments

Comments
 (0)