Skip to content

Commit

Permalink
Added point_layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki committed Jun 14, 2015
1 parent e599967 commit de105f4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/pebble-time-sample2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

static Window *window;
static TextLayer *text_layer;
static Layer *point_layer;

static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
text_layer_set_text(text_layer, "Select");
Expand All @@ -21,6 +22,13 @@ static void click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
}

static void point_layer_update_callback(Layer *layer, GContext *ctx) {
GPoint p0 = GPoint(0, 0);
GPoint p1 = GPoint(100, 100);
graphics_context_set_stroke_color(ctx, GColorBlack);
graphics_draw_line(ctx, p0, p1);
}

static void window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
Expand All @@ -29,10 +37,16 @@ static void window_load(Window *window) {
text_layer_set_text(text_layer, "Press a button");
text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
layer_add_child(window_layer, text_layer_get_layer(text_layer));

point_layer = layer_create(GRect(0, 0, 144, 168));
layer_set_update_proc(point_layer, point_layer_update_callback);
layer_add_child(window_layer, point_layer);
}

static void window_unload(Window *window) {
text_layer_destroy(text_layer);

layer_destroy(point_layer);
}

static void init(void) {
Expand Down

0 comments on commit de105f4

Please sign in to comment.