Trammell Hudson avatar Trammell Hudson committed abf0177

add a small date window

Comments (0)

Files changed (2)

th10/src/Makefile

 
 FONTS := \
 	fonts/GillSans.ttc:40 \
+	fonts/GillSans.ttc:16 \
 
 #fonts/Arial.ttf:16 \
 
 static Layer bg_layer;
 static PblTm now;
 static GFont font_time;
+static GFont font_date;
 
 static int use_24hour;
 
 {
 	(void) ctx;
 
-	now = *event->tick_time;
+	// If the day of month changes, for a redraw of the background
+	if (now.tm_mday != event->tick_time->tm_mday)
+		layer_mark_dirty(&bg_layer);
 
 	layer_mark_dirty(&hand_layer);
+
+	now = *event->tick_time;
 }
 
 
 	}
 
 	// And the large labels
+	graphics_context_set_text_color(ctx, GColorWhite);
 	graphics_text_draw(ctx,
 		use_24hour ? "24" : "12",
 		font_time,
 		GTextAlignmentLeft,
 		NULL
 	);
+
+	// Draw a small box with the current date
+	int mday = now.tm_mday;
+	char mday_str[3] = {
+		'0' + (mday / 10),
+		'0' + (mday % 10),
+		'\0'
+	};
+
+	graphics_context_set_fill_color(ctx, GColorWhite);
+	graphics_fill_rect(
+		ctx,
+		GRect(W/2+25, H/2+25, 20, 18),
+		2,
+		GCornersAll
+	);
+
+	graphics_context_set_text_color(ctx, GColorBlack);
+	graphics_text_draw(
+		ctx,
+		mday_str,
+		font_date,
+		GRect(W/2+25,H/2+24,20,18),
+		GTextOverflowModeTrailingEllipsis,
+		GTextAlignmentCenter,
+		NULL
+	);
 }
 
 #define GPATH_INIT(PATH, POINTS) ({ \
 	resource_init_current_app(&RESOURCES);
 
 	font_time = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GILLSANS_40));
+	font_date = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_GILLSANS_16));
 
 	layer_init(&bg_layer, GRect(0, 0, W, H));
 	layer_add_child(&window.layer, &bg_layer);
 	(void) ctx;
 
 	fonts_unload_custom_font(font_time);
+	fonts_unload_custom_font(font_date);
 }
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.