22* *
33* ngscopeclient *
44* *
5- * Copyright (c) 2012-2024 Andrew D. Zonenberg *
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 *
3535
3636#include " ngscopeclient.h"
3737#include " AddInstrumentDialog.h"
38+ #include " MainWindow.h"
3839
3940using namespace std ;
4041
@@ -44,17 +45,22 @@ using namespace std;
4445AddInstrumentDialog::AddInstrumentDialog (
4546 const string& title,
4647 const string& nickname,
47- Session& session,
48+ Session* session,
49+ MainWindow* parent,
4850 const string& driverType)
49- : Dialog(title, string(" AddInstrument" ) + to_string_hex(reinterpret_cast <uintptr_t >(this )), ImVec2(600 , 150 ))
50- , m_session(session)
51+ : Dialog(
52+ title,
53+ string (" AddInstrument" ) + to_string_hex(reinterpret_cast <uintptr_t >(this )),
54+ ImVec2(600 , 150 ),
55+ session,
56+ parent)
5157 , m_nickname(nickname)
5258 , m_selectedDriver(0 )
5359 , m_selectedTransport(0 )
5460{
5561 SCPITransport::EnumTransports (m_transports);
5662
57- m_drivers = session. GetDriverNamesForType (driverType);
63+ m_drivers = session-> GetDriverNamesForType (driverType);
5864}
5965
6066AddInstrumentDialog::~AddInstrumentDialog ()
@@ -72,13 +78,16 @@ AddInstrumentDialog::~AddInstrumentDialog()
7278 */
7379bool AddInstrumentDialog::DoRender ()
7480{
81+ auto tutorial = m_parent->GetTutorialWizard ();
82+
7583 ImGui::InputText (" Nickname" , &m_nickname);
7684 HelpMarker (
7785 " Text nickname for this instrument so you can distinguish between multiple similar devices.\n "
7886 " \n "
7987 " This is shown on the list of recent instruments, to disambiguate channel names in multi-instrument setups, etc." );
8088
81- Combo (" Driver" , m_drivers, m_selectedDriver);
89+ bool dropdownOpen = false ;
90+ Combo (" Driver" , m_drivers, m_selectedDriver, &dropdownOpen);
8291 HelpMarker (
8392 " Select the instrument driver to use.\n "
8493 " \n "
@@ -88,7 +97,22 @@ bool AddInstrumentDialog::DoRender()
8897 " \n "
8998 " Check the user manual for details of what driver to use with a given instrument." );
9099
91- Combo (" Transport" , m_transports, m_selectedTransport);
100+ // Show speech bubble for tutorial
101+ bool showedBubble = false ;
102+ if (tutorial &&
103+ (tutorial->GetCurrentStep () == TutorialWizard::TUTORIAL_02_CONNECT) &&
104+ (m_drivers[m_selectedDriver] != " demo" ) &&
105+ !dropdownOpen )
106+ {
107+ auto pos = ImGui::GetCursorScreenPos ();
108+ ImVec2 anchorPos (pos.x + 10 *ImGui::GetFontSize (), pos.y );
109+ tutorial->DrawSpeechBubble (anchorPos, ImGuiDir_Up, " Select the \" demo\" driver" );
110+ showedBubble = true ;
111+ }
112+ else if (dropdownOpen) // suppress further bubbles if dropdown is active
113+ showedBubble = true ;
114+
115+ Combo (" Transport" , m_transports, m_selectedTransport, &dropdownOpen);
92116 HelpMarker (
93117 " Select the SCPI transport for the connection between your computer and the instrument.\n "
94118 " \n "
@@ -104,6 +128,21 @@ bool AddInstrumentDialog::DoRender()
104128 }
105129 );
106130
131+ // Show speech bubble for tutorial
132+ if (tutorial &&
133+ (tutorial->GetCurrentStep () == TutorialWizard::TUTORIAL_02_CONNECT) &&
134+ (m_transports[m_selectedTransport] != " null" ) &&
135+ !dropdownOpen &&
136+ !showedBubble)
137+ {
138+ auto pos = ImGui::GetCursorScreenPos ();
139+ ImVec2 anchorPos (pos.x + 10 *ImGui::GetFontSize (), pos.y );
140+ tutorial->DrawSpeechBubble (anchorPos, ImGuiDir_Up, " Select the \" null\" transport" );
141+ showedBubble = true ;
142+ }
143+ else if (dropdownOpen) // suppress further bubbles if dropdown is active
144+ showedBubble = true ;
145+
107146 ImGui::InputText (" Path" , &m_path);
108147 HelpMarker (
109148 " Transport-specific description of how to connect to the instrument.\n " ,
@@ -170,6 +209,6 @@ SCPITransport* AddInstrumentDialog::MakeTransport()
170209
171210bool AddInstrumentDialog::DoConnect (SCPITransport* transport)
172211{
173- m_session. CreateAndAddInstrument (m_drivers[m_selectedDriver], transport, m_nickname);
212+ m_session-> CreateAndAddInstrument (m_drivers[m_selectedDriver], transport, m_nickname);
174213 return true ;
175214}
0 commit comments