Skip to content

Commit

Permalink
Now span new waveform groups as tabs rather than splitting by default…
Browse files Browse the repository at this point in the history
…. Spawn filter graph editor as soon as application starts.
  • Loading branch information
azonenberg committed Aug 23, 2024
1 parent cd38518 commit e9be98e
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/ngscopeclient/Dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class Dialog
void RenderAsChild();
virtual bool DoRender() =0;

const std::string& GetID()
{ return m_id; }

//TODO: this might be better off as a global method?
static bool Combo(const std::string& label, const std::vector<std::string>& items, int& selection);
static bool UnitInputWithImplicitApply(
Expand Down
6 changes: 4 additions & 2 deletions src/ngscopeclient/FilterGraphEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2432,9 +2432,11 @@ void FilterGraphEditor::HandleBackgroundContextMenu()
{
if(ax::NodeEditor::GetNodeCount() == 0)
{
ImGui::BeginTooltip();
if(ImGui::BeginItemTooltip())
{
ImGui::TextUnformatted("Right click to create a waveform\nor import data from a file");
ImGui::EndTooltip();
ImGui::EndTooltip();
}
}
}
ax::NodeEditor::Resume();
Expand Down
42 changes: 31 additions & 11 deletions src/ngscopeclient/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ void MainWindow::InitializeDefaultSession()
{
LogTrace("Initializing new session\n");
LogIndenter li;

//Spawn the graph editor
m_graphEditor = make_shared<FilterGraphEditor>(m_session, this);
AddDialog(m_graphEditor);

//Dock it
m_dockRequests.push_back(DockDialogRequest(m_graphEditor));
}

void MainWindow::CloseSession()
Expand All @@ -217,6 +224,7 @@ void MainWindow::CloseSession()
m_waveformGroups.clear();
m_newWaveformGroups.clear();
m_splitRequests.clear();
m_dockRequests.clear();
m_groupsToClose.clear();
m_pendingChannelDisplayRequests.clear();

Expand Down Expand Up @@ -1234,17 +1242,6 @@ void MainWindow::DockingArea()
while(node->ChildNodes[0])
node = node->ChildNodes[0];

//See if the node has children in it
if(!node->Windows.empty())
{
LogTrace("Windows already in node, splitting it\n");
ImGuiID idLeft;
ImGuiID idRight;

ImGui::DockBuilderSplitNode(node->ID, ImGuiDir_Up, 0.5, &idLeft, &idRight);
node = ImGui::DockBuilderGetNode(idLeft);
}

//Dock new waveform groups by default
for(auto& g : m_newWaveformGroups)
ImGui::DockBuilderDockWindow(g->GetID().c_str(), node->ID);
Expand All @@ -1256,6 +1253,29 @@ void MainWindow::DockingArea()
m_newWaveformGroups.clear();
}

//Process dockable dialogs
else if(!m_dockRequests.empty())
{
//Find the top/leftmost leaf node in the docking tree
auto topNode = ImGui::DockBuilderGetNode(dockspace_id);
if(topNode != nullptr)
{
LogTrace("Docking dialog\n");

//Traverse down the top/left of the tree as long as such a node exists
auto node = topNode;
while(node->ChildNodes[0])
node = node->ChildNodes[0];

for(auto dock : m_dockRequests)
ImGui::DockBuilderDockWindow(dock.m_dlg->GetID().c_str(), node->ID);
m_dockRequests.clear();

//Finish up
ImGui::DockBuilderFinish(dockspace_id);
}
}

ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), /*dockspace_flags*/0, /*window_class*/nullptr);
ImGui::End();
}
Expand Down
16 changes: 16 additions & 0 deletions src/ngscopeclient/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ class SplitGroupRequest
StreamDescriptor m_stream;
};

/**
@brief Pending request to dock a dialog as a top level tab (TODO other options)
*/
class DockDialogRequest
{
public:
DockDialogRequest(std::shared_ptr<Dialog> dlg)
: m_dlg(dlg)
{}

std::shared_ptr<Dialog> m_dlg;
};

/**
@brief Top level application window
*/
Expand Down Expand Up @@ -379,6 +392,9 @@ class MainWindow : public VulkanWindow
///@brief Pending requests to split waveform groups
std::vector<SplitGroupRequest> m_splitRequests;

///@brief Pending requests to dock dialogs
std::vector<DockDialogRequest> m_dockRequests;

///@brief Pending requests to close waveform groups
std::vector<size_t> m_groupsToClose;

Expand Down
2 changes: 2 additions & 0 deletions src/ngscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3036,6 +3036,8 @@ void WaveformArea::EdgeDropArea(const string& name, ImVec2 start, ImVec2 size, I
case ImGuiDir_Down:
center.y = start.y + size.y - fillSizeY;
break;
default:
break;
}

//Draw background and outline
Expand Down

0 comments on commit e9be98e

Please sign in to comment.