예제 #1
0
void chrono_digital_window_unload_handler(struct Window *window) {
  app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "chrono digital unloads");

  if (chrono_digital_line_layer != NULL) {
    layer_destroy(chrono_digital_line_layer);
    chrono_digital_line_layer = NULL;
  }
  
  if (chrono_digital_current_layer != NULL) {
    text_layer_destroy(chrono_digital_current_layer);
    chrono_digital_current_layer = NULL;
  }
  int i;
  for (i = 0; i < CHRONO_MAX_LAPS; ++i) {
    if (chrono_digital_laps_layer[i] != NULL) {
      text_layer_destroy(chrono_digital_laps_layer[i]);
      chrono_digital_laps_layer[i] = NULL;
    }
  }

#ifdef PBL_SDK_3
  if (chrono_digital_contents_layer != NULL) {
    layer_destroy(chrono_digital_contents_layer);
    chrono_digital_contents_layer = NULL;
  }
  if (chrono_status_bar_layer != NULL) {
    status_bar_layer_destroy(chrono_status_bar_layer);
    chrono_status_bar_layer = NULL;
  }
#endif  // PDL_SDK_3
}
static void destroy_ui(void) {
    window_destroy(s_window);
    text_layer_destroy(s_destination_layer);
    text_layer_destroy(s_distance_layer);
    text_layer_destroy(s_distance_label_layer);
    text_layer_destroy(s_eta_layer);
    text_layer_destroy(s_eta_label_layer);
    status_bar_layer_destroy(s_statusbar_layer);
}
예제 #3
0
void window_unload(Window *window) {
    hide_message();
    
    menu_layer_destroy(menu_layer);
#ifdef PBL_PLATFORM_BASALT
    status_bar_layer_destroy(bar_layer);
#endif
    
    window_destroy(window);
}
예제 #4
0
파일: mainwin.c 프로젝트: SeaPea/HomeP
static void destroy_ui(void) {
  IF_3(status_bar_layer_destroy(s_status_bar));
  action_bar_layer_destroy(s_actionbar_main);
  devicecard_layer_destroy(s_devicecard_layer);
  devicecard_layer_destroy(s_devicecard_layer_old);
  layer_destroy(s_layer_spots);
  gbitmap_destroy(s_res_image_action_up);
  gbitmap_destroy(s_res_image_action_set);
  gbitmap_destroy(s_res_image_action_down);
  window_destroy(s_window);
}
예제 #5
0
void time_window_destroy(TimeWindow *time_window) {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "destroy time window");
  if (time_window) {
    status_bar_layer_destroy(time_window->status);
    selection_layer_destroy(time_window->selection);
    text_layer_destroy(time_window->sub_text);
    text_layer_destroy(time_window->main_text);
    free(time_window);
    time_window = NULL;
    return;
  }
}
예제 #6
0
void mainWindowUnload() {
  if (s_gameState == kGameOver) endGame();
  else saveGame();
  layer_destroy(s_boardLayer);
  layer_destroy(s_mainBackgroundLayer);
  layer_destroy(s_mainForegroundLayer);
  status_bar_layer_destroy(s_statusBar);
  s_boardLayer = NULL;
  s_mainBackgroundLayer = NULL;
  s_mainForegroundLayer = NULL;
  s_statusBar = NULL;
  stopGameTick();
  accel_data_service_unsubscribe();
}
예제 #7
0
void main_window_unload(Window *window) 
{
  // Destroy TextLayer
  for ( int loop = 0; loop < N_LAYERS ; loop ++ )
  {
     text_layer_destroy(LOCAL_layers[loop].layer);
     text_layer_destroy(LOCAL_layers_small[loop].layer);
     
     if ( LOCAL_icon[loop] != NULL )
     {
        gbitmap_destroy( LOCAL_icon[loop] );  
        LOCAL_icon[loop] = NULL;
     }   
  }
  
  action_bar_layer_destroy( LOCAL_action_bar );
  status_bar_layer_destroy( LOCAL_status_bar );
}
예제 #8
0
PinWindow* pin_window_create(PinWindowCallbacks callbacks, PinWindowData data) {
  PinWindow *pin_window = (PinWindow*)malloc(sizeof(PinWindow));
  if (data.nb_digits==0)
    data.nb_digits = PIN_WINDOW_NUM_CELLS;
  if (pin_window) {
    pin_window->window = window_create();
    pin_window->callbacks = callbacks;
    if (pin_window->window) {
      pin_window->field_selection = 0;
      for(int i = 0; i < data.nb_digits; i++) {
        pin_window->pin.digits[i] = data.init_pin->digits[i];
      }
      
      // Get window parameters
      Layer *window_layer = window_get_root_layer(pin_window->window);
      GRect bounds = layer_get_bounds(window_layer);
      // Main TextLayer
      const GEdgeInsets main_text_insets = {.top = 30};
      pin_window->main_text = text_layer_create(grect_inset(bounds, main_text_insets));
      text_layer_set_text(pin_window->main_text, data.main_text);
      text_layer_set_font(pin_window->main_text, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
      text_layer_set_text_alignment(pin_window->main_text, GTextAlignmentCenter);
      layer_add_child(window_layer, text_layer_get_layer(pin_window->main_text));
      // Separators layer
      const GEdgeInsets sep_text_insets = {.top = 75};
      pin_window->sep_text = text_layer_create(grect_inset(bounds, sep_text_insets));
      if(data.nb_digits==3)
        text_layer_set_text(pin_window->sep_text, "        :          :      ");
      else
        text_layer_set_text(pin_window->sep_text, "      :     ");
      text_layer_set_font(pin_window->sep_text, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
      text_layer_set_text_alignment(pin_window->sep_text, GTextAlignmentCenter);
      layer_add_child(window_layer, text_layer_get_layer(pin_window->sep_text));
      // Sub TextLayer
      const GEdgeInsets sub_text_insets = {.top = 115, .right = 5, .bottom = 10, .left = 5};
      pin_window->sub_text = text_layer_create(grect_inset(bounds, sub_text_insets));
      text_layer_set_text(pin_window->sub_text, data.sub_text);
      text_layer_set_text_alignment(pin_window->sub_text, GTextAlignmentCenter);
      text_layer_set_font(pin_window->sub_text, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
      layer_add_child(window_layer, text_layer_get_layer(pin_window->sub_text));
      // Create selection layer
      const GEdgeInsets selection_insets = GEdgeInsets(
        (bounds.size.h - PIN_WINDOW_SIZE.h) / 2,
        (bounds.size.w - (40 * data.nb_digits)) / 2);
      pin_window->selection = selection_layer_create(grect_inset(bounds, selection_insets), data.nb_digits);
      for (int i = 0; i < data.nb_digits; i++) {
        selection_layer_set_cell_width(pin_window->selection, i, 40);
      }
      selection_layer_set_cell_padding(pin_window->selection, 4);
      selection_layer_set_active_bg_color(pin_window->selection, GColorRed);
      selection_layer_set_inactive_bg_color(pin_window->selection, GColorDarkGray);
      selection_layer_set_click_config_onto_window(pin_window->selection, pin_window->window);
      selection_layer_set_callbacks(pin_window->selection, pin_window, (SelectionLayerCallbacks) {
        .get_cell_text = selection_handle_get_text,
        .complete = selection_handle_complete,
        .increment = selection_handle_inc,
        .decrement = selection_handle_dec,
        });
      layer_add_child(window_get_root_layer(pin_window->window), pin_window->selection);
      // Create status bar
      pin_window->status = status_bar_layer_create();
      status_bar_layer_set_colors(pin_window->status, GColorClear, GColorBlack);
      layer_add_child(window_layer, status_bar_layer_get_layer(pin_window->status));
      return pin_window;
    }
  }
  APP_LOG(APP_LOG_LEVEL_ERROR, "Failed to create PinWindow");
  return NULL;
}

void pin_window_destroy(PinWindow *pin_window) {
  if (pin_window) {
    status_bar_layer_destroy(pin_window->status);
    selection_layer_destroy(pin_window->selection);
    text_layer_destroy(pin_window->sub_text);
    text_layer_destroy(pin_window->main_text);
    text_layer_destroy(pin_window->sep_text);
    free(pin_window);
    pin_window = NULL;
    return;
  }
}

void pin_window_push(PinWindow *pin_window, bool animated) {
  window_stack_push(pin_window->window, animated);
}