Skip to content

Commit

Permalink
More small refinements to cursor help text
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed Sep 1, 2024
1 parent 80e0682 commit 6b69d6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/ngscopeclient/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,10 @@ void MainWindow::StatusBar(float height)

for(auto it : m_statusHelp)
{
//empty help text is a legal way to remove a previous help message, don't draw this
if(it.second.empty())
continue;

ImGui::Image(GetTexture(it.first), iconSize);
ImGui::SameLine();
ImGui::TextUnformatted(it.second.c_str());
Expand Down
20 changes: 12 additions & 8 deletions src/ngscopeclient/WaveformGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ void WaveformGroup::RenderMarkers(ImVec2 pos, ImVec2 size)
{
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
m_mouseOverMarker = true;
m_parent->AddStatusHelp("mouse_lmb", "");
m_parent->AddStatusHelp("mouse_lmb_drag", "Move marker");

//Start dragging if clicked
Expand Down Expand Up @@ -722,14 +723,10 @@ void WaveformGroup::RenderXAxisCursors(ImVec2 pos, ImVec2 size)
}
ImGui::EndChild();

//Child window doesn't get mouse events (this flag is needed so we can pass mouse events to the WaveformArea's)
//So we have to do all of our interaction processing inside the top level window
DoCursor(0, DRAG_STATE_X_CURSOR0);
if(m_xAxisCursorMode == X_CURSOR_DUAL)
DoCursor(1, DRAG_STATE_X_CURSOR1);

//Help text related to cursors
if(ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows) && !IsMouseOverButtonInWaveformArea())
//Default help text related to cursors (may change if we're over a cursor)
if(ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows) &&
!IsMouseOverButtonInWaveformArea() &&
(m_dragState == DRAG_STATE_NONE) )
{
if(m_xAxisCursorMode != X_CURSOR_NONE)
m_parent->AddStatusHelp("mouse_lmb", "Place first cursor");
Expand All @@ -739,6 +736,12 @@ void WaveformGroup::RenderXAxisCursors(ImVec2 pos, ImVec2 size)
if( (m_dragState == DRAG_STATE_X_CURSOR0) || (m_dragState == DRAG_STATE_X_CURSOR1) )
m_parent->AddStatusHelp("mouse_lmb_drag", "Move cursor");

//Child window doesn't get mouse events (this flag is needed so we can pass mouse events to the WaveformArea's)
//So we have to do all of our interaction processing inside the top level window
DoCursor(0, DRAG_STATE_X_CURSOR0);
if(m_xAxisCursorMode == X_CURSOR_DUAL)
DoCursor(1, DRAG_STATE_X_CURSOR1);

//If not currently dragging, a click places cursor 0 and starts dragging cursor 1 (if enabled)
//Don't process this if a popup is open
if( ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows) &&
Expand Down Expand Up @@ -795,6 +798,7 @@ void WaveformGroup::DoCursor(int iCursor, DragState state)
if( fabs(mouse.x - xpos) < searchRadius)
{
ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW);
m_parent->AddStatusHelp("mouse_lmb", "");
m_parent->AddStatusHelp("mouse_lmb_drag", "Move cursor");

//Start dragging if clicked
Expand Down

0 comments on commit 6b69d6c

Please sign in to comment.