Changeset 9389aaa in mainline


Ignore:
Timestamp:
2026-05-15T19:38:36Z (3 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
08499f0
Parents:
2f1be23
Message:

Display real progress value.

File:
1 edited

Legend:

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

    r2f1be23 r9389aaa  
    4040#include <gfx/text.h>
    4141#include <io/pos_event.h>
     42#include <stdio.h>
    4243#include <stdlib.h>
    4344#include <str.h>
     
    153154        gfx_coord2_t pos;
    154155        gfx_text_fmt_t fmt;
     156        char buf[6];
    155157        errno_t rc;
    156158
     
    184186        fmt.valign = gfx_valign_center;
    185187
    186         rc = gfx_puttext(&pos, &fmt, "42 %");
     188        snprintf(buf, sizeof(buf), "%u %%", progress->value);
     189
     190        rc = gfx_puttext(&pos, &fmt, buf);
    187191        if (rc != EOK)
    188192                goto error;
     
    207211        gfx_rect_t inside;
    208212        gfx_rect_t part;
     213        gfx_coord_t width;
    209214        errno_t rc;
    210215
     
    221226        }
    222227
     228        width = inside.p1.x - inside.p0.x;
     229
    223230        /* Paint completed part. */
    224231        part.p0 = inside.p0;
    225         part.p1.x = (inside.p0.x + inside.p1.x) / 2;
     232        part.p1.x = inside.p0.x + width * progress->value / 100;
    226233        part.p1.y = inside.p1.y;
    227234
Note: See TracChangeset for help on using the changeset viewer.