2 * Copyright (c) 2023 Jiri Svoboda
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
33 * @file Scrollbar structure
37 #ifndef _UI_PRIVATE_SCROLLBAR_H
38 #define _UI_PRIVATE_SCROLLBAR_H
40 #include <gfx/coord.h>
42 #include <types/ui/scrollbar.h>
44 /** Actual structure of scrollbar.
46 * This is private to libui.
49 /** Base control object */
50 struct ui_control
*control
;
53 /** UI window containing scrollbar */
54 struct ui_window
*window
;
56 struct ui_scrollbar_cb
*cb
;
57 /** Callback argument */
59 /** Scrollbar rectangle */
61 /** Scrollbar direction */
62 ui_scrollbar_dir_t dir
;
64 gfx_coord_t thumb_len
;
66 struct ui_pbutton
*up_btn
;
68 struct ui_pbutton
*down_btn
;
69 /** Thumb is currently held down */
71 /** Upper trough is currently held down */
72 bool upper_trough_held
;
73 /** Pointer is inside upper trough */
74 bool upper_trough_inside
;
75 /** Lower trough is currently held down */
76 bool lower_trough_held
;
77 /** Pointer is inside lower trough */
78 bool lower_trough_inside
;
79 /** Position where thumb was pressed */
80 gfx_coord2_t press_pos
;
81 /** Last thumb position */
85 /** Last cursor position (when trough is held) */
86 gfx_coord2_t last_curs_pos
;
89 /** Scrollbar geometry.
91 * Computed rectangles of scrollbar elements.
94 /** Up button rectangle */
95 gfx_rect_t up_btn_rect
;
96 /** Trough rectangle */
97 gfx_rect_t trough_rect
;
98 /** Upper trough rectangle */
99 gfx_rect_t upper_trough_rect
;
100 /** Thumb rectangle */
101 gfx_rect_t thumb_rect
;
102 /** Lower trough rectangle */
103 gfx_rect_t lower_trough_rect
;
104 /** Down button rectangle */
105 gfx_rect_t down_btn_rect
;
106 } ui_scrollbar_geom_t
;
108 extern errno_t
ui_scrollbar_paint_gfx(ui_scrollbar_t
*);
109 extern errno_t
ui_scrollbar_paint_text(ui_scrollbar_t
*);
110 extern void ui_scrollbar_get_geom(ui_scrollbar_t
*, ui_scrollbar_geom_t
*);