diff --git a/src/ngscopeclient/FilterGraphEditor.cpp b/src/ngscopeclient/FilterGraphEditor.cpp index d2a1393b..1d0b141d 100644 --- a/src/ngscopeclient/FilterGraphEditor.cpp +++ b/src/ngscopeclient/FilterGraphEditor.cpp @@ -423,6 +423,8 @@ ax::NodeEditor::PinId FilterGraphEditor::GetSinkPinForLink(StreamDescriptor sour */ bool FilterGraphEditor::DoRender() { + bool windowHovered = ImGui::IsWindowHovered(); + ax::NodeEditor::SetCurrentEditor(m_context); ax::NodeEditor::Begin("Filter Graph", ImVec2(0, 0)); @@ -601,7 +603,7 @@ bool FilterGraphEditor::DoRender() HandleOverlaps(); //Add top level help text if there's nothing else - if(!ax::NodeEditor::GetHoveredNode() && !ax::NodeEditor::GetHoveredLink()) + if(!ax::NodeEditor::GetHoveredNode() && !ax::NodeEditor::GetHoveredLink() && windowHovered) { m_parent->AddStatusHelp("mouse_lmb_drag", "Select multiple"); m_parent->AddStatusHelp("mouse_wheel", "Zoom"); diff --git a/src/ngscopeclient/FilterGraphWorkspace.cpp b/src/ngscopeclient/FilterGraphWorkspace.cpp index bbf47c29..c6992139 100644 --- a/src/ngscopeclient/FilterGraphWorkspace.cpp +++ b/src/ngscopeclient/FilterGraphWorkspace.cpp @@ -36,6 +36,7 @@ #include "FilterGraphWorkspace.h" #include "FilterGraphEditor.h" #include "CreateFilterBrowser.h" +#include "MainWindow.h" using namespace std; @@ -44,9 +45,10 @@ using namespace std; FilterGraphWorkspace::FilterGraphWorkspace( Session& session, + MainWindow* parent, shared_ptr graphEditor, shared_ptr palette) - : Workspace(session) + : Workspace(session, parent) , m_firstRun(true) , m_graphEditor(graphEditor) , m_palette(palette) @@ -54,36 +56,12 @@ FilterGraphWorkspace::FilterGraphWorkspace( m_title = "Filter Graph"; } -bool FilterGraphWorkspace::Render() +void FilterGraphWorkspace::DoRender(ImGuiID id) { - //Closed, nothing to do - if(!m_open) - return false; - - auto dockspace_id = ImGui::GetID(m_id.c_str()); - - string name = m_title + "###" + m_id; - ImGui::SetNextWindowSize(m_defaultSize, ImGuiCond_Appearing); - if(!ImGui::Begin(name.c_str(), &m_open, ImGuiWindowFlags_NoCollapse)) - { - //If we get here, the window is tabbed out or the content area is otherwise not visible. - //Need to keep the dockspace node alive still, though! - ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_KeepAliveOnly, nullptr); - - ImGui::End(); - return true; - } - - if(ImGui::BeginPopupContextItem()) - { - ImGui::InputText("Name", &m_title); - ImGui::EndPopup(); - } - //First run? special case if(m_firstRun) { - auto topNode = ImGui::DockBuilderGetNode(dockspace_id); + auto topNode = ImGui::DockBuilderGetNode(id); if(topNode) { //Split the top into two sub nodes @@ -93,7 +71,7 @@ bool FilterGraphWorkspace::Render() ImGui::DockBuilderDockWindow(m_graphEditor->GetTitleAndID().c_str(), leftPanelID); ImGui::DockBuilderDockWindow(m_palette->GetTitleAndID().c_str(), rightPanelID); - ImGui::DockBuilderFinish(dockspace_id); + ImGui::DockBuilderFinish(id); //Remove references in case user wants to close the dialogs later m_graphEditor = nullptr; @@ -101,9 +79,4 @@ bool FilterGraphWorkspace::Render() m_firstRun = false; } } - - ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), 0, nullptr); - - ImGui::End(); - return true; } diff --git a/src/ngscopeclient/FilterGraphWorkspace.h b/src/ngscopeclient/FilterGraphWorkspace.h index 7dbfc9c1..3dc625bc 100644 --- a/src/ngscopeclient/FilterGraphWorkspace.h +++ b/src/ngscopeclient/FilterGraphWorkspace.h @@ -38,6 +38,7 @@ #include "Workspace.h" class FilterGraphEditor; class CreateFilterBrowser; +class MainWindow; /** @brief Helper class for building the default filter graph editor workspace @@ -47,15 +48,16 @@ class FilterGraphWorkspace : public Workspace public: FilterGraphWorkspace( Session& session, + MainWindow* parent, std::shared_ptr graphEditor, std::shared_ptr palette ); virtual ~FilterGraphWorkspace() {} - virtual bool Render() override; - protected: + virtual void DoRender(ImGuiID id) override; + bool m_firstRun; std::shared_ptr m_graphEditor; std::shared_ptr m_palette; diff --git a/src/ngscopeclient/MainWindow.cpp b/src/ngscopeclient/MainWindow.cpp index 6a030a8c..c5e0ec74 100644 --- a/src/ngscopeclient/MainWindow.cpp +++ b/src/ngscopeclient/MainWindow.cpp @@ -276,7 +276,7 @@ void MainWindow::InitializeDefaultSession() AddDialog(m_filterPalette); //Spawn a new workspace for the filter graph stuff - auto w = make_shared(m_session, m_graphEditor, m_filterPalette); + auto w = make_shared(m_session, this, m_graphEditor, m_filterPalette); m_workspaces.emplace(w); //Dock it @@ -2737,7 +2737,7 @@ bool MainWindow::LoadUIConfiguration(int version, const YAML::Node& node) LogIndenter li2; for(auto w : workspaces) - m_workspaces.emplace(make_shared(w, m_session)); + m_workspaces.emplace(make_shared(w, m_session, this)); } //Measurements diff --git a/src/ngscopeclient/MainWindow_Menus.cpp b/src/ngscopeclient/MainWindow_Menus.cpp index 4bbbe4fa..b09dcc85 100644 --- a/src/ngscopeclient/MainWindow_Menus.cpp +++ b/src/ngscopeclient/MainWindow_Menus.cpp @@ -1397,7 +1397,7 @@ void MainWindow::WindowMenu() ImGui::EndDisabled(); if(ImGui::MenuItem("New Workspace")) - m_workspaces.emplace(make_shared(m_session)); + m_workspaces.emplace(make_shared(m_session, this)); ImGui::EndMenu(); } diff --git a/src/ngscopeclient/WaveformGroup.cpp b/src/ngscopeclient/WaveformGroup.cpp index 90432bbb..caf2fea9 100644 --- a/src/ngscopeclient/WaveformGroup.cpp +++ b/src/ngscopeclient/WaveformGroup.cpp @@ -145,6 +145,7 @@ bool WaveformGroup::Render() if(!ImGui::Begin(GetID().c_str(), &open, ImGuiWindowFlags_NoScrollWithMouse)) { //tabbed out, don't draw anything until we're back in the foreground + TitleHoverHelp(); ImGui::End(); return true; } @@ -157,11 +158,7 @@ bool WaveformGroup::Render() ImGui::EndPopup(); } - if(ImGui::IsItemHovered()) - { - m_parent->AddStatusHelp("mouse_lmb_drag", "Move group"); - m_parent->AddStatusHelp("mouse_rmb", "Rename group"); - } + TitleHoverHelp(); auto pos = ImGui::GetCursorScreenPos(); ImVec2 clientArea = ImGui::GetContentRegionMax(); @@ -243,6 +240,15 @@ bool WaveformGroup::Render() return open; } +void WaveformGroup::TitleHoverHelp() +{ + if(ImGui::IsItemHovered()) + { + m_parent->AddStatusHelp("mouse_lmb_drag", "Move group"); + m_parent->AddStatusHelp("mouse_rmb", "Rename group"); + } +} + /** @brief Run the popup window with cursor values */ diff --git a/src/ngscopeclient/WaveformGroup.h b/src/ngscopeclient/WaveformGroup.h index 910f41f7..e484f140 100644 --- a/src/ngscopeclient/WaveformGroup.h +++ b/src/ngscopeclient/WaveformGroup.h @@ -143,6 +143,8 @@ class WaveformGroup void RenderMarkers(ImVec2 pos, ImVec2 size); void DoCursorReadouts(); + void TitleHoverHelp(); + float GetInBandPower(WaveformBase* wfm, Unit yunit, int64_t t1, int64_t t2); bool IsMouseOverButtonInWaveformArea(); diff --git a/src/ngscopeclient/Workspace.cpp b/src/ngscopeclient/Workspace.cpp index 3a12e910..481201dd 100644 --- a/src/ngscopeclient/Workspace.cpp +++ b/src/ngscopeclient/Workspace.cpp @@ -35,14 +35,16 @@ #include "ngscopeclient.h" #include "Workspace.h" #include "Session.h" +#include "MainWindow.h" using namespace std; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Construction / destruction -Workspace::Workspace(Session& session) +Workspace::Workspace(Session& session, MainWindow* parent) : m_session(session) + , m_parent(parent) , m_open(true) , m_title("New Workspace") , m_defaultSize(800, 600) @@ -52,8 +54,9 @@ Workspace::Workspace(Session& session) m_id = string("Workspace ") + to_string(id); } -Workspace::Workspace(const YAML::Node& node, Session& session) +Workspace::Workspace(const YAML::Node& node, Session& session, MainWindow* parent) : m_session(session) + , m_parent(parent) , m_open(true) , m_defaultSize(800, 600) { @@ -94,6 +97,8 @@ bool Workspace::Render() ImGui::SetNextWindowSize(m_defaultSize, ImGuiCond_Appearing); if(!ImGui::Begin(name.c_str(), &m_open, ImGuiWindowFlags_NoCollapse)) { + TitleHoverHelp(); + //If we get here, the window is tabbed out or the content area is otherwise not visible. //Need to keep the dockspace node alive still, though! ImGui::DockSpace(id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_KeepAliveOnly, nullptr); @@ -108,14 +113,21 @@ bool Workspace::Render() ImGui::EndPopup(); } - if(ImGui::BeginItemTooltip()) - { - ImGui::Text("Right click to rename this workspace"); - ImGui::EndTooltip(); - } + TitleHoverHelp(); + + DoRender(id); ImGui::DockSpace(id, ImVec2(0.0f, 0.0f), 0, nullptr); ImGui::End(); return true; } + +void Workspace::TitleHoverHelp() +{ + if(ImGui::IsItemHovered()) + { + m_parent->AddStatusHelp("mouse_lmb_drag", "Move workspace"); + m_parent->AddStatusHelp("mouse_rmb", "Rename workspace"); + } +} diff --git a/src/ngscopeclient/Workspace.h b/src/ngscopeclient/Workspace.h index 80c61337..1a42ce71 100644 --- a/src/ngscopeclient/Workspace.h +++ b/src/ngscopeclient/Workspace.h @@ -35,15 +35,17 @@ #ifndef Workspace_h #define Workspace_h +class MainWindow; + class Workspace { public: - Workspace(const YAML::Node& node, Session& session); - Workspace(Session& session); + Workspace(const YAML::Node& node, Session& session, MainWindow* parent); + Workspace(Session& session, MainWindow* parent); virtual ~Workspace() {} - virtual bool Render(); + bool Render(); YAML::Node Serialize(); @@ -51,7 +53,13 @@ class Workspace { return m_title + "###" + m_id; } protected: + virtual void DoRender([[maybe_unused]] ImGuiID id) + {} + + void TitleHoverHelp(); + Session& m_session; + MainWindow* m_parent; bool m_open; std::string m_id;