From f57e2eabe0a10c9732c83532e01654a499fb8dcf Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 21 Jun 2021 17:47:13 -0400 Subject: many, many changes; settings is broken --- src/user/settings/model.h | 60 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 12 deletions(-) (limited to 'src/user/settings/model.h') diff --git a/src/user/settings/model.h b/src/user/settings/model.h index 0c9b1d2..410121f 100644 --- a/src/user/settings/model.h +++ b/src/user/settings/model.h @@ -1,24 +1,60 @@ #ifndef MODEL_H #define MODEL_H -#include -#include +#include +#include +#include +#include +#include +#include +#include -union setting_data { - char *string; - _pixel_t color; +typedef void *backing_t; + +struct setting; + +struct setting_kind_info { + void (*write_main)(uint32_t &data_offset, file *f, const backing_t backing); + void (*write_data)(file *f, const backing_t backing); + backing_t (*read_backing)(file *f, uint32_t data_start); + void (*open_editor)(setting &s); }; struct setting { - enum { - STRING, - COLOR - } kind; - union setting_data data; const char *name; + const setting_kind_info *kind; + void *backing; +}; + +class settings_model { +public: + settings_model(const char *from_file); + + void write_to_file(const char *to_file); + + alist settings; }; -extern alist settings; -extern raleigh::saving_window *main_w; +using namespace raleigh; + +template +void do_common_editor(setting &s) { + dllist widgets; + + label l(s.name); + widgets.add_back(l); + + editing_widget ew; + load_into_widget(ew, (backing_type)s.backing); + widgets.add_back(ew); + + vbox box(widgets); + + dialog d(box, okay_cancel); + d.show_modal(); + + if (d.result == OKAY) + save_from_widget(ew, (backing_type &)s.backing); +} #endif \ No newline at end of file -- cgit v1.2.3