source: mainline/uspace/lib/ui/private/list.h

Last change on this file was c0757e1f, checked in by Jiri Svoboda <jiri@…>, 2 years ago

UI display configuration utility

In addition to the command-line utility 'disp', we introduce its UI
equivalent 'display-cfg'. Currently this allows the user to configure
seats in a very comfortable way.

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*
2 * Copyright (c) 2023 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libui
30 * @{
31 */
32/**
33 * @file UI list
34 */
35
36#ifndef _UI_PRIVATE_LIST_H
37#define _UI_PRIVATE_LIST_H
38
39#include <adt/list.h>
40#include <gfx/color.h>
41#include <gfx/coord.h>
42#include <ipc/loc.h>
43#include <ui/window.h>
44#include <stdint.h>
45#include <types/ui/list.h>
46
47/** List entry */
48struct ui_list_entry {
49 /** Containing list */
50 struct ui_list *list;
51 /** Link to @c flist->entries */
52 link_t lentries;
53 /** Entry caption */
54 char *caption;
55 /** User argument */
56 void *arg;
57 /** Custom color or @c NULL to use default color */
58 gfx_color_t *color;
59 /** Custom background color or @c NULL to use default color */
60 gfx_color_t *bgcolor;
61};
62
63/** UI list.
64 *
65 * Displays a scrollable list of entries.
66 */
67typedef struct ui_list {
68 /** Base control object */
69 struct ui_control *control;
70
71 /** Containing window */
72 ui_window_t *window;
73
74 /** Callbacks */
75 struct ui_list_cb *cb;
76
77 /** Callback argument */
78 void *cb_arg;
79
80 /** List rectangle */
81 gfx_rect_t rect;
82
83 /** Scrollbar */
84 struct ui_scrollbar *scrollbar;
85
86 /** List entries (list of ui_list_entry_t) */
87 list_t entries;
88
89 /** Number of entries */
90 size_t entries_cnt;
91
92 /** First entry of current page */
93 ui_list_entry_t *page;
94
95 /** Index of first entry of current page */
96 size_t page_idx;
97
98 /** Cursor position */
99 ui_list_entry_t *cursor;
100
101 /** Index of entry under cursor */
102 size_t cursor_idx;
103
104 /** @c true iff the list is active */
105 bool active;
106} ui_list_t;
107
108extern gfx_coord_t ui_list_entry_height(ui_list_t *);
109extern errno_t ui_list_entry_paint(ui_list_entry_t *, size_t);
110extern errno_t ui_list_paint(ui_list_t *);
111extern ui_evclaim_t ui_list_kbd_event(ui_list_t *, kbd_event_t *);
112extern ui_evclaim_t ui_list_pos_event(ui_list_t *, pos_event_t *);
113extern unsigned ui_list_page_size(ui_list_t *);
114extern void ui_list_inside_rect(ui_list_t *, gfx_rect_t *);
115extern void ui_list_scrollbar_rect(ui_list_t *, gfx_rect_t *);
116extern gfx_coord_t ui_list_scrollbar_pos(ui_list_t *);
117extern void ui_list_scrollbar_update(ui_list_t *);
118extern void ui_list_clear_entries(ui_list_t *);
119extern ui_list_entry_t *ui_list_page_nth_entry(ui_list_t *,
120 size_t, size_t *);
121extern void ui_list_cursor_move(ui_list_t *, ui_list_entry_t *,
122 size_t);
123extern void ui_list_cursor_up(ui_list_t *);
124extern void ui_list_cursor_down(ui_list_t *);
125extern void ui_list_cursor_top(ui_list_t *);
126extern void ui_list_cursor_bottom(ui_list_t *);
127extern void ui_list_page_up(ui_list_t *);
128extern void ui_list_page_down(ui_list_t *);
129extern void ui_list_scroll_up(ui_list_t *);
130extern void ui_list_scroll_down(ui_list_t *);
131extern void ui_list_scroll_page_up(ui_list_t *);
132extern void ui_list_scroll_page_down(ui_list_t *);
133extern void ui_list_scroll_pos(ui_list_t *, size_t);
134extern void ui_list_activate_req(ui_list_t *);
135extern void ui_list_selected(ui_list_entry_t *);
136extern int ui_list_entry_ptr_cmp(const void *, const void *);
137extern size_t ui_list_entry_get_idx(ui_list_entry_t *);
138extern void ui_list_entry_destroy(ui_list_entry_t *);
139
140#endif
141
142/** @}
143 */
Note: See TracBrowser for help on using the repository browser.