// Setup the scroll layer on window load
// We do this here in order to be able to get the max used text size
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(0, 0, bounds.size.w, 2000);

  // Initialize the scroll layer
  scroll_layer = scroll_layer_create(bounds);

  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(scroll_layer, window);

  // Initialize the text layer
  text_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(text_layer, scroll_text);

  // Change the font to a nice readable one
  // This is system font; you can inspect pebble_fonts.h for all system fonts
  // or you can take a look at feature_custom_font to add your own font
  text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));

  // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(text_layer);
  text_layer_set_size(text_layer, max_size);
  scroll_layer_set_content_size(scroll_layer, GSize(bounds.size.w, max_size.h + vert_scroll_text_padding));

  // Add the layers for display
  scroll_layer_add_child(scroll_layer, text_layer_get_layer(text_layer));

  // The inverter layer will highlight some text
  inverter_layer = inverter_layer_create(GRect(0, 28, bounds.size.w, 28));
  scroll_layer_add_child(scroll_layer, inverter_layer_get_layer(inverter_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(scroll_layer));
}
예제 #2
0
void window_load(Window *me) {
	Layer *window_layer = window_get_root_layer(me);
	switch (current_level) {
		case 0:
		case 1:
		if (current_level == 1)
			for (int i = 0; i < item_count; i++)
				memset(item_names[i], 0, TITLE_SIZE);
			menu_layer[current_level] = menu_layer_create(layer_get_bounds(window_layer));
			menu_layer_set_callbacks(menu_layer[current_level], NULL, (MenuLayerCallbacks){
				.get_cell_height = menu_get_cell_height_callback,
				.get_num_rows = menu_get_num_rows_callback,
				.draw_row = menu_draw_row_callback,
				.select_click = menu_select_callback,
			});
			menu_layer_set_click_config_onto_window(menu_layer[current_level], me);
			layer_set_hidden(menu_layer_get_layer(menu_layer[current_level]), true);
			layer_add_child(window_layer, menu_layer_get_layer(menu_layer[current_level]));
			break;
		case 2:
			messageheader_layer = text_layer_create(GRect(0, 0, 144, INT16_MAX));
			messageseparator_layer = inverter_layer_create(GRect(0, 0, 144, INT16_MAX));
			messagetext_layer = text_layer_create(GRect(0, 0, 144, INT16_MAX));
			message_layer = scroll_layer_create(layer_get_bounds(window_layer));
			scroll_layer_add_child(message_layer, text_layer_get_layer(messageheader_layer));
			scroll_layer_add_child(message_layer, inverter_layer_get_layer(messageseparator_layer));
			scroll_layer_add_child(message_layer, text_layer_get_layer(messagetext_layer));
			scroll_layer_set_callbacks(message_layer, (ScrollLayerCallbacks){
				.click_config_provider = message_click_config_provider
			});
예제 #3
0
void storyview_init(char *title, char *summary) {
	window = window_create();

	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_layer);
	GRect max_text_bounds = GRect(2, 0, bounds.size.w - 4, 2000);

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

	title_layer = text_layer_create(max_text_bounds);
	text_layer_set_font(title_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
	text_layer_set_text(title_layer, title);

	GSize title_max_size = text_layer_get_content_size(title_layer);
	text_layer_set_size(title_layer, GSize(title_max_size.w, title_max_size.h + 14));

	summary_layer = text_layer_create(GRect(2, title_max_size.h + 14, max_text_bounds.size.w, max_text_bounds.size.h - (title_max_size.h + 14)));
	text_layer_set_font(summary_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
	text_layer_set_text(summary_layer, summary);

	GSize summary_max_size = text_layer_get_content_size(summary_layer);
	text_layer_set_size(summary_layer, GSize(summary_max_size.w, summary_max_size.h + 14));

	scroll_layer_set_content_size(scroll_layer, GSize(bounds.size.w, title_max_size.h + 14 + summary_max_size.h + 8));

	scroll_layer_add_child(scroll_layer, text_layer_get_layer(title_layer));
	scroll_layer_add_child(scroll_layer, text_layer_get_layer(summary_layer));

	layer_add_child(window_layer, scroll_layer_get_layer(scroll_layer));
}
예제 #4
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));
	}
}
static void window_load(Window *window) {
    Layer *window_layer = window_get_root_layer(window);
    GRect bounds = layer_get_bounds(window_layer);

    s_title_layer = stats_window_common_create_title(bounds,  "SETS DURATION");
    
    s_scroll_layer = scroll_layer_create(bounds);
    scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
    scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, bounds.size.h * 1.7));
    
    scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_title_layer));

    MatchStatistics score_detail= match_statistics_get();

    // score_detail.set_duration[0] = 45* 60;
    // score_detail.set_duration[1] = 53 * 60;
    // score_detail.set_duration[2] = 33 * 60;
    // score_detail.set_duration[3] = 62 * 60;
    // score_detail.set_duration[4] = 39 * 60;    

    int start_from_y =PBL_IF_ROUND_ELSE(40, 30);

    int box_h = 40;
    float every_y = box_h +2;

    for (int i = 0; i < 5; ++i)
    {
        int hours = score_detail.set_duration[i] / 3600;
        int minutes = (score_detail.set_duration[i] / 60) % 60; 
        int seconds = score_detail.set_duration[i] % 60;        
        
        snprintf(buffer_sets_time[i], sizeof(buffer_sets_time[i]), "%.2d:%.2d:%.2d\n", hours, minutes, seconds);
        
        APP_LOG(APP_LOG_LEVEL_DEBUG, "*** window_load  *** set %d lasted %d seconds", 
            i, (int)score_detail.set_duration[i]);

        int padding = PBL_IF_ROUND_ELSE(64, 28);
        int box_x = padding / 2 ;
        int box_w = bounds.size.w - padding;
        s_sets_time_layer[i] = stats_window_common_create_layer(
            GRect(
                box_x, start_from_y + (i * every_y),
                box_w, box_h), 
            buffer_sets_time[i]);

        
        int num_x = PBL_IF_ROUND_ELSE(18, 2);;
        int num_y = start_from_y + (i * every_y) + (box_h / 4);        
        snprintf(buffer_sets_num[i], sizeof(buffer_sets_num[i]), "%d\n", i + 1);
        s_sets_num_layer[i] =create_set_num_layer(GRect(num_x, num_y, 13, 20), buffer_sets_num[i]);

        scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_sets_time_layer[i]));
        scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_sets_num_layer[i]));
        layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));
    }
}
예제 #6
0
// Setup the scroll layer on window load
// We do this here in order to be able to get the max used text size
static void traveltime_details_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(10, 90, bounds.size.w - 20, 60);
  GRect from_text_bounds = GRect(10, 10, bounds.size.w - 20, 30);
  GRect name_text_bounds = GRect(10, 30, bounds.size.w - 20, 40);
  GRect bkg_text_bounds = GRect(0, 70, bounds.size.w, bounds.size.h);
  
  // Initialize the scroll layer
  traveltime_details_scroll_layer = scroll_layer_create(bounds);
  
  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(traveltime_details_scroll_layer, window);
  
  // Initialize the text layers
  traveltime_from_text_layer = text_layer_create(from_text_bounds);
  text_layer_set_text(traveltime_from_text_layer, "Depuis");
  text_layer_set_font(traveltime_from_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  
  traveltime_name_text_layer = text_layer_create(name_text_bounds);
  text_layer_set_text(traveltime_name_text_layer, traveltimes_menu_items[current_traveltime_idx].title);
  text_layer_set_font(traveltime_name_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  
  traveltime_details_text_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(traveltime_details_text_layer, traveltimes_menu_items[current_traveltime_idx].subtitle);
  text_layer_set_font(traveltime_details_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  
  // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(traveltime_details_text_layer);
  //text_layer_set_size(traveltime_details_text_layer, max_size);
  scroll_layer_set_content_size(traveltime_details_scroll_layer, GSize(bounds.size.w, max_size.h + 104));
  
  traveltime_bkg_text_layer = text_layer_create(bkg_text_bounds);
  
#ifdef PBL_COLOR
  text_layer_set_background_color(traveltime_bkg_text_layer, GColorBlack);
  text_layer_set_background_color(traveltime_from_text_layer, GColorIslamicGreen);
  text_layer_set_background_color(traveltime_name_text_layer, GColorIslamicGreen);
  text_layer_set_background_color(traveltime_details_text_layer, GColorBlack);
  text_layer_set_text_color(traveltime_from_text_layer, GColorWhite);
  text_layer_set_text_color(traveltime_name_text_layer, GColorWhite);
  text_layer_set_text_color(traveltime_details_text_layer, GColorYellow);
#endif
  
  // Add the layers for display
  scroll_layer_add_child(traveltime_details_scroll_layer, text_layer_get_layer(traveltime_bkg_text_layer));
  scroll_layer_add_child(traveltime_details_scroll_layer, text_layer_get_layer(traveltime_from_text_layer));
  scroll_layer_add_child(traveltime_details_scroll_layer, text_layer_get_layer(traveltime_name_text_layer));
  scroll_layer_add_child(traveltime_details_scroll_layer, text_layer_get_layer(traveltime_details_text_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(traveltime_details_scroll_layer));
}
예제 #7
0
/**
 * Initializates the GUI Elements
 */
void about_window_load (Window *window) {
	GRect windowBounds = layer_get_frame(ui.windowLayer);
	GRect titleBounds = GRect(0, 0, windowBounds.size.w, 30);
	ui.titleLayer = text_layer_create(titleBounds);
	text_layer_set_text_color(ui.titleLayer, GColorWhite);
	text_layer_set_background_color(ui.titleLayer, GColorBlack);
	text_layer_set_text(ui.titleLayer, "About");
  	text_layer_set_font(ui.titleLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  	text_layer_set_text_alignment(ui.titleLayer, GTextAlignmentCenter);
	layer_add_child(ui.windowLayer, text_layer_get_layer(ui.titleLayer));
	
	// Creates the Scroll
	GRect scrollBounds = GRect(0, 30, windowBounds.size.w, (windowBounds.size.h - 30));
	ui.scroll = scroll_layer_create(scrollBounds);
	scroll_layer_set_click_config_onto_window(ui.scroll, ui.window);
	layer_add_child(ui.windowLayer, scroll_layer_get_layer(ui.scroll));
	
	GRect textBounds = GRect(0, 0, scrollBounds.size.w, 2000);
	ui.textLayer = text_layer_create(textBounds);
	text_layer_set_text_color(ui.textLayer, GColorBlack);
	text_layer_set_background_color(ui.textLayer, GColorClear);
	text_layer_set_text(ui.textLayer, "Developer:\nYago Carballo ([email protected])\n\nGame By...\nameiga 2014\n\n");
  	text_layer_set_font(ui.textLayer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  	text_layer_set_text_alignment(ui.textLayer, GTextAlignmentCenter);
	
	GSize max_size = text_layer_get_content_size(ui.textLayer);
	text_layer_set_size(ui.textLayer, max_size);
	scroll_layer_set_content_size(ui.scroll, GSize(windowBounds.size.w, max_size.h + 5));
	scroll_layer_add_child(ui.scroll, text_layer_get_layer(ui.textLayer));
}
static void typicalIconLayerCreate(uint8_t layerNumber) {
	// A lot is assumed here, could be a source of problems
	s_checkIcons_layers[layerNumber] = bitmap_layer_create(GRect(0, CHECK_ICON_START + PBL_IF_RECT_ELSE(layerNumber, layerNumber + 1) * CHECK_ICON_HEIGHT, CHECK_ICON_HEIGHT, CHECK_ICON_HEIGHT));
	bitmap_layer_set_background_color(s_checkIcons_layers[layerNumber], GColorWhite);
	bitmap_layer_set_alignment(s_checkIcons_layers[layerNumber], GAlignCenter);
	scroll_layer_add_child(s_checklist_scroll, bitmap_layer_get_layer(s_checkIcons_layers[layerNumber]));		// Adds the root layer to the window
}
static void detail_window_load(Window *window)
{
  #ifdef PBL_COLOR
    window_colorize(window);
  #endif

  // set up text layer
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  int16_t content_width = bounds.size.w-10;

  // Initialize the text layers
  GRect max_title_bounds = GRect(5, 0, content_width, 2000);
  s_detail_title_text_layer = detail_text_layer_create(max_title_bounds, s_detail_title, true);
  GSize title_size = text_layer_get_content_size(s_detail_title_text_layer);
  title_size.w = content_width;

  GRect max_text_bounds = GRect(5, title_size.h+2, content_width, 2000);
  s_detail_text_layer = detail_text_layer_create(max_text_bounds, s_detail_text, false);

  // Initialize the scroll layer
  s_detail_scroll_layer = scroll_layer_create(bounds);

  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(s_detail_scroll_layer, window);

  // Add the layers for display

  scroll_layer_add_child(s_detail_scroll_layer, text_layer_get_layer(s_detail_text_layer));
  scroll_layer_add_child(s_detail_scroll_layer, text_layer_get_layer(s_detail_title_text_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(s_detail_scroll_layer));

  // Trim text layer and scroll content to fit text box
  // GSize title_size = text_layer_get_content_size(s_detail_title_text_layer);
  title_size.w = content_width;
  title_size.h += 5;
  GSize text_size = text_layer_get_content_size(s_detail_text_layer);
  text_size.h += title_size.h;
  text_size.w = content_width;

  text_layer_set_size(s_detail_title_text_layer, title_size);
  text_layer_set_size(s_detail_text_layer, text_size);

  scroll_layer_set_content_size(s_detail_scroll_layer, GSize(bounds.size.w, title_size.h + text_size.h));
}
예제 #10
0
ScrollTextLayer* scroll_text_layer_create(GRect rect) {
  ScrollTextLayer* stl = malloc(sizeof(ScrollTextLayer));
  stl->scroll_layer = scroll_layer_create(rect);
  GRect max_text_bounds = GRect(PADDING_X, PADDING_Y, rect.size.w - (PADDING_X * 2), MAX_HEIGHT);
  stl->text_layer = text_layer_create(max_text_bounds);
  scroll_layer_add_child(stl->scroll_layer, text_layer_get_layer(stl->text_layer));
  return stl;
}
예제 #11
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
}
예제 #13
0
파일: main.c 프로젝트: SahaSG552/PebbleDicT
static void window_load2(Window *window) {
  Layer *window_layer2 = window_get_root_layer(window);
  GRect bounds2 = layer_get_bounds(window_layer2);
  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(s_scroll_layer, s_def_window);
  layer_add_child(window_layer2, (Layer *)s_scroll_layer);
  
  //s_word_layer = text_layer_create(GRect(5, 5, bounds2.size.w - 10, bounds2.size.h));
  text_layer_set_font(s_word_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_text_color(s_word_layer, GColorWhite);
  text_layer_set_text_alignment(s_word_layer, GTextAlignmentCenter);
  text_layer_set_background_color(s_word_layer, GColorClear);
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_word_layer));
  
  //s_def_layer = text_layer_create(GRect(5, 30, bounds2.size.w - 10, bounds2.size.h));
  text_layer_set_font(s_def_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_text_color(s_def_layer, GColorWhite);
  text_layer_set_text_alignment(s_def_layer, GTextAlignmentCenter);
  text_layer_set_background_color(s_def_layer, GColorClear);
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_def_layer));
}
예제 #14
0
파일: social.c 프로젝트: johnaspr/UbiSwim
static void window_load(Window *window) {

  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  GRect max_text_bounds = GRect(0, 0, bounds.size.w, 2000);

  // Initialize the scroll layer
  s_scroll_layer = scroll_layer_create(GRect(0, 55, bounds.size.w, 98));

  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
  
  // Initialize the social messages scrolling text layer
  s_text_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(s_text_layer, s_scroll_text);
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));

  // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(s_text_layer);
  text_layer_set_size(s_text_layer, max_size);
  scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, max_size.h + 4));

  // Add the layers for display
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_text_layer));
  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));

  // Set the text of the application name layer
  text_layer_app_name = text_layer_create(GRect(0, 0, bounds.size.w, 20));
  text_layer_set_text(text_layer_app_name, "UbiSwim.org");
  text_layer_set_text_alignment(text_layer_app_name, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(text_layer_app_name));

  // Set the text of the social likes layer
  text_layer_likes = text_layer_create(GRect(0, 20, bounds.size.w, 40));
  text_layer_set_font(text_layer_likes, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); 
  text_layer_set_text(text_layer_likes, "Likes:");
  text_layer_set_text_alignment(text_layer_likes, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(text_layer_likes));

  // Set the text of the info layer
  text_layer_msg = text_layer_create(GRect(0, 150, bounds.size.w, 30));
  text_layer_set_text(text_layer_msg, "U:Prev M:Like D:Next");
  text_layer_set_text_alignment(text_layer_msg, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(text_layer_msg));

  // Set the click config provider for the scrolling text layer
  scroll_layer_set_callbacks(s_scroll_layer, (ScrollLayerCallbacks) {
        .click_config_provider = &click_config_provider_updown
      });
