Exemplo n.º 1
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, BACKGROUND);
  Layer *window_layer = window_get_root_layer(s_window);
  GRect bounds = layer_get_frame(window_layer);

  s_textlayer_1 = text_layer_create(GRect(0, (bounds.size.h - MESSAGE_HEIGHT) / 2, bounds.size.w, MESSAGE_HEIGHT));
  text_layer_set_background_color(s_textlayer_1, GColorClear);
  text_layer_set_text_color(s_textlayer_1, CHARTCOLOR);
  text_layer_set_text(s_textlayer_1, "It is time to measure yourself and record your weight!");
  text_layer_set_text_alignment(s_textlayer_1, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_1, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  layer_add_child(window_layer, (Layer *)s_textlayer_1);

  s_textlayer_2 = text_layer_create(GRect(0, bounds.size.h - INSTRUCTION_HEIGHT, bounds.size.w, INSTRUCTION_HEIGHT));
  text_layer_set_background_color(s_textlayer_2, GColorClear);
  text_layer_set_text_color(s_textlayer_2, FOREGROUND);
  text_layer_set_text(s_textlayer_2, "Push Back button for main window");
  text_layer_set_text_alignment(s_textlayer_2, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_2, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  layer_add_child(window_layer, (Layer *)s_textlayer_2);

#ifdef PBL_ROUND
  text_layer_enable_screen_text_flow_and_paging(s_textlayer_2, 4);
  text_layer_enable_screen_text_flow_and_paging(s_textlayer_1, 4);
#endif
}
Exemplo n.º 2
0
static void allValveSetCallback(Valve_s* valves) {
  static char text[100];
  snprintf(text, sizeof(text), "Fetch done (%d valves)", getValveNumber());
  text_layer_set_text(s_text_layer, text);
  
  s_first_menu_items = (SimpleMenuItem*)malloc(sizeof(SimpleMenuItem) * getValveNumber());
  for(int i=0; i < getValveNumber(); i++){
    char* guid_str = malloc(20);
    snprintf(guid_str, 20, "GUID %d", valves[i].guid);
    s_first_menu_items[i] = (SimpleMenuItem) {
      .title = valves[i].name,
      .subtitle = guid_str,
      .callback = menu_select_callback,
    };
  }

  s_menu_sections[0] = (SimpleMenuSection) {
    .num_items = getValveNumber(),
    .items = s_first_menu_items,
  };

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

  s_simple_menu_layer = simple_menu_layer_create(bounds, s_window, s_menu_sections, NUM_MENU_SECTIONS, NULL);
  
  initActionMenu();
  layer_add_child(window_layer, simple_menu_layer_get_layer(s_simple_menu_layer));
}

static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
	
  // Create a text layer and set the text
	s_text_layer = text_layer_create(bounds);
	text_layer_set_text(s_text_layer, "Fetching valves ...");
  
  // Set the font and text alignment
	text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);

	// Add the text layer to the window
	layer_add_child(window_layer, text_layer_get_layer(s_text_layer));
  
  // Enable text flow and paging on the text layer, with a slight inset of 10, for round screens
  text_layer_enable_screen_text_flow_and_paging(s_text_layer, 10);
  
  setValveSetCompleteCallback(allValveSetCallback);
}
Exemplo n.º 3
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 inset = 8;

  // Create UI
  s_output_layer = text_layer_create(bounds);
  text_layer_set_text(s_output_layer, "Use SELECT to start/stop the background worker.");
  text_layer_set_text_alignment(s_output_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_output_layer));
#ifdef PBL_ROUND
  text_layer_enable_screen_text_flow_and_paging(s_output_layer, inset);
#endif

  s_ticks_layer = text_layer_create(GRect(PBL_IF_RECT_ELSE(5, 0), 135, bounds.size.w, 30));
  text_layer_set_text(s_ticks_layer, "No data yet.");
  text_layer_set_text_alignment(s_ticks_layer, PBL_IF_RECT_ELSE(GTextAlignmentLeft, 
                                                                GTextAlignmentCenter));
  layer_add_child(window_layer, text_layer_get_layer(s_ticks_layer));
