Skip to content

Commit

Permalink
Left-sidebar option works again
Browse files Browse the repository at this point in the history
  • Loading branch information
tilden committed Sep 22, 2016
1 parent 9929332 commit d1e970a
Show file tree
Hide file tree
Showing 54 changed files with 34 additions and 23 deletions.
Empty file modified .gitignore 100644 → 100755
Empty file.
Empty file modified LICENSE 100644 → 100755
Empty file.
Empty file modified README.md 100644 → 100755
Empty file.
Empty file modified other/Consolas.svg 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified other/LECO_1976-Regular.1.svg 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified other/avenir-next-regular.svg 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified other/avenirnext-demibold.svg 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified other/david-libre-bold.svg 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified package.json 100644 → 100755
Empty file.
Empty file modified project_banner.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified resources/data/BATTERY_BG.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/BATTERY_CHARGE.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/CLEAR_DAY.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/CLEAR_NIGHT.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/CLOUDY_DAY.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/DATE_BG.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/DISCONNECTED.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/HEALTH_SLEEP.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/HEALTH_SLEEP_LG.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/HEALTH_SLEEP_SM.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/HEALTH_STEPS.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/HEAVY_RAIN.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/HEAVY_SNOW.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/LIGHT_RAIN.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/LIGHT_SNOW.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/PARTLY_CLOUDY.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/PARTLY_CLOUDY_NIGHT.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/RAINING_AND_SNOWING.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/THUNDERSTORM.pdc 100644 → 100755
Empty file.
Empty file modified resources/data/WEATHER_GENERIC.pdc 100644 → 100755
Empty file.
Empty file modified resources/fonts/AvenirNextDemiBold.ffont 100644 → 100755
Empty file.
Empty file modified resources/fonts/AvenirNextRegular.ffont 100644 → 100755
Empty file.
Empty file modified resources/fonts/LECO1976-Regular.ffont 100644 → 100755
Empty file.
Empty file modified resources/images/menuicon~bw.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified resources/images/menuicon~color.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified resources/images/menuicon~color~round.png 100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 23 additions & 9 deletions src/c/clock_area.c
Expand Up @@ -12,11 +12,15 @@ Layer* clock_area_layer;
FFont* hours_font;
FFont* minutes_font;

// just allocate all the fonts at startup because i'm lazy
// just allocate all the fonts at startup because i don't feel like
// dealing with allocating and deallocating things
FFont* avenir;
FFont* avenir_bold;
FFont* leco;

GRect screen_rect;

