mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
UI: 2-column Home screen with recent file cards and centered workspace (#7231)
* UI: 2-column Home screen with recent file cards and centered workspace * Rate-limit live-document thumbnail composition on Home While an open document is being edited, Home recomposed its preview on the UI thread on every revision. Regenerate at most every 500 ms, keep showing the previous preview in between, and schedule a repaint so the last revision is still drawn. --------- Co-authored-by: FredApps <[email protected]>
This commit is contained in:
1 parent
d7d138b1e5
commit
51131b82cf
32 files changed
+2062
-162
No files matched your search
@@ -29,6 +29,8 @@ photocraft-paint = { workspace = true }
|
||||
photocraft-format = { workspace = true }
|
||||
# Decoding the brand mark's PNG (`brand.rs`); already linked through photocraft-io.
|
||||
photocraft-codecs = { workspace = true }
|
||||
# Reading embedded thumbnail resources (1036/1033) for recent files in Home screen.
|
||||
photocraft-psd = { workspace = true }
|
||||
egui = { workspace = true }
|
||||
egui_extras = { version = "0.37", default-features = false, features = ["svg"] }
|
||||
eframe = { workspace = true, features = ["wgpu", "accesskit", "clipboard"] }
|
||||
|
||||
@@ -46,6 +46,7 @@ impl PhotocraftApp {
|
||||
streams: HashMap::new(),
|
||||
info_samplers: None,
|
||||
monitors: Default::default(),
|
||||
thumbnail_cache: std::sync::Arc::new(std::sync::Mutex::new(crate::home_recent_ui::ThumbnailCache::default())),
|
||||
checker: None,
|
||||
drag: None,
|
||||
cancelled_vector_drag: false,
|
||||
|
||||
@@ -13,15 +13,22 @@ impl PhotocraftApp {
|
||||
let mut r = self.session.prefs().file_handling.recent_files.clone();
|
||||
r.retain(|p| p != path);
|
||||
r.insert(0, path.to_string());
|
||||
let evicted: Vec<String> = if r.len() > cap { r[cap..].to_vec() } else { Vec::new() };
|
||||
r.truncate(cap);
|
||||
self.ui.recent_files = r.clone();
|
||||
self.session.prefs.edit(|p| p.file_handling.recent_files = r);
|
||||
let mut cache = self.thumbnail_cache.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
|
||||
cache.invalidate(path);
|
||||
for evicted_path in evicted {
|
||||
cache.invalidate(&evicted_path);
|
||||
}
|
||||
}
|
||||
|
||||
/// File › Open Recent › Clear Recent File List.
|
||||
pub fn clear_recent(&mut self) {
|
||||
self.ui.recent_files.clear();
|
||||
self.session.prefs.edit(|p| p.file_handling.recent_files.clear());
|
||||
self.thumbnail_cache.lock().unwrap_or_else(std::sync::PoisonError::into_inner).clear();
|
||||
}
|
||||
|
||||
/// Take one file off the recent list (the Home screen's × or Remove from Recent, #2691). The
|
||||
@@ -29,6 +36,7 @@ impl PhotocraftApp {
|
||||
pub fn remove_recent(&mut self, path: &str) {
|
||||
self.ui.recent_files.retain(|p| p != path);
|
||||
self.session.prefs.edit(|p| p.file_handling.recent_files.retain(|r| r != path));
|
||||
self.thumbnail_cache.lock().unwrap_or_else(std::sync::PoisonError::into_inner).invalidate(path);
|
||||
}
|
||||
|
||||
/// How many recent files to remember ("Recent File List Contains", 0–100).
|
||||
@@ -660,6 +668,7 @@ impl PhotocraftApp {
|
||||
// A copy written over the document's own file is this app's change too.
|
||||
self.remember_stamp(doc, path);
|
||||
}
|
||||
self.thumbnail_cache.lock().unwrap_or_else(std::sync::PoisonError::into_inner).invalidate(path);
|
||||
self.ui.status_error = false;
|
||||
let what = crate::i18n::fmt(tl!("Saved {name}"), &[("name", file_open::display_name(path).as_str())]);
|
||||
notices::io_warnings(self, &what, warnings);
|
||||
|
||||
@@ -95,8 +95,7 @@ use paint::{
|
||||
use selection::selection_shown_offset;
|
||||
pub use selection::{SelCursor, selection_cursor};
|
||||
pub(crate) use selection::{floating_outline, selection_drag_delta};
|
||||
#[cfg(test)]
|
||||
use start_screen::start_screen_drop_hint;
|
||||
pub(crate) use start_screen::start_screen_drop_hint;
|
||||
pub(crate) use strokes::multiple_color_target;
|
||||
pub use strokes::paint_target;
|
||||
pub(crate) use strokes::{ClonePreviewCache, CommittedStroke, LiveStroke, cancel_mixer_on_context_change, freehand_tool, spread_ms, strokes_live};
|
||||
|
||||
@@ -1,93 +1,274 @@
|
||||
use super::tabs::{open_on_double_click, paint_dots};
|
||||
use super::{PhotocraftApp, Rect, Sense};
|
||||
|
||||
/// The Home screen's card is this wide when the canvas has room, and as wide as the canvas when it doesn't.
|
||||
const HOME_CARD_WIDTH: f32 = 460.0;
|
||||
|
||||
/// Least width of each of the Home screen's New document and Open buttons.
|
||||
const HOME_BUTTON_WIDTH: f32 = 190.0;
|
||||
|
||||
/// Space between the Home screen's two buttons.
|
||||
const HOME_BUTTON_GAP: f32 = 12.0;
|
||||
|
||||
pub(super) fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
let t = crate::theme::Tokens::get(ui.ctx());
|
||||
let area = ui.available_rect_before_wrap();
|
||||
paint_dots(ui, area, app.session.prefs().interface.show_canvas_dots);
|
||||
open_on_double_click(app, ui, area);
|
||||
|
||||
// File › Open Recent, newest first (on the web there are no paths to reopen).
|
||||
let show_recent = app.session.prefs().interface.show_home_recent_files;
|
||||
let recent: Vec<String> =
|
||||
if cfg!(target_arch = "wasm32") || !show_recent { Vec::new() } else { app.ui.recent_files.iter().take(HOME_RECENT).cloned().collect() };
|
||||
let recent_h = if recent.is_empty() { 0.0 } else { 34.0 + recent.len() as f32 * HOME_RECENT_ROW };
|
||||
// A tiling window manager can give the canvas less room than the card wants: shrink the card
|
||||
// to fit, and stack the buttons when they don't fit side by side.
|
||||
let new_label = crate::shortcuts::command_label(app, "New document…", "file.new");
|
||||
let open_label = crate::shortcuts::command_label(app, "Open…", "file.open");
|
||||
let card_width = HOME_CARD_WIDTH.min(area.width());
|
||||
let button_width = HOME_BUTTON_WIDTH.max(crate::widgets::button_width(ui, &[&new_label, &open_label]));
|
||||
let side_by_side = 2.0 * button_width + HOME_BUTTON_GAP <= card_width;
|
||||
// Stacked buttons take one more row.
|
||||
let stacked_h = if side_by_side { 0.0 } else { 44.0 };
|
||||
let card = Rect::from_center_size(area.center(), egui::vec2(card_width, 330.0 + recent_h + stacked_h));
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(card), |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
let title = ui.painter().layout_no_wrap(tl!("PhotoCraft").into(), crate::theme::semibold(38.0), t.text);
|
||||
let by = ui.painter().layout_no_wrap(tl!("open source").into(), egui::FontId::proportional(13.0), t.text_faint);
|
||||
let total = title.size().x + by.size().x + 10.0;
|
||||
ui.add_space(((card.width() - total) / 2.0).max(0.0));
|
||||
let (r, _) = ui.allocate_exact_size(title.size(), Sense::hover());
|
||||
ui.painter().galley(r.min, title, t.text);
|
||||
let (r2, _) = ui.allocate_exact_size(egui::vec2(by.size().x + 10.0, r.height()), Sense::hover());
|
||||
ui.painter().galley(egui::pos2(r2.left() + 10.0, r.bottom() - by.size().y - 8.0), by, t.text_faint);
|
||||
|
||||
let is_narrow = area.width() < 640.0;
|
||||
let pad_x = if is_narrow { 16.0 } else { 36.0 };
|
||||
let pad_y = if is_narrow { 24.0 } else { 54.0 };
|
||||
let rail_w = 170.0;
|
||||
|
||||
if is_narrow {
|
||||
let card_w = (area.width() - 32.0).clamp(0.0, 520.0);
|
||||
let card = Rect::from_center_size(area.center(), egui::vec2(card_w, (area.height() - 40.0).max(0.0)));
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(card), |ui| {
|
||||
egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
|
||||
render_start_actions_row(app, ui, card.width());
|
||||
ui.add_space(16.0);
|
||||
render_start_content(app, ui, &recent, card.width());
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
ui.label(egui::RichText::new(tl!("Create a new document or open an existing file.")).color(t.text_dim).size(14.0));
|
||||
ui.add_space(22.0);
|
||||
let (mut new_clicked, mut open_clicked) = (false, false);
|
||||
if side_by_side {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(((card.width() - 2.0 * button_width - HOME_BUTTON_GAP) / 2.0).max(0.0));
|
||||
ui.spacing_mut().item_spacing.x = HOME_BUTTON_GAP;
|
||||
new_clicked = crate::widgets::primary_button(ui, &new_label, button_width).clicked();
|
||||
open_clicked = crate::widgets::secondary_button(ui, &open_label, button_width).clicked();
|
||||
});
|
||||
} else {
|
||||
new_clicked = crate::widgets::primary_button(ui, &new_label, button_width).clicked();
|
||||
ui.add_space(HOME_BUTTON_GAP);
|
||||
open_clicked = crate::widgets::secondary_button(ui, &open_label, button_width).clicked();
|
||||
}
|
||||
if new_clicked {
|
||||
let fields = app.new_document_fields();
|
||||
app.ui.open_dialog(crate::state::DialogKind::NewDocument, fields);
|
||||
}
|
||||
if open_clicked {
|
||||
let _ = app.open_dialog_file();
|
||||
}
|
||||
ui.add_space(22.0);
|
||||
ui.horizontal(|ui| {
|
||||
let msg = start_screen_drop_hint(app);
|
||||
let g = ui.painter().layout_no_wrap(msg.to_string(), egui::FontId::proportional(12.5), t.text_faint);
|
||||
ui.add_space(((card.width() - g.size().x - 24.0) / 2.0).max(0.0));
|
||||
let (r, _) = ui.allocate_exact_size(egui::vec2(18.0, 18.0), Sense::hover());
|
||||
crate::icons::paint(ui, r, "image", 15.0, t.text_faint);
|
||||
ui.label(egui::RichText::new(msg).color(t.text_faint));
|
||||
});
|
||||
if !recent.is_empty() {
|
||||
ui.add_space(22.0);
|
||||
home_recent(app, ui, &recent);
|
||||
}
|
||||
ui.add_space(26.0);
|
||||
crate::links::discord_button(app, ui, 190.0);
|
||||
ui.add_space(10.0);
|
||||
crate::links::link_row(app, ui);
|
||||
});
|
||||
} else {
|
||||
let rail_rect = Rect::from_min_size(egui::pos2(area.left() + pad_x, area.top() + pad_y), egui::vec2(rail_w, area.height() - pad_y * 2.0));
|
||||
let content_x = rail_rect.right() + 36.0;
|
||||
let content_rect = Rect::from_min_max(egui::pos2(content_x, area.top() + pad_y), egui::pos2(area.right() - pad_x, area.bottom() - 16.0));
|
||||
|
||||
// 1. Left Navigation Rail
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(rail_rect), |ui| {
|
||||
render_start_rail(app, ui, rail_rect.width());
|
||||
});
|
||||
|
||||
// 2. Right Content Area (scrollable)
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(content_rect), |ui| {
|
||||
egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
|
||||
render_start_content(app, ui, &recent, content_rect.width());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn render_start_actions_row(app: &mut PhotocraftApp, ui: &mut egui::Ui, avail_w: f32) {
|
||||
let t = crate::theme::Tokens::get(ui.ctx());
|
||||
let btn_w = ((avail_w - 12.0) / 2.0).clamp(0.0, 150.0);
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
// [ New file ]
|
||||
let new_label = tl!("New file");
|
||||
let (new_rect, new_resp) = ui.allocate_exact_size(egui::vec2(btn_w, 32.0), Sense::click());
|
||||
new_resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, new_label));
|
||||
let new_resp = new_resp.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
let new_bg = if new_resp.hovered() { egui::Color32::from_rgb(41, 131, 245) } else { egui::Color32::from_rgb(26, 115, 232) };
|
||||
ui.painter().rect_filled(new_rect, 4.0, new_bg);
|
||||
ui.painter().text(new_rect.center(), egui::Align2::CENTER_CENTER, new_label, crate::theme::semibold(13.0), egui::Color32::WHITE);
|
||||
if new_resp.clicked() {
|
||||
let fields = app.new_document_fields();
|
||||
app.ui.open_dialog(crate::state::DialogKind::NewDocument, fields);
|
||||
}
|
||||
|
||||
ui.add_space(8.0);
|
||||
|
||||
// [ Open… ]
|
||||
let open_label = tl!("Open…");
|
||||
let (open_rect, open_resp) = ui.allocate_exact_size(egui::vec2(btn_w, 32.0), Sense::click());
|
||||
open_resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, open_label));
|
||||
let open_resp = open_resp.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
if open_resp.hovered() {
|
||||
ui.painter().rect_filled(open_rect, 4.0, t.hover);
|
||||
}
|
||||
ui.painter().rect_stroke(open_rect, 4.0, egui::Stroke::new(1.0, t.separator), egui::StrokeKind::Inside);
|
||||
ui.painter().text(open_rect.center(), egui::Align2::CENTER_CENTER, open_label, crate::theme::semibold(13.0), t.text);
|
||||
if open_resp.clicked() {
|
||||
let _ = app.open_dialog_file();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn render_start_rail(app: &mut PhotocraftApp, ui: &mut egui::Ui, rail_w: f32) {
|
||||
let t = crate::theme::Tokens::get(ui.ctx());
|
||||
|
||||
ui.add_space(8.0);
|
||||
|
||||
// 1. [ New file ] button
|
||||
let new_label = tl!("New file");
|
||||
let (new_rect, new_resp) = ui.allocate_exact_size(egui::vec2(rail_w.min(130.0), 32.0), Sense::click());
|
||||
new_resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, new_label));
|
||||
let new_resp = new_resp.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
let new_bg = if new_resp.hovered() { egui::Color32::from_rgb(41, 131, 245) } else { egui::Color32::from_rgb(26, 115, 232) };
|
||||
ui.painter().rect_filled(new_rect, 4.0, new_bg);
|
||||
ui.painter().text(new_rect.center(), egui::Align2::CENTER_CENTER, new_label, crate::theme::semibold(13.0), egui::Color32::WHITE);
|
||||
if new_resp.clicked() {
|
||||
let fields = app.new_document_fields();
|
||||
app.ui.open_dialog(crate::state::DialogKind::NewDocument, fields);
|
||||
}
|
||||
|
||||
ui.add_space(8.0);
|
||||
|
||||
// 2. [ Open… ] button
|
||||
let open_label = tl!("Open…");
|
||||
let (open_rect, open_resp) = ui.allocate_exact_size(egui::vec2(rail_w.min(130.0), 30.0), Sense::click());
|
||||
open_resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, open_label));
|
||||
let open_resp = open_resp.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
if open_resp.hovered() {
|
||||
ui.painter().rect_filled(open_rect, 4.0, t.hover);
|
||||
}
|
||||
ui.painter().rect_stroke(open_rect, 4.0, egui::Stroke::new(1.0, t.separator), egui::StrokeKind::Inside);
|
||||
ui.painter().text(open_rect.center(), egui::Align2::CENTER_CENTER, open_label, crate::theme::semibold(13.0), t.text);
|
||||
if open_resp.clicked() {
|
||||
let _ = app.open_dialog_file();
|
||||
}
|
||||
|
||||
ui.add_space(16.0);
|
||||
|
||||
// Separator line
|
||||
let sep_w = 150.0f32.min(rail_w);
|
||||
let (sep_rect, _) = ui.allocate_exact_size(egui::vec2(sep_w, 1.0), Sense::hover());
|
||||
ui.painter().line_segment([sep_rect.min, egui::pos2(sep_rect.max.x, sep_rect.min.y)], egui::Stroke::new(1.0, t.separator));
|
||||
|
||||
ui.add_space(14.0);
|
||||
|
||||
// 3. "Home" Nav Item (Selected)
|
||||
let (home_rect, home_resp) = ui.allocate_exact_size(egui::vec2(rail_w, 32.0), Sense::click());
|
||||
home_resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tl!("Home")));
|
||||
let active_bar = Rect::from_min_size(egui::pos2(home_rect.left(), home_rect.center().y - 7.0), egui::vec2(1.5, 14.0));
|
||||
ui.painter().rect_filled(active_bar, 1.0, t.accent);
|
||||
let house_box = Rect::from_center_size(egui::pos2(home_rect.left() + 20.0, home_rect.center().y), egui::vec2(16.0, 16.0));
|
||||
crate::icons::paint(ui, house_box, "house", 16.0, t.text);
|
||||
ui.painter().text(egui::pos2(home_rect.left() + 34.0, home_rect.center().y), egui::Align2::LEFT_CENTER, tl!("Home"), crate::theme::semibold(13.5), t.text);
|
||||
|
||||
ui.add_space(4.0);
|
||||
|
||||
// 4. "Learn" Nav Item
|
||||
let (learn_rect, learn_resp) = ui.allocate_exact_size(egui::vec2(rail_w, 32.0), Sense::click());
|
||||
let learn_resp = learn_resp.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
learn_resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tl!("Learn")));
|
||||
if learn_resp.hovered() {
|
||||
ui.painter().rect_filled(learn_rect, 4.0, t.hover);
|
||||
}
|
||||
let learn_color = if learn_resp.hovered() { t.text } else { t.text_dim };
|
||||
let sparkle_box = Rect::from_center_size(egui::pos2(learn_rect.left() + 20.0, learn_rect.center().y), egui::vec2(16.0, 16.0));
|
||||
crate::icons::paint(ui, sparkle_box, "sparkles", 16.0, learn_color);
|
||||
ui.painter().text(
|
||||
egui::pos2(learn_rect.left() + 34.0, learn_rect.center().y),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
tl!("Learn"),
|
||||
crate::theme::semibold(13.5),
|
||||
learn_color,
|
||||
);
|
||||
if learn_resp.clicked() {
|
||||
crate::links::open(app, ui.ctx(), crate::links::TUTORIALS);
|
||||
}
|
||||
|
||||
// 5. Bottom pinned community links
|
||||
let bottom_h = 100.0;
|
||||
let avail_h = ui.available_height();
|
||||
let spacer = (avail_h - bottom_h - 20.0).max(24.0);
|
||||
ui.add_space(spacer);
|
||||
|
||||
let (b_sep_rect, _) = ui.allocate_exact_size(egui::vec2(sep_w, 1.0), Sense::hover());
|
||||
ui.painter().line_segment([b_sep_rect.min, egui::pos2(b_sep_rect.max.x, b_sep_rect.min.y)], egui::Stroke::new(1.0, t.separator));
|
||||
|
||||
ui.add_space(8.0);
|
||||
|
||||
render_rail_link(app, ui, rail_w, tl!("Website"), "link", crate::links::APP_PAGE);
|
||||
render_rail_link(app, ui, rail_w, tl!("Discord"), "message-square", crate::links::DISCORD);
|
||||
render_rail_link(app, ui, rail_w, tl!("GitHub"), "link-2", crate::links::GITHUB);
|
||||
}
|
||||
|
||||
fn render_rail_link(app: &mut PhotocraftApp, ui: &mut egui::Ui, rail_w: f32, label: &str, icon_name: &str, url: &str) {
|
||||
let t = crate::theme::Tokens::get(ui.ctx());
|
||||
let (rect, resp) = ui.allocate_exact_size(egui::vec2(rail_w, 28.0), Sense::click());
|
||||
let resp = resp.on_hover_cursor(egui::CursorIcon::PointingHand).on_hover_text(url);
|
||||
if resp.hovered() {
|
||||
ui.painter().rect_filled(rect, 4.0, t.hover);
|
||||
}
|
||||
let color = if resp.hovered() { t.text } else { t.text_dim };
|
||||
let icon_box = Rect::from_center_size(egui::pos2(rect.left() + 20.0, rect.center().y), egui::vec2(14.0, 14.0));
|
||||
crate::icons::paint(ui, icon_box, icon_name, 14.0, color);
|
||||
ui.painter().text(egui::pos2(rect.left() + 34.0, rect.center().y), egui::Align2::LEFT_CENTER, label, crate::theme::medium(12.0), color);
|
||||
if resp.clicked() {
|
||||
crate::links::open(app, ui.ctx(), url);
|
||||
}
|
||||
}
|
||||
|
||||
fn render_start_content(app: &mut PhotocraftApp, ui: &mut egui::Ui, recent: &[String], content_w: f32) {
|
||||
let t = crate::theme::Tokens::get(ui.ctx());
|
||||
ui.add_space(8.0);
|
||||
|
||||
// Top Row: [01] PhotoCraft
|
||||
ui.horizontal(|ui| {
|
||||
let badge_size = egui::vec2(24.0, 19.0);
|
||||
let (badge_rect, _) = ui.allocate_exact_size(badge_size, Sense::hover());
|
||||
ui.painter().rect_filled(badge_rect, 3.0, egui::Color32::from_rgb(26, 115, 232));
|
||||
ui.painter().text(badge_rect.center(), egui::Align2::CENTER_CENTER, "01", crate::theme::semibold(10.5), egui::Color32::WHITE);
|
||||
|
||||
ui.add_space(10.0);
|
||||
|
||||
let title_galley = ui.painter().layout_no_wrap(tl!("PhotoCraft").into(), crate::theme::semibold(20.0), t.text);
|
||||
let (title_r, _) = ui.allocate_exact_size(title_galley.size(), Sense::hover());
|
||||
ui.painter().galley(title_r.min, title_galley, t.text);
|
||||
});
|
||||
|
||||
ui.add_space(18.0);
|
||||
|
||||
// Hairline separator under header
|
||||
let (sep_r, _) = ui.allocate_exact_size(egui::vec2(content_w, 1.0), Sense::hover());
|
||||
ui.painter().line_segment([sep_r.min, egui::pos2(sep_r.max.x, sep_r.min.y)], egui::Stroke::new(1.0, t.separator));
|
||||
|
||||
ui.add_space(24.0);
|
||||
|
||||
if recent.is_empty() {
|
||||
render_first_run_content(app, ui, content_w);
|
||||
} else {
|
||||
crate::home_recent_ui::show_home_recent(app, ui, recent, content_w);
|
||||
}
|
||||
|
||||
ui.add_space(24.0);
|
||||
}
|
||||
|
||||
fn render_first_run_content(app: &mut PhotocraftApp, ui: &mut egui::Ui, content_w: f32) {
|
||||
let t = crate::theme::Tokens::get(ui.ctx());
|
||||
|
||||
let drop_w = 540.0f32.min(content_w - 24.0);
|
||||
let drop_h = 200.0;
|
||||
|
||||
// Center vertically in available content area
|
||||
let avail_h = ui.available_height();
|
||||
let top_space = ((avail_h - drop_h) / 2.0 - 50.0).max(40.0);
|
||||
ui.add_space(top_space);
|
||||
|
||||
// Center horizontally across content_w
|
||||
let pad_x = ((content_w - drop_w) / 2.0).max(0.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(pad_x);
|
||||
|
||||
let (drop_r, drop_resp) = ui.allocate_exact_size(egui::vec2(drop_w, drop_h), Sense::click());
|
||||
let drop_resp = drop_resp.on_hover_cursor(egui::CursorIcon::PointingHand).on_hover_text(tl!("Open…"));
|
||||
let is_hov = drop_resp.hovered();
|
||||
|
||||
let border_color = if is_hov { t.text_dim } else { t.separator };
|
||||
let bg_color = if is_hov { t.hover } else { egui::Color32::TRANSPARENT };
|
||||
ui.painter().rect_filled(drop_r, 8.0, bg_color);
|
||||
ui.painter().rect_stroke(drop_r, 8.0, egui::Stroke::new(1.0, border_color), egui::StrokeKind::Inside);
|
||||
|
||||
// Centered icon & message
|
||||
let icon_box = Rect::from_center_size(egui::pos2(drop_r.center().x, drop_r.center().y - 18.0), egui::vec2(40.0, 40.0));
|
||||
crate::icons::paint(ui, icon_box, "image", 34.0, if is_hov { t.text } else { t.text_dim });
|
||||
|
||||
let drop_msg = start_screen_drop_hint(app);
|
||||
ui.painter().text(
|
||||
egui::pos2(drop_r.center().x, drop_r.center().y + 20.0),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
drop_msg,
|
||||
crate::theme::medium(14.0),
|
||||
if is_hov { t.text } else { t.text_faint },
|
||||
);
|
||||
|
||||
if drop_resp.clicked() {
|
||||
let _ = app.open_dialog_file();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Wayland has no native file drops (winit 0.30, #386), so the hint offers File › Open and paste.
|
||||
pub(super) fn start_screen_drop_hint(app: &PhotocraftApp) -> std::borrow::Cow<'static, str> {
|
||||
pub(crate) fn start_screen_drop_hint(app: &PhotocraftApp) -> std::borrow::Cow<'static, str> {
|
||||
if app.services.is_wayland {
|
||||
crate::i18n::fmt(tl!("Use File › Open, or paste a copied image with {paste}."), &[("paste", &crate::notices::paste_hint(app))]).into()
|
||||
} else {
|
||||
@@ -96,82 +277,4 @@ pub(super) fn start_screen_drop_hint(app: &PhotocraftApp) -> std::borrow::Cow<'s
|
||||
}
|
||||
|
||||
/// Recent files listed on the Home screen.
|
||||
const HOME_RECENT: usize = 6;
|
||||
|
||||
/// Height of one Home-screen recent-file row.
|
||||
const HOME_RECENT_ROW: f32 = 30.0;
|
||||
|
||||
/// The Home screen's "Recent" list: file name, its folder on the right, click to open. The
|
||||
/// hovered row shows a × that takes it off the list, and right-click offers Remove from Recent
|
||||
/// and Clear Recent Files (#2691).
|
||||
fn home_recent(app: &mut PhotocraftApp, ui: &mut egui::Ui, recent: &[String]) {
|
||||
let t = crate::theme::Tokens::get(ui.ctx());
|
||||
let width = 380.0;
|
||||
ui.horizontal(|ui| {
|
||||
// Line the heading up with the file icons.
|
||||
ui.add_space(((ui.available_width() - width) / 2.0).max(0.0) + 8.0);
|
||||
ui.label(egui::RichText::new(tl!("Recent")).font(crate::theme::semibold(12.5)).color(t.text_dim));
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
let mut open = None;
|
||||
let mut remove = None;
|
||||
let mut clear = false;
|
||||
for path in recent {
|
||||
let name = crate::file_open::display_name(path);
|
||||
let folder = std::path::Path::new(path).parent().map(|d| d.to_string_lossy().into_owned()).unwrap_or_default();
|
||||
let (row, resp) = ui.allocate_exact_size(egui::vec2(width, HOME_RECENT_ROW), Sense::click());
|
||||
// The × sits on top of the row, so the row counts as hovered while the pointer is on it.
|
||||
let hovered = ui.rect_contains_pointer(row);
|
||||
if hovered {
|
||||
ui.painter().rect_filled(row, t.radius_sm, t.hover);
|
||||
}
|
||||
let close = Rect::from_center_size(egui::pos2(row.right() - 16.0, row.center().y), egui::vec2(22.0, 22.0));
|
||||
let right = if hovered { close.left() - 4.0 } else { row.right() - 10.0 };
|
||||
let icon = Rect::from_center_size(egui::pos2(row.left() + 16.0, row.center().y), egui::vec2(16.0, 16.0));
|
||||
crate::icons::paint(ui, icon, "file", 14.0, t.text_dim);
|
||||
let x = row.left() + 32.0;
|
||||
let name_g = crate::tab_strip::elided(ui, &name, egui::FontId::proportional(12.5), t.text, 170.0);
|
||||
let name_w = name_g.size().x;
|
||||
ui.painter().galley(egui::pos2(x, row.center().y - name_g.size().y / 2.0), name_g, t.text);
|
||||
let folder_max = (right - (x + name_w + 14.0)).max(0.0);
|
||||
if folder_max > 20.0 && !folder.is_empty() {
|
||||
let fg = crate::tab_strip::elided(ui, &folder, egui::FontId::proportional(11.5), t.text_faint, folder_max);
|
||||
ui.painter().galley(egui::pos2(right - fg.size().x, row.center().y - fg.size().y / 2.0), fg, t.text_faint);
|
||||
}
|
||||
resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, &name));
|
||||
let resp = resp.on_hover_text(path).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
if hovered {
|
||||
let x = ui.interact(close, resp.id.with("remove"), Sense::click());
|
||||
let label = crate::i18n::fmt(tl!("Remove {name} from Recent"), &[("name", &name)]);
|
||||
x.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, &label));
|
||||
let color = crate::icons::button_chrome(ui, close, false, x.hovered());
|
||||
crate::icons::paint(ui, close, "x", 12.0, color);
|
||||
if x.on_hover_text(tl!("Remove from Recent")).clicked() {
|
||||
remove = Some(path.clone());
|
||||
}
|
||||
}
|
||||
if resp.clicked() && remove.is_none() {
|
||||
open = Some(path.clone());
|
||||
}
|
||||
resp.context_menu(|ui| {
|
||||
if ui.button(tl!("Remove from Recent")).clicked() {
|
||||
remove = Some(path.clone());
|
||||
ui.close();
|
||||
}
|
||||
if ui.button(tl!("Clear Recent Files")).clicked() {
|
||||
clear = true;
|
||||
ui.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
if clear {
|
||||
app.clear_recent();
|
||||
} else if let Some(path) = remove {
|
||||
app.remove_recent(&path);
|
||||
}
|
||||
if let Some(path) = open
|
||||
&& let Err(e) = app.open_path(&path)
|
||||
{
|
||||
app.open_failed(&crate::file_open::display_name(&path), &e);
|
||||
}
|
||||
}
|
||||
const HOME_RECENT: usize = 11;
|
||||
@@ -1419,8 +1419,10 @@ fn start_screen_buttons_stay_inside_a_narrow_canvas() {
|
||||
PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::default());
|
||||
h.state_mut().1 = true;
|
||||
h.run_steps(3);
|
||||
for label in ["New document", "Join us on Discord"] {
|
||||
for node in h.query_all_by_label_contains(label) {
|
||||
for label in ["New file", "Open…"] {
|
||||
let nodes: Vec<_> = h.query_all_by_label(label).collect();
|
||||
assert!(!nodes.is_empty(), "`{label}` is rendered in a {width}-point-wide canvas");
|
||||
for node in nodes {
|
||||
let r = node.rect();
|
||||
assert!(r.left() >= 0.0 && r.right() <= width, "`{label}` is clipped in a {width}-point-wide canvas: {r:?}");
|
||||
}
|
||||
@@ -1452,6 +1454,27 @@ fn home_recent_list_hides_when_the_preference_is_off() {
|
||||
assert_eq!(h.state().0.ui.recent_files.len(), 1, "the list itself is kept");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn start_screen_narrow_window_renders_actions_row() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.push_recent("/tmp/photocraft-narrow/test.psd");
|
||||
// Window narrower than 640px (e.g. 500px width split-screen)
|
||||
let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(500.0, 600.0)).build_ui_state(
|
||||
|ui, (app, ready): &mut (PhotocraftApp, bool)| {
|
||||
if *ready {
|
||||
egui::CentralPanel::default().frame(egui::Frame::NONE).show(ui, |ui| document_area(app, ui));
|
||||
}
|
||||
},
|
||||
(app, false),
|
||||
);
|
||||
PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::default());
|
||||
h.state_mut().1 = true;
|
||||
h.run_steps(3);
|
||||
assert!(h.query_by_label("New file").is_some(), "New file button must be present in narrow mode");
|
||||
assert!(h.query_all_by_label("Open…").next().is_some(), "Open… button must be present in narrow mode");
|
||||
}
|
||||
|
||||
/// The Home screen's × takes a file off Recent without opening it, and its right-click menu
|
||||
/// removes one entry or clears the list; the preferences keep the change (#2691).
|
||||
#[test]
|
||||
|
||||
@@ -77,12 +77,12 @@ fn double_clicking_the_empty_workspace_shows_file_open() {
|
||||
#[test]
|
||||
fn the_home_screens_own_widgets_keep_their_double_clicks() {
|
||||
let (mut h, requests) = harness(true);
|
||||
// The subtitle is selectable text: a double-click there selects a word, not File › Open.
|
||||
let at = h.get_by_label_contains("Create a new document or open an existing file").rect().center();
|
||||
// The Home rail button: a double-click there stays on Home, not File › Open.
|
||||
let at = h.get_by_label_contains("Home").rect().center();
|
||||
clicks(&mut h, at, 2);
|
||||
assert_eq!(opens(&requests), 0, "the label took the double-click");
|
||||
// The New document button opens the New Document dialog, not File › Open.
|
||||
let at = h.get_by_label_contains("New document").rect().center();
|
||||
assert_eq!(opens(&requests), 0, "the rail item took the double-click");
|
||||
// The New file button opens the New Document dialog, not File › Open.
|
||||
let at = h.get_by_label_contains("New file").rect().center();
|
||||
clicks(&mut h, at, 1);
|
||||
assert_eq!(opens(&requests), 0);
|
||||
assert_eq!(h.state().ui.dialogs.len(), 1, "the New Document dialog");
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -4268,3 +4268,13 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Barva zarážky
|
||||
Shapes can't use patterns yet Tvary zatím nemohou používat vzorky
|
||||
Edit Brush… Upravit štětec…
|
||||
Drag to move the active shape's path or the Work Path Tažením přesunete cestu aktivního tvaru nebo pracovní cestu
|
||||
Generator enabled Generátor zapnut
|
||||
This Layer: Tato vrstva:
|
||||
Move Up Přesunout nahoru
|
||||
Move Down Přesunout dolů
|
||||
On your computer V tomto počítači
|
||||
New file Nový soubor
|
||||
Learn Učit se
|
||||
No recent files Žádné nedávné soubory
|
||||
Website Web
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3553,3 +3553,12 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Solid Color Volltonfarbe
|
||||
Tint Color Tönungsfarbe
|
||||
Edit Brush… Pinsel bearbeiten…
|
||||
Generator enabled Generator aktiviert
|
||||
This Layer: Diese Ebene:
|
||||
Move Up Nach oben
|
||||
Move Down Nach unten
|
||||
On your computer Auf Ihrem Computer
|
||||
New file Neue Datei
|
||||
Learn Lernen
|
||||
No recent files Keine zuletzt verwendeten Dateien
|
||||
Website Website
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4222,3 +4222,13 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Χρώμα στάσης
|
||||
Shapes can't use patterns yet Τα σχήματα δεν μπορούν ακόμη να χρησιμοποιούν μοτίβα
|
||||
Edit Brush… Επεξεργασία πινέλου…
|
||||
Generator enabled Ενεργοποίηση γεννήτριας
|
||||
Drag to move the active shape's path or the Work Path Σύρετε για μετακίνηση της διαδρομής του ενεργού σχήματος ή της διαδρομής εργασίας
|
||||
Move Up Μετακίνηση επάνω
|
||||
Move Down Μετακίνηση κάτω
|
||||
Grid view Προβολή πλέγματος
|
||||
List view Προβολή λίστας
|
||||
On your computer Στον υπολογιστή σας
|
||||
New file Νέο αρχείο
|
||||
Learn Εκμάθηση
|
||||
Website Ιστότοπος
|
||||
|
Can't render this file because it contains an unexpected character in line 47 and column 53.
|
@@ -4434,3 +4434,12 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Color de la parada
|
||||
Shapes can't use patterns yet Las formas aún no pueden usar motivos
|
||||
Edit Brush… Editar pincel…
|
||||
Drag to move the active shape's path or the Work Path Arrastre para mover el trazado de la forma activa o el trazado de trabajo
|
||||
Generator enabled Generador activado
|
||||
This Layer: Esta capa:
|
||||
Move Up Mover arriba
|
||||
Move Down Mover abajo
|
||||
On your computer En su ordenador
|
||||
New file Nuevo archivo
|
||||
Learn Aprender
|
||||
Website Sitio web
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -4558,3 +4558,11 @@ shape Appearance Apparence
|
||||
Stop Color Couleur du point
|
||||
Shapes can't use patterns yet Les formes ne peuvent pas encore utiliser de motifs
|
||||
Edit Brush… Modifier le pinceau…
|
||||
Generator enabled Générateur activé
|
||||
Move Up Déplacer vers le haut
|
||||
Move Down Déplacer vers le bas
|
||||
Hidden Masqué
|
||||
On your computer Sur votre ordinateur
|
||||
New file Nouveau fichier
|
||||
Learn Apprendre
|
||||
Website Site web
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4442,3 +4442,11 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Színpont színe
|
||||
Shapes can't use patterns yet Az alakzatok még nem használhatnak mintákat
|
||||
Edit Brush… Ecset szerkesztése…
|
||||
This Layer: Ez a réteg:
|
||||
Generator enabled Generátor bekapcsolva
|
||||
Move Up Mozgatás felfelé
|
||||
Move Down Mozgatás lefelé
|
||||
On your computer A számítógépen
|
||||
New file Új fájl
|
||||
Learn Tanulás
|
||||
Website Weboldal
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3545,3 +3545,13 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Solid Color Warna Solid
|
||||
Tint Color Warna Tint
|
||||
Edit Brush… Edit Kuas…
|
||||
Generator enabled Generator aktif
|
||||
Move Up Pindah ke atas
|
||||
Move Down Pindah ke bawah
|
||||
Grid view Tampilan kisi
|
||||
List view Tampilan daftar
|
||||
On your computer Di komputer Anda
|
||||
New file File baru
|
||||
Learn Pelajari
|
||||
No recent files Tidak ada file terbaru
|
||||
Website Situs web
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -4634,3 +4634,11 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Colore del punto
|
||||
Shapes can't use patterns yet Le forme non possono ancora usare pattern
|
||||
Edit Brush… Modifica pennello…
|
||||
Generator enabled Generatore abilitato
|
||||
This Layer: Questo livello:
|
||||
Move Up Sposta su
|
||||
Move Down Sposta giù
|
||||
On your computer Sul computer
|
||||
New file Nuovo file
|
||||
Learn Impara
|
||||
Website Sito web
|
||||
|
Can't render this file because it contains an unexpected character in line 79 and column 53.
|
@@ -4199,3 +4199,15 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color 分岐点のカラー
|
||||
Shapes can't use patterns yet シェイプではまだパターンを使用できません
|
||||
Edit Brush… ブラシを編集…
|
||||
Drag to move the active shape's path or the Work Path ドラッグして、アクティブなシェイプのパスまたは作業用パスを移動
|
||||
Generator enabled 自動生成を有効にする
|
||||
This Layer: 現在のレイヤー:
|
||||
Move Up 上へ移動
|
||||
Move Down 下へ移動
|
||||
Grid view グリッド表示
|
||||
List view リスト表示
|
||||
On your computer このコンピューター上
|
||||
New file 新規ファイル
|
||||
Learn 学ぶ
|
||||
No recent files 最近使ったファイルはありません
|
||||
Website Web サイト
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3742,3 +3742,14 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color 정지점 색상
|
||||
Shapes can't use patterns yet 모양에는 아직 패턴을 사용할 수 없습니다
|
||||
Edit Brush… 브러시 편집…
|
||||
Drag to move the active shape's path or the Work Path 드래그하여 활성 모양의 패스 또는 작업 패스 이동
|
||||
Generator enabled 생성기 활성화
|
||||
Move Up 위로 이동
|
||||
Move Down 아래로 이동
|
||||
Grid view 격자 보기
|
||||
List view 목록 보기
|
||||
On your computer 내 컴퓨터에서
|
||||
New file 새 파일
|
||||
Learn 학습
|
||||
No recent files 최근 파일 없음
|
||||
Website 웹사이트
|
||||
|
Can't render this file because it contains an unexpected character in line 63 and column 53.
|
@@ -4279,3 +4279,12 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Kleur van het punt
|
||||
Shapes can't use patterns yet Vormen kunnen nog geen patronen gebruiken
|
||||
Edit Brush… Penseel bewerken…
|
||||
Generator enabled Generator ingeschakeld
|
||||
Move Up Omhoog
|
||||
Move Down Omlaag
|
||||
Grid view Rasterweergave
|
||||
List view Lijstweergave
|
||||
On your computer Op je computer
|
||||
New file Nieuw bestand
|
||||
Learn Leren
|
||||
Website Website
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 34.
|
@@ -4141,3 +4141,13 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Kolor punktu
|
||||
Shapes can't use patterns yet Kształty nie mogą jeszcze używać wzorków
|
||||
Edit Brush… Edytuj pędzel…
|
||||
Generator enabled Generator włączony
|
||||
Move Up Przesuń w górę
|
||||
Move Down Przesuń w dół
|
||||
Grid view Widok siatki
|
||||
List view Widok listy
|
||||
On your computer Na tym komputerze
|
||||
New file Nowy plik
|
||||
Learn Nauka
|
||||
No recent files Brak ostatnich plików
|
||||
Website Strona internetowa
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4449,3 +4449,11 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Cor da parada
|
||||
Shapes can't use patterns yet Formas ainda não podem usar padrões
|
||||
Edit Brush… Editar pincel…
|
||||
Drag to move the active shape's path or the Work Path Arraste para mover o demarcador da forma ativa ou o demarcador de trabalho
|
||||
Generator enabled Gerador ativado
|
||||
Move Up Mover para cima
|
||||
Move Down Mover para baixo
|
||||
On your computer No seu computador
|
||||
New file Novo arquivo
|
||||
Learn Aprender
|
||||
Website Site
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4719,3 +4719,12 @@ shape Appearance Оформление
|
||||
Stop Color Цвет контрольной точки
|
||||
Shapes can't use patterns yet Фигуры пока не могут использовать узоры
|
||||
Edit Brush… Изменить кисть…
|
||||
Drag to move the active shape's path or the Work Path Перетащите, чтобы переместить контур активной фигуры или рабочий контур
|
||||
Generator enabled Генератор включён
|
||||
Hidden Скрыто
|
||||
Move Up Переместить вверх
|
||||
Move Down Переместить вниз
|
||||
On your computer На вашем компьютере
|
||||
New file Новый файл
|
||||
Learn Обучение
|
||||
Website Сайт
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4601,3 +4601,11 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Boja tačke
|
||||
Shapes can't use patterns yet Oblici još ne mogu da koriste šare
|
||||
Edit Brush… Uredi četkicu…
|
||||
Generator enabled Generator je omogućen
|
||||
This Layer: Ovaj sloj:
|
||||
Move Up Pomeri nagore
|
||||
Move Down Pomeri nadole
|
||||
On your computer На вашем рачунару
|
||||
New file Novi fajl
|
||||
Learn Učenje
|
||||
Website Veb-sajt
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4256,3 +4256,12 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Durak Rengi
|
||||
Shapes can't use patterns yet Şekiller henüz desen kullanamaz
|
||||
Edit Brush… Fırçayı Düzenle…
|
||||
Generator enabled Oluşturucu etkin
|
||||
Move Up Yukarı taşı
|
||||
Move Down Aşağı taşı
|
||||
Grid view Izgara görünümü
|
||||
List view Liste görünümü
|
||||
On your computer Bilgisayarınızda
|
||||
New file Yeni dosya
|
||||
Learn Öğrenin
|
||||
Website Web sitesi
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 34.
|
@@ -4233,3 +4233,14 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Колір контрольної точки
|
||||
Shapes can't use patterns yet Фігури поки не можуть використовувати візерунки
|
||||
Edit Brush… Редагувати пензель…
|
||||
Drag to move the active shape's path or the Work Path Перетягніть, щоб перемістити контур активної фігури або робочий контур
|
||||
Generator enabled Генератор увімкнено
|
||||
Move Up Перемістити вгору
|
||||
Move Down Перемістити вниз
|
||||
Grid view Режим сітки
|
||||
List view Режим списку
|
||||
On your computer На вашому комп’ютері
|
||||
New file Новий файл
|
||||
Learn Навчання
|
||||
No recent files Немає останніх файлів
|
||||
Website Вебсайт
|
||||
|
Can't render this file because it contains an unexpected character in line 152 and column 53.
|
@@ -4029,3 +4029,13 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Stop Color Màu điểm dừng
|
||||
Shapes can't use patterns yet Hình chưa thể dùng mẫu tô
|
||||
Edit Brush… Chỉnh sửa cọ…
|
||||
Generator enabled Đã bật bộ tạo
|
||||
Move Up Di chuyển lên
|
||||
Move Down Di chuyển xuống
|
||||
Grid view Chế độ xem lưới
|
||||
List view Chế độ xem danh sách
|
||||
On your computer Trên máy tính của bạn
|
||||
New file Tệp mới
|
||||
Learn Học hỏi
|
||||
No recent files Không có tệp gần đây
|
||||
Website Trang web
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3207,3 +3207,14 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Solid Color 纯色
|
||||
Tint Color 色调颜色
|
||||
Edit Brush… 编辑画笔…
|
||||
Drag to move the active shape's path or the Work Path 拖动以移动当前形状的路径或工作路径
|
||||
Generator enabled 启用生成器
|
||||
Move Up 上移
|
||||
Move Down 下移
|
||||
Grid view 网格视图
|
||||
List view 列表视图
|
||||
On your computer 在您的计算机上
|
||||
New file 新建文件
|
||||
Learn 学习
|
||||
No recent files 没有最近使用的文件
|
||||
Website 网站
|
||||
|
Can't render this file because it contains an unexpected character in line 63 and column 53.
|
@@ -3163,3 +3163,14 @@ smartSvg AI/PDF/EPS contents will be edited as SVG. Saving replaces the embedded
|
||||
Solid Color 純色
|
||||
Tint Color 色調顏色
|
||||
Edit Brush… 編輯筆刷…
|
||||
Drag to move the active shape's path or the Work Path 拖曳以移動作用中形狀的路徑或工作路徑
|
||||
Generator enabled 啟用 Generator
|
||||
Move Up 上移
|
||||
Move Down 下移
|
||||
Grid view 格線檢視
|
||||
List view 清單檢視
|
||||
On your computer 在您的電腦上
|
||||
New file 新增檔案
|
||||
Learn 學習
|
||||
No recent files 沒有最近使用的檔案
|
||||
Website 網站
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -33,6 +33,7 @@ pub mod file_dialog;
|
||||
pub mod file_open;
|
||||
pub mod frame_stages;
|
||||
pub mod gpu_status;
|
||||
pub mod home_recent_ui;
|
||||
pub mod i18n;
|
||||
mod icon_data;
|
||||
pub mod icons;
|
||||
@@ -356,6 +357,7 @@ pub struct PhotocraftApp {
|
||||
info_samplers: Option<panels::SamplerReadouts>,
|
||||
/// Display profile readings (#569).
|
||||
monitors: monitor_status::State,
|
||||
pub(crate) thumbnail_cache: std::sync::Arc<std::sync::Mutex<crate::home_recent_ui::ThumbnailCache>>,
|
||||
checker: Option<egui::TextureHandle>,
|
||||
drag: Option<canvas::Drag>,
|
||||
/// An owned vector drag was cancelled (`canvas::cancel_stale_vector_drag`): the rest of its
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::PhotocraftApp;
|
||||
pub const DISCORD: &str = "https://discord.gg/artcraft";
|
||||
pub const ARTCRAFT_WEBSITE: &str = "https://getartcraft.com";
|
||||
pub const APP_PAGE: &str = "https://getartcraft.com/apps/photocraft";
|
||||
pub const TUTORIALS: &str = "https://getartcraft.com/tutorials";
|
||||
pub const GITHUB: &str = "https://github.com/storytold/photocraft";
|
||||
pub const ISSUES: &str = "https://github.com/storytold/photocraft/issues";
|
||||
|
||||
|
||||
@@ -117,6 +117,33 @@ mod open_recent_tests {
|
||||
assert!(invoke(&mut app, &ctx, "file.removeRecent", json!({})).is_err(), "needs a path");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn push_recent_evicts_thumbnails_beyond_cap() {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
{
|
||||
let mut cache = app.thumbnail_cache.lock().unwrap();
|
||||
for i in 0..25 {
|
||||
cache.entries.insert(
|
||||
format!("/tmp/item_{i}.png"),
|
||||
crate::home_recent_ui::ThumbnailEntry {
|
||||
key: crate::home_recent_ui::CacheKey::OpenDoc { revision: 1 },
|
||||
texture: None,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
last_checked: std::time::Instant::now(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
for i in 0..25 {
|
||||
app.push_recent(&format!("/tmp/item_{i}.png"));
|
||||
}
|
||||
let cache = app.thumbnail_cache.lock().unwrap();
|
||||
for i in 0..5 {
|
||||
assert!(!cache.entries.contains_key(&format!("/tmp/item_{i}.png")), "evicted item_{i} must be removed from cache");
|
||||
}
|
||||
assert_eq!(app.ui.recent_files.len(), 20);
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[test]
|
||||
fn opening_a_file_records_it_as_recent() {
|
||||
|
||||
@@ -18,6 +18,13 @@ pub struct ChromeState {
|
||||
/// Home screen shown over the open documents (Options bar › Home); holds the document count
|
||||
/// when it was opened, so opening or creating a document leaves it.
|
||||
pub home: Option<usize>,
|
||||
/// View mode for recent files on the Home screen: true = visual thumbnail card grid, false = text list.
|
||||
#[serde(default = "yes")]
|
||||
pub home_recent_grid: bool,
|
||||
}
|
||||
|
||||
fn yes() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
impl ChromeState {
|
||||
@@ -37,7 +44,7 @@ impl ChromeState {
|
||||
|
||||
impl Default for ChromeState {
|
||||
fn default() -> Self {
|
||||
Self { status_info: "dimensions".into(), home: None }
|
||||
Self { status_info: "dimensions".into(), home: None, home_recent_grid: true }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user