Changeset c6f00b40 in mainline for uspace/lib/ui/src


Ignore:
Timestamp:
2020-11-01T22:49:05Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4ac11ff
Parents:
4df6607
git-author:
Jiri Svoboda <jiri@…> (2020-11-01 22:47:03)
git-committer:
Jiri Svoboda <jiri@…> (2020-11-01 22:49:05)
Message:

Add virtual destructor for UI control

Location:
uspace/lib/ui/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/control.c

    r4df6607 rc6f00b40  
    6464/** Delete UI control.
    6565 *
     66 * Deletes the base control (not the extended data).
     67 *
    6668 * @param control UI control or @c NULL
    6769 */
     
    7476}
    7577
     78/** Destroy UI control.
     79 *
     80 * Run the virtual control destructor (destroy complete control including
     81 * extended data).
     82 *
     83 * @param control Control
     84 */
     85void ui_control_destroy(ui_control_t *control)
     86{
     87        return control->ops->destroy(control->ext);
     88}
     89
    7690/** Paint UI control.
    7791 *
    78  * @param control Push button
     92 * @param control Control
    7993 * @return EOK on success or an error code
    8094 */
     
    86100/** Deliver position event to UI control.
    87101 *
    88  * @param control Push button
     102 * @param control Control
    89103 * @param pos_event Position event
    90104 * @return @c ui_claimed iff the event is claimed
  • uspace/lib/ui/src/fixed.c

    r4df6607 rc6f00b40  
    6868void ui_fixed_destroy(ui_fixed_t *fixed)
    6969{
     70        ui_fixed_elem_t *elem;
     71        ui_control_t *control;
     72
    7073        if (fixed == NULL)
    7174                return;
    7275
    73         assert(list_empty(&fixed->elem));
     76        elem = ui_fixed_first(fixed);
     77        while (elem != NULL) {
     78                control = elem->control;
     79                ui_fixed_remove(fixed, control);
     80                ui_control_destroy(control);
     81
     82                elem = ui_fixed_first(fixed);
     83        }
     84
    7485        free(fixed);
    7586}
  • uspace/lib/ui/src/label.c

    r4df6607 rc6f00b40  
    4646#include "../private/resource.h"
    4747
     48static void ui_label_ctl_destroy(void *);
    4849static errno_t ui_label_ctl_paint(void *);
    4950static ui_evclaim_t ui_label_ctl_pos_event(void *, pos_event_t *);
     
    5152/** Label control ops */
    5253ui_control_ops_t ui_label_ops = {
     54        .destroy = ui_label_ctl_destroy,
    5355        .paint = ui_label_ctl_paint,
    5456        .pos_event = ui_label_ctl_pos_event
     
    207209}
    208210
    209 /** Paint lable control.
     211/** Destroy label control.
     212 *
     213 * @param arg Argument (ui_label_t *)
     214 */
     215void ui_label_ctl_destroy(void *arg)
     216{
     217        ui_label_t *label = (ui_label_t *) arg;
     218
     219        ui_label_destroy(label);
     220}
     221
     222/** Paint label control.
    210223 *
    211224 * @param arg Argument (ui_label_t *)
  • uspace/lib/ui/src/pbutton.c

    r4df6607 rc6f00b40  
    5454};
    5555
     56static void ui_pbutton_ctl_destroy(void *);
    5657static errno_t ui_pbutton_ctl_paint(void *);
    5758static ui_evclaim_t ui_pbutton_ctl_pos_event(void *, pos_event_t *);
     
    5960/** Push button control ops */
    6061ui_control_ops_t ui_pbutton_ops = {
     62        .destroy = ui_pbutton_ctl_destroy,
    6163        .paint = ui_pbutton_ctl_paint,
    6264        .pos_event = ui_pbutton_ctl_pos_event
     
    418420}
    419421
     422/** Destroy push button control.
     423 *
     424 * @param arg Argument (ui_pbutton_t *)
     425 */
     426void ui_pbutton_ctl_destroy(void *arg)
     427{
     428        ui_pbutton_t *pbutton = (ui_pbutton_t *) arg;
     429
     430        ui_pbutton_destroy(pbutton);
     431}
     432
    420433/** Paint push button control.
    421434 *
Note: See TracChangeset for help on using the changeset viewer.