Commit 6ce7f138 authored by Niklas Postulart's avatar Niklas Postulart

Disabled window_set_fullscreen, Started new Interface for Menu and Player

parent c3311f96
resources/images/pause.png

206 Bytes | W: | H:

resources/images/pause.png

1.18 KB | W: | H:

resources/images/pause.png
resources/images/pause.png
resources/images/pause.png
resources/images/pause.png
  • 2-up
  • Swipe
  • Onion skin
resources/images/play.png

230 Bytes | W: | H:

resources/images/play.png

1.21 KB | W: | H:

resources/images/play.png
resources/images/play.png
resources/images/play.png
resources/images/play.png
  • 2-up
  • Swipe
  • Onion skin
resources/images/speaker.png

260 Bytes | W: | H:

resources/images/speaker.png

1.23 KB | W: | H:

resources/images/speaker.png
resources/images/speaker.png
resources/images/speaker.png
resources/images/speaker.png
  • 2-up
  • Swipe
  • Onion skin
resources/images/vol_dn.png

226 Bytes | W: | H:

resources/images/vol_dn.png

1.22 KB | W: | H:

resources/images/vol_dn.png
resources/images/vol_dn.png
resources/images/vol_dn.png
resources/images/vol_dn.png
  • 2-up
  • Swipe
  • Onion skin
resources/images/vol_up.png

278 Bytes | W: | H:

resources/images/vol_up.png

1.27 KB | W: | H:

