Ejemplo n.º 1
0
static void window_load(Window *window) {
	Layer *window_layer = window_get_root_layer(window);

	GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);

	text_layer_top = text_layer_create(GRect(0, 0, 144, 68));
	text_layer_set_text_color(text_layer_top, GColorWhite);
	text_layer_set_background_color(text_layer_top, GColorClear);
	text_layer_set_font(text_layer_top, font);
	text_layer_set_text_alignment(text_layer_top, GTextAlignmentCenter);
	text_layer_set_text(text_layer_top, "");
	text_layer_set_overflow_mode(text_layer_top, GTextOverflowModeTrailingEllipsis);

	text_layer_middle = text_layer_create(GRect(0, 55, 144, 68));
	text_layer_set_text_color(text_layer_middle, GColorWhite);
	text_layer_set_background_color(text_layer_middle, GColorClear);
	text_layer_set_font(text_layer_middle, font);
	text_layer_set_text_alignment(text_layer_middle, GTextAlignmentCenter);
	text_layer_set_text(text_layer_middle, "Loading...");
	text_layer_set_overflow_mode(text_layer_middle, GTextOverflowModeTrailingEllipsis);

	text_layer_bottom = text_layer_create(GRect(0, 110, 144, 68));
	text_layer_set_text_color(text_layer_bottom, GColorWhite);
	text_layer_set_background_color(text_layer_bottom, GColorClear);
	text_layer_set_font(text_layer_bottom, font);
	text_layer_set_text_alignment(text_layer_bottom, GTextAlignmentCenter);
	text_layer_set_text(text_layer_bottom, "");
	text_layer_set_overflow_mode(text_layer_bottom, GTextOverflowModeTrailingEllipsis);

	layer_add_child(window_layer, text_layer_get_layer(text_layer_top));
	layer_add_child(window_layer, text_layer_get_layer(text_layer_middle));
	layer_add_child(window_layer, text_layer_get_layer(text_layer_bottom));
}
Ejemplo n.º 2
0
void handle_init(AppContextRef ctx) {
  srand(time(NULL));//seed randmoness!
  window_init(&window, "Window Name");
  window_stack_push(&window, true /* Animated */);
  text_layer_init(&dateLayer, GRect(0, 0, 144, 50));
  text_layer_set_text_alignment(&dateLayer, GTextAlignmentCenter);
  text_layer_set_font(&dateLayer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
  text_layer_set_background_color(&dateLayer, GColorBlack);
  text_layer_set_text_color(&dateLayer, GColorWhite);
  text_layer_set_overflow_mode(&dateLayer, GTextOverflowModeWordWrap);
  layer_add_child(&window.layer, &dateLayer.layer);

  text_layer_init(&busLayer, GRect(0, 93, 144, 75));
  text_layer_set_text_alignment(&busLayer, GTextAlignmentCenter);
  text_layer_set_font(&busLayer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(&busLayer, GColorBlack);
  text_layer_set_text_color(&busLayer, GColorWhite);
  text_layer_set_overflow_mode(&busLayer, GTextOverflowModeWordWrap);
  layer_add_child(&window.layer, &busLayer.layer);

// Init the layer for the display
  layer_init(&display_layer, window.layer.frame);
  display_layer.update_proc = &display_layer_update_callback;
  layer_add_child(&window.layer, &display_layer);

  adjX = ((int) ( (144-((bitRect.size.w+BIT_SPACING)*ROW_WIDTH))/2)) -2;//change the -2 if needed
  adjY = ((int) ( ((168-YSTART)-((bitRect.size.h+BIT_SPACING)*COL_HEIGHT)  )/2)) - YSHORT/2;

  handle_minute_tick(ctx, NULL);
}
StatusBarElement* status_bar_element_create(Layer *parent) {
  GRect bounds = layer_get_bounds(parent);

  int sm_text_margin = 2;
  // L- and R-aligned text overlap, so one can be much longer, or nonexistent
  int text_width = bounds.size.w - sm_text_margin;

  TextLayer *left_text = text_layer_create(GRect(sm_text_margin, 0, text_width, bounds.size.h));
  text_layer_set_text_alignment(left_text, GTextAlignmentLeft);
  text_layer_set_background_color(left_text, GColorClear);
  text_layer_set_font(left_text, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_overflow_mode(left_text, GTextOverflowModeWordWrap);
  layer_add_child(parent, text_layer_get_layer(left_text));

  TextLayer *right_text = text_layer_create(GRect(0, 0, text_width, bounds.size.h));
  text_layer_set_text_alignment(right_text, GTextAlignmentRight);
  text_layer_set_background_color(right_text, GColorClear);
  text_layer_set_font(right_text, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_overflow_mode(right_text, GTextOverflowModeWordWrap);
  layer_add_child(parent, text_layer_get_layer(right_text));

  StatusBarElement *el = malloc(sizeof(StatusBarElement));
  el->left_text = left_text;
  el->right_text = right_text;
  return el;
}
// Initialize all UI components
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, true);
  
  visitors = 0;
  max_visitors = 0;
  
  s_data_text_layer = text_layer_create(GRect(0, 54, 144, 35));
  text_layer_set_text_alignment(s_data_text_layer, GTextAlignmentCenter);
  text_layer_set_overflow_mode(s_data_text_layer, GTextOverflowModeWordWrap);
  text_layer_set_font(s_data_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_text(s_data_text_layer, "Loading...");
  layer_add_child(window_get_root_layer(s_window), text_layer_get_layer(s_data_text_layer));
  
  s_label_text_layer = text_layer_create(GRect(0, 136, 144, 35));
  text_layer_set_text_alignment(s_label_text_layer, GTextAlignmentCenter);
  text_layer_set_overflow_mode(s_label_text_layer, GTextOverflowModeWordWrap);
  text_layer_set_background_color(s_label_text_layer, GColorBlack);
  text_layer_set_text_color(s_label_text_layer, GColorWhite);
  text_layer_set_font(s_label_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text(s_label_text_layer, "Concurrent Visits");
  layer_add_child(window_get_root_layer(s_window), text_layer_get_layer(s_label_text_layer));
  
  s_graph_layer = layer_create(GRect(10, 10, 124, 121));
  layer_set_update_proc(s_graph_layer, graph_layer_update_proc);
  layer_add_child(window_get_root_layer(s_window), s_graph_layer);
  
  get_data();
  s_timer = app_timer_register(REFRESH_TIME, timer_callback, NULL);
}
Ejemplo n.º 5
0
void text_phrase_layer_load(Window* window) {
  
  // Let's go get the bounds of the window first.
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  
  // Here's the coordinates for the textLayer.
  GRect text_location = GRect( PBL_IF_ROUND_ELSE(0, 0),
                              PBL_IF_ROUND_ELSE(bounds.size.h / 2 - RECT_MASTER_SIZE, bounds.size.h - RECT_MASTER_SIZE),
                              PBL_IF_ROUND_ELSE(170, 14*5), 
                              PBL_IF_ROUND_ELSE(PHRASE_TEXT_FONT_SIZE_R,PHRASE_TEXT_FONT_SIZE*2 + PHRASE_TEXT_FONT_SIZE/2));
  
  // Load custom font.
  font_moji = fonts_load_custom_font(
              resource_get_handle(PBL_IF_ROUND_ELSE(RESOURCE_ID_FONT_SHORTMOJI_18,RESOURCE_ID_FONT_SHORTMOJI_14)));
  
  
  // We declare the text layer into existence.
  // Settings to make the text layer look pretty.
  text_phrase_layer = text_layer_create(text_location);
  text_layer_set_text_color(text_phrase_layer, get_idol_main_color());
  text_layer_set_background_color(text_phrase_layer, GColorClear);
  text_layer_set_overflow_mode(text_phrase_layer, GTextOverflowModeWordWrap);
  text_layer_set_text_alignment(text_phrase_layer, GTextAlignmentCenter);
  text_layer_set_font(text_phrase_layer, font_moji);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_phrase_layer)); 
  
  // If we disable tapping events, the talking bubble will be visible
  // no matter what. But if tapping is enabled, then this is hidden by default.
  if(!is_tapping_disabled()) {
    set_text_phrase_layer_hidden(true);
  }
  
}
Ejemplo n.º 6
0
static void create_logo_layer(Window *window) {
	GRect logoBounds = logo_image->bounds;

	notification_layer = layer_create(GRect(0, bounds.size.h - logoBounds.size.h, bounds.size.w, logoBounds.size.h));
	layer_add_child(window_get_root_layer(window), notification_layer);

	// display logo
	logo_layer = bitmap_layer_create(GRect(3, 0, bounds.size.w, logoBounds.size.h));
	bitmap_layer_set_background_color(logo_layer, GColorWhite);
	bitmap_layer_set_alignment(logo_layer, GAlignTopLeft);
	bitmap_layer_set_bitmap(logo_layer, logo_image);
	layer_add_child(notification_layer, bitmap_layer_get_layer(logo_layer));

	// display notofications
	int offset = 4;
	notification_text_layer = text_layer_create(GRect(logoBounds.size.w + 7, offset, bounds.size.w - logoBounds.size.w - 7, logoBounds.size.h - offset));
	//text_layer_set_background_color(notification_text_layer, GColorClear);
	text_layer_set_font(notification_text_layer, statusFont);
	text_layer_set_text_alignment(notification_text_layer, GTextAlignmentLeft);
	text_layer_set_overflow_mode(notification_text_layer, GTextOverflowModeTrailingEllipsis);
	//text_layer_set_text(notification_text_layer, "noti");
	layer_add_child(notification_layer, text_layer_get_layer(notification_text_layer));

	// hide notification bar for state item, show for other items
	layer_set_hidden(notification_layer, (current_item == 0 ? true : false));
}
Ejemplo n.º 7
0
void trl_top_view_load(View *view)
{
	APP_LOG(APP_LOG_LEVEL_DEBUG, "TRLTopView trl_top_view_load");		

	TRLTopView *top_view = trl_top_view_from_view(view);

	// Top layer	
	top_view->base.root_layer = layer_create(GRect(0, 0, 144, 104));	

	top_view->top_value_layer = text_layer_create(GRect(0, 10, 144, 54));
	text_layer_set_text_color(top_view->top_value_layer, GColorWhite);
	text_layer_set_background_color(top_view->top_value_layer, GColorClear);
	text_layer_set_font(top_view->top_value_layer, fonts_get(EXTRA_48_NUMBERS));
	text_layer_set_text_alignment(top_view->top_value_layer, GTextAlignmentCenter);
	text_layer_set_overflow_mode(top_view->top_value_layer, GTextOverflowModeWordWrap);
	text_layer_set_text(top_view->top_value_layer, top_view->value);

	top_view->top_title_layer = text_layer_create(GRect(0, 64, 144, 40));
	text_layer_set_text_color(top_view->top_title_layer, GColorWhite);
	text_layer_set_background_color(top_view->top_title_layer, GColorClear);
	text_layer_set_font(top_view->top_title_layer, fonts_get(LIGHT_24_TEXT));
	text_layer_set_text_alignment(top_view->top_title_layer, GTextAlignmentCenter);
	text_layer_set_text(top_view->top_title_layer, top_view->title);

	layer_add_child(top_view->base.root_layer, text_layer_get_layer(top_view->top_value_layer));
	layer_add_child(top_view->base.root_layer, text_layer_get_layer(top_view->top_title_layer));			
}
Ejemplo n.º 8
0
static void format_text_layer(TextLayer *layer, GTextAlignment alignment) {
  text_layer_set_background_color(layer, GColorClear);
  text_layer_set_overflow_mode(layer, GTextOverflowModeWordWrap);
  text_layer_set_text_alignment(layer, alignment);
  text_layer_set_font(layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text_color(layer, GColorLightGray);
}
Ejemplo n.º 9
0
static void main_window_load(Window *window) {
    // Create time TextLayer
    s_time_layer = text_layer_create(GRect(0, 40, 144, 50));
    text_layer_set_background_color(s_time_layer, GColorClear);
    text_layer_set_text_color(s_time_layer, GColorWhite);

    // Improve the layout to be more like a watchface
    text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
    text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);

    // Add it as a child layer to the Window's root layer
    layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));

    // Create time TextLayer
    s_factors_layer = text_layer_create(GRect(0, 90, 144, 60));
    text_layer_set_background_color( s_factors_layer, GColorClear);
    text_layer_set_text_color( s_factors_layer, GColorWhite);

    // Improve the layout to be more like a watchface
    text_layer_set_font( s_factors_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
    text_layer_set_text_alignment( s_factors_layer, GTextAlignmentCenter);
    text_layer_set_overflow_mode( s_factors_layer, GTextOverflowModeWordWrap );

    // Add it as a child layer to the Window's root layer
    layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_factors_layer));
}
Ejemplo n.º 10
0
static void card_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  
  bounds.origin.x = 5;
  bounds.origin.y = 0;
  bounds.size.w -= 5;
  bounds.size.h -= 110;
  
  s_free_layer = text_layer_create(bounds);
  text_layer_set_font(s_free_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
 
  bounds.origin.y += bounds.size.h;
  bounds.size.h -= 14;
  
  s_total_layer = text_layer_create(bounds);
  text_layer_set_font(s_total_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  
  bounds.origin.y += bounds.size.h;
  bounds.size.h += 24;
  
  s_name_layer = text_layer_create(bounds);
  text_layer_set_font(s_name_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_overflow_mode(s_name_layer, GTextOverflowModeWordWrap);
  
  layer_add_child(window_layer, text_layer_get_layer(s_free_layer));
  layer_add_child(window_layer, text_layer_get_layer(s_total_layer));
  layer_add_child(window_layer, text_layer_get_layer(s_name_layer));
  
  card_shown = true;
  
  update();
}
Ejemplo n.º 11
0
static void single_code_window_load(Window *window) {
	window_set_click_config_provider(single_code_main_window, (ClickConfigProvider) window_config_provider);
	
	Layer *window_layer = window_get_root_layer(single_code_main_window);
	display_bounds = layer_get_frame(window_layer);

  Layer *countdown_layer = layer_create(display_bounds);
  layer_add_child(window_layer, countdown_layer);
	//add_countdown_layer(s_layer);
  start_managing_countdown_layer(countdown_layer);
	
	text_label_rect = single_text_label_rect;
	GRect text_label_start = text_label_rect;
	text_label_start.origin.x = display_bounds.size.w;
	text_label_layer = text_layer_create(text_label_start);
	text_layer_set_background_color(text_label_layer, GColorClear);
	text_layer_set_text_alignment(text_label_layer, single_text_label_alignment);
	text_layer_set_overflow_mode(text_label_layer, GTextOverflowModeWordWrap);
	text_layer_set_text(text_label_layer, label_text);
	layer_add_child(window_layer, text_layer_get_layer(text_label_layer));
	
	text_pin_rect = single_text_pin_rect;
	GRect text_pin_start = text_pin_rect;
	text_pin_start.origin.x = display_bounds.size.w;
	text_pin_layer = text_layer_create(text_pin_start);
	text_layer_set_background_color(text_pin_layer, GColorClear);
	text_layer_set_text_alignment(text_pin_layer, GTextAlignmentCenter);
	text_layer_set_text(text_pin_layer, pin_text);
	layer_add_child(window_layer, text_layer_get_layer(text_pin_layer));
	
	apply_display_colors();
	set_fonts();
	loading_complete = true;
}
Ejemplo n.º 12
0
static void typicalTextLayerSetup(TextLayer *textlayer) {
	// Typical text layer setup
	text_layer_set_text_color(textlayer, GColorBlack);
	text_layer_set_background_color(textlayer, GColorWhite);
	text_layer_set_text_alignment(textlayer, GTextAlignmentLeft);
	text_layer_set_overflow_mode(textlayer, GTextOverflowModeWordWrap);
	text_layer_set_font(textlayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
}
Ejemplo n.º 13
0
static void window_load(Window *window) {

    Loading = 1;

    Layer *window_layer = window_get_root_layer(window);
    GRect bounds = layer_get_bounds(window_layer);

    image_layer = bitmap_layer_create(bounds);
    bitmap_layer_set_alignment(image_layer, GAlignTop);
	#ifdef PBL_COLOR
	    bitmap_layer_set_background_color(image_layer, TRMainColor);
    #else
    	bitmap_layer_set_background_color(image_layer, GColorBlack);
    #endif

	// display initial app graphic
	#ifdef PBL_COLOR
		image = gbitmap_create_with_resource(RESOURCE_ID_INIT_B);
	#else
		image = gbitmap_create_with_resource(RESOURCE_ID_INIT_A);
	#endif
	bitmap_layer_set_bitmap(image_layer, image);
	layer_add_child(window_layer, bitmap_layer_get_layer(image_layer));

    message_text_layer = text_layer_create(GRect(0, bounds.size.h - 160, bounds.size.w, bounds.size.h));
    text_layer_set_text(message_text_layer, "Loading...");
    text_layer_set_font(message_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
    text_layer_set_text_alignment(message_text_layer, GTextAlignmentCenter);
	text_layer_set_overflow_mode(message_text_layer, GTextOverflowModeWordWrap);
    #ifdef PBL_COLOR
        text_layer_set_text_color(message_text_layer, GColorBlack);
    #else
        text_layer_set_text_color(message_text_layer, GColorWhite);
    #endif
    text_layer_set_background_color(message_text_layer, GColorClear);
    layer_add_child(window_layer, text_layer_get_layer(message_text_layer));

    error_text_layer = text_layer_create(GRect(0, bounds.size.h - 148, bounds.size.w, 80));
    text_layer_set_text(error_text_layer, "");
    text_layer_set_font(error_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
    text_layer_set_text_alignment(error_text_layer, GTextAlignmentCenter);
    text_layer_set_text_color(error_text_layer, GColorWhite);
    text_layer_set_background_color(error_text_layer, GColorClear);
    layer_add_child(window_layer, text_layer_get_layer(error_text_layer));

    username_text_layer = text_layer_create(GRect(0, bounds.size.h - 25, bounds.size.w, 25));
    text_layer_set_text(username_text_layer, "");
    text_layer_set_font(username_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
    text_layer_set_text_alignment(username_text_layer, GTextAlignmentLeft);
	text_layer_set_background_color(username_text_layer, GColorClear);
	#ifdef PBL_COLOR
	    text_layer_set_text_color(username_text_layer, TRAltColor);
    #else
    	text_layer_set_text_color(username_text_layer, GColorBlack);
    #endif
    layer_add_child(window_layer, text_layer_get_layer(username_text_layer));
}
Ejemplo n.º 14
0
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
//   const int text_height = 20;
//   const GEdgeInsets text_insets = GEdgeInsets((bounds.size.h - text_height) / 2, 0);
  s_output_layer = text_layer_create(GRect(5, 0, bounds.size.w - 5, bounds.size.h));
  text_layer_set_overflow_mode(s_output_layer, GTextOverflowModeWordWrap);
  text_layer_set_text_alignment(s_output_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_output_layer));
}
Ejemplo n.º 15
0
static TextLayer* init_text_layer(GRect location, GColor colour, GColor background, const char *res_id, GTextAlignment alignment)
{
	TextLayer *layer = text_layer_create(location);
	text_layer_set_text_color(layer, colour);
	text_layer_set_background_color(layer, background);
	text_layer_set_font(layer, fonts_get_system_font(res_id));
  text_layer_set_overflow_mode(layer, GTextOverflowModeWordWrap);
	text_layer_set_text_alignment(layer, alignment);
	return layer;
}
Ejemplo n.º 16
0
static void init_clock(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  time_layer = text_layer_create(GRect(0, 30, bounds.size.w, bounds.size.h-100));
  text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
  text_layer_set_text_color(time_layer, GColorWhite);
  text_layer_set_background_color(time_layer, GColorClear);
  text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49));

  time_t now = time(NULL);
  struct tm *current_time = localtime(&now);
  handle_tick(current_time, MINUTE_UNIT);
  tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer));

  temp_layer = text_layer_create(GRect(0, 130, (bounds.size.w/2), bounds.size.h-130));
  text_layer_set_text_color(temp_layer, GColorBlack);
  text_layer_set_text_alignment(temp_layer, GTextAlignmentCenter);
  text_layer_set_background_color(temp_layer, GColorWhite);
  text_layer_set_overflow_mode(temp_layer, GTextOverflowModeFill);
  text_layer_set_font(temp_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(temp_layer));

  aqi_value_layer = text_layer_create(GRect(bounds.size.w/2, 130, (bounds.size.w/2), bounds.size.h-130));
  text_layer_set_text_color(aqi_value_layer, GColorBlack);
  text_layer_set_text_alignment(aqi_value_layer, GTextAlignmentCenter);
  text_layer_set_background_color(aqi_value_layer, GColorWhite);
  text_layer_set_overflow_mode(aqi_value_layer, GTextOverflowModeFill);
  text_layer_set_font(aqi_value_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  layer_add_child(window_layer, text_layer_get_layer(aqi_value_layer));

  int aqi = persist_exists(AQI) ? persist_read_int(AQI) : -1;
  int temperature = persist_exists(TEMPERATURE) ? persist_read_int(TEMPERATURE) : -1;
  Tuplet initial_values[] = {
     TupletInteger(AQI, aqi),
     TupletInteger(TEMPERATURE, temperature)
  };

  app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values),
      sync_tuple_changed_callback, sync_error_callback, NULL);
}
Ejemplo n.º 17
0
void chrono_digital_window_load_handler(struct Window *window) {
  app_log(APP_LOG_LEVEL_INFO, __FILE__, __LINE__, "chrono digital loads");

  GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);

  Layer *chrono_digital_window_layer = window_get_root_layer(chrono_digital_window);

  chrono_digital_current_layer = text_layer_create(GRect(25, 120, 94, 48));
  if (chrono_digital_current_layer == NULL) {
    trigger_memory_panic(__LINE__);
    return;
  }    
  int i;
  for (i = 0; i < CHRONO_MAX_LAPS; ++i) {
    chrono_digital_laps_layer[i] = text_layer_create(GRect(25, 30 * i, 94, 30));
    if (chrono_digital_laps_layer[i] == NULL) {
      trigger_memory_panic(__LINE__);
      return;
    }    

    text_layer_set_text(chrono_digital_laps_layer[i], chrono_laps_buffer[i]);
    text_layer_set_text_color(chrono_digital_laps_layer[i], GColorBlack);
    text_layer_set_text_alignment(chrono_digital_laps_layer[i], GTextAlignmentRight);
    text_layer_set_overflow_mode(chrono_digital_laps_layer[i], GTextOverflowModeFill);
    text_layer_set_font(chrono_digital_laps_layer[i], font);
    layer_add_child(chrono_digital_window_layer, (Layer *)chrono_digital_laps_layer[i]);
  }

  text_layer_set_text(chrono_digital_current_layer, chrono_current_buffer);
  text_layer_set_text_color(chrono_digital_current_layer, GColorBlack);
  text_layer_set_text_alignment(chrono_digital_current_layer, GTextAlignmentRight);
  text_layer_set_overflow_mode(chrono_digital_current_layer, GTextOverflowModeFill);
  text_layer_set_font(chrono_digital_current_layer, font);
  layer_add_child(chrono_digital_window_layer, (Layer *)chrono_digital_current_layer);

  chrono_digital_line_layer = inverter_layer_create(GRect(0, 121, SCREEN_WIDTH, 1));
  if (chrono_digital_line_layer == NULL) {
    trigger_memory_panic(__LINE__);
    return;
  }    
  layer_add_child(chrono_digital_window_layer, (Layer *)chrono_digital_line_layer);
}
Ejemplo n.º 18
0
static void main_window_load ( Window *window )
{
  Layer *window_layer = window_get_root_layer( window );
  GRect window_bounds = layer_get_bounds( window_layer );

  s_output_layer = text_layer_create( GRect( 5, 0, window_bounds.size.w - 10, window_bounds.size.h ) );
  text_layer_set_font( s_output_layer, fonts_get_system_font( FONT_KEY_GOTHIC_24 ) );
  text_layer_set_text( s_output_layer, "No data yet." );
  text_layer_set_overflow_mode( s_output_layer, GTextOverflowModeWordWrap );
  layer_add_child( window_layer, text_layer_get_layer( s_output_layer ) );
}
Ejemplo n.º 19
0
static void alert_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect window_bounds = layer_get_bounds(window_layer);

  // Create output TextLayer
  s_alert_text_layer = text_layer_create(GRect(5, 0, window_bounds.size.w - 5, window_bounds.size.h));
  text_layer_set_font(s_alert_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text(s_alert_text_layer, BANNER_TEXT);
  text_layer_set_overflow_mode(s_alert_text_layer, GTextOverflowModeWordWrap);
  layer_add_child(window_layer, text_layer_get_layer(s_alert_text_layer));
}
Ejemplo n.º 20
0
static void text_layer_setup(Window *window, TextLayer *text_layer){
  text_layer_set_background_color(text_layer, GColorBlack);
  text_layer_set_text_color(text_layer, GColorWhite);
 
  // Improve the layout to me more like a watchface
  text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
  text_layer_set_overflow_mode(text_layer, GTextOverflowModeWordWrap);
  
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layer));
}
Ejemplo n.º 21
0
NotifLayer* notif_layer_create() {
  NotifLayer *this = (NotifLayer*)malloc(sizeof(NotifLayer));
  this->bg_layer = layer_create(GRect(0, -NOTIF_LAYER_DEFAULT_HEIGHT, 144, NOTIF_LAYER_DEFAULT_HEIGHT));
  layer_set_update_proc(this->bg_layer, update_proc);
  this->content_layer = text_layer_create(GRect(0, -NOTIF_LAYER_DEFAULT_HEIGHT, 144, NOTIF_LAYER_DEFAULT_HEIGHT));
  text_layer_set_text_color(this->content_layer, GColorWhite);
  text_layer_set_background_color(this->content_layer, GColorClear);
  text_layer_set_overflow_mode(this->content_layer, GTextOverflowModeWordWrap);
  this->visible = false;

  return this;
}
Ejemplo n.º 22
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect window_bounds = layer_get_bounds(window_layer);

  // Allocate background
  if(s_bg_bitmap) {
    gbitmap_destroy(s_bg_bitmap);
  }
  s_bg_bitmap = gbitmap_create_with_resource(s_background_res_id);

  // BG Layer
  s_bg_layer = bitmap_layer_create(GRect(0, 0, window_bounds.size.w, window_bounds.size.h));
  bitmap_layer_set_bitmap(s_bg_layer, s_bg_bitmap);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_bg_layer));

  // Title
  s_title_layer = text_layer_create(GRect(10, 40, window_bounds.size.w - 20, 60));
  text_layer_set_text_color(s_title_layer, s_title_color);
  text_layer_set_background_color(s_title_layer, GColorClear);
  text_layer_set_text_alignment(s_title_layer, GTextAlignmentCenter);
  text_layer_set_overflow_mode(s_title_layer, GTextOverflowModeWordWrap);
  text_layer_set_font(s_title_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text(s_title_layer, s_title_buffer);
  layer_add_child(window_layer, text_layer_get_layer(s_title_layer));

  // UP TextLayer
  s_up_layer = text_layer_create(GRect(0, 20, window_bounds.size.w, 30));
  text_layer_set_text_color(s_up_layer, s_title_color);
  text_layer_set_background_color(s_up_layer, GColorClear);
  text_layer_set_text_alignment(s_up_layer, GTextAlignmentRight);
  text_layer_set_font(s_up_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_text(s_up_layer, "LIGHT >");
  layer_add_child(window_layer, text_layer_get_layer(s_up_layer));

  // SELECT TextLayer
  s_select_layer = text_layer_create(GRect(0, 90, window_bounds.size.w, 30));
  text_layer_set_text_color(s_select_layer, s_title_color);
  text_layer_set_background_color(s_select_layer, GColorClear);
  text_layer_set_text_alignment(s_select_layer, GTextAlignmentRight);
  text_layer_set_font(s_select_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_text(s_select_layer, s_select_buffer);
  layer_add_child(window_layer, text_layer_get_layer(s_select_layer));

  // DOWN TextLayer
  s_down_layer = text_layer_create(GRect(0, 130, window_bounds.size.w, 30));
  text_layer_set_text_color(s_down_layer, s_title_color);
  text_layer_set_background_color(s_down_layer, GColorClear);
  text_layer_set_text_alignment(s_down_layer, GTextAlignmentRight);
  text_layer_set_font(s_down_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_text(s_down_layer, s_down_buffer);
  layer_add_child(window_layer, text_layer_get_layer(s_down_layer));
}
Ejemplo n.º 23
0
void details_init(void) {
	details_window = window_create();

	Layer *window_layer = window_get_root_layer(details_window);
	GRect bounds = layer_get_frame(window_layer);

	name_text_layer = text_layer_create(GRect(0, 0, bounds.size.w, 35));
	text_layer_set_text_alignment(name_text_layer, GTextAlignmentCenter);
	text_layer_set_overflow_mode(name_text_layer, GTextOverflowModeTrailingEllipsis);
	text_layer_set_font(name_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
	text_layer_set_text(name_text_layer, "Loading...");
	layer_add_child(window_layer, text_layer_get_layer(name_text_layer));

	status_icon_layer = bitmap_layer_create(GRect(0, 40, bounds.size.w, 75));
	layer_add_child(window_layer, bitmap_layer_get_layer(status_icon_layer));

	uptime_text_layer = text_layer_create(GRect(0,120, bounds.size.w, 35));
	text_layer_set_text_alignment(uptime_text_layer, GTextAlignmentCenter);
	text_layer_set_overflow_mode(uptime_text_layer, GTextOverflowModeTrailingEllipsis);
	text_layer_set_font(uptime_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
	layer_add_child(window_layer, text_layer_get_layer(uptime_text_layer));
}
Ejemplo n.º 24
0
static void tracking_window_load(Window *window) {
  repCount = 0;  
  Layer *window_layer = window_get_root_layer(window);
  GRect window_bounds = layer_get_bounds(window_layer);
  
  // Create output TextLayer
  s_tracking_layer = text_layer_create(GRect(5, 0, 139, 100));
  s_reps_layer = text_layer_create(GRect(5, 115, 139, 50));

  text_layer_set_font(s_tracking_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_font(s_reps_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));

  text_layer_set_text(s_tracking_layer, "No data yet.");
  text_layer_set_text(s_reps_layer, "Reps:");
  
  text_layer_set_overflow_mode(s_tracking_layer, GTextOverflowModeWordWrap);
  text_layer_set_overflow_mode(s_reps_layer, GTextOverflowModeWordWrap);
  
  layer_add_child(window_layer, text_layer_get_layer(s_tracking_layer));
  layer_add_child(window_layer, text_layer_get_layer(s_reps_layer));
  
}
Ejemplo n.º 25
0
Layer* maketext(TextLayer **tl, const char* text, Layer *parent,
                int x, int y, int w, int h, const char* font, GColor fg, GColor bg) {
  
  *tl = text_layer_create(GRect(x, y, w, h));
  text_layer_set_font(*tl, fonts_get_system_font(font));
  text_layer_set_text_color(*tl, fg);
  text_layer_set_background_color(*tl, bg);
  text_layer_set_text(*tl, text);
  text_layer_set_overflow_mode(*tl, GTextOverflowModeWordWrap);
  text_layer_set_text_alignment(*tl, GTextAlignmentCenter);
  Layer *result = text_layer_get_layer(*tl);
  layer_add_child(parent, result);
  return result;
}
StatusBarElement* status_bar_element_create(Layer *parent) {
  GRect bounds = element_get_bounds(parent);

  int sm_text_margin = 2;
  FontChoice font = get_font(FONT_18_BOLD);

  int text_y, height;
  if (bounds.size.h <= font.height + font.padding_top + font.padding_bottom) {
    // vertically center text if there is only room for one line
    text_y = (bounds.size.h - font.height) / 2 - font.padding_top;
    height = font.height + font.padding_top + font.padding_bottom;
  } else {
    // otherwise take up all the space, with half the default padding
    text_y = -1 * font.padding_top / 2;
    height = bounds.size.h - text_y;
  }

  TextLayer *text = text_layer_create(GRect(
    sm_text_margin,
    text_y,
    bounds.size.w - sm_text_margin,
    height
  ));
  text_layer_set_text_alignment(text, GTextAlignmentLeft);
  text_layer_set_background_color(text, GColorClear);
  text_layer_set_text_color(text, element_fg(parent));

  text_layer_set_font(text, fonts_get_system_font(font.key));
  text_layer_set_overflow_mode(text, GTextOverflowModeWordWrap);
  layer_add_child(parent, text_layer_get_layer(text));

  BatteryComponent *battery = NULL;
  if (get_prefs()->battery_loc == BATTERY_LOC_STATUS_RIGHT) {
    // align the battery to the middle of the lowest line of text
    int lines = (bounds.size.h - text_y) / (font.height + font.padding_top);
    int battery_y = text_y + (font.height + font.padding_top) * (lines - 1) + font.padding_top + font.height / 2 - battery_component_height() / 2;
    // ...unless that places it too close to the bottom
    if (battery_y + battery_component_height() - battery_component_vertical_padding() > bounds.size.h - sm_text_margin) {
      battery_y = bounds.size.h - battery_component_height() + battery_component_vertical_padding() - sm_text_margin;
    }

    battery = battery_component_create(parent, bounds.size.w - battery_component_width() - sm_text_margin, battery_y, true);
  }

  StatusBarElement *el = malloc(sizeof(StatusBarElement));
  el->text = text;
  el->battery = battery;
  return el;
}
Ejemplo n.º 27
0
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  //*********************************************************************************
   GRect bounds = layer_get_bounds(window_layer);

  // We do this to account for the offset due to the status bar
  // at the top of the app window.

  GPoint center = grect_center_point(&bounds);
  GSize image_size = gbitmap_get_bounds(back_icon).size;
  
    //GRect image_frame = GRect(center.x-8, center.y-10, image_size.w, image_size.h);
  //image_frame.origin.x -= image_size.w / 2;
  //image_frame.origin.y -= image_size.h / 2;
  
  GRect image_frame = GRect(center.x-14, center.y-10, image_size.w, image_size.h);
  image_frame.origin.x -= image_size.w / 2;
  image_frame.origin.y -= image_size.h / 2;
    
  // Use GCompOpClear to display the black portions of the image
  s_black_layer = bitmap_layer_create(image_frame);
  bitmap_layer_set_bitmap(s_black_layer, back_icon);
  bitmap_layer_set_compositing_mode(s_black_layer, GCompOpSet);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_black_layer));
  //**************************************************************************************************
  
  // Create ActionBar
  // Initialize the action bar:
  s_action_bar_layer = action_bar_layer_create();
  // Associate the action bar with the window:
  action_bar_layer_add_to_window(s_action_bar_layer, window);
  // Set the click config provider:
  action_bar_layer_set_click_config_provider(s_action_bar_layer, config_provider);
  // Set the icons:
  // The loading the icons is omitted for brevity... See HeapBitmap.
  action_bar_layer_set_icon(s_action_bar_layer, BUTTON_ID_UP, my_icon_location);
  action_bar_layer_set_icon(s_action_bar_layer, BUTTON_ID_DOWN, my_icon_stop);
  
    
  // Create output TextLayer
  s_output_layer = text_layer_create(GRect(5, 135, 105, 25));
  //text_layer_set_font(s_output_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text(s_output_layer, " Save pos");
  text_layer_set_text_color(s_output_layer,GColorWhite);
  text_layer_set_background_color(s_output_layer,GColorBlack);
  text_layer_set_overflow_mode(s_output_layer, GTextOverflowModeWordWrap);
  layer_add_child(window_layer, text_layer_get_layer(s_output_layer));
  
}
Ejemplo n.º 28
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  s_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_DS_DIGIB_60));

  int top = PBL_IF_ROUND_ELSE(5, -6);
  int left = PBL_IF_ROUND_ELSE(44, 32);
  s_time_layer = text_layer_create(grect_inset(bounds, GEdgeInsets(top, 0, 0, 0)));
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_font(s_time_layer, s_font);
  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));

  top = PBL_IF_ROUND_ELSE(71, 61);
  s_unread_layer = text_layer_create(grect_inset(bounds, GEdgeInsets(top, 0, 0, left)));
  text_layer_set_text_alignment(s_unread_layer, GTextAlignmentLeft);
  text_layer_set_text_color(s_unread_layer, GColorWhite);
  text_layer_set_background_color(s_unread_layer, GColorClear);
  text_layer_set_font(s_unread_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  layer_add_child(window_layer, text_layer_get_layer(s_unread_layer));

  top = PBL_IF_ROUND_ELSE(100, 90);
  int bottom = PBL_IF_ROUND_ELSE(27, 0);
  int right = PBL_IF_ROUND_ELSE(12, 0);
  s_event_layer = text_layer_create(grect_inset(bounds, GEdgeInsets(top, right, bottom, left)));
  text_layer_set_text_alignment(s_event_layer, GTextAlignmentLeft);
  text_layer_set_text_color(s_event_layer, GColorWhite);
  text_layer_set_background_color(s_event_layer, GColorClear);
  text_layer_set_font(s_event_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_overflow_mode(s_event_layer, GTextOverflowModeTrailingEllipsis);
  layer_add_child(window_layer, text_layer_get_layer(s_event_layer));

  s_icons_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICONS);
  GSize icons_size = gbitmap_get_bounds(s_icons_bitmap).size;

  top = PBL_IF_ROUND_ELSE(78, 68);
  left = PBL_IF_ROUND_ELSE(14, 3);
  bottom = bounds.size.h - top - icons_size.h;
  right = bounds.size.w - left - icons_size.w;
  s_icons_layer = bitmap_layer_create(grect_inset(bounds, GEdgeInsets(top, right, bottom, left)));
  bitmap_layer_set_compositing_mode(s_icons_layer, GCompOpSet);
  bitmap_layer_set_bitmap(s_icons_layer, s_icons_bitmap);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_icons_layer));
}
Ejemplo n.º 29
0
void window_load(Window *window)
{
  Layer *window_layer = window_get_root_layer(window);

  text_layer_1 = text_layer_create(GRect(0, 0, 104, 30));
  text_layer_set_text_color(text_layer_1, GColorBlack);
  text_layer_set_background_color(text_layer_1, GColorWhite);
  text_layer_set_font(text_layer_1, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  layer_add_child(window_layer, text_layer_get_layer(text_layer_1));

  s_action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(s_action_bar, window);
  action_bar_layer_set_click_config_provider(s_action_bar, click_config_provider);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_icon_reset);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_play);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_icon_calib);
  
  text_layer_2 = text_layer_create(GRect(0, 30, 104, 40));
  text_layer_set_font(text_layer_2, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  layer_add_child(window_layer, text_layer_get_layer(text_layer_2));
  
  text_layer_3 = text_layer_create(GRect(0, 70, 104, 20));
  layer_add_child(window_layer, text_layer_get_layer(text_layer_3));
  text_layer_set_overflow_mode(text_layer_3, GTextOverflowModeWordWrap);
  
  text_layer_4 = text_layer_create(GRect(0, 90, 104, 20));
  layer_add_child(window_layer, text_layer_get_layer(text_layer_4));
  int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT;
  if (calib_stored != 0) {
    text_layer_set_text(text_layer_1, "HELLO,");
    text_layer_set_text(text_layer_2, "DRINK SAFE");
    text_layer_set_text(text_layer_4, "Flick to start");
    display(text_layer_3,"Calib: %d", calib_stored);
  }
  else {
    text_layer_set_text(text_layer_1, "PLEASE");
    text_layer_set_text(text_layer_2, "CALIBRATE");
    text_layer_set_text(text_layer_3, "Press UP button");
    text_layer_set_text(text_layer_4, "to calibrate.");
  }
  accel_data_service_subscribe(1, accel_handler);
  accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);

  accel_tap_service_subscribe(accel_tap_handler);
}
Ejemplo n.º 30
0
static void history_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  history_scroller = scroll_layer_create(bounds);
  scroll_layer_set_click_config_onto_window(history_scroller, window);

  int items = current_history_batch * HISTORY_BATCH_SIZE +
    history[current_history_batch].last_event + 1;
  int width = 142;
  int margin = (bounds.size.w - width)/2;
  GSize max_size = GSize(bounds.size.w, (items + 9) * 19); // font size is 18, 5 newlines before and 4 after
  history_layer = text_layer_create(GRect(margin, 0, width, max_size.h));
  if ((current_history_batch == 0) && (history[0].last_event < 0)) {
    strcpy(history_text, "No history recorded.");
  }
  else {
    // int history_events = current_history_batch * HISTORY_BATCH_SIZE + history[current_history_batch].last_event + 1;
    // APP_LOG(APP_LOG_LEVEL_DEBUG, "%d history events", history_events);
    strcpy(history_text, "\n\n\n\n\n");
    for (int b=current_history_batch; b>=0; b--) {
      // APP_LOG(APP_LOG_LEVEL_DEBUG, "Processing batch %d", b);
      for (int e=history[b].last_event; e>=0; e--) {
        // APP_LOG(APP_LOG_LEVEL_DEBUG, "Feeling %d at %d (%d/%d)", history[b].mood[e], (int) history[b].event_time[e], e, b);
        struct tm *lt = localtime(&history[b].event_time[e]);
        strftime(timestr, sizeof(timestr), "%V %a %k:%M", lt);
        snprintf(event_text, sizeof(event_text), "%s %s\n", timestr, Moods[history[b].mood[e]]);
        strncat(history_text, event_text, sizeof(event_text));
      }
    }
  }
  strncat(history_text, "\n\n\n\n", 5);
  text_layer_set_text(history_layer, history_text);
  text_layer_set_font(history_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_overflow_mode(history_layer, GTextOverflowModeWordWrap);
  text_layer_set_text_color(history_layer, GColorBlack);
  text_layer_set_background_color(history_layer, GColorWhite);
  max_size = text_layer_get_content_size(history_layer);
  max_size.w = bounds.size.w;
  text_layer_set_size(history_layer, max_size);
  scroll_layer_set_content_size(history_scroller, max_size);
  scroll_layer_add_child(history_scroller, text_layer_get_layer(history_layer));
  scroll_layer_set_content_offset(history_scroller, GPoint(0, 40), true);
  layer_add_child(window_layer, scroll_layer_get_layer(history_scroller));
}