Iterative MenuLayer Pebble -
i trying create app on pebble using menulayer. intention create menu's , sub-menus using menulayer.
i did basic implementation using "menu_layer_set_callbacks" method , registering callbacks methods each submenu layers. however, realise getting messy.
i want know if there easy way out provided in framework meet requirement.
thanks.
kk
i don't know ended with, project, made set of sub-windows reuses same callbacks, can pass custom data let each know type is. push required sub-windows needed
void sub_window_load(window* parentwindow) { layer* window_layer = window_get_root_layer(parentwindow); const grect bounds = layer_get_frame(window_layer); menulayer* new_layer = menu_layer_create(bounds); const int context = *((int*) window_get_user_data(parentwindow)); if (context == id_a) s_a_layer = new_layer; else if (context == id_b) s_b_layer = new_layer; menu_layer_set_callbacks(new_layer, window_get_user_data(parentwindow), (menulayercallbacks){ .get_num_sections = sub_menu_get_num_sections_callback, .get_num_rows = sub_menu_get_num_rows_callback /* etc */ }); menu_layer_set_click_config_onto_window(new_layer, parentwindow); layer_add_child(window_layer, menu_layer_get_layer(new_layer)); } void createsubwin(window** w, int* context) { *w = window_create(); window_set_user_data(*w, context); window_set_window_handlers(*w, (windowhandlers) { .load = sub_window_load, .unload = sub_window_unload }); }
Comments
Post a Comment