Skip to content
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

Add Timeline Quick View support and fix build with current SDK #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/c/inc_background_layer_update_p_ps_pt_pts.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
graphics_draw_line(ctx, GPoint( 85, 17), GPoint( 85, 68));
graphics_draw_line(ctx, GPoint( 0, 50), GPoint( 84, 50));
graphics_draw_line(ctx, GPoint( 0, 69), GPoint(168, 69));
graphics_draw_line(ctx, GPoint( 0, 90), GPoint(168, 90));
graphics_draw_line(ctx, GPoint( 0, TIME_POS()-4), GPoint(168, 90));
graphics_draw_line(ctx, GPoint( 0, 154), GPoint(168, 154));

#ifndef PBL_PLATFORM_APLITE
Expand Down Expand Up @@ -70,8 +70,8 @@
//draw dots of time:
graphics_context_set_fill_color(ctx, textcolor_clock);
graphics_context_set_stroke_color(ctx, textcolor_clock);
graphics_fill_rect(ctx, GRect(69, 102, 7, 7), 0, 0);
graphics_fill_rect(ctx, GRect(69, 124, 7, 7), 0, 0);
graphics_fill_rect(ctx, GRect(69, TIME_POS()+6, 7, 7), 0, 0);
graphics_fill_rect(ctx, GRect(69, TIME_POS()+32, 7, 7), 0, 0);

//draw arrows of sun rise/set:
graphics_context_set_fill_color(ctx, GColorClear);
Expand Down
16 changes: 12 additions & 4 deletions src/c/inc_main_load_p_ps_pt_pts.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
#ifndef PBL_PLATFORM_APLITE
time_pos_tiny = 72;
time_pos_normal = 94;
update_time_pos();
#endif

background_paint_layer = layer_create(GRect(0, 0, 144, 168));
layer_set_update_proc(background_paint_layer, layer_update_callback_background);
layer_add_child(main_window_layer, background_paint_layer);

s_image_layer_hour_1 = layer_create(GRect(4, 94, 26, 41));
s_image_layer_hour_1 = layer_create(GRect(4, TIME_POS(), 26, 41));
layer_set_update_proc(s_image_layer_hour_1, layer_update_callback_hour_1);
layer_add_child(main_window_layer, s_image_layer_hour_1);
s_image_layer_hour_2 = layer_create(GRect(37, 94, 26, 41));
s_image_layer_hour_2 = layer_create(GRect(37, TIME_POS(), 26, 41));
layer_set_update_proc(s_image_layer_hour_2, layer_update_callback_hour_2);
layer_add_child(main_window_layer, s_image_layer_hour_2);

s_image_layer_minute_1 = layer_create(GRect(80, 94, 26, 41));
s_image_layer_minute_1 = layer_create(GRect(80, TIME_POS(), 26, 41));
layer_set_update_proc(s_image_layer_minute_1, layer_update_callback_minute_1);
layer_add_child(main_window_layer, s_image_layer_minute_1);
s_image_layer_minute_2 = layer_create(GRect(111, 94, 26, 41));
s_image_layer_minute_2 = layer_create(GRect(111, TIME_POS(), 26, 41));
layer_set_update_proc(s_image_layer_minute_2, layer_update_callback_minute_2);
layer_add_child(main_window_layer, s_image_layer_minute_2);

