Changeset ef734b7 in mainline for uspace/app/uidemo/uidemo.c
- Timestamp:
- 2021-02-05T15:59:16Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2ab8ab3
- Parents:
- 5a68791
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r5a68791 ref734b7 37 37 #include <io/pixelmap.h> 38 38 #include <stdio.h> 39 #include <stdlib.h> 39 40 #include <str.h> 40 41 #include <ui/entry.h> … … 74 75 }; 75 76 77 static void slider_moved(ui_slider_t *, void *, gfx_coord_t); 78 79 static ui_slider_cb_t slider_cb = { 80 .moved = slider_moved 81 }; 82 76 83 /** Window close button was clicked. 77 84 * … … 150 157 } 151 158 159 /** Slider was moved. 160 * 161 * @param slider Slider 162 * @param arg Argument (demo) 163 * @param pos Position 164 */ 165 static void slider_moved(ui_slider_t *slider, void *arg, gfx_coord_t pos) 166 { 167 ui_demo_t *demo = (ui_demo_t *) arg; 168 char *str; 169 errno_t rc; 170 int rv; 171 172 rv = asprintf(&str, "Slider at %d of %d", (int) pos, 173 ui_slider_length(slider)); 174 if (rv < 0) { 175 printf("Out of memory.\n"); 176 return; 177 } 178 179 rc = ui_entry_set_text(demo->entry, str); 180 if (rc != EOK) 181 printf("Error changing entry text.\n"); 182 (void) ui_entry_paint(demo->entry); 183 184 free(str); 185 } 186 152 187 /** Run UI demo on display server. */ 153 188 static errno_t ui_demo(const char *display_spec) … … 177 212 params.rect.p0.y = 0; 178 213 params.rect.p1.x = 220; 179 params.rect.p1.y = 3 30;214 params.rect.p1.y = 340; 180 215 181 216 memset((void *) &demo, 0, sizeof(demo)); … … 397 432 398 433 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb3)); 434 if (rc != EOK) { 435 printf("Error adding control to layout.\n"); 436 return rc; 437 } 438 439 rc = ui_slider_create(ui_res, "Slide!", &demo.slider); 440 if (rc != EOK) { 441 printf("Error creating button.\n"); 442 return rc; 443 } 444 445 ui_slider_set_cb(demo.slider, &slider_cb, (void *) &demo); 446 447 rect.p0.x = 15; 448 rect.p0.y = 300; 449 rect.p1.x = 130; 450 rect.p1.y = 320; 451 ui_slider_set_rect(demo.slider, &rect); 452 453 rc = ui_fixed_add(demo.fixed, ui_slider_ctl(demo.slider)); 399 454 if (rc != EOK) { 400 455 printf("Error adding control to layout.\n");
Note:
See TracChangeset
for help on using the changeset viewer.