Better support for non-Emery watches; initial PKJS prep
This commit is contained in:
1 parent
b12f84cb66
commit
74cbe957ee
2 files changed
+69
-11
No files matched your search
+3
-3
@@ -36,12 +36,12 @@
|
||||
"watchface": false
|
||||
},
|
||||
"messageKeys": [
|
||||
"IN_CURRENT_LEVEL",
|
||||
"PKJS_READY",
|
||||
"IN_VANITY_LIST",
|
||||
"IN_ID_LIST",
|
||||
"OUT_MENU_NAV_SCOPE",
|
||||
"OUT_TRACK_ID",
|
||||
"OUT_PLAYBACK_MODE",
|
||||
"OUT_PLAYBACK_ACTION"
|
||||
"OUT_SHUFFLE_MODE"
|
||||
],
|
||||
"resources": {
|
||||
"media": [
|
||||
|
||||
+66
-8
@@ -1,6 +1,15 @@
|
||||
#include "custom_status_bar.h"
|
||||
#include <pebble.h>
|
||||
|
||||
typedef enum {
|
||||
MENU_NAV_DISPLAY_MAIN = 0,
|
||||
MENU_NAV_DISPLAY_ARTISTS = 1,
|
||||
MENU_NAV_DISPLAY_ALBUMS = 2,
|
||||
MENU_NAV_DISPLAY_ALBUM_TRACKS = 3,
|
||||
MENU_NAV_DISPLAY_PLAYLISTS = 4,
|
||||
MENU_NAV_DISPLAY_PLAYLIST_TRACKS = 5,
|
||||
} MenuNavDisplay;
|
||||
|
||||
// layer-age
|
||||
static Window *s_main_window;
|
||||
static CustomStatusBarLayer *s_status_bar_layer;
|
||||
@@ -8,23 +17,52 @@ static Layer *s_divider_layer;
|
||||
static MenuLayer *s_menu_layer;
|
||||
|
||||
// globals
|
||||
static int s_current_menu_rows = 3;
|
||||
static MenuNavDisplay s_current_menu_display = MENU_NAV_DISPLAY_MAIN;
|
||||
|
||||
// resources
|
||||
static GFont s_font_chicago;
|
||||
|
||||
// constants
|
||||
#define BAR_HEIGHT 20
|
||||
#define MARGIN 4
|
||||
static const GRect s_menu_grect = GRect(MARGIN, BAR_HEIGHT + MARGIN, PBL_DISPLAY_WIDTH - (MARGIN * 2), PBL_DISPLAY_HEIGHT - (MARGIN * 2));
|
||||
static const char *s_main_menu_options[3] = {"Artists >", "Playlists >", "Now Playing >"};
|
||||
#ifdef PBL_RECT
|
||||
#define MARGIN_H 4
|
||||
#define MARGIN_V 4
|
||||
#else
|
||||
#define MARGIN_H 0
|
||||
#if PBL_DISPLAY_WIDTH < 260
|
||||
#define MARGIN_V 4
|
||||
#else
|
||||
#define MARGIN_V 5
|
||||
#endif
|
||||
#endif
|
||||
static const GRect s_menu_grect = GRect(MARGIN_H, BAR_HEIGHT + MARGIN_V, PBL_DISPLAY_WIDTH - (MARGIN_H * 2), PBL_DISPLAY_HEIGHT - (MARGIN_V * 2));
|
||||
static const char *s_main_menu_options[3] = {"Artists", "Playlists", "Now Playing"};
|
||||
|
||||
static uint16_t menu_get_num_rows(MenuLayer *menu_layer, uint16_t section_index, void *context) {
|
||||
return s_current_menu_rows;
|
||||
switch (s_current_menu_display) {
|
||||
case MENU_NAV_DISPLAY_MAIN:
|
||||
return 3;
|
||||
case MENU_NAV_DISPLAY_ARTISTS:
|
||||
case MENU_NAV_DISPLAY_ALBUMS:
|
||||
case MENU_NAV_DISPLAY_ALBUM_TRACKS:
|
||||
case MENU_NAV_DISPLAY_PLAYLISTS:
|
||||
default:
|
||||
return 99;
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_draw_row(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *context) {
|
||||
menu_cell_basic_draw(ctx, cell_layer, s_main_menu_options[cell_index->row], NULL, NULL);
|
||||
switch (s_current_menu_display) {
|
||||
case MENU_NAV_DISPLAY_MAIN:
|
||||
menu_cell_basic_draw(ctx, cell_layer, s_main_menu_options[cell_index->row], NULL, NULL); // TODO draw folder icon for... folders
|
||||
break;
|
||||
case MENU_NAV_DISPLAY_ARTISTS:
|
||||
case MENU_NAV_DISPLAY_ALBUMS:
|
||||
case MENU_NAV_DISPLAY_ALBUM_TRACKS:
|
||||
case MENU_NAV_DISPLAY_PLAYLISTS:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void menu_selection_changed(struct MenuLayer *menu_layer, MenuIndex new_index, MenuIndex old_index, void *callback_context) {
|
||||
@@ -43,16 +81,21 @@ static void main_window_load() {
|
||||
menu_layer_set_callbacks(s_menu_layer, NULL, (MenuLayerCallbacks){.get_num_rows = menu_get_num_rows, .draw_row = menu_draw_row, .selection_changed = menu_selection_changed});
|
||||
menu_layer_pad_bottom_enable(s_menu_layer, false);
|
||||
menu_layer_set_click_config_onto_window(s_menu_layer, s_main_window);
|
||||
#ifdef PBL_ROUND
|
||||
menu_layer_set_center_focused(s_menu_layer, false);
|
||||
#endif
|
||||
layer_add_child(main_window_layer, menu_layer_get_layer(s_menu_layer));
|
||||
|
||||
s_status_bar_layer = custom_status_bar_layer_create(BAR_HEIGHT, GColorWhite, 15);
|
||||
custom_status_bar_layer_set_text(s_status_bar_layer, CSB_TEXT_CENTER, "pebble");
|
||||
custom_status_bar_layer_set_text_font(s_status_bar_layer, CSB_TEXT_CENTER, s_font_chicago);
|
||||
#ifdef PBL_RECT
|
||||
custom_status_bar_layer_set_text(s_status_bar_layer, CSB_TEXT_LEFT, " | |");
|
||||
custom_status_bar_layer_set_text(s_status_bar_layer, CSB_TEXT_RIGHT, "[// ]- ");
|
||||
custom_status_bar_layer_set_text_font(s_status_bar_layer, CSB_TEXT_CENTER, s_font_chicago);
|
||||
#endif
|
||||
layer_add_child(main_window_layer, s_status_bar_layer);
|
||||
|
||||
s_divider_layer = layer_create(GRect(MARGIN, BAR_HEIGHT + (MARGIN / 2), PBL_DISPLAY_WIDTH - (MARGIN * 2), 1));
|
||||
s_divider_layer = layer_create(GRect(MARGIN_H, BAR_HEIGHT + (MARGIN_V / 2), PBL_DISPLAY_WIDTH - (MARGIN_H * 2), 1));
|
||||
layer_set_update_proc(s_divider_layer, divider_layer_update_proc);
|
||||
layer_add_child(main_window_layer, s_divider_layer);
|
||||
}
|
||||
@@ -63,9 +106,24 @@ static void main_window_unload() {
|
||||
menu_layer_destroy(s_menu_layer);
|
||||
}
|
||||
|
||||
////////////////////// PKJS //////////////////////
|
||||
|
||||
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||
Tuple *ready_tuple = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
||||
if (ready_tuple) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void init() {
|
||||
// initialize pkjs
|
||||
app_message_register_inbox_received(inbox_received_handler);
|
||||
app_message_open(4096, 1024); // TODO adjust sizes
|
||||
|
||||
// load font
|
||||
s_font_chicago = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CHICAGO_16));
|
||||
|
||||
// create and push window
|
||||
s_main_window = window_create();
|
||||
window_set_window_handlers(
|
||||
s_main_window,
|
||||
|
||||
Reference in new issue
Block a user