diff --git a/src/simply/simply_menu.c b/src/simply/simply_menu.c index 9b7e7e50..a3e3fe65 100644 --- a/src/simply/simply_menu.c +++ b/src/simply/simply_menu.c @@ -18,7 +18,9 @@ #define MAX_CACHED_ITEMS IF_APLITE_ELSE(6, 51) -static const time_t SPINNER_MS = 66; +#define EMPTY_TITLE "" + +#define SPINNER_MS 66 typedef Packet MenuClearPacket; @@ -86,8 +88,6 @@ struct __attribute__((__packed__)) MenuSelectionPacket { static GColor8 s_normal_palette[] = { { GColorBlackARGB8 }, { GColorClearARGB8 } }; static GColor8 s_inverted_palette[] = { { GColorWhiteARGB8 }, { GColorClearARGB8 } }; -static char EMPTY_TITLE[] = ""; - static void simply_menu_clear_section_items(SimplyMenu *self, int section_index); static void simply_menu_clear(SimplyMenu *self); @@ -102,14 +102,14 @@ static void simply_menu_set_selection(SimplyMenu *self, MenuIndex menu_index, Me static void refresh_spinner_timer(SimplyMenu *self); -static int64_t get_milliseconds(void) { +static int64_t prv_get_milliseconds(void) { time_t now_s; uint16_t now_ms_part; time_ms(&now_s, &now_ms_part); return ((int64_t) now_s) * 1000 + now_ms_part; } -static bool send_menu_item(Command type, uint16_t section, uint16_t item) { +static bool prv_send_menu_item(Command type, uint16_t section, uint16_t item) { MenuItemEventPacket packet = { .packet.type = type, .packet.length = sizeof(packet), @@ -119,46 +119,46 @@ static bool send_menu_item(Command type, uint16_t section, uint16_t item) { return simply_msg_send_packet(&packet.packet); } -static bool send_menu_get_section(uint16_t index) { - return send_menu_item(CommandMenuGetSection, index, 0); +static bool prv_send_menu_get_section(uint16_t index) { + return prv_send_menu_item(CommandMenuGetSection, index, 0); } -static bool send_menu_get_item(uint16_t section, uint16_t index) { - return send_menu_item(CommandMenuGetItem, section, index); +static bool prv_send_menu_get_item(uint16_t section, uint16_t index) { + return prv_send_menu_item(CommandMenuGetItem, section, index); } -static bool send_menu_select_click(uint16_t section, uint16_t index) { - return send_menu_item(CommandMenuSelect, section, index); +static bool prv_send_menu_select_click(uint16_t section, uint16_t index) { + return prv_send_menu_item(CommandMenuSelect, section, index); } -static bool send_menu_select_long_click(uint16_t section, uint16_t index) { - return send_menu_item(CommandMenuLongSelect, section, index); +static bool prv_send_menu_select_long_click(uint16_t section, uint16_t index) { + return prv_send_menu_item(CommandMenuLongSelect, section, index); } -static bool section_filter(List1Node *node, void *data) { - SimplyMenuCommon *section = (SimplyMenuCommon*) node; - uint16_t section_index = (uint16_t)(uintptr_t) data; +static bool prv_section_filter(List1Node *node, void *data) { + SimplyMenuCommon *section = (SimplyMenuCommon *)node; + const uint16_t section_index = (uint16_t)(uintptr_t) data; return (section->section == section_index); } -static bool item_filter(List1Node *node, void *data) { - SimplyMenuItem *item = (SimplyMenuItem*) node; - uint32_t cell_index = (uint32_t)(uintptr_t) data; - uint16_t section_index = cell_index; - uint16_t row = cell_index >> 16; +static bool prv_item_filter(List1Node *node, void *data) { + SimplyMenuItem *item = (SimplyMenuItem *)node; + const uint32_t cell_index = (uint32_t)(uintptr_t) data; + const uint16_t section_index = cell_index; + const uint16_t row = cell_index >> 16; return (item->section == section_index && item->item == row); } -static bool request_item_filter(List1Node *node, void *data) { - SimplyMenuItem *item = (SimplyMenuItem*) node; - return (item->title == NULL); +static bool prv_request_item_filter(List1Node *node, void *data) { + return (((SimplyMenuItem *)node)->title == NULL); } -static SimplyMenuSection *get_menu_section(SimplyMenu *self, int index) { - return (SimplyMenuSection*) list1_find(self->menu_layer.sections, section_filter, (void*)(uintptr_t) index); +static SimplyMenuSection *prv_get_menu_section(SimplyMenu *self, int index) { + return (SimplyMenuSection*) list1_find(self->menu_layer.sections, prv_section_filter, + (void*)(uintptr_t) index); } -static void destroy_section(SimplyMenu *self, SimplyMenuSection *section) { +static void prv_destroy_section(SimplyMenu *self, SimplyMenuSection *section) { if (!section) { return; } list1_remove(&self->menu_layer.sections, §ion->node); if (section->title && section->title != EMPTY_TITLE) { @@ -168,17 +168,20 @@ static void destroy_section(SimplyMenu *self, SimplyMenuSection *section) { free(section); } -static void destroy_section_by_index(SimplyMenu *self, int section) { - destroy_section(self, (SimplyMenuSection*) list1_find( - self->menu_layer.sections, section_filter, (void*)(uintptr_t) section)); +static void prv_destroy_section_by_index(SimplyMenu *self, int section) { + SimplyMenuSection *section_node = + (SimplyMenuSection *)list1_find(self->menu_layer.sections, prv_section_filter, + (void *)(uintptr_t)section); + prv_destroy_section(self, section_node); } -static SimplyMenuItem *get_menu_item(SimplyMenu *self, int section, int index) { - uint32_t cell_index = section | (index << 16); - return (SimplyMenuItem*) list1_find(self->menu_layer.items, item_filter, (void*)(uintptr_t) cell_index); +static SimplyMenuItem *prv_get_menu_item(SimplyMenu *self, int section, int index) { + const uint32_t cell_index = section | (index << 16); + return (SimplyMenuItem *) list1_find(self->menu_layer.items, prv_item_filter, + (void *)(uintptr_t) cell_index); } -static void destroy_item(SimplyMenu *self, SimplyMenuItem *item) { +static void prv_destroy_item(SimplyMenu *self, SimplyMenuItem *item) { if (!item) { return; } list1_remove(&self->menu_layer.items, &item->node); if (item->title) { @@ -192,62 +195,60 @@ static void destroy_item(SimplyMenu *self, SimplyMenuItem *item) { free(item); } -static void destroy_item_by_index(SimplyMenu *self, int section, int index) { - uint32_t cell_index = section | (index << 16); - destroy_item(self, (SimplyMenuItem*) list1_find( - self->menu_layer.items, item_filter, (void*)(uintptr_t) cell_index)); +static void prv_destroy_item_by_index(SimplyMenu *self, int section, int index) { + const uint32_t cell_index = section | (index << 16); + SimplyMenuItem *item = + (SimplyMenuItem *)list1_find(self->menu_layer.items, prv_item_filter, + (void *)(uintptr_t) cell_index); + prv_destroy_item(self, item); } -static void add_section(SimplyMenu *self, SimplyMenuSection *section) { +static void prv_add_section(SimplyMenu *self, SimplyMenuSection *section) { if (list1_size(self->menu_layer.sections) >= MAX_CACHED_SECTIONS) { - destroy_section(self, (SimplyMenuSection*) list1_last(self->menu_layer.sections)); + prv_destroy_section(self, (SimplyMenuSection *)list1_last(self->menu_layer.sections)); } - destroy_section_by_index(self, section->section); + prv_destroy_section_by_index(self, section->section); list1_prepend(&self->menu_layer.sections, §ion->node); } -static void add_item(SimplyMenu *self, SimplyMenuItem *item) { +static void prv_add_item(SimplyMenu *self, SimplyMenuItem *item) { if (list1_size(self->menu_layer.items) >= MAX_CACHED_ITEMS) { - destroy_item(self, (SimplyMenuItem*) list1_last(self->menu_layer.items)); + prv_destroy_item(self, (SimplyMenuItem*) list1_last(self->menu_layer.items)); } - destroy_item_by_index(self, item->section, item->item); + prv_destroy_item_by_index(self, item->section, item->item); list1_prepend(&self->menu_layer.items, &item->node); } -static void request_menu_section(SimplyMenu *self, uint16_t section_index) { - SimplyMenuSection *section = get_menu_section(self, section_index); - if (section) { - return; - } +static void prv_request_menu_section(SimplyMenu *self, uint16_t section_index) { + SimplyMenuSection *section = prv_get_menu_section(self, section_index); + if (section) { return; } section = malloc(sizeof(*section)); *section = (SimplyMenuSection) { .section = section_index, }; - add_section(self, section); - send_menu_get_section(section_index); + prv_add_section(self, section); + prv_send_menu_get_section(section_index); } -static void request_menu_item(SimplyMenu *self, uint16_t section_index, uint16_t item_index) { - SimplyMenuItem *item = get_menu_item(self, section_index, item_index); - if (item) { - return; - } +static void prv_request_menu_item(SimplyMenu *self, uint16_t section_index, uint16_t item_index) { + SimplyMenuItem *item = prv_get_menu_item(self, section_index, item_index); + if (item) { return; } item = malloc(sizeof(*item)); *item = (SimplyMenuItem) { .section = section_index, .item = item_index, }; - add_item(self, item); - send_menu_get_item(section_index, item_index); + prv_add_item(self, item); + prv_send_menu_get_item(section_index, item_index); } -static void mark_dirty(SimplyMenu *self) { +static void prv_mark_dirty(SimplyMenu *self) { if (self->menu_layer.menu_layer) { layer_mark_dirty(menu_layer_get_layer(self->menu_layer.menu_layer)); } } -static void reload_data(SimplyMenu *self) { +static void prv_reload_data(SimplyMenu *self) { if (self->menu_layer.menu_layer) { menu_layer_reload_data(self->menu_layer.menu_layer); } @@ -258,51 +259,52 @@ static void simply_menu_set_num_sections(SimplyMenu *self, uint16_t num_sections num_sections = 1; } self->menu_layer.num_sections = num_sections; - reload_data(self); + prv_reload_data(self); } static void simply_menu_add_section(SimplyMenu *self, SimplyMenuSection *section) { if (section->title == NULL) { section->title = EMPTY_TITLE; } - add_section(self, section); - reload_data(self); + prv_add_section(self, section); + prv_reload_data(self); } static void simply_menu_add_item(SimplyMenu *self, SimplyMenuItem *item) { if (item->title == NULL) { item->title = EMPTY_TITLE; } - add_item(self, item); - mark_dirty(self); + prv_add_item(self, item); + prv_mark_dirty(self); } static MenuIndex simply_menu_get_selection(SimplyMenu *self) { return menu_layer_get_selected_index(self->menu_layer.menu_layer); } -static void simply_menu_set_selection(SimplyMenu *self, MenuIndex menu_index, MenuRowAlign align, bool animated) { +static void simply_menu_set_selection(SimplyMenu *self, MenuIndex menu_index, MenuRowAlign align, + bool animated) { menu_layer_set_selected_index(self->menu_layer.menu_layer, menu_index, align, animated); } -static bool send_menu_selection(SimplyMenu *self) { +static bool prv_send_menu_selection(SimplyMenu *self) { MenuIndex menu_index = simply_menu_get_selection(self); - return send_menu_item(CommandMenuSelectionEvent, menu_index.section, menu_index.row); + return prv_send_menu_item(CommandMenuSelectionEvent, menu_index.section, menu_index.row); } static void spinner_timer_callback(void *data) { SimplyMenu *self = data; self->spinner_timer = NULL; - mark_dirty(self); + prv_mark_dirty(self); refresh_spinner_timer(self); } static SimplyMenuItem *get_first_request_item(SimplyMenu *self) { - return (SimplyMenuItem*) list1_find(self->menu_layer.items, request_item_filter, NULL); + return (SimplyMenuItem *)list1_find(self->menu_layer.items, prv_request_item_filter, NULL); } static SimplyMenuItem *get_last_request_item(SimplyMenu *self) { - return (SimplyMenuItem*) list1_find_last(self->menu_layer.items, request_item_filter, NULL); + return (SimplyMenuItem *)list1_find_last(self->menu_layer.items, prv_request_item_filter, NULL); } static void refresh_spinner_timer(SimplyMenu *self) { @@ -311,28 +313,32 @@ static void refresh_spinner_timer(SimplyMenu *self) { } } -static uint16_t menu_get_num_sections_callback(MenuLayer *menu_layer, void *data) { +static uint16_t prv_menu_get_num_sections_callback(MenuLayer *menu_layer, void *data) { SimplyMenu *self = data; return self->menu_layer.num_sections; } -static uint16_t menu_get_num_rows_callback(MenuLayer *menu_layer, uint16_t section_index, void *data) { +static uint16_t prv_menu_get_num_rows_callback(MenuLayer *menu_layer, uint16_t section_index, + void *data) { SimplyMenu *self = data; - SimplyMenuSection *section = get_menu_section(self, section_index); + SimplyMenuSection *section = prv_get_menu_section(self, section_index); return section ? section->num_items : 1; } -static int16_t menu_get_header_height_callback(MenuLayer *menu_layer, uint16_t section_index, void *data) { +static int16_t prv_menu_get_header_height_callback(MenuLayer *menu_layer, uint16_t section_index, + void *data) { SimplyMenu *self = data; - SimplyMenuSection *section = get_menu_section(self, section_index); - return section && section->title && section->title != EMPTY_TITLE ? MENU_CELL_BASIC_HEADER_HEIGHT : 0; + SimplyMenuSection *section = prv_get_menu_section(self, section_index); + return (section && section->title && + section->title != EMPTY_TITLE ? MENU_CELL_BASIC_HEADER_HEIGHT : 0); } -static void menu_draw_header_callback(GContext *ctx, const Layer *cell_layer, uint16_t section_index, void *data) { +static void prv_menu_draw_header_callback(GContext *ctx, const Layer *cell_layer, + uint16_t section_index, void *data) { SimplyMenu *self = data; - SimplyMenuSection *section = get_menu_section(self, section_index); + SimplyMenuSection *section = prv_get_menu_section(self, section_index); if (!section) { - request_menu_section(self, section_index); + prv_request_menu_section(self, section_index); return; } @@ -343,12 +349,14 @@ static void menu_draw_header_callback(GContext *ctx, const Layer *cell_layer, ui bounds.origin.x += 2; bounds.origin.y -= 1; - graphics_context_set_text_color(ctx, gcolor8_get_or(self->menu_layer.normal_foreground, GColorBlack)); + graphics_context_set_text_color(ctx, gcolor8_get_or(self->menu_layer.normal_foreground, + GColorBlack)); graphics_draw_text(ctx, section->title, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD), bounds, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, NULL); } -static void simply_menu_draw_row_spinner(SimplyMenu *self, GContext *ctx, const Layer *cell_layer) { +static void simply_menu_draw_row_spinner(SimplyMenu *self, GContext *ctx, + const Layer *cell_layer) { GRect bounds = layer_get_bounds(cell_layer); GPoint center = grect_center_point(&bounds); @@ -357,13 +365,14 @@ static void simply_menu_draw_row_spinner(SimplyMenu *self, GContext *ctx, const const int16_t num_lines = 16; const int16_t num_drawn_lines = 3; - const int64_t now_ms = get_milliseconds(); + const int64_t now_ms = prv_get_milliseconds(); const uint32_t start_index = (now_ms / SPINNER_MS) % num_lines; graphics_context_set_antialiased(ctx, true); - GColor8 stroke_color = menu_cell_layer_is_highlighted(cell_layer) ? self->menu_layer.highlight_foreground - : self->menu_layer.normal_foreground; + GColor8 stroke_color = + menu_cell_layer_is_highlighted(cell_layer) ? self->menu_layer.highlight_foreground : + self->menu_layer.normal_foreground; graphics_context_set_stroke_color(ctx, gcolor8_get_or(stroke_color, GColorBlack)); for (int16_t i = 0; i < num_drawn_lines; i++) { @@ -374,17 +383,18 @@ static void simply_menu_draw_row_spinner(SimplyMenu *self, GContext *ctx, const } } -static void menu_draw_row_callback(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) { +static void prv_menu_draw_row_callback(GContext *ctx, const Layer *cell_layer, + MenuIndex *cell_index, void *data) { SimplyMenu *self = data; - SimplyMenuSection *section = get_menu_section(self, cell_index->section); + SimplyMenuSection *section = prv_get_menu_section(self, cell_index->section); if (!section) { - request_menu_section(self, cell_index->section); + prv_request_menu_section(self, cell_index->section); return; } - SimplyMenuItem *item = get_menu_item(self, cell_index->section, cell_index->row); + SimplyMenuItem *item = prv_get_menu_item(self, cell_index->section, cell_index->row); if (!item) { - request_menu_item(self, cell_index->section, cell_index->row); + prv_request_menu_item(self, cell_index->section, cell_index->row); return; } @@ -406,7 +416,8 @@ static void menu_draw_row_callback(GContext *ctx, const Layer *cell_layer, MenuI if (image && image->is_palette_black_and_white) { palette = gbitmap_get_palette(image->bitmap); const bool is_highlighted = menu_cell_layer_is_highlighted(cell_layer); - gbitmap_set_palette(image->bitmap, is_highlighted ? s_inverted_palette : s_normal_palette, false); + gbitmap_set_palette(image->bitmap, is_highlighted ? s_inverted_palette : s_normal_palette, + false); } graphics_context_set_alpha_blended(ctx, true); @@ -417,26 +428,28 @@ static void menu_draw_row_callback(GContext *ctx, const Layer *cell_layer, MenuI } } -static void menu_select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) { - send_menu_select_click(cell_index->section, cell_index->row); +static void prv_menu_select_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, + void *data) { + prv_send_menu_select_click(cell_index->section, cell_index->row); } -static void menu_select_long_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) { - send_menu_select_long_click(cell_index->section, cell_index->row); +static void prv_menu_select_long_click_callback(MenuLayer *menu_layer, MenuIndex *cell_index, + void *data) { + prv_send_menu_select_long_click(cell_index->section, cell_index->row); } -static void single_click_handler(ClickRecognizerRef recognizer, void *context) { +static void prv_single_click_handler(ClickRecognizerRef recognizer, void *context) { Window *base_window = layer_get_window(context); SimplyWindow *window = window_get_user_data(base_window); simply_window_single_click_handler(recognizer, window); } -static void click_config_provider(void *context) { - window_single_click_subscribe(BUTTON_ID_BACK, single_click_handler); +static void prv_click_config_provider(void *context) { + window_single_click_subscribe(BUTTON_ID_BACK, prv_single_click_handler); menu_layer_click_config(context); } -static void window_load(Window *window) { +static void prv_menu_window_load(Window *window) { SimplyMenu *self = window_get_user_data(window); simply_window_load(&self->window); @@ -451,24 +464,24 @@ static void window_load(Window *window) { layer_add_child(window_layer, menu_base_layer); menu_layer_set_callbacks(menu_layer, self, (MenuLayerCallbacks){ - .get_num_sections = menu_get_num_sections_callback, - .get_num_rows = menu_get_num_rows_callback, - .get_header_height = menu_get_header_height_callback, - .draw_header = menu_draw_header_callback, - .draw_row = menu_draw_row_callback, - .select_click = menu_select_click_callback, - .select_long_click = menu_select_long_click_callback, + .get_num_sections = prv_menu_get_num_sections_callback, + .get_num_rows = prv_menu_get_num_rows_callback, + .get_header_height = prv_menu_get_header_height_callback, + .draw_header = prv_menu_draw_header_callback, + .draw_row = prv_menu_draw_row_callback, + .select_click = prv_menu_select_click_callback, + .select_long_click = prv_menu_select_long_click_callback, }); - menu_layer_set_click_config_provider_onto_window(menu_layer, click_config_provider, window); + menu_layer_set_click_config_provider_onto_window(menu_layer, prv_click_config_provider, window); } -static void window_appear(Window *window) { +static void prv_menu_window_appear(Window *window) { SimplyMenu *self = window_get_user_data(window); simply_window_appear(&self->window); } -static void window_disappear(Window *window) { +static void prv_menu_window_disappear(Window *window) { SimplyMenu *self = window_get_user_data(window); if (simply_window_disappear(&self->window)) { simply_res_clear(self->window.simply->res); @@ -476,7 +489,7 @@ static void window_disappear(Window *window) { } } -static void window_unload(Window *window) { +static void prv_menu_window_unload(Window *window) { SimplyMenu *self = window_get_user_data(window); menu_layer_destroy(self->menu_layer.menu_layer); @@ -488,65 +501,62 @@ static void window_unload(Window *window) { static void simply_menu_clear_section_items(SimplyMenu *self, int section_index) { SimplyMenuItem *item = NULL; do { - item = (SimplyMenuItem*) list1_find(self->menu_layer.items, section_filter, (void*)(uintptr_t) section_index); - destroy_item(self, item); + item = (SimplyMenuItem *)list1_find(self->menu_layer.items, prv_section_filter, + (void *)(uintptr_t) section_index); + prv_destroy_item(self, item); } while (item); } static void simply_menu_clear(SimplyMenu *self) { while (self->menu_layer.sections) { - destroy_section(self, (SimplyMenuSection*) self->menu_layer.sections); + prv_destroy_section(self, (SimplyMenuSection *)self->menu_layer.sections); } while (self->menu_layer.items) { - destroy_item(self, (SimplyMenuItem*) self->menu_layer.items); + prv_destroy_item(self, (SimplyMenuItem *)self->menu_layer.items); } - reload_data(self); + prv_reload_data(self); } -static void handle_menu_clear_packet(Simply *simply, Packet *data) { +static void prv_handle_menu_clear_packet(Simply *simply, Packet *data) { simply_menu_clear(simply->menu); } -static void handle_menu_clear_section_packet(Simply *simply, Packet *data) { - MenuClearSectionPacket *packet = (MenuClearSectionPacket*) data; +static void prv_handle_menu_clear_section_packet(Simply *simply, Packet *data) { + MenuClearSectionPacket *packet = (MenuClearSectionPacket *)data; simply_menu_clear_section_items(simply->menu, packet->section); } -static void handle_menu_props_packet(Simply *simply, Packet *data) { - MenuPropsPacket *packet = (MenuPropsPacket*) data; +static void prv_handle_menu_props_packet(Simply *simply, Packet *data) { + MenuPropsPacket *packet = (MenuPropsPacket *)data; SimplyMenu *self = simply->menu; simply_menu_set_num_sections(self, packet->num_sections); - if (!self->window.window) { - return; - } - - window_set_background_color(self->window.window, gcolor8_get_or(packet->background_color, GColorWhite)); - - if (!self->menu_layer.menu_layer) { - return; - } + if (!self->window.window) { return; } - self->menu_layer.normal_background = packet->background_color; - self->menu_layer.normal_foreground = packet->text_color; + window_set_background_color(self->window.window, gcolor8_get_or(packet->background_color, + GColorWhite)); - self->menu_layer.highlight_background = packet->highlight_background_color; - self->menu_layer.highlight_foreground = packet->highlight_text_color; + SimplyMenuLayer *menu_layer = &self->menu_layer; + if (!menu_layer->menu_layer) { return; } - menu_layer_set_normal_colors(simply->menu->menu_layer.menu_layer, - gcolor8_get_or(self->menu_layer.normal_background, GColorWhite), - gcolor8_get_or(self->menu_layer.normal_foreground, GColorBlack)); + menu_layer->normal_background = packet->background_color; + menu_layer->normal_foreground = packet->text_color; + menu_layer->highlight_background = packet->highlight_background_color; + menu_layer->highlight_foreground = packet->highlight_text_color; - menu_layer_set_highlight_colors(simply->menu->menu_layer.menu_layer, - gcolor8_get_or(self->menu_layer.highlight_background, GColorBlack), - gcolor8_get_or(self->menu_layer.highlight_foreground, GColorWhite)); + menu_layer_set_normal_colors(menu_layer->menu_layer, + gcolor8_get_or(menu_layer->normal_background, GColorWhite), + gcolor8_get_or(menu_layer->normal_foreground, GColorBlack)); + menu_layer_set_highlight_colors(menu_layer->menu_layer, + gcolor8_get_or(menu_layer->highlight_background, GColorBlack), + gcolor8_get_or(menu_layer->highlight_foreground, GColorWhite)); } -static void handle_menu_section_packet(Simply *simply, Packet *data) { - MenuSectionPacket *packet = (MenuSectionPacket*) data; +static void prv_handle_menu_section_packet(Simply *simply, Packet *data) { + MenuSectionPacket *packet = (MenuSectionPacket *)data; SimplyMenuSection *section = malloc(sizeof(*section)); *section = (SimplyMenuSection) { .section = packet->section, @@ -556,8 +566,8 @@ static void handle_menu_section_packet(Simply *simply, Packet *data) { simply_menu_add_section(simply->menu, section); } -static void handle_menu_item_packet(Simply *simply, Packet *data) { - MenuItemPacket *packet = (MenuItemPacket*) data; +static void prv_handle_menu_item_packet(Simply *simply, Packet *data) { + MenuItemPacket *packet = (MenuItemPacket *)data; SimplyMenuItem *item = malloc(sizeof(*item)); *item = (SimplyMenuItem) { .section = packet->section, @@ -569,12 +579,12 @@ static void handle_menu_item_packet(Simply *simply, Packet *data) { simply_menu_add_item(simply->menu, item); } -static void handle_menu_get_selection_packet(Simply *simply, Packet *data) { - send_menu_selection(simply->menu); +static void prv_handle_menu_get_selection_packet(Simply *simply, Packet *data) { + prv_send_menu_selection(simply->menu); } -static void handle_menu_selection_packet(Simply *simply, Packet *data) { - MenuSelectionPacket *packet = (MenuSelectionPacket*) data; +static void prv_handle_menu_selection_packet(Simply *simply, Packet *data) { + MenuSelectionPacket *packet = (MenuSelectionPacket *)data; MenuIndex menu_index = { .section = packet->section, .row = packet->item, @@ -585,25 +595,25 @@ static void handle_menu_selection_packet(Simply *simply, Packet *data) { bool simply_menu_handle_packet(Simply *simply, Packet *packet) { switch (packet->type) { case CommandMenuClear: - handle_menu_clear_packet(simply, packet); + prv_handle_menu_clear_packet(simply, packet); return true; case CommandMenuClearSection: - handle_menu_clear_section_packet(simply, packet); + prv_handle_menu_clear_section_packet(simply, packet); return true; case CommandMenuProps: - handle_menu_props_packet(simply, packet); + prv_handle_menu_props_packet(simply, packet); return true; case CommandMenuSection: - handle_menu_section_packet(simply, packet); + prv_handle_menu_section_packet(simply, packet); return true; case CommandMenuItem: - handle_menu_item_packet(simply, packet); + prv_handle_menu_item_packet(simply, packet); return true; case CommandMenuSelection: - handle_menu_selection_packet(simply, packet); + prv_handle_menu_selection_packet(simply, packet); return true; case CommandMenuGetSelection: - handle_menu_get_selection_packet(simply, packet); + prv_handle_menu_get_selection_packet(simply, packet); return true; } return false; @@ -617,10 +627,10 @@ SimplyMenu *simply_menu_create(Simply *simply) { }; static const WindowHandlers s_window_handlers = { - .load = window_load, - .appear = window_appear, - .disappear = window_disappear, - .unload = window_unload, + .load = prv_menu_window_load, + .appear = prv_menu_window_appear, + .disappear = prv_menu_window_disappear, + .unload = prv_menu_window_unload, }; self->window.window_handlers = &s_window_handlers;