Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/ui-egui/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@
"No lens data embedded in this file.": "V tomto souboru nejsou vložena data objektivu.",
"No folders to browse": "Žádné složky k procházení",
"No imported folders yet": "Zatím žádné importované složky",
"Folders on this computer, browsed without adding them": "Složky v tomto počítači, procházené bez jejich přidání",
"No keywords are exported": "Neexportují se žádná klíčová slova",
"No keywords match": "Žádné klíčové slovo neodpovídá",
"No keywords yet": "Zatím žádná klíčová slova",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,7 @@
"No folders to browse": "Keine Ordner zum Durchsuchen",
"No photos yet": "Noch keine Fotos",
"No imported folders yet": "Noch keine importierten Ordner",
"Folders on this computer, browsed without adding them": "Ordner auf diesem Computer, die durchsucht werden, ohne sie hinzuzufügen",
"Show Sidebar Section": "Seitenleistenbereich anzeigen",
"Move Sidebar Section": "Seitenleistenbereich verschieben",
"New Library…": "Neue Bibliothek…",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,7 @@
"No folders to browse": "No hay carpetas para explorar",
"No photos yet": "Aún no hay fotos",
"No imported folders yet": "Aún no hay carpetas importadas",
"Folders on this computer, browsed without adding them": "Carpetas de este equipo, exploradas sin añadirlas",
"Show Sidebar Section": "Mostrar sección de la barra lateral",
"Move Sidebar Section": "Mover sección de la barra lateral",
"New Library…": "Nueva biblioteca…",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,7 @@
"No folders to browse": "Ei selattavia kansioita",
"No graphics processor found: LightCraft renders on the CPU, which is much slower. Details in Help → System Info.": "Grafiikkaprosessoria ei löytynyt: LightCraft renderöi suorittimella, mikä on paljon hitaampaa. Lisätietoja kohdassa Ohje → Järjestelmätiedot.",
"No imported folders yet": "Ei vielä tuotuja kansioita",
"Folders on this computer, browsed without adding them": "Tämän tietokoneen kansiot, joita selataan lisäämättä niitä",
"No keywords are exported": "Avainsanoja ei viedä",
"No keywords match": "Yksikään avainsana ei täsmää",
"No keywords yet": "Ei vielä avainsanoja",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,7 @@
"No folders to browse": "Aucun dossier à parcourir",
"No photos yet": "Aucune photo pour l’instant",
"No imported folders yet": "Aucun dossier importé pour l’instant",
"Folders on this computer, browsed without adding them": "Dossiers de cet ordinateur, parcourus sans être ajoutés",
"Show Sidebar Section": "Afficher la section de la barre latérale",
"Move Sidebar Section": "Déplacer la section de la barre latérale",
"New Library…": "Nouvelle bibliothèque…",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,7 @@
"No folders to browse": "Tidak ada folder untuk ditelusuri",
"No graphics processor found: LightCraft renders on the CPU, which is much slower. Details in Help → System Info.": "Prosesor grafis tidak ditemukan: LightCraft merender di CPU, yang jauh lebih lambat. Detailnya ada di Bantuan → Info sistem.",
"No imported folders yet": "Belum ada folder yang diimpor",
"Folders on this computer, browsed without adding them": "Folder di komputer ini, ditelusuri tanpa menambahkannya",
"No keywords are exported": "Tidak ada kata kunci yang diekspor",
"No keywords match": "Tidak ada kata kunci yang cocok",
"No keywords yet": "Belum ada kata kunci",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,7 @@
"No folders to browse": "Nessuna cartella da sfogliare",
"No photos yet": "Ancora nessuna foto",
"No imported folders yet": "Ancora nessuna cartella importata",
"Folders on this computer, browsed without adding them": "Cartelle su questo computer, sfogliate senza aggiungerle",
"Show Sidebar Section": "Mostra sezione della barra laterale",
"Move Sidebar Section": "Sposta sezione della barra laterale",
"New Library…": "Nuova libreria…",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1993,6 +1993,7 @@
"No folders to browse": "参照できるフォルダがありません",
"No photos yet": "写真はまだありません",
"No imported folders yet": "読み込んだフォルダはまだありません",
"Folders on this computer, browsed without adding them": "このコンピュータ上のフォルダを、追加せずに参照します",
"Show Sidebar Section": "サイドバーのセクションを表示",
"Move Sidebar Section": "サイドバーのセクションを移動",
"New Library…": "新しいライブラリ…",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/ka.json
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,7 @@
"No folders to browse": "დასათვალიერებელი საქაღალდეები არ არის",
"No graphics processor found: LightCraft renders on the CPU, which is much slower. Details in Help → System Info.": "გრაფიკული პროცესორი ვერ მოიძებნა: LightCraft რენდერს CPU-ზე ასრულებს, რაც გაცილებით ნელია. დეტალები: დახმარება → სისტემის ინფორმაცია.",
"No imported folders yet": "იმპორტირებული საქაღალდეები ჯერ არ არის",
"Folders on this computer, browsed without adding them": "ამ კომპიუტერის საქაღალდეები, რომლებიც დამატების გარეშე დათვალიერდება",
"No keywords are exported": "საკვანძო სიტყვები არ ექსპორტირდება",
"No keywords match": "შესაბამისი საკვანძო სიტყვა არ არის",
"No keywords yet": "საკვანძო სიტყვები ჯერ არ არის",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,7 @@
"No folders to browse": "Brak folderów do przeglądania",
"No graphics processor found: LightCraft renders on the CPU, which is much slower. Details in Help → System Info.": "Nie znaleziono procesora graficznego: LightCraft renderuje na CPU, co jest znacznie wolniejsze. Szczegóły w Pomoc → Informacje o systemie.",
"No imported folders yet": "Brak zaimportowanych folderów",
"Folders on this computer, browsed without adding them": "Foldery na tym komputerze, przeglądane bez dodawania ich",
"No photos yet": "Brak zdjęć",
"On NixOS, start it from `nix develop`.": "W systemie NixOS uruchom go z `nix develop`.",
"Open Recent Library": "Otwórz ostatnią bibliotekę",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,7 @@
"No folders to browse": "Nenhuma pasta para navegar",
"No photos yet": "Ainda não há fotos",
"No imported folders yet": "Ainda não há pastas importadas",
"Folders on this computer, browsed without adding them": "Pastas neste computador, navegadas sem adicioná-las",
"Show Sidebar Section": "Mostrar seção da barra lateral",
"Move Sidebar Section": "Mover seção da barra lateral",
"New Library…": "Nova biblioteca…",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,7 @@
"No folders to browse": "Нет папок для просмотра",
"No photos yet": "Фотографий пока нет",
"No imported folders yet": "Импортированных папок пока нет",
"Folders on this computer, browsed without adding them": "Папки на этом компьютере, которые просматриваются без добавления",
"Show Sidebar Section": "Показать раздел боковой панели",
"Move Sidebar Section": "Переместить раздел боковой панели",
"Move Up": "Переместить вверх",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,7 @@
"No folders to browse": "Inga mappar att bläddra i",
"No graphics processor found: LightCraft renders on the CPU, which is much slower. Details in Help → System Info.": "Ingen grafikprocessor hittades: LightCraft renderar på CPU:n, vilket är mycket långsammare. Mer information i Hjälp → Systeminfo.",
"No imported folders yet": "Inga importerade mappar än",
"Folders on this computer, browsed without adding them": "Mappar på den här datorn, som bläddras i utan att läggas till",
"No keywords are exported": "Inga nyckelord exporteras",
"No keywords match": "Inga nyckelord matchar",
"No keywords yet": "Inga nyckelord än",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,7 @@
"No folders to browse": "Немає тек для перегляду",
"No photos yet": "Фотографій ще немає",
"No imported folders yet": "Імпортованих тек ще немає",
"Folders on this computer, browsed without adding them": "Теки на цьому комп’ютері, які оглядаються без додавання",
"Show Sidebar Section": "Показати розділ бічної панелі",
"Move Sidebar Section": "Перемістити розділ бічної панелі",
"New Library…": "Нова бібліотека…",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,7 @@
"No folders to browse": "Không có thư mục để duyệt",
"No graphics processor found: LightCraft renders on the CPU, which is much slower. Details in Help → System Info.": "Không tìm thấy bộ xử lý đồ họa: LightCraft kết xuất trên CPU, chậm hơn nhiều. Chi tiết trong Trợ giúp → Thông tin hệ thống.",
"No imported folders yet": "Chưa có thư mục đã nhập",
"Folders on this computer, browsed without adding them": "Thư mục trên máy tính này, được duyệt mà không cần thêm vào",
"No keywords are exported": "Không xuất từ khóa nào",
"No keywords match": "Không có từ khóa khớp",
"No keywords yet": "Chưa có từ khóa",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/zh-hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,7 @@
"No folders to browse": "没有可浏览的文件夹",
"No photos yet": "还没有照片",
"No imported folders yet": "还没有导入的文件夹",
"Folders on this computer, browsed without adding them": "此电脑上的文件夹,无需添加即可浏览",
"Show Sidebar Section": "显示边栏分区",
"Move Sidebar Section": "移动边栏分区",
"New Library…": "新建图库…",
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/locales/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,7 @@
"No folders to browse": "沒有可瀏覽的資料夾",
"No photos yet": "還沒有照片",
"No imported folders yet": "還沒有匯入的資料夾",
"Folders on this computer, browsed without adding them": "這部電腦上的資料夾,無需加入即可瀏覽",
"Show Sidebar Section": "顯示側邊欄區段",
"Move Sidebar Section": "移動側邊欄區段",
"New Library…": "新增照片庫…",
Expand Down
88 changes: 80 additions & 8 deletions crates/ui-egui/src/panels/left/sections.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::albums::top_level_drop_target;
use super::rows::{ROW_HEIGHT, note_width};
use super::rows::{ROW_HEIGHT, Row, note_width};
use super::{Align2, Icon, LightcraftApp, Rect, Sense, SidebarSection, Tokens, icon_button, json, paint, pos2, register, vec2};

