Beispiel #1
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
	if (!state.isRunning) {
		state.score = 0;
		
		reset_labels();
		
		layer_set_hidden((Layer*) high_score_label, true);
  		layer_add_child(window_get_root_layer(window), text_layer_get_layer(high_score_label));
  		
		state.timeInterval = 1000;
		state.isRunning = true;
		state.buttonPushed = true;
		state.direction = 0;
    	state.timer = app_timer_register(state.timeInterval, timer_callback, NULL);
    	
    	static char buf[32];
  		snprintf(buf, 32, "Score: %u", state.score);
    	text_layer_set_text(score_label, buf);
  }

}
Beispiel #2
0
void views_init_fitbit_steps_text_layer(Layer *parent_layer) {
  static const int16_t LEFT = 0;
  static const int16_t TOP = 8;
  static const int16_t WIDTH = STEPS_LAYER_WIDTH;
  static const int16_t HEIGHT = STEPS_LAYER_HEIGHT;

  fitbit_steps_text_layer = text_layer_create(GRect(LEFT, TOP, WIDTH, HEIGHT));

  GFont font = fonts_load_custom_font(
    resource_get_handle(RESOURCE_ID_FONT_STEPS_32));

  text_layer_set_text_color(fitbit_steps_text_layer, GColorBlack);
  text_layer_set_text_alignment(fitbit_steps_text_layer, GTextAlignmentCenter);
  text_layer_set_background_color(fitbit_steps_text_layer, GColorWhite);

  text_layer_set_font(fitbit_steps_text_layer, font);

  layer_add_child(parent_layer, text_layer_get_layer(fitbit_steps_text_layer));

  text_layer_set_text(fitbit_steps_text_layer, "...");
}
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  
  app_message_open(inbox_size, outbox_size);
  compass_service_subscribe(compass_heading_handler);

  // We do this to account for the offset due to the status bar
  // at the top of the app window.
  GRect layer_frame_description = layer_get_frame(window_layer);
  layer_frame_description.origin.x = 0;
  layer_frame_description.origin.y = 0;

  // Add some background content to help demonstrate transparency.
  s_text_layer = text_layer_create(layer_frame_description);
  
  text_layer_set_text(s_text_layer, "Point towards\nthe device");
  layer_add_child(window_layer, text_layer_get_layer(s_text_layer));

  s_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_POINT);

  GPoint center = grect_center_point(&bounds);

  GSize image_size = gbitmap_get_bounds(s_bitmap).size;

  GRect image_frame = GRect(center.x, center.y, image_size.w, image_size.h);
  image_frame.origin.x -= image_size.w / 2;
  image_frame.origin.y -= image_size.h / 2 - 30;

  // Use GCompOpOr to display the white portions of the image
  s_layer = bitmap_layer_create(image_frame);
  bitmap_layer_set_bitmap(s_layer, s_bitmap);
  bitmap_layer_set_compositing_mode(s_layer, GCompOpSet);
  
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
	text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_layer));
  
  
}
Beispiel #4
0
static void data_handler(AccelData *data, uint32_t num_samples) {
    if(state == 4){
    if( ((data[0].x + data[1].x)/2 ) > 200){
      movedUp = true;
    }
  
  if(movedUp && ((data[0].x + data[1].x)/2 ) < -200 ){
    if(reps == 0){
      reps = repMax;
      if(sets == 0){
        vibes_double_pulse();
        titleText = text_layer_create(GRect(0, 0, 144, 168));
        text_layer_set_background_color(titleText, GColorClear);
        text_layer_set_text_color(titleText, GColorBlack);
        text_layer_set_font(titleText, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK));
        text_layer_set_text_alignment(titleText, GTextAlignmentCenter);
        layer_add_child(window_get_root_layer(myWindow), text_layer_get_layer(titleText));
        text_layer_set_text(titleText, "Start");
  
        state = 0;
        general_gui_update();
      }
      else {
      sets--;
      //call delay
        
      }
    }
    else {
      reps--;
      if(reps == 0)
        vibes_long_pulse();
      movedUp = false;
      snprintf(repBuffer, sizeof(repBuffer), "Reps%d\n", reps );
      on_play_gui();
    }
  }
}
  
}
Beispiel #5
0
static void update_total(){
  
   //char total_str[15];
  
  char decimal_buffer[5];
  total_amt = (float)dollars + (float)cents/100;
  total_amt_without_tip = total_amt;
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "total amount double: %02u", (int)total_amt);
  // get the total with the tip
  total_amt = total_amt * (1 + (double)tip_percent/100);
  total_amt = total_amt / people;
  
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "total amount with tip: %02u", (int)total_amt);
  int whole_num = (int)total_amt / 1;
  snprintf(buffer, 5, "%d", (int)whole_num);
  strcat(buffer, ".");
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "buffer %s", buffer);
  // take float, multiply by 100 to shift the decimals over two places, and then do a mod 100 to get teh two decimals places
  int decimal_places = (int)(total_amt * 100) % 100;
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "decimal places %u", decimal_places);
  // append the decimals to the buffer
  snprintf(decimal_buffer, 5, "%d", (int)decimal_places);
  //char decimal_buffer[5];
  strcat(buffer, decimal_buffer);
  //APP_LOG(APP_LOG_LEVEL_DEBUG, "final buffer %s", buffer);
  text_layer_set_text(total_layer, buffer);
  // tip amount -- same procedure as above
  tip_amt = total_amt_without_tip * (double)tip_percent/100;
  tip_amt = tip_amt / people;
  int whole_num_tip = (int)tip_amt / 1;
  char tip_decimal_buffer[5];
  snprintf(tip_buffer, 5, "%d", (int)whole_num_tip);
  strcat(tip_buffer,".");
  int tip_decimal_places = (int)(tip_amt * 100) % 100;
  snprintf(tip_decimal_buffer, 5, "%d", (int)tip_decimal_places);
  strcat(tip_buffer, tip_decimal_buffer);
  text_layer_set_text(tip_layer, tip_buffer);


  layer_mark_dirty(text_layer_get_layer(tip_layer));
  layer_mark_dirty(text_layer_get_layer(total_layer));
  layer_mark_dirty(text_layer_get_layer(layer_array[0]));
  layer_mark_dirty(text_layer_get_layer(layer_array[1]));
  layer_mark_dirty(text_layer_get_layer(layer_array[2]));
  layer_mark_dirty(text_layer_get_layer(layer_array[3]));

}
static void main_window_load(Window *window) {
  // Get information about the Window
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);


  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND);
  s_background_layer = bitmap_layer_create(bounds);
  bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);

  // Create the TextLayer with specific bounds
  s_time_layer = text_layer_create(GRect(0, 110, bounds.size.w, 60));
  // Improve the layout to be more like a watchface
  text_layer_set_background_color(s_time_layer, GColorBlack);
  text_layer_set_text_color(s_time_layer, GColorFolly);
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BANGER_60));
  text_layer_set_font(s_time_layer, s_time_font);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);

  layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer));
  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
}
Beispiel #7
0
void handle_init(void) {
	// Create a window and text layer
	window = window_create();
	text_layer = text_layer_create(GRect(0, 0, 144, 154));
	
	// Set the text, font, and text alignment
	text_layer_set_text(text_layer, "Hi, I'm a Pebble!");
	text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);
	
	// Add the text layer to the window
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layer));

	// Push the window
	window_stack_push(window, true);
	
	// App Logging!
	APP_LOG(APP_LOG_LEVEL_DEBUG, "Just pushed a window!");
	
	accel_tap_service_subscribe(accel_tap_handler);

}
Beispiel #8
0
static void main_window_load(Window *window) {

  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_YG);
  s_background_layer = bitmap_layer_create(GRect(0, -5, 144, 180));
  bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer));
  
 
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_yg_42));

  
  s_time_layer = text_layer_create(GRect(23, 19, 100, 200));
  text_layer_set_overflow_mode(s_time_layer, GTextOverflowModeWordWrap);
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorBlack);
  text_layer_set_text(s_time_layer, "00:00");

  text_layer_set_font(s_time_layer, s_time_font);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);

  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));
}
Beispiel #9
0
void hexagon_set_legend(t_hexagon *hexagon, const char *legend_text){
    
    if( !hexagon->text )
        return;
    
    TextLayer *layer;
    layer = text_layer_create(
            GRect(
                0,
                HALF_SQRT_3 * 1.1 * hexagon->side_width, 
                2*hexagon->side_width, 
                HALF_SQRT_3 * 0.9 * hexagon->side_width));
    text_layer_set_background_color(layer, GColorClear);
    text_layer_set_text_color(layer, hexagon_get_border_color(hexagon)); 
    text_layer_set_text(layer, legend_text);

    text_layer_set_font(layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
    text_layer_set_text_alignment(layer, GTextAlignmentCenter);
  //  layer_set_hidden(text_layer_get_layer(layer), true);
    layer_add_child(hexagon->layer, text_layer_get_layer(layer));
    hexagon->legend = layer;
}
Beispiel #10
0
static void webcam_window_load(Window *window) {
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_layer);

	image_layer = bitmap_layer_create(bounds);
	bitmap_layer_set_alignment(image_layer, GAlignCenter);
	layer_add_child(window_layer, bitmap_layer_get_layer(image_layer));

	webcam_status_text_layer = text_layer_create(GRect(0, bounds.size.h - 16, bounds.size.w, 16));
	text_layer_set_text(webcam_status_text_layer, "Please wait...");
	text_layer_set_font(webcam_status_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
	text_layer_set_text_alignment(webcam_status_text_layer, GTextAlignmentCenter);
	text_layer_set_background_color(webcam_status_text_layer, GColorClear);
	layer_add_child(window_layer, text_layer_get_layer(webcam_status_text_layer));


	DictionaryIterator *iter;
	app_message_outbox_begin(&iter);
	dict_write_int(iter, KEY_WEBCAM, &webcam_current_id, sizeof(int), true);
	dict_write_end(iter);
	app_message_outbox_send();  
}
Beispiel #11
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

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

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

static void window_unload(Window *window) {
  text_layer_destroy(s_text_layer);
}
// Handle the start-up of the app
static void init(void) {

  // Create our app's base window
  window = window_create();
  window_stack_push(window, true);
  window_set_background_color(window, GColorBlack);

  // Init the text layer used to show the time
  // TODO: Wrap this boilerplate in a function?
  timeLayer = text_layer_create(GRect(40, 54, 144-40 /* width */, 168-54 /* height */));
  text_layer_set_text_color(timeLayer, GColorWhite);
  text_layer_set_background_color(timeLayer, GColorClear);
  text_layer_set_font(timeLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));

  // Ensures time is displayed immediately (will break if NULL tick event accessed).
  // (This is why it's a good idea to have a separate routine to do the update itself.)
  handle_minute_tick(NULL, 0);

  layer_add_child(window_get_root_layer(window), text_layer_get_layer(timeLayer));

  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
}
StatusBarElement* status_bar_element_create(Layer *parent) {
  GRect bounds = element_get_bounds(parent);

  int sm_text_margin = 2;

  int y, height;
  if (bounds.size.h <= ACTUAL_TEXT_HEIGHT_18 + PADDING_TOP_18 + PADDING_BOTTOM_18) {
    // vertically center text if there is only room for one line
    y = (bounds.size.h - ACTUAL_TEXT_HEIGHT_18) / 2 - PADDING_TOP_18;
    height = ACTUAL_TEXT_HEIGHT_18 + PADDING_TOP_18 + PADDING_BOTTOM_18;
  } else {
    // otherwise take up all the space, with half the default padding
    y = -1 * PADDING_TOP_18 / 2;
    height = bounds.size.h - y;
  }
  TextLayer *text = text_layer_create(GRect(
    sm_text_margin,
    y,
    bounds.size.w - sm_text_margin,
    height
  ));
  text_layer_set_text_alignment(text, GTextAlignmentLeft);
  text_layer_set_background_color(text, GColorClear);
  text_layer_set_text_color(text, element_fg(parent));

  text_layer_set_font(text, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_overflow_mode(text, GTextOverflowModeWordWrap);
  layer_add_child(parent, text_layer_get_layer(text));

  BatteryComponent *battery = NULL;
  if (get_prefs()->battery_loc == BATTERY_LOC_STATUS_RIGHT) {
    battery = battery_component_create(parent, bounds.size.w - battery_component_width() - battery_component_vertical_padding(), (bounds.size.h - battery_component_height()) / 2);
  }

  StatusBarElement *el = malloc(sizeof(StatusBarElement));
  el->text = text;
  el->battery = battery;
  return el;
}
Beispiel #14
0
/************************************ App *************************************/
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  
  s_text_layer = text_layer_create(GRect(0, 0, bounds.size.w - 10, 2000));
  text_layer_set_text_color(s_text_layer, GColorDarkGray);
  
  changeText(0, FONT_KEY_GOTHIC_28_BOLD);
  text_layer_set_text(s_text_layer, wikiData[0]);
  layer_add_child(window_layer, text_layer_get_layer(s_text_layer));
  // if height of quote > height of window, initiate animation to scroll
  GSize text_size = text_layer_get_content_size(s_text_layer);
  number_of_pixels = bounds.size.h - text_size.h;
  printf("bound height: %d\n", bounds.size.h);
  printf("text height: %d\n", text_size.h);
  if (number_of_pixels < 0) {
      printf("%s\n", "ANIMATION FOR DAYS");
      animate_quote(number_of_pixels);
  }
  
  
}
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);
}
Beispiel #16
0
void
proj_stopped_note(struct tm *tick_time, int p) 
{
    int hours, mins, accum;

    accum = proj_time[p] / 60;
    hours = accum / 60;		/* hours */
    mins = (accum - (hours * 60));	/* minutes */
    app_log(APP_LOG_LEVEL_WARNING,
	    __FILE__,
	    __LINE__,
	    "Proj[%d] Stopped: hours = %d, mins = %d",
	    p, hours, mins);

    if (proj_name[p] && *proj_name[p]) {
	snprintf(string, sizeof(string),
		 "%2u:%02u\n"
		 "%s\n"
		 "%s\n"
		 "%2u:%02u",
		 (uint)tick_time->tm_hour, (uint)tick_time->tm_min,
		 proj_name[p],
		 "stopped",
		 (uint)hours, (uint)mins);
    } else {
	snprintf(string, sizeof(string),
		 "%2u:%02u\n"
		 "Proj %u\n"
		 "%s\n"
		 "%2u:%02u",
		 (uint)tick_time->tm_hour, (uint)tick_time->tm_min,
		 (uint)p,
		 "stopped",
		 (uint)hours, (uint)mins);
    }

    text_layer_set_text(text_layer, string);
    layer_mark_dirty(text_layer_get_layer(text_layer));
}
CopyingTextLayer* copying_text_layer_create(GRect frame, const char* text, size_t max) {
  CopyingTextLayer *copying_text_layer = (CopyingTextLayer *) malloc(sizeof(CopyingTextLayer));
  *copying_text_layer = (CopyingTextLayer) {
    .text_layer = text_layer_create(frame),
    .text = copy_string(text, max),
    .max_size = max,
  };

  text_layer_set_text(copying_text_layer->text_layer, copying_text_layer->text);
  text_layer_set_background_color(copying_text_layer->text_layer, GColorClear);
  text_layer_set_text_color(copying_text_layer->text_layer, GColorWhite);

  return copying_text_layer;
}

