tmenu.h - ltk - Socket-based GUI for X11 (WIP)
HTML git clone git://lumidify.org/ltk.git (fast, but not encrypted)
HTML git clone https://lumidify.org/git/ltk.git (encrypted, but very slow)
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
tmenu.h (2696B)
---
1 /*
2 * Copyright (c) 2022 lumidify <nobody@lumidify.org>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef LTK_MENU_H
18 #define LTK_MENU_H
19
20 #include "cmd.h"
21 #include "ltk.h"
22 #include "text.h"
23 #include "widget.h"
24
25 typedef struct ltk_menuentry ltk_menuentry;
26
27 typedef struct {
28 ltk_widget widget;
29 ltk_menuentry **entries;
30 size_t num_entries;
31 size_t num_alloc;
32 double x_scroll_offset;
33 double y_scroll_offset;
34 int scroll_timer_id;
35 char is_submenu;
36 char was_opened_left;
37 char was_opened_above;
38 /* FIXME: better names */
39 char popup_submenus;
40 char unpopup_submenus_on_hide;
41 char scroll_top_hover;
42 char scroll_bottom_hover;
43 char scroll_left_hover;
44 char scroll_right_hover;
45 } ltk_menu;
46
47 /* FIXME: maybe need to set entire widget hierarchy to hover state so menu entry
48 is also hover when nested widget is hover? */
49
50 struct ltk_menuentry {
51 ltk_widget widget;
52 /* FIXME: I guess if the regular label got the ability to
53 change its color, a label could just be used instead of this */
54 ltk_text_line *text_line;
55 ltk_surface_cache_key *text_surface_key;
56 ltk_menu *submenu;
57 };
58
59 int ltk_menu_ini_handler(ltk_window *window, const char *prop, const char *value);
60 int ltk_menu_fill_theme_defaults(ltk_window *window);
61 void ltk_menu_uninitialize_theme(ltk_window *window);
62 int ltk_submenu_ini_handler(ltk_window *window, const char *prop, const char *value);
63 int ltk_submenu_fill_theme_defaults(ltk_window *window);
64 void ltk_submenu_uninitialize_theme(ltk_window *window);
65
66 int ltk_menuentry_ini_handler(ltk_window *window, const char *prop, const char *value);
67 int ltk_menuentry_fill_theme_defaults(ltk_window *window);
68 void ltk_menuentry_uninitialize_theme(ltk_window *window);
69 int ltk_submenuentry_ini_handler(ltk_window *window, const char *prop, const char *value);
70 int ltk_submenuentry_fill_theme_defaults(ltk_window *window);
71 void ltk_submenuentry_uninitialize_theme(ltk_window *window);
72
73 GEN_CMD_HELPERS_PROTO(ltk_menu_cmd)
74 GEN_CMD_HELPERS_PROTO(ltk_menuentry_cmd)
75
76 #endif /* LTK_MENU_H */