Changeset dc0f6e4c in mainline
- Timestamp:
- 2023-10-24T16:50:46Z (13 months ago)
- Parents:
- 29ed06d
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-10-22 20:38:41)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-10-24 16:50:46)
- Location:
- uspace/lib
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/include/types/display/wndresize.h
r29ed06d rdc0f6e4c 38 38 /** Window resize type */ 39 39 typedef enum { 40 display_wr_none = 0, 41 40 42 display_wr_top = 0x1, 41 43 display_wr_left = 0x2, -
uspace/lib/display/src/wndresize.c
r29ed06d rdc0f6e4c 75 75 bool display_wndrsz_valid(display_wnd_rsztype_t rsztype) 76 76 { 77 bool valid;78 79 valid = false;80 81 77 switch (rsztype) { 82 78 case display_wr_top: … … 88 84 case display_wr_top_right: 89 85 case display_wr_bottom_left: 90 valid = true; 91 break; 86 return true; 87 88 case display_wr_none: 89 return false; 92 90 } 93 91 94 return valid;92 return false; 95 93 } 96 94 -
uspace/lib/ui/include/types/ui/wdecor.h
r29ed06d rdc0f6e4c 40 40 #include <types/common.h> 41 41 #include <types/ui/cursor.h> 42 #include <types/display/wndresize.h> 42 43 43 44 struct ui_wdecor; … … 67 68 } ui_wdecor_style_t; 68 69 69 /** Window resize type */70 typedef enum {71 ui_wr_none = 0,72 73 ui_wr_top = 0x1,74 ui_wr_left = 0x2,75 ui_wr_bottom = 0x4,76 ui_wr_right = 0x8,77 78 ui_wr_top_left = ui_wr_top | ui_wr_left,79 ui_wr_bottom_left = ui_wr_bottom | ui_wr_left,80 ui_wr_bottom_right = ui_wr_bottom | ui_wr_right,81 ui_wr_top_right = ui_wr_top | ui_wr_right82 } ui_wdecor_rsztype_t;83 84 70 /** Window decoration callbacks */ 85 71 typedef struct ui_wdecor_cb { … … 93 79 void (*close)(ui_wdecor_t *, void *); 94 80 void (*move)(ui_wdecor_t *, void *, gfx_coord2_t *, sysarg_t); 95 void (*resize)(ui_wdecor_t *, void *, ui_wdecor_rsztype_t,81 void (*resize)(ui_wdecor_t *, void *, display_wnd_rsztype_t, 96 82 gfx_coord2_t *, sysarg_t); 97 83 void (*set_cursor)(ui_wdecor_t *, void *, ui_stock_cursor_t); -
uspace/lib/ui/private/wdecor.h
r29ed06d rdc0f6e4c 108 108 extern void ui_wdecor_close(ui_wdecor_t *); 109 109 extern void ui_wdecor_move(ui_wdecor_t *, gfx_coord2_t *, sysarg_t); 110 extern void ui_wdecor_resize(ui_wdecor_t *, ui_wdecor_rsztype_t,110 extern void ui_wdecor_resize(ui_wdecor_t *, display_wnd_rsztype_t, 111 111 gfx_coord2_t *, sysarg_t); 112 112 extern void ui_wdecor_set_cursor(ui_wdecor_t *, ui_stock_cursor_t); … … 116 116 extern errno_t ui_wdecor_sysmenu_hdl_paint(ui_wdecor_t *, gfx_rect_t *); 117 117 extern void ui_wdecor_frame_pos_event(ui_wdecor_t *, pos_event_t *); 118 extern ui_wdecor_rsztype_t ui_wdecor_get_rsztype(ui_wdecor_t *,118 extern display_wnd_rsztype_t ui_wdecor_get_rsztype(ui_wdecor_t *, 119 119 gfx_coord2_t *); 120 extern ui_stock_cursor_t ui_wdecor_cursor_from_rsztype( ui_wdecor_rsztype_t);120 extern ui_stock_cursor_t ui_wdecor_cursor_from_rsztype(display_wnd_rsztype_t); 121 121 122 122 #endif -
uspace/lib/ui/src/wdecor.c
r29ed06d rdc0f6e4c 650 650 * @param pos_id Positioning device ID 651 651 */ 652 void ui_wdecor_resize(ui_wdecor_t *wdecor, ui_wdecor_rsztype_t rsztype,652 void ui_wdecor_resize(ui_wdecor_t *wdecor, display_wnd_rsztype_t rsztype, 653 653 gfx_coord2_t *pos, sysarg_t pos_id) 654 654 { … … 912 912 * @return Resize type 913 913 */ 914 ui_wdecor_rsztype_t ui_wdecor_get_rsztype(ui_wdecor_t *wdecor,914 display_wnd_rsztype_t ui_wdecor_get_rsztype(ui_wdecor_t *wdecor, 915 915 gfx_coord2_t *pos) 916 916 { … … 923 923 /* Window not resizable? */ 924 924 if ((wdecor->style & ui_wds_resizable) == 0) 925 return ui_wr_none;925 return display_wr_none; 926 926 927 927 /* Window is maximized? */ 928 928 if (wdecor->maximized) 929 return ui_wr_none;929 return display_wr_none; 930 930 931 931 /* Position not inside window? */ 932 932 if (!gfx_pix_inside_rect(pos, &wdecor->rect)) 933 return ui_wr_none;933 return display_wr_none; 934 934 935 935 /* Position is within edge width from the outside */ … … 950 950 /* Top-left corner */ 951 951 if (edge && cleft && ctop) 952 return ui_wr_top_left;952 return display_wr_top_left; 953 953 954 954 /* Top-right corner */ 955 955 if (edge && cright && ctop) 956 return ui_wr_top_right;956 return display_wr_top_right; 957 957 958 958 /* Bottom-left corner */ 959 959 if (edge && cleft && cbottom) 960 return ui_wr_bottom_left;960 return display_wr_bottom_left; 961 961 962 962 /* Bottom-right corner */ 963 963 if (edge && cright && cbottom) 964 return ui_wr_bottom_right;964 return display_wr_bottom_right; 965 965 966 966 /* Left edge */ 967 967 if (eleft) 968 return ui_wr_left;968 return display_wr_left; 969 969 970 970 /* Right edge */ 971 971 if (eright) 972 return ui_wr_right;972 return display_wr_right; 973 973 974 974 /* Top edge */ 975 975 if (etop) 976 return ui_wr_top;976 return display_wr_top; 977 977 978 978 /* Bottom edge */ 979 979 if (ebottom) 980 return ui_wr_bottom;981 982 return ui_wr_none;980 return display_wr_bottom; 981 982 return display_wr_none; 983 983 } 984 984 … … 990 990 * @return Cursor to use for this resize type 991 991 */ 992 ui_stock_cursor_t ui_wdecor_cursor_from_rsztype( ui_wdecor_rsztype_t rsztype)992 ui_stock_cursor_t ui_wdecor_cursor_from_rsztype(display_wnd_rsztype_t rsztype) 993 993 { 994 994 switch (rsztype) { 995 case ui_wr_none:995 case display_wr_none: 996 996 return ui_curs_arrow; 997 997 998 case ui_wr_top:999 case ui_wr_bottom:998 case display_wr_top: 999 case display_wr_bottom: 1000 1000 return ui_curs_size_ud; 1001 1001 1002 case ui_wr_left:1003 case ui_wr_right:1002 case display_wr_left: 1003 case display_wr_right: 1004 1004 return ui_curs_size_lr; 1005 1005 1006 case ui_wr_top_left:1007 case ui_wr_bottom_right:1006 case display_wr_top_left: 1007 case display_wr_bottom_right: 1008 1008 return ui_curs_size_uldr; 1009 1009 1010 case ui_wr_top_right:1011 case ui_wr_bottom_left:1010 case display_wr_top_right: 1011 case display_wr_bottom_left: 1012 1012 return ui_curs_size_urdl; 1013 1013 … … 1074 1074 gfx_coord2_t pos; 1075 1075 sysarg_t pos_id; 1076 ui_wdecor_rsztype_t rsztype;1076 display_wnd_rsztype_t rsztype; 1077 1077 ui_stock_cursor_t cursor; 1078 1078 … … 1089 1089 1090 1090 /* Press on window border? */ 1091 if (rsztype != ui_wr_none && event->type == POS_PRESS)1091 if (rsztype != display_wr_none && event->type == POS_PRESS) 1092 1092 ui_wdecor_resize(wdecor, rsztype, &pos, pos_id); 1093 1093 } -
uspace/lib/ui/src/window.c
r29ed06d rdc0f6e4c 86 86 static void wd_close(ui_wdecor_t *, void *); 87 87 static void wd_move(ui_wdecor_t *, void *, gfx_coord2_t *, sysarg_t); 88 static void wd_resize(ui_wdecor_t *, void *, ui_wdecor_rsztype_t,88 static void wd_resize(ui_wdecor_t *, void *, display_wnd_rsztype_t, 89 89 gfx_coord2_t *, sysarg_t); 90 90 static void wd_set_cursor(ui_wdecor_t *, void *, ui_stock_cursor_t); … … 1191 1191 */ 1192 1192 static void wd_resize(ui_wdecor_t *wdecor, void *arg, 1193 ui_wdecor_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)1193 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id) 1194 1194 { 1195 1195 ui_window_t *window = (ui_window_t *) arg; 1196 1196 1197 1197 if (window->dwindow != NULL) { 1198 (void) display_window_resize_req(window->dwindow, 1199 (display_wnd_rsztype_t) rsztype, // Same constants in the enums 1198 (void) display_window_resize_req(window->dwindow, rsztype, 1200 1199 pos, pos_id); 1201 1200 } -
uspace/lib/ui/test/wdecor.c
r29ed06d rdc0f6e4c 72 72 static void test_wdecor_close(ui_wdecor_t *, void *); 73 73 static void test_wdecor_move(ui_wdecor_t *, void *, gfx_coord2_t *, sysarg_t); 74 static void test_wdecor_resize(ui_wdecor_t *, void *, ui_wdecor_rsztype_t,74 static void test_wdecor_resize(ui_wdecor_t *, void *, display_wnd_rsztype_t, 75 75 gfx_coord2_t *, sysarg_t); 76 76 static void test_wdecor_set_cursor(ui_wdecor_t *, void *, ui_stock_cursor_t); … … 125 125 char32_t accel; 126 126 bool resize; 127 ui_wdecor_rsztype_t rsztype;127 display_wnd_rsztype_t rsztype; 128 128 bool set_cursor; 129 129 ui_stock_cursor_t cursor; … … 584 584 ui_wdecor_t *wdecor; 585 585 test_cb_resp_t resp; 586 ui_wdecor_rsztype_t rsztype;586 display_wnd_rsztype_t rsztype; 587 587 gfx_coord2_t pos; 588 588 sysarg_t pos_id; … … 591 591 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 592 592 593 rsztype = ui_wr_bottom;593 rsztype = display_wr_bottom; 594 594 pos.x = 3; 595 595 pos.y = 4; … … 605 605 /* Resize callback with real callback set */ 606 606 resp.resize = false; 607 resp.rsztype = ui_wr_none;607 resp.rsztype = display_wr_none; 608 608 resp.pos.x = 0; 609 609 resp.pos.y = 0; … … 1361 1361 ui_wdecor_t *wdecor; 1362 1362 gfx_rect_t rect; 1363 ui_wdecor_rsztype_t rsztype;1363 display_wnd_rsztype_t rsztype; 1364 1364 gfx_coord2_t pos; 1365 1365 errno_t rc; … … 1387 1387 pos.y = -1; 1388 1388 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1389 PCUT_ASSERT_EQUALS( ui_wr_none, rsztype);1389 PCUT_ASSERT_EQUALS(display_wr_none, rsztype); 1390 1390 1391 1391 /* Middle of the window */ … … 1393 1393 pos.y = 100; 1394 1394 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1395 PCUT_ASSERT_EQUALS( ui_wr_none, rsztype);1395 PCUT_ASSERT_EQUALS(display_wr_none, rsztype); 1396 1396 1397 1397 /* Top-left corner, but not on edge */ … … 1399 1399 pos.y = 30; 1400 1400 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1401 PCUT_ASSERT_EQUALS( ui_wr_none, rsztype);1401 PCUT_ASSERT_EQUALS(display_wr_none, rsztype); 1402 1402 1403 1403 /* Top-left corner on top edge */ … … 1405 1405 pos.y = 20; 1406 1406 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1407 PCUT_ASSERT_EQUALS( ui_wr_top_left, rsztype);1407 PCUT_ASSERT_EQUALS(display_wr_top_left, rsztype); 1408 1408 1409 1409 /* Top-left corner on left edge */ … … 1411 1411 pos.y = 30; 1412 1412 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1413 PCUT_ASSERT_EQUALS( ui_wr_top_left, rsztype);1413 PCUT_ASSERT_EQUALS(display_wr_top_left, rsztype); 1414 1414 1415 1415 /* Top-right corner on top edge */ … … 1417 1417 pos.y = 20; 1418 1418 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1419 PCUT_ASSERT_EQUALS( ui_wr_top_right, rsztype);1419 PCUT_ASSERT_EQUALS(display_wr_top_right, rsztype); 1420 1420 1421 1421 /* Top-right corner on right edge */ … … 1423 1423 pos.y = 30; 1424 1424 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1425 PCUT_ASSERT_EQUALS( ui_wr_top_right, rsztype);1425 PCUT_ASSERT_EQUALS(display_wr_top_right, rsztype); 1426 1426 1427 1427 /* Top edge */ … … 1429 1429 pos.y = 20; 1430 1430 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1431 PCUT_ASSERT_EQUALS( ui_wr_top, rsztype);1431 PCUT_ASSERT_EQUALS(display_wr_top, rsztype); 1432 1432 1433 1433 /* Bottom edge */ … … 1435 1435 pos.y = 199; 1436 1436 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1437 PCUT_ASSERT_EQUALS( ui_wr_bottom, rsztype);1437 PCUT_ASSERT_EQUALS(display_wr_bottom, rsztype); 1438 1438 1439 1439 /* Left edge */ … … 1441 1441 pos.y = 100; 1442 1442 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1443 PCUT_ASSERT_EQUALS( ui_wr_left, rsztype);1443 PCUT_ASSERT_EQUALS(display_wr_left, rsztype); 1444 1444 1445 1445 /* Right edge */ … … 1447 1447 pos.y = 100; 1448 1448 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1449 PCUT_ASSERT_EQUALS( ui_wr_right, rsztype);1449 PCUT_ASSERT_EQUALS(display_wr_right, rsztype); 1450 1450 1451 1451 ui_wdecor_destroy(wdecor); … … 1466 1466 pos.y = 20; 1467 1467 rsztype = ui_wdecor_get_rsztype(wdecor, &pos); 1468 PCUT_ASSERT_EQUALS( ui_wr_none, rsztype);1468 PCUT_ASSERT_EQUALS(display_wr_none, rsztype); 1469 1469 1470 1470 ui_wdecor_destroy(wdecor); … … 1479 1479 { 1480 1480 PCUT_ASSERT_EQUALS(ui_curs_arrow, 1481 ui_wdecor_cursor_from_rsztype( ui_wr_none));1481 ui_wdecor_cursor_from_rsztype(display_wr_none)); 1482 1482 PCUT_ASSERT_EQUALS(ui_curs_size_ud, 1483 ui_wdecor_cursor_from_rsztype( ui_wr_top));1483 ui_wdecor_cursor_from_rsztype(display_wr_top)); 1484 1484 PCUT_ASSERT_EQUALS(ui_curs_size_ud, 1485 ui_wdecor_cursor_from_rsztype( ui_wr_bottom));1485 ui_wdecor_cursor_from_rsztype(display_wr_bottom)); 1486 1486 PCUT_ASSERT_EQUALS(ui_curs_size_lr, 1487 ui_wdecor_cursor_from_rsztype( ui_wr_left));1487 ui_wdecor_cursor_from_rsztype(display_wr_left)); 1488 1488 PCUT_ASSERT_EQUALS(ui_curs_size_lr, 1489 ui_wdecor_cursor_from_rsztype( ui_wr_right));1489 ui_wdecor_cursor_from_rsztype(display_wr_right)); 1490 1490 PCUT_ASSERT_EQUALS(ui_curs_size_uldr, 1491 ui_wdecor_cursor_from_rsztype( ui_wr_top_left));1491 ui_wdecor_cursor_from_rsztype(display_wr_top_left)); 1492 1492 PCUT_ASSERT_EQUALS(ui_curs_size_uldr, 1493 ui_wdecor_cursor_from_rsztype( ui_wr_bottom_right));1493 ui_wdecor_cursor_from_rsztype(display_wr_bottom_right)); 1494 1494 PCUT_ASSERT_EQUALS(ui_curs_size_urdl, 1495 ui_wdecor_cursor_from_rsztype( ui_wr_top_right));1495 ui_wdecor_cursor_from_rsztype(display_wr_top_right)); 1496 1496 PCUT_ASSERT_EQUALS(ui_curs_size_urdl, 1497 ui_wdecor_cursor_from_rsztype( ui_wr_bottom_left));1497 ui_wdecor_cursor_from_rsztype(display_wr_bottom_left)); 1498 1498 } 1499 1499 … … 1725 1725 1726 1726 static void test_wdecor_resize(ui_wdecor_t *wdecor, void *arg, 1727 ui_wdecor_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id)1727 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos, sysarg_t pos_id) 1728 1728 { 1729 1729 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
Note:
See TracChangeset
for help on using the changeset viewer.