feat: add unlock icon and update layer lock UI, and fix document loading index management and cache synchronization
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="currentColor">
|
||||||
|
<g transform="translate(40.96,40.96) scale(17.920000) translate(-0.00,-0.00)">
|
||||||
|
<path d="M18 10h-7V7c0-1.7 1.4-3.1 3.1-3.1 1.7 0 3.1 1.4 3.1 3.1h2c0-2.8-2.2-5-5-5S7 4.2 7 7v3H6c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 439 B |
@@ -3591,6 +3591,8 @@ impl HcieIcedApp {
|
|||||||
.engine
|
.engine
|
||||||
.set_layer_locked(id, locked);
|
.set_layer_locked(id, locked);
|
||||||
self.documents[self.active_doc].modified = true;
|
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) => {
|
Message::LayerSetOpacity(id, opacity) => {
|
||||||
@@ -7838,7 +7840,9 @@ impl HcieIcedApp {
|
|||||||
|
|
||||||
match self.pending_file_operation.take() {
|
match self.pending_file_operation.take() {
|
||||||
Some(PendingFileOperation::Open) => {
|
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() {
|
let result = match ext.as_str() {
|
||||||
"psd" => engine.import_psd(&path_str),
|
"psd" => engine.import_psd(&path_str),
|
||||||
"kra" => engine.import_kra(&path_str),
|
"kra" => engine.import_kra(&path_str),
|
||||||
@@ -7848,20 +7852,30 @@ impl HcieIcedApp {
|
|||||||
match result {
|
match result {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
self.show_welcome = false;
|
self.show_welcome = false;
|
||||||
self.documents[self.active_doc].engine.pre_tile_all_layers();
|
self.active_doc = doc_idx;
|
||||||
self.documents[self.active_doc].selection_model_dirty = true;
|
self.documents[doc_idx].engine.pre_tile_all_layers();
|
||||||
self.documents[self.active_doc].name = path
|
self.documents[doc_idx].selection_model_dirty = true;
|
||||||
|
self.documents[doc_idx].name = path
|
||||||
.file_name()
|
.file_name()
|
||||||
.map(|n| n.to_string_lossy().to_string())
|
.map(|n| n.to_string_lossy().to_string())
|
||||||
.unwrap_or_else(|| "Untitled".to_string());
|
.unwrap_or_else(|| "Untitled".to_string());
|
||||||
self.documents[self.active_doc].source_path = Some(path.clone());
|
self.documents[doc_idx].source_path = Some(path.clone());
|
||||||
self.documents[self.active_doc].modified = false;
|
self.documents[doc_idx].modified = false;
|
||||||
self.add_recent_file(&path);
|
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();
|
self.refresh_composite_if_needed();
|
||||||
return Task::perform(async {}, |_| Message::CompositeRefresh);
|
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 }) => {
|
Some(PendingFileOperation::SaveAs { close_after }) => {
|
||||||
|
|||||||
@@ -339,8 +339,13 @@ pub fn view<'a>(
|
|||||||
14.0,
|
14.0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let lock_icon_path = if info.locked {
|
||||||
|
"icons/lock.svg"
|
||||||
|
} else {
|
||||||
|
"icons/unlock.svg"
|
||||||
|
};
|
||||||
let row_lock = svg_icon_btn(
|
let row_lock = svg_icon_btn(
|
||||||
"icons/lock.svg",
|
lock_icon_path,
|
||||||
if info.locked { "Unlock" } else { "Lock" },
|
if info.locked { "Unlock" } else { "Lock" },
|
||||||
Message::LayerToggleLock(info.id),
|
Message::LayerToggleLock(info.id),
|
||||||
colors,
|
colors,
|
||||||
|
|||||||
Reference in New Issue
Block a user