Skip to content

Commit fe86fbe

Browse files
committed
Continued work on tutorial flow. See #950.
1 parent 44a9983 commit fe86fbe

File tree

5 files changed

+59
-16
lines changed

5 files changed

+59
-16
lines changed

src/ngscopeclient/AddInstrumentDialog.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ AddInstrumentDialog::~AddInstrumentDialog()
7878
*/
7979
bool AddInstrumentDialog::DoRender()
8080
{
81+
//Get the tutorial wizard and see if we're on the "connect to scope" page
8182
auto tutorial = m_parent->GetTutorialWizard();
83+
if(tutorial && (tutorial->GetCurrentStep() != TutorialWizard::TUTORIAL_02_CONNECT) )
84+
tutorial = nullptr;
8285

8386
ImGui::InputText("Nickname", &m_nickname);
8487
HelpMarker(
@@ -99,10 +102,7 @@ bool AddInstrumentDialog::DoRender()
99102

100103
//Show speech bubble for tutorial
101104
bool showedBubble = false;
102-
if(tutorial &&
103-
(tutorial->GetCurrentStep() == TutorialWizard::TUTORIAL_02_CONNECT) &&
104-
(m_drivers[m_selectedDriver] != "demo") &&
105-
!dropdownOpen )
105+
if(tutorial && (m_drivers[m_selectedDriver] != "demo") && !dropdownOpen )
106106
{
107107
auto pos = ImGui::GetCursorScreenPos();
108108
ImVec2 anchorPos(pos.x + 10*ImGui::GetFontSize(), pos.y);
@@ -129,11 +129,7 @@ bool AddInstrumentDialog::DoRender()
129129
);
130130

131131
//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)
132+
if(tutorial && (m_transports[m_selectedTransport] != "null") && !dropdownOpen && !showedBubble)
137133
{
138134
auto pos = ImGui::GetCursorScreenPos();
139135
ImVec2 anchorPos(pos.x + 10*ImGui::GetFontSize(), pos.y);
@@ -161,20 +157,33 @@ bool AddInstrumentDialog::DoRender()
161157
if(m_nickname.empty())
162158
{
163159
ShowErrorPopup(
164-
"Nickname error",
165-
"Nickname shall be not empty");
160+
"Nickname error",
161+
"The nickname cannot be left blank");
166162
}
167163
else
168164
{
169165
auto transport = MakeTransport();
170166
if(transport)
171167
{
172168
if(DoConnect(transport))
169+
{
170+
if(tutorial)
171+
tutorial->AdvanceToNextStep();
172+
173173
return false;
174+
}
174175
}
175176
}
176177
}
177178

179+
if(tutorial && !dropdownOpen && !showedBubble)
180+
{
181+
auto pos = ImGui::GetCursorScreenPos();
182+
ImVec2 anchorPos(pos.x + 2*ImGui::GetFontSize(), pos.y);
183+
tutorial->DrawSpeechBubble(anchorPos, ImGuiDir_Up, "Add the scope to your session");
184+
showedBubble = true;
185+
}
186+
178187
return true;
179188
}
180189

src/ngscopeclient/MainWindow.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ void MainWindow::InitializeDefaultSession()
233233
m_initialWorkspaceDockRequest = w;
234234

235235
//Spawn the tutorial if requested
236-
if(m_session.GetPreferences().GetBool("Help.Wizards.first_run_wizard"))
236+
//if(m_session.GetPreferences().GetBool("Help.Wizards.first_run_wizard"))
237+
if(false)
237238
{
238239
m_tutorialDialog = make_shared<TutorialWizard>(&m_session, this);
239240
AddDialog(m_tutorialDialog);
@@ -1030,6 +1031,8 @@ void MainWindow::ToolbarButtons()
10301031

10311032
bool multigroup = (m_session.GetTriggerGroups().size() > 1);
10321033

1034+
auto buttonStartPos = ImGui::GetCursorScreenPos();;
1035+
10331036
//Trigger button group
10341037
if(ImGui::ImageButton("trigger-start", GetTexture("trigger-start"), buttonsize))
10351038
m_session.ArmTrigger(TriggerGroup::TRIGGER_TYPE_NORMAL);
@@ -1041,6 +1044,17 @@ void MainWindow::ToolbarButtons()
10411044
}
10421045

