void handle_init(void) { my_window = window_create(); Layer *window_layer = window_get_root_layer(my_window); GRect bounds = layer_get_bounds(window_layer); time_layer = text_layer_create(bounds); // Size date layer 5/12 of display bounds.size.h = (bounds.size.h * 7) / 12; bounds.origin.y = bounds.size.h; bounds.size.h = (bounds.size.h * 5) / 7; date_layer = text_layer_create(bounds); // Configure layers text_layer_set_background_color(time_layer, GColorBlack); text_layer_set_text_color(time_layer, GColorWhite); text_layer_set_font(time_layer,fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49)); text_layer_set_text_alignment(time_layer, GTextAlignmentRight); text_layer_set_background_color(date_layer, GColorBlack); text_layer_set_text_color(date_layer, GColorWhite); text_layer_set_font(date_layer,fonts_get_system_font(FONT_KEY_GOTHIC_28)); text_layer_set_text_alignment(date_layer, GTextAlignmentRight); // Add layers to window layer_add_child(window_layer, text_layer_get_layer(time_layer)); layer_add_child(window_layer, text_layer_get_layer(date_layer)); window_stack_push(my_window, true); // Respond to taps accel_tap_service_subscribe(tap_handler); // Update window on load and every minute tick_timer_service_subscribe(MINUTE_UNIT, tick_handler); update_time(); }
void weather_layer_set_temperature(WeatherLayer* weather_layer, int16_t t) { memcpy(weather_layer->temp_str, itoa(t), 4); int degree_pos = strlen(weather_layer->temp_str); if (strlen(weather_layer->temp_str) == 1 || (strlen(weather_layer->temp_str) == 2 && weather_layer->temp_str[0] != '1')) { // Don't move temperature if between 0-9° or 20°-99° text_layer_set_font(&weather_layer->temp_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_TEMP_42))); text_layer_set_text_alignment(&weather_layer->temp_layer, GTextAlignmentCenter); memcpy(&weather_layer->temp_str[degree_pos], "°", 3); } else if (strlen(weather_layer->temp_str) == 2 && weather_layer->temp_str[0] == '1') { // Move temperature slightly to the left if between 10°-19° text_layer_set_font(&weather_layer->temp_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_TEMP_42))); text_layer_set_text_alignment(&weather_layer->temp_layer, GTextAlignmentLeft); memcpy(&weather_layer->temp_str[degree_pos], "°", 3); } else if (strlen(weather_layer->temp_str) > 2) { // Shrink font size if above 99° or below -9° text_layer_set_font(&weather_layer->temp_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_TEMP_42))); text_layer_set_text_alignment(&weather_layer->temp_layer, GTextAlignmentCenter); memcpy(&weather_layer->temp_str[degree_pos], "°", 3); } text_layer_set_text(&weather_layer->temp_layer, weather_layer->temp_str); }
// initialize app state based on i_current_stroke. static void init_stroke_layers() { StrokeData *stroke_data = &s_stroke_datas[i_current_stroke]; text_layer_destroy(intro_up_help); text_layer_destroy(intro_select_help); text_layer_destroy(intro_down_help); stroke_image_layer = bitmap_layer_create(GRect(0, 10, 120, 50)); stroke_name_layer = text_layer_create(GRect(0, 65, 120, 30)); stroke_count_layer = text_layer_create(GRect(0, 105, 120, 30)); bitmap_layer_set_bitmap(stroke_image_layer, stroke_data->bitmap); bitmap_layer_set_alignment(stroke_image_layer, GAlignCenter); text_layer_set_text_alignment(stroke_name_layer, GTextAlignmentCenter); text_layer_set_font(stroke_name_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text_alignment(stroke_count_layer, GTextAlignmentCenter); text_layer_set_font(stroke_count_layer, fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK)); layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(stroke_image_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(stroke_name_layer)); layer_add_child(window_get_root_layer(window), text_layer_get_layer(stroke_count_layer)); }
static void main_window_load(Window *window) { // Prepare window properties Layer *window_layer = window_get_root_layer(window); GRect window_bounds = layer_get_bounds(window_layer); // First create the FH logo s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_FHJOANNEUM_LOGO); s_background_layer = bitmap_layer_create(GRect(5, 5, 134, 47)); 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 a text layer for time including font s_time_layer = text_layer_create(GRect(0, 52, window_bounds.size.w, 50)); text_layer_set_background_color(s_time_layer, GColorBlack); text_layer_set_text_color(s_time_layer, GColorClear); s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_42)); 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)); // Create a text layer for the lecture including font s_schedule_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_18)); s_schedule_layer = text_layer_create(GRect(5, 107, window_bounds.size.w-10, window_bounds.size.h - 102)); text_layer_set_background_color(s_schedule_layer, GColorClear); text_layer_set_text_color(s_schedule_layer, GColorBlack); text_layer_set_font(s_schedule_layer, s_schedule_font); text_layer_set_text_alignment(s_schedule_layer, GTextAlignmentLeft); layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_schedule_layer)); text_layer_set_text(s_schedule_layer, "Loading..."); // Begin by updating the time. update_time(); // Load data from storage update_schedule_from_storage(); }
// splash window static void splash_window_load(Window *window) { app_timer_register(1000, (AppTimerCallback) timer_callback, NULL); splash_layer = text_layer_create(GRect(0, 55, 144, 50)); text_layer_set_background_color(splash_layer, GColorClear); text_layer_set_text_color(splash_layer, GColorBlack); text_layer_set_text(splash_layer, "News"); // Improve the layout to be more like a watchface text_layer_set_font(splash_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); text_layer_set_text_alignment(splash_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(splash_layer)); }
static void createPopup() { Layer *window_layer = window_get_root_layer(window); resp_y_layer = text_layer_create(GRect(0,0,144,168)); text_layer_set_text_color(resp_y_layer, GColorClear); text_layer_set_background_color(resp_y_layer, GColorClear); text_layer_set_font(resp_y_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD)); text_layer_set_text_alignment(resp_y_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(resp_y_layer)); // printing promp message to watchface text_layer_set_text(resp_y_layer, " UP->YES Exchange Contact? DOWN->NO"); }
static void main_window_load(Window *window) { APP_LOG(APP_LOG_LEVEL_DEBUG, "window load"); // Create time TextLayer 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); // Improve the layout to be more like a watchface 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_get_root_layer(window), text_layer_get_layer(s_time_layer)); }
void select_long_click_handler(ClickRecognizerRef recognizer, void *context) { //scroll_layer_create(history_scroll, GRect(0, 0, 144, 168)); history_scroll = scroll_layer_create GRect(0,0,144,168); scroll_layer_set_click_config_onto_window(history_scroll, my_window); history_text = text_layer_create(GRect(0, 0, WIDTH, MAX_HEIGHT)); sugar_data_retrieve(size); text_layer_set_background_color(history_text, GColorClear); text_layer_set_text_color(history_text, GColorBlack); text_layer_set_text_alignment(history_text, GTextAlignmentLeft); scroll_layer_set_click_config_onto_window(history_scroll, my_window); scroll_layer_add_child(history_scroll, text_layer_get_layer(history_text)); layer_add_child(window_get_root_layer(my_window), scroll_layer_get_layer(history_scroll)); }
// Load Main Window Layer static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); //bitmap //-- Create GBitmap // s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_SAMPLE_BACKGROUND); //-- Create BitmapLayer to display the GBitmap // s_background_layer = bitmap_layer_create(bounds); //-- Set the bitmap onto the layer and add to the window // bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap); // layer_add_child(window_layer, bitmap_layer_get_layer(s_background_layer)); //background //Create Canvas Layer s_canvas = layer_create(bounds); layer_set_update_proc(s_canvas, layer_update_proc); layer_add_child(window_layer, s_canvas); //time // Create the TextLayer with specific bounds // Set text box position and size s_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(45, 52), bounds.size.w, 85)); // Create GFont and set variable s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HIGHERUP_REG_80)); // 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, TIMECOLOR); 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_layer, text_layer_get_layer(s_time_layer)); //-- // [UNUSED] -- information layer // s_weather_layer = text_layer_create( // GRect(0, PBL_IF_ROUND_ELSE(125, 120), bounds.size.w, 25)); // Style the text // text_layer_set_background_color(s_weather_layer, GColorClear); // text_layer_set_text_color(s_weather_layer, GColorBlack); // text_layer_set_text_alignment(s_weather_layer, GTextAlignmentCenter); // text_layer_set_text(s_weather_layer, "Loading..."); // Create second custom font, apply it and add to Window // s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_DBJ_REGULAR_20)); // text_layer_set_font(s_weather_layer, s_weather_font); // layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer)); }
static void initialise_ui(void) { s_window = window_create(); window_set_background_color(s_window, GColorBlack); #ifndef PBL_SDK_3 window_set_fullscreen(s_window, true); #endif s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD); // StationLayer StationLayer = text_layer_create(GRect(0, 10, 144, 20)); text_layer_set_background_color(StationLayer, GColorClear); text_layer_set_text_color(StationLayer, GColorWhite); text_layer_set_text(StationLayer, "Robert Street Station"); text_layer_set_text_alignment(StationLayer, GTextAlignmentCenter); text_layer_set_font(StationLayer, s_res_gothic_18_bold); layer_add_child(window_get_root_layer(s_window), (Layer *)StationLayer); // EastLabelLayer EastLabelLayer = text_layer_create(GRect(2, 36, 15, 28)); text_layer_set_background_color(EastLabelLayer, GColorClear); text_layer_set_text_color(EastLabelLayer, GColorWhite); text_layer_set_text(EastLabelLayer, "E:"); text_layer_set_font(EastLabelLayer, s_res_gothic_24_bold); layer_add_child(window_get_root_layer(s_window), (Layer *)EastLabelLayer); // EastLayer EastLayer = text_layer_create(GRect(20, 36, 120, 28)); text_layer_set_background_color(EastLayer, GColorClear); text_layer_set_text_color(EastLayer, GColorWhite); text_layer_set_font(EastLayer, s_res_gothic_24_bold); layer_add_child(window_get_root_layer(s_window), (Layer *)EastLayer); // WestLayer WestLayer = text_layer_create(GRect(20, 64, 123, 28)); text_layer_set_background_color(WestLayer, GColorClear); text_layer_set_text_color(WestLayer, GColorWhite); text_layer_set_font(WestLayer, s_res_gothic_24_bold); layer_add_child(window_get_root_layer(s_window), (Layer *)WestLayer); // WestLabelLayer WestLabelLayer = text_layer_create(GRect(2, 64, 15, 28)); text_layer_set_background_color(WestLabelLayer, GColorClear); text_layer_set_text_color(WestLabelLayer, GColorWhite); text_layer_set_text(WestLabelLayer, "W:"); text_layer_set_font(WestLabelLayer, s_res_gothic_24_bold); layer_add_child(window_get_root_layer(s_window), (Layer *)WestLabelLayer); }
static void initialise_ui(void) { s_main_window = window_create(); #ifdef PBL_COLOR window_set_background_color(s_main_window, GColorCeleste); #endif // Loading fonts s_res_gothic_24 = fonts_get_system_font(FONT_KEY_GOTHIC_24); // Initialising labels s_textlayer_label_nearby_hotties = text_layer_create(GRect(5, 5, 134 - ACTION_BAR_WIDTH, 158)); text_layer_set_text(s_textlayer_label_nearby_hotties, "Checking for hotties in your area. Please wait..."); text_layer_set_text_alignment(s_textlayer_label_nearby_hotties, GTextAlignmentLeft); text_layer_set_font(s_textlayer_label_nearby_hotties, s_res_gothic_24); layer_add_child(window_get_root_layer(s_main_window), (Layer *)s_textlayer_label_nearby_hotties); }
void handle_init(AppContextRef ctx) { (void)ctx; myContext = ctx; window_init(&window, "Timer"); window_stack_push(&window, true /* Animated */); text_layer_init(&textLayer, window.layer.frame); text_layer_set_font(&textLayer, fonts_get_system_font(FONT_KEY_GOTHAM_42_BOLD)); text_layer_set_text_alignment(&textLayer, GTextAlignmentCenter); layer_add_child(&window.layer, &textLayer.layer); // Start in the SET state enter_set_state(); }
void time_load( const Window *window_ptr, const GPoint point ) { Time_layer = text_layer_create( GRect( point.x, point.y, 144 - point.x, 34 ) ); text_layer_set_background_color( Time_layer, GColorClear ); #ifdef PBL_COLOR text_layer_set_text_color( Time_layer, GColorBlack ); #else text_layer_set_text_color( Time_layer, GColorBlack ); #endif Time_font = fonts_load_custom_font( resource_get_handle( RESOURCE_ID_FONT_DIGITAL_32 ) ); // text_layer_set_font( Time_layer, fonts_get_system_font( FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM ) ); text_layer_set_font( Time_layer, Time_font ); layer_add_child( window_get_root_layer( window_ptr ), text_layer_get_layer( Time_layer ) ); // text_layer_set_text_alignment( Time_layer, GTextAlignmentLeft ); text_layer_set_text_alignment( Time_layer, GTextAlignmentCenter ); }
void handle_init(AppContextRef ctx) { (void)ctx; window_init(&window, "Logging Demo"); text_layer_init(&text, GRect(0, 0, 144, 150)); text_layer_set_text_color(&text, GColorBlack); text_layer_set_font(&text, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(&text, GTextAlignmentCenter); text_layer_set_text(&text, "Press the select button to try out different clicks and watch your Bluetooth logs"); layer_add_child(&window.layer, &text.layer); window_set_click_config_provider(&window, (ClickConfigProvider) config_provider); window_stack_push(&window, true /* Animated */); }
// defining init and deinit void init() { // creating the text layer in the init window = window_create(); text_layer = text_layer_create(GRect(0, 0, 144, 40)); text_layer_set_text(text_layer, "Pebble"); // horizontal alignment // See https://developer.getpebble.com/docs/c/User_Interface/Layers/TextLayer/#text_layer_set_text_alignment text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); // vertical alignment // See https://forums.getpebble.com/discussion/12492/vertical-text-alignment // not implemented yet layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layer)); window_stack_push(window, true); }
static void init(void) { window = window_create(); window_stack_push(window, true /* Animated */); window_set_background_color(window, GColorBlack); text_time_layer = text_layer_create(UPPER_TO_RECT); text_layer_set_text_color(text_time_layer, GColorWhite); text_layer_set_background_color(text_time_layer, GColorClear); text_layer_set_text_alignment(text_time_layer, GTextAlignmentCenter); text_layer_set_font(text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_CONDENSED_SUBSET_40))); layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_time_layer)); init_animations(); tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick); }
static void main_window_load(Window *window) { // Create time TextLayer //s_time_layer = text_layer_create(GRect(0, 120, 144, 30)); s_time_layer = text_layer_create(GRect(0, 69, 144, 30)); text_layer_set_background_color(s_time_layer, GColorBlack); text_layer_set_text_color(s_time_layer, GColorClear); // Improve the layout to be more like a watchface text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); 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)); update_time(); }
void initializeYBattery() { // Create day TextLayer s_battery_layer = text_layer_create(GRect(84, 88, 80, 30)); text_layer_set_background_color(s_battery_layer, GColorWhite); text_layer_set_text_color(s_battery_layer, GColorBlack); // Improve the day TextLayer layout text_layer_set_font(s_battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text_alignment(s_battery_layer, GTextAlignmentLeft); // Get the current battery level battery_handler(battery_state_service_peek()); // Subscribe to the Battery State Service battery_state_service_subscribe(battery_handler); }
static void init_clock(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); time_layer = text_layer_create(GRect(0, 20, bounds.size.w, bounds.size.h-100)); text_layer_set_text_alignment(time_layer, GTextAlignmentCenter); text_layer_set_text_color(time_layer, GColorWhite); text_layer_set_background_color(time_layer, GColorClear); text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT)); time_t now = time(NULL); struct tm *current_time = localtime(&now); handle_second_tick(current_time, SECOND_UNIT); tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick); layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer)); }
// Handle the start-up of the app void handle_init(AppContextRef app_ctx) { // Create our app's base window window_init(&window, "Peanut Butter Jelly Time"); window_stack_push(&window, true); window_set_background_color(&window, GColorBlack); GFont font_date; resource_init_current_app(&APP_RESOURCES); font_date = fonts_get_system_font(FONT_KEY_GOTHIC_14); // Set up a layer for the static watch face background bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container); layer_add_child(&window.layer, &background_image_container.layer.layer); // Set up a layer for the hour hand rotbmp_pair_init_container(RESOURCE_ID_IMAGE_HOUR_HAND_WHITE, RESOURCE_ID_IMAGE_HOUR_HAND_BLACK, &hour_hand_image_container); rotbmp_pair_layer_set_src_ic(&hour_hand_image_container.layer, GPoint(33, 40)); layer_add_child(&window.layer, &hour_hand_image_container.layer.layer); // Set up a layer for the minute hand rotbmp_pair_init_container(RESOURCE_ID_IMAGE_MINUTE_HAND_WHITE, RESOURCE_ID_IMAGE_MINUTE_HAND_BLACK, &minute_hand_image_container); rotbmp_pair_layer_set_src_ic(&minute_hand_image_container.layer, GPoint(16, 60)); layer_add_child(&window.layer, &minute_hand_image_container.layer.layer); // Set up a layer for the date text_layer_init(&text_date_layer, window.layer.frame); text_layer_set_text_color(&text_date_layer, GColorWhite); text_layer_set_background_color(&text_date_layer, GColorClear); layer_set_frame(&text_date_layer.layer, GRect(8, 152, 144-8, 168-92)); text_layer_set_font(&text_date_layer, font_date); text_layer_set_text_alignment(&text_date_layer,GTextAlignmentCenter); layer_add_child(&window.layer, &text_date_layer.layer); PblTm t; get_time(&t); update_watch(&t); last_wday = -1; }
static TextLayer* make_text_layer(int x_inset, int y_inset, char *font_key) { Layer *window_layer = window_get_root_layer(s_window); GRect bounds = layer_get_bounds(window_layer); TextLayer *this = text_layer_create(grect_inset(bounds, GEdgeInsets(y_inset, 0, 0, x_inset))); text_layer_set_text_alignment(this, GTextAlignmentCenter); text_layer_set_text_color(this, GColorWhite); text_layer_set_background_color(this, GColorClear); text_layer_set_font(this, fonts_get_system_font(font_key)); #if defined(PBL_ROUND) text_layer_enable_screen_text_flow_and_paging(this, 5); #endif return this; }
void InitializeConfirmationWindow(Window *window, TextLayer *exitText, TextLayer *yesText, TextLayer *noText) { InitializeWindow(window, "Exit", true); InitializeTextLayer(exitText, exitFrame, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_text(exitText, "Exit?"); text_layer_set_text_alignment(exitText, GTextAlignmentCenter); layer_add_child(&window->layer, &exitText->layer); InitializeTextLayer(yesText, yesFrame, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text(yesText, "Yes"); layer_add_child(&window->layer, &yesText->layer); InitializeTextLayer(noText, noFrame, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); text_layer_set_text(noText, "No"); layer_add_child(&window->layer, &noText->layer); }
void out_failed_handler(DictionaryIterator *failed, AppMessageResult reason, void *context) { // outgoing message failed APP_LOG(APP_LOG_LEVEL_WARNING, "\nMessage rejected by phone: %s %d", command, reason); if (reason == APP_MSG_SEND_TIMEOUT) { 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)); } text_layer_set_text(hint_layer, "Cannot set target.\nPlease restart the app."); vibes_double_pulse(); }; } }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); header_layer = text_layer_create(GRect(0, 0, 144, 40)); text_layer_set_font(header_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); text_layer_set_text_alignment(header_layer, GTextAlignmentCenter); text_layer_set_text_color(header_layer, GColorBlack); text_layer_set_background_color(header_layer, GColorClear); text_layer_set_text(header_layer, "BariBucks"); layer_add_child(window_layer, text_layer_get_layer(header_layer)); main_menu_layer = menu_layer_create(GRect(0, 40, 144, 113)); menu_layer_set_callbacks(main_menu_layer, NULL, (MenuLayerCallbacks) { .get_num_rows = menu_get_num_rows_callback, .draw_row = menu_draw_row_callback, .select_click = menu_select_callback, //the .(after the dot) is predefined });
static void main_window_load(Window *window) { // Create time TextLayer 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"); // Improve the layout to be more like a watchface 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_get_root_layer(window), text_layer_get_layer(s_time_layer)); // Make sure the time is displayed from the start update_time(); }
static void set_up_time_text(Layer *window_layer, GRect bounds) { // screen resolution (classic) 144×168 s_time_layer = text_layer_create( GRect( 0, // x from left 5, // y from top bounds.size.w, // width 30 // height ) ); 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_30_BLACK)); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); }
static void initialise_ui(void) { s_window = window_create(); window_set_background_color(s_window, GColorBlack); IF_A(window_set_fullscreen(s_window, true)); s_res_img_standby = gbitmap_create_with_resource(RESOURCE_ID_IMG_STANDBY); s_res_img_settings = gbitmap_create_with_resource(RESOURCE_ID_IMG_SETTINGS); s_res_roboto_bold_subset_49 = fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49); s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD); // 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_standby); action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_settings); layer_set_frame(action_bar_layer_get_layer(action_layer), GRect(124, 0, 20, 168)); IF_B(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); // clockbg_layer clockbg_layer = text_layer_create(GRect(0, 60, 144, 50)); text_layer_set_background_color(clockbg_layer, GColorBlack); text_layer_set_text_color(clockbg_layer, GColorClear); text_layer_set_text(clockbg_layer, " "); layer_add_child(window_get_root_layer(s_window), (Layer *)clockbg_layer); // clock_layer clock_layer = text_layer_create(GRect(0, 52, 144, 65)); text_layer_set_background_color(clock_layer, GColorClear); text_layer_set_text_color(clock_layer, GColorWhite); text_layer_set_text(clock_layer, "23:55"); text_layer_set_text_alignment(clock_layer, GTextAlignmentCenter); text_layer_set_font(clock_layer, s_res_roboto_bold_subset_49); layer_add_child(window_get_root_layer(s_window), (Layer *)clock_layer); // onoff_layer onoff_layer = text_layer_create(GRect(2, 2, 119, 56)); layer_set_update_proc(text_layer_get_layer(onoff_layer), draw_onoff); layer_add_child(window_get_root_layer(s_window), (Layer *)onoff_layer); // info_layer info_layer = text_layer_create(GRect(2, 110, 119, 56)); layer_set_update_proc(text_layer_get_layer(info_layer), draw_info); layer_add_child(window_get_root_layer(s_window), (Layer *)info_layer); }
static void main_window_load(Window *window) { // Create GBitmap, then set to created BitmapLayer s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_fatface_15)); // Create temperature Layer s_weather_layer = text_layer_create(GRect(4, 20, 136,150 )); text_layer_set_font(s_weather_layer, s_time_font); text_layer_set_background_color(s_weather_layer, GColorWhite); text_layer_set_text_color(s_weather_layer, GColorBlack); text_layer_set_text_alignment(s_weather_layer, GTextAlignmentCenter); text_layer_set_text(s_weather_layer, "Click for insult"); // Create time TextLayer layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_weather_layer)); //time layer }
static void window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); image = gbitmap_create_with_data(data_image); image_layer = bitmap_layer_create(bounds); bitmap_layer_set_bitmap(image_layer, image); bitmap_layer_set_alignment(image_layer, GAlignCenter); layer_add_child(window_layer, bitmap_layer_get_layer(image_layer)); text_layer = text_layer_create(GRect(0, bounds.size.h - 16, bounds.size.w, 16)); text_layer_set_text(text_layer, "Welcome to PayFace $)"); text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); text_layer_set_background_color(text_layer, GColorClear); layer_add_child(window_layer, text_layer_get_layer(text_layer)); }
// Show loading screen static void show_loading_icon(void) { Layer *window_layer = window_get_root_layer(s_window); GRect bounds = layer_get_frame(window_layer); loading_icon_layer = bitmap_layer_create(GRect(0, 0, bounds.size.w, bounds.size.h)); bitmap_layer_set_background_color(loading_icon_layer, GColorBlack); layer_add_child(window_layer, bitmap_layer_get_layer(loading_icon_layer)); text_layer = text_layer_create(GRect(0, 60, bounds.size.w, 30)); text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); text_layer_set_overflow_mode(text_layer, GTextOverflowModeWordWrap); text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD)); text_layer_set_background_color(text_layer, GColorBlack); text_layer_set_text_color(text_layer, GColorWhite); text_layer_set_text(text_layer, "Loading..."); layer_add_child(window_layer, text_layer_get_layer(text_layer)); }