Changeset 4df6607 in mainline
- Timestamp:
- 2020-11-01T18:37:09Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c6f00b40
- Parents:
- 8009dc27
- Location:
- uspace
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r8009dc27 r4df6607 244 244 } 245 245 246 rc = ui_label_paint(demo.label); 247 if (rc != EOK) { 248 printf("Error painting button.\n"); 249 return rc; 250 } 251 252 rc = ui_pbutton_paint(demo.pb1); 253 if (rc != EOK) { 254 printf("Error painting button.\n"); 255 return rc; 256 } 257 258 rc = ui_pbutton_paint(demo.pb2); 259 if (rc != EOK) { 260 printf("Error painting button.\n"); 246 rc = ui_fixed_paint(demo.fixed); 247 if (rc != EOK) { 248 printf("Error painting UI controls.\n"); 261 249 return rc; 262 250 } -
uspace/lib/ui/include/types/ui/control.h
r8009dc27 r4df6607 37 37 #define _UI_TYPES_CONTROL_H 38 38 39 #include <errno.h> 39 40 #include <io/pos_event.h> 40 41 #include <types/ui/event.h> … … 45 46 /** UI control ops */ 46 47 typedef struct ui_control_ops { 48 /** Paint */ 49 errno_t (*paint)(void *); 47 50 /** Position event */ 48 51 ui_evclaim_t (*pos_event)(void *, pos_event_t *); -
uspace/lib/ui/include/ui/control.h
r8009dc27 r4df6607 44 44 extern errno_t ui_control_new(ui_control_ops_t *, void *, ui_control_t **); 45 45 extern void ui_control_delete(ui_control_t *); 46 extern errno_t ui_control_paint(ui_control_t *); 46 47 extern ui_evclaim_t ui_control_pos_event(ui_control_t *, pos_event_t *); 47 48 -
uspace/lib/ui/include/ui/fixed.h
r8009dc27 r4df6607 47 47 extern errno_t ui_fixed_add(ui_fixed_t *, ui_control_t *); 48 48 extern void ui_fixed_remove(ui_fixed_t *, ui_control_t *); 49 extern errno_t ui_fixed_paint(ui_fixed_t *); 49 50 extern ui_evclaim_t ui_fixed_pos_event(ui_fixed_t *, pos_event_t *); 50 51 -
uspace/lib/ui/src/control.c
r8009dc27 r4df6607 74 74 } 75 75 76 /** Paint UI control. 77 * 78 * @param control Push button 79 * @return EOK on success or an error code 80 */ 81 errno_t ui_control_paint(ui_control_t *control) 82 { 83 return control->ops->paint(control->ext); 84 } 85 76 86 /** Deliver position event to UI control. 77 87 * -
uspace/lib/ui/src/fixed.c
r8009dc27 r4df6607 147 147 } 148 148 149 /** Paint fixed layout. 150 * 151 * @param fixed Fixed layout 152 * @return EOK on success or an error code 153 */ 154 errno_t ui_fixed_paint(ui_fixed_t *fixed) 155 { 156 ui_fixed_elem_t *elem; 157 errno_t rc; 158 159 elem = ui_fixed_first(fixed); 160 while (elem != NULL) { 161 rc = ui_control_paint(elem->control); 162 if (rc != EOK) 163 return rc; 164 165 elem = ui_fixed_next(elem); 166 } 167 168 return EOK; 169 } 170 149 171 /** Handle fixed layout position event. 150 172 * -
uspace/lib/ui/src/label.c
r8009dc27 r4df6607 46 46 #include "../private/resource.h" 47 47 48 static errno_t ui_label_ctl_paint(void *); 48 49 static ui_evclaim_t ui_label_ctl_pos_event(void *, pos_event_t *); 49 50 50 51 /** Label control ops */ 51 52 ui_control_ops_t ui_label_ops = { 53 .paint = ui_label_ctl_paint, 52 54 .pos_event = ui_label_ctl_pos_event 53 55 }; … … 205 207 } 206 208 209 /** Paint lable control. 210 * 211 * @param arg Argument (ui_label_t *) 212 * @return EOK on success or an error code 213 */ 214 errno_t ui_label_ctl_paint(void *arg) 215 { 216 ui_label_t *label = (ui_label_t *) arg; 217 218 return ui_label_paint(label); 219 } 220 207 221 /** Handle label control position event. 208 222 * -
uspace/lib/ui/src/pbutton.c
r8009dc27 r4df6607 54 54 }; 55 55 56 static errno_t ui_pbutton_ctl_paint(void *); 56 57 static ui_evclaim_t ui_pbutton_ctl_pos_event(void *, pos_event_t *); 57 58 58 59 /** Push button control ops */ 59 60 ui_control_ops_t ui_pbutton_ops = { 61 .paint = ui_pbutton_ctl_paint, 60 62 .pos_event = ui_pbutton_ctl_pos_event 61 63 }; … … 416 418 } 417 419 420 /** Paint push button control. 421 * 422 * @param arg Argument (ui_pbutton_t *) 423 * @return EOK on success or an error code 424 */ 425 errno_t ui_pbutton_ctl_paint(void *arg) 426 { 427 ui_pbutton_t *pbutton = (ui_pbutton_t *) arg; 428 429 return ui_pbutton_paint(pbutton); 430 } 431 418 432 /** Handle push button control position event. 419 433 * -
uspace/lib/ui/test/control.c
r8009dc27 r4df6607 27 27 */ 28 28 29 #include <errno.h> 29 30 #include <mem.h> 30 31 #include <io/pos_event.h> … … 38 39 PCUT_TEST_SUITE(control); 39 40 41 static errno_t test_ctl_paint(void *); 40 42 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 41 43 42 44 static ui_control_ops_t test_ctl_ops = { 45 .paint = test_ctl_paint, 43 46 .pos_event = test_ctl_pos_event 44 47 }; … … 48 51 /** Claim to return */ 49 52 ui_evclaim_t claim; 53 /** Result code to return */ 54 errno_t rc; 55 56 /** @c true iff paint was called */ 57 bool paint; 50 58 51 59 /** @c true iff pos_event was called */ … … 72 80 { 73 81 ui_control_delete(NULL); 82 } 83 84 /** Test sending paint request to control */ 85 PCUT_TEST(paint) 86 { 87 ui_control_t *control = NULL; 88 test_resp_t resp; 89 errno_t rc; 90 91 rc = ui_control_new(&test_ctl_ops, &resp, &control); 92 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 93 PCUT_ASSERT_NOT_NULL(control); 94 95 resp.rc = EOK; 96 resp.paint = false; 97 98 rc = ui_control_paint(control); 99 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 100 PCUT_ASSERT_TRUE(resp.paint); 101 102 resp.rc = EINVAL; 103 resp.paint = false; 104 105 rc = ui_control_paint(control); 106 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 107 PCUT_ASSERT_TRUE(resp.paint); 108 109 ui_control_delete(control); 74 110 } 75 111 … … 107 143 } 108 144 145 static errno_t test_ctl_paint(void *arg) 146 { 147 test_resp_t *resp = (test_resp_t *) arg; 148 149 resp->paint = true; 150 return resp->rc; 151 } 152 109 153 static ui_evclaim_t test_ctl_pos_event(void *arg, pos_event_t *event) 110 154 { -
uspace/lib/ui/test/fixed.c
r8009dc27 r4df6607 27 27 */ 28 28 29 #include <errno.h> 29 30 #include <pcut/pcut.h> 30 31 #include <stddef.h> … … 37 38 PCUT_TEST_SUITE(fixed); 38 39 40 static errno_t test_ctl_paint(void *); 39 41 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 40 42 41 43 static ui_control_ops_t test_ctl_ops = { 44 .paint = test_ctl_paint, 42 45 .pos_event = test_ctl_pos_event 43 46 }; … … 47 50 /** Claim to return */ 48 51 ui_evclaim_t claim; 52 /** Result code to return */ 53 errno_t rc; 54 55 /** @c true iff paint was called */ 56 bool paint; 49 57 50 58 /** @c true iff pos_event was called */ … … 107 115 } 108 116 109 /** ui_pos_event() delivers position event to control */ 117 /** ui_fixed_paint() delivers paint request to control */ 118 PCUT_TEST(paint) 119 { 120 ui_fixed_t *fixed = NULL; 121 ui_control_t *control; 122 test_resp_t resp; 123 errno_t rc; 124 125 rc = ui_fixed_create(&fixed); 126 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 127 128 rc = ui_control_new(&test_ctl_ops, (void *) &resp, &control); 129 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 130 131 rc = ui_fixed_add(fixed, control); 132 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 133 134 resp.paint = false; 135 resp.rc = EOK; 136 137 rc = ui_fixed_paint(fixed); 138 PCUT_ASSERT_EQUALS(resp.rc, rc); 139 PCUT_ASSERT_TRUE(resp.paint); 140 141 resp.paint = false; 142 resp.rc = EINVAL; 143 144 rc = ui_fixed_paint(fixed); 145 PCUT_ASSERT_EQUALS(resp.rc, rc); 146 PCUT_ASSERT_TRUE(resp.paint); 147 148 ui_fixed_remove(fixed, control); 149 ui_fixed_destroy(fixed); 150 } 151 152 /** ui_fixed_pos_event() delivers position event to control */ 110 153 PCUT_TEST(pos_event) 111 154 { … … 147 190 } 148 191 192 static errno_t test_ctl_paint(void *arg) 193 { 194 test_resp_t *resp = (test_resp_t *) arg; 195 196 resp->paint = true; 197 return resp->rc; 198 } 199 149 200 static ui_evclaim_t test_ctl_pos_event(void *arg, pos_event_t *event) 150 201 {
Note:
See TracChangeset
for help on using the changeset viewer.