#ifdef PBL_ROUND
  text_layer_enable_screen_text_flow_and_paging(s_ticks_layer, inset);
#endif
}
Exemplo n.º 4
0
static TextLayer* make_text_layer(int x_inset, int y_inset, char *font_key) {
  Layer *window_layer = window_get_root_layer(s_window);
  GRect bounds = layer_get_bounds(window_layer);

  TextLayer *this = text_layer_create(grect_inset(bounds,
                                                GEdgeInsets(y_inset, 0, 0, x_inset)));
  text_layer_set_text_alignment(this, GTextAlignmentCenter);
  text_layer_set_text_color(this, GColorWhite);
  text_layer_set_background_color(this, GColorClear);
  text_layer_set_font(this, fonts_get_system_font(font_key));

#if defined(PBL_ROUND)
  text_layer_enable_screen_text_flow_and_paging(this, 5);
#endif

  return this;
}
Exemplo n.º 5
0
static void main_window_load (Window *window)
{
	Layer *window_layer = window_get_root_layer(window);
	
	// Set the lyrics layer setting...
	platformSettings.grect_lyrics_layer = PBL_IF_RECT_ELSE(GRect(0,0,144,65),layer_get_bounds(window_layer));
	
    s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TOP_LOGO);
    s_background_bitmap_dithered = gbitmap_create_with_resource(RESOURCE_ID_TOP_LOGO_DITHER);
	s_background_bitmap_thin = gbitmap_create_with_resource(RESOURCE_ID_THIN_TOP_LOGO);
    s_background_layer = bitmap_layer_create(platformSettings.grect_background_layer);
    layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer));
    
    s_time_layer = text_layer_create(platformSettings.grect_time_layer);
    text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
    text_layer_set_background_color(s_time_layer, GColorClear);
    text_layer_set_font(s_time_layer,fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
    layer_add_child(window_layer,text_layer_get_layer(s_time_layer));
    
    s_date_layer = text_layer_create(platformSettings.grect_date_layer);
    text_layer_set_text_alignment(s_date_layer, PBL_IF_RECT_ELSE(GTextAlignmentRight,GTextAlignmentLeft));
    text_layer_set_background_color(s_date_layer, GColorClear);
    text_layer_set_font(s_date_layer,fonts_get_system_font(FONT_KEY_GOTHIC_18));
    layer_add_child(window_layer,text_layer_get_layer(s_date_layer));
    
    s_dayOfWeek_layer = text_layer_create(platformSettings.grect_dayOfWeek_layer);
    text_layer_set_text_alignment(s_dayOfWeek_layer, PBL_IF_RECT_ELSE(GTextAlignmentRight,GTextAlignmentLeft));
    text_layer_set_background_color(s_dayOfWeek_layer, GColorClear);
    text_layer_set_font(s_dayOfWeek_layer,fonts_get_system_font(FONT_KEY_GOTHIC_18));
    layer_add_child(window_layer,text_layer_get_layer(s_dayOfWeek_layer));

    s_lyrics_layer = text_layer_create(platformSettings.grect_lyrics_layer);
    text_layer_set_font(s_lyrics_layer,fonts_get_system_font(FONT_KEY_GOTHIC_14));
    text_layer_set_background_color(s_lyrics_layer, GColorClear);
    text_layer_set_text_alignment(s_lyrics_layer, GTextAlignmentCenter);
    layer_add_child(window_layer,text_layer_get_layer(s_lyrics_layer));
    text_layer_enable_screen_text_flow_and_paging(s_lyrics_layer, 1);
        
    // Load time when window is loaded
    time_t now = time(NULL); 
    tick_handler(localtime(&now),MINUTE_UNIT | DAY_UNIT);
	
	update_display();
}
Exemplo n.º 6
0
Arquivo: msg.c Projeto: SeaPea/HomeP
static void initialise_ui(void) {
  s_window = window_create();
  Layer *root_layer = window_get_root_layer(s_window);
  GRect bounds = layer_get_bounds(root_layer); 
  window_set_background_color(s_window, COLOR_FALLBACK(GColorBulgarianRose, GColorBlack)); 
  IF_2(window_set_fullscreen(s_window, true));
  
  s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  // msg_layer
  msg_layer = text_layer_create(GRect(6, 12, bounds.size.w-12, bounds.size.h-24));
  text_layer_set_text(msg_layer, "Sent to Phone. Go to the Draw app Settings in the Pebble phone app");
  text_layer_set_text_alignment(msg_layer, GTextAlignmentCenter);
  text_layer_set_font(msg_layer, s_res_gothic_24_bold);
  text_layer_set_text_color(msg_layer, GColorWhite);
  text_layer_set_background_color(msg_layer, GColorClear);
  layer_add_child(root_layer, (Layer *)msg_layer);
#ifdef PBL_ROUND
  text_layer_enable_screen_text_flow_and_paging(msg_layer, 2);
#endif
}
Exemplo n.º 7
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  const GEdgeInsets text_insets = {.top = 10};
  s_text_layer = text_layer_create(grect_inset(bounds, text_insets));
  text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
  text_layer_set_overflow_mode(s_text_layer, GTextOverflowModeWordWrap);
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_text_color(s_text_layer, GColorWhite);
  text_layer_set_background_color(s_text_layer, GColorClear);
  text_layer_set_text(s_text_layer, "See the app logs to check the insert success.\n\n Check the timeline after ~15s to see the pin!");
  layer_add_child(window_layer, text_layer_get_layer(s_text_layer));

