Skip to content

Commit 0af25a7

Browse files
author
Frederic Borry
committed
Merged code from upstream to open properties on double click + close nodes by default.
1 parent b2ed0eb commit 0af25a7

2 files changed

Lines changed: 36 additions & 24 deletions

File tree

src/ngscopeclient/StreamBrowserDialog.cpp

Lines changed: 34 additions & 22 deletions
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 *
@@ -1714,11 +1714,9 @@ void StreamBrowserDialog::renderChannelNode(shared_ptr<Instrument> instrument, s
17141714
auto awgchan = dynamic_cast<FunctionGeneratorChannel *>(channel);
17151715
auto dmmchan = dynamic_cast<MultimeterChannel *>(channel);
17161716
bool renderProps = false;
1717-
bool isDigital = false;
17181717
if (scopechan)
17191718
{
17201719
renderProps = scopechan->IsEnabled();
1721-
isDigital = scopechan->GetType(0) == Stream::STREAM_TYPE_DIGITAL;
17221720
}
17231721
else if(awg && awgchan)
17241722
{
@@ -1734,19 +1732,32 @@ void StreamBrowserDialog::renderChannelNode(shared_ptr<Instrument> instrument, s
17341732
if(!hasChildren)
17351733
flags |= ImGuiTreeNodeFlags_Leaf;
17361734

1737-
//Collapse all scope channel nodes by default to reduce clutter
1738-
if(isDigital || scopechan)
1739-
{}
1740-
1741-
else
1742-
flags |= ImGuiTreeNodeFlags_DefaultOpen;
1735+
flags |= ImGuiTreeNodeFlags_OpenOnArrow;
17431736

17441737
bool open = ImGui::TreeNodeEx(
17451738
channel->GetDisplayName().c_str(),
17461739
flags);
17471740
if (channel->m_displaycolor != "")
17481741
ImGui::PopStyleColor();
17491742

1743+
//Open properties dialog on double click
1744+
if(ImGui::IsItemHovered())
1745+
{
1746+
if(ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
1747+
{
1748+
if(scopechan)
1749+
m_parent->ShowChannelProperties(scopechan);
1750+
else if(psuchan)
1751+
m_parent->ShowInstrumentProperties(psu);
1752+
else if(awgchan)
1753+
m_parent->ShowInstrumentProperties(awg);
1754+
else
1755+
LogWarning("Don't know how to open channel properties yet\n");
1756+
}
1757+
1758+
m_parent->AddStatusHelp("mouse_lmb_double", "Open properties");
1759+
}
1760+
17501761
//Single stream: drag the stream not the channel
17511762
if(singleStream)
17521763
{
@@ -1911,7 +1922,7 @@ void StreamBrowserDialog::renderChannelNode(shared_ptr<Instrument> instrument, s
19111922
for(size_t j=0; j<streamCount; j++)
19121923
{
19131924
// Iterate on each stream
1914-
renderStreamNode(instrument,channel,j,!singleStream,renderProps,(j==(streamCount-1)));
1925+
renderStreamNode(instrument,channel,j,!singleStream,renderProps);
19151926
}
19161927
}
19171928
ImGui::PopID();
@@ -2006,9 +2017,8 @@ void StreamBrowserDialog::renderChannelProperties(std::shared_ptr<Oscilloscope>
20062017
@param streamIndex the index of the stream to render
20072018
@param renderName true if the name of the stream should be rendred as a selectable item
20082019
@param renderProps true if a properties block should be rendered for this stream
2009-
@param isLast true if this is the last stream of the channel
20102020
*/
2011-
void StreamBrowserDialog::renderStreamNode(shared_ptr<Instrument> instrument, InstrumentChannel* channel, size_t streamIndex, bool renderName, bool renderProps, bool isLast)
2021+
void StreamBrowserDialog::renderStreamNode(shared_ptr<Instrument> instrument, InstrumentChannel* channel, size_t streamIndex, bool renderName, bool renderProps)
20122022
{
20132023
auto scope = std::dynamic_pointer_cast<Oscilloscope>(instrument);
20142024
auto scopechan = dynamic_cast<OscilloscopeChannel *>(channel);
@@ -2020,7 +2030,6 @@ void StreamBrowserDialog::renderStreamNode(shared_ptr<Instrument> instrument, In
20202030
if (renderName)
20212031
{
20222032
ImGui::Selectable(channel->GetStreamName(streamIndex).c_str());
2023-
20242033
StreamDescriptor s(channel, streamIndex);
20252034
if(ImGui::BeginDragDropSource())
20262035
{
@@ -2044,7 +2053,7 @@ void StreamBrowserDialog::renderStreamNode(shared_ptr<Instrument> instrument, In
20442053
if(renderProps && scopechan)
20452054
{
20462055
// If no properties are available for this stream, only show a "Properties" link if it is the last stream of the channel/filter
2047-
bool hasProps = isLast;
2056+
bool hasProps = false;
20482057
switch (type)
20492058
{
20502059
case Stream::STREAM_TYPE_ANALOG:
@@ -2110,9 +2119,6 @@ void StreamBrowserDialog::renderStreamNode(shared_ptr<Instrument> instrument, In
21102119
}
21112120
//fall through
21122121
default:
2113-
{
2114-
ImGui::TextUnformatted("No properties");
2115-
}
21162122
break;
21172123
}
21182124
EndBlock();
@@ -2136,14 +2142,22 @@ void StreamBrowserDialog::renderFilterNode(Filter* filter)
21362142
ImGui::PushStyleColor(ImGuiCol_Text, ColorFromString(filter->m_displaycolor));
21372143

21382144
//Don't expand filters with a single stream by default
2139-
int flags = 0;
2145+
int flags = ImGuiTreeNodeFlags_OpenOnArrow;
21402146
if(!singleStream)
21412147
flags |= ImGuiTreeNodeFlags_DefaultOpen;
21422148

21432149
bool open = ImGui::TreeNodeEx(filter->GetDisplayName().c_str(), flags);
21442150
if (filter->m_displaycolor != "")
21452151
ImGui::PopStyleColor();
21462152

2153+
//Open properties dialog on double click
2154+
if(ImGui::IsItemHovered())
2155+
{
2156+
if(ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
2157+
m_parent->ShowChannelProperties(filter);
2158+
m_parent->AddStatusHelp("mouse_lmb_double", "Open properties");
2159+
}
2160+
21472161
//Single stream: drag the stream not the filter
21482162
if(singleStream)
21492163
{
@@ -2178,10 +2192,8 @@ void StreamBrowserDialog::renderFilterNode(Filter* filter)
21782192

21792193
size_t streamCount = filter->GetStreamCount();
21802194
for(size_t j=0; j<streamCount; j++)
2181-
{
2182-
// Iterate on each stream
2183-
renderStreamNode(nullptr,filter,j,!singleStream,true,(j==(streamCount-1)));
2184-
}
2195+
renderStreamNode(nullptr,filter,j,!singleStream,true);
2196+
21852197
ImGui::PopID();
21862198
}
21872199

src/ngscopeclient/StreamBrowserDialog.h

Lines changed: 2 additions & 2 deletions
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 *
@@ -179,7 +179,7 @@ class StreamBrowserDialog : public Dialog
179179
void renderChannelProperties(std::shared_ptr<Oscilloscope> scope, OscilloscopeChannel* scopechan, size_t channelIndex, std::shared_ptr<OscilloscopeState> scopeState);
180180

181181
// Rendering of a stream node
182-
void renderStreamNode(std::shared_ptr<Instrument> instrument, InstrumentChannel* channel, size_t streamIndex, bool renderName, bool renderProps, bool isLast);
182+
void renderStreamNode(std::shared_ptr<Instrument> instrument, InstrumentChannel* channel, size_t streamIndex, bool renderName, bool renderProps);
183183

184184
// Rendering of an Filter node
185185
void renderFilterNode(Filter* filter);

0 commit comments

Comments
 (0)