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


Ignore:
Timestamp:
2020-10-15T10:05:42Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8ef48ece
Parents:
4ed00d3
git-author:
Jiri Svoboda <jiri@…> (2020-10-14 19:05:34)
git-committer:
Jiri Svoboda <jiri@…> (2020-10-15 10:05:42)
Message:

Push button needs to handle position events itself

Also, release event should release the button regardless if it is
positioned inside or outside.

File:
1 edited

Legend:

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

    r4ed00d3 rfaca61b8  
    3939#include <gfx/render.h>
    4040#include <gfx/text.h>
     41#include <io/pos_event.h>
    4142#include <stdlib.h>
    4243#include <str.h>
     
    408409}
    409410
     411/** Handle push button position event.
     412 *
     413 * @param pbutton Push button
     414 * @param pos_event Position event
     415 */
     416void ui_pbutton_pos_event(ui_pbutton_t *pbutton, pos_event_t *event)
     417{
     418        gfx_coord2_t pos;
     419
     420        pos.x = event->hpos;
     421        pos.y = event->vpos;
     422
     423        if (gfx_pix_inside_rect(&pos, &pbutton->rect)) {
     424                if (event->type == POS_PRESS) {
     425                        ui_pbutton_press(pbutton);
     426                        (void) ui_pbutton_paint(pbutton);
     427                }
     428        }
     429
     430        if (event->type == POS_RELEASE && pbutton->held) {
     431                ui_pbutton_release(pbutton);
     432                (void) ui_pbutton_paint(pbutton);
     433        }
     434}
     435
    410436/** @}
    411437 */
Note: See TracChangeset for help on using the changeset viewer.