team-ljyzipelo

공개

버튼 쌍의 크기를 맞추고 ZIP 만들기 버튼을 오른쪽 아래에 고정함

action_pair로 함께 놓이는 두 버튼(취소/압축하기, 확인/다시 시도, 취소/확인)을
긴 쪽 글자에 맞춘 같은 크기(최소 112x40)로 그림. ZIP 만들기 창의 취소와
압축하기는 창 아래 패널에 두어 위 내용(암호 칸 등)이 바뀌어도 오른쪽 아래
16px 여백 자리에 고정됨.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
작성자
LeeJunyoung
작성 시각
커밋
9cb7e026411a6e69ab9c71e07330faaa09f7829f
부모
3d56b03
이 시점의 파일 보기

변경된 파일 2개

+61-14
수정experiments/rust-ui-memory-app/src/archive_screen.rs+32-3
@@ -1966,6 +1966,8 @@ impl ArchiveApp {
19661966 });
19671967 });
19681968 close |= self.create_area(ui);
1969추가: ui.add_space(theme::SPACE);
1970추가: close |= self.create_actions(ui);
19691971 });
19701972 if close || modal.should_close() {
19711973 self.close_create();
@@ -1988,6 +1990,7 @@ impl ArchiveApp {
19881990 if class == egui::ViewportClass::EmbeddedWindow {
19891991 ui.set_width(CREATE_WIDTH);
19901992 close |= self.create_area(ui);
1993추가: close |= self.create_actions(ui);
19911994 return None;
19921995 }
19931996 let mut chrome = 0.0;
@@ -2004,6 +2007,24 @@ impl ArchiveApp {
20042007 window_frame::edges(ui.ctx(), false);
20052008 chrome = window_frame::TITLE_HEIGHT;
20062009 }
2010추가: // 버튼은 창 오른쪽 아래에 여백을 두고 고정함. 위 내용이 바뀌어도 자리가 같음.
2011추가: let actions = egui::Panel::bottom(egui::Id::unique("create-actions"))
2012추가: .resizable(false)
2013추가: .show_separator_line(false)
2014추가: .frame(
2015추가: egui::Frame::new()
2016추가: .fill(theme::PANEL)
2017추가: .inner_margin(egui::Margin {
2018추가: left: theme::PAD,
2019추가: right: theme::PAD,
2020추가: top: 0,
2021추가: bottom: theme::PAD,
2022추가: }),
2023추가: )
2024추가: .show(ui, |ui| close |= self.create_actions(ui))
2025추가: .response
2026추가: .rect
2027추가: .height();
20072028 let margin = theme::PAD as f32;
20082029 egui::CentralPanel::default()
20092030 .frame(theme::panel(theme::PANEL).corner_radius(0))
@@ -2012,7 +2033,7 @@ impl ArchiveApp {
20122033 .vertical(|ui| close |= self.create_area(ui))
20132034 .response
20142035 .rect;
2015삭제: Some(content.height() + 2.0 * margin + chrome)
2036추가: Some(content.height() + 2.0 * margin + chrome + actions)
20162037 })
20172038 .inner
20182039 });
@@ -2219,10 +2240,18 @@ impl ArchiveApp {
22192240 wipe(&mut self.zip_password_confirm);
22202241 self.zip_password_visible = false;
22212242 }
2222삭제: ui.add_space(theme::SPACE);
2243추가: false
2244추가: }
22232245
2246추가: /// 취소와 압축하기 버튼. 취소를 눌렀으면 true.
2247추가: fn create_actions(&mut self, ui: &mut egui::Ui) -> bool {
22242248 let ready = !self.sources.is_empty() && self.zip_password_ready();
2225삭제: let (cancel, compress) = theme::action_pair(ui, "취소", Some(("압축하기", ready)));
2249추가: let enabled = self.picker.is_none();
2250추가: let (cancel, compress) = ui
2251추가: .add_enabled_ui(enabled, |ui| {
2252추가: theme::action_pair(ui, "취소", Some(("압축하기", ready)))
2253추가: })
2254추가: .inner;
22262255 if compress {
22272256 self.open_picker(Purpose::SaveZip);
22282257 }
수정experiments/rust-ui-memory-app/src/archive_theme.rs+29-11
@@ -126,6 +126,21 @@ pub fn focus(response: &egui::Response) {
126126}
127127
128128pub fn action(ui: &mut egui::Ui, text: &str, primary: bool, enabled: bool) -> egui::Response {
129추가: let size = egui::vec2(
130추가: if primary { 112.0 } else { 0.0 },
131추가: if primary { BUTTON } else { 36.0 },
132추가: );
133추가: action_sized(ui, text, primary, enabled, size)
134추가: }
135추가:
136추가: /// 정한 최소 크기로 버튼을 그림. 함께 놓이는 버튼끼리 크기를 맞출 때 씀.
137추가: pub fn action_sized(
138추가: ui: &mut egui::Ui,
139추가: text: &str,
140추가: primary: bool,
141추가: enabled: bool,
142추가: size: egui::Vec2,
143추가: ) -> egui::Response {
129144 let response = ui
130145 .scope(|ui| {
131146 if primary {
@@ -146,10 +161,7 @@ pub fn action(ui: &mut egui::Ui, text: &str, primary: bool, enabled: bool) -> eg
146161 } else {
147162 TEXT
148163 }))
149삭제: .min_size(egui::vec2(
150삭제: if primary { 112.0 } else { 0.0 },
151삭제: if primary { BUTTON } else { 36.0 },
152삭제: ))
164추가: .min_size(size)
153165 .stroke(Stroke::new(1.0, if primary { BLUE } else { BORDER })),
154166 )
155167 })
@@ -385,17 +397,23 @@ pub fn action_pair(
385397 .size()
386398 .x
387399 };
388삭제: let width = text_width(secondary)
389삭제: + 32.0
390삭제: + primary.map_or(0.0, |(label, _)| {
391삭제: SPACE + (text_width(label) + 32.0).max(112.0)
392삭제: });
400추가: // 두 버튼은 긴 쪽 글자에 맞춘 같은 크기로 그림.
401추가: let button = egui::vec2(
402추가: primary
403추가: .map_or(0.0, |(label, _)| text_width(label))
404추가: .max(text_width(secondary))
405추가: + 32.0,
406추가: BUTTON,
407추가: )
408추가: .max(egui::vec2(112.0, BUTTON));
409추가: let count = if primary.is_some() { 2.0 } else { 1.0 };
410추가: let width = button.x * count + SPACE * (count - 1.0);
393411 ui.horizontal(|ui| {
394412 ui.with_layout(egui::Layout::left_to_right(egui::Align::Center), |ui| {
395413 ui.add_space((ui.available_width() - width).max(0.0));
396삭제: let secondary = action(ui, secondary, false, true).clicked();
414추가: let secondary = action_sized(ui, secondary, false, true, button).clicked();
397415 let primary = primary.is_some_and(|(label, enabled)| {
398삭제: action(ui, label, true, enabled)
416추가: action_sized(ui, label, true, enabled, button)
399417 .on_disabled_hover_text(match label {
400418 "만들기" => "묶을 파일이나 폴더를 추가하세요",
401419 "다른 폴더에 풀기" => "기존 풀 위치 폴더를 먼저 확인하세요",