예제 #15
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));
}
예제 #16
0
void select_long_click_handler(ClickRecognizerRef recognizer, void *context) {
  //scroll_layer_create(history_scroll, GRect(0, 0, 144, 168));
  history_scroll = scroll_layer_create GRect(0,0,144,168);
  scroll_layer_set_click_config_onto_window(history_scroll, my_window);
  history_text = text_layer_create(GRect(0, 0, WIDTH, MAX_HEIGHT));
  sugar_data_retrieve(size);
  text_layer_set_background_color(history_text, GColorClear);
  text_layer_set_text_color(history_text, GColorBlack);
  text_layer_set_text_alignment(history_text, GTextAlignmentLeft);
  scroll_layer_set_click_config_onto_window(history_scroll, my_window);
  
  
  scroll_layer_add_child(history_scroll, text_layer_get_layer(history_text));
  layer_add_child(window_get_root_layer(my_window), scroll_layer_get_layer(history_scroll));
}
예제 #17
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));
}
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);
}
예제 #19
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  GRect max_text_bounds = GRect(0, 0, bounds.size.w, 2000);

  // Initialize the scroll layer
  s_scroll_layer = scroll_layer_create(bounds);

  // This binds the scroll layer to the window so that up and down map to scrolling
  // You may use scroll_layer_set_callbacks to add or override interactivity
  scroll_layer_set_click_config_onto_window(s_scroll_layer, window);

  // Initialize the text layer
  s_text_layer = text_layer_create(max_text_bounds);
  text_layer_set_text(s_text_layer, s_scroll_text);

  // Change the font to a nice readable one
  // This is system font; you can inspect pebble_fonts.h for all system fonts
  // or you can take a look at feature_custom_font to add your own font
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_background_color(s_text_layer, GColorClear);

