Merge pull request #100 from Team-LJY/features/explorer-toolbar-polish
탐색기 화면 정리, Pretendard 글꼴, 폴더 선택으로 시작하는 ZIP 만들기 창
- 작성자
- LeeJunyoung
- 작성 시각
- 커밋
97357bd577c847becd212fd47ca95e195d4c8364
변경된 파일 23개
+1,347-184| @@ -5,3 +5,4 @@ Zipelo 의존성 고지 생성 안내 | ||
| 5 | 5 | 로컬 registry의 원문과 잠금 체크섬을 확인하며 누락 시 패키지 생성을 중단함. |
| 6 | 6 | 이 안내 파일과 과거 시험용 보충 원문은 최종 배포 고지를 대신하지 않음. |
| 7 | 7 | 운영체제 기본 파일 창의 rfd 0.16.0(MIT)과 Linux xdg-portal 전이 의존성도 잠금 파일에서 수집함. |
| 8 | 추가: 앱에 포함한 Pretendard 1.3.9 글꼴(SIL OFL 1.1)의 원문도 같은 고지에 넣음. 출처는 src/assets/fonts/README.md임. |
Diff가 표시 한도를 넘어서 생략했어요.
Raw로 열기| @@ -10,6 +10,12 @@ pub const BLUE: Color32 = Color32::from_rgb(37, 99, 235); | ||
| 10 | 10 | pub const BLUE_HOVER: Color32 = Color32::from_rgb(29, 78, 216); |
| 11 | 11 | pub const BLUE_ACTIVE: Color32 = Color32::from_rgb(30, 64, 175); |
| 12 | 12 | pub 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); | |
| 13 | 19 | pub const DROP: Color32 = Color32::from_rgb(238, 244, 255); |
| 14 | 20 | pub const DASH: Color32 = Color32::from_rgb(170, 180, 192); |
| 15 | 21 | pub const SUCCESS: Color32 = Color32::from_rgb(21, 128, 61); |
| @@ -27,8 +33,40 @@ pub const DROP_HEIGHT: f32 = 280.0; | ||
| 27 | 33 | pub const DROP_RADIUS: u8 = 12; |
| 28 | 34 | pub const ROW: f32 = 32.0; |
| 29 | 35 | pub 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 | 추가: } | |
| 32 | 70 | |
| 33 | 71 | pub fn apply(ctx: &egui::Context) { |
| 34 | 72 | ctx.set_theme(egui::Theme::Light); |
| @@ -36,16 +74,16 @@ pub fn apply(ctx: &egui::Context) { | ||
| 36 | 74 | ctx.style_mut_of(egui::Theme::Light, |style| { |
| 37 | 75 | style |
| 38 | 76 | .text_styles |
| 39 | 삭제: .insert(TextStyle::Body, FontId::proportional(BODY)); | |
| 77 | 추가: .insert(TextStyle::Body, FontId::proportional(FONT_BODY)); | |
| 40 | 78 | style |
| 41 | 79 | .text_styles |
| 42 | 삭제: .insert(TextStyle::Button, FontId::proportional(BODY)); | |
| 80 | 추가: .insert(TextStyle::Button, FontId::proportional(FONT_BODY)); | |
| 43 | 81 | style |
| 44 | 82 | .text_styles |
| 45 | 삭제: .insert(TextStyle::Small, FontId::proportional(BODY)); | |
| 83 | 추가: .insert(TextStyle::Small, FontId::proportional(FONT_SMALL)); | |
| 46 | 84 | style |
| 47 | 85 | .text_styles |
| 48 | 삭제: .insert(TextStyle::Heading, FontId::proportional(TITLE)); | |
| 86 | 추가: .insert(TextStyle::Heading, FontId::proportional(FONT_LARGE)); | |
| 49 | 87 | style.visuals.override_text_color = Some(TEXT); |
| 50 | 88 | style.visuals.panel_fill = BACKGROUND; |
| 51 | 89 | style.visuals.window_fill = PANEL; |
| @@ -75,9 +113,23 @@ pub fn apply(ctx: &egui::Context) { | ||
| 75 | 113 | style.spacing.interact_size.y = ROW; |
| 76 | 114 | style.spacing.window_margin = egui::Margin::same(PAD); |
| 77 | 115 | 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; | |
| 78 | 122 | }); |
| 79 | 123 | } |
| 80 | 124 | |
| 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 | 추가: | |
| 81 | 133 | pub fn focus(response: &egui::Response) { |
| 82 | 134 | if response.has_focus() { |
| 83 | 135 | response.ctx.layer_painter(response.layer_id).rect_stroke( |
| @@ -90,6 +142,21 @@ pub fn focus(response: &egui::Response) { | ||
| 90 | 142 | } |
| 91 | 143 | |
| 92 | 144 | pub 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 { | |
| 93 | 160 | let response = ui |
| 94 | 161 | .scope(|ui| { |
| 95 | 162 | if primary { |
| @@ -110,18 +177,107 @@ pub fn action(ui: &mut egui::Ui, text: &str, primary: bool, enabled: bool) -> eg | ||
| 110 | 177 | } else { |
| 111 | 178 | TEXT |
| 112 | 179 | })) |
| 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) | |
| 117 | 181 | .stroke(Stroke::new(1.0, if primary { BLUE } else { BORDER })), |
| 118 | 182 | ) |
| 119 | 183 | }) |
| 120 | 184 | .inner; |
| 185 | 추가: pointer(&response); | |
| 121 | 186 | focus(&response); |
| 122 | 187 | response |
| 123 | 188 | } |
| 124 | 189 | |
| 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 | 추가: | |
| 125 | 281 | pub fn panel(fill: Color32) -> egui::Frame { |
| 126 | 282 | egui::Frame::new() |
| 127 | 283 | .fill(fill) |
| @@ -200,6 +356,16 @@ pub fn icon(ui: &mut egui::Ui, kind: Icon, size: f32) { | ||
| 200 | 356 | } |
| 201 | 357 | |
| 202 | 358 | pub 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 { | |
| 203 | 369 | let width = width.max(0.0); |
| 204 | 370 | ui.allocate_ui_with_layout( |
| 205 | 371 | 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 | ||
| 211 | 377 | }, |
| 212 | 378 | ) |
| 213 | 379 | .inner |
| 214 | 삭제: .on_hover_text(text) | |
| 380 | 추가: .on_hover_text(hover) | |
| 215 | 381 | } |
| 216 | 382 | |
| 217 | 383 | 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); | |
| 384 | 추가: let mut job = egui::text::LayoutJob::simple_singleline( | |
| 385 | 추가: text.into(), | |
| 386 | 추가: FontId::proportional(FONT_BODY), | |
| 387 | 추가: TEXT, | |
| 388 | 추가: ); | |
| 220 | 389 | job.wrap = egui::text::TextWrapping { |
| 221 | 390 | max_width: width.max(0.0), |
| 222 | 391 | max_rows: 1, |
| @@ -256,21 +425,27 @@ pub fn action_pair( | ||
| 256 | 425 | ) -> (bool, bool) { |
| 257 | 426 | let text_width = |text: &str| { |
| 258 | 427 | ui.painter() |
| 259 | 삭제: .layout_no_wrap(text.into(), FontId::proportional(BODY), TEXT) | |
| 428 | 추가: .layout_no_wrap(text.into(), FontId::proportional(FONT_BODY), TEXT) | |
| 260 | 429 | .size() |
| 261 | 430 | .x |
| 262 | 431 | }; |
| 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); | |
| 268 | 443 | ui.horizontal(|ui| { |
| 269 | 444 | ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| { |
| 270 | 445 | 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(); | |
| 272 | 447 | let primary = primary.is_some_and(|(label, enabled)| { |
| 273 | 삭제: action(ui, label, true, enabled) | |
| 448 | 추가: action_sized(ui, label, true, enabled, button) | |
| 274 | 449 | .on_disabled_hover_text(match label { |
| 275 | 450 | "만들기" => "묶을 파일이나 폴더를 추가하세요", |
| 276 | 451 | "다른 폴더에 풀기" => "기존 풀 위치 폴더를 먼저 확인하세요", |
| @@ -290,18 +465,9 @@ pub fn indeterminate(ui: &mut egui::Ui) { | ||
| 290 | 465 | egui::vec2(ui.available_width(), SPACE * 2.0), |
| 291 | 466 | egui::Sense::hover(), |
| 292 | 467 | ); |
| 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)); | |
| 305 | 471 | response.widget_info(|| { |
| 306 | 472 | egui::WidgetInfo::labeled( |
| 307 | 473 | egui::Role::ProgressIndicator, |
| @@ -333,13 +499,72 @@ pub fn svg_icon(painter: &egui::Painter, rect: egui::Rect, asset: &str, color: C | ||
| 333 | 499 | ) |
| 334 | 500 | }) |
| 335 | 501 | .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))); | |
| 340 | 508 | } |
| 341 | 509 | } |
| 342 | 510 | |
| 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 | 추가: | |
| 343 | 568 | pub fn tool( |
| 344 | 569 | ui: &mut egui::Ui, |
| 345 | 570 | label: &str, |
| @@ -347,36 +572,86 @@ pub fn tool( | ||
| 347 | 572 | enabled: bool, |
| 348 | 573 | blue: bool, |
| 349 | 574 | ) -> 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 | 추가: }, | |
| 359 | 582 | ); |
| 360 | 삭제: let rect = response.rect; | |
| 583 | 추가: response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, label)); | |
| 361 | 584 | let color = if enabled { |
| 362 | 585 | if blue { BLUE } else { TEXT } |
| 363 | 586 | } else { |
| 364 | 587 | MUTED |
| 365 | 588 | }; |
| 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), | |
| 369 | 609 | ); |
| 370 | 삭제: ui.painter() | |
| 371 | 삭제: .rect_filled(rect.shrink2(egui::vec2(1.0, 27.0)), 0, PANEL); | |
| 372 | 610 | 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, | |
| 378 | 615 | color, |
| 379 | 616 | ); |
| 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); | |
| 380 | 655 | focus(&response); |
| 381 | 656 | response |
| 382 | 657 | } |
| @@ -397,6 +672,7 @@ pub fn icon_button(ui: &mut egui::Ui, name: &str, asset: &str, enabled: bool) -> | ||
| 397 | 672 | asset, |
| 398 | 673 | if enabled { TEXT } else { MUTED }, |
| 399 | 674 | ); |
| 675 | 추가: pointer(&response); | |
| 400 | 676 | focus(&response); |
| 401 | 677 | response |
| 402 | 678 | } |
| @@ -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. |
바이너리 파일이라 Diff를 표시하지 않아요.
파일 내려받기| @@ -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`에 이 원문을 넣음. |
| @@ -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> |
| @@ -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> |
| @@ -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> |
| @@ -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> |
| @@ -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> |
| @@ -7,7 +7,7 @@ mod fake; | ||
| 7 | 7 | mod renderer; |
| 8 | 8 | #[path = "system_font.rs"] |
| 9 | 9 | mod system_font; |
| 10 | 삭제: use eframe::egui::{self, FontData, FontDefinitions, FontFamily}; | |
| 10 | 추가: use eframe::egui; | |
| 11 | 11 | fn main() -> eframe::Result { |
| 12 | 12 | let result = run(); |
| 13 | 13 | #[cfg(target_os = "windows")] |
| @@ -43,7 +43,10 @@ fn show_startup_error(message: &str) { | ||
| 43 | 43 | |
| 44 | 44 | fn run() -> eframe::Result { |
| 45 | 45 | 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)); | |
| 47 | 50 | renderer::run_native( |
| 48 | 51 | "Zipelo", |
| 49 | 52 | eframe::NativeOptions { |
| @@ -54,17 +57,10 @@ fn run() -> eframe::Result { | ||
| 54 | 57 | ..Default::default() |
| 55 | 58 | }, |
| 56 | 59 | || { |
| 57 | 삭제: let bytes = font.bytes.clone(); | |
| 58 | 삭제: let face_index = font.face_index; | |
| 60 | 추가: let fallback = fallback.clone(); | |
| 59 | 61 | 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)); | |
| 68 | 64 | zipelo_ui_memory_app::archive_theme::apply(&cc.egui_ctx); |
| 69 | 65 | let (fixture, startup) = zipelo_ui_memory_app::archive_ui::launch_args( |
| 70 | 66 | std::env::args_os().skip(1).collect(), |
| @@ -95,7 +95,7 @@ pub fn title_bar(root: &mut egui::Ui, id: &str, title: &str, buttons: Buttons) - | ||
| 95 | 95 | // 버튼 영역을 피해 가운데에 제목을 그림. |
| 96 | 96 | let reserved = rect.right() - right; |
| 97 | 97 | 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); | |
| 99 | 99 | let text = fit(ui, title, &font, width); |
| 100 | 100 | ui.painter().text( |
| 101 | 101 | rect.center(), |
| @@ -140,6 +140,10 @@ fn start_move(ctx: &egui::Context, id: &str, bar: Rect, buttons_left: f32) -> bo | ||
| 140 | 140 | origin = None; |
| 141 | 141 | // 운영체제가 이동을 맡으므로 egui 쪽 끌기는 끝낸 것으로 처리함. |
| 142 | 142 | ctx.stop_dragging(); |
| 143 | 추가: // 이동이 끝나도 버튼 놓기가 오지 않아 egui가 버튼이 눌린 채로 알고 있으면 | |
| 144 | 추가: // 다른 버튼에 마우스를 올려도 반응하지 않음. 이 창의 마우스 상태를 비움. | |
| 145 | 추가: // 메인 창뿐 아니라 입력 훅을 쓸 수 없는 자식 창에도 적용됨. | |
| 146 | 추가: ctx.input_mut(|input| input.pointer = Default::default()); | |
| 143 | 147 | } |
| 144 | 148 | ctx.data_mut(|d| d.insert_temp(key, origin)); |
| 145 | 149 | start |
| @@ -160,6 +164,7 @@ fn window_button(ui: &mut egui::Ui, id: &str, rect: Rect, glyph: Glyph) -> egui: | ||
| 160 | 164 | ) |
| 161 | 165 | .on_hover_text(label); |
| 162 | 166 | response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, label)); |
| 167 | 추가: theme::pointer(&response); | |
| 163 | 168 | let painter = ui.painter(); |
| 164 | 169 | if response.hovered() || response.is_pointer_button_down_on() { |
| 165 | 170 | let fill = if glyph == Glyph::Close { |
| @@ -189,13 +189,47 @@ def inventory(manifests, project_root=None, supplement_path=ROOT / "packaging/li | ||
| 189 | 189 | return [records[key] for key in sorted(records)] |
| 190 | 190 | |
| 191 | 191 | |
| 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 | 추가: | |
| 192 | 226 | def render(records): |
| 193 | 227 | missing = [f'{record["name"]}@{record["version"]}' for record in records if not record["files"]] |
| 194 | 228 | if missing: |
| 195 | 229 | 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 보충)", ""] | |
| 197 | 231 | 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"]}', | |
| 199 | 233 | f'Source: {record["source"]}', f'License: {record["license"]}', f'Version: {record["version"]}', ""]) |
| 200 | 234 | for file in record["files"]: |
| 201 | 235 | lines.extend([f'File: {file["path"]}', f'SHA-256: {file["sha256"]}']) |
| @@ -206,7 +240,7 @@ def render(records): | ||
| 206 | 240 | |
| 207 | 241 | |
| 208 | 242 | def generate(manifests, output, audit=None): |
| 209 | 삭제: records = inventory(manifests) | |
| 243 | 추가: records = inventory(manifests) + bundled_records() | |
| 210 | 244 | if audit: |
| 211 | 245 | Path(audit).write_text(json.dumps(records, ensure_ascii=False, indent=4) + "\n", encoding="utf-8") |
| 212 | 246 | text = render(records) |
| @@ -79,13 +79,34 @@ impl Screen { | ||
| 79 | 79 | assert_eq!(self.app.model.terminal.as_ref().unwrap().outcome, expected); |
| 80 | 80 | assert!(self.app.model.challenge.is_none()); |
| 81 | 81 | } |
| 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 { | |
| 83 | 85 | self.app.add_sources(vec![source.to_path_buf()]); |
| 84 | 86 | self.render(vec![]); |
| 85 | 87 | self.set_text("zip-name", archive.file_name().unwrap().to_str().unwrap()); |
| 86 | 88 | 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 | 추가: } | |
| 87 | 95 | 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()); | |
| 89 | 110 | } |
| 90 | 111 | } |
| 91 | 112 | #[test] |
| @@ -190,7 +211,8 @@ fn cancel_password_extraction_waits_for_cleanup_without_writes() { | ||
| 190 | 211 | Close::Waiting | Close::Review |
| 191 | 212 | )); |
| 192 | 213 | 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); | |
| 194 | 216 | assert_eq!(fs::read(output.join("existing.txt")).unwrap(), b"preserve"); |
| 195 | 217 | assert_eq!(fs::read_dir(output).unwrap().count(), 1); |
| 196 | 218 | assert_reaped(&observed); |
| @@ -206,11 +228,9 @@ fn cold_start_creates_aes_zip_then_reopens_and_extracts_with_password() { | ||
| 206 | 228 | let (factory, observed) = observed_factory(); |
| 207 | 229 | let mut screen = Screen::new(factory); |
| 208 | 230 | 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); | |
| 214 | 234 | let bytes = fs::read(&archive).unwrap(); |
| 215 | 235 | assert_eq!(&bytes[..4], b"PK\x03\x04"); |
| 216 | 236 | 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() { | ||
| 226 | 246 | assert_reaped(&observed); |
| 227 | 247 | } |
| 228 | 248 | #[test] |
| 229 | 삭제: fn cancel_password_creation_does_not_create_an_archive() { | |
| 249 | 추가: fn cancel_encrypted_creation_window_starts_no_worker_or_archive() { | |
| 230 | 250 | let scratch = Scratch::new(); |
| 231 | 251 | let source = scratch.path("private.txt"); |
| 232 | 252 | fs::write(&source, b"preserve").unwrap(); |
| 233 | 253 | let archive = scratch.path("cancelled.zip"); |
| 234 | 254 | let (factory, observed) = observed_factory(); |
| 235 | 255 | 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()); | |
| 240 | 266 | assert!(!archive.exists()); |
| 241 | 267 | assert_eq!(fs::read(source).unwrap(), b"preserve"); |
| 242 | 268 | 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() { | ||
| 267 | 293 | assert_reaped(&observed); |
| 268 | 294 | } |
| 269 | 295 | |
| 270 | 삭제: fn invalid_password_then_cancel(invalid: &str, close: bool) { | |
| 296 | 추가: fn invalid_zip_password_never_starts_a_worker(invalid: &str, close: bool) { | |
| 271 | 297 | let scratch = Scratch::new(); |
| 272 | 298 | let source = scratch.path("private.txt"); |
| 273 | 299 | fs::write(&source, b"preserve").unwrap(); |
| 274 | 300 | let archive = scratch.path("cancelled.zip"); |
| 275 | 301 | let (factory, observed) = observed_factory(); |
| 276 | 302 | 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() { | |
| 284 | 307 | assert!( |
| 285 | 308 | screen |
| 286 | 309 | .render(vec![]) |
| @@ -289,52 +312,38 @@ fn invalid_password_then_cancel(invalid: &str, close: bool) { | ||
| 289 | 312 | ); |
| 290 | 313 | } |
| 291 | 314 | if close { |
| 315 | 추가: // 작업이 없으므로 확인만 거치면 닫을 수 있음. | |
| 292 | 316 | 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); | |
| 296 | 320 | } else { |
| 297 | 삭제: screen.escape(); | |
| 321 | 추가: screen.click("취소"); | |
| 322 | 추가: assert!( | |
| 323 | 추가: !screen | |
| 324 | 추가: .render(vec![]) | |
| 325 | 추가: .iter() | |
| 326 | 추가: .any(|(value, _)| value == "ZIP 만들기") | |
| 327 | 추가: ); | |
| 298 | 328 | } |
| 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 | 삭제: ); | |
| 316 | 329 | assert!(!archive.exists()); |
| 317 | 330 | assert_eq!(fs::read(&source).unwrap(), b"preserve"); |
| 318 | 331 | assert_eq!(fs::read_dir(&scratch.0).unwrap().count(), 1); |
| 319 | 332 | 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 { | |
| 325 | 334 | screen.open(&encrypted_fixture(&scratch, "aes2-store.zip")); |
| 326 | 335 | assert_reaped(&observed); |
| 327 | 336 | } |
| 328 | 337 | } |
| 329 | 338 | #[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); | |
| 332 | 341 | } |
| 333 | 342 | #[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); | |
| 336 | 345 | } |
| 337 | 346 | #[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); | |
| 340 | 349 | } |
| @@ -1,4 +1,4 @@ | ||
| 1 | 삭제: use eframe::egui::{self, FontData, FontDefinitions, FontFamily, FontId, TextStyle}; | |
| 1 | 추가: use eframe::egui::{self, FontId, TextStyle}; | |
| 2 | 2 | use std::{collections::VecDeque, path::PathBuf}; |
| 3 | 3 | use zipelo_ui_memory_app::{archive_screen::ArchiveApp, archive_ui::*}; |
| 4 | 4 | #[path = "../../experiments/rust-ui-memory-app/src/renderer.rs"] |
| @@ -388,7 +388,9 @@ fn main() -> eframe::Result { | ||
| 388 | 388 | std::fs::create_dir_all(&base).unwrap(); |
| 389 | 389 | std::fs::write(base.join("읽어주세요.txt"), "화면 검증 입력").unwrap(); |
| 390 | 390 | 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)); | |
| 392 | 394 | let title = format!("Zipelo UI capture {mode}"); |
| 393 | 395 | renderer::run_native( |
| 394 | 396 | &title, |
| @@ -401,17 +403,10 @@ fn main() -> eframe::Result { | ||
| 401 | 403 | || { |
| 402 | 404 | let mode = mode.clone(); |
| 403 | 405 | let base = base.clone(); |
| 404 | 삭제: let bytes = font.bytes.clone(); | |
| 405 | 삭제: let face_index = font.face_index; | |
| 406 | 추가: let fallback = fallback.clone(); | |
| 406 | 407 | 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())); | |
| 415 | 410 | cc.egui_ctx.set_visuals(egui::Visuals::light()); |
| 416 | 411 | cc.egui_ctx.style_mut_of(egui::Theme::Light, |style| { |
| 417 | 412 | style |
| @@ -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 | 추가: } |
| @@ -6,6 +6,8 @@ pub struct State { | ||
| 6 | 6 | pub requests: Vec<(u64, &'static str)>, |
| 7 | 7 | pub starts: Vec<Start>, |
| 8 | 8 | pub password_seen: bool, |
| 9 | 추가: /// 마지막으로 받은 암호 원문. 화면에서 입력한 암호가 그대로 전달됐는지 확인할 때 씀. | |
| 10 | 추가: pub password: Vec<u8>, | |
| 9 | 11 | pub job: u64, |
| 10 | 12 | sequence: u64, |
| 11 | 13 | pub queue: VecDeque<HostEvent>, |
| @@ -176,6 +178,7 @@ impl Connection for FakeConnection { | ||
| 176 | 178 | assert_eq!(challenge_id, 17); |
| 177 | 179 | assert!(!secret.as_bytes().is_empty()); |
| 178 | 180 | s.password_seen = true; |
| 181 | 추가: s.password = secret.as_bytes().to_vec(); | |
| 179 | 182 | s.requests.push((request.sequence, "password")); |
| 180 | 183 | if !s.manual { |
| 181 | 184 | s.complete_action(); |
| @@ -100,18 +100,24 @@ fn narrow_archive_keeps_columns_and_virtualizes_thousands_of_long_names() { | ||
| 100 | 100 | assert_narrow_text(&output); |
| 101 | 101 | let text = layout_text(&output); |
| 102 | 102 | assert!(text.len() < 100); |
| 103 | 추가: // 암호가 걸린 항목은 이름 앞에 *가 붙음. | |
| 103 | 104 | let first = text |
| 104 | 105 | .iter() |
| 105 | 삭제: .find(|(text, _, _)| text == &format!("0000-{name}")) | |
| 106 | 추가: .find(|(text, _, _)| text.trim_start_matches('*') == format!("0000-{name}")) | |
| 106 | 107 | .unwrap(); |
| 107 | 108 | assert!(first.2); |
| 109 | 추가: // 크기는 스크롤 막대 자리(오른쪽 24px)를 침범하지 않는 행 안쪽에 남음. | |
| 108 | 110 | assert!( |
| 109 | 111 | text.iter() |
| 110 | 삭제: .any(|(text, rect, _)| text == "31 B" && rect.right() < 720.0) | |
| 112 | 추가: .any(|(text, rect, _)| text == "31 B" && rect.right() <= 736.0) | |
| 111 | 113 | ); |
| 112 | 삭제: for expected in ["크기", "암호", "5000개 항목", "선택 5000개"] { | |
| 114 | 추가: for expected in ["5000개 항목", "선택 5000개"] { | |
| 113 | 115 | assert!(text.iter().any(|(text, _, _)| text == expected)); |
| 114 | 116 | } |
| 117 | 추가: // 열 제목 줄(이름, 크기, 암호)은 없고 암호는 이름 앞의 *로만 표시함. | |
| 118 | 추가: for removed in ["이름", "크기", "암호"] { | |
| 119 | 추가: assert!(!text.iter().any(|(text, _, _)| text == removed)); | |
| 120 | 추가: } | |
| 115 | 121 | let title = output |
| 116 | 122 | .viewport_output |
| 117 | 123 | .values() |
| @@ -123,7 +129,13 @@ fn narrow_archive_keeps_columns_and_virtualizes_thousands_of_long_names() { | ||
| 123 | 129 | .unwrap(); |
| 124 | 130 | assert!(title.contains('…') && title.ends_with(" — Zipelo")); |
| 125 | 131 | 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 | 추가: ); | |
| 127 | 139 | let output = narrow_frame(&ctx, &mut app, 14.0, vec![egui::Event::PointerGone]); |
| 128 | 140 | let point = layout_text(&output) |
| 129 | 141 | .into_iter() |
| @@ -152,13 +164,13 @@ fn narrow_deep_folder_path_is_elided_without_displacing_search() { | ||
| 152 | 164 | assert!(path.2); |
| 153 | 165 | assert!( |
| 154 | 166 | text.iter() |
| 155 | 삭제: .any(|(text, rect, _)| text == "파일 찾기" && rect.right() < 760.0) | |
| 167 | 추가: .any(|(text, rect, _)| text == "파일 검색" && rect.right() < 760.0) | |
| 156 | 168 | ); |
| 157 | 169 | assert_full_tooltip(&ctx, &mut app, path.1.center(), &full); |
| 158 | 170 | } |
| 159 | 171 | |
| 160 | 172 | #[test] |
| 161 | 삭제: fn narrow_create_sources_keep_remove_and_footer_actions_visible() { | |
| 173 | 추가: fn narrow_create_sources_keep_names_and_footer_actions_visible() { | |
| 162 | 174 | let scratch = Folder::new(); |
| 163 | 175 | let factory = FakeFactory::default(); |
| 164 | 176 | let mut app = loaded(&scratch, &factory); |
| @@ -176,7 +188,7 @@ fn narrow_create_sources_keep_remove_and_footer_actions_visible() { | ||
| 176 | 188 | text.iter() |
| 177 | 189 | .any(|(text, _, elided)| text == &name && *elided) |
| 178 | 190 | ); |
| 179 | 삭제: for expected in ["빼기", "취소", "압축하기"] { | |
| 191 | 추가: for expected in ["취소", "압축하기"] { | |
| 180 | 192 | assert!( |
| 181 | 193 | text.iter() |
| 182 | 194 | .any(|(text, rect, _)| text == expected && rect.bottom() <= 540.0) |
| @@ -911,6 +911,7 @@ mod widgets { | ||
| 911 | 911 | include!("explorer_selection.rs"); |
| 912 | 912 | include!("window_frame.rs"); |
| 913 | 913 | include!("work_window.rs"); |
| 914 | 추가: include!("create_window.rs"); | |
| 914 | 915 | } |
| 915 | 916 | |
| 916 | 917 | #[cfg(feature = "ui")] |
| @@ -375,6 +375,16 @@ fn renders_every_flow_with_actual_egui_widgets() { | ||
| 375 | 375 | let ctx = egui::Context::default(); |
| 376 | 376 | let f = FakeFactory::default(); |
| 377 | 377 | 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)); | |
| 378 | 388 | let render = |app: &mut ArchiveApp, events: Vec<egui::Event>, width: f32| { |
| 379 | 389 | let mut output = ctx.run_ui( |
| 380 | 390 | egui::RawInput { |
| @@ -450,7 +460,9 @@ fn renders_every_flow_with_actual_egui_widgets() { | ||
| 450 | 460 | pump(&mut app.model); |
| 451 | 461 | render(&mut app, vec![], 1060.0); |
| 452 | 462 | 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); | |
| 454 | 466 | } |
| 455 | 467 | |
| 456 | 468 | #[test] |
| @@ -57,11 +57,10 @@ fn native_dialog_cancellation_never_starts_a_job() { | ||
| 57 | 57 | policy_click(&ctx, &mut app, "열기"); |
| 58 | 58 | policy_click(&ctx, &mut app, "압축해제"); |
| 59 | 59 | assert_eq!(factory.state.borrow().starts.len(), 1); |
| 60 | 추가: // 압축하기는 폴더 선택 창을 먼저 열고, 취소하면 ZIP 만들기 창을 열지 않음. | |
| 60 | 61 | policy_click(&ctx, &mut app, "압축하기"); |
| 61 | 삭제: policy_click(&ctx, &mut app, "파일 추가"); | |
| 62 | 삭제: policy_click(&ctx, &mut app, "폴더 추가"); | |
| 63 | 62 | let shown = policy_render(&ctx, &mut app, vec![]); |
| 64 | 삭제: assert!(shown.iter().any(|(text, _)| text == "ZIP 만들기")); | |
| 63 | 추가: assert!(!shown.iter().any(|(text, _)| text == "ZIP 만들기")); | |
| 65 | 64 | assert_eq!(factory.state.borrow().starts.len(), 1); |
| 66 | 65 | let source = scratch.0.join("source.txt"); |
| 67 | 66 | fs::write(&source, b"source").unwrap(); |
| @@ -81,7 +80,6 @@ fn native_dialog_cancellation_never_starts_a_job() { | ||
| 81 | 80 | [ |
| 82 | 81 | Purpose::Open, |
| 83 | 82 | Purpose::Destination, |
| 84 | 삭제: Purpose::Files, | |
| 85 | 83 | Purpose::Folder, |
| 86 | 84 | Purpose::SaveZip |
| 87 | 85 | ] |
| @@ -90,7 +88,7 @@ fn native_dialog_cancellation_never_starts_a_job() { | ||
| 90 | 88 | |
| 91 | 89 | #[test] |
| 92 | 90 | fn toolbar_and_modal_keyboard_do_not_submit_from_secondary_controls() { |
| 93 | 삭제: for label in ["취소", "파일 추가", "폴더 추가"] { | |
| 91 | 추가: for label in ["취소", "암호로 보호하기"] { | |
| 94 | 92 | let scratch = Folder::new(); |
| 95 | 93 | let factory = FakeFactory::default(); |
| 96 | 94 | let mut app = loaded(&scratch, &factory); |
| @@ -159,14 +157,30 @@ fn toolbar_has_three_actions_and_zip_password_option_remains_available() { | ||
| 159 | 157 | assert!(shown.iter().any(|(text, _)| text == label), "{label}"); |
| 160 | 158 | } |
| 161 | 159 | 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())); | |
| 162 | 171 | policy_click(&ctx, &mut app, "압축하기"); |
| 163 | 172 | let shown = policy_render(&ctx, &mut app, vec![]); |
| 164 | 173 | assert!(shown.iter().any(|(text, _)| text == "ZIP 만들기")); |
| 165 | 174 | 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 == "암호 확인")); | |
| 169 | 176 | 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"); | |
| 170 | 184 | policy_click(&ctx, &mut app, "압축하기"); |
| 171 | 185 | assert!(matches!( |
| 172 | 186 | factory.state.borrow().starts.last(), |
| @@ -361,7 +375,6 @@ fn dialog_failures_show_alerts_while_cancelled_dialogs_remain_silent() { | ||
| 361 | 375 | for failed in [false, true] { |
| 362 | 376 | for purpose in [ |
| 363 | 377 | Purpose::Open, |
| 364 | 삭제: Purpose::Files, | |
| 365 | 378 | Purpose::Folder, |
| 366 | 379 | Purpose::Destination, |
| 367 | 380 | Purpose::SaveZip, |
| @@ -382,18 +395,14 @@ fn dialog_failures_show_alerts_while_cancelled_dialogs_remain_silent() { | ||
| 382 | 395 | let ctx = egui::Context::default(); |
| 383 | 396 | let label = match purpose { |
| 384 | 397 | 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 | 추가: "압축하기" | |
| 397 | 406 | } |
| 398 | 407 | _ => "압축해제", |
| 399 | 408 | }; |
| @@ -5,6 +5,11 @@ struct WorkChild { | ||
| 5 | 5 | events: Vec<egui::Event>, |
| 6 | 6 | labels: Vec<(String, egui::Pos2)>, |
| 7 | 7 | rendered: usize, |
| 8 | 추가: cursor: Option<egui::CursorIcon>, | |
| 9 | 추가: rects: Vec<(egui::Rect, egui::Color32)>, | |
| 10 | 추가: commands: Vec<egui::ViewportCommand>, | |
| 11 | 추가: /// 다음에 그리는 별도 창에 운영체제의 닫기(X) 요청을 보냄. | |
| 12 | 추가: close: bool, | |
| 8 | 13 | } |
| 9 | 14 | |
| 10 | 15 | std::thread_local! { |
| @@ -16,12 +21,22 @@ fn install_work_child_renderer() { | ||
| 16 | 21 | // 같은 스레드에서 이어 도는 시험끼리 기록이 섞이지 않게 비움. |
| 17 | 22 | WORK_CHILD.with(|child| *child.borrow_mut() = WorkChild::default()); |
| 18 | 23 | 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 | 추가: }); | |
| 20 | 31 | let mut raw = egui::RawInput { |
| 21 | 32 | viewport_id: viewport.ids.this, |
| 33 | 추가: // 창이 요청한 크기로 그림(ZIP 만들기 창은 진행 창보다 큼). | |
| 22 | 34 | screen_rect: Some(egui::Rect::from_min_size( |
| 23 | 35 | 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)), | |
| 25 | 40 | )), |
| 26 | 41 | events, |
| 27 | 42 | ..Default::default() |
| @@ -31,6 +46,11 @@ fn install_work_child_renderer() { | ||
| 31 | 46 | egui::ViewportInfo { |
| 32 | 47 | parent: Some(viewport.ids.parent), |
| 33 | 48 | focused: Some(true), |
| 49 | 추가: events: if close { | |
| 50 | 추가: vec![egui::ViewportEvent::Close] | |
| 51 | 추가: } else { | |
| 52 | 추가: vec![] | |
| 53 | 추가: }, | |
| 34 | 54 | ..Default::default() |
| 35 | 55 | }, |
| 36 | 56 | ); |
| @@ -43,6 +63,21 @@ fn install_work_child_renderer() { | ||
| 43 | 63 | if viewport.ids.this == egui::ViewportId::from_hash_of("archive-work") { |
| 44 | 64 | child.rendered += 1; |
| 45 | 65 | } |
| 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 | 추가: } | |
| 46 | 81 | }); |
| 47 | 82 | }); |
| 48 | 83 | } |
| @@ -224,6 +259,99 @@ fn password_prompt_is_not_covered_by_separate_work_window() { | ||
| 224 | 259 | ); |
| 225 | 260 | } |
| 226 | 261 | |
| 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 | 추가: | |
| 227 | 355 | #[test] |
| 228 | 356 | fn close_confirmation_is_not_covered_by_separate_work_window() { |
| 229 | 357 | let scratch = Folder::new(); |
| @@ -293,7 +421,7 @@ fn close_confirmation_is_not_covered_by_separate_work_window() { | ||
| 293 | 421 | "종료 확인 중에 별도 진행 창이 떠 있음" |
| 294 | 422 | ); |
| 295 | 423 | |
| 296 | 삭제: // 정리가 끝나 결과 확인 후 닫기가 뜰 때도 결과 창이 가리지 않음. | |
| 424 | 추가: // 정리가 끝나면 결과 확인 안내 없이 바로 닫히고, 그사이 결과 창도 뜨지 않음. | |
| 297 | 425 | factory |
| 298 | 426 | .state |
| 299 | 427 | .borrow_mut() |
| @@ -301,12 +429,12 @@ fn close_confirmation_is_not_covered_by_separate_work_window() { | ||
| 301 | 429 | for _ in 0..12 { |
| 302 | 430 | shown = policy_render(&ctx, &mut app, vec![]); |
| 303 | 431 | } |
| 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 == "결과 확인 후 닫기")); | |
| 306 | 434 | assert_eq!( |
| 307 | 435 | WORK_CHILD.with(|child| child.borrow().rendered), |
| 308 | 436 | 0, |
| 309 | 삭제: "결과 확인 후 닫기에 별도 결과 창이 떠 있음" | |
| 437 | 추가: "닫히는 동안 별도 결과 창이 떠 있음" | |
| 310 | 438 | ); |
| 311 | 439 | } |
| 312 | 440 | |
| @@ -351,15 +479,18 @@ fn main_modals_are_not_covered_by_separate_result_window() { | ||
| 351 | 479 | assert!(!app.model.busy()); |
| 352 | 480 | assert!(work_rendered() > 0, "결과가 별도 viewport에 그려져야 함"); |
| 353 | 481 | |
| 354 | 삭제: // 결과 창을 둔 채 ZIP 만들기를 열면 그동안 결과 창을 그리지 않음. | |
| 482 | 추가: // 결과 창을 둔 채 ZIP 만들기 창(같은 자리에 뜨는 별도 창)을 열면 그동안 결과 창을 그리지 않음. | |
| 355 | 483 | app.show_create(false); |
| 356 | 484 | 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 | 추가: }); | |
| 359 | 490 | for _ in 0..5 { |
| 360 | 삭제: shown = policy_render(&ctx, &mut app, vec![]); | |
| 491 | 추가: policy_render(&ctx, &mut app, vec![]); | |
| 361 | 492 | } |
| 362 | 삭제: assert!(shown.iter().any(|(text, _)| text == "ZIP 만들기")); | |
| 493 | 추가: let cancel = work_child_label("취소").expect("ZIP 만들기 창이 떠 있어야 함"); | |
| 363 | 494 | assert_eq!( |
| 364 | 495 | work_rendered(), |
| 365 | 496 | 0, |
| @@ -367,7 +498,7 @@ fn main_modals_are_not_covered_by_separate_result_window() { | ||
| 367 | 498 | ); |
| 368 | 499 | |
| 369 | 500 | // ZIP 만들기를 닫으면 결과 창이 다시 나타남. |
| 370 | 삭제: policy_click(&ctx, &mut app, "취소"); | |
| 501 | 추가: work_child_click(&ctx, &mut app, cancel); | |
| 371 | 502 | for _ in 0..3 { |
| 372 | 503 | policy_render(&ctx, &mut app, vec![]); |
| 373 | 504 | } |
| @@ -387,6 +518,7 @@ fn main_modals_are_not_covered_by_separate_result_window() { | ||
| 387 | 518 | ); |
| 388 | 519 | policy_render(&ctx, &mut app, vec![]); |
| 389 | 520 | WORK_CHILD.with(|child| child.borrow_mut().rendered = 0); |
| 521 | 추가: let mut shown = Vec::new(); | |
| 390 | 522 | for _ in 0..5 { |
| 391 | 523 | shown = policy_render(&ctx, &mut app, vec![]); |
| 392 | 524 | } |
| @@ -410,3 +542,49 @@ fn main_modals_are_not_covered_by_separate_result_window() { | ||
| 410 | 542 | "선택 창을 닫으면 결과 창이 다시 나타나야 함" |
| 411 | 543 | ); |
| 412 | 544 | } |
| 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 | 추가: } |