コード例 #1
0
void scroll_text_layer_add_to_window(ScrollTextLayer* layer, Window* window) {
  if (layer == NULL || window == NULL) {
    return;
  }
  scroll_layer_set_click_config_onto_window(layer->scroll_layer, window);
  layer_add_child(window_get_root_layer(window), scroll_layer_get_layer(layer->scroll_layer));
}
コード例 #2
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 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));
}
コード例 #3
0
ファイル: about.c プロジェクト: YagoCarballo/the_stacker
/**
 * 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));
}
コード例 #4
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));
}
コード例 #5
0
void scroll_text_layer_set_text(ScrollTextLayer* layer, char* text) {
  if (NULL == layer) {
    return;
  }
  text_layer_set_size(layer->text_layer, GSize(layer_get_bounds(scroll_layer_get_layer(layer->scroll_layer)).size.w - (PADDING_X * 2), MAX_HEIGHT));
  text_layer_set_text(layer->text_layer, text);
  scroll_text_layer_update(layer);
}
コード例 #6
0
ファイル: ThreadWindow.c プロジェクト: Healdb/Rebble
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));
	}
}
コード例 #7
0
ファイル: pebblerss2.c プロジェクト: SheepWillPrevail/pebble
void setup_message_layer() {
	int header_height = get_header_height();
	int text_height = get_text_height();
	setup_header(header_height);
	layer_set_frame(text_layer_get_layer(messagetext_layer), GRect(0, header_height, 144, text_height));
	scroll_layer_set_content_offset(message_layer, GPoint(0, 0), false);
	scroll_layer_set_content_size(message_layer, GSize(144, header_height + text_height));
	layer_set_hidden(scroll_layer_get_layer(message_layer), false);
}
コード例 #8
0
ファイル: main.c プロジェクト: willyb321/pebble-timetable_c
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);
}
コード例 #9
0
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));
    }
}
コード例 #10
0
void scroll_text_layer_set_text(ScrollTextLayer* layer, char* text) {
  if (layer == NULL) {
    return;
  }
  text_layer_set_text(layer->text_layer, text);
  GSize max_size = text_layer_get_content_size(layer->text_layer);
  text_layer_set_size(layer->text_layer, max_size);
  GRect bounds = layer_get_bounds(scroll_layer_get_layer(layer->scroll_layer));
  scroll_layer_set_content_size(layer->scroll_layer, GSize(bounds.size.w, max_size.h + (PADDING_Y * 3)));
}
コード例 #11
0
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
}
コード例 #12
0
ファイル: temps.c プロジェクト: ghys/PebbleTrafficLux
// 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));
}
コード例 #13
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
      });
コード例 #14
0
ファイル: main.c プロジェクト: stevmoli/Diabetes-Journal
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));
}
コード例 #15
0
ファイル: help.c プロジェクト: GilDev/Smoove
static void windowLoad(Window *window)
{
	Layer *windowLayer = window_get_root_layer(window);
	GRect frame = layer_get_frame(windowLayer);

	#ifdef PBL_PLATFORM_BASALT
	sStatusBar = status_bar_layer_create();
	layer_add_child(windowLayer, status_bar_layer_get_layer(sStatusBar));

	frame.size.h -= STATUS_BAR_LAYER_HEIGHT;
	frame.origin.y += STATUS_BAR_LAYER_HEIGHT;
	#endif

	sScroll = scroll_layer_create(frame);
	layer_add_child(windowLayer, scroll_layer_get_layer(sScroll));
}
コード例 #16
0
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));
}
コード例 #17
0
ファイル: trackmood.c プロジェクト: samuelmr/pebble-trackmood
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));
}
コード例 #18
0
ファイル: about.c プロジェクト: stuntstein/Pebble-rcTimer
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));
 
}
コード例 #19
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);
  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);
}
コード例 #20
0
ファイル: textHandler.c プロジェクト: runnersaw/pebble-chess
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);
}
コード例 #21
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));
}
コード例 #22
0
ファイル: simply_ui.c プロジェクト: cesleem/restful
static void layer_update_callback(Layer *layer, GContext *ctx) {
  SimplyUi *self = *(void **)layer_get_data(layer);

  const GTextAlignment text_align =
      PBL_IF_ROUND_ELSE((self->window.use_action_bar ? GTextAlignmentRight : GTextAlignmentCenter),
                        GTextAlignmentLeft);

  GRect window_frame = {
    .size = layer_get_frame(scroll_layer_get_layer(self->window.scroll_layer)).size,
  };
  GRect frame = window_frame;

  const SimplyStyle *style = self->ui_layer.style;
  GFont title_font = fonts_get_system_font(style->title_font);
  GFont subtitle_font = fonts_get_system_font(style->subtitle_font);
  GFont body_font = self->ui_layer.custom_body_font ?
      self->ui_layer.custom_body_font : fonts_get_system_font(style->body_font);

  const int16_t margin_x = 5;
  const int16_t margin_y = 2;
  const int16_t image_offset_y = 3;

  GRect text_frame = frame;
  text_frame.size.w -= 2 * margin_x;
  text_frame.size.h += 1000;
  GPoint cursor = { margin_x, margin_y };

  if (self->window.use_action_bar) {
    text_frame.size.w -= ACTION_BAR_WIDTH + PBL_IF_ROUND_ELSE(TEXT_FLOW_INSET, 0);
    window_frame.size.w -= ACTION_BAR_WIDTH;
  }

  graphics_context_set_text_color(ctx, GColorBlack);

  const SimplyUiTextfield *title = &self->ui_layer.textfields[UiTitle];
  const SimplyUiTextfield *subtitle = &self->ui_layer.textfields[UiSubtitle];
  const SimplyUiTextfield *body = &self->ui_layer.textfields[UiBody];

  GTextAttributes *title_attributes = graphics_text_attributes_create();
  GTextAttributes *subtitle_attributes = graphics_text_attributes_create();
  GTextAttributes *body_attributes = graphics_text_attributes_create();

  bool has_title = is_string(title->text);
  bool has_subtitle = is_string(subtitle->text);
  bool has_body = is_string(body->text);

  GSize title_size, subtitle_size;
  GPoint title_pos, subtitle_pos, image_pos = GPointZero;
  GRect body_rect;

  SimplyImage *title_icon = simply_res_get_image(
      self->window.simply->res, self->ui_layer.imagefields[UiTitleIcon]);
  SimplyImage *subtitle_icon = simply_res_get_image(
      self->window.simply->res, self->ui_layer.imagefields[UiSubtitleIcon]);
  SimplyImage *body_image = simply_res_get_image(
      self->window.simply->res, self->ui_layer.imagefields[UiBodyImage]);

  GRect title_icon_bounds =
      title_icon ? gbitmap_get_bounds(title_icon->bitmap) : GRectZero;
  GRect subtitle_icon_bounds =
      subtitle_icon ? gbitmap_get_bounds(subtitle_icon->bitmap) : GRectZero;
  GRect body_image_bounds;

  if (has_title) {
    GRect title_frame = { cursor, text_frame.size };
    if (title_icon) {
      title_icon_bounds.origin = title_frame.origin;
      title_icon_bounds.origin.y += image_offset_y;
      PBL_IF_RECT_ELSE({
        title_frame.origin.x += title_icon_bounds.size.w;
        title_frame.size.w -= title_icon_bounds.size.w;
      }, {
        title_frame.origin.y += title_icon_bounds.size.h + style->title_icon_padding;
      });
    }
    PBL_IF_ROUND_ELSE(
        enable_text_flow_and_paging(self, title_attributes, &title_frame), NOOP);
    title_size = graphics_text_layout_get_content_size_with_attributes(
        title->text, title_font, title_frame, GTextOverflowModeWordWrap, text_align,
        title_attributes);
    title_size.w = title_frame.size.w;
    title_pos = title_frame.origin;
    cursor.y = title_frame.origin.y + title_size.h + style->title_padding;
  }
コード例 #23
0
ファイル: pebblerss2.c プロジェクト: SheepWillPrevail/pebble
			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
			});
			scroll_layer_set_click_config_onto_window(message_layer, me);
			layer_set_hidden(scroll_layer_get_layer(message_layer), true);
			layer_add_child(window_layer, scroll_layer_get_layer(message_layer));
			break;
		case 3:
			image_layer = bitmap_layer_create(layer_get_bounds(window_layer));
			bitmap_layer_set_alignment(image_layer, GAlignCenter);
			bitmap_layer_set_background_color(image_layer, GColorClear);
			bitmap_layer_set_bitmap(image_layer, &image);
			layer_set_hidden(bitmap_layer_get_layer(image_layer), true);
			layer_add_child(window_layer, bitmap_layer_get_layer(image_layer));
			window_set_click_config_provider(me, image_click_config_provider);
			break;
		}
	}

void window_unload(Window *me) {
コード例 #24
0
static void scroll_text_layer_update(ScrollTextLayer* layer) {
  GSize max_size = text_layer_get_content_size(layer->text_layer);
  text_layer_set_size(layer->text_layer, max_size);
  GRect bounds = layer_get_bounds(scroll_layer_get_layer(layer->scroll_layer));
  scroll_layer_set_content_size(layer->scroll_layer, GSize(bounds.size.w, max_size.h + (PADDING_Y * 3)));
}
コード例 #25
0
ファイル: Floodwatch.c プロジェクト: hasithaj/Floodwatch
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);
}