[bd16113] | 1 | /*
|
---|
| 2 | * Copyright (c) 2022 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 Scrollbar structure
|
---|
| 34 | *
|
---|
| 35 | */
|
---|
| 36 |
|
---|
| 37 | #ifndef _UI_PRIVATE_SCROLLBAR_H
|
---|
| 38 | #define _UI_PRIVATE_SCROLLBAR_H
|
---|
| 39 |
|
---|
| 40 | #include <gfx/coord.h>
|
---|
| 41 | #include <stdbool.h>
|
---|
| 42 |
|
---|
| 43 | /** Actual structure of scrollbar.
|
---|
| 44 | *
|
---|
| 45 | * This is private to libui.
|
---|
| 46 | */
|
---|
| 47 | struct ui_scrollbar {
|
---|
| 48 | /** Base control object */
|
---|
| 49 | struct ui_control *control;
|
---|
| 50 | /** UI resource */
|
---|
| 51 | struct ui_resource *res;
|
---|
| 52 | /** Callbacks */
|
---|
| 53 | struct ui_scrollbar_cb *cb;
|
---|
| 54 | /** Callback argument */
|
---|
| 55 | void *arg;
|
---|
| 56 | /** Scrollbar rectangle */
|
---|
| 57 | gfx_rect_t rect;
|
---|
| 58 | /** Thumb length */
|
---|
| 59 | gfx_coord_t thumb_len;
|
---|
| 60 | /** Up button */
|
---|
[d4ea1f6] | 61 | struct ui_pbutton *up_btn;
|
---|
[bd16113] | 62 | /** Down button */
|
---|
[d4ea1f6] | 63 | struct ui_pbutton *down_btn;
|
---|
[bd16113] | 64 | /** Thumb is currently held down */
|
---|
[1026cc4] | 65 | bool thumb_held;
|
---|
| 66 | /** Up through is currently held down */
|
---|
| 67 | bool up_through_held;
|
---|
| 68 | /** Down through is currently held down */
|
---|
| 69 | bool down_through_held;
|
---|
[bd16113] | 70 | /** Position where thumb was pressed */
|
---|
| 71 | gfx_coord2_t press_pos;
|
---|
| 72 | /** Last thumb position */
|
---|
| 73 | gfx_coord_t last_pos;
|
---|
| 74 | /** Thumb position */
|
---|
| 75 | gfx_coord_t pos;
|
---|
| 76 | };
|
---|
| 77 |
|
---|
| 78 | /** Scrollbar geometry.
|
---|
| 79 | *
|
---|
| 80 | * Computed rectangles of scrollbar elements.
|
---|
| 81 | */
|
---|
| 82 | typedef struct {
|
---|
| 83 | /** Up button rectangle */
|
---|
| 84 | gfx_rect_t up_btn_rect;
|
---|
| 85 | /** Through rectangle */
|
---|
| 86 | gfx_rect_t through_rect;
|
---|
[1026cc4] | 87 | /** Up through rectangle */
|
---|
| 88 | gfx_rect_t up_through_rect;
|
---|
[bd16113] | 89 | /** Thumb rectangle */
|
---|
| 90 | gfx_rect_t thumb_rect;
|
---|
[1026cc4] | 91 | /** Down through rectangle */
|
---|
| 92 | gfx_rect_t down_through_rect;
|
---|
[bd16113] | 93 | /** Down button rectangle */
|
---|
| 94 | gfx_rect_t down_btn_rect;
|
---|
| 95 | } ui_scrollbar_geom_t;
|
---|
| 96 |
|
---|
| 97 | extern errno_t ui_scrollbar_paint_gfx(ui_scrollbar_t *);
|
---|
| 98 | extern errno_t ui_scrollbar_paint_text(ui_scrollbar_t *);
|
---|
| 99 | extern errno_t ui_scrollbar_thumb_clear(ui_scrollbar_t *);
|
---|
| 100 | extern void ui_scrollbar_get_geom(ui_scrollbar_t *, ui_scrollbar_geom_t *);
|
---|
| 101 |
|
---|
| 102 | #endif
|
---|
| 103 |
|
---|
| 104 | /** @}
|
---|
| 105 | */
|
---|