team-ljyzipelo

공개

자식 창을 옮긴 뒤 버튼이 반응하지 않던 문제와 선택 행 오른쪽 여백을 고침

- 자식 창(진행·결과, ZIP 만들기)을 제목 표시줄로 끌어 옮기면 GNOME이 버튼
  놓기를 보내지 않아 egui가 버튼이 눌린 채로 알고 있었음. 그래서 한 번 클릭할
  때까지 닫기·취소 등 버튼에 마우스를 올려도 배경과 커서가 바뀌지 않았음.
  메인 창은 입력 훅으로 놓기를 넣어 주었지만 자식 창에는 훅이 없음. 창 이동을
  넘길 때 그 창의 마우스 상태를 비워 메인·자식 창 모두 바로 반응하게 함.
- 파일 목록 선택·마우스 올림 배경과 키보드 선택 테두리가 목록 너비를 꽉 채움.
  누르는 영역의 오른쪽 24px은 긴 목록에서 끌어서 선택을 시작하는 자리라 그대로 둠.

시험: 별도 viewport에서 자식 창 제목 표시줄을 끈 뒤(놓기 없음) 닫기 버튼에
마우스를 올리면 빨간 배경과 손 모양 커서가 나오는지, 선택 배경이 오른쪽 끝까지
닿는지 확인함.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
작성자
LeeJunyoung
작성 시각
커밋
40f55a6758b6d23915d67884d9524b9cf264d72f
부모
33b51f6
이 시점의 파일 보기

변경된 파일 4개

