File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ namespace mathplotter {
2020 std::size_t rowIndex;
2121 std::string expression;
2222 sf::Color color;
23+ bool shouldRemove{false };
2324 };
2425
2526 class UserInterface {
Original file line number Diff line number Diff line change @@ -144,22 +144,30 @@ namespace mathplotter {
144144 )
145145 };
146146
147- if (renderer->IsValid ()) {
148- m_functionRenderers[submission->rowIndex ] =
149- std::move (renderer);
150-
151- m_userInterface.SetFunctionError (
152- submission->rowIndex ,
153- false
154- );
147+ if (submission->shouldRemove ) {
148+ if (submission->rowIndex < m_functionRenderers.size ()) {
149+ m_functionRenderers[submission->rowIndex ].reset ();
150+ }
155151 } else {
156- m_functionRenderers[submission->rowIndex ].reset ();
157-
158- m_userInterface.SetFunctionError (
159- submission->rowIndex ,
160- true
161- );
152+ if (renderer->IsValid ()) {
153+ m_functionRenderers[submission->rowIndex ] =
154+ std::move (renderer);
155+
156+ m_userInterface.SetFunctionError (
157+ submission->rowIndex ,
158+ false
159+ );
160+ } else {
161+ m_functionRenderers[submission->rowIndex ].reset ();
162+
163+ m_userInterface.SetFunctionError (
164+ submission->rowIndex ,
165+ true
166+ );
167+ }
162168 }
169+
170+
163171 }
164172
165173 // Render User Interface
Original file line number Diff line number Diff line change @@ -487,8 +487,19 @@ namespace mathplotter {
487487 )
488488 };
489489
490- if (ImGui::IsItemEdited ()) {
490+ if (
491+ ImGui::IsItemEdited () &&
492+ m_functionRows[i].expression .empty ()
493+ ) {
491494 m_functionRows[i].isSubmitted = false ;
495+ m_functionRows[i].hasError = false ;
496+
497+ submission = FunctionSubmission{
498+ i,
499+ " " ,
500+ ToSfmlColor (m_functionRows[i].color ),
501+ true
502+ };
492503 }
493504
494505 if (
You can’t perform that action at this time.
0 commit comments