UndoRedo extension::
has_undo_snapshot(timestamp) to query whether one can undo to a snapshot with a specific timestamp. Useful for notifications, that want to Undo a specific operation, to verify whether such operation is still valid.
This commit is contained in:
parent
7b9f2093bb
commit
d70d54d4d3
@ -548,6 +548,7 @@ public:
|
||||
void load_snapshot(size_t timestamp, Slic3r::Model& model, Slic3r::GUI::GLGizmosManager& gizmos);
|
||||
|
||||
bool has_undo_snapshot() const;
|
||||
bool has_undo_snapshot(size_t time_to_load) const;
|
||||
bool has_redo_snapshot() const;
|
||||
bool undo(Slic3r::Model &model, const Slic3r::GUI::Selection &selection, Slic3r::GUI::GLGizmosManager &gizmos, const SnapshotData &snapshot_data, size_t jump_to_time);
|
||||
bool redo(Slic3r::Model &model, Slic3r::GUI::GLGizmosManager &gizmos, size_t jump_to_time);
|
||||
@ -907,6 +908,11 @@ bool StackImpl::has_undo_snapshot() const
|
||||
return -- it != m_snapshots.begin();
|
||||
}
|
||||
|
||||
bool StackImpl::has_undo_snapshot(size_t time_to_load) const
|
||||
{
|
||||
return time_to_load < m_active_snapshot_time && std::binary_search(m_snapshots.begin(), m_snapshots.end(), Snapshot(time_to_load));
|
||||
}
|
||||
|
||||
bool StackImpl::has_redo_snapshot() const
|
||||
{
|
||||
assert(this->valid());
|
||||
@ -1083,6 +1089,7 @@ void Stack::release_least_recently_used() { pimpl->release_least_recently_used()
|
||||
void Stack::take_snapshot(const std::string& snapshot_name, const Slic3r::Model& model, const Slic3r::GUI::Selection& selection, const Slic3r::GUI::GLGizmosManager& gizmos, const SnapshotData &snapshot_data)
|
||||
{ pimpl->take_snapshot(snapshot_name, model, selection, gizmos, snapshot_data); }
|
||||
bool Stack::has_undo_snapshot() const { return pimpl->has_undo_snapshot(); }
|
||||
bool Stack::has_undo_snapshot(size_t time_to_load) const { return pimpl->has_undo_snapshot(time_to_load); }
|
||||
bool Stack::has_redo_snapshot() const { return pimpl->has_redo_snapshot(); }
|
||||
bool Stack::undo(Slic3r::Model& model, const Slic3r::GUI::Selection& selection, Slic3r::GUI::GLGizmosManager& gizmos, const SnapshotData &snapshot_data, size_t time_to_load)
|
||||
{ return pimpl->undo(model, selection, gizmos, snapshot_data, time_to_load); }
|
||||
|
@ -107,6 +107,8 @@ public:
|
||||
// To be queried to enable / disable the Undo / Redo buttons at the UI.
|
||||
bool has_undo_snapshot() const;
|
||||
bool has_redo_snapshot() const;
|
||||
// To query whether one can undo to a snapshot. Useful for notifications, that want to Undo a specific operation.
|
||||
bool has_undo_snapshot(size_t time_to_load) const;
|
||||
|
||||
// Roll back the time. If time_to_load is SIZE_MAX, the previous snapshot is activated.
|
||||
// Undoing an action may need to take a snapshot of the current application state, so that redo to the current state is possible.
|
||||
|
Loading…
Reference in New Issue
Block a user