Changeset 8922b76 in mainline for uspace/app/nav/panel.c
- Timestamp:
- 2021-10-22T18:25:44Z (3 years ago)
- Children:
- 5e221a77
- Parents:
- 966a27d3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/panel.c
r966a27d3 r8922b76 324 324 { 325 325 gfx_coord2_t pos; 326 gfx_rect_t irect; 327 panel_entry_t *entry; 328 size_t entry_idx; 329 int n; 326 330 327 331 pos.x = event->hpos; … … 330 334 return ui_unclaimed; 331 335 332 if (!panel->active ) {336 if (!panel->active && event->type == POS_PRESS) 333 337 panel_activate_req(panel); 338 339 if (event->type == POS_PRESS) { 340 irect.p0.x = panel->rect.p0.x + 1; 341 irect.p0.y = panel->rect.p0.y + 1; 342 irect.p1.x = panel->rect.p1.x - 1; 343 irect.p1.y = panel->rect.p1.y - 1; 344 345 /* Did we click on one of the entries? */ 346 if (gfx_pix_inside_rect(&pos, &irect)) { 347 /* Index within page */ 348 n = pos.y - irect.p0.y; 349 350 /* Entry and its index within entire listing */ 351 entry = panel_page_nth_entry(panel, n, &entry_idx); 352 353 /* Move to the entry found */ 354 panel_cursor_move(panel, entry, entry_idx); 355 } 334 356 } 335 357 … … 800 822 } 801 823 824 /** Find the n-th entry of the current panel page. 825 * 826 * If the page is short and has less than n+1 entries, return the last entry. 827 * 828 * @param panel Panel 829 * @param n Which entry to get (starting from 0) 830 * @param ridx Place to store index (within listing) of the entry 831 * @return n-th entry of the page 832 */ 833 panel_entry_t *panel_page_nth_entry(panel_t *panel, size_t n, size_t *ridx) 834 { 835 panel_entry_t *entry; 836 panel_entry_t *next; 837 size_t i; 838 size_t idx; 839 840 assert(n < panel_page_size(panel)); 841 842 entry = panel->page; 843 idx = panel->page_idx; 844 for (i = 0; i < n; i++) { 845 next = panel_next(entry); 846 if (next == NULL) 847 break; 848 849 entry = next; 850 ++idx; 851 } 852 853 *ridx = idx; 854 return entry; 855 } 856 802 857 /** Move cursor to a new position, possibly scrolling. 803 858 *
Note:
See TracChangeset
for help on using the changeset viewer.