#if defined(PBL_ROUND)
  text_layer_enable_screen_text_flow_and_paging(s_text_layer, 3);
#endif
}

static void window_unload(Window *window) {
  text_layer_destroy(s_text_layer);
}
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  s_scroll_layer = scroll_layer_create(bounds);
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

  s_text_layer = text_layer_create(GRect(bounds.origin.x, bounds.origin.y, bounds.size.w, 2000));
  text_layer_set_text(s_text_layer, s_long_text);
  text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_text_layer));

  scroll_layer_set_content_size(s_scroll_layer, text_layer_get_content_size(s_text_layer));

  // Must be after added to the view heirachy
  text_layer_enable_screen_text_flow_and_paging(s_text_layer, 2);

  // Enable ScrollLayer paging
  scroll_layer_set_paging(s_scroll_layer, true);
}
Exemplo n.º 9
0
static void window_appear(Window* window) {

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

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

#ifdef PBL_ROUND
  scroll_layer_set_paging(scroll_layer, true);
#endif

  urlab_logo = gbitmap_create_with_resource(RESOURCE_ID_URLAB_LOGO);
  GRect image_bound = gbitmap_get_bounds(urlab_logo);

  image_layer = bitmap_layer_create(GRect(0, 0, bounds.size.w, image_bound.size.h));
  bitmap_layer_set_bitmap(image_layer, urlab_logo);
  bitmap_layer_set_alignment(image_layer, GAlignCenter);

  scroll_layer_add_child(scroll_layer, bitmap_layer_get_layer(image_layer));

  text_layer = text_layer_create(GRect(0, image_bound.size.h, bounds.size.w , bounds.size.h / 2));
  text_layer_set_text (text_layer, about_text);
  text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
#ifdef PBL_ROUND
  uint8_t inset = 4;
  text_layer_enable_screen_text_flow_and_paging(text_layer, inset);
#endif
  layer_add_child(window_layer, text_layer_get_layer(text_layer));

  scroll_layer_add_child(scroll_layer, text_layer_get_layer(text_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(scroll_layer));

  scroll_layer_set_content_size(scroll_layer, GSize(bounds.size.w, image_bound.size.h + bounds.size.h / 2));
}