Changeset 806d761 in mainline for uspace/lib/ui


Ignore:
Timestamp:
2024-02-07T23:44:59Z (18 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
242e3c3
Parents:
74cb6610
Message:

Start menu should have 'open in terminal' functionality

Makes it easier for the user and if we are running in console mode,
we correctly start the application, instead of failing to start a
terminal.

Location:
uspace/lib/ui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/include/ui/checkbox.h

    r74cb6610 r806d761  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    5252extern void ui_checkbox_set_cb(ui_checkbox_t *, ui_checkbox_cb_t *, void *);
    5353extern void ui_checkbox_set_rect(ui_checkbox_t *, gfx_rect_t *);
     54extern bool ui_checkbox_get_checked(ui_checkbox_t *);
     55extern void ui_checkbox_set_checked(ui_checkbox_t *, bool);
    5456extern errno_t ui_checkbox_paint(ui_checkbox_t *);
    5557extern void ui_checkbox_press(ui_checkbox_t *);
  • uspace/lib/ui/src/checkbox.c

    r74cb6610 r806d761  
    11/*
    2  * Copyright (c) 2022 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    139139}
    140140
    141 /** Set button rectangle.
    142  *
    143  * @param checkbox Button
    144  * @param rect New button rectangle
     141/** Set check box rectangle.
     142 *
     143 * @param checkbox Check box
     144 * @param rect New check box rectangle
    145145 */
    146146void ui_checkbox_set_rect(ui_checkbox_t *checkbox, gfx_rect_t *rect)
    147147{
    148148        checkbox->rect = *rect;
     149}
     150
     151/** Return if check box is checked.
     152 *
     153 * @param checkbox Check box
     154 * @return @c true iff check box is checked
     155 */
     156bool ui_checkbox_get_checked(ui_checkbox_t *checkbox)
     157{
     158        return checkbox->checked;
     159}
     160
     161/** Set check box checked state.
     162 *
     163 * @param checkbox Check box
     164 * @param checked @c true iff checkbox should be checked
     165 */
     166void ui_checkbox_set_checked(ui_checkbox_t *checkbox, bool checked)
     167{
     168        checkbox->checked = checked;
    149169}
    150170
  • uspace/lib/ui/test/checkbox.c

    r74cb6610 r806d761  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    151151}
    152152
     153/** Get check box checked returns internal field */
     154PCUT_TEST(get_checked)
     155{
     156        ui_checkbox_t *checkbox;
     157        errno_t rc;
     158
     159        rc = ui_checkbox_create(NULL, "Hello", &checkbox);
     160        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     161
     162        checkbox->checked = false;
     163        PCUT_ASSERT_FALSE(ui_checkbox_get_checked(checkbox));
     164        checkbox->checked = true;
     165        PCUT_ASSERT_TRUE(ui_checkbox_get_checked(checkbox));
     166
     167        ui_checkbox_destroy(checkbox);
     168}
     169
     170/** Set check box checked sets internal field */
     171PCUT_TEST(set_checked)
     172{
     173        ui_checkbox_t *checkbox;
     174        errno_t rc;
     175
     176        rc = ui_checkbox_create(NULL, "Hello", &checkbox);
     177        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     178
     179        ui_checkbox_set_checked(checkbox, true);
     180        PCUT_ASSERT_TRUE(checkbox->checked);
     181        ui_checkbox_set_checked(checkbox, false);
     182        PCUT_ASSERT_FALSE(checkbox->checked);
     183
     184        ui_checkbox_destroy(checkbox);
     185}
     186
    153187/** Paint check box in graphics mode */
    154188PCUT_TEST(paint_gfx)
Note: See TracChangeset for help on using the changeset viewer.