team-ljyzipelo

공개

Merge pull request #142 from Team-LJY/fix/work-window-stays-on-top

작업 창 가림과 로딩 중 빈 폴더 안내 수정
작성자
LeeJunyoung
작성 시각
커밋
fc5e571a73ed8d22840c1f603b7cef945ade5db7
이 시점의 파일 보기

변경된 파일 6개

+351-10
수정docs/ui-scenario-guide.md+2-0
@@ -52,6 +52,8 @@ cargo +1.99.1 build --locked --manifest-path experiments/rust-ui-memory-app/Carg
5252- search-empty: 검색 결과 없음. 검색 입력과 빈 결과 안내를 확인한다.
5353- password: 암호 입력 창. 입력칸과 보기, 취소, 확인 버튼 배치를 확인한다.
5454- password-retry: 두 번째 암호 입력 요청. 틀린 암호 안내와 입력칸 배치를 확인한다.
55추가: - archive-loading: 플랫폼과 관계없이 별도 작업 창으로 재현합니다. 최초 생성에서 포커스 정보가 아직 없을 때만 창을 올리며, 다른 앱에 포커스가 있는 상태에서 다시 표시할 때는 올리지 않습니다. 명령줄이나 더블클릭으로 압축파일을 연 직후의 목록 로딩입니다. 목록을 읽는 동안에는 "이 폴더는 비어 있습니다"를 표시하지 않아야 합니다. X11에서는 처음부터 작업 창이 부모 위에 보이고 부모를 클릭해도 유지되는지 확인합니다. 다른 앱으로 전환하면 작업 창이 그 앱 뒤로 내려가야 합니다.
56추가: - archive-loading-in-parent: 플랫폼과 관계없이 부모 내부 창으로 재현합니다. 실제 앱은 Wayland에서 이 방식을 사용합니다. Wayland의 목록 로딩입니다. 네이티브 창 올리기를 지원하지 않는 환경에서는 같은 진행 화면을 부모 내부의 이동 가능한 창으로 표시합니다. 부모를 클릭해도 작업 화면이 가려지지 않고, 다른 앱이나 기본 파일 선택 창 위에 남지 않아야 합니다. 암호 입력 등 기존 모달이 열리면 작업 화면은 숨깁니다. 애니메이션은 사용하지 않습니다.
5557- extract-progress: 압축 해제 중. 62% 진행 막대와 취소 버튼을 확인한다.
5658- extract-unknown: 전체 크기를 모르는 압축 해제. 진행 중 안내와 처리량을 확인한다.
5759- extract-complete: 압축 해제 완료. 완료 문구와 결과 행동을 확인한다.
수정experiments/rust-ui-memory-app/src/archive_screen.rs+68-8
@@ -74,6 +74,7 @@ const WORK_RESULT_MAX_HEIGHT: f32 = 220.0;
7474/// 부모 창 기준 상대 위치를 기억해 두고, 부모 창이 움직이면 같은 상대 위치로 따라감.
7575struct WorkWindow {
7676 open: bool,
77추가: created: bool,
7778 initial: Option<egui::Pos2>,
7879 offset: Option<egui::Vec2>,
7980 parent: Option<egui::Pos2>,
@@ -86,6 +87,7 @@ impl Default for WorkWindow {
8687 fn default() -> Self {
8788 Self {
8889 open: false,
90추가: created: false,
8991 initial: None,
9092 offset: None,
9193 parent: None,
@@ -112,16 +114,20 @@ impl WorkWindow {
112114 let (parent, parent_focused, now) = ctx.input(|i| {
113115 (
114116 i.viewport().outer_rect,
115삭제: i.viewport().focused.unwrap_or(false),
117추가: i.viewport().focused,
116118 i.time,
117119 )
118120 });
119121 let (child, child_focused) = ctx.input(|i| {
120삭제: i.raw.viewports.get(&id).map_or((None, false), |v| {
121삭제: (v.outer_rect, v.focused.unwrap_or(false))
122추가: i.raw.viewports.get(&id).map_or((None, None), |v| {
123추가: (v.outer_rect, v.focused)
122124 })
123125 });
124삭제: if !self.open {
126추가: let initial_focus_unknown =
127추가: !self.created && parent_focused.is_none() && child_focused.is_none();
128추가: self.created = true;
129추가: let opening = !self.open;
130추가: if opening {
125131 // 처음 열 때 부모 창 가운데에 둠. 닫혔다 다시 열 때는 기억한 위치에 둠.
126132 self.open = true;
127133 self.initial = parent.map(|p| match self.offset {
@@ -165,7 +171,11 @@ impl WorkWindow {
165171 .with_maximize_button(false)
166172 .with_taskbar(false)
167173 .with_window_level(
168삭제: if !native_dialog_open && (parent_focused || child_focused) {
174추가: if !native_dialog_open
175추가: && (initial_focus_unknown
176추가: || parent_focused == Some(true)
177추가: || child_focused == Some(true))
178추가: {
169179 egui::WindowLevel::AlwaysOnTop
170180 } else {
171181 egui::WindowLevel::Normal
@@ -218,6 +228,7 @@ pub struct ArchiveApp {
218228 preview_return_focus: Option<egui::Id>,
219229 preview_initial_focus: bool,
220230 work: WorkWindow,
231추가: work_in_parent: bool,
221232 create_win: WorkWindow,
222233 /// ZIP 만들기 창에서 보고 있는 폴더 (고른 폴더 기준 상대 경로, 비어 있으면 최상위).
223234 create_folder: String,
@@ -289,6 +300,7 @@ impl ArchiveApp {
289300 preview_return_focus: None,
290301 preview_initial_focus: false,
291302 work: WorkWindow::default(),
303추가: work_in_parent: false,
292304 create_win: WorkWindow::default(),
293305 create_folder: String::new(),
294306 create_listing: None,
@@ -332,6 +344,11 @@ impl ArchiveApp {
332344 self.dialogs = dialogs;
333345 }
334346
347추가: /// 창 순서를 지정할 수 없는 환경에서는 부모 안에 작업 화면을 그림.
348추가: pub fn set_work_window_in_parent(&mut self, enabled: bool) {
349추가: self.work_in_parent = enabled;
350추가: }
351추가:
335352 /// 운영체제가 창 테두리를 그려 주지 않을 때(GNOME Wayland) 제목 표시줄을 직접 그림.
336353 pub fn set_custom_frame(&mut self, custom: bool) {
337354 self.custom_frame = custom;
@@ -1085,7 +1102,11 @@ impl ArchiveApp {
10851102 );
10861103 theme::status_text(ui, rect, &format!("선택 {selected}개"), half, Align::Max);
10871104 });
1088삭제: if ctx.embed_viewports() && self.work_visible() && !self.limit_result_visible() {
1105추가: if ctx.embed_viewports()
1106추가: && !self.work_in_parent
1107추가: && self.work_visible()
1108추가: && !self.limit_result_visible()
1109추가: {
10891110 // 별도 창을 만들 수 없을 때만 쓰는 대체 배치. 목록을 가리지 않도록 하단에 둠.
10901111 egui::Panel::bottom("archive-work")
10911112 .frame(theme::panel(theme::PANEL).corner_radius(0))
@@ -1515,7 +1536,9 @@ impl ArchiveApp {
15151536 );
15161537 }
15171538 }
1518삭제: if rows.is_empty() {
1539추가: if rows.is_empty()
1540추가: && !(self.model.busy() && matches!(self.last_request, Some(Start::List { .. })))
1541추가: {
15191542 ui.scope_builder(egui::UiBuilder::new().max_rect(clip), |ui| {
15201543 ui.centered_and_justified(|ui| {
15211544 ui.label(if self.search.is_empty() {
@@ -1918,7 +1941,7 @@ impl ArchiveApp {
19181941 self.work.open = false;
19191942 return;
19201943 }
1921삭제: if ctx.embed_viewports() {
1944추가: if ctx.embed_viewports() && !self.work_in_parent {
19221945 // 별도 창을 만들 수 없는 환경(시험 등)은 show()에서 하단에 그림.
19231946 return;
19241947 }
@@ -1941,6 +1964,43 @@ impl ArchiveApp {
19411964 } else {
19421965 "작업 결과".to_owned()
19431966 };
1967추가: if self.work_in_parent {
1968추가: // Wayland는 창 올리기를 지원하지 않으므로 부모 안에서 같은 내용을 그림.
1969추가: let mut open = true;
1970추가: let mut window = egui::Window::new(RichText::new(title).size(theme::FONT_SMALL))
1971추가: .id(egui::Id::new("archive-work-in-parent"))
1972추가: .default_pos(
1973추가: ctx.content_rect().center() - egui::vec2(WORK_WIDTH, self.work.height) / 2.0,
1974추가: )
1975추가: .default_width(WORK_WIDTH)
1976추가: .min_width(WORK_WIDTH)
1977추가: .max_width(WORK_WIDTH)
1978추가: .max_height(WORK_MAX_HEIGHT)
1979추가: .collapsible(false)
1980추가: .resizable(false)
1981추가: .fade_in(false)
1982추가: .fade_out(false)
1983추가: .title_frame(
1984추가: theme::panel(theme::STRIPE)
1985추가: .inner_margin(egui::Margin::symmetric(16, 8))
1986추가: .corner_radius(0),
1987추가: )
1988추가: .frame(
1989추가: theme::panel(theme::PANEL)
1990추가: .stroke(egui::Stroke::new(1.0, theme::BORDER))
1991추가: .corner_radius(0),
1992추가: );
1993추가: if !self.model.busy() {
1994추가: window = window.open(&mut open);
1995추가: }
1996추가: window.show(ctx, |ui| self.work_area(ui));
1997추가: if !open {
1998추가: self.dismissed = true;
1999추가: self.ui_error = None;
2000추가: self.model.input_error = None;
2001추가: }
2002추가: return;
2003추가: }
19442004 let window_title = format!("{title} — Zipelo");
19452005 let custom_frame = self.custom_frame;
19462006 let size = egui::vec2(WORK_WIDTH, self.work.height);
수정experiments/rust-ui-memory-app/src/desktop.rs+2-2
@@ -106,8 +106,7 @@ fn run() -> eframe::Result {
106106 zipelo_ui_memory_app::archive_theme::apply(&cc.egui_ctx);
107107 #[cfg(all(feature = "ui-fixture", debug_assertions))]
108108 if let Some(scenario) = scenario {
109삭제: let mut app = scenario.build();
110삭제: app.set_custom_frame(custom_frame);
109추가: let app = scenario.build_with_frame(custom_frame);
111110 return Ok(Box::new(
112111 zipelo_ui_memory_app::archive_screen::scenarios::Preview::new(
113112 app,
@@ -139,6 +138,7 @@ fn run() -> eframe::Result {
139138 fixture,
140139 );
141140 app.set_custom_frame(custom_frame);
141추가: app.set_work_window_in_parent(custom_frame);
142142 Ok(Box::new(app))
143143 })
144144 },
수정tests/rust-app-ui/scenario_tests.rs+8-0
@@ -128,7 +128,15 @@ fn every_listed_scenario_draws_and_keeps_its_expected_screen() {
128128 assert!(app.model.list_id.as_ref().unwrap().is_split());
129129 assert!(!app.model.can_preview());
130130 }
131추가: if matches!(scenario.name, "archive-loading" | "archive-loading-in-parent") {
132추가: assert!(app.model.busy());
133추가: assert!(app.model.list_id.is_none());
134추가: assert!(app.model.entries.is_empty());
135추가: assert!(!labels.contains("이 폴더는 비어 있습니다"), "{labels}");
136추가: }
137추가:
131138 let expected = match scenario.name {
139추가: "archive-loading" | "archive-loading-in-parent" => "압축파일을 읽는 중",
132140 "split-archive" => "읽어주세요.txt",
133141 "split-first-volume" => "첫 조각 여행.7z.001을 선택해 다시 여세요.",
134142 "split-missing-volume" => "여행.7z.003 조각이 없습니다",
수정tests/rust-app-ui/scenarios.rs+27-0
@@ -21,6 +21,8 @@ macro_rules! catalog {
2121}
2222
2323catalog! {
24추가: "archive-loading" => "목록 로딩 중 최초 작업 창의 표시 순서",
25추가: "archive-loading-in-parent" => "Wayland의 부모 내부 목록 로딩 창",
2426 "recovery-progress" => "ZIP 복구 분석과 저장 확인 전 대기",
2527 "recovery-complete" => "전체 항목을 검증한 복구본 저장 완료",
2628 "recovery-partial" => "유실 항목이 있는 복구본과 경고",
@@ -256,6 +258,13 @@ impl Scenario {
256258 });
257259 }
258260
261추가: /// 플랫폼 테두리만 적용하고 시나리오가 정한 작업 창 방식은 유지함.
262추가: pub fn build_with_frame(self, custom_frame: bool) -> ArchiveApp {
263추가: let mut app = self.build();
264추가: app.set_custom_frame(custom_frame);
265추가: app
266추가: }
267추가:
259268 /// 실제 파일과 작업자를 사용하지 않고 기존 화면 상태를 준비함.
260269 pub fn build(self) -> ArchiveApp {
261270 let factory = FakeFactory::manual();
@@ -275,6 +284,24 @@ impl Scenario {
275284 "tar-xz" => "여행 자료.TaR.Xz",
276285 _ => "여행 자료.zip",
277286 });
287추가: if matches!(self.name, "archive-loading" | "archive-loading-in-parent") {
288추가: app.set_work_window_in_parent(self.name == "archive-loading-in-parent");
289추가: app.open_path(archive);
290추가: {
291추가: let mut state = state.borrow_mut();
292추가: state.frame(Event::Accepted { encryption: false });
293추가: state.frame(Event::Progress {
294추가: stage: Stage::Read,
295추가: processed: 38 << 20,
296추가: total: Some(61 << 20),
297추가: completed_entries: 0,
298추가: });
299추가: }
300추가: for _ in 0..64 {
301추가: app.model.poll();
302추가: }
303추가: return app;
304추가: }
278305 app.model.archive = Some(archive.clone());
279306 app.model.entries = entries(self.name == "many-items");
280307 app.model.list_id = Some(ListId {
수정tests/rust-app-ui/work_window.rs+244-0
@@ -694,3 +694,247 @@ fn partial_limit_result_is_visible_in_main_modal_without_native_child() {
694694 assert!(!shown.iter().any(|(text, _)| text == "한도를 늘려 다시 시도"));
695695 assert_eq!(WORK_CHILD.with(|child| child.borrow().rendered), 0);
696696}
697추가:
698추가: #[test]
699추가: fn startup_work_window_is_above_parent_before_focus_is_reported() {
700추가: let factory = FakeFactory::manual();
701추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), Some("/sample.zip".into()), false);
702추가: let ctx = egui::Context::default();
703추가: ctx.set_embed_viewports(false);
704추가: install_work_child_renderer();
705추가: let mut raw = egui::RawInput {
706추가: screen_rect: Some(egui::Rect::from_min_size(
707추가: egui::Pos2::ZERO,
708추가: egui::vec2(1060.0, 720.0),
709추가: )),
710추가: ..Default::default()
711추가: };
712추가: raw.viewports
713추가: .insert(egui::ViewportId::ROOT, egui::ViewportInfo::default());
714추가: let _ = ctx.run_ui(raw, |ui| app.show(ui));
715추가: WORK_CHILD.with(|child| {
716추가: let child = child.borrow();
717추가: let (_, builder) = child
718추가: .builders
719추가: .iter()
720추가: .find(|(id, _)| *id == egui::ViewportId::from_hash_of("archive-work"))
721추가: .expect("작업 창이 처음부터 보여야 함");
722추가: assert_eq!(builder.window_level, Some(egui::WindowLevel::AlwaysOnTop));
723추가: });
724추가: }
725추가:
726추가: #[test]
727추가: fn native_work_window_follows_app_focus_without_covering_other_apps() {
728추가: let factory = FakeFactory::manual();
729추가: let mut app = ArchiveApp::new(Box::new(factory), Some("/sample.zip".into()), false);
730추가: let ctx = egui::Context::default();
731추가: ctx.set_embed_viewports(false);
732추가: install_work_child_renderer();
733추가: let id = egui::ViewportId::from_hash_of("archive-work");
734추가: for (parent, child, level) in [
735추가: (None, None, egui::WindowLevel::AlwaysOnTop),
736추가: (Some(true), Some(false), egui::WindowLevel::AlwaysOnTop),
737추가: (Some(false), Some(true), egui::WindowLevel::AlwaysOnTop),
738추가: (Some(false), Some(false), egui::WindowLevel::Normal),
739추가: (Some(true), Some(false), egui::WindowLevel::AlwaysOnTop),
740추가: ] {
741추가: let mut raw = egui::RawInput {
742추가: screen_rect: Some(egui::Rect::from_min_size(
743추가: egui::Pos2::ZERO,
744추가: egui::vec2(1060.0, 720.0),
745추가: )),
746추가: ..Default::default()
747추가: };
748추가: for (id, focus) in [(egui::ViewportId::ROOT, parent), (id, child)] {
749추가: raw.viewports.insert(
750추가: id,
751추가: egui::ViewportInfo {
752추가: focused: focus,
753추가: ..Default::default()
754추가: },
755추가: );
756추가: }
757추가: let _ = ctx.run_ui(raw, |ui| app.show(ui));
758추가: WORK_CHILD.with(|child| {
759추가: let child = child.borrow();
760추가: let (_, builder) = child
761추가: .builders
762추가: .iter()
763추가: .rev()
764추가: .find(|(window, _)| *window == id)
765추가: .unwrap();
766추가: assert_eq!(builder.window_level, Some(level));
767추가: });
768추가: }
769추가: }
770추가:
771추가: #[test]
772추가: fn hosted_work_window_stays_in_parent_and_hides_for_native_picker() {
773추가: let factory = FakeFactory::manual();
774추가: let mut app = ArchiveApp::new(Box::new(factory.clone()), Some("/sample.zip".into()), false);
775추가: app.set_work_window_in_parent(true);
776추가: let ctx = egui::Context::default();
777추가: ctx.set_embed_viewports(false);
778추가: install_work_child_renderer();
779추가: for _ in 0..3 {
780추가: policy_render(&ctx, &mut app, vec![]);
781추가: }
782추가: let shown = policy_render(&ctx, &mut app, vec![]);
783추가: assert!(
784추가: shown.iter().any(|(text, _)| text == "압축파일을 읽는 중"),
785추가: "{shown:?}"
786추가: );
787추가: assert!(shown.iter().any(|(text, _)| text == "취소"));
788추가: assert!(WORK_CHILD.with(|child| child.borrow().builders.is_empty()));
789추가: {
790추가: let mut worker = factory.state.borrow_mut();
791추가: worker.finish(Outcome::Failed, Publication::None);
792추가: for event in &mut worker.queue {
793추가: if let HostEvent::Frame {
794추가: event: Event::Terminal(terminal),
795추가: ..
796추가: } = event
797추가: {
798추가: terminal.error = Some(ErrorCode::Io);
799추가: }
800추가: }
801추가: }
802추가: for _ in 0..3 {
803추가: policy_render(&ctx, &mut app, vec![]);
804추가: }
805추가: let dialogs = HeldDialogs::default();
806추가: app.set_dialogs(Box::new(dialogs.clone()));
807추가: policy_click(&ctx, &mut app, "열기");
808추가: assert_eq!(dialogs.0.borrow().len(), 1);
809추가: let shown = policy_render(&ctx, &mut app, vec![]);
810추가: assert!(
811추가: !shown
812추가: .iter()
813추가: .any(|(text, _)| text == "압축파일을 열지 못했습니다")
814추가: );
815추가: dialogs.0.borrow()[0].send(Ok(None)).unwrap();
816추가: for _ in 0..3 {
817추가: policy_render(&ctx, &mut app, vec![]);
818추가: }
819추가: let shown = policy_render(&ctx, &mut app, vec![]);
820추가: assert!(
821추가: shown
822추가: .iter()
823추가: .any(|(text, _)| text == "압축파일을 열지 못했습니다")
824추가: );
825추가: }
826추가:
827추가:
828추가: #[test]
829추가: fn native_work_window_reopens_without_raising_over_another_app() {
830추가: let mut app = zipelo_ui_memory_app::archive_screen::scenarios::parse("extract-complete")
831추가: .unwrap()
832추가: .build();
833추가: let ctx = egui::Context::default();
834추가: ctx.set_embed_viewports(false);
835추가: install_work_child_renderer();
836추가: for _ in 0..3 {
837추가: policy_render(&ctx, &mut app, vec![]);
838추가: }
839추가: let dialogs = HeldDialogs::default();
840추가: app.set_dialogs(Box::new(dialogs.clone()));
841추가: policy_click(&ctx, &mut app, "열기");
842추가: assert_eq!(dialogs.0.borrow().len(), 1);
843추가: let rendered = WORK_CHILD.with(|child| child.borrow().rendered);
844추가: policy_render(&ctx, &mut app, vec![]);
845추가: assert_eq!(WORK_CHILD.with(|child| child.borrow().rendered), rendered);
846추가: dialogs.0.borrow()[0].send(Ok(None)).unwrap();
847추가: for focus in [Some(false), None] {
848추가: let mut raw = egui::RawInput {
849추가: screen_rect: Some(egui::Rect::from_min_size(
850추가: egui::Pos2::ZERO,
851추가: egui::vec2(1060.0, 720.0),
852추가: )),
853추가: ..Default::default()
854추가: };
855추가: for id in [
856추가: egui::ViewportId::ROOT,
857추가: egui::ViewportId::from_hash_of("archive-work"),
858추가: ] {
859추가: raw.viewports.insert(
860추가: id,
861추가: egui::ViewportInfo {
862추가: focused: focus,
863추가: ..Default::default()
864추가: },
865추가: );
866추가: }
867추가: let _ = ctx.run_ui(raw, |ui| app.show(ui));
868추가: WORK_CHILD.with(|child| {
869추가: let child = child.borrow();
870추가: assert!(child.rendered > rendered);
871추가: assert_eq!(
872추가: child.builders.last().unwrap().1.window_level,
873추가: Some(egui::WindowLevel::Normal)
874추가: );
875추가: });
876추가: }
877추가: }
878추가:
879추가: #[test]
880추가: fn initial_work_window_respects_explicitly_absent_focus() {
881추가: let mut app = ArchiveApp::new(
882추가: Box::new(FakeFactory::manual()),
883추가: Some("/sample.zip".into()),
884추가: false,
885추가: );
886추가: let ctx = egui::Context::default();
887추가: ctx.set_embed_viewports(false);
888추가: install_work_child_renderer();
889추가: let mut raw = egui::RawInput {
890추가: screen_rect: Some(egui::Rect::from_min_size(
891추가: egui::Pos2::ZERO,
892추가: egui::vec2(1060.0, 720.0),
893추가: )),
894추가: ..Default::default()
895추가: };
896추가: raw.viewports.insert(
897추가: egui::ViewportId::ROOT,
898추가: egui::ViewportInfo {
899추가: focused: Some(false),
900추가: ..Default::default()
901추가: },
902추가: );
903추가: let _ = ctx.run_ui(raw, |ui| app.show(ui));
904추가: WORK_CHILD.with(|child| {
905추가: assert_eq!(
906추가: child.borrow().builders.last().unwrap().1.window_level,
907추가: Some(egui::WindowLevel::Normal)
908추가: );
909추가: });
910추가: }
911추가:
912추가: #[test]
913추가: fn scenario_window_hosting_survives_platform_frame_configuration() {
914추가: for custom_frame in [false, true] {
915추가: for (name, hosted) in [
916추가: ("archive-loading", false),
917추가: ("archive-loading-in-parent", true),
918추가: ] {
919추가: let scenario = zipelo_ui_memory_app::archive_screen::scenarios::parse(name).unwrap();
920추가: let mut app = scenario.build_with_frame(custom_frame);
921추가: let ctx = egui::Context::default();
922추가: ctx.set_embed_viewports(false);
923추가: install_work_child_renderer();
924추가: let mut shown = Vec::new();
925추가: for _ in 0..3 {
926추가: shown = policy_render(&ctx, &mut app, vec![]);
927추가: }
928추가: assert_eq!(
929추가: WORK_CHILD.with(|child| child.borrow().builders.is_empty()),
930추가: hosted,
931추가: "{name}, custom_frame={custom_frame}"
932추가: );
933추가: assert_eq!(
934추가: shown.iter().any(|(text, _)| text == "압축파일을 읽는 중"),
935추가: hosted,
936추가: "{name}, custom_frame={custom_frame}"
937추가: );
938추가: }
939추가: }
940추가: }