10431046
ImGui::SameLine(0.0, 0.0);
1047+
1048+
if(m_tutorialDialog && (m_tutorialDialog->GetCurrentStep() == TutorialWizard::TUTORIAL_03_ACQUIRE) )
1049+
{
1050+
auto buttonEndPos = ImGui::GetCursorScreenPos();
1051+
ImVec2 anchorPos(
1052+
buttonEndPos.x - ImGui::GetFontSize(),
1053+
buttonStartPos.y + 2*ImGui::GetFontSize());
1054+
m_tutorialDialog->DrawSpeechBubble(anchorPos, ImGuiDir_Up, " Arm the trigger");
1055+
//FIXME better handling of going off edge
1056+
}
1057+
10441058
if(ImGui::ImageButton("trigger-single", GetTexture("trigger-single"), buttonsize))
10451059
m_session.ArmTrigger(TriggerGroup::TRIGGER_TYPE_SINGLE);
10461060
Dialog::Tooltip("Arm the trigger in one-shot mode");

src/ngscopeclient/TutorialWizard.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ TutorialWizard::TutorialWizard(Session* session, MainWindow* parent)
5252
m_markdownText.push_back(ReadDataFile("md/tutorial_00_intro.md"));
5353
m_markdownText.push_back(ReadDataFile("md/tutorial_01_addinstrument.md"));
5454
m_markdownText.push_back(ReadDataFile("md/tutorial_02_connect.md"));
55+
m_markdownText.push_back(ReadDataFile("md/tutorial_03_acquire.md"));
5556
}
5657

5758
TutorialWizard::~TutorialWizard()
@@ -183,12 +184,25 @@ void TutorialWizard::MakePathSpeechBubble(
183184
float radius)
184185
{
185186
auto size = ImGui::GetFontSize();
186-
187-
//ImGui wants clockwise winding. Starting from the tip of the speech bubble go down, then across
188-
//Angles are measured clockwise from the 3 o'clock position
189187
auto tailWidth = size;
188+
189+
//Default is for the arrow to be 1/4 of the way across
190190
auto leftOverhang = textsize.x / 4;
191+
192+
//Update overhang if the button would go off the start of the window
193+
auto wpos = ImGui::GetWindowPos();
194+
float minleft = wpos.x;
195+
float farleft = anchorPos.x - (leftOverhang + radius);
196+
float offLeftEdge = farleft - minleft;
197+
if(offLeftEdge < 0)
198+
{
199+
//leftOverhang = 0.5*size;
200+
}
201+
191202
auto rightOverhang = textsize.x - leftOverhang;
203+
204+
//ImGui wants clockwise winding. Starting from the tip of the speech bubble go down, then across
205+
//Angles are measured clockwise from the 3 o'clock position
192206
ImVec2 tailCorner(anchorPos.x, anchorPos.y + tailLength);
193207
ImVec2 topRight(tailCorner.x + rightOverhang, tailCorner.y);
194208
ImVec2 topRightRadiusCenter(topRight.x, topRight.y + radius);

src/ngscopeclient/TutorialWizard.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class TutorialWizard : public Dialog
5050
{
5151
TUTORIAL_00_INTRO,
5252
TUTORIAL_01_ADDINSTRUMENT,
53-
TUTORIAL_02_CONNECT
53+
TUTORIAL_02_CONNECT,
54+
TUTORIAL_03_ACQUIRE
5455
};
5556

5657
TutorialStep GetCurrentStep()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Acquire Data
2+
3+
We're connected to the scope. Let's start capturing data!
4+
5+
Press the "normal trigger" button on the toolbar.

0 commit comments

Comments
 (0)