Skip to content

Commit

Permalink
Undo for Script Edits
Browse files Browse the repository at this point in the history
  • Loading branch information
markusmoenig committed Dec 26, 2024
1 parent a4a9514 commit 6b432f0
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion creator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ theframework = { git = "https://github.com/markusmoenig/TheFramework", features
# theframework = { path = "../../TheFramework", features = [
# "ui",
# "code",
# "winit_app",
# # "winit_app",
# ], default-features = true }
# theframework = { version = "0.1.20", features = [
# "ui",
Expand Down
132 changes: 70 additions & 62 deletions creator/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1487,72 +1487,80 @@ impl TheTrait for Editor {
self.server.stop();
update_server_icons = true;
} else if id.name == "Undo" || id.name == "Redo" {
let mut manager = UNDOMANAGER.lock().unwrap();

if manager.context == UndoManagerContext::Region {
if id.name == "Undo" {
manager.undo(
self.server_ctx.curr_region,
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
} else {
manager.redo(
self.server_ctx.curr_region,
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
}
if let Some(region) =
self.project.get_region(&self.server_ctx.curr_region)
{
self.server.update_region(region);
}
ctx.ui.send(TheEvent::Custom(
TheId::named("Update Minimap"),
TheValue::Empty,
));
} else if manager.context == UndoManagerContext::MaterialFX {
if ui.focus_widget_supports_undo_redo(ctx) {
if id.name == "Undo" {
manager.undo(
Uuid::nil(),
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
ui.undo(ctx);
} else {
manager.redo(
Uuid::nil(),
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
ui.redo(ctx);
}
} else if manager.context == UndoManagerContext::Palette {
if id.name == "Undo" {
manager.undo(
Uuid::nil(),
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
} else {
manager.redo(
Uuid::nil(),
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
} else {
let mut manager = UNDOMANAGER.lock().unwrap();

if manager.context == UndoManagerContext::Region {
if id.name == "Undo" {
manager.undo(
self.server_ctx.curr_region,
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
} else {
manager.redo(
self.server_ctx.curr_region,
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
}
if let Some(region) =
self.project.get_region(&self.server_ctx.curr_region)
{
self.server.update_region(region);
}
ctx.ui.send(TheEvent::Custom(
TheId::named("Update Minimap"),
TheValue::Empty,
));
} else if manager.context == UndoManagerContext::MaterialFX {
if id.name == "Undo" {
manager.undo(
Uuid::nil(),
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
} else {
manager.redo(
Uuid::nil(),
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
}
} else if manager.context == UndoManagerContext::Palette {
if id.name == "Undo" {
manager.undo(
Uuid::nil(),
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
} else {
manager.redo(
Uuid::nil(),
&mut self.server_ctx,
&mut self.project,
ui,
ctx,
);
}
self.server.set_palette(&self.project.palette);
}
self.server.set_palette(&self.project.palette);
}
} else if id.name == "Cut" {
if ui.focus_widget_supports_clipboard(ctx) {
Expand Down

0 comments on commit 6b432f0

Please sign in to comment.