Changeset 8009dc27 in mainline for uspace/app/uidemo/uidemo.c


Ignore:
Timestamp:
2020-10-31T01:03:26Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4df6607
Parents:
f03d1308
Message:

Prototype control base class and fixed layout class

So far only position event delivery is handled via layout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/uidemo/uidemo.c

    rf03d1308 r8009dc27  
    4040#include <str.h>
    4141#include <task.h>
     42#include <ui/fixed.h>
    4243#include <ui/label.h>
    4344#include <ui/pbutton.h>
     
    8485
    8586        /* Make sure we don't process events until fully initialized */
    86         if (demo->pb1 == NULL || demo->pb2 == NULL)
     87        if (demo->fixed == NULL)
    8788                return;
    8889
    89         ui_pbutton_pos_event(demo->pb1, event);
    90         ui_pbutton_pos_event(demo->pb2, event);
     90        ui_fixed_pos_event(demo->fixed, event);
    9191}
    9292
     
    159159        ui_window_get_app_rect(window, &app_rect);
    160160
     161        rc = ui_fixed_create(&demo.fixed);
     162        if (rc != EOK) {
     163                printf("Error creating fixed layout.\n");
     164                return rc;
     165        }
     166
    161167        rc = ui_label_create(ui_res, "Hello there!", &demo.label);
    162168        if (rc != EOK) {
     
    172178        ui_label_set_halign(demo.label, gfx_halign_center);
    173179
     180        rc = ui_fixed_add(demo.fixed, ui_label_ctl(demo.label));
     181        if (rc != EOK) {
     182                printf("Error adding control to layout.\n");
     183                return rc;
     184        }
     185
    174186        rc = ui_pbutton_create(ui_res, "Confirm", &demo.pb1);
    175187        if (rc != EOK) {
     
    188200        ui_pbutton_set_default(demo.pb1, true);
    189201
     202        rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb1));
     203        if (rc != EOK) {
     204                printf("Error adding control to layout.\n");
     205                return rc;
     206        }
     207
    190208        rc = ui_pbutton_create(ui_res, "Cancel", &demo.pb2);
    191209        if (rc != EOK) {
     
    202220        ui_pbutton_set_rect(demo.pb2, &rect);
    203221
     222        rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb2));
     223        if (rc != EOK) {
     224                printf("Error adding control to layout.\n");
     225                return rc;
     226        }
     227
    204228        rc = gfx_color_new_rgb_i16(0xc8c8, 0xc8c8, 0xc8c8, &color);
    205229        if (rc != EOK) {
     
    239263
    240264        ui_run(ui);
     265
     266        ui_fixed_remove(demo.fixed, ui_label_ctl(demo.label));
     267        ui_fixed_remove(demo.fixed, ui_pbutton_ctl(demo.pb1));
     268        ui_fixed_remove(demo.fixed, ui_pbutton_ctl(demo.pb2));
    241269
    242270        ui_pbutton_destroy(demo.pb1);
Note: See TracChangeset for help on using the changeset viewer.