Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
824 theseven 1
//
2
//
3
//    Copyright 2011 TheSeven
4
//
5
//
6
//    This file is part of emCORE.
7
//
8
//    emCORE is free software: you can redistribute it and/or
9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
13
//    emCORE is distributed in the hope that it will be useful,
14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
24
#ifndef __SETTINGCHOOSER_H__
25
#define __SETTINGCHOOSER_H__
26
 
27
#include "emcorelib.h"
28
#include "libui.h"
29
#include "chooser_renderer_list.h"
30
 
31
 
32
struct settingchooser_item_config_integer
33
{
34
    int min;
35
    int max;
36
    int step;
37
    int (*tostring)(char* buf, int buflen, void* setting, int value);
38
};
39
 
40
struct settingchooser_select_option
41
{
42
    const char* preview;
43
    const char* text;
44
    struct libui_surface icon;
45
    struct libui_surface icon_selected;
46
};
47
#define SETTINGCHOOSER_SELECT_OPTION(a, b, c, d) \
48
{                      \
49
    .preview = a,      \
50
    .text = b,         \
51
    .icon = c,         \
52
    .icon_selected = d \
53
}
54
#define SETTINGCHOOSER_SELECT_OPTION_NULL \
55
    SETTINGCHOOSER_SELECT_OPTION(NULL, NULL, LIBUI_SURFACE_NULL, LIBUI_SURFACE_NULL)
56
 
57
struct settingchooser_select_options
58
{
59
    int optioncount;
60
    struct settingchooser_select_option options[];
61
};
62
 
63
struct settingchooser_item_config_select
64
{
65
    const struct settingchooser_select_options* options;
66
};
67
 
68
union settingchooser_item_config
69
{
70
    struct settingchooser_item_config_integer integer;
71
    struct settingchooser_item_config_select select;
72
};
73
 
74
enum settingchooser_type
75
{
76
    SETTINGCHOOSER_TYPE_NULL = 0,
77
    SETTINGCHOOSER_TYPE_INTEGER,
78
    SETTINGCHOOSER_TYPE_SELECT
79
};
80
 
81
struct settingchooser_item
82
{
83
    const char* text;
84
    struct libui_surface icon;
85
    struct libui_surface icon_selected;
86
    enum settingchooser_type type;
87
    void* setting;
88
    void (*validator)(void* setting);
89
    union settingchooser_item_config config;
90
};
91
 
92
struct settingchooser_itemparams
93
{
94
    struct libui_point size;
95
    struct libui_box fill_box;
96
    uint32_t fill_color;
97
    uint32_t fill_color_selected;
98
    uint32_t fill_color_active;
99
    struct libui_point icon_pos;
100
    int icon_opacity;
101
    int icon_selected_opacity;
102
    int icon_active_opacity;
103
    struct libui_point text_pos;
104
    uint32_t text_color;
105
    uint32_t text_color_selected;
106
    uint32_t text_color_active;
107
};
108
 
109
#define SETTINGCHOOSER_INFO_VERSION 1
110
struct settingchooser_info
111
{
112
    int version;
113
    struct chooser_renderer_list_params rendererparams;
114
    struct settingchooser_itemparams itemparams;
115
    const char* returntext;
116
    long tickinterval;
117
    int itemcount;
118
    const struct settingchooser_item items[];
119
};
120
 
121
struct settingchooser_data
122
{
123
    const struct settingchooser_info* info;
124
    bool changed;
125
    bool editing;
126
    int collect;
127
};
128
 
129
 
130
bool settingchooser_run(const struct settingchooser_info* info);
131
 
132
 
133
#endif