Changeset 8009dc27 in mainline for uspace/lib/ui/src/label.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/lib/ui/src/label.c

    rf03d1308 r8009dc27  
    4040#include <stdlib.h>
    4141#include <str.h>
     42#include <ui/control.h>
    4243#include <ui/paint.h>
    4344#include <ui/label.h>
     
    4546#include "../private/resource.h"
    4647
     48static ui_evclaim_t ui_label_ctl_pos_event(void *, pos_event_t *);
     49
     50/** Label control ops */
     51ui_control_ops_t ui_label_ops = {
     52        .pos_event = ui_label_ctl_pos_event
     53};
     54
    4755/** Create new label.
    4856 *
     
    5664{
    5765        ui_label_t *label;
     66        errno_t rc;
    5867
    5968        label = calloc(1, sizeof(ui_label_t));
     
    6170                return ENOMEM;
    6271
     72        rc = ui_control_new(&ui_label_ops, (void *) label, &label->control);
     73        if (rc != EOK) {
     74                free(label);
     75                return rc;
     76        }
     77
    6378        label->text = str_dup(text);
    6479        if (label->text == NULL) {
     80                ui_control_delete(label->control);
    6581                free(label);
    6682                return ENOMEM;
     
    8298                return;
    8399
     100        ui_control_delete(label->control);
    84101        free(label);
     102}
     103
     104/** Get base control from label.
     105 *
     106 * @param label Label
     107 * @return Control
     108 */
     109ui_control_t *ui_label_ctl(ui_label_t *label)
     110{
     111        return label->control;
    85112}
    86113
     
    178205}
    179206
     207/** Handle label control position event.
     208 *
     209 * @param arg Argument (ui_label_t *)
     210 * @param pos_event Position event
     211 * @return @c ui_claimed iff the event is claimed
     212 */
     213ui_evclaim_t ui_label_ctl_pos_event(void *arg, pos_event_t *event)
     214{
     215        ui_label_t *label = (ui_label_t *) arg;
     216
     217        (void) label;
     218        return ui_unclaimed;
     219}
     220
    180221/** @}
    181222 */
Note: See TracChangeset for help on using the changeset viewer.