static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);

  s_action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(s_action_bar, window);
  action_bar_layer_set_click_config_provider(s_action_bar, click_config_provider);

  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_icon_plus);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_icon_minus);

  int width = layer_get_frame(window_layer).size.w - ACTION_BAR_WIDTH - 3;

  s_header_layer = text_layer_create(GRect(4, 0, width, 60));
  text_layer_set_font(s_header_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_background_color(s_header_layer, GColorClear);
  text_layer_set_text(s_header_layer, "Drink Counter");
  layer_add_child(window_layer, text_layer_get_layer(s_header_layer));

  s_body_layer = text_layer_create(GRect(4, 44, width, 60));
  text_layer_set_font(s_body_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_background_color(s_body_layer, GColorClear);
  layer_add_child(window_layer, text_layer_get_layer(s_body_layer));

  s_label_layer = text_layer_create(GRect(4, 44 + 28, width, 60));
  text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(s_label_layer, GColorClear);
  text_layer_set_text(s_label_layer, "of drinks on the wall");
  layer_add_child(window_layer, text_layer_get_layer(s_label_layer));

  update_text();
}
Пример #2
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, false);
  
  s_res_image_action_increment = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_INCREMENT);
  s_res_image_action_decrement = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_DECREMENT);
  s_res_font_dd_50 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DD_50));
  s_res_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
  // action_bar_layer
  action_bar_layer = action_bar_layer_create();
  action_bar_layer_add_to_window(action_bar_layer, s_window);
  action_bar_layer_set_background_color(action_bar_layer, GColorWhite);
  action_bar_layer_set_icon(action_bar_layer, BUTTON_ID_UP, s_res_image_action_increment);
  action_bar_layer_set_icon(action_bar_layer, BUTTON_ID_DOWN, s_res_image_action_decrement);
  layer_add_child(window_get_root_layer(s_window), (Layer *)action_bar_layer);
  
  // number_text_layer
  number_text_layer = text_layer_create(GRect(6, 39, 116, 50));
  text_layer_set_text(number_text_layer, "0");
  text_layer_set_text_alignment(number_text_layer, GTextAlignmentCenter);
  text_layer_set_font(number_text_layer, s_res_font_dd_50);
  layer_add_child(window_get_root_layer(s_window), (Layer *)number_text_layer);
  
  // title_text_layer
  title_text_layer = text_layer_create(GRect(2, 93, 123, 20));
  text_layer_set_text(title_text_layer, "Text layer");
  text_layer_set_text_alignment(title_text_layer, GTextAlignmentCenter);
  text_layer_set_font(title_text_layer, s_res_gothic_18);
  layer_add_child(window_get_root_layer(s_window), (Layer *)title_text_layer);
}
Пример #3
0
static void initialise_ui(void) {
    s_window = window_create();
    window_set_background_color(s_window, GColorBlack);
    IF_2(window_set_fullscreen(s_window, true));

    s_res_img_upaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_UPACTION);
    s_res_img_nextaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_NEXTACTION);
    s_res_img_downaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_DOWNACTION);
    s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
    s_res_bitham_30_black = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK);
    // action_layer
    action_layer = action_bar_layer_create();
    action_bar_layer_add_to_window(action_layer, s_window);
    action_bar_layer_set_background_color(action_layer, GColorWhite);
    action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_upaction);
    action_bar_layer_set_icon(action_layer, BUTTON_ID_SELECT, s_res_img_nextaction);
    action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_downaction);
    layer_set_frame(action_bar_layer_get_layer(action_layer), GRect(124, 0, 20, 168));
    IF_3(layer_set_bounds(action_bar_layer_get_layer(action_layer), GRect(-5, 0, 30, 168)));
    layer_add_child(window_get_root_layer(s_window), (Layer *)action_layer);

    time_layer = layer_create(GRect(0, 0, 124, 168));
    layer_set_update_proc(time_layer, draw_time);
    layer_add_child(window_get_root_layer(s_window), time_layer);
}
Пример #4
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  uint32_t *layer_data;
  
  Tuple *t = dict_read_first(iterator);
  while(t != NULL) {
    switch(t->key) {
      case MSG_KEY_TITLE: 
        strncpy(s_title, t->value->cstring, sizeof(s_title));
        text_layer_set_text(s_txt_title, s_title);
        break;
      case MSG_KEY_ARTIST: 
        strncpy(s_artist, t->value->cstring, sizeof(s_artist));
        text_layer_set_text(s_txt_artist, s_artist);
        break;
      case MSG_KEY_VOLUME: 
        layer_data = (uint32_t *)layer_get_data(s_lyr_volume);
    	  *layer_data = t->value->int32;
        layer_mark_dirty(s_lyr_volume);
        break;
      case MSG_KEY_PLAY_STATE: 
        if (t->value->int32 > 0) {
          action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_pause);
        } else {
          action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_play);
        }
        break;
    }

    t = dict_read_next(iterator);
  }
}
Пример #5
0
void tertiary_text_chosen(char *text) {
  if (s_state == BEGINNING_STATE) {
    snprintf(dictated_name, sizeof(dictated_name), "%s", text);

    snprintf(instruction_text, sizeof(instruction_text), "%s", "Loading Contact...");
    snprintf(primary_text, sizeof(primary_text), "%s", dictated_name);
    text_layer_set_text(s_instruction_layer, instruction_text);
    text_layer_set_text(s_primary_layer, primary_text);

    change_state(CHECKING_CONTACT_STATE);

    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_UP, NULL);
    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_SELECT, NULL);
    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_DOWN, NULL);

    get_contact();
  }

  if (s_state == CREATING_FINAL_MESSAGE_STATE) {
    change_state(CONFIRMING_FINAL_MESSAGE_STATE);
    snprintf(dictated_message, sizeof(dictated_message), "%s", text);

    snprintf(instruction_text, sizeof(instruction_text), "%s", contact_name);
    snprintf(primary_text, sizeof(primary_text), "%s", dictated_message);
    text_layer_set_text(s_instruction_layer, instruction_text);
    text_layer_set_text(s_primary_layer, primary_text);
  }
}
Пример #6
0
static void pause_click_handler(ClickRecognizerRef recognizer, void *context) {
  int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT;
  if (calib_stored != 0 && calibrating == 0) {
    pause++;
    pause = pause % 2;
    if (pause == 0) {
      end_time = time(NULL);
      double elapsed = difftime(end_time, start_time);
      result = (int)floor(sum_x/elapsed);
      display(text_layer_3, "Score: %d", result);
      action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_play);
      int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT;
      display(text_layer_4, "Calib: %d", calib_stored);
      text_layer_set_text(text_layer_2, "");
      if (result > 2*calib_stored) {
        send(0, 1);
        text_layer_set_text(text_layer_1, "YOU'RE DRUNK");
        dialog_message_window_push();
        
      }
      else {
        send(0, 0);
        text_layer_set_text(text_layer_1, "YOU'RE FINE");
        
      }
    }
    else {
      sum_x = 0;
      text_layer_set_text(text_layer_2, "RUNNING");
      text_layer_set_text(text_layer_3, "");
      action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_pause);   
      start_time = time(NULL);
    }
  }
}
Пример #7
0
// Update the main window to show snoozing, smart alarm monitoring, or Get Out Of Bed alarm monitoring
void show_status(time_t alarm_time, status_enum status) {
  s_onoff_mode = MODE_ACTIVE;
  stop_autoclose_timer();
  switch (status) {
    case S_Snoozing:
      set_onoff_text("SNOOZING");
      break;
    case S_SmartMonitoring:
      set_onoff_text("SMART ALARM\nACTIVE");
      break;
    case S_GooBMonitoring:
      set_onoff_text("GET OUT OF BED\nMONITORING");
      break;
    case S_GooBSnooze:
      set_onoff_text("SNOOZING\nGET OUT OF BED\nMONITORING");
      break;
  }
  
  struct tm *t = localtime(&alarm_time);
  
  char time_str[8];
  gen_time_str(t->tm_hour, t->tm_min, time_str, sizeof(time_str));
  
  char info[40];
  snprintf(info, sizeof(info), "%s: %s\n2 clicks to stop", (status == S_Snoozing ? "Until" : "Alarm"), time_str);
  update_info(info);
  
  action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_snooze);
  action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_snooze);
}
Пример #8
0
static void initialise_ui(void) {
    s_window = window_create();
    window_set_fullscreen(s_window, true);

    s_res_yes = gbitmap_create_with_resource(RESOURCE_ID_YES);
    s_res_no = gbitmap_create_with_resource(RESOURCE_ID_NO);
    s_res_gothic_24 = fonts_get_system_font(FONT_KEY_GOTHIC_24);
    s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
    // s_actionbarlayer_1
    s_actionbarlayer_1 = action_bar_layer_create();
    action_bar_layer_add_to_window(s_actionbarlayer_1, s_window);
    action_bar_layer_set_background_color(s_actionbarlayer_1, GColorBlack);
    action_bar_layer_set_icon(s_actionbarlayer_1, BUTTON_ID_UP, s_res_yes);
    action_bar_layer_set_icon(s_actionbarlayer_1, BUTTON_ID_DOWN, s_res_no);
    layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbarlayer_1);

    // s_textlayer_1
    s_textlayer_1 = text_layer_create(GRect(6, 14, 114, 99));
    text_layer_set_text(s_textlayer_1, "You're close to a weighing machine!");
    text_layer_set_text_alignment(s_textlayer_1, GTextAlignmentCenter);
    text_layer_set_font(s_textlayer_1, s_res_gothic_24);
    layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_1);

    // s_textlayer_2
    s_textlayer_2 = text_layer_create(GRect(12, 99, 100, 57));
    text_layer_set_text(s_textlayer_2, "Input your weight?");
    text_layer_set_text_alignment(s_textlayer_2, GTextAlignmentCenter);
    text_layer_set_font(s_textlayer_2, s_res_gothic_24_bold);
    layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_2);
}
Пример #9
0
void scores_name_window_load (Window *window) {
	GRect windowBounds = layer_get_frame(ui.windowLayer);
	GRect titleBounds = GRect(0, 0, 120, 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, "  Enter Name");
  	text_layer_set_font(ui.titleLayer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  	text_layer_set_text_alignment(ui.titleLayer, GTextAlignmentLeft);
	layer_add_child(ui.windowLayer, text_layer_get_layer(ui.titleLayer));
	
	ui.frontArrow = gbitmap_create_with_resource(RESOURCE_ID_FRONT_ARROW);
	ui.backArrow = gbitmap_create_with_resource(RESOURCE_ID_BACK_ARROW);
	ui.nextArrow = gbitmap_create_with_resource(RESOURCE_ID_NEXT_ARROW);
	
	ui.actionBarLayer = action_bar_layer_create();
	action_bar_layer_add_to_window(ui.actionBarLayer, ui.window);
	action_bar_layer_set_click_config_provider(ui.actionBarLayer, scores_name_click_config_provider);
	action_bar_layer_set_icon(ui.actionBarLayer, BUTTON_ID_UP, ui.backArrow);
	action_bar_layer_set_icon(ui.actionBarLayer, BUTTON_ID_DOWN, ui.frontArrow);
	action_bar_layer_set_icon(ui.actionBarLayer, BUTTON_ID_SELECT, ui.nextArrow);
	
	GRect selectorBounds = GRect(100, 30, 20, (windowBounds.size.h - 30));
	ui.selectorLayer = text_layer_create(selectorBounds);
	text_layer_set_text_color(ui.selectorLayer, GColorClear);
	text_layer_set_background_color(ui.selectorLayer, GColorBlack);
	text_layer_set_text(ui.selectorLayer, "");
  	text_layer_set_font(ui.selectorLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  	text_layer_set_text_alignment(ui.selectorLayer, GTextAlignmentCenter);
	layer_add_child(ui.windowLayer, text_layer_get_layer(ui.selectorLayer));
	
	GRect activeBounds = GRect(20, 70, 60, 1);
	ui.activeLayer = text_layer_create(activeBounds);
	text_layer_set_text_color(ui.activeLayer, GColorClear);
	text_layer_set_background_color(ui.activeLayer, GColorBlack);
	text_layer_set_text(ui.activeLayer, "");
  	text_layer_set_font(ui.activeLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  	text_layer_set_text_alignment(ui.activeLayer, GTextAlignmentCenter);
	layer_add_child(ui.windowLayer, text_layer_get_layer(ui.activeLayer));
	
	int r, c, x = 0, y = 0, index = 0;
	for (c=5;c>=0;c--) {
		x = (c + 1) * 5 + (c * 15);
		
		for (r=0;r<3;r++) {
			y = (r + 1) * 40;
			index = status.indexes[r] - (5 - c);
			if (index < 0) index = 25 + (index + 1);
			
			GRect letterBounds = GRect(x, y, 30, 30);
			ui.letterLayers[c][r] = text_layer_create(letterBounds);
			text_layer_set_text_color(ui.letterLayers[c][r], ((c >= 5)?GColorWhite:GColorBlack));
			text_layer_set_background_color(ui.letterLayers[c][r], GColorClear);
			text_layer_set_text(ui.letterLayers[c][r], letters[index]);
			text_layer_set_font(ui.letterLayers[c][r], fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
			text_layer_set_text_alignment(ui.letterLayers[c][r], GTextAlignmentLeft);
			layer_add_child(ui.windowLayer, text_layer_get_layer(ui.letterLayers[c][r]));
		}
	}
}
Пример #10
0
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {  
  if (!is_connected) {
    return;
  }
  // Start dictation UI
  #if defined(PBL_MICROPHONE)
  if (s_dictation_session == NULL) {
    s_dictation_session = dictation_session_create(sizeof(dictated_message), dictation_session_callback, NULL);
    if (s_dictation_session != NULL) {
      dictation_session_enable_confirmation(s_dictation_session, false);
    }
  }
  if (s_state == BEGINNING_STATE) {
    dictation_session_start(s_dictation_session);
  }

  if (s_state == CREATING_FINAL_MESSAGE_STATE) {
    dictation_session_start(s_dictation_session);
  }
  #endif
  if (s_state == CONFIRMING_FINAL_MESSAGE_STATE) {
    change_state(SENDING_FINAL_MESSAGE_STATE);
    send_final_message();

    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_UP, NULL);
    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_SELECT, NULL);
    action_bar_layer_set_icon(s_actionbar, BUTTON_ID_DOWN, NULL);
  }
}
Пример #11
0
static void in_received_handler(DictionaryIterator *iter, void *context) {
	Tuple *server_host_tuple = dict_find(iter, KEY_SERVER_HOST);
	Tuple *server_pass_tuple = dict_find(iter, KEY_SERVER_PASS);
	Tuple *title_tuple = dict_find(iter, KEY_TITLE);
	Tuple *status_tuple = dict_find(iter, KEY_STATUS);
	Tuple *volume_tuple = dict_find(iter, KEY_VOLUME);

	if (server_host_tuple) {
		persist_write_string(KEY_SERVER_HOST, server_host_tuple->value->cstring);
		set_server_host_from_persistent_storage();
	}
	if (server_pass_tuple) {
		persist_write_string(KEY_SERVER_PASS, server_pass_tuple->value->cstring);
		set_server_pass_from_persistent_storage();
	}
	if (title_tuple) {
		strncpy(title, title_tuple->value->cstring, sizeof(title));
		text_layer_set_text(title_layer, title);
	}
	if (status_tuple) {
		strncpy(status, status_tuple->value->cstring, sizeof(status));
		text_layer_set_text(status_layer, status);
		if (strcmp(status, "Playing") == 0) {
			action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, action_icon_pause);
		} else {
			action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, action_icon_play);
		}
	}
	if (volume_tuple) {
		strncpy(volume, volume_tuple->value->cstring, sizeof(volume));
		text_layer_set_text(volume_layer, volume);
	}
}
Пример #12
0
/*
 * Highlight or unhighlight a field
 */
