Changeset c6f00b40 in mainline
- Timestamp:
- 2020-11-01T22:49:05Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4ac11ff
- Parents:
- 4df6607
- git-author:
- Jiri Svoboda <jiri@…> (2020-11-01 22:47:03)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-11-01 22:49:05)
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
r4df6607 rc6f00b40 252 252 ui_run(ui); 253 253 254 ui_fixed_remove(demo.fixed, ui_label_ctl(demo.label)); 255 ui_fixed_remove(demo.fixed, ui_pbutton_ctl(demo.pb1)); 256 ui_fixed_remove(demo.fixed, ui_pbutton_ctl(demo.pb2)); 257 258 ui_pbutton_destroy(demo.pb1); 259 ui_pbutton_destroy(demo.pb2); 260 254 ui_fixed_destroy(demo.fixed); 261 255 ui_window_destroy(window); 262 256 ui_destroy(ui); -
uspace/lib/ui/include/types/ui/control.h
r4df6607 rc6f00b40 46 46 /** UI control ops */ 47 47 typedef struct ui_control_ops { 48 /** Destroy control */ 49 void (*destroy)(void *); 48 50 /** Paint */ 49 51 errno_t (*paint)(void *); -
uspace/lib/ui/include/ui/control.h
r4df6607 rc6f00b40 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 void ui_control_destroy(ui_control_t *); 46 47 extern errno_t ui_control_paint(ui_control_t *); 47 48 extern ui_evclaim_t ui_control_pos_event(ui_control_t *, pos_event_t *); -
uspace/lib/ui/src/control.c
r4df6607 rc6f00b40 64 64 /** Delete UI control. 65 65 * 66 * Deletes the base control (not the extended data). 67 * 66 68 * @param control UI control or @c NULL 67 69 */ … … 74 76 } 75 77 78 /** Destroy UI control. 79 * 80 * Run the virtual control destructor (destroy complete control including 81 * extended data). 82 * 83 * @param control Control 84 */ 85 void ui_control_destroy(ui_control_t *control) 86 { 87 return control->ops->destroy(control->ext); 88 } 89 76 90 /** Paint UI control. 77 91 * 78 * @param control Push button92 * @param control Control 79 93 * @return EOK on success or an error code 80 94 */ … … 86 100 /** Deliver position event to UI control. 87 101 * 88 * @param control Push button102 * @param control Control 89 103 * @param pos_event Position event 90 104 * @return @c ui_claimed iff the event is claimed -
uspace/lib/ui/src/fixed.c
r4df6607 rc6f00b40 68 68 void ui_fixed_destroy(ui_fixed_t *fixed) 69 69 { 70 ui_fixed_elem_t *elem; 71 ui_control_t *control; 72 70 73 if (fixed == NULL) 71 74 return; 72 75 73 assert(list_empty(&fixed->elem)); 76 elem = ui_fixed_first(fixed); 77 while (elem != NULL) { 78 control = elem->control; 79 ui_fixed_remove(fixed, control); 80 ui_control_destroy(control); 81 82 elem = ui_fixed_first(fixed); 83 } 84 74 85 free(fixed); 75 86 } -
uspace/lib/ui/src/label.c
r4df6607 rc6f00b40 46 46 #include "../private/resource.h" 47 47 48 static void ui_label_ctl_destroy(void *); 48 49 static errno_t ui_label_ctl_paint(void *); 49 50 static ui_evclaim_t ui_label_ctl_pos_event(void *, pos_event_t *); … … 51 52 /** Label control ops */ 52 53 ui_control_ops_t ui_label_ops = { 54 .destroy = ui_label_ctl_destroy, 53 55 .paint = ui_label_ctl_paint, 54 56 .pos_event = ui_label_ctl_pos_event … … 207 209 } 208 210 209 /** Paint lable control. 211 /** Destroy label control. 212 * 213 * @param arg Argument (ui_label_t *) 214 */ 215 void ui_label_ctl_destroy(void *arg) 216 { 217 ui_label_t *label = (ui_label_t *) arg; 218 219 ui_label_destroy(label); 220 } 221 222 /** Paint label control. 210 223 * 211 224 * @param arg Argument (ui_label_t *) -
uspace/lib/ui/src/pbutton.c
r4df6607 rc6f00b40 54 54 }; 55 55 56 static void ui_pbutton_ctl_destroy(void *); 56 57 static errno_t ui_pbutton_ctl_paint(void *); 57 58 static ui_evclaim_t ui_pbutton_ctl_pos_event(void *, pos_event_t *); … … 59 60 /** Push button control ops */ 60 61 ui_control_ops_t ui_pbutton_ops = { 62 .destroy = ui_pbutton_ctl_destroy, 61 63 .paint = ui_pbutton_ctl_paint, 62 64 .pos_event = ui_pbutton_ctl_pos_event … … 418 420 } 419 421 422 /** Destroy push button control. 423 * 424 * @param arg Argument (ui_pbutton_t *) 425 */ 426 void ui_pbutton_ctl_destroy(void *arg) 427 { 428 ui_pbutton_t *pbutton = (ui_pbutton_t *) arg; 429 430 ui_pbutton_destroy(pbutton); 431 } 432 420 433 /** Paint push button control. 421 434 * -
uspace/lib/ui/test/control.c
r4df6607 rc6f00b40 21 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INT ERRUPTION) HOWEVER CAUSED AND ON ANY23 * DATA, OR PROFITS; OR BUSINESS INTvvhhzccgggrERRUPTION) HOWEVER CAUSED AND ON ANY 24 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF … … 39 39 PCUT_TEST_SUITE(control); 40 40 41 static void test_ctl_destroy(void *); 41 42 static errno_t test_ctl_paint(void *); 42 43 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 43 44 44 45 static ui_control_ops_t test_ctl_ops = { 46 .destroy = test_ctl_destroy, 45 47 .paint = test_ctl_paint, 46 48 .pos_event = test_ctl_pos_event … … 53 55 /** Result code to return */ 54 56 errno_t rc; 57 58 /** @c true iff destroy was called */ 59 bool destroy; 55 60 56 61 /** @c true iff paint was called */ … … 80 85 { 81 86 ui_control_delete(NULL); 87 } 88 89 /** Test sending destroy request to control */ 90 PCUT_TEST(destroy) 91 { 92 ui_control_t *control = NULL; 93 test_resp_t resp; 94 errno_t rc; 95 96 rc = ui_control_new(&test_ctl_ops, &resp, &control); 97 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 98 PCUT_ASSERT_NOT_NULL(control); 99 100 resp.rc = EOK; 101 resp.destroy = false; 102 103 ui_control_destroy(control); 104 PCUT_ASSERT_TRUE(resp.destroy); 82 105 } 83 106 … … 143 166 } 144 167 168 static void test_ctl_destroy(void *arg) 169 { 170 test_resp_t *resp = (test_resp_t *) arg; 171 172 resp->destroy = true; 173 } 174 145 175 static errno_t test_ctl_paint(void *arg) 146 176 { -
uspace/lib/ui/test/fixed.c
r4df6607 rc6f00b40 38 38 PCUT_TEST_SUITE(fixed); 39 39 40 static void test_ctl_destroy(void *); 40 41 static errno_t test_ctl_paint(void *); 41 42 static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *); 42 43 43 44 static ui_control_ops_t test_ctl_ops = { 45 .destroy = test_ctl_destroy, 44 46 .paint = test_ctl_paint, 45 47 .pos_event = test_ctl_pos_event … … 52 54 /** Result code to return */ 53 55 errno_t rc; 54 56 /** @c true iff destroy was called */ 57 bool destroy; 55 58 /** @c true iff paint was called */ 56 59 bool paint; 57 58 60 /** @c true iff pos_event was called */ 59 61 bool pos; … … 113 115 114 116 ui_fixed_destroy(fixed); 117 ui_control_delete(control); 118 } 119 120 /** ui_fixed_destroy() delivers destroy request to control */ 121 PCUT_TEST(destroy) 122 { 123 ui_fixed_t *fixed = NULL; 124 ui_control_t *control; 125 test_resp_t resp; 126 errno_t rc; 127 128 rc = ui_fixed_create(&fixed); 129 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 130 131 rc = ui_control_new(&test_ctl_ops, (void *) &resp, &control); 132 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 133 134 rc = ui_fixed_add(fixed, control); 135 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 136 137 resp.destroy = false; 138 139 ui_fixed_destroy(fixed); 140 PCUT_ASSERT_TRUE(resp.destroy); 115 141 } 116 142 … … 146 172 PCUT_ASSERT_TRUE(resp.paint); 147 173 148 ui_fixed_remove(fixed, control);149 174 ui_fixed_destroy(fixed); 150 175 } … … 186 211 PCUT_ASSERT_INT_EQUALS(resp.pevent.vpos, event.vpos); 187 212 188 ui_fixed_remove(fixed, control); 189 ui_fixed_destroy(fixed); 213 ui_fixed_destroy(fixed); 214 } 215 216 static void test_ctl_destroy(void *arg) 217 { 218 test_resp_t *resp = (test_resp_t *) arg; 219 220 resp->destroy = true; 190 221 } 191 222
Note:
See TracChangeset
for help on using the changeset viewer.