Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
Fix image rendering on Aplite
Browse files Browse the repository at this point in the history
  • Loading branch information
macecchi committed Sep 2, 2015
1 parent e42fac5 commit 1f44f1c
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/itunes-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static AppMode appMode = APP_PLAYER_ITUNES;
static AppPlayer appPlayer;
static Window *window;
static ActionBarLayer *action_bar;
static Layer *player_layer;
static BitmapLayer *player_layer;
static GBitmap *itunes_img;
static GBitmap *spotify_img;
static GBitmap *action_icon_previous;
Expand Down Expand Up @@ -53,13 +53,20 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
if (strcmp(tuple->value->cstring, "spotify") == 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Current player is Spotify.");
appPlayer = APP_PLAYER_SPOTIFY;
bitmap_layer_set_bitmap(player_layer, spotify_img);
}
else if (strcmp(tuple->value->cstring, "itunes") == 0) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "Current player is iTunes.");
appPlayer = APP_PLAYER_ITUNES;
bitmap_layer_set_bitmap(player_layer, itunes_img);
}
layer_remove_from_parent(player_layer);
layer_add_child(window_get_root_layer(window), player_layer);
#ifdef PBL_PLATFORM_APLITE
bitmap_layer_set_compositing_mode(player_layer, GCompOpAssignInverted);
#elif PBL_PLATFORM_BASALT
bitmap_layer_set_compositing_mode(player_layer, GCompOpSet);
#endif
layer_remove_from_parent(bitmap_layer_get_layer(player_layer));
layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(player_layer));
}
}

Expand Down Expand Up @@ -135,16 +142,6 @@ static void click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
}

static void player_layer_update_callback(Layer *layer, GContext *ctx) {
graphics_context_set_compositing_mode(ctx, GCompOpSet);
if (appPlayer == APP_PLAYER_ITUNES) {
graphics_draw_bitmap_in_rect(ctx, itunes_img, layer_get_bounds(layer));
}
else {
graphics_draw_bitmap_in_rect(ctx, spotify_img, layer_get_bounds(layer));
}
}

#ifdef PBL_COLOR
static void action_performed_callback(ActionMenu *action_menu, const ActionMenuItem *action, void *action_data) {
AppPlayer player = (AppPlayer)action_menu_item_get_action_data(action);
Expand Down Expand Up @@ -193,14 +190,16 @@ static void window_load(Window *window) {
// Resources
itunes_img = gbitmap_create_with_resource(RESOURCE_ID_ITUNES_FACE);
spotify_img = gbitmap_create_with_resource(RESOURCE_ID_SPOTIFY_FACE);
player_layer = layer_create(GRect(18,45,80,80));
layer_set_update_proc(player_layer, player_layer_update_callback);

//layer_add_child(window_layer, player_layer);
#ifdef PBL_PLATFORM_APLITE
player_layer = bitmap_layer_create(GRect(25,38,80,80));
#elif PBL_PLATFORM_BASALT
player_layer = bitmap_layer_create(GRect(18,45,80,80));
#endif
}

static void window_unload(Window *window) {
layer_destroy(player_layer);
bitmap_layer_destroy(player_layer);
gbitmap_destroy(itunes_img);
gbitmap_destroy(spotify_img);
action_bar_layer_destroy(action_bar);
Expand Down

0 comments on commit 1f44f1c

Please sign in to comment.