static void highlight_field(int8_t id, bool hilight) {
  text_layer_set_background_color(fields[id], hilight ? HIGHLIGHT_BG_COLOR : NON_HIGHLIGHT_BG_COLOR);
  text_layer_set_text_color(fields[id], hilight ? HIGHLIGHT_FG_COLOR : NON_HIGHLIGHT_FG_COLOR);
  if (hilight) {
    action_bar_layer_set_icon(button_layer, BUTTON_ID_UP, id == F_DONE ? tick_button_res : up_button_res);
    action_bar_layer_set_icon(button_layer, BUTTON_ID_DOWN, id == F_DONE ? tick_button_res : down_button_res);
  }
}
Пример #13
0
static void initialize_ui() {
  s_window = window_create();
  window_set_fullscreen(s_window, false);
  window_set_background_color(s_window, GColorBlack);
  Layer *window_layer = window_get_root_layer(s_window);
  GRect bounds = layer_get_frame(window_layer);
  
  s_icon_vol_up = gbitmap_create_with_resource(RESOURCE_ID_ICON_VOL_UP);
  s_icon_pause = gbitmap_create_with_resource(RESOURCE_ID_ICON_PAUSE);
  s_icon_play = gbitmap_create_with_resource(RESOURCE_ID_ICON_PLAY);
  s_icon_vol_dn = gbitmap_create_with_resource(RESOURCE_ID_ICON_VOL_DN);
  s_icon_speaker = gbitmap_create_with_resource(RESOURCE_ID_ICON_SPEAKER);
  s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  s_res_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);

  // s_lyr_backround
  s_lyr_background = layer_create(bounds);
  layer_set_update_proc(s_lyr_background, lyr_background_update_proc);
  layer_add_child(window_layer, (Layer *) s_lyr_background);
  // s_player_bar
  s_action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(s_action_bar, s_window);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_icon_vol_up);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_pause);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_icon_vol_dn);
  action_bar_layer_set_click_config_provider(s_action_bar, click_provider);
  layer_add_child(window_layer, (Layer *) s_action_bar);
  // s_txt_title
  s_txt_title = text_layer_create(GRect(4, 0, 116, 76));
  text_layer_set_background_color(s_txt_title, GColorClear);
  text_layer_set_text_color(s_txt_title, GColorWhite);
  text_layer_set_text_alignment(s_txt_title, GTextAlignmentCenter);
  text_layer_set_font(s_txt_title, s_res_gothic_24_bold);
  text_layer_set_text(s_txt_title, "Loading...");
  layer_add_child(window_layer, (Layer *) s_txt_title);
  // s_txt_artist
  s_txt_artist = text_layer_create(GRect(4, 78, 116, 56));
  text_layer_set_background_color(s_txt_artist, GColorClear);
  text_layer_set_text_color(s_txt_artist, GColorWhite);
  text_layer_set_text_alignment(s_txt_artist, GTextAlignmentCenter);
  text_layer_set_font(s_txt_artist, s_res_gothic_18);
  layer_add_child(window_layer, (Layer *) s_txt_artist);
  // s_bmap_speaker
  s_bmp_speaker = bitmap_layer_create(GRect(2, 134, 8, 12));
  bitmap_layer_set_bitmap(s_bmp_speaker, s_icon_speaker);
  layer_add_child(window_layer, (Layer *) s_bmp_speaker);
  // s_lyr_volume
  s_lyr_volume = layer_create_with_data(GRect(16, 136, 100, 8), sizeof(uint32_t));
  layer_set_update_proc(s_lyr_volume, lyr_volume_update_proc);
  uint32_t *len = (uint32_t *) layer_get_data(s_lyr_volume);
	*len = 0;
  layer_add_child(window_layer, (Layer *) s_lyr_volume);
  
  app_message_register_inbox_received(inbox_received_callback);
  app_message_register_inbox_dropped(inbox_dropped_callback);

  outbox_send("GET_STATUS");
}
Пример #14
0
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  APP_LOG(APP_LOG_LEVEL_DEBUG, "window height = %d", layer_get_frame(window_layer).size.h);

  s_action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(s_action_bar, window);
  action_bar_layer_set_click_config_provider(s_action_bar, 
                                             click_config_provider);

  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_icon_plus);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_icon_minus);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_done);
  
  
  int width = layer_get_frame(window_layer).size.w - ACTION_BAR_WIDTH - 3;

  // Header Text Layer
  s_header_layer = text_layer_create(GRect(4, 0, width, 60));
  text_layer_set_font(s_header_layer, 
                      fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_background_color(s_header_layer, GColorClear);
  text_layer_set_text(s_header_layer, "Mood Tracker");
  layer_add_child(window_layer, text_layer_get_layer(s_header_layer));

  // Body Text Layer
  s_body_layer = text_layer_create(GRect(4, 44, width, 60));
  text_layer_set_font(s_body_layer, 
                      fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_background_color(s_body_layer, GColorClear);
  layer_add_child(window_layer, text_layer_get_layer(s_body_layer));

  // Label Text Layer
  s_label_layer = text_layer_create(GRect(4, 44 + 28, width, 60));
  text_layer_set_font(s_label_layer, 
                      fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(s_label_layer, GColorClear);
  
  text_layer_set_text(s_label_layer, "of mood today");
  layer_add_child(window_layer, text_layer_get_layer(s_label_layer));
  
#ifdef PBL_COLOR
  // Set the Window background color to a color that is similar to hospital 
  // walls
  window_set_background_color(window, GColorCadetBlue);
  // Set the actionbar background color to a color that is similar to medical 
  // staff uniforms
  action_bar_layer_set_background_color(s_action_bar, GColorCobaltBlue);
  
  text_layer_set_text_color(s_header_layer, GColorBlack);
  text_layer_set_text_color(s_body_layer, GColorBlack);
  text_layer_set_text_color(s_label_layer, GColorBlack);
#endif

  update_text();
}
Пример #15
0
void action_bar_init(Window* window) {
  // Initialize the action bar:
  action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(action_bar, window);
  action_bar_layer_set_click_config_provider(action_bar, click_config_provider);

  action_bar_layer_set_icon(action_bar, BUTTON_ID_UP, start_button);
  action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, next_button);
  //action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, reset_buttonp);
  action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, menu_button);
}
Пример #16
0
static void gui_ab_update_icons(void) {
  if(started) {
    action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_ab_icon_check_out);
    action_bar_layer_clear_icon(s_action_bar, BUTTON_ID_SELECT);
    /* action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_ab_icon_task); */
    action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_ab_icon_switch);
  } else {
    action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_ab_icon_check_in);
    action_bar_layer_clear_icon(s_action_bar, BUTTON_ID_SELECT);
    action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_ab_icon_switch);
  }
}
Пример #17
0
// initializes action bar
static void action_bar_init(Window *window) {
  GBitmap *add_icon = gbitmap_create_with_resource(RESOURCE_IDS[0]);
  GBitmap *subtract_icon = gbitmap_create_with_resource(RESOURCE_IDS[1]);
  GBitmap *stroke_icon = gbitmap_create_with_resource(RESOURCE_IDS[2]);

  action_bar_layer = action_bar_layer_create();
  action_bar_layer_add_to_window(action_bar_layer, window);
  action_bar_layer_set_click_config_provider(action_bar_layer, click_config_provider);
  action_bar_layer_set_icon(action_bar_layer, BUTTON_ID_UP, add_icon);
  action_bar_layer_set_icon(action_bar_layer, BUTTON_ID_SELECT, stroke_icon);
  action_bar_layer_set_icon(action_bar_layer, BUTTON_ID_DOWN, subtract_icon);
}
Пример #18
0
static void initialise_ui(void) {
  
  s_window = window_create();
  Layer *root_layer = window_get_root_layer(s_window);
  GRect bounds = layer_get_bounds(root_layer); 
  window_set_background_color(s_window, COLOR_FALLBACK(GColorBulgarianRose, GColorBlack)); 
  IF_2(window_set_fullscreen(s_window, false));
  
#ifdef PBL_ROUND
  int dev_layer_left = (bounds.size.w - DEV_LAYER_WIDTH)/2;
  int dev_layer_top = (bounds.size.h - DEV_LAYER_HEIGHT)/2;
#else
  int dev_layer_left = ((bounds.size.w - DEV_LAYER_WIDTH - ACTION_BAR_WIDTH)/2) + 4;
  int dev_layer_top = ((bounds.size.h - DEV_LAYER_HEIGHT - 14)/2) + IF_32(14, 0);
#endif
  
  s_rect_above = GRect(dev_layer_left, -(DEV_LAYER_HEIGHT+2), DEV_LAYER_WIDTH, DEV_LAYER_HEIGHT);
  s_rect_onscreen = GRect(dev_layer_left, dev_layer_top, DEV_LAYER_WIDTH, DEV_LAYER_HEIGHT);
  s_rect_below = GRect(dev_layer_left, bounds.size.h+2, DEV_LAYER_WIDTH, DEV_LAYER_HEIGHT);
  
  // s_devicecard_layer
  s_devicecard_layer = devicecard_layer_create(s_rect_onscreen);
  layer_add_child(root_layer, s_devicecard_layer->layer);
  
  // s_layer_spots
  s_layer_spots = layer_create(PBL_IF_RECT_ELSE(GRect((dev_layer_left/2)-SPOT_RADIUS, dev_layer_top, 
                                                (SPOT_RADIUS*2)+1 , DEV_LAYER_HEIGHT), bounds));
  layer_add_child(root_layer, (Layer *)s_layer_spots);
  
#ifndef PBL_SDK_2
  s_status_bar = status_bar_layer_create();
  status_bar_layer_set_colors(s_status_bar, COLOR_FALLBACK(GColorBulgarianRose, GColorBlack), GColorWhite);
  layer_add_child(root_layer, status_bar_layer_get_layer(s_status_bar));
#endif
  
  s_res_image_action_up = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_UP);
  s_res_image_action_set = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_SET);
  s_res_image_action_down = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_DOWN);
  
  // s_actionbar_main
  s_actionbar_main = action_bar_layer_create();
  action_bar_layer_add_to_window(s_actionbar_main, s_window);
  action_bar_layer_set_background_color(s_actionbar_main, GColorWhite);
  action_bar_layer_set_icon(s_actionbar_main, BUTTON_ID_UP, s_res_image_action_up);
  action_bar_layer_set_icon(s_actionbar_main, BUTTON_ID_SELECT, s_res_image_action_set);
  action_bar_layer_set_icon(s_actionbar_main, BUTTON_ID_DOWN, s_res_image_action_down);
