18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 08:17:09 +01:00

fix(editor): the lay panel says "Laid" only while the step it was laid with is on top of the history

lay_panel_state() told the line laid from laid_step == m_history.size(). Lay, Ctrl+Z, then any one-step edit made the size the
same again, and the panel said "Laid … Ctrl+Z undoes" for a line that was gone; at the cap of 200 steps it stayed "laid" for
good. The panel now compares the serial of the step on top of the history (EditorSnapshot::serial), which each step made has
of its own.
This commit is contained in:
maj00r
2026-11-24 18:56:11 +01:00
parent 2217da8648
commit da1ef628bf
2 changed files with 14 additions and 5 deletions
+6 -2
View File
@@ -54,6 +54,7 @@ http://mozilla.org/MPL/2.0/.
#include "world/Sweep.h"
#include <array>
#include <cstdint>
#include <map>
#include <tuple>
#include <chrono>
@@ -1141,6 +1142,8 @@ class editor_mode : public application_mode, private editor_track::observer, pri
// false, with the reason, when one of the paths can't be changed, its file not taking the changes back
static bool tracks_editable(std::vector<TTrack *> const &Tracks, std::string &Reason);
void trim_history();
// the serial of the step on top of the history, 0 with none
std::uint64_t history_top() const;
void restore_track_snapshot(EditorSnapshot const &Snapshot, std::vector<EditorSnapshot> &Opposite, bool const Undo);
// changes of the kept alignments and switches go into the last step of the history, made just before them
void records_to_history();
@@ -1920,9 +1923,10 @@ class editor_mode : public application_mode, private editor_track::observer, pri
bool settings_open{false};
bool details_open{false};
bool notes_open{false};
// the status tells of a line laid just now, as long as the history stays at the step it was laid with
// the status tells of a line laid just now, as long as the history stays at the step it was laid with: the serial of the step on
// top then, not the size of the history, which an undo and another step make the same again
bool laid_now{false};
std::size_t laid_step{0};
std::uint64_t laid_step{0};
// the line laid last, told in the inspector while the last of its tracks stays the selection the laying left
struct laid_curve
{
+8 -3
View File
@@ -2141,7 +2141,7 @@ void editor_mode::lay_finish(editor_track::snap_target const &End)
tool.points.clear();
tool.modes.clear();
tool.start = {};
tool.laid_step = m_history.size();
tool.laid_step = history_top();
straight_refresh();
}
@@ -2152,7 +2152,7 @@ void editor_mode::lay_told(double const Length, std::size_t const Tracks)
tool.status_time = ImGui::GetTime();
tool.laid_now = true;
tool.notes_open = false;
tool.laid_step = m_history.size();
tool.laid_step = history_top();
}
void editor_mode::lay_enter()
@@ -2352,13 +2352,18 @@ alignment::limits editor_mode::laying_norms() const
return norms;
}
std::uint64_t editor_mode::history_top() const
{
return m_history.empty() ? 0 : m_history.back().serial;
}
editor_mode::lay_state editor_mode::lay_panel_state() const
{
if (m_extend.active)
return lay_state::extending;
if (false == m_lay.points.empty())
return lay_state::clicking;
if (m_lay.laid_now && m_lay.laid_step == m_history.size())
if (m_lay.laid_now && m_lay.laid_step == history_top())
return lay_state::laid;
return lay_state::ready;
}