Changes in uspace/lib/ui/src/filedialog.c [b979ffb:12dd36c] in mainline
- File:
-
- 1 edited
-
uspace/lib/ui/src/filedialog.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/filedialog.c
rb979ffb r12dd36c 1 1 /* 2 * Copyright (c) 202 6Jiri Svoboda2 * Copyright (c) 2024 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 *);51 50 static void ui_file_dialog_wnd_close(ui_window_t *, void *); 52 51 static void ui_file_dialog_wnd_kbd(ui_window_t *, void *, kbd_event_t *); 53 52 54 53 ui_window_cb_t ui_file_dialog_wnd_cb = { 55 .resize = ui_file_dialog_wnd_resize,56 54 .close = ui_file_dialog_wnd_close, 57 55 .kbd = ui_file_dialog_wnd_kbd … … 89 87 memset(params, 0, sizeof(ui_file_dialog_params_t)); 90 88 params->ifname = ""; 91 }92 93 /** Compute file dialog geometry.94 *95 * @param ui User interface96 * @param wrect Window interior rectangle97 * @param geom Place to store geometry98 */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 }183 89 } 184 90 … … 203 109 ui_pbutton_t *bok = NULL; 204 110 ui_pbutton_t *bcancel = NULL; 205 ui_file_dialog_geom_t geom; 206 gfx_rect_t arect; 111 gfx_rect_t rect; 207 112 ui_resource_t *ui_res; 208 113 … … 215 120 ui_wnd_params_init(&wparams); 216 121 wparams.caption = params->caption; 217 wparams.style |= ui_wds_maximize_btn | ui_wds_resizable;218 122 219 123 /* FIXME: Auto layout */ … … 223 127 wparams.rect.p1.x = 40; 224 128 wparams.rect.p1.y = 20; 225 226 wparams.min_size.x = 30;227 wparams.min_size.y = 10;228 129 } else { 229 130 wparams.rect.p0.x = 0; … … 231 132 wparams.rect.p1.x = 300; 232 133 wparams.rect.p1.y = 335; 233 234 wparams.min_size.x = 240;235 wparams.min_size.y = 260;236 134 } 237 135 … … 242 140 ui_window_set_cb(window, &ui_file_dialog_wnd_cb, dialog); 243 141 244 ui_window_get_app_rect(window, &arect);245 142 ui_res = ui_window_get_res(window); 246 143 247 /* Compute geometry. */248 ui_file_dialog_get_geom(ui, &arect, &geom);249 250 144 rc = ui_fixed_create(&fixed); 251 145 if (rc != EOK) … … 256 150 goto error; 257 151 258 ui_label_set_rect(label, &geom.fname_label_rect); 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); 259 166 260 167 rc = ui_fixed_add(fixed, ui_label_ctl(label)); … … 268 175 goto error; 269 176 270 ui_entry_set_rect(entry, &geom.entry_rect); 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); 271 191 272 192 rc = ui_fixed_add(fixed, ui_entry_ctl(entry)); … … 288 208 goto error; 289 209 290 ui_label_set_rect(label, &geom.files_label_rect); 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); 291 224 292 225 rc = ui_fixed_add(fixed, ui_label_ctl(label)); … … 302 235 goto error; 303 236 304 ui_file_list_set_rect(flist, &geom.flist_rect); 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); 305 251 ui_file_list_set_cb(flist, &ui_file_dialog_flist_cb, dialog); 306 252 … … 323 269 324 270 ui_pbutton_set_cb(bok, &ui_file_dialog_bok_cb, dialog); 325 ui_pbutton_set_rect(bok, &geom.bok_rect); 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 326 287 ui_pbutton_set_default(bok, true); 327 288 … … 340 301 341 302 ui_pbutton_set_cb(bcancel, &ui_file_dialog_bcancel_cb, dialog); 342 ui_pbutton_set_rect(bcancel, &geom.bcancel_rect); 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); 343 318 344 319 rc = ui_fixed_add(fixed, ui_pbutton_ctl(bcancel)); … … 405 380 } 406 381 407 /** File dialog window resize handler.408 *409 * @param window Window410 * @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 432 382 /** File dialog window close handler. 433 383 *
Note:
See TracChangeset
for help on using the changeset viewer.