#ifdef PBL_RECT
  layer_set_frame(action_bar_layer_get_layer(s_actionbar_main), GRect(bounds.size.w-20, 0, 20, bounds.size.h));
  IF_3(layer_set_bounds(action_bar_layer_get_layer(s_actionbar_main), GRect(-5, 0, 30, bounds.size.h)));
#endif
  layer_add_child(root_layer, (Layer *)s_actionbar_main);
}
Пример #19
0
void show_alarm_ui(bool on) {
  if (on) {
    s_onoff_mode = MODE_ACTIVE;
    set_onoff_text("WAKEY! WAKEY!");
    update_info("Click to snooze\n2 clicks to stop ");
    action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_snooze);
    action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_snooze);
  } else {
    update_onoff(s_alarms_on);
    action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_standby);
    action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_settings);
  }
}
Пример #20
0
static void window_load(Window *window) {
	action_bar = action_bar_layer_create();
	action_bar_layer_add_to_window(action_bar, window);
	action_bar_layer_set_click_config_provider(action_bar, click_config_provider);

	action_bar_layer_set_icon(action_bar, BUTTON_ID_UP, action_icon_vol_up);
	action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, action_icon_vol_down);
	action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, action_icon_play);

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

	title_layer = text_layer_create((GRect) { .origin = { 5, 0 }, .size = { bounds.size.w - 28, 52 } });