resources/images/vol_up.png
resources/images/vol_up.png
resources/images/vol_up.png
resources/images/vol_up.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -76,7 +76,7 @@ static void menu_select_cb(MenuLayer *menu_layer, MenuIndex *cell_index, BasicMe
static void initialize_ui(void) {
s_window = window_create();
window_set_fullscreen(s_window, false);
// window_set_fullscreen(s_window, false);
window_set_background_color(s_window, GColorBlack);
Layer *window_layer = window_get_root_layer(s_window);
GRect bounds = layer_get_frame(window_layer);
......
......@@ -79,8 +79,11 @@ static void menu_draw_row_cb(GContext* ctx, const Layer *cell_layer, MenuIndex *
GRect bounds = layer_get_frame(cell_layer);
GBitmap *icon = model->items[cell_index->row]->icon;
graphics_context_set_fill_color(ctx, GColorWhite);
graphics_fill_rect(ctx, GRect(0, 0, bounds.size.w, bounds.size.h), 12, GCornersAll);
graphics_context_set_fill_color(ctx, GColorBlack);
#ifdef PBL_COLOR
graphics_context_set_fill_color(ctx, GColorVividCerulean);
#endif
graphics_fill_rect(ctx, GRect(0, 0, bounds.size.w, bounds.size.h), 0, GCornerNone);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_rect(ctx, GRect(1, 1, bounds.size.w - 2, bounds.size.h - 2), 12, GCornersAll);
......
......@@ -26,7 +26,7 @@ static Window *s_window;
static void initialize_ui(void) {
s_window = window_create();
window_set_fullscreen(s_window, false);
// window_set_fullscreen(s_window, false);
window_set_background_color(s_window, GColorBlack);
Layer *window_layer = window_get_root_layer(s_window);
GRect bounds = layer_get_frame(window_layer);
......
......@@ -50,7 +50,7 @@ static void initialize_ui(void) {
s_icon_weather = gbitmap_create_with_resource(RESOURCE_ID_ICON_WEATHER);
s_window = window_create();
window_set_fullscreen(s_window, false);
// window_set_fullscreen(s_window, false);
window_set_background_color(s_window, GColorBlack);
Layer *window_layer = window_get_root_layer(s_window);
GRect bounds = layer_get_frame(window_layer);
......
......@@ -29,6 +29,8 @@
#include "addons.h"
#include "power.h"
#define NUM_WINDOWS 6
static Window *s_window;
static MenuLayer *s_menu;
static GBitmap *s_icon_player;
......@@ -38,42 +40,87 @@ static GBitmap *s_icon_list;
static GBitmap *s_icon_addons;
static GBitmap *s_icon_power;
static BasicMenuModel *s_model;
static MenuLayer *s_menu_layer;
static uint16_t get_num_rows_callback(MenuLayer *menu_layer, uint16_t section_index, void *context) {
return NUM_WINDOWS;
}
static int16_t get_cell_height_callback(struct MenuLayer *menu_layer, MenuIndex *cell_index, void *context) {
return CHECKBOX_WINDOW_CELL_HEIGHT;
}
static void draw_row_callback(GContext *ctx, Layer *cell_layer, MenuIndex *cell_index, void *context) {
switch(cell_index->row) {
case 0: menu_cell_basic_draw(ctx, cell_layer, "Player", NULL, s_icon_player); break;
case 1: menu_cell_basic_draw(ctx, cell_layer, "Remote", NULL, s_icon_remote); break;
case 2: menu_cell_basic_draw(ctx, cell_layer, "Go to", NULL, s_icon_goto); break;
case 3: menu_cell_basic_draw(ctx, cell_layer, "Playlists", NULL, s_icon_list); break;
case 4: menu_cell_basic_draw(ctx, cell_layer, "Addons", NULL, s_icon_addons); break;
case 5: menu_cell_basic_draw(ctx, cell_layer, "Power", NULL, s_icon_power); break;
default: break;
}
}
static void select_callback(struct MenuLayer *menu_layer, MenuIndex *cell_index, void *context) {
switch(cell_index->row) {
case 0: show_player(); break;
case 1: show_remote(); break;
case 2: show_goto(); break;
case 3: show_playlists(); break;
case 4: show_addons(); break;
case 5: show_power(); break;
default: break;
}
}
static void draw_header_callback(GContext *ctx, const Layer *cell_layer, uint16_t section_index, void *context) {
menu_cell_basic_header_draw(ctx, cell_layer, "Rockodi - Kodi Remote");
}
static void menu_select_cb(MenuLayer *menu_layer, MenuIndex *cell_index, BasicMenuItem *item) {
void (*callback)(void) = item->value;
callback();
}
static void initialize_ui(void) {
s_icon_player = gbitmap_create_with_resource(RESOURCE_ID_ICON_PLAYER);
static int16_t get_header_height_callback(struct MenuLayer *menu_layer, uint16_t section_index, void *context) {
return MENU_CELL_BASIC_HEADER_HEIGHT;
}
static uint16_t get_num_sections_callback(struct MenuLayer *menu_layer, void *context) {
return 1;
}
static void window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
s_icon_player = gbitmap_create_with_resource(RESOURCE_ID_ICON_PLAYER_ALPHA);
s_icon_remote = gbitmap_create_with_resource(RESOURCE_ID_ICON_REMOTE);
s_icon_goto = gbitmap_create_with_resource(RESOURCE_ID_ICON_GOTO);
s_icon_list = gbitmap_create_with_resource(RESOURCE_ID_ICON_LIST);
s_icon_addons = gbitmap_create_with_resource(RESOURCE_ID_ICON_ADDONS);
s_icon_power = gbitmap_create_with_resource(RESOURCE_ID_ICON_POWER);
s_window = window_create();
window_set_fullscreen(s_window, false);
window_set_background_color(s_window, GColorBlack);
Layer *window_layer = window_get_root_layer(s_window);
GRect bounds = layer_get_frame(window_layer);
s_model = basic_menu_model_create();
basic_menu_model_add_item(s_model, "Player", s_icon_player, show_player);
basic_menu_model_add_item(s_model, "Remote", s_icon_remote, show_remote);
basic_menu_model_add_item(s_model, "Go to", s_icon_goto, show_goto);
basic_menu_model_add_item(s_model, "Playlists", s_icon_list, show_playlists);
basic_menu_model_add_item(s_model, "Addons", s_icon_addons, show_addons);
basic_menu_model_add_item(s_model, "Power", s_icon_power, show_power);
s_menu = basic_menu_layer_create(bounds, s_model);
basic_menu_model_set_select_callback(s_model, menu_select_cb);
menu_layer_set_click_config_onto_window(s_menu, s_window);
layer_add_child(window_layer, menu_layer_get_layer(s_menu));
s_menu_layer = menu_layer_create(bounds);
menu_layer_set_click_config_onto_window(s_menu_layer, window);
#ifdef PBL_PLATFORM_BASALT
menu_layer_set_normal_colors(s_menu_layer, GColorBlack, GColorWhite);
menu_layer_set_highlight_colors(s_menu_layer, GColorCobaltBlue, GColorWhite);
#endif
menu_layer_set_callbacks(s_menu_layer, NULL, (MenuLayerCallbacks) {
.get_num_rows = (MenuLayerGetNumberOfRowsInSectionsCallback)get_num_rows_callback,
.draw_row = (MenuLayerDrawRowCallback)draw_row_callback,
.get_cell_height = (MenuLayerGetCellHeightCallback)get_cell_height_callback,
.select_click = (MenuLayerSelectCallback)select_callback,
.draw_header = (MenuLayerDrawHeaderCallback)draw_header_callback,
.get_header_height = (MenuLayerGetHeaderHeightCallback)get_header_height_callback,
.get_num_sections = (MenuLayerGetNumberOfSectionsCallback)get_num_sections_callback,
});
layer_add_child(window_layer, menu_layer_get_layer(s_menu_layer));
}
static void destroy_ui() {
static void window_unload(Window* window) {
window_destroy(s_window);
gbitmap_destroy(s_icon_player);
gbitmap_destroy(s_icon_remote);
......@@ -85,14 +132,11 @@ static void destroy_ui() {
basic_menu_model_destroy(s_model);
}
static void handle_window_unload(Window* window) {
destroy_ui();
}
void show_main_menu(void) {
initialize_ui();
s_window = window_create();
window_set_window_handlers(s_window, (WindowHandlers) {
.unload = handle_window_unload,
.load = window_load,
.unload = window_unload,
});
window_stack_push(s_window, true);
}
......
......@@ -21,3 +21,7 @@
#pragma once
void show_main_menu(void);
void hide_main_menu(void);
#define CHECKBOX_WINDOW_NUM_ROWS 4
#define CHECKBOX_WINDOW_CELL_HEIGHT 30
#define CHECKBOX_WINDOW_BOX_SIZE 12
......@@ -40,15 +40,14 @@ static Layer *s_lyr_background;
static char s_title[64];
static char s_artist[64];
static void up_click_cb(ClickRecognizerRef recognizer, void *context) {outbox_send("VOLUME_UP");}
static void down_click_cb(ClickRecognizerRef recognizer, void *context) {outbox_send("VOLUME_DOWN");}
static void select_click_cb(ClickRecognizerRef recognizer, void *context) {outbox_send("PLAY_PAUSE");}
static void previous_click_cb(ClickRecognizerRef recognizer, void *context) {outbox_send("PREVIOUS");}
static void stop_click_cb(ClickRecognizerRef recognizer, void *context) {outbox_send("STOP");}
static void next_click_cb(ClickRecognizerRef recognizer, void *context) {outbox_send("NEXT");}
static void click_provider(void *context)
{
static void up_click_cb(ClickRecognizerRef recognizer, void *context) { outbox_send("VOLUME_UP"); }
static void down_click_cb(ClickRecognizerRef recognizer, void *context) { outbox_send("VOLUME_DOWN"); }
static void select_click_cb(ClickRecognizerRef recognizer, void *context) { outbox_send("PLAY_PAUSE"); }
static void previous_click_cb(ClickRecognizerRef recognizer, void *context) { outbox_send("PREVIOUS"); }
static void stop_click_cb(ClickRecognizerRef recognizer, void *context) { outbox_send("STOP"); }
static void next_click_cb(ClickRecognizerRef recognizer, void *context) { outbox_send("NEXT"); }
static void click_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_UP, up_click_cb);
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_cb);
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_cb);
......@@ -68,7 +67,7 @@ static void lyr_volume_update_proc(Layer *layer, GContext *ctx) {
uint32_t *len = (uint32_t *) layer_get_data(s_lyr_volume);
graphics_context_set_fill_color(ctx, GColorWhite);
GRect rect = GRect(0, 1, *len, bounds.size.h - 2);
GRect rect = GRect(0, 1, *len * .8, bounds.size.h - 2);
graphics_fill_rect(ctx, rect, 1, GCornersAll);
}
......@@ -112,11 +111,10 @@ static void player_tap_cb(AccelAxisType axis, int32_t direction) {
outbox_send("GET_STATUS");
}
static void initialize_ui() {
s_window = window_create();
window_set_fullscreen(s_window, false);
window_set_background_color(s_window, GColorBlack);
Layer *window_layer = window_get_root_layer(s_window);
static void window_load(Window *window) {
// window_set_fullscreen(s_window, false);
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_frame(window_layer);
s_icon_vol_up = gbitmap_create_with_resource(RESOURCE_ID_ICON_VOL_UP);
......@@ -127,20 +125,16 @@ static void initialize_ui() {
s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
s_res_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
// s_lyr_backround
s_lyr_background = layer_create(bounds);
layer_set_update_proc(s_lyr_background, lyr_background_update_proc);
layer_add_child(window_layer, (Layer *) s_lyr_background);
// s_player_bar
s_action_bar = action_bar_layer_create();
action_bar_layer_add_to_window(s_action_bar, s_window);
action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_icon_vol_up);
action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_pause);
action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_play);
action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_icon_vol_dn);
action_bar_layer_set_click_config_provider(s_action_bar, click_provider);
layer_add_child(window_layer, (Layer *) s_action_bar);
action_bar_layer_add_to_window(s_action_bar, window);
// s_txt_title
s_txt_title = text_layer_create(GRect(4, 0, 116, 76));
s_txt_title = text_layer_create(GRect(10, 10, 124 - ACTION_BAR_WIDTH, 76));
text_layer_set_background_color(s_txt_title, GColorClear);
text_layer_set_text_color(s_txt_title, GColorWhite);
text_layer_set_text_alignment(s_txt_title, GTextAlignmentCenter);
......@@ -148,18 +142,19 @@ static void initialize_ui() {
text_layer_set_text(s_txt_title, "Loading...");
layer_add_child(window_layer, (Layer *) s_txt_title);
// s_txt_artist
s_txt_artist = text_layer_create(GRect(4, 78, 116, 56));
s_txt_artist = text_layer_create(GRect(10, 78, 116, 56));
text_layer_set_background_color(s_txt_artist, GColorClear);
text_layer_set_text_color(s_txt_artist, GColorWhite);
text_layer_set_text_alignment(s_txt_artist, GTextAlignmentCenter);
text_layer_set_font(s_txt_artist, s_res_gothic_18);
layer_add_child(window_layer, (Layer *) s_txt_artist);
// s_bmap_speaker
s_bmp_speaker = bitmap_layer_create(GRect(2, 134, 8, 12));
s_bmp_speaker = bitmap_layer_create(GRect(10, 134, 8, 12));
bitmap_layer_set_bitmap(s_bmp_speaker, s_icon_speaker);
bitmap_layer_set_compositing_mode(s_bmp_speaker, GCompOpSet);
layer_add_child(window_layer, (Layer *) s_bmp_speaker);
// s_lyr_volume
s_lyr_volume = layer_create_with_data(GRect(16, 136, 100, 8), sizeof(uint32_t));
s_lyr_volume = layer_create_with_data(GRect(24, 136, 92, 8), sizeof(uint32_t));
layer_set_update_proc(s_lyr_volume, lyr_volume_update_proc);
uint32_t *len = (uint32_t *) layer_get_data(s_lyr_volume);
*len = 0;
......@@ -171,14 +166,21 @@ static void initialize_ui() {
outbox_send("GET_STATUS");
}
static void destroy_ui() {
static void window_appear(Window* window) {
accel_tap_service_subscribe(player_tap_cb);
}
static void window_disappear(Window* window) {
accel_tap_service_unsubscribe();
}
static void window_unload(Window* window) {
window_destroy(s_window);
gbitmap_destroy(s_icon_vol_up);
gbitmap_destroy(s_icon_pause);
gbitmap_destroy(s_icon_play);
gbitmap_destroy(s_icon_vol_dn);
gbitmap_destroy(s_icon_speaker);
layer_destroy(s_lyr_background);
action_bar_layer_destroy(s_action_bar);
text_layer_destroy(s_txt_title);
text_layer_destroy(s_txt_artist);
......@@ -186,24 +188,16 @@ static void destroy_ui() {
layer_destroy(s_lyr_volume);
}
static void handle_window_appear(Window* window) {
accel_tap_service_subscribe(player_tap_cb);
}
static void handle_window_disappear(Window* window) {
accel_tap_service_unsubscribe();
}
static void handle_window_unload(Window* window) {
destroy_ui();
}
void show_player(void) {
initialize_ui();
s_window = window_create();
#ifdef PBL_COLOR
window_set_background_color(s_window, GColorJaegerGreen);
#endif
window_set_window_handlers(s_window, (WindowHandlers) {
.unload = handle_window_unload,
.appear = handle_window_appear,
.disappear = handle_window_disappear,
.load = window_load,
.unload = window_unload,
.appear = window_appear,
.disappear = window_disappear,
});
window_stack_push(s_window, true);
}
......
......@@ -59,7 +59,7 @@ static void inbox_received_callback(DictionaryIterator *iterator, void *context)
dict_write_cstring(&items_iter, (int) t->key, (char*) t->value->cstring);
t = dict_read_next(iterator);
}
int items_size = dict_write_end(&items_iter);
// int items_size = dict_write_end(&items_iter);
load_menu();
}
......@@ -75,7 +75,7 @@ static void menu_select_cb(MenuLayer *menu_layer, MenuIndex *cell_index, BasicMe
static void initialize_ui(void) {
s_window = window_create();
window_set_fullscreen(s_window, false);
// window_set_fullscreen(s_window, false);
window_set_background_color(s_window, GColorBlack);
Layer *window_layer = window_get_root_layer(s_window);
GRect bounds = layer_get_frame(window_layer);
......
......@@ -34,7 +34,7 @@ static void menu_select_cb(MenuLayer *menu_layer, MenuIndex *cell_index, BasicMe
static void initialize_ui(void) {
s_window = window_create();
window_set_fullscreen(s_window, false);
// window_set_fullscreen(s_window, false);
window_set_background_color(s_window, GColorBlack);
Layer *window_layer = window_get_root_layer(s_window);
GRect bounds = layer_get_frame(window_layer);
......
......@@ -48,7 +48,7 @@ static void click_provider(void *context)
static void initialize_ui() {
s_window = buttons_window_create();
window_set_fullscreen(s_window, false);
// window_set_fullscreen(s_window, false);
Layer *window_layer = window_get_root_layer(s_window);
s_icon_cursor_up = gbitmap_create_with_resource(RESOURCE_ID_ICON_CURSOR_UP);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment