Esempio n. 1
0
static void main_window_unload(Window *window) {
  layer_destroy(s_display_layer);
}
Esempio n. 2
0
void layer_destroy_safe(Layer *layer) {
    if (layer != NULL) {
        layer_destroy(layer);
        layer = NULL;
    }
}
static void main_window_unload(Window *window) {
  layer_destroy(s_path_layer);
}
Esempio n. 4
0
static void side_window_unload(Window *window)
  {
  layer_destroy(s_pad2_layer);
  text_layer_destroy(s_scoreb);
  }
Esempio n. 5
0
static void hands_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);
  graphics_draw_circle(ctx, center, bounds.size.w / 2);
  
  int16_t second_hand_length = bounds.size.w / 3;

  time_t now = time(NULL);
  struct tm *t = localtime(&now);
  int32_t second_angle = TRIG_MAX_ANGLE * t->tm_sec / 60;
  GPoint second_hand = {
    .x = (int16_t)(sin_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.x,
    .y = (int16_t)(-cos_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.y,
  };

  gpath_rotate_to(s_second_arrow, second_angle);
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_context_set_stroke_width(ctx, 1);
  graphics_draw_circle(ctx, second_hand, 5);
  // second hand
  //graphics_context_set_stroke_color(ctx, GColorBlack);
  //graphics_draw_line(ctx, second_hand, center);

  // minute/hour hand
  //graphics_context_set_fill_color(ctx, GColorBlack);
  //graphics_context_set_stroke_color(ctx, GColorBlack);
  int16_t minute_hand_length = bounds.size.w / 3;
  int32_t minute_angle = TRIG_MAX_ANGLE * t->tm_min / 60;
  GPoint minute_hand = {
    .x = (int16_t)(sin_lookup(minute_angle) * (int32_t)minute_hand_length / TRIG_MAX_RATIO) + center.x,
    .y = (int16_t)(-cos_lookup(minute_angle) * (int32_t)minute_hand_length / TRIG_MAX_RATIO) + center.y,
  };
  
  gpath_rotate_to(s_minute_arrow, minute_angle);
  //gpath_draw_filled(ctx, s_minute_arrow);
  //gpath_draw_outline(ctx, s_minute_arrow);
  graphics_context_set_stroke_color(ctx, GColorBlack);
  //graphics_context_set_fill_color(ctx, GColorBlack);
  graphics_context_set_stroke_width(ctx, 1);
  graphics_draw_circle(ctx, minute_hand, 15);
  //graphics_context_set_fill_color(ctx, GColorWhite);
  //graphics_fill_circle(ctx, minute_hand, 8);

  int16_t hour_hand_length = bounds.size.w / 3;
  int32_t hour_angle = (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6);
  GPoint hour_hand = {
    .x = (int16_t)(sin_lookup(hour_angle) * (int32_t)hour_hand_length / TRIG_MAX_RATIO) + center.x,
    .y = (int16_t)(-cos_lookup(hour_angle) * (int32_t)hour_hand_length / TRIG_MAX_RATIO) + center.y,
  };
  gpath_rotate_to(s_hour_arrow, hour_angle);
  //gpath_draw_filled(ctx, s_hour_arrow);
  //gpath_draw_outline(ctx, s_hour_arrow);
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_context_set_stroke_width(ctx, 1);
  graphics_draw_circle(ctx, hour_hand, 8);
  
  // dot in the middle
  graphics_context_set_fill_color(ctx, GColorBlack);
  //graphics_fill_rect(ctx, GRect(bounds.size.w / 2 - 1, bounds.size.h / 2 - 1, 3, 3), 0, GCornerNone);
  graphics_fill_circle(ctx, center, 3);
}
  
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  
  s_simple_bg_layer = layer_create(bounds);
  layer_set_update_proc(s_simple_bg_layer, bg_update_proc);
  layer_add_child(window_layer, s_simple_bg_layer);
  
  s_hands_layer = layer_create(bounds);
  layer_set_update_proc(s_hands_layer, hands_update_proc);
  layer_add_child(window_layer, s_hands_layer);

}

