Beispiel #1
0
void thread_window_load(Window *window)
{
	struct ThreadData *thread = GetSelectedThread();
	
	thread_scroll_layer = scroll_layer_create(window_frame);

	scroll_layer_set_shadow_hidden(thread_scroll_layer, true);
	scroll_layer_set_click_config_onto_window(thread_scroll_layer, window);
	scroll_layer_set_content_size(thread_scroll_layer, GSize(window_frame.size.w, 0));
	scroll_layer_set_content_offset(thread_scroll_layer, GPoint(0, 0), false);

	ScrollLayerCallbacks scrollOverride =
	{
		.click_config_provider = &thread_click_config,
		.content_offset_changed_handler = &thread_offset_changed_handler
	};
	scroll_layer_set_callbacks(thread_scroll_layer, scrollOverride);

	thread_title_layer = layer_create(GRect(0, 0, window_frame.size.w, 22));
	layer_set_update_proc(thread_title_layer, thread_title_layer_update_proc);
	scroll_layer_add_child(thread_scroll_layer, thread_title_layer);

	layer_add_child(window_get_root_layer(window), scroll_layer_get_layer(thread_scroll_layer));

	thread_view_comments_layer = text_layer_create(GRect(0, 0, window_frame.size.w, LOAD_COMMENTS_HEIGHT));
	text_layer_set_text(thread_view_comments_layer, "View Comments");
	text_layer_set_font(thread_view_comments_layer, GetBiggerFont());
	text_layer_set_text_alignment(thread_view_comments_layer, GTextAlignmentCenter);
	scroll_layer_add_child(thread_scroll_layer, text_layer_get_layer(thread_view_comments_layer));

	thread_inverter_hidden = true;
	thread_inverter_layer = inverter_layer_create(GRect(0, 0, window_frame.size.w, LOAD_COMMENTS_HEIGHT));
	layer_set_hidden(inverter_layer_get_layer(thread_inverter_layer), true);
	scroll_layer_add_child(thread_scroll_layer, inverter_layer_get_layer(thread_inverter_layer));

	if(thread->type == 1)
	{
		// we are an image
		thread_body_layer = NULL;

		thread_bitmap_layer = bitmap_layer_create(GRect(0, 22, window_frame.size.w, window_frame.size.h));
		scroll_layer_add_child(thread_scroll_layer, bitmap_layer_get_layer(thread_bitmap_layer));

		scroll_layer_set_content_size(thread_scroll_layer, GSize(window_frame.size.w, 22 + window_frame.size.h + 10));

		thread_update_comments_position();
	}
	else
	{
		//current_thread.image = NULL;
		thread_bitmap_layer = NULL;

		thread_body_layer = text_layer_create(GRect(0, 22, window_frame.size.w, 10000));
		text_layer_set_font(thread_body_layer, GetFont());
		scroll_layer_add_child(thread_scroll_layer, text_layer_get_layer(thread_body_layer));
	}
}
Beispiel #2
0
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);
  scroll_layer_set_shadow_hidden(s_scroll_layer, true);
  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

  // Get the ContentIndicator from the ScrollLayer
  s_indicator = scroll_layer_get_content_indicator(s_scroll_layer);
  
  // Create two Layers to draw the arrows
  s_indicator_up_layer = layer_create(GRect(bounds.origin.x, bounds.origin.y, 
                                      bounds.size.w, STATUS_BAR_LAYER_HEIGHT));
  s_indicator_down_layer = layer_create(GRect(0, bounds.size.h - STATUS_BAR_LAYER_HEIGHT, 
                                        bounds.size.w, STATUS_BAR_LAYER_HEIGHT));
  layer_add_child(window_layer, s_indicator_up_layer);
  layer_add_child(window_layer, s_indicator_down_layer);

  // Configure the properties of each indicator
  const ContentIndicatorConfig up_config = (ContentIndicatorConfig) {
    .layer = s_indicator_up_layer,
    .times_out = false,
    .alignment = GAlignCenter,
    .colors = {
      .foreground = GColorBlack,
      .background = GColorWhite
    }
  };
  content_indicator_configure_direction(s_indicator, ContentIndicatorDirectionUp, 
                                        &up_config);

  const ContentIndicatorConfig down_config = (ContentIndicatorConfig) {
    .layer = s_indicator_down_layer,
    .times_out = false,
    .alignment = GAlignCenter,
    .colors = {
      .foreground = GColorBlack,
      .background = GColorWhite
    }
  };
  content_indicator_configure_direction(s_indicator, ContentIndicatorDirectionDown, 
                                        &down_config);

  s_content_layer = text_layer_create(GRect(bounds.origin.x, bounds.origin.y, bounds.size.w, 2000));
  text_layer_set_text(s_content_layer, s_content);
  text_layer_set_text_alignment(s_content_layer, GTextAlignmentCenter);
  text_layer_set_font(s_content_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_content_layer));

  GSize text_size = text_layer_get_content_size(s_content_layer);
  layer_set_frame(text_layer_get_layer(s_content_layer), 
                  GRect(bounds.origin.x, bounds.origin.y, bounds.size.w, text_size.h));
  scroll_layer_set_content_size(s_scroll_layer, text_size);
}
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);

  s_icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ICONO_PRINCIPAL);
  GRect bitmap_bounds = gbitmap_get_bounds(s_icon_bitmap);


  s_fondo_layer = bitmap_layer_create(GRect(0, 0, 144, 40));
  bitmap_layer_set_background_color(s_fondo_layer, COLOR_CABECERA);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_fondo_layer));



  s_scroll_layer = scroll_layer_create(GRect(10, 10 + bitmap_bounds.size.h + 5, 124, 168 - (10 + bitmap_bounds.size.h + 10)));
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
  
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(0, 0, 120, 2000);
  s_label_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(s_label_layer, i_lineas);
  text_layer_set_text_color(s_label_layer, COLOR_TEXTO_CUERPO);  
  text_layer_set_background_color(s_label_layer, GColorClear);
  if (i_total_lineas> 3)
    text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  else
    text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
    
  //layer_add_child(window_layer, text_layer_get_layer(s_label_layer));
  
  
  
    // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(s_label_layer);
  text_layer_set_size(s_label_layer, max_size);
  scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, max_size.h + 4));
  scroll_layer_set_shadow_hidden(s_scroll_layer, true);
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_label_layer));
  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

  // CAPA DE LA PARADA
  s_titulo_layer = text_layer_create(GRect(38, 0 , 101, 40));
  text_layer_set_text(s_titulo_layer, string_parada);
  text_layer_set_background_color(s_titulo_layer, GColorClear );
  text_layer_set_text_color(s_titulo_layer, COLOR_TEXTO_CABECERA );
  text_layer_set_text_alignment(s_titulo_layer, GTextAlignmentCenter);
  text_layer_set_font(s_titulo_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  layer_add_child(window_layer, text_layer_get_layer(s_titulo_layer));
  // FIN DE CAPA DE LA PARADA
  
  // CAPA DEL ICONO DEL BUS
  s_icon_layer = bitmap_layer_create(GRect(5, 5, bitmap_bounds.size.w, bitmap_bounds.size.h));
  bitmap_layer_set_bitmap(s_icon_layer, s_icon_bitmap);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_icon_layer));
  // FIN DE LA CAPA
}
Beispiel #4
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, true);
  window_set_background_color(s_window, COLOUR_WINDOW);
  
  // s_menu
  s_menu = menu_layer_create(layer_get_bounds(window_get_root_layer(s_window)));
  if(watch_info_get_firmware_version().major >= 3) {
    scroll_layer_set_shadow_hidden(menu_layer_get_scroll_layer(s_menu), true);
  }
