Changeset 211fd68 in mainline for uspace/lib/ui
- Timestamp:
- 2024-03-08T10:41:31Z (19 months ago)
- 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)
- Location:
- uspace/lib/ui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/include/ui/wdecor.h
rcd27cd1 r211fd68 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 44 44 #include <types/ui/event.h> 45 45 #include <types/ui/resource.h> 46 #include <types/ui/ui.h> 46 47 #include <types/ui/wdecor.h> 47 48 … … 58 59 extern ui_evclaim_t ui_wdecor_kbd_event(ui_wdecor_t *, kbd_event_t *); 59 60 extern 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 *,61 extern void ui_wdecor_rect_from_app(ui_t *, ui_wdecor_style_t, gfx_rect_t *, 61 62 gfx_rect_t *); 62 63 extern void ui_wdecor_app_from_rect(ui_wdecor_style_t, gfx_rect_t *, -
uspace/lib/ui/src/wdecor.c
rcd27cd1 r211fd68 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 45 45 #include <ui/paint.h> 46 46 #include <ui/pbutton.h> 47 #include <ui/ui.h> 47 48 #include <ui/wdecor.h> 48 49 #include "../private/resource.h" … … 94 95 /** Window resizing edge height */ 95 96 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, 96 101 /** Title bar height */ 97 102 wdecor_tbar_h = 22, … … 860 865 * and its decoration. 861 866 * 867 * @param ui UI 862 868 * @param style Decoration style 863 869 * @param app Application area rectangle 864 870 * @param rect Place to store (outer) window decoration rectangle 865 871 */ 866 void ui_wdecor_rect_from_app(ui_wdecor_style_t style, gfx_rect_t *app, 867 gfx_rect_t *rect) 868 { 872 void 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; 869 877 *rect = *app; 870 878 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 871 888 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; 880 897 } 881 898 -
uspace/lib/ui/test/wdecor.c
rcd27cd1 r211fd68 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 34 34 #include <ui/pbutton.h> 35 35 #include <ui/resource.h> 36 #include <ui/ui.h> 36 37 #include <ui/wdecor.h> 37 38 #include "../private/wdecor.h" … … 1322 1323 PCUT_TEST(rect_from_app) 1323 1324 { 1325 errno_t rc; 1326 ui_t *ui = NULL; 1324 1327 gfx_rect_t arect; 1325 1328 gfx_rect_t rect; 1329 1330 rc = ui_create_disp(NULL, &ui); 1331 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1326 1332 1327 1333 arect.p0.x = 14; … … 1330 1336 arect.p1.y = 196; 1331 1337 1332 ui_wdecor_rect_from_app(ui _wds_none, &arect, &rect);1338 ui_wdecor_rect_from_app(ui, ui_wds_none, &arect, &rect); 1333 1339 1334 1340 PCUT_ASSERT_INT_EQUALS(14, rect.p0.x); … … 1337 1343 PCUT_ASSERT_INT_EQUALS(196, rect.p1.y); 1338 1344 1339 ui_wdecor_rect_from_app(ui _wds_frame, &arect, &rect);1345 ui_wdecor_rect_from_app(ui, ui_wds_frame, &arect, &rect); 1340 1346 1341 1347 PCUT_ASSERT_INT_EQUALS(10, rect.p0.x); … … 1344 1350 PCUT_ASSERT_INT_EQUALS(200, rect.p1.y); 1345 1351 1346 ui_wdecor_rect_from_app(ui _wds_decorated, &arect, &rect);1352 ui_wdecor_rect_from_app(ui, ui_wds_decorated, &arect, &rect); 1347 1353 1348 1354 PCUT_ASSERT_INT_EQUALS(10, rect.p0.x); … … 1351 1357 PCUT_ASSERT_INT_EQUALS(200, rect.p1.y); 1352 1358 1359 ui_destroy(ui); 1353 1360 } 1354 1361
Note:
See TracChangeset
for help on using the changeset viewer.