void views_init_date_text_layer(Layer *parent_layer) { static const int16_t LEFT = 0; static const int16_t TOP = 26; static const int16_t WIDTH = DATE_TIME_LAYER_WIDTH; static const int16_t HEIGHT = 32; GFont font = fonts_load_custom_font( resource_get_handle(RESOURCE_ID_FONT_DATE_21)); date_text_layer = text_layer_create(GRect(LEFT, TOP, WIDTH, HEIGHT)); text_layer_set_text_color(date_text_layer, GColorWhite); text_layer_set_background_color(date_text_layer, GColorClear); text_layer_set_font(date_text_layer, font); layer_add_child(parent_layer, text_layer_get_layer(date_text_layer)); text_layer_set_text(date_text_layer, "March 9"); }
static void main_window_load(Window *window) { // Create time TextLayer s_time_layer = text_layer_create(GRect(0, -2, 144, 170)); text_layer_set_background_color(s_time_layer, GColorBlack); text_layer_set_text_color(s_time_layer, GColorWhite); text_layer_set_text(s_time_layer, "00:00"); // Format text layer text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT)); text_layer_set_text_alignment(s_time_layer, GTextAlignmentRight); text_layer_set_overflow_mode(s_time_layer, GTextOverflowModeWordWrap); // 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)); // Make sure the time is displayed from the start UPDATE_TIME_NOW(); }
static void main_window_load(Window *window) { // load font s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_AMATIC_REGULAR_60)); // Create time TextLayer s_time_layer = text_layer_create(GRect(0, 45, 144, 60)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorBlack); // 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); // Make sure the time is displayed from the start update_time(); // 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) { // Get information about the Window Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); // Create the TextLayer with specific bounds s_time_layer = text_layer_create( GRect(0, PBL_IF_ROUND_ELSE(58, 52), bounds.size.w, 50)); // Improve the layout to be more like a watchface 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, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); 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_layer, text_layer_get_layer(s_time_layer)); }
static void main_window_load(Window *window) { //Initialize the backgrounds we can select s_dog_bg = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG_DOG); s_cat_bg = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG_CAT); s_bird_bg = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG_BIRD); // Create time TextLayer s_time_layer = text_layer_create(GRect(0, 0, 144, 32)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorBlack); // Improve the layout to be more like a watchface s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MULI_24)); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); //Check for saved background option char facebg[20]; persist_read_string(KEY_BG, facebg, sizeof(facebg)); if(strcmp(facebg,"dog") == 0){ s_bg_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG_DOG); }else if(strcmp(facebg,"cat") == 0){ s_bg_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG_CAT); }else if(strcmp(facebg,"bird") == 0){ s_bg_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG_BIRD); } //Declare a bitmap layer //static BitmapLayer *s_bitmap_layer; //Create bitmap layer and set it to show the GBitmap s_bitmap_layer = bitmap_layer_create(GRect(0,0,144,168)); bitmap_layer_set_bitmap(s_bitmap_layer,s_bg_bitmap); //Add the bitmaplayer as a child layer to the window: layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_bitmap_layer)); // Add text layer 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)); }
void notify_init(bool subscribe, Window *window) { Layer *window_layer = window_get_root_layer(window); /* ** Load graphics... */ tick = gbitmap_create_with_resource(RESOURCE_ID_TICK); /* ** Initialize the layers. */ warn_layer = bitmap_layer_create(GRect(0, 0, 144, 168)); layer_set_hidden(bitmap_layer_get_layer(warn_layer), true); layer_add_child(window_layer, bitmap_layer_get_layer(warn_layer)); warn_text_layer = text_layer_create(GRect(0, 100, 144, 68)); text_layer_set_background_color(warn_text_layer, GColorClear); text_layer_set_font(warn_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); text_layer_set_text_alignment(warn_text_layer, GTextAlignmentCenter); text_layer_set_text_color(warn_text_layer, GColorWhite); layer_add_child(bitmap_layer_get_layer(warn_layer), text_layer_get_layer(warn_text_layer)); if (subscribe) { subscribed = true; /* ** Load graphics... */ lowbatt = gbitmap_create_with_resource(RESOURCE_ID_LOWBATT); btdisc = gbitmap_create_with_resource(RESOURCE_ID_BTDISC); /* ** Subscribe to event services. */ battery_state_service_subscribe(handle_battery); bluetooth_connection_service_subscribe(handle_bluetooth); } }
static void init(void) { time_t t; struct tm *tm; initRadiuses(); readConfig(); app_message_init(); window = window_create(); window_set_background_color(window, GColorBlack); window_stack_push(window, false); rootLayer = window_get_root_layer(window); t = time(NULL); tm = localtime(&t); layer = layer_create(GRect(0, 0, 144, 168)); layer_set_update_proc(layer, updateScreen); layer_add_child(rootLayer, layer); font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TIMEBURNER_20)); textFrame = GRect(72-innerCircleInnerRadius, 60, 2*innerCircleInnerRadius, 60); textLayer = text_layer_create(textFrame); text_layer_set_text_alignment(textLayer, GTextAlignmentCenter); text_layer_set_overflow_mode(textLayer, GTextOverflowModeWordWrap); text_layer_set_background_color(textLayer, GColorClear); text_layer_set_text_color(textLayer, GColorWhite); text_layer_set_font(textLayer, font); layer_set_hidden(text_layer_get_layer(textLayer), true); layer_add_child(rootLayer, text_layer_get_layer(textLayer)); setDate(tm); calcAngles(tm); tick_timer_service_subscribe(MINUTE_UNIT, handleTick); accel_tap_service_subscribe(tapHandler); bluetooth_connection_service_subscribe(&handle_bluetooth); }
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, true)); s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); // msg_layer msg_layer = text_layer_create(GRect(6, 12, bounds.size.w-12, bounds.size.h-24)); text_layer_set_text(msg_layer, "Sent to Phone. Go to the Draw app Settings in the Pebble phone app"); text_layer_set_text_alignment(msg_layer, GTextAlignmentCenter); text_layer_set_font(msg_layer, s_res_gothic_24_bold); text_layer_set_text_color(msg_layer, GColorWhite); text_layer_set_background_color(msg_layer, GColorClear); layer_add_child(root_layer, (Layer *)msg_layer); #ifdef PBL_ROUND text_layer_enable_screen_text_flow_and_paging(msg_layer, 2); #endif }
// callback function for the app initialization void load_retro() { background = layer_create(layer_get_frame(rootLayer)); layer_set_update_proc(background, &background_update_callback); layer_add_child(rootLayer, background); rb46 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_46)); rb22 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_22)); rc10 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_SUBSET_10)); hour_text = text_layer_create(GRect(2, 8 + 4, 68, 68 - 4)); init_text(hour_text, rb46); minute_text = text_layer_create(GRect(74, 8 + 4, 68, 68 - 4)); init_text(minute_text, rb46); day_text = text_layer_create(GRect(2, 92 + 2, 140, 32 - 2)); init_text(day_text, rb22); ampm_text = text_layer_create(GRect(4, 48, 16, 12)); init_text(ampm_text, rc10); date_text = text_layer_create(GRect(dateFormats[dateStyle].dx, 128 + 2, 32, 32 - 2)); init_text(date_text, rb22); month_text = text_layer_create(GRect(dateFormats[dateStyle].mx, 128 + 2, 32, 32 - 2)); init_text(month_text, rb22); year_text = text_layer_create(GRect(dateFormats[dateStyle].yx, 128 + 2, 68, 32 - 2)); init_text(year_text, rb22); layer_add_child(rootLayer, text_layer_get_layer(hour_text)); layer_add_child(rootLayer, text_layer_get_layer(minute_text)); layer_add_child(rootLayer, text_layer_get_layer(day_text)); layer_add_child(rootLayer, text_layer_get_layer(date_text)); layer_add_child(rootLayer, text_layer_get_layer(month_text)); layer_add_child(rootLayer, text_layer_get_layer(year_text)); layer_add_child(rootLayer, text_layer_get_layer(ampm_text)); configRedraw(); display_time(NULL); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); }
void out_sent_handler(DictionaryIterator *sent, void *context) { // outgoing message was delivered APP_LOG(APP_LOG_LEVEL_DEBUG, "Message accepted by phone: %s", command); if (strncmp(command,"set",3) == 0) { if (!hint_layer) { Layer *window_layer = window_get_root_layer(window); hint_layer = text_layer_create(hint_layer_size); text_layer_set_font(hint_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(hint_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(hint_layer)); } if (strlen(command) == 3) strncpy(hint_text, "\nSetting\nreference\nlocation...", sizeof(hint_text)); else if (strlen(command) == 4) snprintf(hint_text, sizeof(hint_text), "Selected\n%s.", locations[command[3] - '0' + 2]); else /* command is set1x */ snprintf(hint_text, sizeof(hint_text), "Selected\n%s.", locations[command[4] - '0' + 12]); text_layer_set_text(hint_layer, hint_text); }; }
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 Joe Pebble!"); text_layer_set_text(text_layer, "Testing 123!"); 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! Joe"); }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); temperature_layer = text_layer_create(GRect(0, 100, 144, 68)); 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) 1), TupletCString(WEATHER_TEMPERATURE_KEY, "Trader Watch"), }; 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)); }
void init() { // Create the Window window = window_create(); // Push to the stack, animated window_stack_push(window, true); // Create the TextLayer, for display at (0, 0), // and with a size of 144 x 40 text_layer = text_layer_create(GRect(0, 0, 144, 40)); // Set the text that the TextLayer will display text_layer_set_text(text_layer, "Hello, Pebble!"); // Add as child layer to be included in rendering layer_add_child( window_get_root_layer(window), text_layer_get_layer(text_layer) ); }
//Window load static void main_window_load(Window *window) { //Bitmap and Bitmap layer s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND); s_background_layer = bitmap_layer_create(GRect(0,0,144,168)); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); layer_add_child(window_get_root_layer(s_main_window), bitmap_layer_get_layer(s_background_layer)); //Time layer s_time_layer = text_layer_create(GRect(5, 52, 139, 50)); //s_time_layer = text_layer_create(GRect(0, 55, 144, 50)); 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_text_alignment(s_time_layer, GTextAlignmentCenter); s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_48)); text_layer_set_font(s_time_layer, s_time_font); //text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); layer_add_child(window_get_root_layer(s_main_window), text_layer_get_layer(s_time_layer)); }
void help_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); int16_t width = bounds.size.w - ACTION_BAR_WIDTH; s_check_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CHECK); s_help_action_bar = action_bar_layer_create(); action_bar_layer_set_icon_animated(s_help_action_bar, BUTTON_ID_SELECT, s_check_bitmap, true); action_bar_layer_set_background_color(s_help_action_bar, GColorElectricUltramarine); action_bar_layer_set_click_config_provider(s_help_action_bar, help_click_config_provider); s_help_layer = text_layer_create(GRect(bounds.origin.x, bounds.origin.y + PBL_IF_ROUND_ELSE(60, 50), width - 5, bounds.size.h)); text_layer_set_text(s_help_layer, PBL_IF_ROUND_ELSE("Example Reminder:\n\n\"Remind me to pick up milk at 5pm\" ", "Example Reminder:\n\n\"Remind me to pick up milk at 5pm\" ")); text_layer_set_font(s_help_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(s_help_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_help_layer)); action_bar_layer_add_to_window(s_help_action_bar, window); }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); //Bitmap Layyer + GBitmap s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ROBOSTANGS_LOGO); s_background_layer = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); bitmap_layer_set_alignment(s_background_layer, GAlignTop); layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer)); //Time layer s_time_layer = text_layer_create(GRect(0, 125, bounds.size.w, 50)); s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BANK_GOTHIC_30)); text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, PBL_IF_BW_ELSE(GColorWhite, GColorChromeYellow)); text_layer_set_font(s_time_layer, s_time_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); }
void create_single_code_screen_elements(Layer **layer, GRect *text_label_rect, GRect *text_pin_rect, TextLayer **text_label_layer) { GRect display_bounds = layer_get_frame(*layer); text_label_rect->origin.x = 0; text_label_rect->origin.y = 150; text_label_rect->size.w = display_bounds.size.w; text_label_rect->size.h = 40; text_pin_rect->origin.x = 0; text_pin_rect->origin.y = 180; text_pin_rect->size.w = display_bounds.size.w; text_pin_rect->size.h = 50; GRect text_label_start = *text_label_rect; text_label_start.origin.x = display_bounds.size.w; *text_label_layer = text_layer_create(text_label_start); text_layer_set_background_color(*text_label_layer, GColorClear); text_layer_set_overflow_mode(*text_label_layer, GTextOverflowModeWordWrap); text_layer_set_text_alignment(*text_label_layer, GTextAlignmentCenter); }
void init_menu_window() { callHistoryIcon = gbitmap_create_with_resource(RESOURCE_ID_CALL_HISTORY); contactsIcon = gbitmap_create_with_resource(RESOURCE_ID_CONTACTS); contactGroupIcon = gbitmap_create_with_resource(RESOURCE_ID_CONTACT_GROUP); menuWindow = window_create(); Layer* topLayer = window_get_root_layer(menuWindow); menuLoadingLayer = text_layer_create(GRect(0, 10, 144, 168 - 16)); text_layer_set_text_alignment(menuLoadingLayer, GTextAlignmentCenter); text_layer_set_text(menuLoadingLayer, "Loading..."); text_layer_set_font(menuLoadingLayer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); layer_add_child(topLayer, (Layer*) menuLoadingLayer); window_set_window_handlers(menuWindow, (WindowHandlers){ .appear = window_load, .unload = window_unload });
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 initialise_ui(void) { s_window = window_create(); window_set_fullscreen(s_window, false); s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); // s_station_name s_station_name = text_layer_create(GRect(0, -7, 144, 29)); text_layer_set_background_color(s_station_name, GColorClear); text_layer_set_text(s_station_name, "Mountain View"); text_layer_set_text_alignment(s_station_name, GTextAlignmentCenter); text_layer_set_font(s_station_name, s_res_gothic_24_bold); layer_add_child(window_get_root_layer(s_window), (Layer *)s_station_name); // s_inverterlayer_2 s_inverterlayer_2 = inverter_layer_create(GRect(0, 0, 145, 21)); layer_add_child(window_get_root_layer(s_window), (Layer *)s_inverterlayer_2); // s_inverterlayer_1 s_inverterlayer_1 = inverter_layer_create(GRect(0, 86, 144, 2)); layer_add_child(window_get_root_layer(s_window), (Layer *)s_inverterlayer_1); }
int main(void) { window = window_create(); window_stack_push(window, true /* Animated */); window_set_click_config_provider(window, (ClickConfigProvider) config_provider); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); text_layer = text_layer_create(bounds); text_layer_set_text(text_layer, "Press the select button to try out different clicks and watch your Bluetooth logs"); text_layer_set_text_color(text_layer, GColorBlack); text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(text_layer)); app_event_loop(); text_layer_destroy(text_layer); window_destroy(window); }
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); // Background Image s_bitmap_layer = bitmap_layer_create(bounds); bitmap_layer_set_compositing_mode(s_bitmap_layer, GCompOpSet); int color = persist_read_int(KEY_GEM_COLOR)? persist_read_int(KEY_GEM_COLOR) : 0; set_background_gem(color); layer_add_child(window_layer, bitmap_layer_get_layer(s_bitmap_layer)); // Time Layout s_time_layer = text_layer_create( GRect(0, PBL_IF_ROUND_ELSE(58, 52), bounds.size.w, 50)); 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_24)); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); }
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(); } } } }
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)); }
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); }
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); }
/************************************ 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_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)); }
void note_init(){ GRect windowBounds = GRect(0, 0, 144, 168); fullWindow = window_create(); Layer* topLayer = window_get_root_layer(fullWindow); fullNoteText = text_layer_create(windowBounds); window_set_background_color(fullWindow, GColorBlue); text_layer_set_background_color(fullNoteText, GColorBlue); text_layer_set_font(fullNoteText, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21)); scroller = scroll_layer_create(windowBounds); scroll_layer_set_click_config_onto_window(scroller, fullWindow); scroll_layer_add_child(scroller, (Layer *) fullNoteText); for (uint16_t i = 0; i < 3000; i++) fullNote[i] = 0; layer_add_child(topLayer, (Layer *) scroller); window_stack_push(fullWindow, true /* Animated */); }
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; }