/// Space above a section's header.
Expand Down Expand Up @@ -43,7 +43,7 @@ pub(super) fn section(
let rows_from = ui.cursor().top();
body(app, ui);
if ui.cursor().top() <= rows_from {
empty_hint(ui, section);
empty_hint(app, ui, section);
}
}
PlacedSection { section, top: header.top(), bottom: ui.cursor().top(), open, rows }
Expand Down Expand Up @@ -83,15 +83,19 @@ pub(super) fn pinned_header(app: &mut LightcraftApp, ui: &mut egui::Ui, placed:
}

/// What an open section with nothing to list says in place of its rows (widget
/// `sidebarEmpty:<id>`), so the section stays where it is instead of disappearing.
fn empty_hint(ui: &mut egui::Ui, section: SidebarSection) {
/// `sidebarEmpty:<id>`), so the section stays where it is instead of disappearing. An empty
/// Folders also offers the ways to fill it ([`IMPORT_WAYS`]), as rows.
fn empty_hint(app: &mut LightcraftApp, ui: &mut egui::Ui, section: SidebarSection) {
let t = Tokens::get(ui.ctx());
let (r, _) = ui.allocate_exact_size(vec2(ui.available_width(), ROW_HEIGHT), Sense::hover());
register(ui, format!("sidebarEmpty:{}", section.id()), r);
let text = crate::i18n::tr(section.empty_hint());
let galley = ui.painter().layout_no_wrap(text.to_string(), t.font(12.5), t.text_dim);
note_width(ui, 42.0 + galley.size().x + 18.0);
ui.painter().galley(pos2(r.left() + 42.0, r.center().y - galley.size().y / 2.0), galley, t.text_dim);
if section == SidebarSection::Folders {
folders_import_rows(app, ui);
}
}

/// Where a section was laid out this frame (screen y): from its header's top to the end of its rows.
Expand Down Expand Up @@ -192,14 +196,20 @@ fn section_header(app: &mut LightcraftApp, ui: &mut egui::Ui, section: SidebarSe
let title = crate::i18n::tr(section.title());
let (interact, widget) = if pinned { ("sidebar-section-pinned", "sidebarSectionPinned") } else { ("sidebar-section", "sidebarSection") };
let resp = ui.interact(r, ui.scope_id().with((interact, id)), Sense::click_and_drag());
// (what the name leaves open, as Local's is the disk and not the library)
let resp = match section.header_hint() {
Some(hint) => resp.on_hover_text(crate::i18n::tr(hint)),
None => resp,
};
register(ui, format!("{widget}:{id}"), r);
let toggled = resp.clicked();
if toggled {
app.ui.sidebar.toggle_collapsed(section);
}
// dragged by its header, a section moves among the others (see `section_drag`); a press on
// the header's button is the button's, also when it turns into a drag
let on_button = header_button(section).is_some() && ui.input(|i| i.pointer.press_origin()).is_some_and(|p| header_button_rect(ui, r).contains(p));
let on_button =
header_button(app, section).is_some() && ui.input(|i| i.pointer.press_origin()).is_some_and(|p| header_button_rect(ui, r).contains(p));
if resp.drag_started_by(egui::PointerButton::Primary) && !on_button {
// picked up by the pinned header, the drag starts inside the top edge (see `drag_auto_scroll`)
ui.data_mut(|d| d.insert_temp(egui::Id::unique("left-section-drag-from-pinned"), pinned));
Expand All @@ -220,7 +230,7 @@ fn section_header(app: &mut LightcraftApp, ui: &mut egui::Ui, section: SidebarSe
let col = if hovered { t.text } else { t.text_dim };
paint(ui.painter(), Rect::from_center_size(c, vec2(16.0, 16.0)), if open { Icon::ChevronDown } else { Icon::ChevronRight }, col);
ui.painter().text(pos2(r.left() + 18.0, r.center().y), Align2::LEFT_CENTER, title, t.semibold(13.5), t.text_label);
let button = header_button(section);
let button = header_button(app, section);
// (an album being dragged puts "Top Level" in the Albums header)
let room = !(section == SidebarSection::Albums && app.ui.dragging_album.is_some());
if !open && rows > 0 && app.ui.show_counts && room {
Expand Down Expand Up @@ -262,15 +272,22 @@ enum HeaderAction {
/// The button a section has at the end of its header, if it has one. This is the one place that
/// says so: the header (its own and the pinned copy) draws the button at the visible edge, keeps
/// its clicks from folding the section and leaves it room beside a folded section's count.
fn header_button(section: SidebarSection) -> Option<HeaderButton> {
fn header_button(app: &LightcraftApp, section: SidebarSection) -> Option<HeaderButton> {
match section {
SidebarSection::Albums => {
Some(HeaderButton { id: "albumNew", icon: Icon::Plus, tooltip: "Create Album", action: HeaderAction::Menu(new_album_menu) })
}
SidebarSection::Keywords => {
Some(HeaderButton { id: "keywordNew", icon: Icon::Plus, tooltip: "Create Keyword Tag", action: HeaderAction::Run(new_keyword) })
}
SidebarSection::Local | SidebarSection::ByDate | SidebarSection::Folders => None,
// (a host with no dialog to pick with can't import from here: no + either)
SidebarSection::Folders => (import_ways(app).next().is_some()).then_some(HeaderButton {
id: "foldersImport",
icon: Icon::Plus,
tooltip: "Import",
action: HeaderAction::Menu(import_menu),
}),
SidebarSection::Local | SidebarSection::ByDate => None,
}
}

Expand Down Expand Up @@ -378,6 +395,61 @@ fn new_album_menu(app: &mut LightcraftApp, ui: &mut egui::Ui) {
}
}

/// One way into the library from the Folders section: a command File ▸ Import offers, as a row of
/// the empty section and as an item of the header's + menu.
struct ImportWay {
command: &'static str,
/// In English (translated where it is shown).
label: &'static str,
/// The empty section's row: widget `source:<row>`.
row: &'static str,
/// The + menu's item: its widget.
item: &'static str,
}

/// Import Photos…, and where the host has a folder picker (not the web build) Import from Folder….
const IMPORT_WAYS: [ImportWay; 2] = [
ImportWay { command: "file.addPhotos", label: "Import Photos…", row: "folders:import", item: "button:foldersImportPhotos" },
ImportWay { command: "file.addFolder", label: "Import from Folder…", row: "folders:importFolder", item: "button:foldersImportFolder" },
];

/// The ways in this build offers right now: a command that can't run is not offered. That is the menu's
/// own rule, and for Import Photos… (which the menu always enables, and which does nothing on a host with
/// no dialog to pick files with) a file picker of either kind. Decided up front, so the caller is free to
/// use `app` as it draws them.
fn import_ways(app: &LightcraftApp) -> impl Iterator<Item = &'static ImportWay> + use<> {
let can_pick_files = app.services.pick_files.is_some() || app.services.picker.is_some();
let offered = IMPORT_WAYS.each_ref().map(|w| crate::menus::ui_enabled(app, w.command) && (w.command != "file.addPhotos" || can_pick_files));
IMPORT_WAYS.iter().zip(offered).filter_map(|(way, offered)| offered.then_some(way))
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

/// Run one of [`IMPORT_WAYS`] as its menu item does (it asks for the photos or the folder); a refusal is a toast.
fn run_import(app: &mut LightcraftApp, ctx: &egui::Context, way: &ImportWay) {
if let Err(e) = app.run(way.command, json!({})) {
app.toast(ctx, e);
}
}

/// What an empty Folders offers below its "No imported folders yet": a row for each of [`IMPORT_WAYS`].
fn folders_import_rows(app: &mut LightcraftApp, ui: &mut egui::Ui) {
for way in import_ways(app) {
if Row::new(way.row, Icon::Plus, crate::i18n::tr(way.label)).show(app, ui).clicked() {
run_import(app, ui.ctx(), way);
}
}
}

/// The menu of Folders' +: Import Photos…, Import from Folder….
fn import_menu(app: &mut LightcraftApp, ui: &mut egui::Ui) {
for way in import_ways(app) {
let item = ui.button(crate::i18n::tr(way.label));
register(ui, way.item, item.rect);
if item.clicked() {
run_import(app, ui.ctx(), way);
}
}
}

/// How many library photos have no file (Local browse records are not checked; see
/// `cmd::missing::checked_path`). Checking stats every file, which on a network share takes
/// seconds, so it runs on a worker thread: the count shown is the last finished one, refreshed
Expand Down
9 changes: 9 additions & 0 deletions crates/ui-egui/src/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ impl SidebarSection {
}
}

/// What hovering the section's header says, in English, where the name alone leaves it open
/// (Local is the disk, not the library); `None` where the name says it.
pub const fn header_hint(self) -> Option<&'static str> {
match self {
SidebarSection::Local => Some("Folders on this computer, browsed without adding them"),
SidebarSection::Albums | SidebarSection::ByDate | SidebarSection::Folders | SidebarSection::Keywords => None,
}
}

pub fn from_id(id: &str) -> Option<SidebarSection> {
Self::ALL.into_iter().find(|s| s.id() == id)
}
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ mod rules_editor;
mod sam_setup;
mod scan_probes;
mod scroll;
mod sidebar_folders_import;
mod slider_reset;
mod slideshow;
mod solo_sections;
Expand Down
Loading
Loading