-
Notifications
You must be signed in to change notification settings - Fork 50
Initial Snowy, Tintin, and Chalk(?) support for About window #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
6054e14
298b239
98f369c
2dc6324
6767af4
5115aae
ad22f7b
3261de7
ece5963
0669fec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,20 @@ | |
| #include "node_list.h" | ||
|
|
||
| extern void flash_dump(void); | ||
| extern const char git_version[]; | ||
|
|
||
| static Window *s_main_window; | ||
| static Menu *s_menu; | ||
|
|
||
| static Window *s_about_window; | ||
| static Layer *s_aboutCanvas_layer; | ||
| static ScrollLayer *s_about_scroll; | ||
| static void about_update_proc(Layer *layer, GContext *nGContext); | ||
| static GBitmap *logo_color; | ||
| static GBitmap *rocket_color; | ||
| static GBitmap *logo_bw; | ||
| static GBitmap *rocket_color; | ||
|
|
||
| StatusBarLayer *status_bar; | ||
|
|
||
| typedef struct { | ||
|
|
@@ -59,6 +69,12 @@ static MenuItems* notification_item_selected(const MenuItem *item) | |
| return NULL; | ||
| } | ||
|
|
||
| static MenuItems* about_item_selected(const MenuItem *item) | ||
| { | ||
| window_stack_push(s_about_window, false); | ||
| return NULL; | ||
| } | ||
|
|
||
| static MenuItems* watch_list_item_selected(const MenuItem *item) { | ||
| MenuItems *items = menu_items_create(16); | ||
| // loop through all apps | ||
|
|
@@ -123,7 +139,7 @@ static void systemapp_window_load(Window *window) | |
| menu_items_add(items, MenuItem("Settings", "Config", RESOURCE_ID_SPANNER, settings_item_selected)); | ||
| menu_items_add(items, MenuItem("Tests", NULL, RESOURCE_ID_CLOCK, run_test_item_selected)); | ||
| menu_items_add(items, MenuItem("Notifications", NULL, RESOURCE_ID_SPEECH_BUBBLE, notification_item_selected)); | ||
| menu_items_add(items, MenuItem("RebbleOS", "... v0.0.0.2", RESOURCE_ID_SPEECH_BUBBLE, NULL)); | ||
| menu_items_add(items, MenuItem("RebbleOS", "... v0.0.0.2", RESOURCE_ID_SPEECH_BUBBLE, about_item_selected)); | ||
| menu_set_items(s_menu, items); | ||
|
|
||
| #ifdef PBL_RECT | ||
|
|
@@ -140,6 +156,86 @@ static void systemapp_window_unload(Window *window) | |
| menu_destroy(s_menu); | ||
| } | ||
|
|
||
| static void window_exit_handler(ClickRecognizerRef recognizer, void *context) | ||
| { | ||
| window_stack_pop(true); | ||
| } | ||
|
|
||
| static void about_window_load(Window *window) | ||
| { | ||
| Layer *window_layer = window_get_root_layer(s_about_window); | ||
| GRect bounds = layer_get_bounds(window_layer); | ||
|
|
||
| status_bar = status_bar_layer_create(); | ||
| status_bar_layer_set_separator_mode(status_bar, StatusBarLayerSeparatorModeDotted); | ||
|
|
||
| #ifdef PBL_BW | ||
| status_bar_layer_set_colors(status_bar, GColorBlack, GColorWhite); | ||
| #else | ||
| status_bar_layer_set_colors(status_bar, GColorRed, GColorWhite); | ||
| #endif | ||
|
|
||
|
|
||
| status_bar_layer_set_text(status_bar, "About RebbleOS"); | ||
|
|
||
| s_about_scroll = scroll_layer_create(bounds); | ||
| scroll_layer_set_click_config_onto_window(s_about_scroll, window); | ||
|
|
||
| s_aboutCanvas_layer = layer_create(bounds); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. caution mixed indentation (we aren't great about this internally righ tnow so I won't block merge on this) |
||
| layer_set_update_proc(s_aboutCanvas_layer, about_update_proc); | ||
| scroll_layer_add_child(s_about_scroll, s_aboutCanvas_layer); | ||
| layer_mark_dirty(s_aboutCanvas_layer); | ||
|
|
||
| layer_add_child(window_layer, scroll_layer_get_layer(s_about_scroll)); | ||
| layer_add_child(window_layer, status_bar_layer_get_layer(status_bar)); | ||
|
|
||
| #ifdef PBL_BW | ||
| logo_bw = gbitmap_create_with_resource(RESOURCE_ID_REBBLE_LOGO_BW); | ||
| //TODO: rocket_bw = | ||
| #else | ||
| logo_color = gbitmap_create_with_resource(RESOURCE_ID_REBBLE_LOGO_DARK); | ||
| rocket_color = gbitmap_create_with_resource(RESOURCE_ID_TO_MOON); | ||
| #endif | ||
|
|
||
| } | ||
|
|
||
| static void about_update_proc(Layer *layer, GContext *nGContext) | ||
| { | ||
| GRect bounds = layer_get_unobstructed_bounds(layer); | ||
| graphics_context_set_text_color(nGContext, GColorBlack); | ||
| graphics_context_set_compositing_mode(nGContext, GCompOpSet); | ||
|
|
||
| window_single_click_subscribe(BUTTON_ID_BACK, window_exit_handler); | ||
|
|
||
| graphics_draw_text(nGContext, "Version:", fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect((bounds.size.w/2)-70, (bounds.size.h/2)-10, 140, 20), | ||
| GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, 0); | ||
|
|
||
| graphics_draw_text(nGContext, git_version, fonts_get_system_font(FONT_KEY_GOTHIC_18), GRect((bounds.size.w/2)-70, (bounds.size.h/2)+5, 140, 20), | ||
| GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, 0); | ||
|
|
||
| graphics_draw_text(nGContext, "Join us!", fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), GRect((bounds.size.w/2)-70, (bounds.size.h/2)+20, 140, 20), | ||
| GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, 0); | ||
|
|
||
| graphics_draw_text(nGContext, "https://rebble.io/discord", fonts_get_system_font(FONT_KEY_GOTHIC_14), GRect((bounds.size.w/2)-70, (bounds.size.h/2)+38, 140, 20), | ||
| GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, 0); | ||
|
|
||
| #ifdef PBL_BW | ||
| graphics_draw_bitmap_in_rect(nGContext, logo_bw, GRect((bounds.size.w/2)-17, (bounds.size.h/2)-63, 34, 53)); | ||
| //TODO: Get black and white rocket bitmap for Classic | ||
| //graphics_draw_bitmap_in_rect(nGContext, gbitmap_create_with_resource(RESOURCE_ID_TO_MOON_BW), GRect((bounds.size.w/2)-8, (bounds.size.h/2)+60, 19, 19)); | ||
| #else | ||
| graphics_draw_bitmap_in_rect(nGContext, logo_color, GRect((bounds.size.w/2)-17, (bounds.size.h/2)-63, 34, 53)); | ||
| graphics_draw_bitmap_in_rect(nGContext, rocket_color, GRect((bounds.size.w/2)-8, (bounds.size.h/2)+60, 19, 19)); | ||
| #endif | ||
| } | ||
|
|
||
| static void about_window_unload(Window *window) | ||
| { | ||
| scroll_layer_destroy(s_about_scroll); | ||
| gbitmap_destroy(logo_color); | ||
|
||
| gbitmap_destroy(rocket_color); | ||
| } | ||
|
|
||
| void systemapp_init(void) | ||
| { | ||
| s_main_window = window_create(); | ||
|
|
@@ -149,12 +245,20 @@ void systemapp_init(void) | |
| .unload = systemapp_window_unload, | ||
| }); | ||
|
|
||
| s_about_window = window_create(); | ||
|
|
||
| window_set_window_handlers(s_about_window, (WindowHandlers) { | ||
| .load = about_window_load, | ||
| .unload = about_window_unload, | ||
| }); | ||
|
|
||
| window_stack_push(s_main_window, true); | ||
| } | ||
|
|
||
| void systemapp_deinit(void) | ||
| { | ||
| window_destroy(s_main_window); | ||
| window_destroy(s_about_window); | ||
| } | ||
|
|
||
| void systemapp_main(void) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.