Expand Down Expand Up @@ -82,6 +87,9 @@
text_layer_set_font(Date_Layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
text_layer_set_text_alignment(Date_Layer, GTextAlignmentCenter);
layer_add_child(main_window_layer, text_layer_get_layer(Date_Layer));
#ifndef PBL_PLATFORM_APLITE
layer_set_hidden(text_layer_get_layer(Date_Layer), is_tiny_view);
#endif

// Calendar Week
cwLayer = text_layer_create(GRect(72, 135, 64, 20)); //64 = label_width = 144-72-2*4 = display_width - display_width/2 - 2*Space
Expand Down
9 changes: 5 additions & 4 deletions src/c/inc_main_load_ptr.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
time_pos = time_pos_normal = time_pos_tiny = 94+Y_OFFSET; // quick view not supported there

background_paint_layer = layer_create(GRect(0, 0, 180, 180));
layer_set_update_proc(background_paint_layer, layer_update_callback_background);
layer_add_child(main_window_layer, background_paint_layer);

s_image_layer_hour_1 = layer_create(GRect(4+X_OFFSET-5, 94+Y_OFFSET, 26, 41));
s_image_layer_hour_1 = layer_create(GRect(4+X_OFFSET-5, TIME_POS(), 26, 41));
layer_set_update_proc(s_image_layer_hour_1, layer_update_callback_hour_1);
layer_add_child(main_window_layer, s_image_layer_hour_1);
s_image_layer_hour_2 = layer_create(GRect(37+X_OFFSET-5, 94+Y_OFFSET, 26, 41));
s_image_layer_hour_2 = layer_create(GRect(37+X_OFFSET-5, TIME_POS(), 26, 41));
layer_set_update_proc(s_image_layer_hour_2, layer_update_callback_hour_2);
layer_add_child(main_window_layer, s_image_layer_hour_2);

s_image_layer_minute_1 = layer_create(GRect(80+X_OFFSET-5, 94+Y_OFFSET, 26, 41));
s_image_layer_minute_1 = layer_create(GRect(80+X_OFFSET-5, TIME_POS(), 26, 41));
layer_set_update_proc(s_image_layer_minute_1, layer_update_callback_minute_1);
layer_add_child(main_window_layer, s_image_layer_minute_1);
s_image_layer_minute_2 = layer_create(GRect(111+X_OFFSET-5, 94+Y_OFFSET, 26, 41));
s_image_layer_minute_2 = layer_create(GRect(111+X_OFFSET-5, TIME_POS(), 26, 41));
layer_set_update_proc(s_image_layer_minute_2, layer_update_callback_minute_2);
layer_add_child(main_window_layer, s_image_layer_minute_2);

Expand Down
49 changes: 46 additions & 3 deletions src/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,15 @@ GColor background_color_location;
GColor background_color_last_update;
GColor background_color_status;


#ifdef PBL_PLATFORM_APLITE
#define TIME_POS() 94
#else
#define TIME_POS() time_pos
int time_pos_tiny = 0;
int time_pos_normal = 0;
int time_pos = 0;
int is_tiny_view = 0;
#endif

// Settings variables (App Config):

Expand Down Expand Up @@ -2050,8 +2058,37 @@ static void timer_cycle_color_profile_callback(void *data){
app_timer_register(3000, timer_cycle_color_profile_callback, NULL);
}
}
#endif

int max(int a, int b){
return (a>b) ? a : b;
}
void update_time_pos(){
Layer *main_window_layer = window_get_root_layer(s_main_window);
GRect fullscreen = layer_get_bounds(main_window_layer);
GRect bounds = layer_get_unobstructed_bounds(main_window_layer);
int diff = fullscreen.size.h - bounds.size.h;
is_tiny_view = diff != 0;
time_pos = is_tiny_view ? max(time_pos_tiny, time_pos_normal-diff) : time_pos_normal;
}

void update_window_size(){
update_time_pos();
Layer *layers[] = {s_image_layer_hour_1, s_image_layer_hour_2, s_image_layer_minute_1, s_image_layer_minute_2};
for(unsigned int i=0; i<(sizeof(layers)/sizeof(layers[0])); i++){
Layer* layer = layers[i];
GRect frame = layer_get_frame(layer);
frame.origin.y = time_pos;
layer_set_frame(layer, frame);
}
layer_set_hidden(text_layer_get_layer(Date_Layer), is_tiny_view);
}
void update_window_size_during_change(AnimationProgress progress, void * xx_main_window_layer){
update_window_size();
}
void update_window_size_after_change(void * xx_main_window_layer){
update_window_size();
}
#endif

static void main_window_load(Window *window) {

Expand Down Expand Up @@ -2087,7 +2124,13 @@ static void main_window_load(Window *window) {
#else
#include "inc_main_load_p_ps_pt_pts.h"
#endif

#ifndef PBL_PLATFORM_APLITE
UnobstructedAreaHandlers handlers = {
.change = update_window_size_during_change,
.did_change = update_window_size_after_change
};
unobstructed_area_service_subscribe(handlers, NULL);
#endif
apply_color_profile();

DisplayData();
Expand Down
2 changes: 1 addition & 1 deletion wscript
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ def build(ctx):
binaries.append({'platform': p, 'app_elf': app_elf})

ctx.set_group('bundle')
ctx.pbl_bundle(binaries=binaries, js='pebble-js-app.js' if has_js else [])
ctx.pbl_bundle(binaries=binaries, js_entry_file='pebble-js-app.js' if has_js else [])