Layer* copying_text_layer_get_layer(CopyingTextLayer *copying_text_layer) {
  return text_layer_get_layer(copying_text_layer->text_layer);
}

void copying_text_layer_set_overflow(CopyingTextLayer *copying_text_layer, GTextOverflowMode overflow_mode) {
  text_layer_set_overflow_mode(copying_text_layer->text_layer, overflow_mode);
}
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  s_text_layer = text_layer_create(GRect(0, 55, bounds.size.w, 100));
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_LECO_38_BOLD_NUMBERS));
  text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
  text_layer_set_background_color(s_text_layer, GColorClear);

  if (persist_read_int(KEY_BACKGROUND_COLOR)) {
    int background_color = persist_read_int(KEY_BACKGROUND_COLOR);
    set_background_and_text_color(background_color);
  }

  if (persist_read_bool(KEY_TWENTY_FOUR_HOUR_FORMAT)) {
    twenty_four_hour_format = persist_read_bool(KEY_TWENTY_FOUR_HOUR_FORMAT);
  }

  layer_add_child(window_layer, text_layer_get_layer(s_text_layer));

  update_time();
}
Beispiel #19
0
static void
load(Window *window)
{
  Layer *rl = window_get_root_layer(window);
  user_data *ud;
  Layer *l;
  GRect f;
  GSize s;
 
  ud = (user_data*) malloc(sizeof(*ud));
  if (!ud)
    return;
  *ud = (user_data) { .moving = {-1, -1} };
  window_set_user_data(window, ud);
  
  ud->icon = gbitmap_create_with_resource(RESOURCE_ID_MOVE);

  ud->tl = text_layer_create(layer_get_bounds(rl));
  text_layer_set_text(ud->tl, "Use FreeOTP on your mobile device to add tokens.");
  text_layer_set_text_alignment(ud->tl, GTextAlignmentCenter);
  text_layer_set_overflow_mode(ud->tl, GTextOverflowModeWordWrap);
  s = text_layer_get_content_size(ud->tl);
  l = text_layer_get_layer(ud->tl);
  f = layer_get_frame(l);
  f.origin.y = (f.size.h - s.h) / 2;
  f.size.h = s.h;
  layer_set_frame(l, f);
  layer_set_hidden(l, true);
  
  ud->ml = menu_layer_create(layer_get_bounds(rl));
  layer_set_hidden(menu_layer_get_layer(ud->ml), false);
  menu_layer_set_click_config_onto_window(ud->ml, window);
  menu_layer_set_callbacks(ud->ml, ud, (MenuLayerCallbacks) {
    .draw_row = menu_draw_row,
    .get_num_rows = menu_get_num_rows,
    .select_click = menu_select_click,
    .select_long_click = menu_select_long_click,
    .selection_changed = menu_selection_changed
  });
Beispiel #20
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));
 
}
/* ----------------
  window load/unload
---------------- */
static void main_window_load(Window *window) {
  // ウィンドウ情報取得
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  // 現在時刻テキストレイヤー作成
  s_date_layer = text_layer_create(GRect(0, 0, bounds.size.w, 22));
  text_layer_set_background_color(s_date_layer, GColorClear);
  text_layer_set_text_color(      s_date_layer, GColorBlack);
  text_layer_set_font(            s_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  layer_add_child(window_layer, text_layer_get_layer(s_date_layer));

  s_time_layer = text_layer_create(GRect(0, 10, bounds.size.w, 36));
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(      s_time_layer, GColorBlack);
  text_layer_set_font(            s_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));

  // UNIXTIME
  s_unixtime_title_layer = text_layer_create(GRect(0, 40, bounds.size.w, 22));
  text_layer_set_background_color(s_unixtime_title_layer, GColorClear);
  text_layer_set_text_color(      s_unixtime_title_layer, GColorBlack);
  text_layer_set_font(            s_unixtime_title_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  text_layer_set_text(            s_unixtime_title_layer, "UNIXTIME:");
  layer_add_child(window_layer, text_layer_get_layer(s_unixtime_title_layer));

  s_unixtime_layer = text_layer_create(GRect(0, 50, bounds.size.w, 36));
  text_layer_set_background_color(s_unixtime_layer, GColorClear);
  text_layer_set_text_color(      s_unixtime_layer, GColorBlack);
  text_layer_set_font(            s_unixtime_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  layer_add_child(window_layer, text_layer_get_layer(s_unixtime_layer));

  // 歩数
  s_step_title_layer = text_layer_create(GRect(0, 80, bounds.size.w, 22));
  text_layer_set_background_color(s_step_title_layer, GColorClear);
  text_layer_set_text_color(      s_step_title_layer, GColorBlack);
  text_layer_set_font(            s_step_title_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  text_layer_set_text(            s_step_title_layer, "Step Count:");
  layer_add_child(window_layer, text_layer_get_layer(s_step_title_layer));

  s_step_layer = text_layer_create(GRect(0, 90, bounds.size.w, 36));
  text_layer_set_background_color(s_step_layer, GColorClear);
  text_layer_set_text_color(      s_step_layer, GColorBlack);
  text_layer_set_font(            s_step_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  layer_add_child(window_layer, text_layer_get_layer(s_step_layer));
}
Beispiel #22
0
static void window_load(Window *window)
{
    Layer *window_layer = window_get_root_layer(window);
    GRect window_layer_frame = layer_get_frame(window_layer);

    int16_t aThird = window_layer_frame.size.h / 3;

    GRect textFrame;
    textFrame.origin.x = 0;
    textFrame.origin.y = 0;
    textFrame.size.w = window_layer_frame.size.w;
    textFrame.size.h = aThird;

    textFrame.origin.y = aThird;
    statusTextLayer = text_layer_create( textFrame );
    text_layer_set_text(statusTextLayer, STATUS_READY);
    text_layer_set_text_alignment(statusTextLayer, GTextAlignmentLeft);
    text_layer_set_font(statusTextLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
    layer_add_child(window_layer, text_layer_get_layer(statusTextLayer));


    // Initialize the action bar:
    actionBar = action_bar_layer_create();
    // Associate the action bar with the window:
    action_bar_layer_add_to_window(actionBar, window);
    // Set the click config provider:
    action_bar_layer_set_click_config_provider(actionBar, click_config_provider);

    // Set the icons:
    bitmapRing = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_RING_ICON);
    bitmapSilence = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SILENCE_ICON);

    action_bar_layer_set_icon(actionBar, BUTTON_ID_UP, bitmapRing);
    action_bar_layer_set_icon(actionBar, BUTTON_ID_DOWN, bitmapSilence);

    register_callbacks();

}
Beispiel #23
0
void init(void) {
  // Create Window
  s_main_window = window_create();
  #ifdef PBL_COLOR
  window_set_background_color(s_main_window, GColorPictonBlue);
  #else
  window_set_background_color(s_main_window, GColorWhite);
  #endif
  
  // Create text layer
  #if defined(PBL_RECT)
  s_text_layer = text_layer_create(GRect(0, 63, 144, 35));
  #elif defined(PBL_ROUND)
  s_text_layer = text_layer_create(GRect(0, 70, 180, 35));
  #endif
  text_layer_set_background_color(s_text_layer, GColorClear);
  #ifdef PBL_COLOR
  text_layer_set_text_color(s_text_layer, GColorWhite);
  #else
  text_layer_set_text_color(s_text_layer, GColorBlack);
  #endif
  text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
  text_layer_set_font(s_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  text_layer_set_text(s_text_layer, "Connecting");
  layer_add_child(window_get_root_layer(s_main_window), text_layer_get_layer(s_text_layer));
  
  // Show the Window on the watch, with animated=true
  window_stack_push(s_main_window, true);
  
  // Register callbacks
  app_message_register_inbox_received(inbox_received_callback);
  app_message_register_inbox_dropped(inbox_dropped_callback);
  app_message_register_outbox_failed(outbox_failed_callback);
  app_message_register_outbox_sent(outbox_sent_callback);
  
  // Open AppMessage
  app_message_open(200, 0);
}
Beispiel #24
0
static void add_menu_item(int position, GRect bounds){
  
  Layer *window_layer = window_get_root_layer(window);
  temp_layer = text_layer_create(bounds);
  if (position == 0){
     snprintf(dollar_str, sizeof(dollar_str), "Dollars: %u", dollars);
     text_layer_set_text(temp_layer, dollar_str);
  }else if(position == 1){
     snprintf(cents_str, sizeof(cents_str), "Cents: %u", cents);
     text_layer_set_text(temp_layer, cents_str);
  }else if(position == 2){
      snprintf(tip_str, sizeof(tip_str), "Tip: %u ", tip_percent);
      text_layer_set_text(temp_layer, tip_str);
  }else{
      snprintf(people_str, sizeof(people_str), "People: %u", people);
      text_layer_set_text(temp_layer, people_str);
  }
  //text_layer_set_font(temp_layer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
  
   text_layer_set_font(temp_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
    

  
  //text_layer_set_text_alignment(temp_layer, GTextAlignmentCenter);
 
  
  path_layer = layer_create(bounds);
  if(position == layer_count_start){
     layer_set_update_proc(path_layer, path_layer_update_callback);
     //text_layer_set_text_color(temp_layer, GColorWhite);
  }
  layer_add_child(window_layer, text_layer_get_layer(temp_layer));
  layer_add_child(window_layer, path_layer);
  layer_array[position] = temp_layer;
  path_layer_array[position] = path_layer;
  // add this second so font color will appear above it
  
}
Beispiel #25
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);

  icon_layer = bitmap_layer_create(GRect(32, 10, 80, 80));
  layer_add_child(window_layer, bitmap_layer_get_layer(icon_layer));

  temperature_layer = text_layer_create(GRect(0, 100, 144, 144));
  text_layer_set_text_color(temperature_layer, GColorWhite);
  text_layer_set_background_color(temperature_layer, GColorClear); 
  text_layer_set_font(temperature_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_text_alignment(temperature_layer, GTextAlignmentCenter);
  text_layer_set_text(temperature_layer, temperature);

  Tuplet initial_values[] = {
    TupletInteger(WEATHER_ICON_KEY, (uint8_t) 0),
    TupletCString(WEATHER_TEMPERATURE_KEY, "Hello AI :-)"),
    TupletInteger(WATCH_VIBR_KEY, (int8_t) 0),
  };
  app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values),
      sync_tuple_changed_callback, sync_error_callback, NULL);

  layer_add_child(window_layer, text_layer_get_layer(temperature_layer));
}
Beispiel #26
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds        = layer_get_bounds(window_layer);

  s_simple_bg_layer = layer_create(bounds);
  layer_set_update_proc(s_simple_bg_layer, bg_update_proc);
  layer_add_child(window_layer, s_simple_bg_layer);

  s_hands_layer       = layer_create(bounds);
  layer_set_update_proc(s_hands_layer, hands_update_proc);
  layer_add_child(window_layer, s_hands_layer);

  TextLayer *s_trump_layer = text_layer_create(bounds);

  s_trump_layer = text_layer_create(
  GRect(0, PBL_IF_ROUND_ELSE(28, 22), bounds.size.w, 50));
  text_layer_set_background_color(s_trump_layer, GColorClear);
  text_layer_set_text_color(s_trump_layer, GColorWhite);
  text_layer_set_text_alignment(s_trump_layer, GTextAlignmentCenter);
  text_layer_set_text(s_trump_layer, "Trump");

  layer_add_child(window_layer, text_layer_get_layer(s_trump_layer));
}
Beispiel #27
0
void select_click_callback(
    struct MenuLayer *menu_layer,
    MenuIndex *cell_index,
    void *callback_context) {
  // Get the value for this index
  char str_buffer[BUFFER_SIZE];
  read_data_value(keys[cell_index->row], str_buffer);

  text_window = window_create(); // This memory leaks
  text_layer = text_layer_create(GRect(0, 0, 144, 154));

  char value_buffer[BUFFER_SIZE];
  read_data_value(keys[cell_index->row], value_buffer);
  snprintf(buf, 300, "%s", value_buffer);
  text_layer_set_text(text_layer, buf);
  text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_text_alignment(text_layer, GTextAlignmentCenter);

  // Add the text layer to the window
  layer_add_child(window_get_root_layer(text_window), text_layer_get_layer(text_layer));
  window_stack_push(text_window, true);
  light_enable_interaction();
}
Beispiel #28
0
static void main_window_load(Window *window) {
  // Create GBitmap, then set to created BitmapLayer
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_SPARK_ICON);
  s_background_layer = bitmap_layer_create(GRect(0, -6, 144, 180));
  bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer));
  
  // Create time TextLayer
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ATE_BIT_24));

  //time layer
  s_time_layer = text_layer_create(GRect(15, 141, 120, 40));
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_text(s_time_layer, "00:00");

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

  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));
}
static void main_window_load(Window *window) {
    Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer);

    // background image
    background_layer = bitmap_layer_create(layer_get_bounds(window_layer));
    background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND);
    bitmap_layer_set_bitmap(background_layer, background_bitmap);
