Changeset 211fd68 in mainline for uspace/app


Ignore:
Timestamp:
2024-03-08T10:41:31Z (19 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
0a411bbf
Parents:
cd27cd1
git-author:
Jiri Svoboda <jiri@…> (2024-03-07 18:41:21)
git-committer:
Jiri Svoboda <jiri@…> (2024-03-08 10:41:31)
Message:

Add text mode support to Barber

Location:
uspace/app
Files:
30 added
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/aboutos/meson.build

    rcd27cd1 r211fd68  
    3535        input : _images,
    3636        output : [ 'images.zip' ],
    37         command : [ mkarray, '@OUTDIR@', 'images', 'image', uspace_as_prolog, '.data', '@INPUT@' ],
     37        command : [ mkarray, '@OUTDIR@', 'images', 'image', 'image', uspace_as_prolog, '.data', '@INPUT@' ],
    3838)
    3939_imgs_s = custom_target('aboutos_images.s',
  • uspace/app/barber/barber.c

    rcd27cd1 r211fd68  
    5050#include <ui/image.h>
    5151#include "images.h"
     52#include "images_tiny.h"
    5253
    5354#define NAME  "barber"
     
    6061#define MIN_LOAD  (LOAD_UNIT / 4)
    6162#define MAX_LOAD  (LOAD_UNIT / 3)
    62 
    63 #define FRAME_WIDTH   59
    64 #define FRAME_HEIGHT  192
    6563
    6664#define LED_PERIOD  1000000
     
    9795static unsigned int frame = 0;
    9896static unsigned int fps = MIN_FPS;
     97static gfx_coord_t frame_width;
     98static gfx_coord_t frame_height;
    9999
    100100static void led_timer_callback(void *);
     
    119119}
    120120
    121 static bool decode_frames(gfx_context_t *gc)
     121static bool decode_frames(gfx_context_t *gc, image_t *img)
    122122{
    123123        gfx_rect_t rect;
     
    125125
    126126        for (unsigned int i = 0; i < FRAMES; i++) {
    127                 rc = decode_tga_gz(gc, images[i].addr, images[i].size,
     127                rc = decode_tga_gz(gc, img[i].addr, img[i].size,
    128128                    &frame_bmp[i], &rect);
    129129                if (rc != EOK) {
     
    132132                }
    133133
    134                 (void) rect;
     134                (void)rect;
    135135        }
    136136
     
    238238        rect.p0.x = 0;
    239239        rect.p0.y = 0;
    240         rect.p1.x = FRAME_WIDTH;
    241         rect.p1.y = FRAME_HEIGHT;
     240        rect.p1.x = frame_width;
     241        rect.p1.y = frame_height;
    242242
    243243        ui_image_set_bmp(frame_img, frame_bmp[frame], &rect);
     
    299299int main(int argc, char *argv[])
    300300{
    301         const char *display_spec = UI_DISPLAY_DEFAULT;
     301        const char *display_spec = UI_ANY_DEFAULT;
    302302        barber_t barber;
    303303        ui_t *ui;
     
    310310        gfx_context_t *gc;
    311311        gfx_coord2_t off;
     312        image_t *img;
    312313        int i;
    313314
     
    355356        }
    356357
     358        if (ui_is_textmode(ui)) {
     359                frame_width = 10;
     360                frame_height = 16;
     361        } else {
     362                frame_width = 59;
     363                frame_height = 192;
     364        }
     365
    357366        rect.p0.x = 0;
    358367        rect.p0.y = 0;
    359         rect.p1.x = FRAME_WIDTH;
    360         rect.p1.y = FRAME_HEIGHT;
     368        rect.p1.x = frame_width;
     369        rect.p1.y = frame_height;
    361370
    362371        ui_wnd_params_init(&params);
     
    367376         * to rect
    368377         */
    369         ui_wdecor_rect_from_app(params.style, &rect, &wrect);
     378        ui_wdecor_rect_from_app(ui, params.style, &rect, &wrect);
    370379        off = wrect.p0;
    371380        gfx_rect_rtranslate(&off, &wrect, &params.rect);
     
    384393        ui_window_set_cb(window, &window_cb, (void *) &barber);
    385394
    386         if (!decode_frames(gc))
     395        img = ui_is_textmode(ui) ? image_tinys : images;
     396
     397        if (!decode_frames(gc, img))
    387398                return 1;
    388399
  • uspace/app/barber/meson.build

    rcd27cd1 r211fd68  
    6262)
    6363
     64_images_tiny = files(
     65        'gfx-tiny/frame01t.tga.gz',
     66        'gfx-tiny/frame02t.tga.gz',
     67        'gfx-tiny/frame03t.tga.gz',
     68        'gfx-tiny/frame04t.tga.gz',
     69        'gfx-tiny/frame05t.tga.gz',
     70        'gfx-tiny/frame06t.tga.gz',
     71        'gfx-tiny/frame07t.tga.gz',
     72        'gfx-tiny/frame08t.tga.gz',
     73        'gfx-tiny/frame09t.tga.gz',
     74        'gfx-tiny/frame10t.tga.gz',
     75        'gfx-tiny/frame11t.tga.gz',
     76        'gfx-tiny/frame12t.tga.gz',
     77        'gfx-tiny/frame13t.tga.gz',
     78        'gfx-tiny/frame14t.tga.gz',
     79        'gfx-tiny/frame15t.tga.gz',
     80        'gfx-tiny/frame16t.tga.gz',
     81        'gfx-tiny/frame17t.tga.gz',
     82        'gfx-tiny/frame18t.tga.gz',
     83        'gfx-tiny/frame19t.tga.gz',
     84        'gfx-tiny/frame20t.tga.gz',
     85        'gfx-tiny/frame21t.tga.gz',
     86        'gfx-tiny/frame22t.tga.gz',
     87        'gfx-tiny/frame23t.tga.gz',
     88        'gfx-tiny/frame24t.tga.gz',
     89        'gfx-tiny/frame25t.tga.gz',
     90        'gfx-tiny/frame26t.tga.gz',
     91        'gfx-tiny/frame27t.tga.gz',
     92        'gfx-tiny/frame28t.tga.gz',
     93        'gfx-tiny/frame29t.tga.gz',
     94        'gfx-tiny/frame30t.tga.gz',
     95)
     96
    6497_tarball = custom_target('barber_images.tar',
    6598        input: _images,
     
    70103# TODO
    71104
     105# Normal images
     106
    72107_images_zip = custom_target('barber_images.zip',
    73108        input : _images,
    74109        output : [ 'images.zip' ],
    75         command : [ mkarray, '@OUTDIR@', 'images', 'image', uspace_as_prolog, '.data', '@INPUT@' ],
     110        command : [ mkarray, '@OUTDIR@', 'images', 'image', 'image', uspace_as_prolog, '.data', '@INPUT@' ],
    76111)
    77112_imgs_s = custom_target('barber_images.s',
     
    94129)
    95130
    96 src = [ files('barber.c'), _imgs_s, _imgs_h, _imgs_desc_c ]
     131# Tiny images
     132
     133_images_tiny_zip = custom_target('barber_images_tiny.zip',
     134        input : _images_tiny,
     135        output : [ 'images_tiny.zip' ],
     136        command : [ mkarray, '@OUTDIR@', 'images_tiny', 'image', 'image_tiny', uspace_as_prolog, '.data', '@INPUT@' ],
     137)
     138_imgs_tiny_s = custom_target('barber_images_tiny.s',
     139        input : _images_tiny_zip,
     140        output : [ 'images_tiny.s' ],
     141        command : [ unzip, '-p', '@INPUT@', 'images_tiny.s' ],
     142        capture : true,
     143)
     144_imgs_tiny_h = custom_target('barber_images_tiny.h',
     145        input : _images_tiny_zip,
     146        output : [ 'images_tiny.h' ],
     147        command : [ unzip, '-p', '@INPUT@', 'images_tiny.h' ],
     148        capture : true,
     149)
     150_imgs_tiny_desc_c = custom_target('barber_images_tiny_desc.c',
     151        input : _images_tiny_zip,
     152        output : [ 'images_tiny_desc.c' ],
     153        command : [ unzip, '-p', '@INPUT@', 'images_tiny_desc.c' ],
     154        capture : true,
     155)
     156
     157src = [ files('barber.c'), _imgs_s, _imgs_h, _imgs_desc_c,
     158    _imgs_tiny_s, _imgs_tiny_h, _imgs_tiny_desc_c ]
  • uspace/app/fontedit/fontedit.c

    rcd27cd1 r211fd68  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    787787         * to rect
    788788         */
    789         ui_wdecor_rect_from_app(params.style, &rect, &wrect);
     789        ui_wdecor_rect_from_app(ui, params.style, &rect, &wrect);
    790790        off = wrect.p0;
    791791        gfx_rect_rtranslate(&off, &wrect, &params.rect);
  • uspace/app/gfxdemo/gfxdemo.c

    rcd27cd1 r211fd68  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    11601160         * to rect
    11611161         */
    1162         ui_wdecor_rect_from_app(params.style, &rect, &wrect);
     1162        ui_wdecor_rect_from_app(ui, params.style, &rect, &wrect);
    11631163        off = wrect.p0;
    11641164        gfx_rect_rtranslate(&off, &wrect, &params.rect);
  • uspace/app/terminal/terminal.c

    rcd27cd1 r211fd68  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * Copyright (c) 2012 Petr Koupy
    44 * All rights reserved.
     
    974974                wparams.placement = ui_wnd_place_top_left;
    975975
     976        rc = ui_create(display_spec, &term->ui);
     977        if (rc != EOK) {
     978                printf("Error creating UI on %s.\n", display_spec);
     979                goto error;
     980        }
     981
    976982        /*
    977983         * Compute window rectangle such that application area corresponds
    978984         * to rect
    979985         */
    980         ui_wdecor_rect_from_app(wparams.style, &rect, &wrect);
     986        ui_wdecor_rect_from_app(term->ui, wparams.style, &rect, &wrect);
    981987        off = wrect.p0;
    982988        gfx_rect_rtranslate(&off, &wrect, &wparams.rect);
    983989
    984990        term->off = off;
    985 
    986         rc = ui_create(display_spec, &term->ui);
    987         if (rc != EOK) {
    988                 printf("Error creating UI on %s.\n", display_spec);
    989                 goto error;
    990         }
    991991
    992992        rc = ui_window_create(term->ui, &wparams, &term->window);
  • uspace/app/viewer/viewer.c

    rcd27cd1 r211fd68  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * Copyright (c) 2013 Martin Decky
    44 * All rights reserved.
     
    314314         * to rect
    315315         */
    316         ui_wdecor_rect_from_app(params.style, &lrect, &wrect);
     316        ui_wdecor_rect_from_app(ui, params.style, &lrect, &wrect);
    317317        off = wrect.p0;
    318318        gfx_rect_rtranslate(&off, &wrect, &rect);
Note: See TracChangeset for help on using the changeset viewer.