Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gui/button.c

    r5a6cc679 ra35b458  
    5050{
    5151        button_t *btn = (button_t *) widget;
    52        
     52
    5353        surface_t *surface = window_claim(btn->widget.window);
    5454        if (!surface)
    5555                window_yield(btn->widget.window);
    56        
     56
    5757        source_t source;
    5858        source_init(&source);
    59        
     59
    6060        drawctx_t drawctx;
    6161        drawctx_init(&drawctx, surface);
    62        
     62
    6363        drawctx_set_source(&drawctx, &btn->background);
    6464        drawctx_transfer(&drawctx, widget->hpos, widget->vpos,
    6565            widget->width, widget->height);
    66        
     66
    6767        if ((widget->width >= 8) && (widget->height >= 8)) {
    6868                drawctx_set_source(&drawctx, &source);
     
    7070                    widget->width - 6, widget->height - 6, color_highlight,
    7171                    color_shadow);
    72                
     72
    7373                drawctx_set_source(&drawctx, &btn->foreground);
    7474                drawctx_transfer(&drawctx, widget->hpos + 4, widget->vpos + 4,
    7575                    widget->width - 8, widget->height - 8);
    7676        }
    77        
     77
    7878        sysarg_t cpt_width;
    7979        sysarg_t cpt_height;
    8080        font_get_box(btn->font, btn->caption, &cpt_width, &cpt_height);
    81        
     81
    8282        if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
    8383                sysarg_t x = ((widget->width - cpt_width) / 2) + widget->hpos;
    8484                sysarg_t y = ((widget->height - cpt_height) / 2) + widget->vpos;
    85                
     85
    8686                drawctx_set_source(&drawctx, &btn->text);
    8787                drawctx_set_font(&drawctx, btn->font);
    88                
     88
    8989                if (btn->caption)
    9090                        drawctx_print(&drawctx, btn->caption, x, y);
    9191        }
    92        
     92
    9393        window_yield(btn->widget.window);
    9494}
     
    104104{
    105105        button_t *btn = (button_t *) widget;
    106        
     106
    107107        deinit_button(btn);
    108108        free(btn);
     
    130130{
    131131        button_t *btn = (button_t *) widget;
    132        
     132
    133133        if (event.key == KC_ENTER && event.type == KEY_PRESS)
    134134                sig_send(&btn->clicked, NULL);
     
    139139        button_t *btn = (button_t *) widget;
    140140        widget->window->focus = widget;
    141        
     141
    142142        // TODO make the click logic more robust (mouse grabbing, mouse moves)
    143143        if (event.btn_num == 1) {
     
    152152{
    153153        widget_init(&btn->widget, parent, data);
    154        
     154
    155155        btn->widget.destroy = button_destroy;
    156156        btn->widget.reconfigure = button_reconfigure;
     
    159159        btn->widget.handle_keyboard_event = button_handle_keyboard_event;
    160160        btn->widget.handle_position_event = button_handle_position_event;
    161        
     161
    162162        source_init(&btn->background);
    163163        source_set_color(&btn->background, background);
    164        
     164
    165165        source_init(&btn->foreground);
    166166        source_set_color(&btn->foreground, foreground);
    167        
     167
    168168        source_init(&btn->text);
    169169        source_set_color(&btn->text, text);
    170        
     170
    171171        if (caption == NULL)
    172172                btn->caption = NULL;
    173173        else
    174174                btn->caption = str_dup(caption);
    175        
     175
    176176        errno_t rc = embedded_font_create(&btn->font, points);
    177177        if (rc != EOK) {
     
    180180                return false;
    181181        }
    182        
     182
    183183        sysarg_t cpt_width;
    184184        sysarg_t cpt_height;
     
    188188        btn->widget.width_ideal = cpt_width + 30;
    189189        btn->widget.height_ideal = cpt_height + 10;
    190        
     190
    191191        return true;
    192192}
     
    198198        if (!btn)
    199199                return NULL;
    200        
     200
    201201        if (init_button(btn, parent, data, caption, points, background, foreground,
    202202            text))
    203203                return btn;
    204        
     204
    205205        free(btn);
    206206        return NULL;
Note: See TracChangeset for help on using the changeset viewer.