team-ljyzipelo

공개

긴 이름과 경로가 화면을 밀어내지 않도록 제한함

작성자
호시노 히나타
작성 시각
커밋
8ce724306fa9cadc13967f6db37be304325cb81b
부모
0c1b0da
이 시점의 파일 보기

변경된 파일 11개

+371-22
수정experiments/rust-ui-memory-app/src/archive_screen.rs+58-22
@@ -489,7 +489,15 @@ impl ArchiveApp {
489489 format!("{} — Zipelo", full.display())
490490 })
491491 .unwrap_or_else(|| "Zipelo".into());
492삭제: ctx.send_viewport_cmd(egui::ViewportCommand::Title(title));
492추가: let short_title = if let Some(path) = title.strip_suffix(" — Zipelo") {
493추가: format!(
494추가: "{} — Zipelo",
495추가: theme::window_title(root, path, ctx.content_rect().width() - 300.0)
496추가: )
497추가: } else {
498추가: title.clone()
499추가: };
500추가: ctx.send_viewport_cmd(egui::ViewportCommand::Title(short_title));
493501 egui::Panel::top("archive-actions")
494502 .frame(
495503 theme::panel(theme::PANEL)
@@ -499,7 +507,10 @@ impl ArchiveApp {
499507 .show(root, |ui| {
500508 ui.horizontal(|ui| {
501509 let idle = !self.model.busy() && self.model.close == Close::Open;
502삭제: if theme::tool(ui, "열기", theme::OPEN, idle, false).clicked() {
510추가: if theme::tool(ui, "열기", theme::OPEN, idle, false)
511추가: .on_hover_text(&title)
512추가: .clicked()
513추가: {
503514 self.open_picker(Purpose::Open);
504515 }
505516 if theme::tool(ui, "압축하기", theme::CREATE, idle, false).clicked() {
@@ -526,12 +537,21 @@ impl ArchiveApp {
526537 )
527538 .show(root, |ui| {
528539 ui.horizontal(|ui| {
529삭제: ui.label(format!(
530삭제: "{}개 항목",
531삭제: browser::rows(&self.model.entries, &self.folder, &self.search).len()
532삭제: ));
540추가: let width = (ui.available_width() - ui.spacing().item_spacing.x) / 2.0;
541추가: theme::bounded_text(
542추가: ui,
543추가: &format!(
544추가: "{}개 항목",
545추가: browser::rows(&self.model.entries, &self.folder, &self.search).len()
546추가: ),
547추가: width,
548추가: );
533549 ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
534삭제: ui.label(format!("선택 {}개", self.model.selected.len()));
550추가: theme::bounded_text(
551추가: ui,
552추가: &format!("선택 {}개", self.model.selected.len()),
553추가: width,
554추가: );
535555 });
536556 });
537557 });
@@ -657,11 +677,16 @@ impl ArchiveApp {
657677 self.browse_folder(&parent);
658678 }
659679 ui.label("현재 경로");
660삭제: let mut path = format!("/{}", self.folder);
661삭제: ui.add_sized(
662삭제: [ui.available_width() - 270.0, 36.0],
663삭제: egui::TextEdit::singleline(&mut path).interactive(false),
664삭제: );
680추가: let path = format!("/{}", self.folder);
681추가: let width = (ui.available_width() - 270.0).max(0.0);
682추가: egui::Frame::new()
683추가: .fill(theme::PANEL)
684추가: .stroke(egui::Stroke::new(1.0, theme::BORDER))
685추가: .corner_radius(6)
686추가: .inner_margin(egui::Margin::symmetric(8, 7))
687추가: .show(ui, |ui| {
688추가: theme::bounded_text(ui, &path, (width - 18.0).max(0.0));
689추가: });
665690 let (rect, _) =
666691 ui.allocate_exact_size(egui::vec2(20.0, 20.0), egui::Sense::hover());
667692 theme::svg_icon(ui.painter(), rect, theme::SEARCH, theme::MUTED);
@@ -753,20 +778,23 @@ impl ArchiveApp {
753778 );
754779 let label = ui
755780 .allocate_ui_with_layout(
756삭제: egui::vec2(name_width - 28.0, 34.0),
781추가: egui::vec2((name_width - 28.0).max(0.0), 34.0),
757782 Layout::left_to_right(Align::Center),
758783 |ui| {
759삭제: ui.set_min_width(name_width - 28.0);
784추가: ui.set_min_width((name_width - 28.0).max(0.0));
785추가: ui.set_max_width((name_width - 28.0).max(0.0));
760786 ui.add_enabled(
761787 !self.model.busy(),
762788 egui::Button::new(&row.name)
789추가: .truncate()
763790 .selected(selected)
764791 .frame(false)
765792 .min_size(egui::vec2(0.0, 34.0)),
766793 )
767794 },
768795 )
769삭제: .inner;
796추가: .inner
797추가: .on_hover_text(&row.name);
770798 theme::focus(&label);
771799 let enter =
772800 label.has_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
@@ -996,12 +1024,13 @@ impl ArchiveApp {
9961024 .max_height(max_height)
9971025 .show(ui, |ui| {
9981026 if success {
999삭제: ui.label(match self.last_request.as_ref() {
1027추가: let path = match self.last_request.as_ref() {
10001028 Some(Start::CreateZip { output_file, .. }) => {
10011029 output_file.display().to_string()
10021030 }
10031031 _ => format!("{} 폴더에 저장했습니다.", self.destination.display()),
1004삭제: });
1032추가: };
1033추가: theme::bounded_text(ui, &path, ui.available_width());
10051034 } else if let Some(code) = t.as_ref().and_then(|t| t.error) {
10061035 ui.label(if creating && code == ErrorCode::SourceChanged {
10071036 "묶을 파일이 바뀌었습니다. 파일을 확인한 뒤 다시 만드세요"
@@ -1047,7 +1076,11 @@ impl ArchiveApp {
10471076 ui.label(error);
10481077 }
10491078 for (name, state) in &self.model.outputs {
1050삭제: ui.label(format!("{name}: {}", disposition_label(*state)));
1079추가: theme::bounded_text(
1080추가: ui,
1081추가: &format!("{name}: {}", disposition_label(*state)),
1082추가: ui.available_width(),
1083추가: );
10511084 }
10521085 });
10531086 }
@@ -1235,10 +1268,13 @@ impl ArchiveApp {
12351268 },
12361269 20.0,
12371270 );
1238삭제: ui.label(present::middle_text(
1239삭제: &path.file_name().unwrap_or_default().to_string_lossy(),
1240삭제: 36,
1241삭제: ))
1271추가: let name =
1272추가: path.file_name().unwrap_or_default().to_string_lossy();
1273추가: theme::bounded_text(
1274추가: ui,
1275추가: &name,
1276추가: (ui.available_width() - 72.0).max(0.0),
1277추가: )
12421278 .on_hover_text(path.display().to_string());
12431279 if ui.button("빼기").clicked() {
12441280 remove = Some(index);
수정experiments/rust-ui-memory-app/src/archive_theme.rs+31-0
@@ -199,6 +199,37 @@ pub fn icon(ui: &mut egui::Ui, kind: Icon, size: f32) {
199199 }
200200}
201201
202추가: pub fn bounded_text(ui: &mut egui::Ui, text: &str, width: f32) -> egui::Response {
203추가: let width = width.max(0.0);
204추가: ui.allocate_ui_with_layout(
205추가: egui::vec2(width, ui.text_style_height(&TextStyle::Body)),
206추가: ui.layout().clone(),
207추가: |ui| {
208추가: ui.set_min_width(width);
209추가: ui.set_max_width(width);
210추가: ui.add(egui::Label::new(text).truncate())
211추가: },
212추가: )
213추가: .inner
214추가: .on_hover_text(text)
215추가: }
216추가:
217추가: pub fn window_title(ui: &egui::Ui, text: &str, width: f32) -> String {
218추가: let mut job =
219추가: egui::text::LayoutJob::simple_singleline(text.into(), FontId::proportional(BODY), TEXT);
220추가: job.wrap = egui::text::TextWrapping {
221추가: max_width: width.max(0.0),
222추가: max_rows: 1,
223추가: break_anywhere: true,
224추가: ..Default::default()
225추가: };
226추가: ui.fonts_mut(|fonts| fonts.layout_job(job))
227추가: .rows
228추가: .iter()
229추가: .flat_map(|row| row.glyphs.iter().map(|glyph| glyph.chr))
230추가: .collect()
231추가: }
232추가:
202233pub fn column_label(
203234 ui: &mut egui::Ui,
204235 text: impl Into<egui::WidgetText>,
수정tests/rust-app-ui/capture.rs+42-0
@@ -289,6 +289,48 @@ impl eframe::App for Capture {
289289 }
290290 if !self.triggered && self.app.model.list_id.is_some() {
291291 self.triggered = true;
292추가: if self.mode.starts_with("long-") {
293추가: let name = format!("{}.txt", "W".repeat(220));
294추가: let folder = "deep-folder/".repeat(30);
295추가: let base = std::env::current_dir()
296추가: .unwrap()
297추가: .join("tests/ui-redesign/runs/fixtures");
298추가: self.app.model.archive = Some(base.join(&folder).join(format!("{name}.zip")));
299추가: if self.mode == "long-list" || self.mode == "long-folder" {
300추가: self.app.model.entries = (0..5000)
301추가: .map(|id| Entry {
302추가: id,
303추가: name: format!(
304추가: "{}{id:04}-{name}",
305추가: if self.mode == "long-folder" {
306추가: folder.as_str()
307추가: } else {
308추가: ""
309추가: }
310추가: ),
311추가: kind: Kind::File,
312추가: bytes: Some(31),
313추가: packed: None,
314추가: encrypted: true,
315추가: })
316추가: .collect();
317추가: if self.mode == "long-folder" {
318추가: self.app.browse_folder(folder.trim_end_matches('/'));
319추가: }
320추가: }
321추가: if self.mode == "long-create" {
322추가: let source = base.join(&name);
323추가: std::fs::write(&source, b"capture source").unwrap();
324추가: self.app.add_sources(vec![source]);
325추가: self.app.show_create(false);
326추가: }
327추가: if self.mode == "long-result" {
328추가: let destination = base.join(&folder);
329추가: std::fs::create_dir_all(&destination).unwrap();
330추가: self.app.choose_destination(destination);
331추가: self.app.begin_extract();
332추가: }
333추가: }
292334 if self.mode == "toolbar-folder" {
293335 self.app.browse_folder("Install");
294336 }
추가tests/rust-app-ui/long_layout.rs+211-0
@@ -0,0 +1,211 @@
1추가: fn narrow_frame(
2추가: ctx: &egui::Context,
3추가: app: &mut ArchiveApp,
4추가: time: f64,
5추가: events: Vec<egui::Event>,
6추가: ) -> egui::FullOutput {
7추가: let mut output = ctx.run_ui(
8추가: egui::RawInput {
9추가: screen_rect: Some(egui::Rect::from_min_size(
10추가: egui::Pos2::ZERO,
11추가: egui::vec2(760.0, 540.0),
12추가: )),
13추가: time: Some(time),
14추가: events,
15추가: ..Default::default()
16추가: },
17추가: |ui| app.show(ui),
18추가: );
19추가: output.textures_delta.clear();
20추가: output
21추가: }
22추가:
23추가: fn layout_text(output: &egui::FullOutput) -> Vec<(String, egui::Rect, bool)> {
24추가: fn walk(shape: &Shape, result: &mut Vec<(String, egui::Rect, bool)>) {
25추가: match shape {
26추가: Shape::Text(text) => result.push((
27추가: text.galley.job.text.clone(),
28추가: text.galley.rect.translate(text.pos.to_vec2()),
29추가: text.galley.elided,
30추가: )),
31추가: Shape::Vec(shapes) => {
32추가: for shape in shapes {
33추가: walk(shape, result);
34추가: }
35추가: }
36추가: _ => {}
37추가: }
38추가: }
39추가: let mut result = Vec::new();
40추가: for shape in &output.shapes {
41추가: walk(&shape.shape, &mut result);
42추가: }
43추가: result
44추가: }
45추가:
46추가: fn assert_narrow_text(output: &egui::FullOutput) {
47추가: for (text, rect, _) in layout_text(output) {
48추가: assert!(
49추가: rect.left() >= -1.0 && rect.right() <= 761.0,
50추가: "{text:?}: {rect:?}"
51추가: );
52추가: }
53추가: }
54추가:
55추가: fn assert_full_tooltip(ctx: &egui::Context, app: &mut ArchiveApp, point: egui::Pos2, full: &str) {
56추가: ctx.style_mut_of(egui::Theme::Light, |style| {
57추가: style.interaction.tooltip_delay = 0.0
58추가: });
59추가: let mut output = narrow_frame(ctx, app, 10.0, vec![egui::Event::PointerMoved(point)]);
60추가: for time in [11.0, 12.0, 13.0] {
61추가: output = narrow_frame(ctx, app, time, vec![]);
62추가: }
63추가: assert!(
64추가: layout_text(&output)
65추가: .iter()
66추가: .any(|(text, _, elided)| text == full && !elided),
67추가: "전체 툴팁 없음: {full} point={point:?} shown={:?}",
68추가: layout_text(&output)
69추가: );
70추가: assert_narrow_text(&output);
71추가: }
72추가:
73추가: #[test]
74추가: fn narrow_archive_keeps_columns_and_virtualizes_thousands_of_long_names() {
75추가: let scratch = Folder::new();
76추가: let factory = FakeFactory::default();
77추가: let mut app = loaded(&scratch, &factory);
78추가: let name = format!("{}.txt", "W".repeat(220));
79추가: app.model.entries = (0..5000)
80추가: .map(|id| Entry {
81추가: id,
82추가: name: format!("{id:04}-{name}"),
83추가: kind: Kind::File,
84추가: bytes: Some(31),
85추가: packed: None,
86추가: encrypted: true,
87추가: })
88추가: .collect();
89추가: app.model.selected = (0..5000).collect();
90추가: app.model.archive = Some(
91추가: scratch
92추가: .0
93추가: .join("deep-folder/".repeat(30))
94추가: .join(format!("{name}.zip")),
95추가: );
96추가: let full_title = format!("{} — Zipelo", app.model.archive.as_ref().unwrap().display());
97추가: let ctx = egui::Context::default();
98추가: narrow_frame(&ctx, &mut app, 0.0, vec![]);
99추가: let output = narrow_frame(&ctx, &mut app, 1.0, vec![]);
100추가: assert_narrow_text(&output);
101추가: let text = layout_text(&output);
102추가: assert!(text.len() < 100);
103추가: let first = text
104추가: .iter()
105추가: .find(|(text, _, _)| text == &format!("0000-{name}"))
106추가: .unwrap();
107추가: assert!(first.2);
108추가: assert!(
109추가: text.iter()
110추가: .any(|(text, rect, _)| text == "31 B" && rect.right() < 720.0)
111추가: );
112추가: for expected in ["크기", "암호", "5000개 항목", "선택 5000개"] {
113추가: assert!(text.iter().any(|(text, _, _)| text == expected));
114추가: }
115추가: let title = output
116추가: .viewport_output
117추가: .values()
118추가: .flat_map(|v| &v.commands)
119추가: .find_map(|cmd| match cmd {
120추가: egui::ViewportCommand::Title(title) => Some(title),
121추가: _ => None,
122추가: })
123추가: .unwrap();
124추가: assert!(title.contains('…') && title.ends_with(" — Zipelo"));
125추가: assert!(title.chars().count() < full_title.chars().count());
126추가: assert_full_tooltip(&ctx, &mut app, first.1.center(), &first.0);
127추가: let output = narrow_frame(&ctx, &mut app, 14.0, vec![egui::Event::PointerGone]);
128추가: let point = layout_text(&output)
129추가: .into_iter()
130추가: .find(|(text, _, _)| text == "열기")
131추가: .unwrap()
132추가: .1
133추가: .center();
134추가: assert_full_tooltip(&ctx, &mut app, point, &full_title);
135추가: }
136추가:
137추가: #[test]
138추가: fn narrow_deep_folder_path_is_elided_without_displacing_search() {
139추가: let scratch = Folder::new();
140추가: let factory = FakeFactory::default();
141추가: let mut app = loaded(&scratch, &factory);
142추가: let folder = "deep-folder/".repeat(40).trim_end_matches('/').to_owned();
143추가: app.model.entries[0].name = format!("{folder}/file.txt");
144추가: app.browse_folder(&folder);
145추가: let ctx = egui::Context::default();
146추가: narrow_frame(&ctx, &mut app, 0.0, vec![]);
147추가: let output = narrow_frame(&ctx, &mut app, 1.0, vec![]);
148추가: assert_narrow_text(&output);
149추가: let text = layout_text(&output);
150추가: let full = format!("/{folder}");
151추가: let path = text.iter().find(|(text, _, _)| text == &full).unwrap();
152추가: assert!(path.2);
153추가: assert!(
154추가: text.iter()
155추가: .any(|(text, rect, _)| text == "파일 찾기" && rect.right() < 760.0)
156추가: );
157추가: assert_full_tooltip(&ctx, &mut app, path.1.center(), &full);
158추가: }
159추가:
160추가: #[test]
161추가: fn narrow_create_sources_keep_remove_and_footer_actions_visible() {
162추가: let scratch = Folder::new();
163추가: let factory = FakeFactory::default();
164추가: let mut app = loaded(&scratch, &factory);
165추가: let name = format!("{}.txt", "W".repeat(220));
166추가: let path = scratch.0.join(&name);
167추가: fs::write(&path, b"source").unwrap();
168추가: app.add_sources(vec![path]);
169추가: app.show_create(false);
170추가: let ctx = egui::Context::default();
171추가: narrow_frame(&ctx, &mut app, 0.0, vec![]);
172추가: let output = narrow_frame(&ctx, &mut app, 1.0, vec![]);
173추가: assert_narrow_text(&output);
174추가: let text = layout_text(&output);
175추가: assert!(
176추가: text.iter()
177추가: .any(|(text, _, elided)| text == &name && *elided)
178추가: );
179추가: for expected in ["빼기", "취소", "압축하기"] {
180추가: assert!(
181추가: text.iter()
182추가: .any(|(text, rect, _)| text == expected && rect.bottom() <= 540.0)
183추가: );
184추가: }
185추가: }
186추가:
187추가: #[test]
188추가: fn narrow_result_path_is_elided_and_full_path_remains_in_tooltip() {
189추가: let scratch = Folder::new();
190추가: let factory = FakeFactory::default();
191추가: let mut app = loaded(&scratch, &factory);
192추가: let output_path = scratch.0.join("nested-output/".repeat(30));
193추가: fs::create_dir_all(&output_path).unwrap();
194추가: app.choose_destination(output_path.clone());
195추가: assert!(app.begin_extract());
196추가: pump(&mut app.model);
197추가: let ctx = egui::Context::default();
198추가: for frame in 0..8 {
199추가: narrow_frame(&ctx, &mut app, frame as f64 / 10.0, vec![]);
200추가: }
201추가: let output = narrow_frame(&ctx, &mut app, 1.0, vec![]);
202추가: assert_narrow_text(&output);
203추가: let text = layout_text(&output);
204추가: let full = format!("{} 폴더에 저장했습니다.", output_path.display());
205추가: let path = text.iter().find(|(text, _, _)| text == &full).unwrap();
206추가: assert!(path.2);
207추가: for expected in ["확인", "폴더 열기"] {
208추가: assert!(text.iter().any(|(text, _, _)| text == expected));
209추가: }
210추가: assert_full_tooltip(&ctx, &mut app, path.1.center(), &full);
211추가: }
수정tests/rust-app-ui/presentation.rs+1-0
@@ -902,6 +902,7 @@ mod widgets {
902902 }
903903 }
904904 include!("toolbar.rs");
905추가: include!("long_layout.rs");
905906}
906907
907908#[cfg(feature = "ui")]
수정tests/ui-redesign/README.md+2-0
@@ -20,6 +20,8 @@ Enter는 초점이 있는 버튼만 활성화하며 암호 입력란 제출만
2020
2121Linux는 rfd가 사용하는 기존 ashpd backend의 오류 응답을 직접 받아 사용자 취소와 구분함. portal_response_distinguishes_cancellation_from_backend_failure는 취소 코드, backend 실패와 잘못된 성공 응답을 구분함. missing_portal_returns_errors_for_every_dialog는 별도 자식 프로세스의 연결 불가 bus로 실제 native backend 8개 경로를 확인하며 부모의 세션 환경은 바꾸지 않음. dialog_failures_show_alerts_while_cancelled_dialogs_remain_silent는 열기, 파일 추가, 폴더 추가, 풀 위치, ZIP 저장과 GZ 저장에서 실패 안내와 취소 무작업을 대조함.
2222
23추가: 760px 화면의 긴 텍스트는 long_layout.rs에서 확인함. 220자 이름과 깊은 경로, 5,000개 항목에서도 크기와 암호 열, 검색, 상태 줄과 모달 버튼이 화면 안에 유지되는지 실제 글자 배치로 검증함. 이름과 현재 경로 및 결과 경로는 말줄임과 전체 텍스트 툴팁을 확인함. 창 제목은 폭에 맞춰 줄이고 전체 압축파일 경로는 열기 버튼의 툴팁에서 확인함. screenshots/long-layout에 목록, 깊은 폴더, ZIP 만들기와 결과 화면을 기록함.
24추가:
2325## 화면 재현
2426
2527Xvfb, xdotool, ImageMagick import와 시스템 CJK 글꼴이 필요함. 촬영 실행 파일은 실제 eframe 컴포넌트에 합성 목록을 전달하며 압축파일을 읽거나 결과물을 저장하지 않음.
추가tests/ui-redesign/screenshots/long-layout/capture.json+26-0
@@ -0,0 +1,26 @@
1추가: [
2추가: {
3추가: "state": "long-list",
4추가: "path": "tests/ui-redesign/screenshots/long-layout/long-list.png",
5추가: "width": 760,
6추가: "height": 540
7추가: },
8추가: {
9추가: "state": "long-folder",
10추가: "path": "tests/ui-redesign/screenshots/long-layout/long-folder.png",
11추가: "width": 760,
12추가: "height": 540
13추가: },
14추가: {
15추가: "state": "long-create",
16추가: "path": "tests/ui-redesign/screenshots/long-layout/long-create.png",
17추가: "width": 760,
18추가: "height": 540
19추가: },
20추가: {
21추가: "state": "long-result",
22추가: "path": "tests/ui-redesign/screenshots/long-layout/long-result.png",
23추가: "width": 760,
24추가: "height": 540
25추가: }
26추가: ]
추가tests/ui-redesign/screenshots/long-layout/long-create.png

바이너리 파일이라 Diff를 표시하지 않아요.

파일 내려받기
추가tests/ui-redesign/screenshots/long-layout/long-folder.png

바이너리 파일이라 Diff를 표시하지 않아요.

파일 내려받기
추가tests/ui-redesign/screenshots/long-layout/long-list.png

바이너리 파일이라 Diff를 표시하지 않아요.

파일 내려받기
추가tests/ui-redesign/screenshots/long-layout/long-result.png

바이너리 파일이라 Diff를 표시하지 않아요.

파일 내려받기