team-ljyzipelo

공개

Merge pull request #100 from Team-LJY/features/explorer-toolbar-polish

탐색기 화면 정리, Pretendard 글꼴, 폴더 선택으로 시작하는 ZIP 만들기 창
작성자
LeeJunyoung
작성 시각
커밋
97357bd577c847becd212fd47ca95e195d4c8364
이 시점의 파일 보기

변경된 파일 23개

+1,347-184
수정experiments/rust-ui-memory-app/THIRD-PARTY-NOTICES.txt+1-0
@@ -5,3 +5,4 @@ Zipelo 의존성 고지 생성 안내
55로컬 registry의 원문과 잠금 체크섬을 확인하며 누락 시 패키지 생성을 중단함.
66이 안내 파일과 과거 시험용 보충 원문은 최종 배포 고지를 대신하지 않음.
77운영체제 기본 파일 창의 rfd 0.16.0(MIT)과 Linux xdg-portal 전이 의존성도 잠금 파일에서 수집함.
8추가: 앱에 포함한 Pretendard 1.3.9 글꼴(SIL OFL 1.1)의 원문도 같은 고지에 넣음. 출처는 src/assets/fonts/README.md임.
수정experiments/rust-ui-memory-app/src/archive_screen.rs

Diff가 표시 한도를 넘어서 생략했어요.

