Changeset 5713e5f in mainline for uspace/lib/gui


Ignore:
Timestamp:
2014-09-01T19:17:55Z (11 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
21365c0
Parents:
a4666a9 (diff), 00ddb40 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge improvements in the graphics stack.

  • Support for drawing proportional fonts (although no actual font file included yet)
  • Implementation of bilinear filter
Location:
uspace/lib/gui
Files:
7 edited

Legend:

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

    ra4666a9 r5713e5f  
    3838#include <drawctx.h>
    3939#include <surface.h>
     40#include <font/embedded.h>
     41#include <errno.h>
    4042#include "common.h"
    4143#include "window.h"
     
    7678        sysarg_t cpt_width;
    7779        sysarg_t cpt_height;
    78         font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height);
     80        font_get_box(btn->font, btn->caption, &cpt_width, &cpt_height);
    7981       
    8082        if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
     
    8385               
    8486                drawctx_set_source(&drawctx, &btn->text);
    85                 drawctx_set_font(&drawctx, &btn->font);
     87                drawctx_set_font(&drawctx, btn->font);
    8688               
    8789                if (btn->caption)
     
    9698        widget_deinit(&btn->widget);
    9799        free(btn->caption);
    98         font_release(&btn->font);
     100        font_release(btn->font);
    99101}
    100102
     
    171173                btn->caption = str_dup(caption);
    172174       
    173         font_init(&btn->font, FONT_DECODER_EMBEDDED, NULL, points);
     175        int rc = embedded_font_create(&btn->font, points);
     176        if (rc != EOK) {
     177                free(btn->caption);
     178                btn->caption = NULL;
     179                return false;
     180        }
    174181       
    175182        sysarg_t cpt_width;
    176183        sysarg_t cpt_height;
    177         font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height);
     184        font_get_box(btn->font, btn->caption, &cpt_width, &cpt_height);
    178185        btn->widget.width_min = cpt_width + 10;
    179186        btn->widget.height_min = cpt_height + 10;
  • uspace/lib/gui/button.h

    ra4666a9 r5713e5f  
    5252        source_t text;
    5353        char *caption;
    54         font_t font;
     54        font_t *font;
    5555        signal_t clicked;
    5656} button_t;
  • uspace/lib/gui/canvas.c

    ra4666a9 r5713e5f  
    5858        source_init(&source);
    5959        source_set_transform(&source, transform);
    60         source_set_texture(&source, canvas->surface, false);
     60        source_set_texture(&source, canvas->surface,
     61            PIXELMAP_EXTEND_TRANSPARENT_BLACK);
    6162       
    6263        drawctx_t drawctx;
  • uspace/lib/gui/label.c

    ra4666a9 r5713e5f  
    3838#include <drawctx.h>
    3939#include <surface.h>
     40#include <font/embedded.h>
     41#include <errno.h>
    4042#include "window.h"
    4143#include "label.h"
     
    5860        sysarg_t cpt_width;
    5961        sysarg_t cpt_height;
    60         font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height);
     62        font_get_box(lbl->font, lbl->caption, &cpt_width, &cpt_height);
    6163       
    6264        if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
     
    6567               
    6668                drawctx_set_source(&drawctx, &lbl->text);
    67                 drawctx_set_font(&drawctx, &lbl->font);
     69                drawctx_set_font(&drawctx, lbl->font);
    6870               
    6971                if (lbl->caption)
     
    8486                sysarg_t cpt_width;
    8587                sysarg_t cpt_height;
    86                 font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height);
     88                font_get_box(lbl->font, lbl->caption, &cpt_width, &cpt_height);
    8789               
    8890                lbl->widget.width_min = cpt_width + 4;
     
    99101        widget_deinit(&lbl->widget);
    100102        free(lbl->caption);
    101         font_release(&lbl->font);
     103        font_release(lbl->font);
    102104}
    103105
     
    161163                lbl->caption = str_dup(caption);
    162164       
    163         font_init(&lbl->font, FONT_DECODER_EMBEDDED, NULL, points);
     165        int rc = embedded_font_create(&lbl->font, points);
     166        if (rc != EOK) {
     167                free(lbl->caption);
     168                lbl->caption = NULL;
     169                return false;
     170        }
    164171       
    165172        sysarg_t cpt_width;
    166173        sysarg_t cpt_height;
    167         font_get_box(&lbl->font, lbl->caption, &cpt_width, &cpt_height);
     174        font_get_box(lbl->font, lbl->caption, &cpt_width, &cpt_height);
    168175       
    169176        lbl->widget.width_min = cpt_width + 4;
  • uspace/lib/gui/label.h

    ra4666a9 r5713e5f  
    5151        source_t text;
    5252        char *caption;
    53         font_t font;
     53        font_t *font;
    5454        slot_t rewrite;
    5555} label_t;
  • uspace/lib/gui/terminal.c

    ra4666a9 r5713e5f  
    186186        //        for full UTF-32 coverage.
    187187       
    188         uint16_t glyph = fb_font_glyph(field->ch);
     188        uint16_t glyph = fb_font_glyph(field->ch, NULL);
    189189       
    190190        for (unsigned int y = 0; y < FONT_SCANLINES; y++) {
  • uspace/lib/gui/window.c

    ra4666a9 r5713e5f  
    5555#include <drawctx.h>
    5656#include <surface.h>
     57#include <font/embedded.h>
    5758
    5859#include "common.h"
     
    160161        /* Window caption */
    161162       
    162         font_t font;
    163         font_init(&font, FONT_DECODER_EMBEDDED, NULL, 16);
    164        
    165         drawctx_set_font(&drawctx, &font);
     163        font_t *font;
     164        int rc = embedded_font_create(&font, 16);
     165        if (rc != EOK) {
     166                window_yield(widget->window);
     167                return;
     168        }
     169       
     170        drawctx_set_font(&drawctx, font);
    166171        source_set_color(&source, widget->window->is_focused ?
    167172            color_caption_focus : color_caption_unfocus);
     
    169174        sysarg_t cpt_width;
    170175        sysarg_t cpt_height;
    171         font_get_box(&font, widget->window->caption, &cpt_width, &cpt_height);
     176        font_get_box(font, widget->window->caption, &cpt_width, &cpt_height);
    172177       
    173178        bool draw_title =
     
    183188        }
    184189       
    185         font_release(&font);
     190        font_release(font);
    186191        window_yield(widget->window);
    187192}
Note: See TracChangeset for help on using the changeset viewer.