Changeset d8ddf7a in mainline for uspace/lib/ui/src/image.c


Ignore:
Timestamp:
2020-11-22T17:52:37Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2d879f7
Parents:
4f64b7b8
Message:

UI demo should demonstrate image and entry controls

We also add the ability to draw a frame around image control, use
in UI demo and in launcher.

File:
1 edited

Legend:

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

    r4f64b7b8 rd8ddf7a  
    124124}
    125125
     126/** Set image flags.
     127 *
     128 * @param image Image
     129 * @param flags Flags
     130 */
     131void ui_image_set_flags(ui_image_t *image, ui_image_flags_t flags)
     132{
     133        image->flags = flags;
     134}
     135
    126136/** Paint image.
    127137 *
     
    131141errno_t ui_image_paint(ui_image_t *image)
    132142{
     143        gfx_rect_t irect;
    133144        gfx_rect_t srect;
    134145        gfx_coord2_t offs;
     146        errno_t rc;
     147
     148        if ((image->flags & ui_imgf_frame) != 0) {
     149                rc = ui_paint_bevel(image->res->gc, &image->rect,
     150                    image->res->btn_frame_color, image->res->btn_frame_color,
     151                    1, NULL);
     152                if (rc != EOK)
     153                        return rc;
     154        }
    135155
    136156        if (image->bitmap == NULL)
    137157                return EOK;
     158
     159        irect = image->rect;
     160        if ((image->flags & ui_imgf_frame) != 0) {
     161                irect.p0.x++;
     162                irect.p0.y++;
     163                irect.p1.x--;
     164                irect.p1.y--;
     165        }
    138166
    139167        /*
     
    141169         * we need to subtract it.
    142170         */
    143         offs.x = image->rect.p0.x - image->brect.p0.x;
    144         offs.y = image->rect.p0.y - image->brect.p0.y;
     171        offs.x = irect.p0.x - image->brect.p0.x;
     172        offs.y = irect.p0.y - image->brect.p0.y;
    145173
    146174        /*
    147          * Transalte image rectangle back to bitmap coordinate space.
     175         * Translate image rectangle back to bitmap coordinate space.
    148176         * Thus the bitmap will be clipped to the image rectangle.
    149177         */
    150         gfx_rect_rtranslate(&offs, &image->rect, &srect);
     178        gfx_rect_rtranslate(&offs, &irect, &srect);
    151179        return gfx_bitmap_render(image->bitmap, &srect, &offs);
     180
    152181}
    153182
Note: See TracChangeset for help on using the changeset viewer.