#ifdef PBL_SDK_3
  menu_layer_set_highlight_colors(s_menu, COLOUR_MENU_HIGHLIGHT_BACKGROUND, COLOUR_MENU_HIGHLIGHT_FOREGROUND);
  menu_layer_set_normal_colors(s_menu, COLOUR_MENU_BACKGROUND, COLOUR_MENU_FOREGROUND);
#endif
  menu_layer_set_click_config_onto_window(s_menu, s_window);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_menu);
}
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, PBL_IF_ROUND_ELSE(true, false));
  window_set_background_color(s_window, COLOUR_WINDOW);
  
  // s_menu
  s_menu = menu_layer_create(layer_get_bounds(window_get_root_layer(s_window)));
  if(watch_info_get_firmware_version().major >= 3) {
    scroll_layer_set_shadow_hidden(menu_layer_get_scroll_layer(s_menu), true);
  }
  menu_set_colours(s_menu);
#ifdef PBL_ROUND
  menu_layer_set_center_focused(s_menu, true);
#endif
  menu_layer_set_click_config_onto_window(s_menu, s_window);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_menu);
}
Beispiel #6
0
static void nearbyStopsWindow_load(Window *window) {
    Layer *windowLayer = window_get_root_layer(window);
    GRect bounds = layer_get_frame(windowLayer);

    #ifdef PBL_SDK_3
    bounds = GRect(0, 16, 144, 168-16);
    #endif

    s_menuLayer = menu_layer_create(bounds);
    s_scrollLayer = menu_layer_get_scroll_layer(s_menuLayer);
    scroll_layer_set_shadow_hidden(s_scrollLayer, false);

    menu_layer_set_callbacks(s_menuLayer, NULL, (MenuLayerCallbacks) {
        .get_num_sections = menu_get_num_sections_callback,
        .get_num_rows = menu_get_num_rows_callback,
        .get_header_height = menu_get_header_height_callback,
        .draw_header = menu_draw_header_callback,
        .draw_row = menu_draw_row_callback,
        .select_click = menu_select_callback,
        .selection_changed = menu_selection_changed_callback,
    });
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, false);
  window_set_background_color(s_window, COLOUR_WINDOW);
  
  s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  s_res_gothic_24 = fonts_get_system_font(FONT_KEY_GOTHIC_24);
  // s_statusbar
  s_statusbar = text_layer_create(GRect(0, 0, 144, 21));
  text_layer_set_background_color(s_statusbar, COLOUR_HEADER);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_statusbar);
  
  // s_train_number
  s_train_number = text_layer_create(GRect(2, -7, 56, 29));
  text_layer_set_background_color(s_train_number, GColorClear);
  text_layer_set_text_color(s_train_number, COLOUR_HEADER_TEXT);
  text_layer_set_text(s_train_number, "#307");
  text_layer_set_font(s_train_number, s_res_gothic_24_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_train_number);
  
  // s_train_type
  s_train_type = text_layer_create(GRect(62, -7, 80, 28));
  text_layer_set_background_color(s_train_type, GColorClear);
  text_layer_set_text_color(s_train_type, COLOUR_HEADER_TEXT);
  text_layer_set_text(s_train_type, "Something");
  text_layer_set_text_alignment(s_train_type, GTextAlignmentRight);
  text_layer_set_font(s_train_type, s_res_gothic_24);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_train_type);
  
  // s_stop_list
  s_stop_list = menu_layer_create(GRect(0, 21, 144, 131));
  #ifdef PBL_COLOR
  menu_hack_disable_inversion(s_stop_list);
  #endif
  if(watch_info_get_firmware_version().major >= 3) {
    scroll_layer_set_shadow_hidden(menu_layer_get_scroll_layer(s_stop_list), true);
  }
  menu_layer_set_click_config_onto_window(s_stop_list, s_window);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_stop_list);
}
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, false);
  window_set_background_color(s_window, COLOUR_WINDOW);
  
  s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  s_res_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
  // s_inverterlayer_1
  s_inverterlayer_1 = inverter_layer_create(GRect(0, 0, 144, 35));
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_inverterlayer_1);
  
  // s_direction_layer
  s_direction_layer = text_layer_create(GRect(0, 14, 144, 21));
  text_layer_set_background_color(s_direction_layer, COLOUR_HEADER);
  text_layer_set_text_color(s_direction_layer, COLOUR_HEADER_TEXT);
  text_layer_set_text(s_direction_layer, "Southbound");
  text_layer_set_text_alignment(s_direction_layer, GTextAlignmentCenter);
  text_layer_set_font(s_direction_layer, s_res_gothic_18);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_direction_layer);
  
  // s_stop_name_layer
  s_stop_name_layer = text_layer_create(GRect(0, -8, 144, 28));
  text_layer_set_background_color(s_stop_name_layer, COLOUR_HEADER);
  text_layer_set_text_color(s_stop_name_layer, COLOUR_HEADER_TEXT);
  text_layer_set_text(s_stop_name_layer, "Mountain View");
  text_layer_set_text_alignment(s_stop_name_layer, GTextAlignmentCenter);
  text_layer_set_font(s_stop_name_layer, s_res_gothic_24_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_stop_name_layer);
  
  // s_train_menu
  s_train_menu = menu_layer_create(GRect(0, 35, 144, 117));
  #ifdef PBL_COLOR
  menu_hack_disable_inversion(s_train_menu);
  #endif
  if(watch_info_get_firmware_version().major >= 3) {
    scroll_layer_set_shadow_hidden(menu_layer_get_scroll_layer(s_train_menu), true);
  }
  menu_layer_set_click_config_onto_window(s_train_menu, s_window);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_train_menu);
}
Beispiel #9
0
static void main_window_load(Window *window) {

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


  title_layer = text_layer_create(
    GRect(0, 0,window_bounds.size.w, window_bounds.size.h));
  text_layer_set_text_alignment(title_layer, GTextAlignmentCenter);
  text_layer_set_text(title_layer, "FloodWatch");
  text_layer_set_text_color(title_layer, GColorBlack);
  text_layer_set_background_color(title_layer, GColorClear);
  text_layer_set_font(title_layer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
  layer_add_child(window_layer, text_layer_get_layer(title_layer));

  region_layer = text_layer_create(
    GRect(0, 20,window_bounds.size.w, window_bounds.size.h));
  text_layer_set_text_alignment(region_layer, GTextAlignmentCenter);
  text_layer_set_text(region_layer, "Jakarta - Timur");
  text_layer_set_text_color(region_layer, GColorWhite);
  text_layer_set_background_color(region_layer, GColorClear);
  text_layer_set_font(region_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  layer_add_child(window_layer, text_layer_get_layer(region_layer));


  s_scroll_layer = scroll_layer_create(window_bounds);
 scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
 scroll_layer_set_shadow_hidden(s_scroll_layer, true);
 layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

 // Get the ContentIndicator from the ScrollLayer
 s_indicator = scroll_layer_get_content_indicator(s_scroll_layer);

 // Create two Layers to draw the arrows
 s_indicator_up_layer = layer_create(GRect(window_bounds.origin.x, window_bounds.origin.y,
                                     window_bounds.size.w, STATUS_BAR_LAYER_HEIGHT));
 s_indicator_down_layer = layer_create(GRect(0, window_bounds.size.h - STATUS_BAR_LAYER_HEIGHT,
                                       window_bounds.size.w, STATUS_BAR_LAYER_HEIGHT));
 layer_add_child(window_layer, s_indicator_up_layer);
 layer_add_child(window_layer, s_indicator_down_layer);

 // Configure the properties of each indicator
 const ContentIndicatorConfig up_config = (ContentIndicatorConfig) {
   .layer = s_indicator_up_layer,
   .times_out = false,
   .alignment = GAlignCenter,
   .colors = {
     .foreground = GColorBlack,
     .background = GColorLightGray
   }
 };
 content_indicator_configure_direction(s_indicator, ContentIndicatorDirectionUp,
                                       &up_config);

 const ContentIndicatorConfig down_config = (ContentIndicatorConfig) {
   .layer = s_indicator_down_layer,
   .times_out = false,
   .alignment = GAlignCenter,
   .colors = {
     .foreground = GColorBlack,
     .background = GColorLightGray
   }
 };
 content_indicator_configure_direction(s_indicator, ContentIndicatorDirectionDown,
                                       &down_config);

 reports_layer = text_layer_create(GRect(0, 50, window_bounds.size.w, 2000));
 text_layer_set_text(reports_layer, reports);
 text_layer_set_text_alignment(reports_layer, GTextAlignmentCenter);
 text_layer_set_font(reports_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
 text_layer_set_text_color(region_layer, GColorBlack);
 text_layer_set_background_color(region_layer, GColorClear);
 scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(reports_layer));

 GSize text_size = text_layer_get_content_size(reports_layer);
 layer_set_frame(text_layer_get_layer(reports_layer),
                 GRect(0, 50, window_bounds.size.w, text_size.h));
 scroll_layer_set_content_size(s_scroll_layer, text_size);
}