| 504 |
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 __CHOOSER_H__
|
|
|
25 |
#define __CHOOSER_H__
|
|
|
26 |
|
|
|
27 |
#include "emcorelib.h"
|
|
|
28 |
#include "libui.h"
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
enum chooser_result
|
|
|
32 |
{
|
|
|
33 |
CHOOSER_RESULT_OK = 0,
|
|
|
34 |
CHOOSER_RESULT_REDRAW,
|
|
|
35 |
CHOOSER_RESULT_FINISHED,
|
|
|
36 |
CHOOSER_RESULT_CANCEL
|
|
|
37 |
};
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
struct chooser_item
|
|
|
41 |
{
|
|
|
42 |
const void* user;
|
|
|
43 |
const void* actionparams;
|
|
|
44 |
const void* renderparams;
|
|
|
45 |
};
|
|
|
46 |
|
|
|
47 |
struct chooser_data;
|
|
|
48 |
|
|
|
49 |
#define CHOOSER_ACTION_HANDLER_VERSION 1
|
|
|
50 |
|
|
|
51 |
struct chooser_action_handler
|
|
|
52 |
{
|
|
|
53 |
int version;
|
|
|
54 |
int (*init)(struct chooser_data* data);
|
|
|
55 |
enum chooser_result (*handleevent)(struct chooser_data* data,
|
|
|
56 |
enum button_event event, int which, int value);
|
|
|
57 |
enum chooser_result (*handletick)(struct chooser_data* data);
|
|
|
58 |
int (*stepsperitem)(struct chooser_data* data);
|
|
|
59 |
void (*destroy)(struct chooser_data* data);
|
|
|
60 |
};
|
|
|
61 |
|
|
|
62 |
#define CHOOSER_RENDERER_VERSION 1
|
|
|
63 |
|
|
|
64 |
struct chooser_renderer
|
|
|
65 |
{
|
|
|
66 |
int version;
|
|
|
67 |
int (*init)(struct chooser_data* data);
|
|
|
68 |
enum chooser_result (*render)(struct chooser_data* data);
|
|
|
69 |
const struct chooser_item* (*itematpixel)(struct chooser_data* data, int x, int y);
|
|
|
70 |
void (*destroy)(struct chooser_data* data);
|
|
|
71 |
};
|
|
|
72 |
|
|
|
73 |
#define CHOOSER_INFO_VERSION 1
|
|
|
74 |
|
|
|
75 |
struct chooser_info
|
|
|
76 |
{
|
|
|
77 |
int version;
|
|
|
78 |
const struct chooser_action_handler* actionhandler;
|
|
|
79 |
const void* actionhandlerparams;
|
|
|
80 |
const struct chooser_renderer* renderer;
|
|
|
81 |
const void* rendererparams;
|
|
|
82 |
const void* userparams;
|
| 527 |
theseven |
83 |
long tickinterval;
|
| 504 |
theseven |
84 |
int itemcount;
|
|
|
85 |
int defaultitem;
|
|
|
86 |
const struct chooser_item items[];
|
|
|
87 |
};
|
|
|
88 |
|
|
|
89 |
struct chooser_data
|
|
|
90 |
{
|
|
|
91 |
const struct chooser_info* info;
|
|
|
92 |
struct mutex statemutex;
|
|
|
93 |
struct wakeup eventwakeup;
|
|
|
94 |
bool redrawneeded;
|
|
|
95 |
bool finished;
|
|
|
96 |
bool canceled;
|
|
|
97 |
const struct chooser_item* selected;
|
|
|
98 |
int position;
|
|
|
99 |
void* actionhandlerdata;
|
|
|
100 |
void* rendererdata;
|
|
|
101 |
void* userdata;
|
|
|
102 |
};
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
const struct chooser_item* chooser_run(const struct chooser_info* info);
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
#endif
|