Changeset a2f173b in mainline
- Timestamp:
- 2020-10-21T21:49:13Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 58a67050
- Parents:
- 172188a
- Location:
- uspace/lib/ui
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/include/ui/pbutton.h
r172188a ra2f173b 40 40 #include <gfx/coord.h> 41 41 #include <io/pos_event.h> 42 #include <types/ui/event.h> 42 43 #include <types/ui/pbutton.h> 43 44 #include <types/ui/resource.h> … … 56 57 extern void ui_pbutton_leave(ui_pbutton_t *); 57 58 extern void ui_pbutton_clicked(ui_pbutton_t *); 58 extern voidui_pbutton_pos_event(ui_pbutton_t *, pos_event_t *);59 extern ui_evclaim_t ui_pbutton_pos_event(ui_pbutton_t *, pos_event_t *); 59 60 60 61 #endif -
uspace/lib/ui/src/pbutton.c
r172188a ra2f173b 350 350 * @param pbutton Push button 351 351 * @param pos_event Position event 352 */ 353 void ui_pbutton_pos_event(ui_pbutton_t *pbutton, pos_event_t *event) 352 * @return @c ui_claimed iff the event is claimed 353 */ 354 ui_evclaim_t ui_pbutton_pos_event(ui_pbutton_t *pbutton, pos_event_t *event) 354 355 { 355 356 gfx_coord2_t pos; … … 363 364 switch (event->type) { 364 365 case POS_PRESS: 365 if (inside) 366 if (inside) { 366 367 ui_pbutton_press(pbutton); 368 return ui_claimed; 369 } 367 370 break; 368 371 case POS_RELEASE: 369 ui_pbutton_release(pbutton); 372 if (pbutton->held) { 373 ui_pbutton_release(pbutton); 374 return ui_claimed; 375 } 370 376 break; 371 377 case POS_UPDATE: 372 378 if (inside && !pbutton->inside) { 373 379 ui_pbutton_enter(pbutton); 380 return ui_claimed; 374 381 } else if (!inside && pbutton->inside) { 375 382 ui_pbutton_leave(pbutton); … … 377 384 break; 378 385 } 386 387 return ui_unclaimed; 379 388 } 380 389 -
uspace/lib/ui/src/wdecor.c
r172188a ra2f173b 280 280 gfx_coord2_t pos; 281 281 ui_wdecor_geom_t geom; 282 ui_evclaim_t claim; 282 283 283 284 pos.x = event->hpos; … … 286 287 ui_wdecor_get_geom(wdecor, &geom); 287 288 288 if (gfx_pix_inside_rect(&pos, &geom.btn_close_rect)) {289 ui_pbutton_pos_event(wdecor->btn_close, event);289 claim = ui_pbutton_pos_event(wdecor->btn_close, event); 290 if (claim == ui_claimed) 290 291 return; 291 }292 292 293 293 if (event->type == POS_PRESS && -
uspace/lib/ui/test/pbutton.c
r172188a ra2f173b 359 359 ui_resource_t *resource = NULL; 360 360 ui_pbutton_t *pbutton; 361 ui_evclaim_t claim; 361 362 pos_event_t event; 362 363 gfx_rect_t rect; … … 381 382 ui_pbutton_set_rect(pbutton, &rect); 382 383 383 /* Press outside does nothing */384 /* Press outside is not claimed and does nothing */ 384 385 event.type = POS_PRESS; 385 386 event.hpos = 9; 386 387 event.vpos = 20; 387 ui_pbutton_pos_event(pbutton, &event); 388 PCUT_ASSERT_FALSE(pbutton->held); 389 390 /* Press inside depresses button */ 388 claim = ui_pbutton_pos_event(pbutton, &event); 389 PCUT_ASSERT_FALSE(pbutton->held); 390 PCUT_ASSERT_EQUALS(ui_unclaimed, claim); 391 392 /* Press inside is claimed and depresses button */ 391 393 event.type = POS_PRESS; 392 394 event.hpos = 10; 393 395 event.vpos = 20; 394 ui_pbutton_pos_event(pbutton, &event); 395 PCUT_ASSERT_TRUE(pbutton->held); 396 397 /* Release outside (or anywhere) relases button */ 396 claim = ui_pbutton_pos_event(pbutton, &event); 397 PCUT_ASSERT_TRUE(pbutton->held); 398 PCUT_ASSERT_EQUALS(ui_claimed, claim); 399 400 /* Release outside (or anywhere) is claimed and relases button */ 398 401 event.type = POS_RELEASE; 399 402 event.hpos = 9; 400 403 event.vpos = 20; 401 ui_pbutton_pos_event(pbutton, &event); 402 PCUT_ASSERT_FALSE(pbutton->held); 404 claim = ui_pbutton_pos_event(pbutton, &event); 405 PCUT_ASSERT_FALSE(pbutton->held); 406 PCUT_ASSERT_EQUALS(ui_claimed, claim); 403 407 404 408 ui_pbutton_destroy(pbutton);
Note:
See TracChangeset
for help on using the changeset viewer.