Changeset db3895d in mainline for uspace/lib/ui/src
- Timestamp:
- 2021-06-10T17:10:11Z (4 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- af5d62eb
- Parents:
- 90f1f19
- Location:
- uspace/lib/ui/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/entry.c
r90f1f19 rdb3895d 47 47 #include <ui/entry.h> 48 48 #include <ui/ui.h> 49 #include <ui/window.h> 49 50 #include "../private/entry.h" 50 51 #include "../private/resource.h" … … 70 71 /** Create new text entry. 71 72 * 72 * @param resource UI resource73 * @param window UI window 73 74 * @param text Text 74 75 * @param rentry Place to store pointer to new text entry 75 76 * @return EOK on success, ENOMEM if out of memory 76 77 */ 77 errno_t ui_entry_create(ui_ resource_t *resource, const char *text,78 errno_t ui_entry_create(ui_window_t *window, const char *text, 78 79 ui_entry_t **rentry) 79 80 { … … 98 99 } 99 100 100 entry-> res = resource;101 entry->window = window; 101 102 entry->halign = gfx_halign_left; 102 103 *rentry = entry; … … 174 175 errno_t ui_entry_paint(ui_entry_t *entry) 175 176 { 177 ui_resource_t *res; 176 178 gfx_text_fmt_t fmt; 177 179 gfx_coord2_t pos; … … 181 183 errno_t rc; 182 184 183 if (entry->res->textmode) { 185 res = ui_window_get_res(entry->window); 186 187 if (res->textmode) { 184 188 hpad = ui_entry_hpad_text; 185 189 vpad = ui_entry_vpad_text; … … 189 193 } 190 194 191 if ( entry->res->textmode == false) {195 if (res->textmode == false) { 192 196 /* Paint inset frame */ 193 rc = ui_paint_inset_frame( entry->res, &entry->rect, &inside);197 rc = ui_paint_inset_frame(res, &entry->rect, &inside); 194 198 if (rc != EOK) 195 199 goto error; … … 200 204 /* Paint entry background */ 201 205 202 rc = gfx_set_color( entry->res->gc, entry->res->entry_bg_color);206 rc = gfx_set_color(res->gc, res->entry_bg_color); 203 207 if (rc != EOK) 204 208 goto error; 205 209 206 rc = gfx_fill_rect( entry->res->gc, &inside);210 rc = gfx_fill_rect(res->gc, &inside); 207 211 if (rc != EOK) 208 212 goto error; … … 224 228 225 229 gfx_text_fmt_init(&fmt); 226 fmt.color = entry->res->entry_fg_color;230 fmt.color = res->entry_fg_color; 227 231 fmt.halign = entry->halign; 228 232 fmt.valign = gfx_valign_top; 229 233 230 rc = gfx_puttext( entry->res->font, &pos, &fmt, entry->text);234 rc = gfx_puttext(res->font, &pos, &fmt, entry->text); 231 235 if (rc != EOK) 232 236 goto error; 233 237 234 rc = gfx_update( entry->res->gc);238 rc = gfx_update(res->gc); 235 239 if (rc != EOK) 236 240 goto error; … … 273 277 { 274 278 ui_entry_t *entry = (ui_entry_t *) arg; 275 276 (void) entry; 279 gfx_coord2_t pos; 280 281 if (event->type == POS_UPDATE) { 282 pos.x = event->hpos; 283 pos.y = event->vpos; 284 285 if (gfx_pix_inside_rect(&pos, &entry->rect)) { 286 if (!entry->pointer_inside) { 287 ui_window_set_ctl_cursor(entry->window, 288 ui_curs_ibeam); 289 entry->pointer_inside = true; 290 } 291 } else { 292 if (entry->pointer_inside) { 293 ui_window_set_ctl_cursor(entry->window, 294 ui_curs_arrow); 295 entry->pointer_inside = false; 296 } 297 } 298 } 299 277 300 return ui_unclaimed; 278 301 } -
uspace/lib/ui/src/window.c
r90f1f19 rdb3895d 646 646 } 647 647 648 /** Set cursor when pointer is hovering over a control. 649 * 650 * @param window Window 651 * @param cursor Cursor 652 */ 653 void ui_window_set_ctl_cursor(ui_window_t *window, ui_stock_cursor_t cursor) 654 { 655 display_stock_cursor_t dcursor; 656 657 dcursor = wnd_dcursor_from_cursor(cursor); 658 659 if (window->dwindow != NULL) 660 (void) display_window_set_cursor(window->dwindow, dcursor); 661 } 662 648 663 /** Paint window 649 664 * … … 770 785 } 771 786 772 /** Window decoration requested changing cursor. 773 * 774 * @param wdecor Window decoration 775 * @param arg Argument (window) 776 * @param cursor Cursor to set 777 */ 778 static void wd_set_cursor(ui_wdecor_t *wdecor, void *arg, 779 ui_stock_cursor_t cursor) 780 { 781 ui_window_t *window = (ui_window_t *) arg; 787 /** Get display stock cursor from UI stock cursor. 788 * 789 * @param cursor UI stock cursor 790 * @return Display stock cursor 791 */ 792 display_stock_cursor_t wnd_dcursor_from_cursor(ui_stock_cursor_t cursor) 793 { 782 794 display_stock_cursor_t dcursor; 783 784 if (cursor == window->cursor)785 return;786 795 787 796 dcursor = dcurs_arrow; … … 803 812 dcursor = dcurs_size_urdl; 804 813 break; 805 } 814 case ui_curs_ibeam: 815 dcursor = dcurs_ibeam; 816 break; 817 } 818 819 return dcursor; 820 } 821 822 /** Window decoration requested changing cursor. 823 * 824 * @param wdecor Window decoration 825 * @param arg Argument (window) 826 * @param cursor Cursor to set 827 */ 828 static void wd_set_cursor(ui_wdecor_t *wdecor, void *arg, 829 ui_stock_cursor_t cursor) 830 { 831 ui_window_t *window = (ui_window_t *) arg; 832 display_stock_cursor_t dcursor; 833 834 if (cursor == window->cursor) 835 return; 836 837 dcursor = wnd_dcursor_from_cursor(cursor); 806 838 807 839 if (window->dwindow != NULL) 808 840 (void) display_window_set_cursor(window->dwindow, dcursor); 841 809 842 window->cursor = cursor; 810 843 }
Note:
See TracChangeset
for help on using the changeset viewer.