파일 목록 행에 선택과 마우스 올림 배경을 반투명 파란색으로 그림
선택한 행은 반투명 파란색(BLUE 12%), 마우스를 올린 행은 그보다 옅은 파란색(BLUE 6%)으로 그림. 선택한 행은 마우스를 올려도 선택 색을 유지함. 메인 목록과 ZIP 만들기 목록이 같은 row_background를 씀. ZIP 만들기 목록은 한 번 누르면 그 항목을 선택하고, 보고 있는 폴더가 바뀌면 선택을 지움. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 작성자
- LeeJunyoung
- 작성 시각
- 커밋
331925472b7a561d1338d99329fcddfbc29a7319- 부모
- 9cb7e02
변경된 파일 3개
+118-3| @@ -207,6 +207,8 @@ pub struct ArchiveApp { | ||
| 207 | 207 | create_listing: Option<(PathBuf, Option<std::rc::Rc<Vec<SourceRow>>>)>, |
| 208 | 208 | /// 마지막으로 누른 폴더 행 (이름, 프레임 번호, 시각). 두 번 누름을 직접 판단할 때 씀. |
| 209 | 209 | create_last_click: Option<(String, u64, f64)>, |
| 210 | 추가: /// ZIP 만들기 목록에서 한 번 눌러 선택한 항목 이름. 보고 있는 폴더가 바뀌면 지움. | |
| 211 | 추가: create_selected: Option<String>, | |
| 210 | 212 | zip_password: String, |
| 211 | 213 | zip_password_confirm: String, |
| 212 | 214 | zip_password_visible: bool, |
| @@ -258,6 +260,7 @@ impl ArchiveApp { | ||
| 258 | 260 | create_folder: String::new(), |
| 259 | 261 | create_listing: None, |
| 260 | 262 | create_last_click: None, |
| 263 | 추가: create_selected: None, | |
| 261 | 264 | zip_password: String::new(), |
| 262 | 265 | zip_password_confirm: String::new(), |
| 263 | 266 | zip_password_visible: false, |
| @@ -466,6 +469,7 @@ impl ArchiveApp { | ||
| 466 | 469 | } |
| 467 | 470 | self.create_folder.clear(); |
| 468 | 471 | self.create_listing = None; |
| 472 | 추가: self.create_selected = None; | |
| 469 | 473 | self.create = true; |
| 470 | 474 | } |
| 471 | 475 | |
| @@ -1269,9 +1273,7 @@ impl ArchiveApp { | ||
| 1269 | 1273 | ) |
| 1270 | 1274 | }); |
| 1271 | 1275 | } |
| 1272 | 삭제: if selected { | |
| 1273 | 삭제: ui.painter().rect_filled(rect, 0, theme::SELECTED); | |
| 1274 | 삭제: } | |
| 1276 | 추가: theme::row_background(ui, rect, selected, response.hovered()); | |
| 1275 | 1277 | if response.clicked() { |
| 1276 | 1278 | background.request_focus(); |
| 1277 | 1279 | let modifiers = ui.input(|i| i.modifiers); |
| @@ -2077,6 +2079,7 @@ impl ArchiveApp { | ||
| 2077 | 2079 | .rsplit_once('/') |
| 2078 | 2080 | .map_or("", |(parent, _)| parent) |
| 2079 | 2081 | .to_owned(); |
| 2082 | 추가: self.create_selected = None; | |
| 2080 | 2083 | } |
| 2081 | 2084 | ui.add_space(6.0); |
| 2082 | 2085 | let path = match &root { |
| @@ -2135,6 +2138,15 @@ impl ArchiveApp { | ||
| 2135 | 2138 | &row.name, |
| 2136 | 2139 | ) |
| 2137 | 2140 | }); |
| 2141 | 추가: if response.clicked() { | |
| 2142 | 추가: self.create_selected = Some(row.name.clone()); | |
| 2143 | 추가: } | |
| 2144 | 추가: theme::row_background( | |
| 2145 | 추가: ui, | |
| 2146 | 추가: rect, | |
| 2147 | 추가: self.create_selected.as_deref() == Some(row.name.as_str()), | |
| 2148 | 추가: response.hovered(), | |
| 2149 | 추가: ); | |
| 2138 | 2150 | if row.directory && root.is_some() && response.clicked() { |
| 2139 | 2151 | // egui가 한 프레임을 다시 그리면 두 번 누름 정보가 사라질 수 있어 |
| 2140 | 2152 | // 같은 폴더를 다른 프레임에서 0.4초 안에 다시 누르면 두 번 누름으로 봄. |
| @@ -2175,6 +2187,7 @@ impl ArchiveApp { | ||
| 2175 | 2187 | } else { |
| 2176 | 2188 | format!("{}/{name}", self.create_folder) |
| 2177 | 2189 | }; |
| 2190 | 추가: self.create_selected = None; | |
| 2178 | 2191 | } |
| 2179 | 2192 | ui.add_space(theme::SPACE); |
| 2180 | 2193 |
| @@ -10,6 +10,10 @@ 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); | |
| 13 | 17 | pub const DROP: Color32 = Color32::from_rgb(238, 244, 255); |
| 14 | 18 | pub const DASH: Color32 = Color32::from_rgb(170, 180, 192); |
| 15 | 19 | pub const SUCCESS: Color32 = Color32::from_rgb(21, 128, 61); |
| @@ -172,6 +176,19 @@ pub fn action_sized( | ||
| 172 | 176 | |
| 173 | 177 | pub const STATUS_HEIGHT: f32 = 34.0; |
| 174 | 178 | |
| 179 | 추가: /// 파일 목록 행 배경. 선택한 행은 마우스를 올려도 선택 색을 유지하고, | |
| 180 | 추가: /// 선택하지 않은 행에 마우스를 올리면 더 옅은 파란색을 칠함. | |
| 181 | 추가: pub fn row_background(ui: &egui::Ui, rect: egui::Rect, selected: bool, hovered: bool) { | |
| 182 | 추가: let fill = if selected { | |
| 183 | 추가: ROW_SELECTED | |
| 184 | 추가: } else if hovered { | |
| 185 | 추가: ROW_HOVER | |
| 186 | 추가: } else { | |
| 187 | 추가: return; | |
| 188 | 추가: }; | |
| 189 | 추가: ui.painter().rect_filled(rect, 0, fill); | |
| 190 | 추가: } | |
| 191 | 추가: | |
| 175 | 192 | /// 경로 줄 높이를 꽉 채우는 입력란을 그림. 모서리는 각지게 하고, |
| 176 | 193 | /// 위 테두리는 상단 메뉴의 구분선이, 아래 테두리는 경로 줄의 아래 선이 대신해 |
| 177 | 194 | /// 선이 겹쳐 보이지 않게 함. 초점이 있으면 파란 테두리. |
| @@ -190,3 +190,88 @@ fn retry_of_encrypted_creation_reopens_create_window_for_password() { | ||
| 190 | 190 | assert!(!shown.iter().any(|(text, _)| text == "ZIP 암호 설정")); |
| 191 | 191 | assert_eq!(factory.state.borrow().starts.len(), starts); |
| 192 | 192 | } |
| 193 | 추가: | |
| 194 | 추가: /// 주어진 세로 위치를 덮는 목록 행 배경색(선택/마우스 올림 색 중)을 찾음. | |
| 195 | 추가: fn row_fill_at(output: &egui::FullOutput, y: f32) -> Option<egui::Color32> { | |
| 196 | 추가: use zipelo_ui_memory_app::archive_theme::{ROW_HOVER, ROW_SELECTED}; | |
| 197 | 추가: fn walk(shape: &egui::epaint::Shape, y: f32, found: &mut Option<egui::Color32>) { | |
| 198 | 추가: match shape { | |
| 199 | 추가: egui::epaint::Shape::Rect(rect) | |
| 200 | 추가: if (rect.fill == ROW_SELECTED || rect.fill == ROW_HOVER) | |
| 201 | 추가: && rect.rect.top() <= y | |
| 202 | 추가: && y <= rect.rect.bottom() => | |
| 203 | 추가: { | |
| 204 | 추가: *found = Some(rect.fill); | |
| 205 | 추가: } | |
| 206 | 추가: egui::epaint::Shape::Vec(shapes) => { | |
| 207 | 추가: for shape in shapes { | |
| 208 | 추가: walk(shape, y, found); | |
| 209 | 추가: } | |
| 210 | 추가: } | |
| 211 | 추가: _ => {} | |
| 212 | 추가: } | |
| 213 | 추가: } | |
| 214 | 추가: let mut found = None; | |
| 215 | 추가: for shape in &output.shapes { | |
| 216 | 추가: walk(&shape.shape, y, &mut found); | |
| 217 | 추가: } | |
| 218 | 추가: found | |
| 219 | 추가: } | |
| 220 | 추가: | |
| 221 | 추가: fn label_y(ctx: &egui::Context, app: &mut ArchiveApp, label: &str) -> f32 { | |
| 222 | 추가: policy_render(ctx, app, vec![]) | |
| 223 | 추가: .iter() | |
| 224 | 추가: .rev() | |
| 225 | 추가: .find(|(text, _)| text == label) | |
| 226 | 추가: .unwrap_or_else(|| panic!("항목 없음: {label}")) | |
| 227 | 추가: .1 | |
| 228 | 추가: .y | |
| 229 | 추가: } | |
| 230 | 추가: | |
| 231 | 추가: fn hover(ctx: &egui::Context, app: &mut ArchiveApp, label: &str) -> egui::FullOutput { | |
| 232 | 추가: let point = policy_render(ctx, app, vec![]) | |
| 233 | 추가: .iter() | |
| 234 | 추가: .rev() | |
| 235 | 추가: .find(|(text, _)| text == label) | |
| 236 | 추가: .unwrap() | |
| 237 | 추가: .1; | |
| 238 | 추가: frame_output(ctx, app, vec![egui::Event::PointerMoved(point)]); | |
| 239 | 추가: frame_output(ctx, app, vec![egui::Event::PointerMoved(point)]) | |
| 240 | 추가: } | |
| 241 | 추가: | |
| 242 | 추가: #[test] | |
| 243 | 추가: fn create_list_click_selects_and_hover_uses_lighter_blue() { | |
| 244 | 추가: use zipelo_ui_memory_app::archive_theme::{ROW_HOVER, ROW_SELECTED}; | |
| 245 | 추가: let scratch = Folder::new(); | |
| 246 | 추가: let factory = FakeFactory::default(); | |
| 247 | 추가: let (mut app, ctx) = create_from_folder(&scratch, &factory); | |
| 248 | 추가: let a = label_y(&ctx, &mut app, "a.txt"); | |
| 249 | 추가: let trip = label_y(&ctx, &mut app, "trip"); | |
| 250 | 추가: // 한 번 누르면 반투명 파란 배경으로 선택함. | |
| 251 | 추가: policy_click(&ctx, &mut app, "a.txt"); | |
| 252 | 추가: // 다른 행에 마우스를 올리면 선택 색보다 옅은 파란색. | |
| 253 | 추가: let output = hover(&ctx, &mut app, "trip"); | |
| 254 | 추가: assert_eq!(row_fill_at(&output, a), Some(ROW_SELECTED)); | |
| 255 | 추가: assert_eq!(row_fill_at(&output, trip), Some(ROW_HOVER)); | |
| 256 | 추가: // 선택한 행에 마우스를 올려도 더 옅어지지 않음. | |
| 257 | 추가: let output = hover(&ctx, &mut app, "a.txt"); | |
| 258 | 추가: assert_eq!(row_fill_at(&output, a), Some(ROW_SELECTED)); | |
| 259 | 추가: assert_eq!(row_fill_at(&output, trip), None); | |
| 260 | 추가: assert!(ROW_HOVER.a() < ROW_SELECTED.a()); | |
| 261 | 추가: } | |
| 262 | 추가: | |
| 263 | 추가: #[test] | |
| 264 | 추가: fn main_list_hover_uses_lighter_blue_and_selected_row_keeps_its_color() { | |
| 265 | 추가: use zipelo_ui_memory_app::archive_theme::{ROW_HOVER, ROW_SELECTED}; | |
| 266 | 추가: let scratch = Folder::new(); | |
| 267 | 추가: let factory = FakeFactory::default(); | |
| 268 | 추가: let mut app = loaded(&scratch, &factory); | |
| 269 | 추가: let ctx = egui::Context::default(); | |
| 270 | 추가: let name = "읽어주세요.txt"; | |
| 271 | 추가: let y = label_y(&ctx, &mut app, name); | |
| 272 | 추가: let output = hover(&ctx, &mut app, name); | |
| 273 | 추가: assert_eq!(row_fill_at(&output, y), Some(ROW_HOVER)); | |
| 274 | 추가: policy_click(&ctx, &mut app, name); | |
| 275 | 추가: let output = hover(&ctx, &mut app, name); | |
| 276 | 추가: assert_eq!(row_fill_at(&output, y), Some(ROW_SELECTED)); | |
| 277 | 추가: } |