Changeset 8b22d44 in mainline


Ignore:
Timestamp:
2022-05-20T12:05:26Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0415776
Parents:
ea9024d7
git-author:
Jiri Svoboda <jiri@…> (2022-05-19 18:05:08)
git-committer:
Jiri Svoboda <jiri@…> (2022-05-20 12:05:26)
Message:

Scrollbar buttons should not depress in text mode

Location:
uspace/lib/ui
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/include/types/ui/pbutton.h

    rea9024d7 r8b22d44  
    4343typedef struct ui_pbutton ui_pbutton_t;
    4444
     45/** UI push button flags */
     46typedef enum {
     47        /** Do not depress the button in text mode */
     48        ui_pbf_no_text_depress = 0x1
     49} ui_pbutton_flags_t;
     50
    4551/** Push button callbacks */
    4652typedef struct ui_pbutton_cb {
  • uspace/lib/ui/include/ui/pbutton.h

    rea9024d7 r8b22d44  
    5353extern void ui_pbutton_set_decor_ops(ui_pbutton_t *, ui_pbutton_decor_ops_t *,
    5454    void *);
     55extern void ui_pbutton_set_flags(ui_pbutton_t *, ui_pbutton_flags_t);
    5556extern void ui_pbutton_set_rect(ui_pbutton_t *, gfx_rect_t *);
    5657extern void ui_pbutton_set_default(ui_pbutton_t *, bool);
  • uspace/lib/ui/private/pbutton.h

    rea9024d7 r8b22d44  
    4040#include <gfx/coord.h>
    4141#include <stdbool.h>
     42#include <types/ui/pbutton.h>
    4243
    4344/** Actual structure of push button.
     
    6869        /** Pointer is currently inside */
    6970        bool inside;
     71        /** Push button flags */
     72        ui_pbutton_flags_t flags;
    7073};
    7174
  • uspace/lib/ui/src/pbutton.c

    rea9024d7 r8b22d44  
    152152}
    153153
     154/** Set push button flag.s
     155 *
     156 * @param pbutton Push button
     157 * @param flags Flags
     158 */
     159void ui_pbutton_set_flags(ui_pbutton_t *pbutton, ui_pbutton_flags_t flags)
     160{
     161        pbutton->flags = flags;
     162}
     163
    154164/** Set button rectangle.
    155165 *
     
    377387        errno_t rc;
    378388
    379         depressed = pbutton->held && pbutton->inside;
     389        if ((pbutton->flags & ui_pbf_no_text_depress) == 0)
     390                depressed = pbutton->held && pbutton->inside;
     391        else
     392                depressed = false;
    380393
    381394        rc = gfx_set_color(pbutton->res->gc, pbutton->res->wnd_face_color);
  • uspace/lib/ui/src/scrollbar.c

    rea9024d7 r8b22d44  
    205205            &ui_scrollbar_up_btn_decor_ops, (void *) scrollbar);
    206206
     207        ui_pbutton_set_flags(scrollbar->up_btn, ui_pbf_no_text_depress);
     208
    207209        rc = ui_pbutton_create(resource, down_text, &scrollbar->down_btn);
    208210        if (rc != EOK)
     
    214216        ui_pbutton_set_decor_ops(scrollbar->down_btn,
    215217            &ui_scrollbar_down_btn_decor_ops, (void *) scrollbar);
     218
     219        ui_pbutton_set_flags(scrollbar->down_btn, ui_pbf_no_text_depress);
    216220
    217221        scrollbar->thumb_len = resource->textmode ?
  • uspace/lib/ui/test/pbutton.c

    rea9024d7 r8b22d44  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2022 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    133133}
    134134
     135/** Set flags sets internal field */
     136PCUT_TEST(set_flags)
     137{
     138        ui_pbutton_t *pbutton;
     139        errno_t rc;
     140
     141        rc = ui_pbutton_create(NULL, "Hello", &pbutton);
     142        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     143
     144        ui_pbutton_set_flags(pbutton, ui_pbf_no_text_depress);
     145        PCUT_ASSERT_INT_EQUALS(ui_pbf_no_text_depress, pbutton->flags);
     146
     147        ui_pbutton_destroy(pbutton);
     148}
     149
    135150/** Set button rectangle sets internal field */
    136151PCUT_TEST(set_rect)
Note: See TracChangeset for help on using the changeset viewer.