#if defined(PBL_PLATFORM_APLITE)
  text_layer_set_text_color(s_text_layer, GColorBlack);
#else
  text_layer_set_text_color(s_text_layer, GColorWhite);
#endif

  // Trim text layer and scroll content to fit text box
  GSize max_size = text_layer_get_content_size(s_text_layer);
  text_layer_set_size(s_text_layer, max_size);
  scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, max_size.h + 4));

  // Add the layers for display
  scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_text_layer));

  layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));
 
}
예제 #20
0
void note_init(){
  GRect windowBounds = GRect(0, 0, 144, 168);

  fullWindow = window_create();
  Layer* topLayer = window_get_root_layer(fullWindow);
  
  fullNoteText = text_layer_create(windowBounds);
  window_set_background_color(fullWindow, GColorBlue);
  text_layer_set_background_color(fullNoteText, GColorBlue);
  text_layer_set_font(fullNoteText, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
  
  scroller = scroll_layer_create(windowBounds);
  scroll_layer_set_click_config_onto_window(scroller, fullWindow);
  scroll_layer_add_child(scroller, (Layer *) fullNoteText);
  
  for (uint16_t i = 0; i < 3000; i++)
  fullNote[i] = 0;

  layer_add_child(topLayer, (Layer *) scroller);
  
  window_stack_push(fullWindow, true /* Animated */);
}
예제 #21
0
void instruction_window_load(Window *window) {
  // set size variables for instructions
  short size = get_instruction_size(instruction_type);
  short height = get_instruction_height(instruction_type);
  ResHandle rh = get_resource_handle(instruction_type);

  // allocate text holder and load resource
  instruction_text_ptr = malloc(size*sizeof(char));
  reset_text();
  resource_load(rh, (uint8_t *)instruction_text_ptr, size*sizeof(char));

  // get bounds of the window and set bounds of text
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  GRect text_bounds = GRect(0, 0, bounds.size.w, height);

  // create layers
  s_instruction_scroll_layer = scroll_layer_create(bounds);
  s_instruction_text_layer = text_layer_create(text_bounds);

  // setup scroll view
  scroll_layer_set_content_size(s_instruction_scroll_layer, GSize(SCROLL_WIDTH,height));
  scroll_layer_set_click_config_onto_window(s_instruction_scroll_layer, s_instruction_window);

  // setup text view
  text_layer_set_text(s_instruction_text_layer, instruction_text_ptr);
  text_layer_set_text_alignment(s_instruction_text_layer, GTextAlignmentCenter);
  
  // add children
  layer_add_child(window_get_root_layer(s_instruction_window), scroll_layer_get_layer(s_instruction_scroll_layer));
  scroll_layer_add_child(s_instruction_scroll_layer, text_layer_get_layer(s_instruction_text_layer));

  scroll_layer_set_content_offset(s_instruction_scroll_layer, GPoint(0,0), false);

  // free memory
  free(instruction_text_ptr);
}
예제 #22
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);
}