Skip to content

Commit 8a1e555

Browse files
terttyjwise
authored andcommitted
Initial Snowy, Tintin, and Chalk(?) support for About window (#82)
* Updated about screen to match current project. * Update resource pack with about screen icons. * Updated Discord link * Stop update layer from redrawing bitmaps each time * Updated about screen to match current project. * Updated Discord link * Stop update layer from redrawing bitmaps each time * Taking out the garbage and leaking aplite_love
1 parent 2dc6324 commit 8a1e555

2 files changed

Lines changed: 99 additions & 1 deletion

File tree

Apps/System/systemapp.c

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@
1414
#include "node_list.h"
1515

1616
extern void flash_dump(void);
17+
extern const char git_version[];
1718

1819
static Window *s_main_window;
1920
static Menu *s_menu;
2021

22+
static Window *s_about_window;
23+
static Layer *s_aboutCanvas_layer;
24+
static ScrollLayer *s_about_scroll;
25+
static void about_update_proc(Layer *layer, GContext *nGContext);
26+
static GBitmap *logo_bitmap;
27+
static GBitmap *rocket_bitmap;
28+
2129
StatusBarLayer *status_bar;
2230

2331
typedef struct {
@@ -59,6 +67,12 @@ static MenuItems* notification_item_selected(const MenuItem *item)
5967
return NULL;
6068
}
6169

70+
static MenuItems* about_item_selected(const MenuItem *item)
71+
{
72+
window_stack_push(s_about_window, false);
73+
return NULL;
74+
}
75+
6276
static MenuItems* watch_list_item_selected(const MenuItem *item) {
6377
MenuItems *items = menu_items_create(16);
6478
// loop through all apps
@@ -123,7 +137,7 @@ static void systemapp_window_load(Window *window)
123137
menu_items_add(items, MenuItem("Settings", "Config", RESOURCE_ID_SPANNER, settings_item_selected));
124138
menu_items_add(items, MenuItem("Tests", NULL, RESOURCE_ID_CLOCK, run_test_item_selected));
125139
menu_items_add(items, MenuItem("Notifications", NULL, RESOURCE_ID_SPEECH_BUBBLE, notification_item_selected));
126-
menu_items_add(items, MenuItem("RebbleOS", "... v0.0.0.2", RESOURCE_ID_SPEECH_BUBBLE, NULL));
140+
menu_items_add(items, MenuItem("RebbleOS", "... v0.0.0.2", RESOURCE_ID_SPEECH_BUBBLE, about_item_selected));
127141
menu_set_items(s_menu, items);
128142

129143
#ifdef PBL_RECT
@@ -140,6 +154,76 @@ static void systemapp_window_unload(Window *window)
140154
menu_destroy(s_menu);
141155
}
142156

157+
static void window_exit_handler(ClickRecognizerRef recognizer, void *context)
158+
{
159+
window_stack_pop(true);
160+
}
161+
162+
static void about_window_load(Window *window)
163+
{
164+
Layer *window_layer = window_get_root_layer(s_about_window);
165+
GRect bounds = layer_get_bounds(window_layer);
166+
167+
status_bar = status_bar_layer_create();
168+
status_bar_layer_set_separator_mode(status_bar, StatusBarLayerSeparatorModeDotted);
169+
170+
status_bar_layer_set_colors(status_bar, PBL_IF_COLOR_ELSE(GColorRed,GColorBlack), GColorWhite);
171+
172+
status_bar_layer_set_text(status_bar, "About RebbleOS");
173+
174+
s_about_scroll = scroll_layer_create(bounds);
175+
scroll_layer_set_click_config_onto_window(s_about_scroll, window);
176+
177+
s_aboutCanvas_layer = layer_create(bounds);
178+
layer_set_update_proc(s_aboutCanvas_layer, about_update_proc);
179+
scroll_layer_add_child(s_about_scroll, s_aboutCanvas_layer);
180+
layer_mark_dirty(s_aboutCanvas_layer);
181+
182+
layer_add_child(window_layer, scroll_layer_get_layer(s_about_scroll));
183+
layer_add_child(window_layer, status_bar_layer_get_layer(status_bar));
184+
185+
#ifdef PBL_BW
186+
//TODO: Get black and white rocket bitmap for Classic
187+
logo_bitmap = gbitmap_create_with_resource(RESOURCE_ID_REBBLE_LOGO_BW);
188+
rocket_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TO_MOON_BW);
189+
#else
190+
logo_bitmap = gbitmap_create_with_resource(RESOURCE_ID_REBBLE_LOGO_DARK);
191+
rocket_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TO_MOON);
192+
#endif
193+
194+
}
195+
196+
static void about_update_proc(Layer *layer, GContext *nGContext)
197+
{
198+
GRect bounds = layer_get_unobstructed_bounds(layer);
199+
graphics_context_set_text_color(nGContext, GColorBlack);
200+
graphics_context_set_compositing_mode(nGContext, GCompOpSet);
201+
202+
window_single_click_subscribe(BUTTON_ID_BACK, window_exit_handler);
203+
204+
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),
205+
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, 0);
206+
207+
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),
208+
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, 0);
209+
210+
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),
211+
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, 0);
212+
213+
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),
214+
GTextOverflowModeTrailingEllipsis, GTextAlignmentCenter, 0);
215+
216+
graphics_draw_bitmap_in_rect(nGContext, logo_bitmap, GRect((bounds.size.w/2)-17, (bounds.size.h/2)-63, 34, 53));
217+
graphics_draw_bitmap_in_rect(nGContext, rocket_bitmap, GRect((bounds.size.w/2)-8, (bounds.size.h/2)+60, 19, 19));
218+
}
219+
220+
static void about_window_unload(Window *window)
221+
{
222+
scroll_layer_destroy(s_about_scroll);
223+
gbitmap_destroy(logo_bitmap);
224+
gbitmap_destroy(rocket_bitmap);
225+
}
226+
143227
void systemapp_init(void)
144228
{
145229
s_main_window = window_create();
@@ -149,12 +233,20 @@ void systemapp_init(void)
149233
.unload = systemapp_window_unload,
150234
});
151235

236+
s_about_window = window_create();
237+
238+
window_set_window_handlers(s_about_window, (WindowHandlers) {
239+
.load = about_window_load,
240+
.unload = about_window_unload,
241+
});
242+
152243
window_stack_push(s_main_window, true);
153244
}
154245

155246
void systemapp_deinit(void)
156247
{
157248
window_destroy(s_main_window);
249+
window_destroy(s_about_window);
158250
}
159251

160252
void systemapp_main(void)

rwatch/pebble_defines.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
#define PBL_IF_RECT_ELSE(rct, round) (round)
1515
#endif
1616

17+
#ifdef PBL_BW
18+
#define PBL_IF_COLOR_ELSE(color, bw) (bw)
19+
#else
20+
#define PBL_IF_COLOR_ELSE(color, bw) (color)
21+
#endif
22+
1723
#if defined REBBLE_PLATFORM_TINTIN
1824
#define PBL_PLATFORM_SWITCH(tintin, snowy, chalk, diorite, emery) (tintin)
1925
#elif defined REBBLE_PLATFORM_SNOWY

0 commit comments

Comments
 (0)