// "private" functions
void update_fonts() {
switch(globalSettings.clockFontId) {
case FONT_SETTING_DEFAULT:
Expand All @@ -42,7 +46,6 @@ void update_fonts() {
}
}

// "private" functions
void update_clock_area_layer(Layer *l, GContext* ctx) {
// check layer bounds
GRect bounds = layer_get_unobstructed_bounds(l);
Expand All @@ -54,23 +57,30 @@ void update_clock_area_layer(Layer *l, GContext* ctx) {
fctx_set_color_bias(&fctx, 0);
fctx_set_fill_color(&fctx, globalSettings.timeColor);

// draw the time

// calculate font size
int font_size = 4 * bounds.size.h / 7;

// avenir
// avenir + avenir bold metrics
int v_padding = bounds.size.h / 16;
int h_adjust = 0;

// alternate params for LECO
// alternate metrics for LECO
if(globalSettings.clockFontId == FONT_SETTING_LECO) {
v_padding = bounds.size.h / 13;
h_adjust = -2;

// leco looks awful with antialiasing
#ifdef PBL_COLOR
fctx_enable_aa(false);
#endif
}

// if the sidebar is on the other side, modify offset to accomodate
if(globalSettings.sidebarOnLeft) {
h_adjust += 30;
}

FPoint time_pos;
fctx_begin_fill(&fctx);
fctx_set_text_size(&fctx, hours_font, font_size);
Expand All @@ -91,14 +101,15 @@ void update_clock_area_layer(Layer *l, GContext* ctx) {
fctx_deinit_context(&fctx);
}


void ClockArea_init(Window* window) {
// init the clock area layer
GRect screen_rect = layer_get_bounds(window_get_root_layer(window));
GRect bounds;
// record the screen size, since we NEVER GET IT AGAIN
screen_rect = layer_get_bounds(window_get_root_layer(window));

// TODO: add left-side-sidebar support
GRect bounds;
bounds = GRect(0, 0, screen_rect.size.w - 30, screen_rect.size.h);

// init the clock area layer
clock_area_layer = layer_create(bounds);
layer_add_child(window_get_root_layer(window), clock_area_layer);
layer_set_update_proc(clock_area_layer, update_clock_area_layer);
Expand All @@ -121,8 +132,11 @@ void ClockArea_deinit() {
}

void ClockArea_redraw() {

// check if the fonts need to be switched
update_fonts();
// check if we need to move the frame


layer_mark_dirty(clock_area_layer);
}
Expand Down
Empty file modified src/c/clock_area.h 100644 → 100755
Empty file.
Empty file modified src/c/languages.c 100644 → 100755
Empty file.
Empty file modified src/c/languages.h 100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src/c/main.c 100644 → 100755
Expand Up @@ -66,11 +66,11 @@ void redrawScreen() {
static void main_window_load(Window *window) {
window_set_background_color(window, globalSettings.timeBgColor);

ClockArea_init(window);

// create the sidebar
Sidebar_init(window);

ClockArea_init(window);

// Make sure the time is displayed from the start
redrawScreen();
update_clock();
Expand Down
Empty file modified src/c/messaging.h 100644 → 100755
Empty file.
21 changes: 9 additions & 12 deletions src/c/sidebar.c 100644 → 100755
Expand Up @@ -8,7 +8,8 @@
#include "sidebar_widgets.h"

#define V_PADDING 8
#define SCREEN_HEIGHT 168

GRect screen_rect;

// "private" functions
// layer update callbacks
Expand All @@ -30,18 +31,18 @@ Layer* sidebarLayer;

void Sidebar_init(Window* window) {
// init the sidebar layer
GRect screenRect = layer_get_bounds(window_get_root_layer(window));
screen_rect = layer_get_bounds(window_get_root_layer(window));
GRect bounds;

#ifdef PBL_ROUND
GRect bounds2;
bounds = GRect(0, 0, 40, screenRect.size.h);
bounds2 = GRect(screenRect.size.w - 40, 0, 40, screenRect.size.h);
bounds = GRect(0, 0, 40, screen_rect.size.h);
bounds2 = GRect(screen_rect.size.w - 40, 0, 40, screen_rect.size.h);
#else
if(!globalSettings.sidebarOnLeft) {
bounds = GRect(114, 0, 30, screenRect.size.h);
bounds = GRect(114, 0, 30, screen_rect.size.h);
} else {
bounds = GRect(0, 0, 30, screenRect.size.h);
bounds = GRect(0, 0, 30, screen_rect.size.h);
}
#endif

Expand Down Expand Up @@ -74,9 +75,9 @@ void Sidebar_redraw() {
#ifndef PBL_ROUND
// reposition the sidebar if needed
if(globalSettings.sidebarOnLeft) {
layer_set_frame(sidebarLayer, GRect(0, 0, 30, SCREEN_HEIGHT));
layer_set_frame(sidebarLayer, GRect(0, 0, 30, screen_rect.size.h));
} else {
layer_set_frame(sidebarLayer, GRect(114, 0, 30, SCREEN_HEIGHT));
layer_set_frame(sidebarLayer, GRect(114, 0, 30, screen_rect.size.h));
}
#endif

Expand Down Expand Up @@ -219,10 +220,6 @@ void drawRoundSidebar(GContext* ctx, GRect bgBounds, SidebarWidgetType widgetTyp
}
#endif





void updateRectSidebar(Layer *l, GContext* ctx) {
GRect bounds = layer_get_unobstructed_bounds(l);

Expand Down
Empty file modified src/c/sidebar.h 100644 → 100755
Empty file.
Empty file modified src/c/sidebar_widgets.h 100644 → 100755
Empty file.
Empty file modified src/c/util.c 100644 → 100755
Empty file.
Empty file modified src/c/weather.c 100644 → 100755
Empty file.
Empty file modified src/c/weather.h 100644 → 100755
Empty file.
Empty file modified src/pkjs/secrets_example.js 100644 → 100755
Empty file.
Empty file modified src/pkjs/weather.js 100644 → 100755
Empty file.
Empty file modified src/pkjs/weather_owm.js 100644 → 100755
Empty file.
Empty file modified src/pkjs/weather_wunderground.js 100644 → 100755
Empty file.
Empty file modified tools/localDates.py 100644 → 100755
Empty file.
Empty file modified wscript 100644 → 100755
Empty file.

0 comments on commit d1e970a

Please sign in to comment.