Raw로 열기
수정experiments/rust-ui-memory-app/src/archive_theme.rs+333-57
@@ -10,6 +10,12 @@ pub const BLUE: Color32 = Color32::from_rgb(37, 99, 235);
1010pub const BLUE_HOVER: Color32 = Color32::from_rgb(29, 78, 216);
1111pub const BLUE_ACTIVE: Color32 = Color32::from_rgb(30, 64, 175);
1212pub const SELECTED: Color32 = Color32::from_rgb(232, 240, 254);
13추가: /// 파일 목록에서 선택한 행의 반투명 파란 배경 (BLUE 12%).
14추가: pub const ROW_SELECTED: Color32 = Color32::from_rgba_unmultiplied_const(37, 99, 235, 31);
15추가: /// 파일 목록에서 마우스를 올린 행의 배경. 선택한 행보다 조금 더 투명함 (BLUE 6%).
16추가: pub const ROW_HOVER: Color32 = Color32::from_rgba_unmultiplied_const(37, 99, 235, 15);
17추가: /// 선택한 행에 마우스를 올렸을 때의 배경. 선택 색보다 덜 투명함 (BLUE 18%).
18추가: pub const ROW_SELECTED_HOVER: Color32 = Color32::from_rgba_unmultiplied_const(37, 99, 235, 46);
1319pub const DROP: Color32 = Color32::from_rgb(238, 244, 255);
1420pub const DASH: Color32 = Color32::from_rgb(170, 180, 192);
1521pub const SUCCESS: Color32 = Color32::from_rgb(21, 128, 61);
@@ -27,8 +33,40 @@ pub const DROP_HEIGHT: f32 = 280.0;
2733pub const DROP_RADIUS: u8 = 12;
2834pub const ROW: f32 = 32.0;
2935pub const BUTTON: f32 = 40.0;
30삭제: pub const BODY: f32 = 17.0;
31삭제: pub const TITLE: f32 = 22.0;
36추가: /// 글자 크기 단계. 앱의 모든 글자는 이 세 값 중 하나를 씀.
37추가: /// 기본 16px을 기준으로 보조 글자는 작게, 제목과 강조 글자는 크게 씀.
38추가: pub const FONT_SMALL: f32 = 14.0;
39추가: pub const FONT_BODY: f32 = 16.0;
40추가: pub const FONT_LARGE: f32 = 20.0;
41추가: /// 경로와 검색 입력란의 높이. 위쪽 경로 줄은 이 높이만큼만 차지함.
42추가: pub const FIELD: f32 = 36.0;
43추가: /// 테두리 없는 버튼에 마우스를 올리거나 누를 때의 배경.
44추가: pub const HOVER: Color32 = Color32::from_rgb(229, 233, 239);
45추가: pub const PRESS: Color32 = Color32::from_rgb(214, 220, 229);
46추가:
47추가: /// 앱에 포함한 기본 글꼴 (SIL OFL 1.1, assets/fonts/OFL.txt).
48추가: pub const PRETENDARD: &[u8] = include_bytes!("assets/fonts/Pretendard-Regular.ttf");
49추가:
50추가: /// Pretendard를 기본 글꼴로 쓰고, 없는 글자는 운영체제 한글 글꼴로 대신 그림.
51추가: pub fn fonts(fallback: Option<(Vec<u8>, u32)>) -> egui::FontDefinitions {
52추가: let mut fonts = egui::FontDefinitions::empty();
53추가: fonts.font_data.insert(
54추가: "pretendard".into(),
55추가: egui::FontData::from_static(PRETENDARD).into(),
56추가: );
57추가: let mut family = vec!["pretendard".to_owned()];
58추가: if let Some((bytes, index)) = fallback {
59추가: let mut data = egui::FontData::from_owned(bytes);
60추가: data.index = index;
61추가: fonts.font_data.insert("system-kr".into(), data.into());
62추가: family.push("system-kr".into());
63추가: }
64추가: fonts
65추가: .families
66추가: .insert(egui::FontFamily::Proportional, family.clone());
67추가: fonts.families.insert(egui::FontFamily::Monospace, family);
68추가: fonts
69추가: }
3270
3371pub fn apply(ctx: &egui::Context) {
3472 ctx.set_theme(egui::Theme::Light);
@@ -36,16 +74,16 @@ pub fn apply(ctx: &egui::Context) {
3674 ctx.style_mut_of(egui::Theme::Light, |style| {
3775 style
3876 .text_styles
39삭제: .insert(TextStyle::Body, FontId::proportional(BODY));
77추가: .insert(TextStyle::Body, FontId::proportional(FONT_BODY));
4078 style
4179 .text_styles
42삭제: .insert(TextStyle::Button, FontId::proportional(BODY));
80추가: .insert(TextStyle::Button, FontId::proportional(FONT_BODY));
4381 style
4482 .text_styles
45삭제: .insert(TextStyle::Small, FontId::proportional(BODY));
83추가: .insert(TextStyle::Small, FontId::proportional(FONT_SMALL));
4684 style
4785 .text_styles
48삭제: .insert(TextStyle::Heading, FontId::proportional(TITLE));
86추가: .insert(TextStyle::Heading, FontId::proportional(FONT_LARGE));
4987 style.visuals.override_text_color = Some(TEXT);
5088 style.visuals.panel_fill = BACKGROUND;
5189 style.visuals.window_fill = PANEL;
@@ -75,9 +113,23 @@ pub fn apply(ctx: &egui::Context) {
75113 style.spacing.interact_size.y = ROW;
76114 style.spacing.window_margin = egui::Margin::same(PAD);
77115 style.visuals.disabled_alpha = 0.4;
116추가: // egui 기본 버튼에도 손 모양 커서를 씀.
117추가: style.visuals.interact_cursor = Some(egui::CursorIcon::PointingHand);
118추가: // 클릭과 표시가 즉시 바뀌도록 서서히 나타남, 부드러운 스크롤, 커서 깜빡임을 모두 끔.
119추가: style.animation_time = 0.0;
120추가: style.scroll_animation = egui::style::ScrollAnimation::none();
121추가: style.visuals.text_cursor.blink = false;
78122 });
79123}
80124
125추가: /// 누를 수 있는 버튼이나 항목에 마우스를 올리면 손 모양 커서를 보여 줌.
126추가: /// 사용할 수 없거나 누를 수 없는 영역(끌기 전용 등)은 그대로 둠.
127추가: pub fn pointer(response: &egui::Response) {
128추가: if response.enabled() && response.sense.senses_click() && response.hovered() {
129추가: response.ctx.set_cursor_icon(egui::CursorIcon::PointingHand);
130추가: }
131추가: }
132추가:
81133pub fn focus(response: &egui::Response) {
82134 if response.has_focus() {
83135 response.ctx.layer_painter(response.layer_id).rect_stroke(
@@ -90,6 +142,21 @@ pub fn focus(response: &egui::Response) {
90142}
91143
92144pub fn action(ui: &mut egui::Ui, text: &str, primary: bool, enabled: bool) -> egui::Response {
145추가: let size = egui::vec2(
146추가: if primary { 112.0 } else { 0.0 },
147추가: if primary { BUTTON } else { 36.0 },
148추가: );
149추가: action_sized(ui, text, primary, enabled, size)
150추가: }
151추가:
152추가: /// 정한 최소 크기로 버튼을 그림. 함께 놓이는 버튼끼리 크기를 맞출 때 씀.
153추가: pub fn action_sized(
154추가: ui: &mut egui::Ui,
155추가: text: &str,
156추가: primary: bool,
157추가: enabled: bool,
158추가: size: egui::Vec2,
159추가: ) -> egui::Response {
93160 let response = ui
94161 .scope(|ui| {
95162 if primary {
@@ -110,18 +177,107 @@ pub fn action(ui: &mut egui::Ui, text: &str, primary: bool, enabled: bool) -> eg
110177 } else {
111178 TEXT
112179 }))
113삭제: .min_size(egui::vec2(
114삭제: if primary { 112.0 } else { 0.0 },
115삭제: if primary { BUTTON } else { 36.0 },
116삭제: ))
180추가: .min_size(size)
117181 .stroke(Stroke::new(1.0, if primary { BLUE } else { BORDER })),
118182 )
119183 })
120184 .inner;
185추가: pointer(&response);
121186 focus(&response);
122187 response
123188}
124189
190추가: pub const STATUS_HEIGHT: f32 = 34.0;
191추가:
192추가: /// 파일 목록 행 배경. 선택한 행에 마우스를 올리면 선택 색보다 진하게,
193추가: /// 선택하지 않은 행에 마우스를 올리면 선택 색보다 옅게 칠함.
194추가: pub fn row_background(ui: &egui::Ui, rect: egui::Rect, selected: bool, hovered: bool) {
195추가: let fill = if selected && hovered {
196추가: ROW_SELECTED_HOVER
197추가: } else if selected {
198추가: ROW_SELECTED
199추가: } else if hovered {
200추가: ROW_HOVER
201추가: } else {
202추가: return;
203추가: };
204추가: ui.painter().rect_filled(rect, 0, fill);
205추가: }
206추가:
207추가: /// 경로 줄 높이를 꽉 채우는 입력란을 그림. 모서리는 각지게 하고,
208추가: /// 위 테두리는 상단 메뉴의 구분선이, 아래 테두리는 경로 줄의 아래 선이 대신해
209추가: /// 선이 겹쳐 보이지 않게 함. 초점이 있으면 파란 테두리.
210추가: pub fn field_frame(ui: &egui::Ui, rect: egui::Rect, focused: bool) {
211추가: let painter = ui.painter();
212추가: painter.rect_filled(rect, 0, PANEL);
213추가: if focused {
214추가: painter.rect_stroke(rect, 0, Stroke::new(1.0, BLUE), egui::StrokeKind::Inside);
215추가: return;
216추가: }
217추가: let stroke = Stroke::new(1.0, BORDER);
218추가: painter.vline(rect.left() + 0.5, rect.y_range(), stroke);
219추가: painter.vline(rect.right() - 0.5, rect.y_range(), stroke);
220추가: }
221추가:
222추가: /// 네 변 테두리가 모두 있는 입력란 모양 (주변에 구분선이 없는 곳에서 씀).
223추가: pub fn boxed_field(ui: &egui::Ui, rect: egui::Rect) {
224추가: ui.painter().rect(
225추가: rect,
226추가: 0,
227추가: PANEL,
228추가: Stroke::new(1.0, BORDER),
229추가: egui::StrokeKind::Inside,
230추가: );
231추가: }
232추가:
233추가: /// 입력란 안에 경로처럼 한 줄 글자를 그림. 넘치면 줄이고 전체 글자는 툴팁으로 보여 줌.
234추가: /// 부모 배치에 영향을 주지 않는 하위 영역을 써서 옆 칸의 위치가 흔들리지 않게 함.
235추가: pub fn field_text(ui: &mut egui::Ui, rect: egui::Rect, text: &str) {
236추가: let mut child = ui.new_child(
237추가: egui::UiBuilder::new()
238추가: .max_rect(rect.shrink2(egui::vec2(10.0, 0.0)))
239추가: .layout(egui::Layout::left_to_right(egui::Align::Center)),
240추가: );
241추가: bounded_text(&mut child, text, (rect.width() - 20.0).max(0.0));
242추가: }
243추가:
244추가: /// 상태 줄 글자를 칸의 세로 가운데에 그림. 넘치면 줄이고 전체 글자는 툴팁으로 보여 줌.
245추가: pub fn status_text(
246추가: ui: &mut egui::Ui,
247추가: rect: egui::Rect,
248추가: text: &str,
249추가: width: f32,
250추가: align: egui::Align,
251추가: ) {
252추가: let mut job = egui::text::LayoutJob::simple_singleline(
253추가: text.into(),
254추가: FontId::proportional(FONT_BODY),
255추가: TEXT,
256추가: );
257추가: job.wrap = egui::text::TextWrapping {
258추가: max_width: width.max(0.0),
259추가: max_rows: 1,
260추가: ..Default::default()
261추가: };
262추가: let galley = ui.fonts_mut(|fonts| fonts.layout_job(job));
263추가: let size = galley.size();
264추가: let x = if align == egui::Align::Max {
265추가: rect.right() - size.x
266추가: } else {
267추가: rect.left()
268추가: };
269추가: let text_rect = egui::Rect::from_min_size(egui::pos2(x, rect.center().y - size.y / 2.0), size);
270추가: ui.painter().galley(text_rect.min, galley, TEXT);
271추가: let response = ui.interact(
272추가: text_rect,
273추가: ui.scope_id()
274추가: .with(("status-text", align == egui::Align::Max)),
275추가: egui::Sense::hover(),
276추가: );
277추가: response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, text));
278추가: response.on_hover_text(text);
279추가: }
280추가:
125281pub fn panel(fill: Color32) -> egui::Frame {
126282 egui::Frame::new()
127283 .fill(fill)
@@ -200,6 +356,16 @@ pub fn icon(ui: &mut egui::Ui, kind: Icon, size: f32) {
200356}
201357
202358pub fn bounded_text(ui: &mut egui::Ui, text: &str, width: f32) -> egui::Response {
359추가: bounded_text_hover(ui, text, text, width)
360추가: }
361추가:
362추가: /// 폭에 맞춰 줄인 글자를 그리고, 마우스를 올리면 hover 글자를 보여 줌.
363추가: pub fn bounded_text_hover(
364추가: ui: &mut egui::Ui,
365추가: text: &str,
366추가: hover: &str,
367추가: width: f32,
368추가: ) -> egui::Response {
203369 let width = width.max(0.0);
204370 ui.allocate_ui_with_layout(
205371 egui::vec2(width, ui.text_style_height(&TextStyle::Body)),
@@ -211,12 +377,15 @@ pub fn bounded_text(ui: &mut egui::Ui, text: &str, width: f32) -> egui::Response
211377 },
212378 )
213379 .inner
214삭제: .on_hover_text(text)
380추가: .on_hover_text(hover)
215381}
216382
217383pub 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);
384추가: let mut job = egui::text::LayoutJob::simple_singleline(
385추가: text.into(),
386추가: FontId::proportional(FONT_BODY),
387추가: TEXT,
388추가: );
220389 job.wrap = egui::text::TextWrapping {
221390 max_width: width.max(0.0),
222391 max_rows: 1,
@@ -256,21 +425,27 @@ pub fn action_pair(
256425) -> (bool, bool) {
257426 let text_width = |text: &str| {
258427 ui.painter()
259삭제: .layout_no_wrap(text.into(), FontId::proportional(BODY), TEXT)
428추가: .layout_no_wrap(text.into(), FontId::proportional(FONT_BODY), TEXT)
260429 .size()
261430 .x
262431 };
263삭제: let width = text_width(secondary)
264삭제: + 32.0
265삭제: + primary.map_or(0.0, |(label, _)| {
266삭제: SPACE + (text_width(label) + 32.0).max(112.0)
267삭제: });
432추가: // 두 버튼은 긴 쪽 글자에 맞춘 같은 크기로 그림.
433추가: let button = egui::vec2(
434추가: primary
435추가: .map_or(0.0, |(label, _)| text_width(label))
436추가: .max(text_width(secondary))
437추가: + 32.0,
438추가: BUTTON,
439추가: )
440추가: .max(egui::vec2(112.0, BUTTON));
441추가: let count = if primary.is_some() { 2.0 } else { 1.0 };
442추가: let width = button.x * count + SPACE * (count - 1.0);
268443 ui.horizontal(|ui| {
269444 ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| {
270445 ui.add_space((ui.available_width() - width).max(0.0));
271삭제: let secondary = action(ui, secondary, false, true).clicked();
446추가: let secondary = action_sized(ui, secondary, false, true, button).clicked();
272447 let primary = primary.is_some_and(|(label, enabled)| {
273삭제: action(ui, label, true, enabled)
448추가: action_sized(ui, label, true, enabled, button)
274449 .on_disabled_hover_text(match label {
275450 "만들기" => "묶을 파일이나 폴더를 추가하세요",
276451 "다른 폴더에 풀기" => "기존 풀 위치 폴더를 먼저 확인하세요",
@@ -290,18 +465,9 @@ pub fn indeterminate(ui: &mut egui::Ui) {
290465 egui::vec2(ui.available_width(), SPACE * 2.0),
291466 egui::Sense::hover(),
292467 );
293삭제: ui.painter().rect_filled(rect, 8, BORDER);
294삭제: let phase = if ui.style().animation_time > 0.0 {
295삭제: ui.input(|i| (i.time * 0.6).fract()) as f32
296삭제: } else {
297삭제: 0.5
298삭제: };
299삭제: let width = (SPACE * 8.0).min(rect.width());
300삭제: let pulse = egui::Rect::from_min_size(
301삭제: rect.min + egui::vec2((rect.width() - width) * phase, 0.0),
302삭제: egui::vec2(width, rect.height()),
303삭제: );
304삭제: ui.painter().rect_filled(pulse, 8, BLUE);
468추가: // 움직이는 표시 없이 전체 막대를 옅은 파란색으로 채워 진행 중임을 나타냄.
469추가: ui.painter()
470추가: .rect_filled(rect, 8, Color32::from_rgb(191, 211, 248));
305471 response.widget_info(|| {
306472 egui::WidgetInfo::labeled(
307473 egui::Role::ProgressIndicator,
@@ -333,13 +499,72 @@ pub fn svg_icon(painter: &egui::Painter, rect: egui::Rect, asset: &str, color: C
333499 )
334500 })
335501 .collect::<Vec<_>>();
336삭제: painter.add(egui::Shape::line(
337삭제: points,
338삭제: Stroke::new(rect.width() / 18.0, color),
339삭제: ));
502추가: let width = rect.width() / 18.0;
503추가: // 꼭짓점과 끝점에 원을 더해 둥근 이음과 둥근 끝을 만듦.
504추가: for point in &points {
505추가: painter.circle_filled(*point, width / 2.0, color);
506추가: }
507추가: painter.add(egui::Shape::line(points, Stroke::new(width, color)));
340508 }
341509}
342510
511추가: /// 가장 긴 이름(압축해제, FONT_SMALL에서 약 48px) 양옆에 12px씩 남는 폭.
512추가: pub const TOOL_SIZE: egui::Vec2 = egui::vec2(72.0, 60.0);
513추가: const TOOL_ICON: f32 = 30.0;
514추가: const TOOL_LABEL: f32 = FONT_SMALL;
515추가: /// 아이콘 그림 아래와 이름 글자 위 사이의 보이는 간격.
516추가: const TOOL_GAP: f32 = 6.0;
517추가:
518추가: /// SVG 폴리라인 점들의 세로 범위(24 단위 좌표).
519추가: fn svg_y_range(asset: &str) -> Option<(f32, f32)> {
520추가: asset
521추가: .split("points=\"")
522추가: .skip(1)
523추가: .flat_map(|element| {
524추가: element
525추가: .split('"')
526추가: .next()
527추가: .unwrap_or_default()
528추가: .split_whitespace()
529추가: .filter_map(|pair| pair.split_once(',')?.1.parse::<f32>().ok())
530추가: .collect::<Vec<_>>()
531추가: })
532추가: .fold(None, |range: Option<(f32, f32)>, y| {
533추가: Some(range.map_or((y, y), |(lo, hi)| (lo.min(y), hi.max(y))))
534추가: })
535추가: }
536추가:
537추가: /// 상단 메뉴 아이콘 세 개를 합친 그림 범위. 모든 버튼이 같은 기준을 써서 이름 높이가 맞음.
538추가: fn tool_icon_ink() -> (f32, f32) {
539추가: let scale = TOOL_ICON / 24.0;
540추가: let half_stroke = TOOL_ICON / 18.0 / 2.0;
541추가: let (lo, hi) = [OPEN, CREATE, EXTRACT]
542추가: .iter()
543추가: .filter_map(|asset| svg_y_range(asset))
544추가: .fold((24.0f32, 0.0f32), |(lo, hi), (a, b)| (lo.min(a), hi.max(b)));
545추가: (lo * scale - half_stroke, hi * scale + half_stroke)
546추가: }
547추가:
548추가: /// 글자 줄 상자가 아니라 실제로 그려지는 글자 모양의 위아래 범위.
549추가: fn galley_ink(galley: &egui::Galley) -> (f32, f32) {
550추가: galley
551추가: .rows
552추가: .iter()
553추가: .flat_map(|row| {
554추가: row.glyphs
555추가: .iter()
556추가: .filter(|g| g.uv_rect.size.y > 0.0)
557추가: .map(move |g| {
558추가: let top = row.pos.y + g.pos.y + g.uv_rect.offset.y;
559추가: (top, top + g.uv_rect.size.y)
560추가: })
561추가: })
562추가: .fold(None, |range: Option<(f32, f32)>, (top, bottom)| {
563추가: Some(range.map_or((top, bottom), |(a, b)| (a.min(top), b.max(bottom))))
564추가: })
565추가: .unwrap_or((0.0, galley.size().y))
566추가: }
567추가:
343568pub fn tool(
344569 ui: &mut egui::Ui,
345570 label: &str,
@@ -347,36 +572,86 @@ pub fn tool(
347572 enabled: bool,
348573 blue: bool,
349574) -> egui::Response {
350삭제: let response = ui.add_enabled(
351삭제: enabled,
352삭제: egui::Button::new(
353삭제: egui::RichText::new(label)
354삭제: .size(18.0)
355삭제: .color(Color32::TRANSPARENT),
356삭제: )
357삭제: .frame(false)
358삭제: .min_size(egui::vec2(108.0, 86.0)),
575추가: let (rect, response) = ui.allocate_exact_size(
576추가: TOOL_SIZE,
577추가: if enabled {
578추가: egui::Sense::click()
579추가: } else {
580추가: egui::Sense::hover()
581추가: },
359582 );
360삭제: let rect = response.rect;
583추가: response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, label));
361584 let color = if enabled {
362585 if blue { BLUE } else { TEXT }
363586 } else {
364587 MUTED
365588 };
366삭제: let icon_rect = egui::Rect::from_center_size(
367삭제: egui::pos2(rect.center().x, rect.top() + 27.0),
368삭제: egui::vec2(36.0, 36.0),
589추가: if enabled && (response.hovered() || response.has_focus()) {
590추가: let fill = if response.is_pointer_button_down_on() {
591추가: PRESS
592추가: } else {
593추가: HOVER
594추가: };
595추가: ui.painter().rect_filled(rect, 8, fill);
596추가: }
597추가: // 아이콘 그림 위쪽부터 글자 모양 아래쪽까지를 하나로 보고 버튼 가운데에 둠.
598추가: // 그래서 마우스를 올려 배경이 보일 때 위아래 여백이 같음.
599추가: let galley =
600추가: ui.painter()
601추가: .layout_no_wrap(label.to_owned(), FontId::proportional(TOOL_LABEL), color);
602추가: let (icon_top, icon_bottom) = tool_icon_ink();
603추가: let (text_top, text_bottom) = galley_ink(&galley);
604추가: let block = (icon_bottom - icon_top) + TOOL_GAP + (text_bottom - text_top);
605추가: let start = rect.top() + (rect.height() - block) / 2.0;
606추가: let icon_rect = egui::Rect::from_min_size(
607추가: egui::pos2(rect.center().x - TOOL_ICON / 2.0, start - icon_top),
608추가: egui::vec2(TOOL_ICON, TOOL_ICON),
369609 );
370삭제: ui.painter()
371삭제: .rect_filled(rect.shrink2(egui::vec2(1.0, 27.0)), 0, PANEL);
372610 svg_icon(ui.painter(), icon_rect, asset, color);
373삭제: ui.painter().text(
374삭제: egui::pos2(rect.center().x, rect.bottom() - 15.0),
375삭제: egui::Align2::CENTER_CENTER,
376삭제: label,
377삭제: FontId::proportional(18.0),
611추가: let text_y = start + (icon_bottom - icon_top) + TOOL_GAP - text_top;
612추가: ui.painter().galley(
613추가: egui::pos2(rect.center().x - galley.size().x / 2.0, text_y).round(),
614추가: galley,
378615 color,
379616 );
617추가: pointer(&response);
618추가: focus(&response);
619추가: response
620추가: }
621추가:
622추가: /// 테두리와 배경 없이 아이콘만 그리는 버튼. 사용할 수 있을 때만 마우스를 올리면 배경이 어두워짐.
623추가: pub fn flat_icon_button(
624추가: ui: &mut egui::Ui,
625추가: name: &str,
626추가: asset: &str,
627추가: enabled: bool,
628추가: size: egui::Vec2,
629추가: ) -> egui::Response {
630추가: let (rect, response) = ui.allocate_exact_size(
631추가: size,
632추가: if enabled {
633추가: egui::Sense::click()
634추가: } else {
635추가: egui::Sense::hover()
636추가: },
637추가: );
638추가: let response = response.on_hover_text(name);
639추가: response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, name));
640추가: if enabled && response.hovered() {
641추가: let fill = if response.is_pointer_button_down_on() {
642추가: PRESS
643추가: } else {
644추가: HOVER
645추가: };
646추가: ui.painter().rect_filled(rect, 6, fill);
647추가: }
648추가: svg_icon(
649추가: ui.painter(),
650추가: egui::Rect::from_center_size(rect.center(), egui::vec2(20.0, 20.0)),
651추가: asset,
652추가: if enabled { TEXT } else { MUTED },
653추가: );
654추가: pointer(&response);
380655 focus(&response);
381656 response
382657}
@@ -397,6 +672,7 @@ pub fn icon_button(ui: &mut egui::Ui, name: &str, asset: &str, enabled: bool) ->
397672 asset,
398673 if enabled { TEXT } else { MUTED },
399674 );
675추가: pointer(&response);
400676 focus(&response);
401677 response
402678}
추가experiments/rust-ui-memory-app/src/assets/fonts/OFL.txt+94-0
@@ -0,0 +1,94 @@
1추가: Copyright (c) 2021, Kil Hyung-jin (https://github.com/orioncactus/pretendard),
2추가: with Reserved Font Name Pretendard.
3추가:
4추가: This Font Software is licensed under the SIL Open Font License, Version 1.1.
5추가: This license is copied below, and is also available with a FAQ at:
6추가: https://scripts.sil.org/OFL
7추가:
8추가:
9추가: -----------------------------------------------------------
10추가: SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
11추가: -----------------------------------------------------------
12추가:
13추가: PREAMBLE
14추가: The goals of the Open Font License (OFL) are to stimulate worldwide
15추가: development of collaborative font projects, to support the font creation
16추가: efforts of academic and linguistic communities, and to provide a free and
17추가: open framework in which fonts may be shared and improved in partnership
18추가: with others.
19추가:
20추가: The OFL allows the licensed fonts to be used, studied, modified and
21추가: redistributed freely as long as they are not sold by themselves. The
22추가: fonts, including any derivative works, can be bundled, embedded,
23추가: redistributed and/or sold with any software provided that any reserved
24추가: names are not used by derivative works. The fonts and derivatives,
25추가: however, cannot be released under any other type of license. The
26추가: requirement for fonts to remain under this license does not apply
27추가: to any document created using the fonts or their derivatives.
28추가:
29추가: DEFINITIONS
30추가: "Font Software" refers to the set of files released by the Copyright
31추가: Holder(s) under this license and clearly marked as such. This may
32추가: include source files, build scripts and documentation.
33추가:
34추가: "Reserved Font Name" refers to any names specified as such after the
35추가: copyright statement(s).
36추가:
37추가: "Original Version" refers to the collection of Font Software components as
38추가: distributed by the Copyright Holder(s).
39추가:
40추가: "Modified Version" refers to any derivative made by adding to, deleting,
41추가: or substituting -- in part or in whole -- any of the components of the
42추가: Original Version, by changing formats or by porting the Font Software to a
43추가: new environment.
44추가:
45추가: "Author" refers to any designer, engineer, programmer, technical
46추가: writer or other person who contributed to the Font Software.
47추가:
48추가: PERMISSION & CONDITIONS
49추가: Permission is hereby granted, free of charge, to any person obtaining
50추가: a copy of the Font Software, to use, study, copy, merge, embed, modify,
51추가: redistribute, and sell modified and unmodified copies of the Font
52추가: Software, subject to the following conditions:
53추가:
54추가: 1) Neither the Font Software nor any of its individual components,
55추가: in Original or Modified Versions, may be sold by itself.
56추가:
57추가: 2) Original or Modified Versions of the Font Software may be bundled,
58추가: redistributed and/or sold with any software, provided that each copy
59추가: contains the above copyright notice and this license. These can be
60추가: included either as stand-alone text files, human-readable headers or
61추가: in the appropriate machine-readable metadata fields within text or
62추가: binary files as long as those fields can be easily viewed by the user.
63추가:
64추가: 3) No Modified Version of the Font Software may use the Reserved Font
65추가: Name(s) unless explicit written permission is granted by the corresponding
66추가: Copyright Holder. This restriction only applies to the primary font name as
67추가: presented to the users.
68추가:
69추가: 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
70추가: Software shall not be used to promote, endorse or advertise any
71추가: Modified Version, except to acknowledge the contribution(s) of the
72추가: Copyright Holder(s) and the Author(s) or with their explicit written
73추가: permission.
74추가:
75추가: 5) The Font Software, modified or unmodified, in part or in whole,
76추가: must be distributed entirely under this license, and must not be
77추가: distributed under any other license. The requirement for fonts to
78추가: remain under this license does not apply to any document created
79추가: using the Font Software.
80추가:
81추가: TERMINATION
82추가: This license becomes null and void if any of the above conditions are
83추가: not met.
84추가:
85추가: DISCLAIMER
86추가: THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
87추가: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
88추가: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
89추가: OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
90추가: COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
91추가: INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
92추가: DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
93추가: FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
94추가: OTHER DEALINGS IN THE FONT SOFTWARE.
추가experiments/rust-ui-memory-app/src/assets/fonts/Pretendard-Regular.ttf

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

파일 내려받기
추가experiments/rust-ui-memory-app/src/assets/fonts/README.md+11-0
@@ -0,0 +1,11 @@
1추가: # 포함 글꼴
2추가:
3추가: | 파일 | 출처 | 라이선스 |
4추가: | --- | --- | --- |
5추가: | Pretendard-Regular.ttf | [Pretendard v1.3.9](https://github.com/orioncactus/pretendard/releases/tag/v1.3.9) `Pretendard-1.3.9.zip`의 `public/static/alternative/Pretendard-Regular.ttf` | SIL OFL 1.1 (`OFL.txt`) |
6추가:
7추가: - 릴리스 압축파일 SHA-256: `04be351a74d6bf7d60c480a3087e51d185485d35a52023142af1df19eb8c428a`
8추가: - 글꼴 파일 SHA-256: `6d0af5258997aec7354a6e340fc2325ba321c410ca48b3af858c8c3d6e92a324`
9추가: - `OFL.txt`는 같은 압축파일의 `LICENSE.txt` 원문임.
10추가: - 예약 글꼴 이름(Pretendard)이 있으므로 하위 집합 추출이나 변환 없이 원본 그대로 포함함.
11추가: - 배포 고지는 `packaging/licenses.py`가 `THIRD-PARTY-LICENSES.txt`에 이 원문을 넣음.
수정experiments/rust-ui-memory-app/src/assets/icons/create-zip.svg+1-1
@@ -1 +1 @@
1삭제: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="14,3 5,3 5,21 16,21"/><polyline points="14,3 20,9 14,9 14,3"/><polyline points="20,14 20,22"/><polyline points="16,18 24,18"/></svg>
1추가: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="2.80,5.60 2.84,5.11 2.98,4.71 3.20,4.40 3.51,4.18 3.91,4.04 4.40,4.00 19.60,4.00 20.09,4.04 20.49,4.18 20.80,4.40 21.02,4.71 21.16,5.11 21.20,5.60 21.20,7.40 21.16,7.89 21.02,8.29 20.80,8.60 20.49,8.82 20.09,8.96 19.60,9.00 4.40,9.00 3.91,8.96 3.51,8.82 3.20,8.60 2.98,8.29 2.84,7.89 2.80,7.40 2.80,5.60"/> <polyline points="4.30,9.00 4.30,17.60 4.37,18.33 4.57,18.93 4.90,19.40 5.37,19.73 5.97,19.93 6.70,20.00 17.30,20.00 18.03,19.93 18.63,19.73 19.10,19.40 19.43,18.93 19.63,18.33 19.70,17.60 19.70,9.00"/> <polyline points="9.60,13.00 14.40,13.00"/></svg>
수정experiments/rust-ui-memory-app/src/assets/icons/extract-archive.svg+1-1
@@ -1 +1 @@
1삭제: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="12,2 12,16"/><polyline points="6,10 12,16 18,10"/><polyline points="3,16 3,22 21,22 21,16"/></svg>
1추가: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="2.33,9.40 2.23,8.95 2.24,8.55 2.36,8.22 2.58,7.93 2.90,7.70 3.32,7.53 14.42,4.14 14.87,4.04 15.26,4.05 15.60,4.17 15.89,4.38 16.12,4.71 16.29,5.13 16.52,5.90 16.62,6.35 16.61,6.74 16.49,7.08 16.28,7.37 15.95,7.60 15.53,7.77 4.43,11.16 3.98,11.26 3.59,11.25 3.25,11.13 2.96,10.91 2.74,10.59 2.56,10.17 2.33,9.40"/> <polyline points="4.30,12.60 4.30,17.60 4.37,18.33 4.57,18.93 4.90,19.40 5.37,19.73 5.97,19.93 6.70,20.00 17.30,20.00 18.03,19.93 18.63,19.73 19.10,19.40 19.43,18.93 19.63,18.33 19.70,17.60 19.70,12.60"/> <polyline points="2.80,12.60 21.20,12.60"/> <polyline points="9.60,16.00 14.40,16.00"/></svg>
수정experiments/rust-ui-memory-app/src/assets/icons/navigate-up.svg+1-1
@@ -1 +1 @@
1삭제: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="5,10 12,3 19,10"/><polyline points="12,3 12,22"/></svg>
1추가: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="12.00,20.00 12.00,4.50"/> <polyline points="6.00,10.50 11.29,5.21 11.53,5.01 11.76,4.89 12.00,4.85 12.24,4.89 12.47,5.01 12.71,5.21 18.00,10.50"/></svg>
수정experiments/rust-ui-memory-app/src/assets/icons/open-archive.svg+1-1
@@ -1 +1 @@
1삭제: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="3,8 3,4 10,4 13,7 21,7 19,20 3,20 3,8 21,8"/></svg>
1추가: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="3.00,7.00 3.00,7.00 3.00,7.00 3.00,7.00 3.00,7.00 3.00,7.00 3.00,7.00 3.00,5.75 3.03,5.37 3.14,5.06 3.31,4.81 3.56,4.64 3.87,4.53 4.25,4.50 8.13,4.50 8.41,4.52 8.68,4.58 8.92,4.67 9.14,4.80 9.35,4.97 9.54,5.18 10.46,6.32 10.65,6.53 10.86,6.70 11.08,6.83 11.32,6.92 11.59,6.98 11.87,7.00 19.20,7.00 19.75,7.05 20.20,7.20 20.55,7.45 20.80,7.80 20.95,8.25 21.00,8.80 21.00,17.70 20.95,18.25 20.80,18.70 20.55,19.05 20.20,19.30 19.75,19.45 19.20,19.50 4.80,19.50 4.25,19.45 3.80,19.30 3.45,19.05 3.20,18.70 3.05,18.25 3.00,17.70 3.00,7.00"/> <polyline points="3.00,10.00 21.00,10.00"/></svg>
수정experiments/rust-ui-memory-app/src/assets/icons/search-files.svg+1-1
@@ -1 +1 @@
1삭제: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="16,16 23,23"/><polyline points="18,10 17,5 13,2 7,2 3,5 2,10 4,15 9,18 14,17 18,13 18,10"/></svg>
1추가: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="17.00,10.50 16.88,11.77 16.51,12.99 15.90,14.11 15.10,15.10 14.11,15.90 12.99,16.51 11.77,16.88 10.50,17.00 9.23,16.88 8.01,16.51 6.89,15.90 5.90,15.10 5.10,14.11 4.49,12.99 4.12,11.77 4.00,10.50 4.12,9.23 4.49,8.01 5.10,6.89 5.90,5.90 6.89,5.10 8.01,4.49 9.23,4.12 10.50,4.00 11.77,4.12 12.99,4.49 14.11,5.10 15.10,5.90 15.90,6.89 16.51,8.01 16.88,9.23 17.00,10.50"/> <polyline points="15.30,15.30 20.50,20.50"/></svg>
수정experiments/rust-ui-memory-app/src/desktop.rs+8-12
@@ -7,7 +7,7 @@ mod fake;
77mod renderer;
88#[path = "system_font.rs"]
99mod system_font;
10삭제: use eframe::egui::{self, FontData, FontDefinitions, FontFamily};
10추가: use eframe::egui;
1111fn main() -> eframe::Result {
1212 let result = run();
1313 #[cfg(target_os = "windows")]
@@ -43,7 +43,10 @@ fn show_startup_error(message: &str) {
4343
4444fn run() -> eframe::Result {
4545 let custom_frame = zipelo_ui_memory_app::window_frame::custom_frame_needed();
46삭제: let font = system_font::load().map_err(|e| eframe::Error::AppCreation(Box::new(e)))?;
46추가: // 운영체제 한글 글꼴은 Pretendard에 없는 글자를 위한 대체 글꼴로만 씀.
47추가: let fallback = system_font::load()
48추가: .ok()
49추가: .map(|font| (font.bytes, font.face_index));
4750 renderer::run_native(
4851 "Zipelo",
4952 eframe::NativeOptions {
@@ -54,17 +57,10 @@ fn run() -> eframe::Result {
5457 ..Default::default()
5558 },
5659 || {
57삭제: let bytes = font.bytes.clone();
58삭제: let face_index = font.face_index;
60추가: let fallback = fallback.clone();
5961 Box::new(move |cc| {
60삭제: let mut fonts = FontDefinitions::empty();
61삭제: let mut data = FontData::from_owned(bytes);
62삭제: data.index = face_index;
63삭제: fonts.font_data.insert("noto-kr".into(), data.into());
64삭제: fonts
65삭제: .families
66삭제: .insert(FontFamily::Proportional, vec!["noto-kr".into()]);
67삭제: cc.egui_ctx.set_fonts(fonts);
62추가: cc.egui_ctx
63추가: .set_fonts(zipelo_ui_memory_app::archive_theme::fonts(fallback));
6864 zipelo_ui_memory_app::archive_theme::apply(&cc.egui_ctx);
6965 let (fixture, startup) = zipelo_ui_memory_app::archive_ui::launch_args(
7066 std::env::args_os().skip(1).collect(),
수정experiments/rust-ui-memory-app/src/window_frame.rs+6-1
@@ -95,7 +95,7 @@ pub fn title_bar(root: &mut egui::Ui, id: &str, title: &str, buttons: Buttons) -
9595 // 버튼 영역을 피해 가운데에 제목을 그림.
9696 let reserved = rect.right() - right;
9797 let width = (rect.width() - 2.0 * reserved).max(0.0);
98삭제: let font = FontId::proportional(theme::BODY - 2.0);
98추가: let font = FontId::proportional(theme::FONT_SMALL);
9999 let text = fit(ui, title, &font, width);
100100 ui.painter().text(
101101 rect.center(),
@@ -140,6 +140,10 @@ fn start_move(ctx: &egui::Context, id: &str, bar: Rect, buttons_left: f32) -> bo
140140 origin = None;
141141 // 운영체제가 이동을 맡으므로 egui 쪽 끌기는 끝낸 것으로 처리함.
142142 ctx.stop_dragging();
143추가: // 이동이 끝나도 버튼 놓기가 오지 않아 egui가 버튼이 눌린 채로 알고 있으면
144추가: // 다른 버튼에 마우스를 올려도 반응하지 않음. 이 창의 마우스 상태를 비움.
145추가: // 메인 창뿐 아니라 입력 훅을 쓸 수 없는 자식 창에도 적용됨.
146추가: ctx.input_mut(|input| input.pointer = Default::default());
143147 }
144148 ctx.data_mut(|d| d.insert_temp(key, origin));
145149 start
@@ -160,6 +164,7 @@ fn window_button(ui: &mut egui::Ui, id: &str, rect: Rect, glyph: Glyph) -> egui:
160164 )
161165 .on_hover_text(label);
162166 response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, label));
167추가: theme::pointer(&response);
163168 let painter = ui.painter();
164169 if response.hovered() || response.is_pointer_button_down_on() {
165170 let fill = if glyph == Glyph::Close {
수정packaging/licenses.py+37-3
@@ -189,13 +189,47 @@ def inventory(manifests, project_root=None, supplement_path=ROOT / "packaging/li
189189 return [records[key] for key in sorted(records)]
190190
191191
192추가: # 앱에 그대로 포함하는 Rust crate 밖의 자산. 원문 고지가 없으면 배포를 중단함.
193추가: BUNDLED = [
194추가: {
195추가: "kind": "Font",
196추가: "name": "Pretendard",
197추가: "version": "1.3.9",
198추가: "license": "OFL-1.1",
199추가: "source": "https://github.com/orioncactus/pretendard/releases/tag/v1.3.9",
200추가: "asset": "experiments/rust-ui-memory-app/src/assets/fonts/Pretendard-Regular.ttf",
201추가: "license_file": "experiments/rust-ui-memory-app/src/assets/fonts/OFL.txt",
202추가: },
203추가: ]
204추가:
205추가:
206추가: def bundled_records(root=ROOT):
207추가: records = []
208추가: for item in BUNDLED:
209추가: asset = root / item["asset"]
210추가: license_file = root / item["license_file"]
211추가: if not asset.is_file() or not license_file.is_file():
212추가: raise ValueError(f"포함 자산 또는 원문 누락: {item['name']}")
213추가: content = license_file.read_bytes()
214추가: records.append({
215추가: "kind": item["kind"], "name": item["name"], "version": item["version"],
216추가: "source": item["source"], "license": item["license"],
217추가: "files": [{
218추가: "path": item["license_file"], "sha256": hashlib.sha256(content).hexdigest(),
219추가: "note": f"Asset: {item['asset']} (SHA-256 {hashlib.sha256(asset.read_bytes()).hexdigest()})",
220추가: "text": content.decode("utf-8"),
221추가: }],
222추가: })
223추가: return records
224추가:
225추가:
192226def render(records):
193227 missing = [f'{record["name"]}@{record["version"]}' for record in records if not record["files"]]
194228 if missing:
195229 raise ValueError(f"라이선스 원문 누락 {len(missing)}개: " + ", ".join(missing))
196삭제: lines = ["Zipelo third-party licenses", "Cargo.lock 전체 의존성의 원문 고지 (로컬 registry 및 고정 upstream 보충)", ""]
230추가: lines = ["Zipelo third-party licenses", "Cargo.lock 전체 의존성과 앱에 포함한 자산의 원문 고지 (로컬 registry 및 고정 upstream 보충)", ""]
197231 for record in records:
198삭제: lines.extend(["=" * 72, f'Crate: {record["name"]} {record["version"]}',
232추가: lines.extend(["=" * 72, f'{record.get("kind", "Crate")}: {record["name"]} {record["version"]}',
199233 f'Source: {record["source"]}', f'License: {record["license"]}', f'Version: {record["version"]}', ""])
200234 for file in record["files"]:
201235 lines.extend([f'File: {file["path"]}', f'SHA-256: {file["sha256"]}'])
@@ -206,7 +240,7 @@ def render(records):
206240
207241
208242def generate(manifests, output, audit=None):
209삭제: records = inventory(manifests)
243추가: records = inventory(manifests) + bundled_records()
210244 if audit:
211245 Path(audit).write_text(json.dumps(records, ensure_ascii=False, indent=4) + "\n", encoding="utf-8")
212246 text = render(records)
수정tests/rust-app-real-worker/password_flows.rs+62-53
@@ -79,13 +79,34 @@ impl Screen {
7979 assert_eq!(self.app.model.terminal.as_ref().unwrap().outcome, expected);
8080 assert!(self.app.model.challenge.is_none());
8181 }
82삭제: fn start_encrypted_zip(&mut self, source: &Path, archive: &Path) {
82추가: /// ZIP 만들기 창에서 암호로 보호하기를 켜고 두 칸에 암호를 넣은 뒤 압축하기를 누름.
83추가: /// 작업이 시작됐는지 돌려줌.
84추가: fn start_encrypted_zip(&mut self, source: &Path, archive: &Path, password: &str) -> bool {
8385 self.app.add_sources(vec![source.to_path_buf()]);
8486 self.render(vec![]);
8587 self.set_text("zip-name", archive.file_name().unwrap().to_str().unwrap());
8688 self.click("암호로 보호하기");
89추가: self.set_text("zip-password-input", password);
90추가: self.set_text("zip-password-confirm", password);
91추가: if !password.is_empty() {
92추가: // 입력한 암호는 화면에 그대로 보이지 않음.
93추가: assert!(!self.render(vec![]).iter().any(|(value, _)| value.contains(password)));
94추가: }
8795 self.click("압축하기");
88삭제: assert!(self.app.model.busy(), "{}", self.app.model.status());
96추가: self.app.model.busy()
97추가: }
98추가: /// 별도 암호 입력 창 없이 작업이 끝나는지 확인함.
99추가: fn finish_without_password_prompt(&mut self, expected: Outcome) {
100추가: let deadline = Instant::now() + Duration::from_secs(10);
101추가: while self.app.model.busy() {
102추가: let shown = self.render(vec![]);
103추가: assert!(!shown.iter().any(|(value, _)| value == "ZIP 암호 설정"));
104추가: assert!(Instant::now() < deadline);
105추가: std::thread::sleep(Duration::from_millis(2));
106추가: }
107추가: assert!(self.app.model.confirmed, "{}", self.app.model.status());
108추가: assert_eq!(self.app.model.terminal.as_ref().unwrap().outcome, expected);
109추가: assert!(self.app.model.challenge.is_none());
89110 }
90111}
91112#[test]
@@ -190,7 +211,8 @@ fn cancel_password_extraction_waits_for_cleanup_without_writes() {
190211 Close::Waiting | Close::Review
191212 ));
192213 screen.finish_password_job(Outcome::Cancelled);
193삭제: assert_eq!(screen.app.model.close, Close::Review);
214추가: // 정리가 끝나면 결과 확인 안내 없이 바로 닫힘.
215추가: assert_eq!(screen.app.model.close, Close::Allowed);
194216 assert_eq!(fs::read(output.join("existing.txt")).unwrap(), b"preserve");
195217 assert_eq!(fs::read_dir(output).unwrap().count(), 1);
196218 assert_reaped(&observed);
@@ -206,11 +228,9 @@ fn cold_start_creates_aes_zip_then_reopens_and_extracts_with_password() {
206228 let (factory, observed) = observed_factory();
207229 let mut screen = Screen::new(factory);
208230 assert!(!screen.app.model.encryption);
209삭제: screen.start_encrypted_zip(&source, &archive);
210삭제: screen.password_request(1, true);
211삭제: assert!(!archive.exists());
212삭제: screen.password_answer(FIXTURE_PASSWORD);
213삭제: screen.finish_password_job(Outcome::Completed);
231추가: // 암호는 ZIP 만들기 창에서 받고, 작업자가 요청하면 별도 창 없이 넘김.
232추가: assert!(screen.start_encrypted_zip(&source, &archive, FIXTURE_PASSWORD));
233추가: screen.finish_without_password_prompt(Outcome::Completed);
214234 let bytes = fs::read(&archive).unwrap();
215235 assert_eq!(&bytes[..4], b"PK\x03\x04");
216236 assert_eq!(u16::from_le_bytes(bytes[6..8].try_into().unwrap()) & 1, 1);
@@ -226,17 +246,23 @@ fn cold_start_creates_aes_zip_then_reopens_and_extracts_with_password() {
226246 assert_reaped(&observed);
227247}
228248#[test]
229삭제: fn cancel_password_creation_does_not_create_an_archive() {
249추가: fn cancel_encrypted_creation_window_starts_no_worker_or_archive() {
230250 let scratch = Scratch::new();
231251 let source = scratch.path("private.txt");
232252 fs::write(&source, b"preserve").unwrap();
233253 let archive = scratch.path("cancelled.zip");
234254 let (factory, observed) = observed_factory();
235255 let mut screen = Screen::new(factory);
236삭제: screen.start_encrypted_zip(&source, &archive);
237삭제: screen.password_request(1, true);
238삭제: screen.escape();
239삭제: screen.finish_password_job(Outcome::Cancelled);
256추가: screen.app.add_sources(vec![source.clone()]);
257추가: screen.render(vec![]);
258추가: screen.click("암호로 보호하기");
259추가: screen.set_text("zip-password-input", FIXTURE_PASSWORD);
260추가: screen.set_text("zip-password-confirm", FIXTURE_PASSWORD);
261추가: screen.click("취소");
262추가: let shown = screen.render(vec![]);
263추가: assert!(!shown.iter().any(|(value, _)| value == "ZIP 만들기"));
264추가: assert!(!screen.app.model.busy());
265추가: assert!(observed.borrow().jobs.is_empty());
240266 assert!(!archive.exists());
241267 assert_eq!(fs::read(source).unwrap(), b"preserve");
242268 assert_eq!(fs::read_dir(&scratch.0).unwrap().count(), 1);
@@ -267,20 +293,17 @@ fn oversized_utf8_password_stays_in_dialog_then_accepts_valid_input() {
267293 assert_reaped(&observed);
268294}
269295
270삭제: fn invalid_password_then_cancel(invalid: &str, close: bool) {
296추가: fn invalid_zip_password_never_starts_a_worker(invalid: &str, close: bool) {
271297 let scratch = Scratch::new();
272298 let source = scratch.path("private.txt");
273299 fs::write(&source, b"preserve").unwrap();
274300 let archive = scratch.path("cancelled.zip");
275301 let (factory, observed) = observed_factory();
276302 let mut screen = Screen::new(factory);
277삭제: screen.start_encrypted_zip(&source, &archive);
278삭제: let challenge = screen.password_request(1, true);
279삭제: screen.password_answer(invalid);
280삭제: assert_eq!(screen.app.model.challenge, Some((challenge, 1, true)));
281삭제: if invalid.is_empty() {
282삭제: assert!(screen.app.model.input_error.is_none());
283삭제: } else {
303추가: // 빈 암호나 1024바이트를 넘는 암호로는 압축하기를 누를 수 없음.
304추가: assert!(!screen.start_encrypted_zip(&source, &archive, invalid));
305추가: assert!(observed.borrow().jobs.is_empty());
306추가: if !invalid.is_empty() {
284307 assert!(
285308 screen
286309 .render(vec![])
@@ -289,52 +312,38 @@ fn invalid_password_then_cancel(invalid: &str, close: bool) {
289312 );
290313 }
291314 if close {
315추가: // 작업이 없으므로 확인만 거치면 닫을 수 있음.
292316 screen.app.model.request_close();
293삭제: screen.app.model.confirm_close();
294삭제: assert_eq!(screen.app.model.close, Close::Waiting);
295삭제: assert!(!screen.app.model.confirmed);
317추가: assert_eq!(screen.app.model.close, Close::Review);
318추가: screen.app.model.acknowledge_close();
319추가: assert_eq!(screen.app.model.close, Close::Allowed);
296320 } else {
297삭제: screen.escape();
321추가: screen.click("취소");
322추가: assert!(
323추가: !screen
324추가: .render(vec![])
325추가: .iter()
326추가: .any(|(value, _)| value == "ZIP 만들기")
327추가: );
298328 }
299삭제: screen.finish_password_job(Outcome::Cancelled);
300삭제: assert_eq!(screen.app.model.status(), "작업 취소됨");
301삭제: assert_eq!(
302삭제: screen.app.model.terminal.as_ref().unwrap().publication,
303삭제: Publication::None
304삭제: );
305삭제: assert_eq!(screen.app.model.terminal.as_ref().unwrap().created_count, 0);
306삭제: assert_eq!(
307삭제: screen
308삭제: .app
309삭제: .model
310삭제: .terminal
311삭제: .as_ref()
312삭제: .unwrap()
313삭제: .retained_partial_count,
314삭제: 0
315삭제: );
316329 assert!(!archive.exists());
317330 assert_eq!(fs::read(&source).unwrap(), b"preserve");
318331 assert_eq!(fs::read_dir(&scratch.0).unwrap().count(), 1);
319332 assert_reaped(&observed);
320삭제: if close {
321삭제: assert_eq!(screen.app.model.close, Close::Review);
322삭제: screen.app.model.acknowledge_close();
323삭제: assert_eq!(screen.app.model.close, Close::Allowed);
324삭제: } else {
333추가: if !close {
325334 screen.open(&encrypted_fixture(&scratch, "aes2-store.zip"));
326335 assert_reaped(&observed);
327336 }
328337}
329338#[test]
330삭제: fn empty_password_then_cancel_confirms_worker_exit() {
331삭제: invalid_password_then_cancel("", false);
339추가: fn empty_zip_password_never_starts_a_worker() {
340추가: invalid_zip_password_never_starts_a_worker("", false);
332341}
333342#[test]
334삭제: fn oversized_password_then_cancel_confirms_worker_exit() {
335삭제: invalid_password_then_cancel(&"가".repeat(342), false);
343추가: fn oversized_zip_password_never_starts_a_worker() {
344추가: invalid_zip_password_never_starts_a_worker(&"가".repeat(342), false);
336345}
337346#[test]
338삭제: fn invalid_password_then_close_confirms_worker_exit() {
339삭제: invalid_password_then_cancel("", true);
347추가: fn invalid_zip_password_then_close_allows_closing() {
348추가: invalid_zip_password_never_starts_a_worker("", true);
340349}
수정tests/rust-app-ui/capture.rs+7-12
@@ -1,4 +1,4 @@
1삭제: use eframe::egui::{self, FontData, FontDefinitions, FontFamily, FontId, TextStyle};
1추가: use eframe::egui::{self, FontId, TextStyle};
22use std::{collections::VecDeque, path::PathBuf};
33use zipelo_ui_memory_app::{archive_screen::ArchiveApp, archive_ui::*};
44#[path = "../../experiments/rust-ui-memory-app/src/renderer.rs"]
@@ -388,7 +388,9 @@ fn main() -> eframe::Result {
388388 std::fs::create_dir_all(&base).unwrap();
389389 std::fs::write(base.join("읽어주세요.txt"), "화면 검증 입력").unwrap();
390390 std::fs::create_dir_all(base.join("사진")).unwrap();
391삭제: let font = system_font::load().map_err(|e| eframe::Error::AppCreation(Box::new(e)))?;
391추가: let fallback = system_font::load()
392추가: .ok()
393추가: .map(|font| (font.bytes, font.face_index));
392394 let title = format!("Zipelo UI capture {mode}");
393395 renderer::run_native(
394396 &title,
@@ -401,17 +403,10 @@ fn main() -> eframe::Result {
401403 || {
402404 let mode = mode.clone();
403405 let base = base.clone();
404삭제: let bytes = font.bytes.clone();
405삭제: let face_index = font.face_index;
406추가: let fallback = fallback.clone();
406407 Box::new(move |cc| {
407삭제: let mut fonts = FontDefinitions::empty();
408삭제: let mut data = FontData::from_owned(bytes.clone());
409삭제: data.index = face_index;
410삭제: fonts.font_data.insert("noto-kr".into(), data.into());
411삭제: fonts
412삭제: .families
413삭제: .insert(FontFamily::Proportional, vec!["noto-kr".into()]);
414삭제: cc.egui_ctx.set_fonts(fonts);
408추가: cc.egui_ctx
409추가: .set_fonts(zipelo_ui_memory_app::archive_theme::fonts(fallback.clone()));
415410 cc.egui_ctx.set_visuals(egui::Visuals::light());
416411 cc.egui_ctx.style_mut_of(egui::Theme::Light, |style| {
417412 style
추가tests/rust-app-ui/create_window.rs+527-0
@@ -0,0 +1,527 @@
1추가: // ZIP 만들기 창: 폴더 선택으로 시작하고, 메인 목록과 같은 모양으로 폴더 안을 보여 주며,
2추가: // 암호는 창 안에서 받아 작업자 요청에 자동으로 넘기는지 확인함.
3추가:
4추가: fn create_double_click(ctx: &egui::Context, app: &mut ArchiveApp, label: &str) {
5추가: policy_render(ctx, app, vec![]);
6추가: let point = policy_render(ctx, app, vec![])
7추가: .iter()
8추가: .rev()
9추가: .find(|(text, _)| text == label)
10추가: .unwrap_or_else(|| panic!("항목 없음: {label}"))
11추가: .1;
12추가: for _ in 0..2 {
13추가: for pressed in [true, false] {
14추가: policy_render(
15추가: ctx,
16추가: app,
17추가: vec![
18추가: egui::Event::PointerMoved(point),
19추가: egui::Event::PointerButton {
20추가: pos: point,
21추가: button: egui::PointerButton::Primary,
22추가: pressed,
23추가: modifiers: egui::Modifiers::NONE,
24추가: },
25추가: ],
26추가: );
27추가: }
28추가: }
29추가: }
30추가:
31추가: /// photos/a.txt, photos/trip/sea.jpg 폴더를 만들고 압축하기의 폴더 선택 응답으로 씀.
32추가: fn create_from_folder(scratch: &Folder, factory: &FakeFactory) -> (ArchiveApp, egui::Context) {
33추가: let folder = scratch.0.join("photos");
34추가: fs::create_dir_all(folder.join("trip")).unwrap();
35추가: fs::write(folder.join("a.txt"), b"abc").unwrap();
36추가: fs::write(folder.join("trip/sea.jpg"), b"sea").unwrap();
37추가: let mut app = loaded(scratch, factory);
38추가: let dialogs = TestDialogs::default();
39추가: dialogs.0.borrow_mut().answers.push_back(Some(vec![folder]));
40추가: app.set_dialogs(Box::new(dialogs));
41추가: let ctx = egui::Context::default();
42추가: policy_click(&ctx, &mut app, "압축하기");
43추가: (app, ctx)
44추가: }
45추가:
46추가: #[test]
47추가: fn create_window_lists_chosen_folder_and_browses_into_subfolders() {
48추가: let scratch = Folder::new();
49추가: let factory = FakeFactory::default();
50추가: let (mut app, ctx) = create_from_folder(&scratch, &factory);
51추가: let shown = policy_render(&ctx, &mut app, vec![]);
52추가: for expected in [
53추가: "ZIP 만들기",
54추가: "/photos",
55추가: "trip",
56추가: "a.txt",
57추가: "암호로 보호하기",
58추가: "취소",
59추가: ] {
60추가: assert!(
61추가: shown.iter().any(|(text, _)| text == expected),
62추가: "{expected}: {shown:?}"
63추가: );
64추가: }
65추가: // 끌어 놓기 영역, 파일/폴더 추가 버튼, 암호화 제목은 없음.
66추가: for removed in [
67추가: "파일이나 폴더를 여기에 끌어 놓으세요",
68추가: "파일 추가",
69추가: "폴더 추가",
70추가: "빼기",
71추가: "암호화",
72추가: ] {
73추가: assert!(!shown.iter().any(|(text, _)| text == removed), "{removed}");
74추가: }
75추가: // 폴더가 파일보다 먼저 나옴 (메인 목록과 같은 순서).
76추가: let y = |label: &str| shown.iter().find(|(text, _)| text == label).unwrap().1.y;
77추가: assert!(y("trip") < y("a.txt"));
78추가:
79추가: // 한 번 누르면 들어가지 않음.
80추가: policy_click(&ctx, &mut app, "trip");
81추가: for _ in 0..30 {
82추가: policy_render(&ctx, &mut app, vec![]);
83추가: }
84추가: let shown = policy_render(&ctx, &mut app, vec![]);
85추가: assert!(shown.iter().any(|(text, _)| text == "a.txt"));
86추가: assert!(!shown.iter().any(|(text, _)| text == "/photos/trip"));
87추가:
88추가: create_double_click(&ctx, &mut app, "trip");
89추가: let shown = policy_render(&ctx, &mut app, vec![]);
90추가: assert!(shown.iter().any(|(text, _)| text == "/photos/trip"));
91추가: assert!(shown.iter().any(|(text, _)| text == "sea.jpg"));
92추가: assert!(!shown.iter().any(|(text, _)| text == "a.txt"));
93추가:
94추가: // ZIP 안에는 고른 폴더가 최상위 폴더로 들어감.
95추가: policy_click(&ctx, &mut app, "압축하기");
96추가: match factory.state.borrow().starts.last() {
97추가: Some(Start::CreateZip {
98추가: sources, aes256, ..
99추가: }) => {
100추가: assert_eq!(sources.len(), 1);
101추가: assert_eq!(sources[0].1, "photos");
102추가: assert!(!aes256);
103추가: }
104추가: other => panic!("ZIP 만들기 요청이 필요함: {other:?}"),
105추가: }
106추가: }
107추가:
108추가: #[test]
109추가: fn create_password_rows_follow_checkbox_and_answer_worker_without_prompt() {
110추가: let scratch = Folder::new();
111추가: let factory = FakeFactory::default();
112추가: let (mut app, ctx) = create_from_folder(&scratch, &factory);
113추가: let shown = policy_render(&ctx, &mut app, vec![]);
114추가: assert!(!shown.iter().any(|(text, _)| text == "암호 확인"));
115추가:
116추가: policy_click(&ctx, &mut app, "암호로 보호하기");
117추가: let shown = policy_render(&ctx, &mut app, vec![]);
118추가: assert!(shown.iter().any(|(text, _)| text == "암호"));
119추가: assert!(shown.iter().any(|(text, _)| text == "암호 확인"));
120추가:
121추가: // 다른 두 암호는 알리고 시작하지 않음.
122추가: text(&ctx, &mut app, "zip-password-input", "first-secret");
123추가: text(&ctx, &mut app, "zip-password-confirm", "other-secret");
124추가: let shown = policy_render(&ctx, &mut app, vec![]);
125추가: assert!(
126추가: shown
127추가: .iter()
128추가: .any(|(text, _)| text == "두 암호가 같지 않습니다")
129추가: );
130추가: policy_click(&ctx, &mut app, "압축하기");
131추가: assert_eq!(factory.state.borrow().starts.len(), 1);
132추가:
133추가: // 체크를 해제하면 암호 칸이 사라지고 입력한 암호도 남기지 않음.
134추가: policy_click(&ctx, &mut app, "암호로 보호하기");
135추가: let shown = policy_render(&ctx, &mut app, vec![]);
136추가: assert!(!shown.iter().any(|(text, _)| text == "암호 확인"));
137추가: policy_click(&ctx, &mut app, "암호로 보호하기");
138추가: policy_click(&ctx, &mut app, "압축하기");
139추가: assert_eq!(factory.state.borrow().starts.len(), 1, "지운 암호로 시작함");
140추가:
141추가: text(&ctx, &mut app, "zip-password-input", "fixture-secret");
142추가: text(&ctx, &mut app, "zip-password-confirm", "fixture-secret");
143추가: factory.state.borrow_mut().manual = true;
144추가: policy_click(&ctx, &mut app, "압축하기");
145추가: assert!(matches!(
146추가: factory.state.borrow().starts.last(),
147추가: Some(Start::CreateZip { aes256: true, .. })
148추가: ));
149추가: {
150추가: let mut worker = factory.state.borrow_mut();
151추가: worker.frame(Event::Accepted { encryption: true });
152추가: worker.frame(Event::PasswordRequired {
153추가: challenge_id: 17,
154추가: attempt: 1,
155추가: encrypt: true,
156추가: });
157추가: }
158추가: // 작업자가 암호를 요청하면 별도 암호 창 없이 ZIP 만들기 창의 암호를 넘김.
159추가: for _ in 0..12 {
160추가: let shown = policy_render(&ctx, &mut app, vec![]);
161추가: assert!(!shown.iter().any(|(text, _)| text == "ZIP 암호 설정"));
162추가: }
163추가: assert!(app.model.challenge.is_none());
164추가: assert!(factory.state.borrow().password_seen);
165추가: assert_eq!(factory.state.borrow().password, b"fixture-secret");
166추가: }
167추가:
168추가: #[test]
169추가: fn retry_of_encrypted_creation_reopens_create_window_for_password() {
170추가: let scratch = Folder::new();
171추가: let factory = FakeFactory::default();
172추가: let (mut app, ctx) = create_from_folder(&scratch, &factory);
173추가: policy_click(&ctx, &mut app, "암호로 보호하기");
174추가: text(&ctx, &mut app, "zip-password-input", "fixture-secret");
175추가: text(&ctx, &mut app, "zip-password-confirm", "fixture-secret");
176추가: factory.state.borrow_mut().manual = true;
177추가: policy_click(&ctx, &mut app, "압축하기");
178추가: let starts = factory.state.borrow().starts.len();
179추가: {
180추가: let mut worker = factory.state.borrow_mut();
181추가: worker.frame(Event::Accepted { encryption: true });
182추가: worker.finish(Outcome::Failed, Publication::None);
183추가: for event in &mut worker.queue {
184추가: if let HostEvent::Frame {
185추가: event: Event::Terminal(t),
186추가: ..
187추가: } = event
188추가: {
189추가: t.error = Some(ErrorCode::Io);
190추가: }
191추가: }
192추가: }
193추가: for _ in 0..12 {
194추가: policy_render(&ctx, &mut app, vec![]);
195추가: }
196추가: policy_click(&ctx, &mut app, "다시 시도");
197추가: let shown = policy_render(&ctx, &mut app, vec![]);
198추가: // 암호는 보관하지 않으므로 ZIP 만들기 창을 다시 열어 암호를 받음.
199추가: assert!(shown.iter().any(|(text, _)| text == "ZIP 만들기"));
200추가: assert!(shown.iter().any(|(text, _)| text == "암호 확인"));
201추가: assert!(!shown.iter().any(|(text, _)| text == "ZIP 암호 설정"));
202추가: assert_eq!(factory.state.borrow().starts.len(), starts);
203추가: }
204추가:
205추가: /// 주어진 세로 위치를 덮는 목록 행 배경색(선택/마우스 올림 색 중)을 찾음.
206추가: fn row_fill_at(output: &egui::FullOutput, y: f32) -> Option<egui::Color32> {
207추가: use zipelo_ui_memory_app::archive_theme::{ROW_HOVER, ROW_SELECTED, ROW_SELECTED_HOVER};
208추가: fn walk(shape: &egui::epaint::Shape, y: f32, found: &mut Option<egui::Color32>) {
209추가: match shape {
210추가: egui::epaint::Shape::Rect(rect)
211추가: if (rect.fill == ROW_SELECTED
212추가: || rect.fill == ROW_HOVER
213추가: || rect.fill == ROW_SELECTED_HOVER)
214추가: && rect.rect.top() <= y
215추가: && y <= rect.rect.bottom() =>
216추가: {
217추가: *found = Some(rect.fill);
218추가: }
219추가: egui::epaint::Shape::Vec(shapes) => {
220추가: for shape in shapes {
221추가: walk(shape, y, found);
222추가: }
223추가: }
224추가: _ => {}
225추가: }
226추가: }
227추가: let mut found = None;
228추가: for shape in &output.shapes {
229추가: walk(&shape.shape, y, &mut found);
230추가: }
231추가: found
232추가: }
233추가:
234추가: fn label_y(ctx: &egui::Context, app: &mut ArchiveApp, label: &str) -> f32 {
235추가: policy_render(ctx, app, vec![])
236추가: .iter()
237추가: .rev()
238추가: .find(|(text, _)| text == label)
239추가: .unwrap_or_else(|| panic!("항목 없음: {label}"))
240추가: .1
241추가: .y
242추가: }
243추가:
244추가: fn hover(ctx: &egui::Context, app: &mut ArchiveApp, label: &str) -> egui::FullOutput {
245추가: let point = policy_render(ctx, app, vec![])
246추가: .iter()
247추가: .rev()
248추가: .find(|(text, _)| text == label)
249추가: .unwrap()
250추가: .1;
251추가: frame_output(ctx, app, vec![egui::Event::PointerMoved(point)]);
252추가: frame_output(ctx, app, vec![egui::Event::PointerMoved(point)])
253추가: }
254추가:
255추가: #[test]
256추가: fn create_list_click_selects_and_hover_uses_lighter_blue() {
257추가: use zipelo_ui_memory_app::archive_theme::{ROW_HOVER, ROW_SELECTED, ROW_SELECTED_HOVER};
258추가: let scratch = Folder::new();
259추가: let factory = FakeFactory::default();
260추가: let (mut app, ctx) = create_from_folder(&scratch, &factory);
261추가: let a = label_y(&ctx, &mut app, "a.txt");
262추가: let trip = label_y(&ctx, &mut app, "trip");
263추가: // 한 번 누르면 반투명 파란 배경으로 선택함.
264추가: policy_click(&ctx, &mut app, "a.txt");
265추가: // 다른 행에 마우스를 올리면 선택 색보다 옅은 파란색.
266추가: let output = hover(&ctx, &mut app, "trip");
267추가: assert_eq!(row_fill_at(&output, a), Some(ROW_SELECTED));
268추가: assert_eq!(row_fill_at(&output, trip), Some(ROW_HOVER));
269추가: // 선택한 행에 마우스를 올리면 선택 색보다 진해짐 (덜 투명함).
270추가: let output = hover(&ctx, &mut app, "a.txt");
271추가: assert_eq!(row_fill_at(&output, a), Some(ROW_SELECTED_HOVER));
272추가: assert_eq!(row_fill_at(&output, trip), None);
273추가: assert!(ROW_HOVER.a() < ROW_SELECTED.a());
274추가: assert!(ROW_SELECTED.a() < ROW_SELECTED_HOVER.a());
275추가: }
276추가:
277추가: #[test]
278추가: fn main_list_hover_uses_lighter_blue_and_selected_row_gets_stronger() {
279추가: use zipelo_ui_memory_app::archive_theme::{ROW_HOVER, ROW_SELECTED, ROW_SELECTED_HOVER};
280추가: let scratch = Folder::new();
281추가: let factory = FakeFactory::default();
282추가: let mut app = loaded(&scratch, &factory);
283추가: let ctx = egui::Context::default();
284추가: let name = "읽어주세요.txt";
285추가: let y = label_y(&ctx, &mut app, name);
286추가: let output = hover(&ctx, &mut app, name);
287추가: assert_eq!(row_fill_at(&output, y), Some(ROW_HOVER));
288추가: policy_click(&ctx, &mut app, name);
289추가: let output = hover(&ctx, &mut app, name);
290추가: assert_eq!(row_fill_at(&output, y), Some(ROW_SELECTED_HOVER));
291추가: // 마우스를 치우면 선택 색만 남음 (마우스 상태는 다음 프레임에 반영됨).
292추가: frame_output(&ctx, &mut app, vec![egui::Event::PointerGone]);
293추가: let output = frame_output(&ctx, &mut app, vec![]);
294추가: assert_eq!(row_fill_at(&output, y), Some(ROW_SELECTED));
295추가: // 선택 배경은 오른쪽 여백 없이 목록 너비(창 1060px)를 꽉 채움.
296추가: let right = output
297추가: .shapes
298추가: .iter()
299추가: .filter_map(|shape| match &shape.shape {
300추가: egui::epaint::Shape::Rect(rect)
301추가: if rect.fill == ROW_SELECTED && rect.rect.top() <= y && y <= rect.rect.bottom() =>
302추가: {
303추가: Some(rect.rect.right())
304추가: }
305추가: _ => None,
306추가: })
307추가: .fold(0.0f32, f32::max);
308추가: assert!(right >= 1059.0, "선택 배경 오른쪽 끝: {right}");
309추가: }
310추가:
311추가: fn cursor_over(ctx: &egui::Context, app: &mut ArchiveApp, point: egui::Pos2) -> egui::CursorIcon {
312추가: frame_output(ctx, app, vec![egui::Event::PointerMoved(point)]);
313추가: frame_output(ctx, app, vec![egui::Event::PointerMoved(point)])
314추가: .platform_output
315추가: .cursor_icon
316추가: }
317추가:
318추가: #[test]
319추가: fn clickable_buttons_and_rows_show_pointing_hand_cursor() {
320추가: let scratch = Folder::new();
321추가: let factory = FakeFactory::default();
322추가: let mut app = loaded(&scratch, &factory);
323추가: let ctx = egui::Context::default();
324추가: let at = |ctx: &egui::Context, app: &mut ArchiveApp, label: &str| {
325추가: policy_render(ctx, app, vec![])
326추가: .iter()
327추가: .rev()
328추가: .find(|(text, _)| text == label)
329추가: .unwrap_or_else(|| panic!("항목 없음: {label}"))
330추가: .1
331추가: };
332추가: for label in ["열기", "압축하기", "읽어주세요.txt"] {
333추가: let point = at(&ctx, &mut app, label);
334추가: assert_eq!(
335추가: cursor_over(&ctx, &mut app, point),
336추가: egui::CursorIcon::PointingHand,
337추가: "{label}"
338추가: );
339추가: }
340추가: // 목록의 빈 곳(끌어서 선택하는 영역)과 검색 입력란은 손 모양이 아님.
341추가: let row = at(&ctx, &mut app, "읽어주세요.txt");
342추가: let empty = row + egui::vec2(0.0, 200.0);
343추가: assert_eq!(
344추가: cursor_over(&ctx, &mut app, empty),
345추가: egui::CursorIcon::Default
346추가: );
347추가: let search = at(&ctx, &mut app, "파일 검색");
348추가: assert_ne!(
349추가: cursor_over(&ctx, &mut app, search),
350추가: egui::CursorIcon::PointingHand
351추가: );
352추가:
353추가: // ZIP 만들기 창의 체크박스와 항목도 손 모양.
354추가: let create_scratch = Folder::new();
355추가: let (mut app, ctx) = create_from_folder(&create_scratch, &FakeFactory::default());
356추가: for label in ["암호로 보호하기", "a.txt", "취소"] {
357추가: let point = at(&ctx, &mut app, label);
358추가: assert_eq!(
359추가: cursor_over(&ctx, &mut app, point),
360추가: egui::CursorIcon::PointingHand,
361추가: "{label}"
362추가: );
363추가: }
364추가: }
365추가:
366추가: /// 별도 창으로 뜨는 ZIP 만들기 창을 photos 폴더로 엶.
367추가: fn create_window_from_folder(
368추가: scratch: &Folder,
369추가: factory: &FakeFactory,
370추가: ) -> (ArchiveApp, egui::Context) {
371추가: let folder = scratch.0.join("photos");
372추가: fs::create_dir_all(folder.join("trip")).unwrap();
373추가: fs::write(folder.join("a.txt"), b"abc").unwrap();
374추가: let mut app = loaded(scratch, factory);
375추가: let dialogs = TestDialogs::default();
376추가: dialogs.0.borrow_mut().answers.push_back(Some(vec![folder]));
377추가: app.set_dialogs(Box::new(dialogs));
378추가: let ctx = egui::Context::default();
379추가: ctx.set_embed_viewports(false);
380추가: install_work_child_renderer();
381추가: policy_click(&ctx, &mut app, "압축하기");
382추가: for _ in 0..3 {
383추가: policy_render(&ctx, &mut app, vec![]);
384추가: }
385추가: assert!(
386추가: work_child_label("암호로 보호하기").is_some(),
387추가: "ZIP 만들기 창이 별도 창으로 떠야 함"
388추가: );
389추가: (app, ctx)
390추가: }
391추가:
392추가: fn create_child_render(ctx: &egui::Context, app: &mut ArchiveApp) {
393추가: WORK_CHILD.with(|child| child.borrow_mut().labels.clear());
394추가: for _ in 0..3 {
395추가: policy_render(ctx, app, vec![]);
396추가: }
397추가: }
398추가:
399추가: #[test]
400추가: fn closing_create_window_drops_pending_save_answer() {
401추가: let scratch = Folder::new();
402추가: let factory = FakeFactory::default();
403추가: let (mut app, ctx) = create_window_from_folder(&scratch, &factory);
404추가: let before = factory.state.borrow().starts.len();
405추가:
406추가: // ZIP 만들기 창의 압축하기로 저장 위치 선택 창을 띄워 둠.
407추가: let dialogs = HeldDialogs::default();
408추가: app.set_dialogs(Box::new(dialogs.clone()));
409추가: let compress = work_child_label("압축하기").expect("ZIP 만들기 창의 압축하기");
410추가: work_child_click(&ctx, &mut app, compress);
411추가: assert_eq!(
412추가: dialogs.0.borrow().len(),
413추가: 1,
414추가: "저장 위치 선택 창이 응답을 기다려야 함"
415추가: );
416추가:
417추가: // 저장 위치 창을 둔 채 ZIP 만들기 창을 X로 닫음.
418추가: WORK_CHILD.with(|child| child.borrow_mut().close = true);
419추가: // 닫기 요청을 받은 프레임은 내용을 그린 뒤 닫으므로 그다음 프레임부터 봄.
420추가: policy_render(&ctx, &mut app, vec![]);
421추가: create_child_render(&ctx, &mut app);
422추가: assert!(
423추가: work_child_label("암호로 보호하기").is_none(),
424추가: "ZIP 만들기 창이 닫혀야 함"
425추가: );
426추가:
427추가: // 나중에 저장 위치 창에서 저장을 눌러도 닫힌 창의 압축을 시작하지 않음.
428추가: dialogs.0.borrow()[0]
429추가: .send(Ok(Some(vec![scratch.0.join("photos.zip")])))
430추가: .unwrap();
431추가: for _ in 0..5 {
432추가: policy_render(&ctx, &mut app, vec![]);
433추가: }
434추가: assert_eq!(
435추가: factory.state.borrow().starts.len(),
436추가: before,
437추가: "닫은 ZIP 만들기 창의 저장 응답으로 압축이 시작됨"
438추가: );
439추가: }
440추가:
441추가: #[test]
442추가: fn cancelling_second_folder_choice_keeps_create_window_contents() {
443추가: let scratch = Folder::new();
444추가: let factory = FakeFactory::default();
445추가: let (mut app, ctx) = create_window_from_folder(&scratch, &factory);
446추가: let check = work_child_label("암호로 보호하기").unwrap();
447추가: work_child_click(&ctx, &mut app, check);
448추가: create_child_render(&ctx, &mut app);
449추가: assert!(
450추가: work_child_label("암호 확인").is_some(),
451추가: "암호 칸이 나와야 함"
452추가: );
453추가:
454추가: // ZIP 만들기 창을 둔 채 툴바의 압축하기를 다시 누르고 폴더 선택을 취소함.
455추가: let dialogs = TestDialogs::default();
456추가: app.set_dialogs(Box::new(dialogs.clone()));
457추가: policy_click(&ctx, &mut app, "압축하기");
458추가: assert_eq!(
459추가: dialogs.0.borrow().requests.len(),
460추가: 1,
461추가: "폴더 선택 창이 열려야 함"
462추가: );
463추가: create_child_render(&ctx, &mut app);
464추가: for label in ["/photos", "a.txt", "암호 확인"] {
465추가: assert!(
466추가: work_child_label(label).is_some(),
467추가: "폴더 선택을 취소했는데 {label}이(가) 사라짐"
468추가: );
469추가: }
470추가:
471추가: // 대조: 다른 폴더를 실제로 고르면 그 폴더로 새로 시작하고 암호 설정도 비움.
472추가: let other = scratch.0.join("music");
473추가: fs::create_dir_all(&other).unwrap();
474추가: fs::write(other.join("song.mp3"), b"la").unwrap();
475추가: dialogs.0.borrow_mut().answers.push_back(Some(vec![other]));
476추가: policy_click(&ctx, &mut app, "압축하기");
477추가: create_child_render(&ctx, &mut app);
478추가: assert!(work_child_label("/music").is_some());
479추가: assert!(work_child_label("song.mp3").is_some());
480추가: assert!(work_child_label("a.txt").is_none());
481추가: assert!(work_child_label("암호 확인").is_none());
482추가: }
483추가:
484추가: #[test]
485추가: fn unchecking_password_also_forgets_undo_history() {
486추가: let scratch = Folder::new();
487추가: let factory = FakeFactory::default();
488추가: let (mut app, ctx) = create_from_folder(&scratch, &factory);
489추가: policy_click(&ctx, &mut app, "암호로 보호하기");
490추가: text(&ctx, &mut app, "zip-password-input", "undo-secret");
491추가: // egui는 입력이 1초쯤 멈춰야 실행 취소 지점을 남기므로 그만큼 프레임을 진행함.
492추가: for _ in 0..90 {
493추가: policy_render(&ctx, &mut app, vec![]);
494추가: }
495추가:
496추가: // 체크를 풀었다가 다시 켜면 암호 칸은 비어 있음.
497추가: policy_click(&ctx, &mut app, "암호로 보호하기");
498추가: policy_click(&ctx, &mut app, "암호로 보호하기");
499추가:
500추가: // 실행 취소(Ctrl+Z)를 눌러도 지운 암호가 되살아나지 않아야 함.
501추가: // 한 번만 누름(두 번째 실행 취소는 다시 처음 상태로 돌아감).
502추가: ctx.memory_mut(|memory| memory.request_focus(egui::Id::unique("zip-password-input")));
503추가: policy_render(&ctx, &mut app, vec![]);
504추가: {
505추가: policy_render(
506추가: &ctx,
507추가: &mut app,
508추가: vec![egui::Event::Key {
509추가: key: egui::Key::Z,
510추가: physical_key: None,
511추가: pressed: true,
512추가: repeat: false,
513추가: modifiers: egui::Modifiers::COMMAND,
514추가: }],
515추가: );
516추가: }
517추가: policy_click(&ctx, &mut app, "보기");
518추가: let shown = policy_render(&ctx, &mut app, vec![]);
519추가: assert!(
520추가: shown.iter().any(|(text, _)| text == "숨기기"),
521추가: "암호가 보여야 함"
522추가: );
523추가: assert!(
524추가: !shown.iter().any(|(text, _)| text.contains("undo-secret")),
525추가: "지운 암호가 실행 취소로 되살아남"
526추가: );
527추가: }
수정tests/rust-app-ui/fake.rs+3-0
@@ -6,6 +6,8 @@ pub struct State {
66 pub requests: Vec<(u64, &'static str)>,
77 pub starts: Vec<Start>,
88 pub password_seen: bool,
9추가: /// 마지막으로 받은 암호 원문. 화면에서 입력한 암호가 그대로 전달됐는지 확인할 때 씀.
10추가: pub password: Vec<u8>,
911 pub job: u64,
1012 sequence: u64,
1113 pub queue: VecDeque<HostEvent>,
@@ -176,6 +178,7 @@ impl Connection for FakeConnection {
176178 assert_eq!(challenge_id, 17);
177179 assert!(!secret.as_bytes().is_empty());
178180 s.password_seen = true;
181추가: s.password = secret.as_bytes().to_vec();
179182 s.requests.push((request.sequence, "password"));
180183 if !s.manual {
181184 s.complete_action();
수정tests/rust-app-ui/long_layout.rs+19-7
@@ -100,18 +100,24 @@ fn narrow_archive_keeps_columns_and_virtualizes_thousands_of_long_names() {
100100 assert_narrow_text(&output);
101101 let text = layout_text(&output);
102102 assert!(text.len() < 100);
103추가: // 암호가 걸린 항목은 이름 앞에 *가 붙음.
103104 let first = text
104105 .iter()
105삭제: .find(|(text, _, _)| text == &format!("0000-{name}"))
106추가: .find(|(text, _, _)| text.trim_start_matches('*') == format!("0000-{name}"))
106107 .unwrap();
107108 assert!(first.2);
109추가: // 크기는 스크롤 막대 자리(오른쪽 24px)를 침범하지 않는 행 안쪽에 남음.
108110 assert!(
109111 text.iter()
110삭제: .any(|(text, rect, _)| text == "31 B" && rect.right() < 720.0)
112추가: .any(|(text, rect, _)| text == "31 B" && rect.right() <= 736.0)
111113 );
112삭제: for expected in ["크기", "암호", "5000개 항목", "선택 5000개"] {
114추가: for expected in ["5000개 항목", "선택 5000개"] {
113115 assert!(text.iter().any(|(text, _, _)| text == expected));
114116 }
117추가: // 열 제목 줄(이름, 크기, 암호)은 없고 암호는 이름 앞의 *로만 표시함.
118추가: for removed in ["이름", "크기", "암호"] {
119추가: assert!(!text.iter().any(|(text, _, _)| text == removed));
120추가: }
115121 let title = output
116122 .viewport_output
117123 .values()
@@ -123,7 +129,13 @@ fn narrow_archive_keeps_columns_and_virtualizes_thousands_of_long_names() {
123129 .unwrap();
124130 assert!(title.contains('…') && title.ends_with(" — Zipelo"));
125131 assert!(title.chars().count() < full_title.chars().count());
126삭제: assert_full_tooltip(&ctx, &mut app, first.1.center(), &first.0);
132추가: // 툴팁은 표시용 *를 뺀 실제 이름을 보여 줌.
133추가: assert_full_tooltip(
134추가: &ctx,
135추가: &mut app,
136추가: first.1.center(),
137추가: first.0.trim_start_matches('*'),
138추가: );
127139 let output = narrow_frame(&ctx, &mut app, 14.0, vec![egui::Event::PointerGone]);
128140 let point = layout_text(&output)
129141 .into_iter()
@@ -152,13 +164,13 @@ fn narrow_deep_folder_path_is_elided_without_displacing_search() {
152164 assert!(path.2);
153165 assert!(
154166 text.iter()
155삭제: .any(|(text, rect, _)| text == "파일 찾기" && rect.right() < 760.0)
167추가: .any(|(text, rect, _)| text == "파일 검색" && rect.right() < 760.0)
156168 );
157169 assert_full_tooltip(&ctx, &mut app, path.1.center(), &full);
158170}
159171
160172#[test]
161삭제: fn narrow_create_sources_keep_remove_and_footer_actions_visible() {
173추가: fn narrow_create_sources_keep_names_and_footer_actions_visible() {
162174 let scratch = Folder::new();
163175 let factory = FakeFactory::default();
164176 let mut app = loaded(&scratch, &factory);
@@ -176,7 +188,7 @@ fn narrow_create_sources_keep_remove_and_footer_actions_visible() {
176188 text.iter()
177189 .any(|(text, _, elided)| text == &name && *elided)
178190 );
179삭제: for expected in ["빼기", "취소", "압축하기"] {
191추가: for expected in ["취소", "압축하기"] {
180192 assert!(
181193 text.iter()
182194 .any(|(text, rect, _)| text == expected && rect.bottom() <= 540.0)
수정tests/rust-app-ui/presentation.rs+1-0
@@ -911,6 +911,7 @@ mod widgets {
911911 include!("explorer_selection.rs");
912912 include!("window_frame.rs");
913913 include!("work_window.rs");
914추가: include!("create_window.rs");
914915}
915916
916917#[cfg(feature = "ui")]
수정tests/rust-app-ui/regressions.rs+13-1
@@ -375,6 +375,16 @@ fn renders_every_flow_with_actual_egui_widgets() {
375375 let ctx = egui::Context::default();
376376 let f = FakeFactory::default();
377377 let mut app = ArchiveApp::new(Box::new(f.clone()), None, true);
378추가: // 압축하기는 운영체제 폴더 선택 창을 여므로 시험 응답으로 바꿈.
379추가: let folder = std::env::temp_dir().join(format!("zipelo-ui-create-{}", std::process::id()));
380추가: std::fs::create_dir_all(&folder).unwrap();
381추가: let dialogs = dialogs::TestDialogs::default();
382추가: dialogs
383추가: .0
384추가: .borrow_mut()
385추가: .answers
386추가: .push_back(Some(vec![folder.clone()]));
387추가: app.set_dialogs(Box::new(dialogs));
378388 let render = |app: &mut ArchiveApp, events: Vec<egui::Event>, width: f32| {
379389 let mut output = ctx.run_ui(
380390 egui::RawInput {
@@ -450,7 +460,9 @@ fn renders_every_flow_with_actual_egui_widgets() {
450460 pump(&mut app.model);
451461 render(&mut app, vec![], 1060.0);
452462 let result = render(&mut app, vec![], 1060.0);
453삭제: assert!(result.iter().any(|(t, _)| t == "결과 확인 후 닫기"));
463추가: // 작업 정리가 끝나면 결과 확인 안내 없이 바로 닫힘.
464추가: assert!(!result.iter().any(|(t, _)| t == "결과 확인 후 닫기"));
465추가: assert_eq!(app.model.close, Close::Allowed);
454466}
455467
456468#[test]
수정tests/rust-app-ui/toolbar.rs+30-21
@@ -57,11 +57,10 @@ fn native_dialog_cancellation_never_starts_a_job() {
5757 policy_click(&ctx, &mut app, "열기");
5858 policy_click(&ctx, &mut app, "압축해제");
5959 assert_eq!(factory.state.borrow().starts.len(), 1);
60추가: // 압축하기는 폴더 선택 창을 먼저 열고, 취소하면 ZIP 만들기 창을 열지 않음.
6061 policy_click(&ctx, &mut app, "압축하기");
61삭제: policy_click(&ctx, &mut app, "파일 추가");
62삭제: policy_click(&ctx, &mut app, "폴더 추가");
6362 let shown = policy_render(&ctx, &mut app, vec![]);
64삭제: assert!(shown.iter().any(|(text, _)| text == "ZIP 만들기"));
63추가: assert!(!shown.iter().any(|(text, _)| text == "ZIP 만들기"));
6564 assert_eq!(factory.state.borrow().starts.len(), 1);
6665 let source = scratch.0.join("source.txt");
6766 fs::write(&source, b"source").unwrap();
@@ -81,7 +80,6 @@ fn native_dialog_cancellation_never_starts_a_job() {
8180 [
8281 Purpose::Open,
8382 Purpose::Destination,
84삭제: Purpose::Files,
8583 Purpose::Folder,
8684 Purpose::SaveZip
8785 ]
@@ -90,7 +88,7 @@ fn native_dialog_cancellation_never_starts_a_job() {
9088
9189#[test]
9290fn toolbar_and_modal_keyboard_do_not_submit_from_secondary_controls() {
93삭제: for label in ["취소", "파일 추가", "폴더 추가"] {
91추가: for label in ["취소", "암호로 보호하기"] {
9492 let scratch = Folder::new();
9593 let factory = FakeFactory::default();
9694 let mut app = loaded(&scratch, &factory);
@@ -159,14 +157,30 @@ fn toolbar_has_three_actions_and_zip_password_option_remains_available() {
159157 assert!(shown.iter().any(|(text, _)| text == label), "{label}");
160158 }
161159 assert!(!shown.iter().any(|(text, _)| text == "암호화"));
160추가: // 압축하기 → 폴더 선택 → ZIP 만들기 창. 암호 칸은 체크해야 나타남.
161추가: let folder = scratch.0.join("protected");
162추가: fs::create_dir(&folder).unwrap();
163추가: fs::write(folder.join("note.txt"), b"protected").unwrap();
164추가: let dialogs = TestDialogs::default();
165추가: dialogs
166추가: .0
167추가: .borrow_mut()
168추가: .answers
169추가: .push_back(Some(vec![folder.clone()]));
170추가: app.set_dialogs(Box::new(dialogs.clone()));
162171 policy_click(&ctx, &mut app, "압축하기");
163172 let shown = policy_render(&ctx, &mut app, vec![]);
164173 assert!(shown.iter().any(|(text, _)| text == "ZIP 만들기"));
165174 assert!(shown.iter().any(|(text, _)| text == "암호로 보호하기"));
166삭제: let source = scratch.0.join("protected.txt");
167삭제: fs::write(&source, b"protected").unwrap();
168삭제: app.add_sources(vec![source]);
175추가: assert!(!shown.iter().any(|(text, _)| text == "암호 확인"));
169176 policy_click(&ctx, &mut app, "암호로 보호하기");
177추가: let shown = policy_render(&ctx, &mut app, vec![]);
178추가: assert!(shown.iter().any(|(text, _)| text == "암호 확인"));
179추가: // 두 암호가 같아야 만들 수 있음.
180추가: policy_click(&ctx, &mut app, "압축하기");
181추가: assert_eq!(factory.state.borrow().starts.len(), 1);
182추가: text(&ctx, &mut app, "zip-password-input", "fixture-secret");
183추가: text(&ctx, &mut app, "zip-password-confirm", "fixture-secret");
170184 policy_click(&ctx, &mut app, "압축하기");
171185 assert!(matches!(
172186 factory.state.borrow().starts.last(),
@@ -361,7 +375,6 @@ fn dialog_failures_show_alerts_while_cancelled_dialogs_remain_silent() {
361375 for failed in [false, true] {
362376 for purpose in [
363377 Purpose::Open,
364삭제: Purpose::Files,
365378 Purpose::Folder,
366379 Purpose::Destination,
367380 Purpose::SaveZip,
@@ -382,18 +395,14 @@ fn dialog_failures_show_alerts_while_cancelled_dialogs_remain_silent() {
382395 let ctx = egui::Context::default();
383396 let label = match purpose {
384397 Purpose::Open => "열기",
385삭제: Purpose::Files | Purpose::Folder | Purpose::SaveZip => {
386삭제: policy_click(&ctx, &mut app, "압축하기");
387삭제: if purpose == Purpose::SaveZip {
388삭제: let source = scratch.0.join("source.txt");
389삭제: fs::write(&source, b"preserve").unwrap();
390삭제: app.add_sources(vec![source]);
391삭제: }
392삭제: match purpose {
393삭제: Purpose::Files => "파일 추가",
394삭제: Purpose::Folder => "폴더 추가",
395삭제: _ => "압축하기",
396삭제: }
398추가: // 도구 막대의 압축하기가 폴더 선택 창을 엶.
399추가: Purpose::Folder => "압축하기",
400추가: Purpose::SaveZip => {
401추가: let source = scratch.0.join("source.txt");
402추가: fs::write(&source, b"preserve").unwrap();
403추가: app.add_sources(vec![source]);
404추가: // ZIP 만들기 창의 압축하기가 저장 위치 선택 창을 엶.
405추가: "압축하기"
397406 }
398407 _ => "압축해제",
399408 };
수정tests/rust-app-ui/work_window.rs+190-12
@@ -5,6 +5,11 @@ struct WorkChild {
55 events: Vec<egui::Event>,
66 labels: Vec<(String, egui::Pos2)>,
77 rendered: usize,
8추가: cursor: Option<egui::CursorIcon>,
9추가: rects: Vec<(egui::Rect, egui::Color32)>,
10추가: commands: Vec<egui::ViewportCommand>,
11추가: /// 다음에 그리는 별도 창에 운영체제의 닫기(X) 요청을 보냄.
12추가: close: bool,
813}
914
1015std::thread_local! {
@@ -16,12 +21,22 @@ fn install_work_child_renderer() {
1621 // 같은 스레드에서 이어 도는 시험끼리 기록이 섞이지 않게 비움.
1722 WORK_CHILD.with(|child| *child.borrow_mut() = WorkChild::default());
1823 egui::Context::set_immediate_viewport_renderer(|ctx, mut viewport| {
19삭제: let events = WORK_CHILD.with(|child| std::mem::take(&mut child.borrow_mut().events));
24추가: let (events, close) = WORK_CHILD.with(|child| {
25추가: let mut child = child.borrow_mut();
26추가: (
27추가: std::mem::take(&mut child.events),
28추가: std::mem::take(&mut child.close),
29추가: )
30추가: });
2031 let mut raw = egui::RawInput {
2132 viewport_id: viewport.ids.this,
33추가: // 창이 요청한 크기로 그림(ZIP 만들기 창은 진행 창보다 큼).
2234 screen_rect: Some(egui::Rect::from_min_size(
2335 egui::Pos2::ZERO,
24삭제: egui::vec2(480.0, 240.0),
36추가: viewport
37추가: .builder
38추가: .inner_size
39추가: .unwrap_or(egui::vec2(480.0, 240.0)),
2540 )),
2641 events,
2742 ..Default::default()
@@ -31,6 +46,11 @@ fn install_work_child_renderer() {
3146 egui::ViewportInfo {
3247 parent: Some(viewport.ids.parent),
3348 focused: Some(true),
49추가: events: if close {
50추가: vec![egui::ViewportEvent::Close]
51추가: } else {
52추가: vec![]
53추가: },
3454 ..Default::default()
3555 },
3656 );
@@ -43,6 +63,21 @@ fn install_work_child_renderer() {
4363 if viewport.ids.this == egui::ViewportId::from_hash_of("archive-work") {
4464 child.rendered += 1;
4565 }
66추가: child.cursor = Some(output.platform_output.cursor_icon);
67추가: child.rects.clear();
68추가: fn walk(shape: &egui::epaint::Shape, out: &mut Vec<(egui::Rect, egui::Color32)>) {
69추가: match shape {
70추가: egui::epaint::Shape::Rect(rect) => out.push((rect.rect, rect.fill)),
71추가: egui::epaint::Shape::Vec(shapes) => shapes.iter().for_each(|s| walk(s, out)),
72추가: _ => {}
73추가: }
74추가: }
75추가: for shape in &output.shapes {
76추가: walk(&shape.shape, &mut child.rects);
77추가: }
78추가: for viewport in output.viewport_output.values() {
79추가: child.commands.extend(viewport.commands.iter().cloned());
80추가: }
4681 });
4782 });
4883}
@@ -224,6 +259,99 @@ fn password_prompt_is_not_covered_by_separate_work_window() {
224259 );
225260}
226261
262추가: #[test]
263추가: fn child_window_buttons_hover_again_after_title_bar_drag() {
264추가: let scratch = Folder::new();
265추가: let factory = FakeFactory::default();
266추가: let mut app = loaded(&scratch, &factory);
267추가: factory.state.borrow_mut().manual = true;
268추가: assert!(app.begin_extract());
269추가: {
270추가: let mut worker = factory.state.borrow_mut();
271추가: worker.frame(Event::Accepted { encryption: false });
272추가: worker.finish(Outcome::Failed, Publication::None);
273추가: }
274추가: app.set_custom_frame(true);
275추가: let ctx = egui::Context::default();
276추가: ctx.set_embed_viewports(false);
277추가: install_work_child_renderer();
278추가: for _ in 0..10 {
279추가: policy_render(&ctx, &mut app, vec![]);
280추가: }
281추가: let mut commands = Vec::new();
282추가: fn child_frame(
283추가: ctx: &egui::Context,
284추가: app: &mut ArchiveApp,
285추가: events: Vec<egui::Event>,
286추가: commands: &mut Vec<egui::ViewportCommand>,
287추가: ) {
288추가: WORK_CHILD.with(|child| child.borrow_mut().events = events);
289추가: // 자식 창 명령은 부모 출력에 실려 올 수도 있어 둘 다 모음.
290추가: let output = frame_output(ctx, app, vec![]);
291추가: for viewport in output.viewport_output.values() {
292추가: commands.extend(viewport.commands.iter().cloned());
293추가: }
294추가: }
295추가: // 자식 창 제목 표시줄을 누른 채 끌어 창 이동을 운영체제에 넘김.
296추가: let start = egui::pos2(120.0, 19.0);
297추가: child_frame(
298추가: &ctx,
299추가: &mut app,
300추가: vec![egui::Event::PointerMoved(start)],
301추가: &mut commands,
302추가: );
303추가: child_frame(
304추가: &ctx,
305추가: &mut app,
306추가: vec![egui::Event::PointerButton {
307추가: pos: start,
308추가: button: egui::PointerButton::Primary,
309추가: pressed: true,
310추가: modifiers: egui::Modifiers::NONE,
311추가: }],
312추가: &mut commands,
313추가: );
314추가: for step in 1..=3 {
315추가: child_frame(
316추가: &ctx,
317추가: &mut app,
318추가: vec![egui::Event::PointerMoved(
319추가: start + egui::vec2(6.0 * step as f32, 0.0),
320추가: )],
321추가: &mut commands,
322추가: );
323추가: }
324추가: let started = commands.contains(&egui::ViewportCommand::StartDrag)
325추가: || WORK_CHILD.with(|child| {
326추가: child
327추가: .borrow()
328추가: .commands
329추가: .contains(&egui::ViewportCommand::StartDrag)
330추가: });
331추가: assert!(started, "자식 창 이동이 시작돼야 함");
332추가: // GNOME은 이동이 끝나도 버튼 놓기를 보내지 않음. 그대로 닫기 버튼에 마우스를 올림.
333추가: let close = egui::pos2(480.0 - 6.0 - 17.0, 19.0);
334추가: for _ in 0..3 {
335추가: child_frame(
336추가: &ctx,
337추가: &mut app,
338추가: vec![egui::Event::PointerMoved(close)],
339추가: &mut commands,
340추가: );
341추가: }
342추가: let (cursor, hovered_red) = WORK_CHILD.with(|child| {
343추가: let child = child.borrow();
344추가: (
345추가: child.cursor,
346추가: child.rects.iter().any(|(rect, fill)| {
347추가: rect.contains(close) && *fill == egui::Color32::from_rgb(232, 17, 35)
348추가: }),
349추가: )
350추가: });
351추가: assert!(hovered_red, "닫기 버튼에 마우스를 올린 배경이 없음");
352추가: assert_eq!(cursor, Some(egui::CursorIcon::PointingHand));
353추가: }
354추가:
227355#[test]
228356fn close_confirmation_is_not_covered_by_separate_work_window() {
229357 let scratch = Folder::new();
@@ -293,7 +421,7 @@ fn close_confirmation_is_not_covered_by_separate_work_window() {
293421 "종료 확인 중에 별도 진행 창이 떠 있음"
294422 );
295423
296삭제: // 정리가 끝나 결과 확인 후 닫기가 뜰 때도 결과 창이 가리지 않음.
424추가: // 정리가 끝나면 결과 확인 안내 없이 바로 닫히고, 그사이 결과 창도 뜨지 않음.
297425 factory
298426 .state
299427 .borrow_mut()
@@ -301,12 +429,12 @@ fn close_confirmation_is_not_covered_by_separate_work_window() {
301429 for _ in 0..12 {
302430 shown = policy_render(&ctx, &mut app, vec![]);
303431 }
304삭제: assert_eq!(app.model.close, Close::Review);
305삭제: assert!(shown.iter().any(|(text, _)| text == "결과 확인 후 닫기"));
432추가: assert_eq!(app.model.close, Close::Allowed);
433추가: assert!(!shown.iter().any(|(text, _)| text == "결과 확인 후 닫기"));
306434 assert_eq!(
307435 WORK_CHILD.with(|child| child.borrow().rendered),
308436 0,
309삭제: "결과 확인 후 닫기에 별도 결과 창이 떠 있음"
437추가: "닫히는 동안 별도 결과 창이 떠 있음"
310438 );
311439}
312440
@@ -351,15 +479,18 @@ fn main_modals_are_not_covered_by_separate_result_window() {
351479 assert!(!app.model.busy());
352480 assert!(work_rendered() > 0, "결과가 별도 viewport에 그려져야 함");
353481
354삭제: // 결과 창을 둔 채 ZIP 만들기를 열면 그동안 결과 창을 그리지 않음.
482추가: // 결과 창을 둔 채 ZIP 만들기 창(같은 자리에 뜨는 별도 창)을 열면 그동안 결과 창을 그리지 않음.
355483 app.show_create(false);
356484 policy_render(&ctx, &mut app, vec![]);
357삭제: WORK_CHILD.with(|child| child.borrow_mut().rendered = 0);
358삭제: let mut shown = Vec::new();
485추가: WORK_CHILD.with(|child| {
486추가: let mut child = child.borrow_mut();
487추가: child.rendered = 0;
488추가: child.labels.clear();
489추가: });
359490 for _ in 0..5 {
360삭제: shown = policy_render(&ctx, &mut app, vec![]);
491추가: policy_render(&ctx, &mut app, vec![]);
361492 }
362삭제: assert!(shown.iter().any(|(text, _)| text == "ZIP 만들기"));
493추가: let cancel = work_child_label("취소").expect("ZIP 만들기 창이 떠 있어야 함");
363494 assert_eq!(
364495 work_rendered(),
365496 0,
@@ -367,7 +498,7 @@ fn main_modals_are_not_covered_by_separate_result_window() {
367498 );
368499
369500 // ZIP 만들기를 닫으면 결과 창이 다시 나타남.
370삭제: policy_click(&ctx, &mut app, "취소");
501추가: work_child_click(&ctx, &mut app, cancel);
371502 for _ in 0..3 {
372503 policy_render(&ctx, &mut app, vec![]);
373504 }
@@ -387,6 +518,7 @@ fn main_modals_are_not_covered_by_separate_result_window() {
387518 );
388519 policy_render(&ctx, &mut app, vec![]);
389520 WORK_CHILD.with(|child| child.borrow_mut().rendered = 0);
521추가: let mut shown = Vec::new();
390522 for _ in 0..5 {
391523 shown = policy_render(&ctx, &mut app, vec![]);
392524 }
@@ -410,3 +542,49 @@ fn main_modals_are_not_covered_by_separate_result_window() {
410542 "선택 창을 닫으면 결과 창이 다시 나타나야 함"
411543 );
412544}
545추가:
546추가: #[test]
547추가: fn unanswered_close_confirmation_does_not_close_when_work_finishes() {
548추가: let scratch = Folder::new();
549추가: let factory = FakeFactory::default();
550추가: let mut app = loaded(&scratch, &factory);
551추가: factory.state.borrow_mut().manual = true;
552추가: assert!(app.begin_extract());
553추가: factory
554추가: .state
555추가: .borrow_mut()
556추가: .frame(Event::Accepted { encryption: false });
557추가: let ctx = egui::Context::default();
558추가: for _ in 0..4 {
559추가: policy_render(&ctx, &mut app, vec![]);
560추가: }
561추가: app.model.request_close();
562추가: assert_eq!(app.model.close, Close::Confirm);
563추가:
564추가: // 종료 확인 창에 답하지 않은 채 작업이 끝남.
565추가: factory
566추가: .state
567추가: .borrow_mut()
568추가: .finish(Outcome::Completed, Publication::None);
569추가: let mut shown = Vec::new();
570추가: for _ in 0..12 {
571추가: shown = policy_render(&ctx, &mut app, vec![]);
572추가: }
573추가: assert!(!app.model.busy());
574추가: assert_eq!(
575추가: app.model.close,
576추가: Close::Confirm,
577추가: "닫기를 승인하지 않았는데 앱이 닫힘"
578추가: );
579추가: assert!(
580추가: shown
581추가: .iter()
582추가: .any(|(text, _)| text == "작업이 끝났습니다. 창을 닫을까요?"),
583추가: "{shown:?}"
584추가: );
585추가:
586추가: // 그 뒤에 닫기를 고르면 바로 닫힘.
587추가: policy_click(&ctx, &mut app, "닫기");
588추가: policy_render(&ctx, &mut app, vec![]);
589추가: assert_eq!(app.model.close, Close::Allowed);
590추가: }