Example #1
0
void checkbox_destroy(checkbox *c)
{
    int i;
    for(i = 0; i < BORDER_MAX; ++i)
        fb_rm_rect(c->borders[i]);

    fb_rm_rect(c->selected);

    if(c->clicked)
        rm_touch_handler(&checkbox_touch_handler, c);

    free(c);
}
Example #2
0
int checkbox_touch_handler(touch_event *ev, void *data)
{
    checkbox *box = (checkbox*)data;

    if(box->touch_id == -1 && (ev->changed & TCHNG_ADDED))
    {
        if(!in_rect(ev->x, ev->y, box->x-TOUCH, box->y-TOUCH, CHECKBOX_SIZE+TOUCH*2, CHECKBOX_SIZE+TOUCH*2))
            return -1;

        box->touch_id = ev->id;
        box->hover = fb_add_rect(box->x-TOUCH, box->y-TOUCH, CHECKBOX_SIZE+TOUCH*2, CHECKBOX_SIZE+TOUCH*2, CLR_SECONDARY);
        fb_draw();
    }

    if(box->touch_id != ev->id)
        return -1;

    if(ev->changed & TCHNG_REMOVED)
    {
        if(in_rect(ev->x, ev->y, box->x-TOUCH, box->y-TOUCH, CHECKBOX_SIZE+TOUCH*2, CHECKBOX_SIZE+TOUCH*2))
        {
            (*box->clicked)(box->selected == NULL);
            checkbox_select(box, (box->selected == NULL));
        }

        fb_rm_rect(box->hover);
        box->hover = NULL;
        box->touch_id = -1;

        fb_draw();
    }
    return 0;
}
Example #3
0
void progdots_destroy(progdots *p)
{
    workers_remove(progdots_animate, p);

    int i;
    for(i = 0; i < PROGDOTS_CNT; ++i)
        fb_rm_rect(p->dots[i]);
    free(p);
}
Example #4
0
void button_destroy(button *b)
{
    rm_touch_handler(&button_touch_handler, b);
    keyaction_remove(&button_keyaction_call, b);

    if(b->text)
    {
        fb_rm_rect(b->rect);
        fb_rm_text(b->text);
    }

    free(b);
}
Example #5
0
void checkbox_select(checkbox *c, int select)
{
    if((c->selected != NULL) == (select != 0))
        return;

    if(select)
    {
        c->selected = fb_add_rect(c->x + SELECTED_PADDING, c->y + SELECTED_PADDING,
                                  SELECTED_SIZE, SELECTED_SIZE, CLR_PRIMARY);
    }
    else
    {
        fb_rm_rect(c->selected);
        c->selected = NULL;
    }
}