static void window_unload(Window *window) {

  layer_destroy(s_hands_layer);
}
  
static void init() {
  window = window_create();
  window_set_window_handlers(window, (WindowHandlers) {
    .load = window_load,
    .unload = window_unload,
  });
Esempio n. 6
0
File: app.c Progetto: abi93k/explore
/**
 * Called when result window is unloaded
 * @param window
 */
 static void r_window_unload(Window *window) {
  layer_destroy((Layer *)r_menu_layer);
}
Esempio n. 7
0
void unload_ill(void) {
  tick_timer_service_unsubscribe();
  layer_destroy(display_layer);
  //window_destroy(window);
}
Esempio n. 8
0
static void destroy_ui(void) {
  window_destroy(s_window);
  text_layer_destroy(date);
  layer_destroy(bluetooth);
  layer_destroy(battery);
}
Esempio n. 9
0
static void window_unload(Window *window) {
    game_end(0);
    text_layer_destroy(game_bonus_label);
    text_layer_destroy(game_score_label);
    layer_destroy(game_layer);
}
Esempio n. 10
0
static void main_window_unload(Window *window) {
  layer_destroy(text_layer);
  layer_destroy(dither_layer);
}
Esempio n. 11
0
void text_layer_destroy (TextLayer* layer) {
    if (layer)
        layer_destroy((Layer*)layer);
}
Esempio n. 12
0
static void deinit(void) {
    layer_destroy(display_layer);
    layer_destroy(background_layer);
    window_destroy(window);
}
Esempio n. 13
0
File: main.c Progetto: j0hax/Braun
// Draws hands onto the given layer
static void draw_hands(Layer* layer, GContext* ctx) {
  gpath_rotate_to(hour_ptr, (TRIG_MAX_ANGLE * timedata[0] / 12) + (TRIG_MAX_ANGLE * timedata[1] / 720.0f));
  graphics_context_set_fill_color(ctx, GColorWhite);
  gpath_draw_filled(ctx, hour_ptr);
  // minute hand
  gpath_rotate_to(minute_ptr, (TRIG_MAX_ANGLE * timedata[1] / 60) + (TRIG_MAX_ANGLE * timedata[2] / 3600.0f));
  graphics_context_set_fill_color(ctx, GColorWhite);
  gpath_draw_filled(ctx, minute_ptr);
  
  // seconds get some extra attention here-- the same as above, but with an extra little counterweight type thing on the opposite site
  GPoint sec0 = (GPoint) {
    .x = (int16_t)(center.x + -sin_lookup(TRIG_MAX_ANGLE * timedata[2] / 60) * 18 / TRIG_MAX_RATIO),
     .y = (int16_t)(center.y + cos_lookup(TRIG_MAX_ANGLE * timedata[2] / 60) * 18 / TRIG_MAX_RATIO)
  };
  GPoint sec1 = (GPoint) {
    .x = (int16_t)(center.x + sin_lookup(TRIG_MAX_ANGLE * timedata[2] / 60) * 72 / TRIG_MAX_RATIO), .y = (int16_t)(center.y + -cos_lookup(TRIG_MAX_ANGLE * timedata[2] / 60) * 72 / TRIG_MAX_RATIO)
  };
  graphics_context_set_stroke_color(ctx, GColorYellow );
  graphics_context_set_stroke_width(ctx, 3);
  graphics_draw_line(ctx, center, sec1);
  graphics_context_set_stroke_width(ctx, 6);
  graphics_draw_line(ctx, center, sec0);
  graphics_context_set_fill_color(ctx, GColorYellow );
  graphics_fill_circle(ctx, center, 5);
  graphics_context_set_stroke_color(ctx, GColorBlack);
  graphics_draw_pixel(ctx, center);
}

// draws face onto the given layer
static void draw_face(Layer* layer, GContext* ctx) {
  
  static char buf[] = "00";
  
  graphics_context_set_stroke_color(ctx, GColorLightGray);

  // draw 60 minute ticks around clock
  for (int i = 0; i < 60; i++) {
    // tic0 = start of inner point
    // tic1 = end of outer point
    GPoint tic0, tic1;

    // tic0 is the starting point from center, tic1 is the outer point of the tic
    if (i % 5 == 0) {
      // hour
      tic0 = (GPoint) {
        .x = (int16_t)(center.x + sin_lookup(TRIG_MAX_ANGLE * i / 60) * 69 / TRIG_MAX_RATIO),
         .y = (int16_t)(center.y + -cos_lookup(TRIG_MAX_ANGLE * i / 60) * 69 / TRIG_MAX_RATIO)
      };
      tic1 = (GPoint) {
        .x = (int16_t)(tic0.x + sin_lookup(TRIG_MAX_ANGLE * i / 60) * 15 / TRIG_MAX_RATIO),
         .y = (int16_t)(tic0.y + -cos_lookup(TRIG_MAX_ANGLE * i / 60) * 15 / TRIG_MAX_RATIO)
      };
      graphics_context_set_stroke_width(ctx, 2);
      
      /*if (i != 30) {
        GRect HourText = GRect((int16_t)(center.x + sin_lookup(TRIG_MAX_ANGLE * i / 60) * 54 / TRIG_MAX_RATIO)-10,
                               (int16_t)(center.y + -cos_lookup(TRIG_MAX_ANGLE * i / 60) * 54 / TRIG_MAX_RATIO)-10,
                               20, 20);
        
        snprintf(buf, sizeof(buf), "%d", i/5);
        graphics_context_set_text_color(ctx, GColorWhite);
        graphics_draw_text(ctx, buf, fonts_get_system_font(FONT_KEY_GOTHIC_18),
                       HourText, GTextOverflowModeWordWrap,
                       GTextAlignmentCenter, NULL);
        
      }*/

    } else {
      // minute marks
      tic0 = (GPoint) {
        .x = (int16_t)(center.x + sin_lookup(TRIG_MAX_ANGLE * i / 60) * 74 / TRIG_MAX_RATIO),
         .y = (int16_t)(center.y + -cos_lookup(TRIG_MAX_ANGLE * i / 60) * 74 / TRIG_MAX_RATIO)
      };
      tic1 = (GPoint) {
        .x = (int16_t)(tic0.x + sin_lookup(TRIG_MAX_ANGLE * i / 60) * 10 / TRIG_MAX_RATIO),
         .y = (int16_t)(tic0.y + -cos_lookup(TRIG_MAX_ANGLE * i / 60) * 10 / TRIG_MAX_RATIO)
      };
      graphics_context_set_stroke_width(ctx, 1);
    }

    graphics_draw_line(ctx, tic0, tic1);
  }

  // draw the date (new and complex how scary)
  snprintf(buf, sizeof(buf), "%d", timedata[3]);
  int yDate = center.y + layer_get_frame(s_face_layer).size.h / 4;
  int xDate = center.x - 6;
  GRect date_window = GRect(xDate, yDate, 13, 18);
  graphics_context_set_fill_color(ctx, GColorWhite);
  graphics_context_set_text_color(ctx, GColorBlack);
  graphics_fill_rect(ctx, date_window, 0, 0);
  graphics_draw_text(ctx, buf, fonts_get_system_font(FONT_KEY_GOTHIC_14),
                     date_window, GTextOverflowModeWordWrap,
                     GTextAlignmentCenter, NULL);
  graphics_context_set_fill_color(ctx, GColorRed);
  gpath_move_to(chevron, GPoint(xDate + 6, yDate - 3));
  gpath_rotate_to(chevron, TRIG_MAX_ANGLE * 0.5f);
  gpath_draw_filled(ctx, chevron);
}

static void tick_handler(struct tm* tick_time, TimeUnits units_changed) {
  // just store the time, don't bother with making a new one in the update_proc or calling update_time
  timedata[0] = tick_time->tm_hour % 12;
  timedata[1] = tick_time->tm_min;
  timedata[2] = tick_time->tm_sec;
  timedata[3] = tick_time->tm_mday;
  layer_mark_dirty(s_hands_layer);
}

static void main_window_load(Window* window) {
  // self-explanatory: make the main window black with one full-screen layer to display the time
  window_set_background_color(window, GColorBlack);
  s_face_layer = layer_create(layer_get_bounds(window_get_root_layer(s_window)));
  s_hands_layer = layer_create(layer_get_bounds(window_get_root_layer(s_window)));
  logo = gbitmap_create_with_resource(RESOURCE_ID_LOGO);
  int offset = (center.x-20);
  logo_layer = bitmap_layer_create(GRect(offset, 50, 40, 12));
  bitmap_layer_set_bitmap(logo_layer, logo);
  layer_add_child(s_face_layer, bitmap_layer_get_layer(logo_layer));
  layer_set_update_proc(s_face_layer, draw_face);
  layer_set_update_proc(s_hands_layer, draw_hands);
  layer_add_child(window_get_root_layer(window), s_face_layer);
  layer_add_child(window_get_root_layer(window), s_hands_layer);
}

static void main_window_unload(Window* window) {
  gbitmap_destroy(logo);
  bitmap_layer_destroy(logo_layer);
  layer_destroy(s_face_layer);
  layer_destroy(s_hands_layer);
  gpath_destroy(hour_ptr);
  gpath_destroy(minute_ptr);
  gpath_destroy(second_ptr);
}

static void init() {
  // initialize stuff you know the drill
  s_window = window_create();
  window_set_window_handlers(s_window, (WindowHandlers) {
    .load = main_window_load,
     .unload = main_window_unload
  });
Esempio n. 14
0
void dim_layer_destroy(DimLayer* dim_layer)
{
    layer_destroy(dim_layer);
}
Esempio n. 15
0
static void main_window_unload(Window *window) {
	// Destroy layers
	text_layer_destroy(s_time_layer);
	text_layer_destroy(s_time_remaining_layer);
	layer_destroy(s_progress_layer);
}
Esempio n. 16
0
static void handle_deinit(void) {
  text_layer_destroy(s_battery_layer);
  layer_destroy(s_graph_layer);
  window_destroy(s_main_window);
}
static void main_window_unload(Window *window) {
	layer_destroy(s_canvas_layer);
}
Esempio n. 18
0
static void main_window_unload(Window *window) {
  // Destroy Layer
  layer_destroy(canvas);
}
Esempio n. 19
0
//destroys title layer
void title_layer_destroy(TitleLayer *title_layer) {
    layer_destroy(title_layer->layer);
}
Esempio n. 20
0
static void window_unload(Window *window) {
  layer_destroy(s_simple_bg_layer);
  layer_destroy(s_hands_layer);
  text_layer_destroy(s_trump_layer);
}
Esempio n. 21
0
// Clean up
void deinit(void) {
  window_destroy(window);
  layer_destroy(boardLayer);
  layer_destroy(playersLayer);
  text_layer_destroy(timeLayer);
}
Esempio n. 22
0
static void window_unload(Window *window) {
  layer_remove_from_parent(layer);
  layer_destroy(layer);
}
Esempio n. 23
0
//
// main_window_unload
//
static void main_window_unload(Window *window) {
  sprite_free( RESOURCE_ID_IMAGE_ROCKET );
  layer_destroy(s_canvas);
  bitmap_layer_destroy(s_bitmap_layer);
}
Esempio n. 24
0
static void deinit(void) {
  tick_timer_service_unsubscribe();
  layer_destroy(timeLayer);
  layer_destroy(astroLayer);
  window_destroy(window);
}
Esempio n. 25
0
static void window_unload(Window *window) {
  layer_destroy(Hour);
  layer_destroy(HourLine);
  layer_destroy(Minute);
  layer_destroy(MinuteLine);
}
Esempio n. 26
0
void deinit(void) {
  tick_timer_service_unsubscribe();
  layer_destroy(display_layer);
  window_destroy(window);
}
Esempio n. 27
0
void init()
{
	window = window_create();
	window_set_fullscreen(window, true);
	window_stack_push(window, true);
	
	Layer* window_layer = window_get_root_layer(window);
	
	//backgrounds
	back_layer_A = layer_create(GRect(0,0,144,144));
	layer_set_update_proc(back_layer_A, update_back_layer_A);
	back_layer_B = layer_create(GRect(0,168,144,144));
	layer_set_update_proc(back_layer_B, update_back_layer_B);
	//watchface
	watchface_layer = layer_create(GRect(0,0,144,168));
	layer_set_update_proc(watchface_layer, update_watchface);
	//cards
	card_layer_A = layer_create(GRect(0,168,144,168));
	layer_set_update_proc(card_layer_A, update_card_layer_A);
	card_layer_B = layer_create(GRect(0,168,144,168));
	layer_set_update_proc(card_layer_B, update_card_layer_B);
	//expanded
	expanded_layer = layer_create(GRect(0,168,144,168-50));
	layer_set_update_proc(expanded_layer, update_expanded_layer);
	
	for(int i=0; i<CACHE_SIZE; i++)
	{	
		back_bitmaps[i] = (GBitmap){.addr = back_image_data[i], .bounds = GRect(0,0,144,144), .row_size_bytes = ROW_SIZE};
		icon_bitmaps[i] = (GBitmap){.addr = icon_image_data[i], .bounds = GRect(0,0,48,48), .row_size_bytes = ICON_ROW_SIZE};
		reset_card(i);
	}
	
	resize_layers();
	
	layer_add_child(window_layer, back_layer_A);
	layer_add_child(window_layer, back_layer_B);
	layer_add_child(window_layer, watchface_layer);
	layer_add_child(window_layer, card_layer_A);
	layer_add_child(window_layer, card_layer_B);
	layer_add_child(window_layer, expanded_layer);
	
	window_set_click_config_provider(window, (ClickConfigProvider) subscribe_buttons);
	tick_timer_service_subscribe(MINUTE_UNIT, (TickHandler) tick);
	
	
	//message stuff
	app_message_register_inbox_received(in_received_handler);
	app_message_register_inbox_dropped(in_dropped_handler);
	app_message_register_outbox_sent(out_sent_handler);
	app_message_register_outbox_failed(out_failed_handler);

	//set size
	const uint32_t inbound_size = 512;
	const uint32_t outbound_size = 64;
	app_message_open(inbound_size, outbound_size);
	
	app_comm_set_sniff_interval(SNIFF_INTERVAL_REDUCED);
	
	DictionaryIterator *iter;
 	app_message_outbox_begin(&iter);
	Tuplet value = TupletInteger(1, 0);
	dict_write_tuplet(iter, &value);
	app_message_outbox_send();
}

void deinit()
{
	destroy_animations();
	layer_destroy(back_layer_A);
	layer_destroy(back_layer_B);
	layer_destroy(card_layer_A);
	layer_destroy(card_layer_B);
	layer_destroy(watchface_layer);
	layer_destroy(expanded_layer);
	window_destroy(window);
}
	
int main(void)
{
	init();
	app_event_loop();
	deinit();
}
Esempio n. 28
0
static void main_window_unload(Window *window) {
    layer_destroy(graphics_layer);
}
Esempio n. 29
0
static void window_unload(Window *window) {
  free(s_palette);
  layer_destroy(s_layer);
}
Esempio n. 30
0
void bluetooth_deinit() {
  bluetooth_connection_service_unsubscribe();
  gpath_destroy(s_bt_path);
  layer_destroy(s_bt_layer);
}