Changeset bb14312 in mainline for uspace/lib/ui/src/entry.c
- Timestamp:
- 2021-06-26T16:40:28Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1215db9
- Parents:
- 69511176
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/entry.c
r69511176 rbb14312 39 39 #include <errno.h> 40 40 #include <gfx/context.h> 41 #include <gfx/cursor.h> 41 42 #include <gfx/render.h> 42 43 #include <gfx/text.h> … … 62 63 ui_entry_vpad_text = 0, 63 64 ui_entry_cursor_overshoot = 1, 64 ui_entry_cursor_width = 2, 65 ui_entry_cursor_width_text = 1 65 ui_entry_cursor_width = 2 66 66 }; 67 67 … … 107 107 entry->halign = gfx_halign_left; 108 108 *rentry = entry; 109 109 110 return EOK; 110 111 } … … 194 195 gfx_rect_t rect; 195 196 gfx_font_metrics_t metrics; 196 gfx_coord_t w;197 197 errno_t rc; 198 198 199 199 res = ui_window_get_res(entry->window); 200 200 201 if (res->textmode) { 202 rc = gfx_cursor_set_pos(res->gc, pos); 203 return rc; 204 } 205 201 206 gfx_font_get_metrics(res->font, &metrics); 202 203 w = res->textmode ? ui_entry_cursor_width_text :204 ui_entry_cursor_width;205 207 206 208 rect.p0.x = pos->x; 207 209 rect.p0.y = pos->y - ui_entry_cursor_overshoot; 208 rect.p1.x = pos->x + w;210 rect.p1.x = pos->x + ui_entry_cursor_width; 209 211 rect.p1.y = pos->y + metrics.ascent + metrics.descent + 1 + 210 212 ui_entry_cursor_overshoot; … … 399 401 ui_entry_backspace(entry); 400 402 401 if (event->key == KC_ESCAPE) { 402 entry->active = false; 403 (void) ui_entry_paint(entry); 404 } 403 if (event->key == KC_ESCAPE) 404 ui_entry_deactivate(entry); 405 405 406 406 return ui_claimed; … … 475 475 476 476 if (gfx_pix_inside_rect(&pos, &entry->rect)) { 477 if (!entry->active) { 478 entry->active = true; 479 (void) ui_entry_paint(entry); 480 } 477 ui_entry_activate(entry); 481 478 482 479 return ui_claimed; 483 480 } else { 484 if (entry->active) { 485 entry->active = false; 486 (void) ui_entry_paint(entry); 487 } 481 ui_entry_deactivate(entry); 488 482 } 489 483 } … … 518 512 } 519 513 514 /** Activate text entry. 515 * 516 * @param entry Text entry 517 */ 518 void ui_entry_activate(ui_entry_t *entry) 519 { 520 ui_resource_t *res; 521 522 res = ui_window_get_res(entry->window); 523 524 if (entry->active) 525 return; 526 527 entry->active = true; 528 (void) ui_entry_paint(entry); 529 530 if (res->textmode) 531 gfx_cursor_set_visible(res->gc, true); 532 } 533 534 /** Deactivate text entry. 535 * 536 * @param entry Text entry 537 */ 538 void ui_entry_deactivate(ui_entry_t *entry) 539 { 540 ui_resource_t *res; 541 542 res = ui_window_get_res(entry->window); 543 544 if (!entry->active) 545 return; 546 547 entry->active = false; 548 (void) ui_entry_paint(entry); 549 550 if (res->textmode) 551 gfx_cursor_set_visible(res->gc, false); 552 } 553 520 554 /** @} 521 555 */
Note:
See TracChangeset
for help on using the changeset viewer.