feat: add unlock icon and update layer lock UI, and fix document loading index management and cache synchronization
This commit is contained in:
@@ -3591,6 +3591,8 @@ impl HcieIcedApp {
|
||||
.engine
|
||||
.set_layer_locked(id, locked);
|
||||
self.documents[self.active_doc].modified = true;
|
||||
self.documents[self.active_doc].cached_layers =
|
||||
self.documents[self.active_doc].engine.layer_infos();
|
||||
}
|
||||
|
||||
Message::LayerSetOpacity(id, opacity) => {
|
||||
@@ -7838,7 +7840,9 @@ impl HcieIcedApp {
|
||||
|
||||
match self.pending_file_operation.take() {
|
||||
Some(PendingFileOperation::Open) => {
|
||||
let engine = &mut self.documents[self.active_doc].engine;
|
||||
let _ = self.update(Message::NewDocument(1, 1));
|
||||
let doc_idx = self.documents.len() - 1;
|
||||
let engine = &mut self.documents[doc_idx].engine;
|
||||
let result = match ext.as_str() {
|
||||
"psd" => engine.import_psd(&path_str),
|
||||
"kra" => engine.import_kra(&path_str),
|
||||
@@ -7848,20 +7852,30 @@ impl HcieIcedApp {
|
||||
match result {
|
||||
Ok(()) => {
|
||||
self.show_welcome = false;
|
||||
self.documents[self.active_doc].engine.pre_tile_all_layers();
|
||||
self.documents[self.active_doc].selection_model_dirty = true;
|
||||
self.documents[self.active_doc].name = path
|
||||
self.active_doc = doc_idx;
|
||||
self.documents[doc_idx].engine.pre_tile_all_layers();
|
||||
self.documents[doc_idx].selection_model_dirty = true;
|
||||
self.documents[doc_idx].name = path
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| "Untitled".to_string());
|
||||
self.documents[self.active_doc].source_path = Some(path.clone());
|
||||
self.documents[self.active_doc].modified = false;
|
||||
self.documents[doc_idx].source_path = Some(path.clone());
|
||||
self.documents[doc_idx].modified = false;
|
||||
self.add_recent_file(&path);
|
||||
self.documents[self.active_doc].full_upload.replace(true);
|
||||
self.documents[doc_idx].full_upload.replace(true);
|
||||
self.documents[doc_idx].cached_layers =
|
||||
self.documents[doc_idx].engine.layer_infos();
|
||||
self.refresh_composite_if_needed();
|
||||
return Task::perform(async {}, |_| Message::CompositeRefresh);
|
||||
}
|
||||
Err(e) => log::error!("Failed to open: {}", e),
|
||||
Err(e) => {
|
||||
log::error!("Failed to open: {}", e);
|
||||
// Remove empty dummy document if load failed
|
||||
if self.documents.len() > 1 {
|
||||
self.documents.pop();
|
||||
self.active_doc = self.documents.len() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(PendingFileOperation::SaveAs { close_after }) => {
|
||||
|
||||
@@ -339,8 +339,13 @@ pub fn view<'a>(
|
||||
14.0,
|
||||
);
|
||||
|
||||
let lock_icon_path = if info.locked {
|
||||
"icons/lock.svg"
|
||||
} else {
|
||||
"icons/unlock.svg"
|
||||
};
|
||||
let row_lock = svg_icon_btn(
|
||||
"icons/lock.svg",
|
||||
lock_icon_path,
|
||||
if info.locked { "Unlock" } else { "Lock" },
|
||||
Message::LayerToggleLock(info.id),
|
||||
colors,
|
||||
|
||||
Reference in New Issue
Block a user