Пример #21
0
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  s_icon_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CONFIRM);

  const GEdgeInsets icon_insets = {.top = 7, .right = 28, .bottom = 56, .left = 14};
  s_icon_layer = bitmap_layer_create(grect_inset(bounds, icon_insets));
  bitmap_layer_set_bitmap(s_icon_layer, s_icon_bitmap);
  bitmap_layer_set_compositing_mode(s_icon_layer, GCompOpSet);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_icon_layer));

  const GEdgeInsets label_insets = {.top = 112, .right = ACTION_BAR_WIDTH, .left = ACTION_BAR_WIDTH / 2};
  s_label_layer = text_layer_create(grect_inset(bounds, label_insets));
  text_layer_set_text(s_label_layer, DIALOG_CHOICE_WINDOW_MESSAGE);
  text_layer_set_background_color(s_label_layer, GColorClear);
  text_layer_set_text_alignment(s_label_layer, GTextAlignmentCenter);
  text_layer_set_font(s_label_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  layer_add_child(window_layer, text_layer_get_layer(s_label_layer));

  s_tick_bitmap = gbitmap_create_with_resource(RESOURCE_ID_TICK);
  s_cross_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CROSS);

  s_action_bar_layer = action_bar_layer_create();
  action_bar_layer_set_icon(s_action_bar_layer, BUTTON_ID_UP, s_tick_bitmap);
  action_bar_layer_set_icon(s_action_bar_layer, BUTTON_ID_DOWN, s_cross_bitmap);
  action_bar_layer_add_to_window(s_action_bar_layer, window);
}

