static void handle_deinit() { app_message_deregister_callbacks(); battery_state_service_unsubscribe(); tick_timer_service_unsubscribe(); fonts_unload_custom_font(font); fonts_unload_custom_font(font2); gpath_destroy(min_path); gpath_destroy(hour_path); gpath_destroy(hour_in_path); text_layer_destroy(battp_layer); text_layer_destroy(date_layer); text_layer_destroy(day_layer); text_layer_destroy(time_layer); layer_destroy(hands_layer); bitmap_layer_destroy(logo_layer); gbitmap_destroy(logo); bitmap_layer_destroy(battery_layer); for (int i = 0; i < 22; i++) gbitmap_destroy(battery_images[i]); bitmap_layer_destroy(bluetooth_layer); for (int i = 0; i < 2; i++) gbitmap_destroy(bluetooth_images[i]); layer_destroy(background_layer); window_destroy(window); }
void deinit() { //window_destroy(window); gbitmap_destroy(background_image_container); gbitmap_destroy(icon_battery); gbitmap_destroy(icon_battery_charge); gbitmap_destroy(icon_bt); text_layer_destroy(date_layer); layer_destroy(minute_display_layer); layer_destroy(hour_display_layer); layer_destroy(center_display_layer); layer_destroy(second_display_layer); layer_destroy(battery_layer); layer_destroy(bt_layer); #ifdef INVERSE inverter_layer_destroy(full_inverse_layer); #endif layer_destroy(background_layer); layer_destroy(window_layer); gpath_destroy(hour_hand_path); gpath_destroy(minute_hand_path); }
void handle_deinit() { app_message_deregister_callbacks(); battery_state_service_unsubscribe(); tick_timer_service_unsubscribe(); if (has_config) { persist_write_int(SECONDS_MODE, seconds_mode); persist_write_int(BATTERY_MODE, battery_mode); persist_write_int(DATE_MODE, date_mode); persist_write_int(BLUETOOTH_MODE, bluetooth_mode); APP_LOG(APP_LOG_LEVEL_DEBUG, "Wrote config"); } else { APP_LOG(APP_LOG_LEVEL_DEBUG, "Did not write config"); } fonts_unload_custom_font(font); gpath_destroy(sec_path); gpath_destroy(min_path); gpath_destroy(hour_path); inverter_layer_destroy(inverter_layer); #if DEBUG text_layer_destroy(debug_layer); #endif layer_destroy(hands_layer); bitmap_layer_destroy(logo_layer); gbitmap_destroy(logo); bitmap_layer_destroy(battery_layer); for (int i = 0; i < 22; i++) gbitmap_destroy(battery_images[i]); bitmap_layer_destroy(bluetooth_layer); for (int i = 0; i < 2; i++) gbitmap_destroy(bluetooth_images[i]); layer_destroy(background_layer); layer_destroy(date_layer); window_destroy(window); }
void deinit() { // http://forums.getpebble.com/discussion/12927/app-crashes-on-2-1-double-free-detected //window_destroy(window); gbitmap_destroy(background_image_container); gbitmap_destroy(icon_battery); gbitmap_destroy(icon_battery_charge); gbitmap_destroy(icon_bt); text_layer_destroy(date_layer); layer_destroy(minute_display_layer); layer_destroy(hour_display_layer); layer_destroy(center_display_layer); layer_destroy(second_display_layer); layer_destroy(battery_layer); layer_destroy(bt_layer); deinit_double_time(); #ifdef INVERSE inverter_layer_destroy(full_inverse_layer); #endif layer_destroy(background_layer); layer_destroy(window_layer); gpath_destroy(hour_hand_path); gpath_destroy(minute_hand_path); }
static void main_window_unload(Window *window) { gpath_destroy(s_minute_segment_path); gpath_destroy(s_hour_segment_path); layer_destroy(s_minute_display_layer); layer_destroy(s_hour_display_layer); }
void paths_create() { for (int i = 0; i < NUM_WEDGES; i++) { if (s_paths[i]) { gpath_destroy(s_paths[i]); } GPathInfo path_info = (GPathInfo) { .num_points = 3, .points = s_points[i] }; s_paths[i] = gpath_create(&path_info); gpath_move_to(s_paths[i], s_center); } } void paths_destroy() { for (int i = 0; i < NUM_WEDGES; i++) { gpath_destroy(s_paths[i]); } } Layer* forecast_create(GRect window_bounds) { s_center = grect_center_point(&window_bounds); init_points(); paths_create(); s_canvas_layer = layer_create(window_bounds); //layer_add_child(s_canvas_layer, textlayer_create()); layer_set_update_proc(s_canvas_layer, draw_forecast); static Layer* icons_layer; icons_layer = forecast_icons_create(window_bounds); layer_add_child(s_canvas_layer, icons_layer); return s_canvas_layer; }
static void deinit(void) { gpath_destroy(minute_segment_path); gpath_destroy(hour_segment_path); tick_timer_service_unsubscribe(); window_destroy(window); layer_destroy(minute_display_layer); layer_destroy(hour_display_layer); }
static void main_window_unload(Window *window) { layer_destroy(s_draw_layer); layer_destroy(s_bg_layer); text_layer_destroy(s_time_layer); deinit_battery_watcher(); deinit_accel_tap_handler(); gpath_destroy(s_minute_arrow); gpath_destroy(s_hour_arrow); }
static void window_unload(Window *window) { gbitmap_destroy(s_background_bitmap); bitmap_layer_destroy(s_background_layer); gpath_destroy(s_minute_arrow); gpath_destroy(s_hour_arrow); layer_destroy(s_hands_layer); text_layer_destroy(s_textlayer_date); }
static void main_window_unload(Window *window) { layer_destroy(s_clock_layer_outer); layer_destroy(s_clock_layer_center); layer_destroy(s_clock_layer_inner); text_layer_destroy(s_text_time); inverter_layer_destroy(s_layer_invert); gpath_destroy(s_hand_path_outer); gpath_destroy(s_hand_path_center); gpath_destroy(s_hand_path_inner); }
// Draw the gray cover over part of the progress ring static void prv_draw_progress_ring(GContext *ctx, GSize window_size, uint32_t angle) { graphics_context_set_fill_color(ctx, COLOR_BACKGROUND); // get step angle and exit if too small int32_t step = angle / 4; if (step < 1) { return; } // get properties GPoint center = GPoint(window_size.w / 2, window_size.h / 2); uint16_t radius = window_size.h + window_size.w / 2; // calculate points around outside of window to draw cover GPoint points[8]; int8_t idx = 0; for (uint32_t t_angle = 0; t_angle < angle; t_angle += step){ points[idx++] = prv_polar_to_rectangular(center, t_angle, radius); } // add point at hand position, and in center (to form pie wedge) points[idx++] = prv_polar_to_rectangular(center, angle, radius); points[idx++] = center; // fill the covering GPathInfo info = (GPathInfo) { .num_points = idx, .points = points }; GPath *path = gpath_create(&info); gpath_draw_filled(ctx, path); gpath_destroy(path); }
static void shape(GContext *ctx,uint16_t ang,int16_t ox,int16_t oy,int16_t mx,int16_t my,GPathInfo *gp,int func) { // draw 'shape' rotated to 'ang' and translated by 'ox' and 'oy' // use this instead of the library functions as they have shit precision GPoint *oldpoints=gp->points; gp->points=malloc(sizeof(GPoint)*gp->num_points); for(uint16_t i=0;i<gp->num_points;i++) { gp->points[i].x=((oldpoints[i].x*mx)>>FRACBITS)+ox; gp->points[i].y=((oldpoints[i].y*my)>>FRACBITS)+oy; rotate(ang,&gp->points[i]); gp->points[i].x=(gp->points[i].x>>FRACBITS)+CENTREX; gp->points[i].y=(gp->points[i].y>>FRACBITS)+CENTREY; } GPath *pptr=gpath_create(gp); switch(func) { case 0: // std filled in gpath_draw_outline(ctx,pptr); gpath_draw_filled(ctx,pptr); break; case 1: // open line draw #ifdef PBL_COLOR gpath_draw_outline_open(ctx,pptr); #else gpath_draw_outline(ctx,pptr); #endif break; } gpath_destroy(pptr); free(gp->points); gp->points=oldpoints; }
void screen_map_layer_deinit() { layer_destroy(s_data.page_map); for(int i = 0; i < NUM_LIVE_FRIENDS; i++) { text_layer_destroy(s_live.friends[i].name_layer); } layer_destroy(path_layer); layer_destroy(bearing_layer); gpath_destroy(bearing_gpath); }
static void main_window_unload(Window *window) { bitmap_layer_destroy(arrow); text_layer_destroy(distance); text_layer_destroy(timeTo); text_layer_destroy(output); text_layer_destroy(s_output_layer); text_layer_destroy(s_heading_layer); layer_destroy(s_path_layer); gpath_destroy(s_needle_north); }
// Release any memory held within a HandCache structure. void hand_cache_destroy(struct HandCache *hand_cache) { bwd_destroy(&hand_cache->image); bwd_destroy(&hand_cache->mask); int gi; for (gi = 0; gi < HAND_CACHE_MAX_GROUPS; ++gi) { if (hand_cache->path[gi] != NULL) { gpath_destroy(hand_cache->path[gi]); hand_cache->path[gi] = NULL; } } }
static void main_window_unload(Window *window) { // Destroy TextLayer text_layer_destroy(s_time_layer); text_layer_destroy(s_info_layer); gpath_destroy(battery); layer_destroy(s_canvas); // Unload GFont fonts_unload_custom_font(s_time_font); }
void handle_deinit(void) { tick_timer_service_unsubscribe(); bluetooth_connection_service_unsubscribe(); // Destroy the date layer text_layer_destroy(s_data.day_label); text_layer_destroy(s_data.num_label); layer_destroy(s_data.date_layer); //destroy hands layer text_layer_destroy(s_data.sec_layer); text_layer_destroy(s_data.min_layer); text_layer_destroy(s_data.hour_layer); layer_destroy(s_data.hands_layer); //destroy bg layer layer_destroy(s_data.bg_layer); //destroy paths for (int i = 0; i < NUM_CLOCK_TICKS; ++i) { gpath_destroy(s_data.tick_paths[i]); } //destroy paths for (int i = 0; i < NUM_BT_LINES; ++i) { gpath_destroy(s_data.bt_paths[i]); } //destroy paths for (int i = 0; i < NUM_BAT_LINES; ++i) { gpath_destroy(s_data.bat_paths[i]); } // Destroy the window window_destroy(s_data.window); app_sync_deinit(&app); }
void deinit() { tick_timer_service_unsubscribe(); battery_state_service_unsubscribe(); bluetooth_connection_service_unsubscribe(); text_layer_destroy(time1_text_layer); text_layer_destroy(date_text_layer); gpath_destroy(batt10); gpath_destroy(batt20); gpath_destroy(batt30); gpath_destroy(batt40); gpath_destroy(batt50); gpath_destroy(batt60); gpath_destroy(batt70); gpath_destroy(batt80); gpath_destroy(batt90); gpath_destroy(batt100); layer_destroy(path_layer); // window_destroy(window); }
static void window_unload() { // digital_clock_unload(); // binary_clock_unload(); // morse_clock_load(); watchface_unload(); indicators_unload(); settings_unload(); layer_destroy(s_top_layer); layer_destroy(s_background_layer); layer_destroy(s_grill_layer); gpath_destroy(s_windshield_path); }
static void window_unload(Window *window) { text_layer_destroy(s_time_layer); //destroy the main layer layer_destroy(s_layer); //destroy the date layer text_layer_destroy(s_date_layer); //destroy the weather layer text_layer_destroy(s_weather_layer); //destroy the bluetooth stuffs layer_destroy(s_bluetooth_icon_layer); gpath_destroy(bluetooth_path); }
// Draws a given hand on the face, using the vector structures. void draw_vector_hand(struct HandCache *hand_cache, struct HandDef *hand_def, int hand_index, GContext *ctx) { struct VectorHand *vector_hand = hand_def->vector_hand; int gi; if (hand_cache->vector_hand_index != hand_index) { // Force a new path. for (gi = 0; gi < vector_hand->num_groups; ++gi) { if (hand_cache->path[gi] != NULL) { gpath_destroy(hand_cache->path[gi]); hand_cache->path[gi] = NULL; } } hand_cache->vector_hand_index = hand_index; } GPoint center = { hand_def->place_x, hand_def->place_y }; int32_t angle = TRIG_MAX_ANGLE * hand_index / hand_def->num_steps; assert(vector_hand->num_groups <= HAND_CACHE_MAX_GROUPS); for (gi = 0; gi < vector_hand->num_groups; ++gi) { struct VectorHandGroup *group = &vector_hand->group[gi]; if (hand_cache->path[gi] == NULL) { hand_cache->path[gi] = gpath_create(&group->path_info); if (hand_cache->path[gi] == NULL) { trigger_memory_panic(__LINE__); return; } gpath_rotate_to(hand_cache->path[gi], angle); gpath_move_to(hand_cache->path[gi], center); } if (group->fill != 0) { graphics_context_set_fill_color(ctx, draw_mode_table[config.draw_mode].colors[group->fill]); gpath_draw_filled(ctx, hand_cache->path[gi]); } if (group->outline != 0) { graphics_context_set_stroke_color(ctx, draw_mode_table[config.draw_mode].colors[group->outline]); gpath_draw_outline(ctx, hand_cache->path[gi]); } } }
static void window_unload(Window *window) { gbitmap_destroy(s_unary_ticks_bitmap); bitmap_layer_destroy(s_unary_ticks_layer); gbitmap_destroy(s_ternary_ticks_bitmap); bitmap_layer_destroy(s_ternary_ticks_layer_minutes); bitmap_layer_destroy(s_ternary_ticks_layer_seconds); //destroy the main layer layer_destroy(s_layer); //destroy the date layer text_layer_destroy(s_date_layer); //destroy the weather layer text_layer_destroy(s_weather_layer); //destroy the bluetooth stuffs layer_destroy(s_bluetooth_icon_layer); gpath_destroy(bluetooth_path); }
/* * Function: canvas_update_proc * ---------------------------------------------------------------------------- * Draws the mood graph on the screen. * * this_layer: the layer on which to draw on * ctx: the drawing context * ---------------------------------------------------------------------------- */ void canvas_update_proc(Layer *this_layer, GContext *ctx) { if (s_path) { gpath_destroy(s_path); } GRect bounds = layer_get_bounds(this_layer); int bounds_size_w = bounds.size.w; int bounds_size_h = bounds.size.h; GPathBuilder *builder = gpath_builder_create(MAX_POINTS); // Draw a black filled rectangle with sharp corners graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, bounds, 0, GCornerNone); // Draw the mood lines graphics_context_set_fill_color(ctx, GColorWhite); // Draw the Mood (color) coding rectangles draw_mood_areas(ctx, bounds_size_w); #if PBL_PLATFORM_BASALT graphics_context_set_stroke_width(ctx, 1); #endif // Create the mood data graph create_graph(ctx, bounds_size_h, builder); // Set the graph line color to white graphics_context_set_stroke_color(ctx, GColorWhite); #ifdef PBL_PLATFORM_BASALT // On Pebble Time (Basalt) create path from builder s_path = gpath_builder_create_path(builder); #endif gpath_builder_destroy(builder); #ifdef PBL_PLATFORM_APLITE //gpath_draw_outline(ctx, s_path); #elif PBL_PLATFORM_BASALT gpath_draw_outline_open(ctx, s_path); #endif }
void twilight_path_render(TwilightPath *pTwilightPath, GContext *ctx, GColor color, GRect frameDst) { if ((pTwilightPath->fDawnTime == NO_RISE_SET_TIME) || (pTwilightPath->fDuskTime == NO_RISE_SET_TIME)) { // sun either never sets or never rises at this location / time. // For now, simply render nothing. return; } // Recreate path each time. Not sure if this is strictly necessary // but it would probably not be good to apply gpath_move_to() more // than once for the same path instance. if (pTwilightPath->pPath != NULL) gpath_destroy(pTwilightPath->pPath); pTwilightPath->pPath = gpath_create(&(pTwilightPath->pathInfo)); if (pTwilightPath->pPath == NULL) return; gpath_move_to(pTwilightPath->pPath, grect_center_point(&frameDst)); // do rendering if (pTwilightPath->pBmpGrey != NULL) { graphics_context_set_compositing_mode(ctx, GCompOpAnd); graphics_draw_bitmap_in_rect(ctx, pTwilightPath->pBmpGrey, frameDst); } graphics_context_set_fill_color(ctx, color); if ((pTwilightPath != NULL) && (pTwilightPath->pPath != NULL)) { gpath_draw_filled(ctx, pTwilightPath->pPath); } } /* end of twilight_path_render */
static void clean() { already_failed_question = false; for(int i=0; i < ui.glyph_paths_num; i++) gpath_destroy(ui.glyph_path[i]); ui.glyph_paths_num = 0; for(int i=0; i < 3; i++) { text_layer_set_text(ui.romajiAnswer[i], ""); #ifdef PBL_COLOR text_layer_set_text_color(ui.romajiAnswer[i], SEC_FG_COLOR); #endif } if(ui.romajiQuestion != NULL) { text_layer_destroy(ui.romajiQuestion); ui.romajiQuestion = NULL; } for(int i=0; i < 3; i++) clean_bitmap_answer(i); }
static void display_layer_update(Layer *layer, GContext *ctx) { time_t temp = time(NULL); struct tm *tick_time = localtime(&temp); // Second angle = TRIG_MAX_ANGLE * (tick_time->tm_sec / 60.0); path_info.points[0].x = centre.x + (sin_lookup(angle) * radius / TRIG_MAX_RATIO); path_info.points[0].y = centre.y - (cos_lookup(angle) * radius / TRIG_MAX_RATIO); // Minute angle = TRIG_MAX_ANGLE * (((tick_time->tm_min * 60) + tick_time->tm_sec) / 3600.0); path_info.points[1].x = centre.x + (sin_lookup(angle) * radius / TRIG_MAX_RATIO); path_info.points[1].y = centre.y - (cos_lookup(angle) * radius / TRIG_MAX_RATIO); // Hour angle = TRIG_MAX_ANGLE * ((((tick_time->tm_hour % 12) * 60) + tick_time->tm_min) / 720.0); path_info.points[2].x = centre.x + (sin_lookup(angle) * radius / TRIG_MAX_RATIO); path_info.points[2].y = centre.y - (cos_lookup(angle) * radius / TRIG_MAX_RATIO); // Do some drawing graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_fill_color(ctx, GColorBlack); // Draw the poly path = gpath_create(&path_info); if(tick_time->tm_sec == tick_time->tm_min || tick_time->tm_sec == tick_time->tm_hour * 5) { // Make it easier to see gpath_draw_outline(ctx, path); } else { gpath_draw_filled(ctx, path); } gpath_destroy(path); // Draw some dots graphics_fill_circle(ctx, path_info.points[0], 1); graphics_fill_circle(ctx, path_info.points[1], 2); graphics_fill_circle(ctx, path_info.points[2], 3); }
static void prv_draw_major_hands(GContext *ctx, const GPoint *center, int32_t hand_length, int32_t angle, GColor color) { GPoint points[] = { {-3, 0}, {3, 0}, {6, (int16_t)-(hand_length - 8)}, {0, (int16_t)-hand_length}, {-6, (int16_t)-(hand_length - 8)}, }; const GPathInfo path_info = (GPathInfo) { .num_points = ARRAY_LENGTH(points), .points = points, }; GPath *path = gpath_create(&path_info); gpath_move_to(path, *center); gpath_rotate_to(path, angle); graphics_context_set_fill_color(ctx, color); gpath_draw_filled(ctx, path); gpath_destroy(path); }
// Draw the button onto the drawing context void drawing_button_draw(Button *button, GContext *ctx, GSize window_size, uint8_t pose, GBitmap *bmp) { // set fill color GColor fore_color = COLOR_PLAYING_FORE; if (pose == PoseWaitingForStart || pose == PoseDone) { fore_color = COLOR_PAUSED_FORE; } else if (pose == PoseResting) { fore_color = COLOR_RESTING_FORE; } graphics_context_set_fill_color(ctx, fore_color); // draw as path GPathInfo button_path = { .num_points = 4, .points = button->right, }; GPath *path = gpath_create(&button_path); gpath_move_to(path, GPoint(window_size.w / 2, window_size.h / 2)); gpath_draw_filled(ctx, path); gpath_destroy(path); button_path.points = button->left; path = gpath_create(&button_path); gpath_move_to(path, GPoint(window_size.w / 2, window_size.h / 2)); gpath_draw_filled(ctx, path); gpath_destroy(path); // if aplite, cover with gray #ifndef PBL_COLOR graphics_context_set_compositing_mode(ctx, GCompOpOr); graphics_draw_bitmap_in_rect(ctx, bmp, GRect(32, 42, 80, 80)); #endif } // Draw background in center of window void drawing_background(GContext *ctx, GSize window_size, uint32_t angle, uint8_t pose, GBitmap *bmp) { #ifdef PBL_COLOR // draw background color of window // this is actually the color of the progress ring, which is then covered up to give // the appearance of progress GColor fore_color = COLOR_PLAYING_FORE; GColor back_color = COLOR_PLAYING_BACK; if (pose == PoseWaitingForStart || pose == PoseDone) { fore_color = COLOR_PAUSED_FORE; back_color = COLOR_PAUSED_BACK; } else if (pose == PoseResting) { fore_color = COLOR_RESTING_FORE; back_color = COLOR_RESTING_BACK; } graphics_context_set_fill_color(ctx, fore_color); graphics_fill_rect(ctx, GRect(0, 0, window_size.w, window_size.h), 1, GCornerNone); #else GColor back_color = COLOR_PLAYING_BACK; graphics_draw_bitmap_in_rect(ctx, bmp, GRect(0, 0, window_size.w, window_size.h)); #endif // draw the cover for the progress ring prv_draw_progress_ring(ctx, window_size, angle); // draw the center circle graphics_context_set_fill_color(ctx, back_color); graphics_fill_circle(ctx, GPoint(window_size.w / 2, window_size.h / 2), CIRCLE_RADIUS); }
void analog_destroy(void) { layer_destroy(analog_layer); gpath_destroy(minute_arrow); gpath_destroy(hour_arrow); }
void draw_custom_weather_gpath(GContext *ctx, int CUSTOM_PATH_ID, GPoint origin, struct CONFIG_TYPE *config) { int path_num = 0; const struct GPathInfo *path; switch (CUSTOM_PATH_ID) { case CLOUDY_DAY: path_num = CLOUDY_DAY_PATH_COUNT; path = CLOUDY_DAY_PATHS; break; case HEAVY_RAIN: path_num = HEAVY_RAIN_PATH_COUNT; path = HEAVY_RAIN_PATHS; break; case HEAVY_SNOW: path_num = HEAVY_SNOW_PATH_COUNT; path = HEAVY_SNOW_PATHS; break; case LIGHT_RAIN: path_num = LIGHT_RAIN_PATH_COUNT; path = LIGHT_RAIN_PATHS; break; case LIGHT_SNOW: path_num = LIGHT_SNOW_PATH_COUNT; path = LIGHT_SNOW_PATHS; break; case PARTLY_CLOUDY: path_num = PARTLY_CLOUDY_PATH_COUNT; path = PARTLY_CLOUDY_PATHS; break; case RAINING_AND_SNOWING: path_num = RAINING_AND_SNOWING_PATH_COUNT; path = RAINING_AND_SNOWING_PATHS; break; case TIMELINE_SUN: path_num = TIMELINE_SUN_PATH_COUNT; path = TIMELINE_SUN_PATHS; break; case TIMELINE_WEATHER: path_num = TIMELINE_WEATHER_PATH_COUNT; path = TIMELINE_WEATHER_PATHS; break; default: path_num = TIMELINE_WEATHER_PATH_COUNT; path = TIMELINE_WEATHER_PATHS; break; } // Draw GPath for (int i = 0; i < path_num; i++) { s_my_path_ptr = gpath_create(&path[i]); gpath_move_to(s_my_path_ptr, origin); // Fill the path: graphics_context_set_fill_color(ctx, config->WEATHER_COLOR_FILL); gpath_draw_filled(ctx, s_my_path_ptr); // Stroke the path: graphics_context_set_stroke_color(ctx, config->WEATHER_COLOR_STROKE); graphics_context_set_stroke_width(ctx, 1); gpath_draw_outline(ctx, s_my_path_ptr); // Release gpath_destroy(s_my_path_ptr); //APP_LOG(APP_LOG_LEVEL_DEBUG, "Heap Available: %d", heap_bytes_free()); } }