#ifdef PBL_PLATFORM_APLITE
    bitmap_layer_set_compositing_mode(background_layer, GCompOpAssign);
#elif PBL_PLATFORM_BASALT
    bitmap_layer_set_compositing_mode(background_layer, GCompOpSet);
    layer_add_child(window_layer, bitmap_layer_get_layer(background_layer));
#endif
    
    // info text
    info_layer = text_layer_create(GRect(0, 0, bounds.size.w, 30));
    text_layer_set_text(info_layer, "GESTURES ON");
    text_layer_set_font(info_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
    text_layer_set_text_alignment(info_layer, GTextAlignmentCenter);
    layer_add_child(window_layer, text_layer_get_layer(info_layer));

    launch_background_worker();
}
Beispiel #30
0
void goal_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  window_set_background_color(window, GColorSpringBud);

  s_goal_icon = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_TROPHY);
  GRect dimensions = gbitmap_get_bounds(s_goal_icon);
  s_bitmap_layer = bitmap_layer_create(GRect(bounds.size.w/2-dimensions.size.w/2, bounds.size.h/2-dimensions.size.h/2-30, dimensions.size.w, dimensions.size.h));
  bitmap_layer_set_bitmap(s_bitmap_layer, s_goal_icon);
  bitmap_layer_set_compositing_mode(s_bitmap_layer, GCompOpSet);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_bitmap_layer));

  s_goal_text = text_layer_create(GRect(0, bounds.size.h/2+15, bounds.size.w, 60));
  text_layer_set_background_color(s_goal_text, GColorClear);
  text_layer_set_text_color(s_goal_text, GColorBlack);
  text_layer_set_text(s_goal_text, "Daily Step Goal Met!");
  text_layer_set_font(s_goal_text, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text_alignment(s_goal_text, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_goal_text));

  vibes_double_pulse();
  app_timer_register(5000, quitApp, NULL);
}