+120-3
수정experiments/rust-ui-memory-app/src/archive_screen.rs+12-3
@@ -1167,7 +1167,10 @@ impl ArchiveApp {
11671167 .show_viewport(ui, |ui, viewport| {
11681168 let origin = ui.max_rect().min;
11691169 let clip = ui.clip_rect();
1170삭제: let width = (ui.available_width() - 24.0).max(0.0);
1170추가: // 행을 누르는 영역은 오른쪽 24px을 비워 둠. 목록이 길어도 그 빈 곳에서
1171추가: // 끌어서 선택을 시작할 수 있음. 행 배경(선택, 마우스 올림)은 너비를 꽉 채움.
1172추가: let full_width = ui.available_width();
1173추가: let width = (full_width - 24.0).max(0.0);
11711174 ui.set_min_height((rows.len() as f32 * LIST_ROW).max(viewport.height()));
11721175 let point = ui.input(|i| i.pointer.interact_pos());
11731176 if active && let Some(point) = point {
@@ -1274,7 +1277,12 @@ impl ArchiveApp {
12741277 )
12751278 });
12761279 }
1277삭제: theme::row_background(ui, rect, selected, response.hovered());
1280추가: theme::row_background(
1281추가: ui,
1282추가: egui::Rect::from_min_size(rect.min, egui::vec2(full_width, LIST_ROW)),
1283추가: selected,
1284추가: response.hovered(),
1285추가: );
12781286 if response.clicked() {
12791287 background.request_focus();
12801288 let modifiers = ui.input(|i| i.modifiers);
@@ -1314,7 +1322,8 @@ impl ArchiveApp {
13141322 && (response.has_focus() || background.has_focus())
13151323 {
13161324 ui.painter().rect_stroke(
1317삭제: rect.shrink(1.0),
1325추가: egui::Rect::from_min_size(rect.min, egui::vec2(full_width, LIST_ROW))
1326추가: .shrink(1.0),
13181327 0,
13191328 egui::Stroke::new(1.0, theme::BLUE),
13201329 egui::StrokeKind::Inside,
수정experiments/rust-ui-memory-app/src/window_frame.rs+4-0
@@ -140,6 +140,10 @@ fn start_move(ctx: &egui::Context, id: &str, bar: Rect, buttons_left: f32) -> bo
140140 origin = None;
141141 // 운영체제가 이동을 맡으므로 egui 쪽 끌기는 끝낸 것으로 처리함.
142142 ctx.stop_dragging();
143추가: // 이동이 끝나도 버튼 놓기가 오지 않아 egui가 버튼이 눌린 채로 알고 있으면
144추가: // 다른 버튼에 마우스를 올려도 반응하지 않음. 이 창의 마우스 상태를 비움.
145추가: // 메인 창뿐 아니라 입력 훅을 쓸 수 없는 자식 창에도 적용됨.
146추가: ctx.input_mut(|input| input.pointer = Default::default());
143147 }
144148 ctx.data_mut(|d| d.insert_temp(key, origin));
145149 start
수정tests/rust-app-ui/create_window.rs+14-0
@@ -281,6 +281,20 @@ fn main_list_hover_uses_lighter_blue_and_selected_row_gets_stronger() {
281281 frame_output(&ctx, &mut app, vec![egui::Event::PointerGone]);
282282 let output = frame_output(&ctx, &mut app, vec![]);
283283 assert_eq!(row_fill_at(&output, y), Some(ROW_SELECTED));
284추가: // 선택 배경은 오른쪽 여백 없이 목록 너비(창 1060px)를 꽉 채움.
285추가: let right = output
286추가: .shapes
287추가: .iter()
288추가: .filter_map(|shape| match &shape.shape {
289추가: egui::epaint::Shape::Rect(rect)
290추가: if rect.fill == ROW_SELECTED && rect.rect.top() <= y && y <= rect.rect.bottom() =>
291추가: {
292추가: Some(rect.rect.right())
293추가: }
294추가: _ => None,
295추가: })
296추가: .fold(0.0f32, f32::max);
297추가: assert!(right >= 1059.0, "선택 배경 오른쪽 끝: {right}");
284298}
285299
286300fn cursor_over(ctx: &egui::Context, app: &mut ArchiveApp, point: egui::Pos2) -> egui::CursorIcon {
수정tests/rust-app-ui/work_window.rs+90-0
@@ -5,6 +5,9 @@ struct WorkChild {
55 events: Vec<egui::Event>,
66 labels: Vec<(String, egui::Pos2)>,
77 rendered: usize,
8추가: cursor: Option<egui::CursorIcon>,
9추가: rects: Vec<(egui::Rect, egui::Color32)>,
10추가: commands: Vec<egui::ViewportCommand>,
811}
912
1013std::thread_local! {
@@ -43,6 +46,21 @@ fn install_work_child_renderer() {
4346 let mut child = child.borrow_mut();
4447 child.labels = labels(&output.shapes);
4548 child.rendered += 1;
49추가: child.cursor = Some(output.platform_output.cursor_icon);
50추가: child.rects.clear();
51추가: fn walk(shape: &egui::epaint::Shape, out: &mut Vec<(egui::Rect, egui::Color32)>) {
52추가: match shape {
53추가: egui::epaint::Shape::Rect(rect) => out.push((rect.rect, rect.fill)),
54추가: egui::epaint::Shape::Vec(shapes) => shapes.iter().for_each(|s| walk(s, out)),
55추가: _ => {}
56추가: }
57추가: }
58추가: for shape in &output.shapes {
59추가: walk(&shape.shape, &mut child.rects);
60추가: }
61추가: for viewport in output.viewport_output.values() {
62추가: child.commands.extend(viewport.commands.iter().cloned());
63추가: }
4664 });
4765 });
4866}
@@ -219,3 +237,75 @@ fn password_prompt_is_not_covered_by_separate_work_window() {
219237 "암호 입력 뒤 진행 창이 다시 나타나야 함"
220238 );
221239}
240추가:
241추가: #[test]
242추가: fn child_window_buttons_hover_again_after_title_bar_drag() {
243추가: let scratch = Folder::new();
244추가: let factory = FakeFactory::default();
245추가: let mut app = loaded(&scratch, &factory);
246추가: factory.state.borrow_mut().manual = true;
247추가: assert!(app.begin_extract());
248추가: {
249추가: let mut worker = factory.state.borrow_mut();
250추가: worker.frame(Event::Accepted { encryption: false });
251추가: worker.finish(Outcome::Failed, Publication::None);
252추가: }
253추가: app.set_custom_frame(true);
254추가: let ctx = egui::Context::default();
255추가: ctx.set_embed_viewports(false);
256추가: install_work_child_renderer();
257추가: for _ in 0..10 {
258추가: policy_render(&ctx, &mut app, vec![]);
259추가: }
260추가: let mut commands = Vec::new();
261추가: fn child_frame(
262추가: ctx: &egui::Context,
263추가: app: &mut ArchiveApp,
264추가: events: Vec<egui::Event>,
265추가: commands: &mut Vec<egui::ViewportCommand>,
266추가: ) {
267추가: WORK_CHILD.with(|child| child.borrow_mut().events = events);
268추가: // 자식 창 명령은 부모 출력에 실려 올 수도 있어 둘 다 모음.
269추가: let output = frame_output(ctx, app, vec![]);
270추가: for viewport in output.viewport_output.values() {
271추가: commands.extend(viewport.commands.iter().cloned());
272추가: }
273추가: }
274추가: // 자식 창 제목 표시줄을 누른 채 끌어 창 이동을 운영체제에 넘김.
275추가: let start = egui::pos2(120.0, 19.0);
276추가: child_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(start)], &mut commands);
277추가: child_frame(&ctx, &mut app, vec![egui::Event::PointerButton {
278추가: pos: start,
279추가: button: egui::PointerButton::Primary,
280추가: pressed: true,
281추가: modifiers: egui::Modifiers::NONE,
282추가: }], &mut commands);
283추가: for step in 1..=3 {
284추가: child_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(start + egui::vec2(6.0 * step as f32, 0.0))], &mut commands);
285추가: }
286추가: let started = commands.contains(&egui::ViewportCommand::StartDrag)
287추가: || WORK_CHILD.with(|child| {
288추가: child
289추가: .borrow()
290추가: .commands
291추가: .contains(&egui::ViewportCommand::StartDrag)
292추가: });
293추가: assert!(started, "자식 창 이동이 시작돼야 함");
294추가: // GNOME은 이동이 끝나도 버튼 놓기를 보내지 않음. 그대로 닫기 버튼에 마우스를 올림.
295추가: let close = egui::pos2(480.0 - 6.0 - 17.0, 19.0);
296추가: for _ in 0..3 {
297추가: child_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(close)], &mut commands);
298추가: }
299추가: let (cursor, hovered_red) = WORK_CHILD.with(|child| {
300추가: let child = child.borrow();
301추가: (
302추가: child.cursor,
303추가: child
304추가: .rects
305추가: .iter()
306추가: .any(|(rect, fill)| rect.contains(close) && *fill == egui::Color32::from_rgb(232, 17, 35)),
307추가: )
308추가: });
309추가: assert!(hovered_red, "닫기 버튼에 마우스를 올린 배경이 없음");
310추가: assert_eq!(cursor, Some(egui::CursorIcon::PointingHand));
311추가: }