Changeset b769ca0 in mainline for uspace/lib/ui/src/pbutton.c


Ignore:
Timestamp:
2026-02-19T00:01:36Z (45 hours ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
08fcaf2
Parents:
39f67f1
Message:

Allow overriding the complete UI push button paint routine.

File:
1 edited

Legend:

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

    r39f67f1 rb769ca0  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2026 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    142142}
    143143
    144 /** Set push button decoration ops.
    145  *
    146  * @param pbutton Push button
    147  * @param ops Push button decoration callbacks
     144/** Set push button ops.
     145 *
     146 * These allow overriding the function for painting the button or
     147 * painting the button decoration.
     148 *
     149 * @param pbutton Push button
     150 * @param ops Push button ops
    148151 * @param arg Decoration ops argument
    149152 */
    150 void ui_pbutton_set_decor_ops(ui_pbutton_t *pbutton,
    151     ui_pbutton_decor_ops_t *ops, void *arg)
    152 {
    153         pbutton->decor_ops = ops;
    154         pbutton->decor_arg = arg;
     153void ui_pbutton_set_ops(ui_pbutton_t *pbutton, ui_pbutton_ops_t *ops, void *arg)
     154{
     155        pbutton->ops = ops;
     156        pbutton->ops_arg = arg;
    155157}
    156158
     
    379381        }
    380382
    381         if (pbutton->decor_ops != NULL && pbutton->decor_ops->paint != NULL) {
     383        if (pbutton->ops != NULL && pbutton->ops->decor_paint != NULL) {
    382384                /* Custom decoration */
    383                 rc = pbutton->decor_ops->paint(pbutton, pbutton->decor_arg,
     385                rc = pbutton->ops->decor_paint(pbutton, pbutton->ops_arg,
    384386                    &pos);
    385387                if (rc != EOK)
     
    503505errno_t ui_pbutton_paint(ui_pbutton_t *pbutton)
    504506{
    505         if (pbutton->res->textmode)
     507        if (pbutton->ops != NULL && pbutton->ops->paint != NULL) {
     508                /* Custom paint routine */
     509                return pbutton->ops->paint(pbutton, pbutton->ops_arg);
     510        } else if (pbutton->res->textmode) {
    506511                return ui_pbutton_paint_text(pbutton);
    507         else
     512        } else {
    508513                return ui_pbutton_paint_gfx(pbutton);
     514        }
    509515}
    510516
Note: See TracChangeset for help on using the changeset viewer.