static void window_unload(Window *window) {
  text_layer_destroy(s_label_layer);
  action_bar_layer_destroy(s_action_bar_layer);
  bitmap_layer_destroy(s_icon_layer);

  gbitmap_destroy(s_icon_bitmap);
  gbitmap_destroy(s_tick_bitmap);
  gbitmap_destroy(s_cross_bitmap);

  window_destroy(window);
  s_main_window = NULL;
}

void dialog_choice_window_push() {
  if(!s_main_window) {
    s_main_window = window_create();
    window_set_background_color(s_main_window, PBL_IF_COLOR_ELSE(GColorJaegerGreen, GColorWhite));
    window_set_window_handlers(s_main_window, (WindowHandlers) {
        .load = window_load,
        .unload = window_unload,
    });
  }
static void action_bar_setup(Window *window)
{
  abl_action = action_bar_layer_create();
  action_bar_layer_add_to_window(abl_action, window);
  action_bar_layer_set_click_config_provider(abl_action, abl_click_config_provider);

  gb_arrow_up = gbitmap_create_with_resource(RESOURCE_ID_ARROW_UP);
  gb_arrow_down = gbitmap_create_with_resource(RESOURCE_ID_ARROW_DOWN);
  gb_arrow_reload = gbitmap_create_with_resource(RESOURCE_ID_ARROW_RELOAD);

  action_bar_layer_set_icon(abl_action, BUTTON_ID_UP, gb_arrow_up);
  action_bar_layer_set_icon(abl_action, BUTTON_ID_DOWN, gb_arrow_down);
  action_bar_layer_set_icon(abl_action, BUTTON_ID_SELECT, gb_arrow_reload);
}
Пример #23
0
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  //*********************************************************************************
   GRect bounds = layer_get_bounds(window_layer);

  // We do this to account for the offset due to the status bar
  // at the top of the app window.

  GPoint center = grect_center_point(&bounds);
  GSize image_size = gbitmap_get_bounds(back_icon).size;
  
    //GRect image_frame = GRect(center.x-8, center.y-10, image_size.w, image_size.h);
  //image_frame.origin.x -= image_size.w / 2;
  //image_frame.origin.y -= image_size.h / 2;
  
  GRect image_frame = GRect(center.x-14, center.y-10, image_size.w, image_size.h);
  image_frame.origin.x -= image_size.w / 2;
  image_frame.origin.y -= image_size.h / 2;
    
  // Use GCompOpClear to display the black portions of the image
  s_black_layer = bitmap_layer_create(image_frame);
  bitmap_layer_set_bitmap(s_black_layer, back_icon);
  bitmap_layer_set_compositing_mode(s_black_layer, GCompOpSet);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_black_layer));
  //**************************************************************************************************
  
  // Create ActionBar
  // Initialize the action bar:
  s_action_bar_layer = action_bar_layer_create();
  // Associate the action bar with the window:
  action_bar_layer_add_to_window(s_action_bar_layer, window);
  // Set the click config provider:
  action_bar_layer_set_click_config_provider(s_action_bar_layer, config_provider);
  // Set the icons:
  // The loading the icons is omitted for brevity... See HeapBitmap.
  action_bar_layer_set_icon(s_action_bar_layer, BUTTON_ID_UP, my_icon_location);
  action_bar_layer_set_icon(s_action_bar_layer, BUTTON_ID_DOWN, my_icon_stop);
  
    
  // Create output TextLayer
  s_output_layer = text_layer_create(GRect(5, 135, 105, 25));
  //text_layer_set_font(s_output_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text(s_output_layer, " Save pos");
  text_layer_set_text_color(s_output_layer,GColorWhite);
  text_layer_set_background_color(s_output_layer,GColorBlack);
  text_layer_set_overflow_mode(s_output_layer, GTextOverflowModeWordWrap);
  layer_add_child(window_layer, text_layer_get_layer(s_output_layer));
  
}
Пример #24
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  IF_2(window_set_fullscreen(s_window, true));
  
  s_res_img_upaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_UPACTION);
  s_res_img_okaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_OKACTION);
  s_res_img_downaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_DOWNACTION);
  s_res_gothic_24 = fonts_get_system_font(FONT_KEY_GOTHIC_24);
  s_res_gothic_28 = fonts_get_system_font(FONT_KEY_GOTHIC_28);
  // s_actionbarlayer
  s_actionbarlayer = action_bar_layer_create();
  action_bar_layer_add_to_window(s_actionbarlayer, s_window);
  action_bar_layer_set_background_color(s_actionbarlayer, GColorWhite);
  action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_UP, s_res_img_upaction);
  action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_SELECT, s_res_img_okaction);
  action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_DOWN, s_res_img_downaction);
  layer_set_frame(action_bar_layer_get_layer(s_actionbarlayer), GRect(124, 0, 20, 168));
  IF_3(layer_set_bounds(action_bar_layer_get_layer(s_actionbarlayer), GRect(-5, 0, 30, 168)));
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbarlayer);
  
  // s_textlayer_info
  s_textlayer_info = text_layer_create(GRect(7, 25, 117, 32));
  text_layer_set_background_color(s_textlayer_info, GColorClear);
  text_layer_set_text_color(s_textlayer_info, GColorWhite);
  text_layer_set_text(s_textlayer_info, "Skip Until:");
  text_layer_set_text_alignment(s_textlayer_info, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_info, s_res_gothic_24);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_info);
  
  // s_textlayer_date
  s_textlayer_date = text_layer_create(GRect(2, 64, 122, 32));
  text_layer_set_background_color(s_textlayer_date, GColorClear);
  text_layer_set_text_color(s_textlayer_date, GColorWhite);
  text_layer_set_text(s_textlayer_date, "Thu, Feb 22");
  text_layer_set_text_alignment(s_textlayer_date, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_date, s_res_gothic_28);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_date);
  
  // s_textlayer_status
  s_textlayer_status = text_layer_create(GRect(7, 100, 117, 32));
  text_layer_set_background_color(s_textlayer_status, GColorClear);
  text_layer_set_text_color(s_textlayer_status, GColorWhite);
  text_layer_set_text(s_textlayer_status, "(No skipping)");
  text_layer_set_text_alignment(s_textlayer_status, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_status, s_res_gothic_24);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_status);
}
Пример #25
0
void show_monitoring(time_t alarm_time) {
  s_onoff_mode = MODE_ACTIVE;
  set_onoff_text("SMART ALARM ACTIVE");
  
  struct tm *t = localtime(&alarm_time);
  
  char time_str[8];
  gen_time_str(t->tm_hour, t->tm_min, time_str, sizeof(time_str));
  
  char info[40];
  snprintf(info, sizeof(info), "Alarm: %s\n2 clicks to stop", time_str);
  update_info(info);
  
  action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_snooze);
  action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_snooze);
}
Пример #26
0
void win_add_duration_init(void) {
  window = window_create();

  layer = layer_create_fullscreen(window);
  layer_set_update_proc(layer, layer_update);
  layer_add_to_window(layer, window);

  layer_action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(layer_action_bar, window);
  action_bar_layer_set_click_config_provider(layer_action_bar, layer_action_bar_click_config_provider);
  action_bar_layer_set_icon(layer_action_bar, BUTTON_ID_UP, bitmaps_get_bitmap(RESOURCE_ID_ACTION_INC));
  action_bar_layer_set_icon(layer_action_bar, BUTTON_ID_DOWN, bitmaps_get_bitmap(RESOURCE_ID_ACTION_DEC));
  action_bar_layer_set_icon(layer_action_bar, BUTTON_ID_SELECT, bitmaps_get_bitmap(RESOURCE_ID_ACTION_OK));

  font_duration = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_AUDI_70_BOLD));
}
Пример #27
0
static void endtrial_callback() {
  pause++;
  vibes_short_pulse();
  end_time = time(NULL);
  double elapsed = difftime(end_time, start_time);
  result = (int)floor(sum_x/elapsed);
  
  display(text_layer_3, "Final: %d", result);
  
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_play);
  int calib_stored = persist_exists(CALIB_PKEY) ? persist_read_int(CALIB_PKEY) : CALIB_DEFAULT;

  if (result > 2*calib_stored) {
    send(0,1);
    text_layer_set_text(text_layer_1, "YOU'RE DRUNK");
    text_layer_set_text(text_layer_4, "");
    dialog_message_window_push();
  }
  else {
    send(0,0);
    text_layer_set_text(text_layer_1, "YOU'RE FINE");
    text_layer_set_text(text_layer_2, "");
    text_layer_set_text(text_layer_4, "");
  }

}
Пример #28
0
void select_click_handler(ClickRecognizerRef recognizer, void *context)
{

  if (cargando==1)
    return;
  
  switch(posicion) 
    {
		case 0:
      posicion=1;
      break;
		case 1:
      posicion=2;
      action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, buscar_bitmap);

			break;
		case 2:
      if (strcmp(devuelve_datos_parada(numero_parada(),0),"Parada inexistente")==0)
      {
        posicion =0;
      }
    else
      {
            posicion=0;
      layer_mark_dirty(marcador);
        //envia_peticion();
        dialog_message_window_push(numero_parada());
      }
      break;    
    
    }

  layer_mark_dirty(marcador);
}
Пример #29
0
void show_snooze(time_t snooze_time) {
  s_onoff_mode = MODE_ACTIVE;
  set_onoff_text("SNOOZING");
  
  struct tm *t = localtime(&snooze_time);
  
  char time_str[8];
  gen_time_str(t->tm_hour, t->tm_min, time_str, sizeof(time_str));
  
  char info[40];
  snprintf(info, sizeof(info), "Until: %s\n2 clicks to stop", time_str);
  update_info(info);
  
  action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_snooze);
  action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_snooze);
}
Пример #30
0
/** Window Callbacks **/
static void window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  icon_confirm = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_CHECK);
  icon_cancel = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_X);
  icon_select = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SOCIAL);

  action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(action_bar, window);
  action_bar_layer_set_click_config_provider(action_bar, click_config_provider);
  action_bar_layer_set_icon(action_bar, BUTTON_ID_DOWN, icon_confirm);
  action_bar_layer_set_icon(action_bar, BUTTON_ID_SELECT, icon_select);
  action_bar_layer_set_icon(action_bar, BUTTON_ID_UP, icon_cancel);

  prompt_text = text_layer_create((GRect) { .origin = { 10, 10 }, .size = { bounds.size.w - 30, 120 } });