Changeset 11662bd in mainline
- Timestamp:
- 2022-05-31T08:38:28Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 03fc3a9
- Parents:
- 5877de74
- git-author:
- Jiri Svoboda <jiri@…> (2022-05-30 17:38:13)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-05-31 08:38:28)
- Location:
- uspace/lib/ui
- Files:
-
- 5 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/meson.build
r5877de74 r11662bd 36 36 'src/entry.c', 37 37 'src/filedialog.c', 38 'src/filelist.c', 38 39 'src/fixed.c', 39 40 'src/image.c', … … 63 64 'test/entry.c', 64 65 'test/filedialog.c', 66 'test/filelist.c', 65 67 'test/fixed.c', 66 68 'test/image.c', -
uspace/lib/ui/private/filedialog.h
r5877de74 r11662bd 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 47 47 /** File name entry */ 48 48 struct ui_entry *ename; 49 /** File list */ 50 struct ui_file_list *flist; 49 51 /** OK button */ 50 52 struct ui_pbutton *bok; -
uspace/lib/ui/src/filedialog.c
r5877de74 r11662bd 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 #include <ui/label.h> 42 42 #include <ui/filedialog.h> 43 #include <ui/filelist.h> 43 44 #include <ui/pbutton.h> 44 45 #include <ui/resource.h> … … 53 54 .close = ui_file_dialog_wnd_close, 54 55 .kbd = ui_file_dialog_wnd_kbd 56 }; 57 58 static void ui_file_dialog_flist_activate_req(ui_file_list_t *, void *); 59 static void ui_file_dialog_flist_selected(ui_file_list_t *, void *, 60 const char *); 61 62 ui_file_list_cb_t ui_file_dialog_flist_cb = { 63 .activate_req = ui_file_dialog_flist_activate_req, 64 .selected = ui_file_dialog_flist_selected 55 65 }; 56 66 … … 96 106 ui_label_t *label = NULL; 97 107 ui_entry_t *entry = NULL; 108 ui_file_list_t *flist = NULL; 98 109 ui_pbutton_t *bok = NULL; 99 110 ui_pbutton_t *bcancel = NULL; … … 115 126 wparams.rect.p0.y = 0; 116 127 wparams.rect.p1.x = 40; 117 wparams.rect.p1.y = 9;128 wparams.rect.p1.y = 20; 118 129 } else { 119 130 wparams.rect.p0.x = 0; 120 131 wparams.rect.p0.y = 0; 121 132 wparams.rect.p1.x = 300; 122 wparams.rect.p1.y = 135;133 wparams.rect.p1.y = 335; 123 134 } 124 135 … … 167 178 if (ui_is_textmode(ui)) { 168 179 rect.p0.x = 3; 169 rect.p0.y = 4;180 rect.p0.y = 3; 170 181 rect.p1.x = 37; 171 rect.p1.y = 5;182 rect.p1.y = 4; 172 183 } else { 173 184 rect.p0.x = 10; … … 192 203 entry = NULL; 193 204 205 /* Files label */ 206 rc = ui_label_create(ui_res, "Files:", &label); 207 if (rc != EOK) 208 goto error; 209 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); 224 225 rc = ui_fixed_add(fixed, ui_label_ctl(label)); 226 if (rc != EOK) 227 goto error; 228 229 label = NULL; 230 231 /* File list */ 232 233 rc = ui_file_list_create(window, false, &flist); 234 if (rc != EOK) 235 goto error; 236 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); 251 ui_file_list_set_cb(flist, &ui_file_dialog_flist_cb, dialog); 252 253 rc = ui_fixed_add(fixed, ui_file_list_ctl(flist)); 254 if (rc != EOK) 255 goto error; 256 257 dialog->flist = flist; 258 flist = NULL; 259 260 rc = ui_file_list_read_dir(dialog->flist, "."); 261 if (rc != EOK) 262 goto error; 263 264 /* OK button */ 265 194 266 rc = ui_pbutton_create(ui_res, "OK", &bok); 195 267 if (rc != EOK) … … 201 273 if (ui_is_textmode(ui)) { 202 274 rect.p0.x = 10; 203 rect.p0.y = 6;275 rect.p0.y = 17; 204 276 rect.p1.x = 20; 205 rect.p1.y = 7;277 rect.p1.y = 18; 206 278 } else { 207 279 rect.p0.x = 55; 208 rect.p0.y = 90;280 rect.p0.y = 290; 209 281 rect.p1.x = 145; 210 rect.p1.y = 118;282 rect.p1.y = 318; 211 283 } 212 284 … … 222 294 bok = NULL; 223 295 296 /* Cancel button */ 297 224 298 rc = ui_pbutton_create(ui_res, "Cancel", &bcancel); 225 299 if (rc != EOK) … … 231 305 if (ui_is_textmode(ui)) { 232 306 rect.p0.x = 22; 233 rect.p0.y = 6;307 rect.p0.y = 17; 234 308 rect.p1.x = 32; 235 rect.p1.y = 7;309 rect.p1.y = 18; 236 310 } else { 237 311 rect.p0.x = 155; 238 rect.p0.y = 90;312 rect.p0.y = 290; 239 313 rect.p1.x = 245; 240 rect.p1.y = 118;314 rect.p1.y = 318; 241 315 } 242 316 … … 263 337 if (entry != NULL) 264 338 ui_entry_destroy(entry); 339 if (flist != NULL) 340 ui_file_list_destroy(flist); 265 341 if (bok != NULL) 266 342 ui_pbutton_destroy(bok); … … 328 404 ui_file_dialog_t *dialog = (ui_file_dialog_t *) arg; 329 405 const char *fname; 406 ui_evclaim_t claim; 407 408 claim = ui_window_def_kbd(window, event); 409 if (claim == ui_claimed) 410 return; 330 411 331 412 if (event->type == KEY_PRESS && … … 347 428 } 348 429 349 ui_window_def_kbd(window, event); 430 } 431 432 static void ui_file_dialog_flist_activate_req(ui_file_list_t *flist, void *arg) 433 { 434 ui_file_dialog_t *dialog = (ui_file_dialog_t *) arg; 435 436 ui_file_list_activate(dialog->flist); 437 ui_entry_deactivate(dialog->ename); 438 } 439 440 static void ui_file_dialog_flist_selected(ui_file_list_t *flist, void *arg, 441 const char *fname) 442 { 443 ui_file_dialog_t *dialog = (ui_file_dialog_t *) arg; 444 445 dialog->cb->bok(dialog, dialog->arg, fname); 350 446 } 351 447 -
uspace/lib/ui/test/main.c
r5877de74 r11662bd 37 37 PCUT_IMPORT(entry); 38 38 PCUT_IMPORT(file_dialog); 39 PCUT_IMPORT(file_list); 39 40 PCUT_IMPORT(fixed); 40 41 PCUT_IMPORT(image); … … 54 55 PCUT_IMPORT(wdecor); 55 56 PCUT_IMPORT(window); 56 57 57 PCUT_MAIN();
Note:
See TracChangeset
for help on using the changeset viewer.