Changeset 211fd68 in mainline for uspace/lib/ui


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/lib/ui
Files:
3 edited

Legend:

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

    rcd27cd1 r211fd68  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4444#include <types/ui/event.h>
    4545#include <types/ui/resource.h>
     46#include <types/ui/ui.h>
    4647#include <types/ui/wdecor.h>
    4748
     
    5859extern ui_evclaim_t ui_wdecor_kbd_event(ui_wdecor_t *, kbd_event_t *);
    5960extern ui_evclaim_t ui_wdecor_pos_event(ui_wdecor_t *, pos_event_t *);
    60 extern void ui_wdecor_rect_from_app(ui_wdecor_style_t, gfx_rect_t *,
     61extern void ui_wdecor_rect_from_app(ui_t *, ui_wdecor_style_t, gfx_rect_t *,
    6162    gfx_rect_t *);
    6263extern void ui_wdecor_app_from_rect(ui_wdecor_style_t, gfx_rect_t *,
  • uspace/lib/ui/src/wdecor.c

    rcd27cd1 r211fd68  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4545#include <ui/paint.h>
    4646#include <ui/pbutton.h>
     47#include <ui/ui.h>
    4748#include <ui/wdecor.h>
    4849#include "../private/resource.h"
     
    9495        /** Window resizing edge height */
    9596        wdecor_edge_h = 4,
     97        /** Window resizing edge witdth */
     98        wdecor_edge_w_text = 1,
     99        /** Window resizing edge height */
     100        wdecor_edge_h_text = 1,
    96101        /** Title bar height */
    97102        wdecor_tbar_h = 22,
     
    860865 * and its decoration.
    861866 *
     867 * @param ui UI
    862868 * @param style Decoration style
    863869 * @param app Application area rectangle
    864870 * @param rect Place to store (outer) window decoration rectangle
    865871 */
    866 void ui_wdecor_rect_from_app(ui_wdecor_style_t style, gfx_rect_t *app,
    867     gfx_rect_t *rect)
    868 {
     872void ui_wdecor_rect_from_app(ui_t *ui, ui_wdecor_style_t style,
     873    gfx_rect_t *app, gfx_rect_t *rect)
     874{
     875        bool textmode;
     876        gfx_coord_t edge_w, edge_h;
    869877        *rect = *app;
    870878
     879        textmode = ui_is_textmode(ui);
     880        if (textmode) {
     881                edge_w = wdecor_edge_w_text;
     882                edge_h = wdecor_edge_h_text;
     883        } else {
     884                edge_w = wdecor_edge_w;
     885                edge_h = wdecor_edge_h;
     886        }
     887
    871888        if ((style & ui_wds_frame) != 0) {
    872                 rect->p0.x -= wdecor_edge_w;
    873                 rect->p0.y -= wdecor_edge_h;
    874                 rect->p1.x += wdecor_edge_w;
    875                 rect->p1.y += wdecor_edge_h;
    876         }
    877 
    878         if ((style & ui_wds_titlebar) != 0)
    879                 rect->p0.y -= 22;
     889                rect->p0.x -= edge_w;
     890                rect->p0.y -= edge_h;
     891                rect->p1.x += edge_w;
     892                rect->p1.y += edge_h;
     893        }
     894
     895        if ((style & ui_wds_titlebar) != 0 && !textmode)
     896                rect->p0.y -= wdecor_tbar_h;
    880897}
    881898
  • uspace/lib/ui/test/wdecor.c

    rcd27cd1 r211fd68  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3434#include <ui/pbutton.h>
    3535#include <ui/resource.h>
     36#include <ui/ui.h>
    3637#include <ui/wdecor.h>
    3738#include "../private/wdecor.h"
     
    13221323PCUT_TEST(rect_from_app)
    13231324{
     1325        errno_t rc;
     1326        ui_t *ui = NULL;
    13241327        gfx_rect_t arect;
    13251328        gfx_rect_t rect;
     1329
     1330        rc = ui_create_disp(NULL, &ui);
     1331        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    13261332
    13271333        arect.p0.x = 14;
     
    13301336        arect.p1.y = 196;
    13311337
    1332         ui_wdecor_rect_from_app(ui_wds_none, &arect, &rect);
     1338        ui_wdecor_rect_from_app(ui, ui_wds_none, &arect, &rect);
    13331339
    13341340        PCUT_ASSERT_INT_EQUALS(14, rect.p0.x);
     
    13371343        PCUT_ASSERT_INT_EQUALS(196, rect.p1.y);
    13381344
    1339         ui_wdecor_rect_from_app(ui_wds_frame, &arect, &rect);
     1345        ui_wdecor_rect_from_app(ui, ui_wds_frame, &arect, &rect);
    13401346
    13411347        PCUT_ASSERT_INT_EQUALS(10, rect.p0.x);
     
    13441350        PCUT_ASSERT_INT_EQUALS(200, rect.p1.y);
    13451351
    1346         ui_wdecor_rect_from_app(ui_wds_decorated, &arect, &rect);
     1352        ui_wdecor_rect_from_app(ui, ui_wds_decorated, &arect, &rect);
    13471353
    13481354        PCUT_ASSERT_INT_EQUALS(10, rect.p0.x);
     
    13511357        PCUT_ASSERT_INT_EQUALS(200, rect.p1.y);
    13521358
     1359        ui_destroy(ui);
    13531360}
    13541361
Note: See TracChangeset for help on using the changeset viewer.