Skip to content

Commit

Permalink
wip: save/restore ui window open state code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Dec 19, 2024
1 parent 5d7b19a commit 4abd3b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion examples/common/ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ static void imgui_ApplyAllFn(ImGuiContext* ctx, ImGuiSettingsHandler* handler) {
static void imgui_WriteAllFn(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) {
(void)ctx; (void)handler;
if (state.save_settings_cb) {
ui_settings_t settings = state.save_settings_cb();
ui_settings_t settings;
ui_settings_init(&settings);
state.save_settings_cb(&settings);
buf->reserve(buf->size() + settings.num_slots * 64);
for (int i = 0; i < settings.num_slots; i++) {
const ui_settings_slot_t* slot = &settings.slots[i];
Expand Down
2 changes: 1 addition & 1 deletion examples/common/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern "C" {
typedef uint64_t ui_texture_t;

typedef void (*ui_draw_t)(void);
typedef ui_settings_t (*ui_save_settings_t)(void);
typedef void (*ui_save_settings_t)(ui_settings_t* settings);

typedef struct {
ui_draw_t draw_cb;
Expand Down
6 changes: 3 additions & 3 deletions examples/sokol/atom.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static struct {

#ifdef CHIPS_USE_UI
static void ui_draw_cb(void);
static ui_settings_t ui_save_settings_cb(void);
static void ui_save_settings_cb(ui_settings_t* settings);
static void ui_boot_cb(atom_t* sys);
static void ui_save_snapshot(size_t slot_index);
static bool ui_load_snapshot(size_t slot_index);
Expand Down Expand Up @@ -305,8 +305,8 @@ static void ui_draw_cb(void) {
ui_atom_draw(&state.ui);
}

static ui_settings_t ui_save_settings_cb(void) {
return ui_atom_save_settings(&state.ui);
static void ui_save_settings_cb(ui_settings_t* settings) {
ui_atom_save_settings(&state.ui, settings);
}

static void ui_boot_cb(atom_t* sys) {
Expand Down

0 comments on commit 4abd3b6

Please sign in to comment.