Changeset b979ffb in mainline for uspace/lib
- Timestamp:
- 2026-03-10T09:41:42Z (7 days ago)
- Branches:
- master
- Children:
- 52148ef, 66da893, 79ec0a0, 9b534a4, bc969a1, d811fe5, d8120c5, db6ead8b, e474d61, eede1c5
- Parents:
- 3c22438a
- git-author:
- Jiri Svoboda <jiri@…> (2026-03-09 20:41:23)
- git-committer:
- Jiri Svoboda <jiri@…> (2026-03-10 09:41:42)
- Location:
- uspace/lib/ui
- Files:
-
- 3 edited
-
private/filedialog.h (modified) (3 diffs)
-
src/filedialog.c (modified) (15 diffs)
-
src/window.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/private/filedialog.h
r3c22438a rb979ffb 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 38 38 #define _UI_PRIVATE_FILEDIALOG_H 39 39 40 #include <gfx/coord.h> 41 40 42 /** Actual structure of file dialog. 41 43 * … … 59 61 }; 60 62 63 /** File dialog geometry. 64 * 65 * Computed geometry of file dialog. 66 */ 67 typedef struct { 68 /** File name label rectangle */ 69 gfx_rect_t fname_label_rect; 70 /** File name entry rectangle */ 71 gfx_rect_t entry_rect; 72 /** Files label rectangle */ 73 gfx_rect_t files_label_rect; 74 /** File list rectangle */ 75 gfx_rect_t flist_rect; 76 /** File list rectangle */ 77 gfx_rect_t bok_rect; 78 /** File list rectangle */ 79 gfx_rect_t bcancel_rect; 80 } ui_file_dialog_geom_t; 81 61 82 #endif 62 83 -
uspace/lib/ui/src/filedialog.c
r3c22438a rb979ffb 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2026 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 48 48 #include "../private/filedialog.h" 49 49 50 static void ui_file_dialog_wnd_resize(ui_window_t *, void *); 50 51 static void ui_file_dialog_wnd_close(ui_window_t *, void *); 51 52 static void ui_file_dialog_wnd_kbd(ui_window_t *, void *, kbd_event_t *); 52 53 53 54 ui_window_cb_t ui_file_dialog_wnd_cb = { 55 .resize = ui_file_dialog_wnd_resize, 54 56 .close = ui_file_dialog_wnd_close, 55 57 .kbd = ui_file_dialog_wnd_kbd … … 87 89 memset(params, 0, sizeof(ui_file_dialog_params_t)); 88 90 params->ifname = ""; 91 } 92 93 /** Compute file dialog geometry. 94 * 95 * @param ui User interface 96 * @param wrect Window interior rectangle 97 * @param geom Place to store geometry 98 */ 99 static void ui_file_dialog_get_geom(ui_t *ui, gfx_rect_t *wrect, 100 ui_file_dialog_geom_t *geom) 101 { 102 gfx_coord_t cx; 103 104 /* FIXME: Auto layout */ 105 if (ui_is_textmode(ui)) { 106 geom->fname_label_rect.p0.x = 3; 107 geom->fname_label_rect.p0.y = 2; 108 geom->fname_label_rect.p1.x = 17; 109 geom->fname_label_rect.p1.y = 3; 110 } else { 111 geom->fname_label_rect.p0.x = 10; 112 geom->fname_label_rect.p0.y = 35; 113 geom->fname_label_rect.p1.x = 190; 114 geom->fname_label_rect.p1.y = 50; 115 } 116 117 /* FIXME: Auto layout */ 118 if (ui_is_textmode(ui)) { 119 geom->entry_rect.p0.x = 3; 120 geom->entry_rect.p0.y = 3; 121 geom->entry_rect.p1.x = wrect->p1.x - 3; 122 geom->entry_rect.p1.y = 4; 123 } else { 124 geom->entry_rect.p0.x = 10; 125 geom->entry_rect.p0.y = 55; 126 geom->entry_rect.p1.x = wrect->p1.x - 10; 127 geom->entry_rect.p1.y = 80; 128 } 129 130 /* FIXME: Auto layout */ 131 if (ui_is_textmode(ui)) { 132 geom->files_label_rect.p0.x = 3; 133 geom->files_label_rect.p0.y = 5; 134 geom->files_label_rect.p1.x = 17; 135 geom->files_label_rect.p1.y = 6; 136 } else { 137 geom->files_label_rect.p0.x = 10; 138 geom->files_label_rect.p0.y = 90; 139 geom->files_label_rect.p1.x = 190; 140 geom->files_label_rect.p1.y = 105; 141 } 142 143 /* FIXME: Auto layout */ 144 if (ui_is_textmode(ui)) { 145 geom->flist_rect.p0.x = 3; 146 geom->flist_rect.p0.y = 6; 147 geom->flist_rect.p1.x = wrect->p1.x - 3; 148 geom->flist_rect.p1.y = wrect->p1.y - 4; 149 } else { 150 geom->flist_rect.p0.x = 10; 151 geom->flist_rect.p0.y = 110; 152 geom->flist_rect.p1.x = wrect->p1.x - 10; 153 geom->flist_rect.p1.y = wrect->p1.y - 55; 154 } 155 156 cx = (wrect->p0.x + wrect->p1.x) / 2; 157 158 /* FIXME: Auto layout */ 159 if (ui_is_textmode(ui)) { 160 geom->bok_rect.p0.x = cx - 10; 161 geom->bok_rect.p0.y = wrect->p1.y - 3; 162 geom->bok_rect.p1.x = cx; 163 geom->bok_rect.p1.y = wrect->p1.y - 2; 164 } else { 165 geom->bok_rect.p0.x = cx - 95; 166 geom->bok_rect.p0.y = wrect->p1.y - 45; 167 geom->bok_rect.p1.x = cx - 5; 168 geom->bok_rect.p1.y = wrect->p1.y - 17; 169 } 170 171 /* FIXME: Auto layout */ 172 if (ui_is_textmode(ui)) { 173 geom->bcancel_rect.p0.x = cx + 2; 174 geom->bcancel_rect.p0.y = wrect->p1.y - 3; 175 geom->bcancel_rect.p1.x = cx + 12; 176 geom->bcancel_rect.p1.y = wrect->p1.y - 2; 177 } else { 178 geom->bcancel_rect.p0.x = cx + 5; 179 geom->bcancel_rect.p0.y = wrect->p1.y - 45; 180 geom->bcancel_rect.p1.x = cx + 95; 181 geom->bcancel_rect.p1.y = wrect->p1.y - 17; 182 } 89 183 } 90 184 … … 109 203 ui_pbutton_t *bok = NULL; 110 204 ui_pbutton_t *bcancel = NULL; 111 gfx_rect_t rect; 205 ui_file_dialog_geom_t geom; 206 gfx_rect_t arect; 112 207 ui_resource_t *ui_res; 113 208 … … 120 215 ui_wnd_params_init(&wparams); 121 216 wparams.caption = params->caption; 217 wparams.style |= ui_wds_maximize_btn | ui_wds_resizable; 122 218 123 219 /* FIXME: Auto layout */ … … 127 223 wparams.rect.p1.x = 40; 128 224 wparams.rect.p1.y = 20; 225 226 wparams.min_size.x = 30; 227 wparams.min_size.y = 10; 129 228 } else { 130 229 wparams.rect.p0.x = 0; … … 132 231 wparams.rect.p1.x = 300; 133 232 wparams.rect.p1.y = 335; 233 234 wparams.min_size.x = 240; 235 wparams.min_size.y = 260; 134 236 } 135 237 … … 140 242 ui_window_set_cb(window, &ui_file_dialog_wnd_cb, dialog); 141 243 244 ui_window_get_app_rect(window, &arect); 142 245 ui_res = ui_window_get_res(window); 143 246 247 /* Compute geometry. */ 248 ui_file_dialog_get_geom(ui, &arect, &geom); 249 144 250 rc = ui_fixed_create(&fixed); 145 251 if (rc != EOK) … … 150 256 goto error; 151 257 152 /* FIXME: Auto layout */ 153 if (ui_is_textmode(ui)) { 154 rect.p0.x = 3; 155 rect.p0.y = 2; 156 rect.p1.x = 17; 157 rect.p1.y = 3; 158 } else { 159 rect.p0.x = 10; 160 rect.p0.y = 35; 161 rect.p1.x = 190; 162 rect.p1.y = 50; 163 } 164 165 ui_label_set_rect(label, &rect); 258 ui_label_set_rect(label, &geom.fname_label_rect); 166 259 167 260 rc = ui_fixed_add(fixed, ui_label_ctl(label)); … … 175 268 goto error; 176 269 177 /* FIXME: Auto layout */ 178 if (ui_is_textmode(ui)) { 179 rect.p0.x = 3; 180 rect.p0.y = 3; 181 rect.p1.x = 37; 182 rect.p1.y = 4; 183 } else { 184 rect.p0.x = 10; 185 rect.p0.y = 55; 186 rect.p1.x = 290; 187 rect.p1.y = 80; 188 } 189 190 ui_entry_set_rect(entry, &rect); 270 ui_entry_set_rect(entry, &geom.entry_rect); 191 271 192 272 rc = ui_fixed_add(fixed, ui_entry_ctl(entry)); … … 208 288 goto error; 209 289 210 /* FIXME: Auto layout */ 211 if (ui_is_textmode(ui)) { 212 rect.p0.x = 3; 213 rect.p0.y = 5; 214 rect.p1.x = 17; 215 rect.p1.y = 6; 216 } else { 217 rect.p0.x = 10; 218 rect.p0.y = 90; 219 rect.p1.x = 190; 220 rect.p1.y = 105; 221 } 222 223 ui_label_set_rect(label, &rect); 290 ui_label_set_rect(label, &geom.files_label_rect); 224 291 225 292 rc = ui_fixed_add(fixed, ui_label_ctl(label)); … … 235 302 goto error; 236 303 237 /* FIXME: Auto layout */ 238 if (ui_is_textmode(ui)) { 239 rect.p0.x = 3; 240 rect.p0.y = 6; 241 rect.p1.x = 37; 242 rect.p1.y = 16; 243 } else { 244 rect.p0.x = 10; 245 rect.p0.y = 110; 246 rect.p1.x = 290; 247 rect.p1.y = 280; 248 } 249 250 ui_file_list_set_rect(flist, &rect); 304 ui_file_list_set_rect(flist, &geom.flist_rect); 251 305 ui_file_list_set_cb(flist, &ui_file_dialog_flist_cb, dialog); 252 306 … … 269 323 270 324 ui_pbutton_set_cb(bok, &ui_file_dialog_bok_cb, dialog); 271 272 /* FIXME: Auto layout */ 273 if (ui_is_textmode(ui)) { 274 rect.p0.x = 10; 275 rect.p0.y = 17; 276 rect.p1.x = 20; 277 rect.p1.y = 18; 278 } else { 279 rect.p0.x = 55; 280 rect.p0.y = 290; 281 rect.p1.x = 145; 282 rect.p1.y = 318; 283 } 284 285 ui_pbutton_set_rect(bok, &rect); 286 325 ui_pbutton_set_rect(bok, &geom.bok_rect); 287 326 ui_pbutton_set_default(bok, true); 288 327 … … 301 340 302 341 ui_pbutton_set_cb(bcancel, &ui_file_dialog_bcancel_cb, dialog); 303 304 /* FIXME: Auto layout */ 305 if (ui_is_textmode(ui)) { 306 rect.p0.x = 22; 307 rect.p0.y = 17; 308 rect.p1.x = 32; 309 rect.p1.y = 18; 310 } else { 311 rect.p0.x = 155; 312 rect.p0.y = 290; 313 rect.p1.x = 245; 314 rect.p1.y = 318; 315 } 316 317 ui_pbutton_set_rect(bcancel, &rect); 342 ui_pbutton_set_rect(bcancel, &geom.bcancel_rect); 318 343 319 344 rc = ui_fixed_add(fixed, ui_pbutton_ctl(bcancel)); … … 380 405 } 381 406 407 /** File dialog window resize handler. 408 * 409 * @param window Window 410 * @param arg Argument (ui_file_dialog_t *) 411 */ 412 static void ui_file_dialog_wnd_resize(ui_window_t *window, void *arg) 413 { 414 ui_file_dialog_t *dialog = (ui_file_dialog_t *) arg; 415 gfx_rect_t arect; 416 ui_file_dialog_geom_t geom; 417 418 /* Get new window application rectangle. */ 419 ui_window_get_app_rect(window, &arect); 420 421 /* Compute geometry. */ 422 ui_file_dialog_get_geom(ui_window_get_ui(window), &arect, &geom); 423 424 ui_entry_set_rect(dialog->ename, &geom.entry_rect); 425 ui_file_list_set_rect(dialog->flist, &geom.flist_rect); 426 ui_pbutton_set_rect(dialog->bok, &geom.bok_rect); 427 ui_pbutton_set_rect(dialog->bcancel, &geom.bcancel_rect); 428 429 (void)ui_window_paint(window); 430 } 431 382 432 /** File dialog window close handler. 383 433 * -
uspace/lib/ui/src/window.c
r3c22438a rb979ffb 840 840 } 841 841 842 /* Need to repaint UI if windows are emulated */843 if (ui_is_fullscreen(window->ui))844 (void)ui_paint(window->ui);845 846 842 switch (scop) { 847 843 case ui_wsc_resize: … … 876 872 errno_t ui_window_resize(ui_window_t *window, gfx_rect_t *rect) 877 873 { 878 return ui_window_size_change(window, rect, ui_wsc_resize); 874 errno_t rc; 875 876 rc = ui_window_size_change(window, rect, ui_wsc_resize); 877 if (rc != EOK) 878 return rc; 879 880 /* Need to repaint UI if windows are emulated */ 881 if (ui_is_fullscreen(window->ui)) 882 (void)ui_paint(window->ui); 883 884 return EOK; 879 885 } 880 886 … … 1578 1584 1579 1585 window->normal_rect = old_rect; 1580 (void) ui_window_paint(window); 1586 ui_window_send_resize(window); 1587 1588 /* Need to repaint UI if windows are emulated */ 1589 if (ui_is_fullscreen(window->ui)) 1590 (void)ui_paint(window->ui); 1591 1581 1592 return EOK; 1582 1593 } … … 1603 1614 } 1604 1615 1605 (void) ui_window_paint(window); 1616 ui_window_send_resize(window); 1617 1618 /* Need to repaint UI if windows are emulated */ 1619 if (ui_is_fullscreen(window->ui)) 1620 (void)ui_paint(window->ui); 1621 1606 1622 return EOK; 1607 1623 }
Note:
See TracChangeset
for help on using the changeset viewer.
