• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PBL_IF_ROUND_ELSE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PBL_IF_ROUND_ELSE函数的典型用法代码示例。如果您正苦于以下问题:C++ PBL_IF_ROUND_ELSE函数的具体用法?C++ PBL_IF_ROUND_ELSE怎么用?C++ PBL_IF_ROUND_ELSE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PBL_IF_ROUND_ELSE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main_window_load

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

  s_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(61, 55), bounds.size.w, 50));  
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text(s_time_layer, "00:00");
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
  
  s_step_count_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(45, 40), bounds.size.w, 40));
  text_layer_set_text_alignment(s_step_count_layer, GTextAlignmentCenter);
  text_layer_set_background_color(s_step_count_layer, GColorClear);
  layer_add_child(window_layer, text_layer_get_layer(s_step_count_layer));
  
  s_dayt_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(106, 100), bounds.size.w, 40));
  text_layer_set_text_alignment(s_dayt_layer, GTextAlignmentCenter);
  text_layer_set_background_color(s_dayt_layer, GColorClear);
  layer_add_child(window_layer, text_layer_get_layer(s_dayt_layer));
  
  setLayerTextColors();
  setLayerFonts();
  
  s_canvas_layer = layer_create(bounds);
  layer_set_update_proc(s_canvas_layer, draw_proc);
  layer_add_child(window_layer, s_canvas_layer);
}
开发者ID:gerryk,项目名称:ActiveHour,代码行数:27,代码来源:main.c


示例2: text_phrase_layer_load

void text_phrase_layer_load(Window* window) {
  
  // Let's go get the bounds of the window first.
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  
  // Here's the coordinates for the textLayer.
  GRect text_location = GRect( PBL_IF_ROUND_ELSE(0, 0),
                              PBL_IF_ROUND_ELSE(bounds.size.h / 2 - RECT_MASTER_SIZE, bounds.size.h - RECT_MASTER_SIZE),
                              PBL_IF_ROUND_ELSE(170, 14*5), 
                              PBL_IF_ROUND_ELSE(PHRASE_TEXT_FONT_SIZE_R,PHRASE_TEXT_FONT_SIZE*2 + PHRASE_TEXT_FONT_SIZE/2));
  
  // Load custom font.
  font_moji = fonts_load_custom_font(
              resource_get_handle(PBL_IF_ROUND_ELSE(RESOURCE_ID_FONT_SHORTMOJI_18,RESOURCE_ID_FONT_SHORTMOJI_14)));
  
  
  // We declare the text layer into existence.
  // Settings to make the text layer look pretty.
  text_phrase_layer = text_layer_create(text_location);
  text_layer_set_text_color(text_phrase_layer, get_idol_main_color());
  text_layer_set_background_color(text_phrase_layer, GColorClear);
  text_layer_set_overflow_mode(text_phrase_layer, GTextOverflowModeWordWrap);
  text_layer_set_text_alignment(text_phrase_layer, GTextAlignmentCenter);
  text_layer_set_font(text_phrase_layer, font_moji);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_phrase_layer)); 
  
  // If we disable tapping events, the talking bubble will be visible
  // no matter what. But if tapping is enabled, then this is hidden by default.
  if(!is_tapping_disabled()) {
    set_text_phrase_layer_hidden(true);
  }
  
}
开发者ID:starrodkirby86,项目名称:llsiw,代码行数:34,代码来源:text_phrase_layer.c


示例3: main_window_load

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(PBL_IF_ROUND_ELSE(32, 28), PBL_IF_ROUND_ELSE(65, 60), bounds.size.w, 60));
  
  // 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, GColorWhite);
  text_layer_set_text(s_time_layer, "00:00");
  text_layer_set_font(s_time_layer, fonts_get_system_font(PBL_IF_ROUND_ELSE(FONT_KEY_LECO_32_BOLD_NUMBERS, FONT_KEY_LECO_26_BOLD_NUMBERS_AM_PM)));
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  

  
  // Add to Window 
  s_bitmap = gbitmap_create_with_resource(PBL_IF_ROUND_ELSE(RESOURCE_ID_TORI, RESOURCE_ID_TORIS));
  s_bitmap_layer = bitmap_layer_create(bounds);
  bitmap_layer_set_background_color(s_bitmap_layer, GColorTiffanyBlue);
  bitmap_layer_set_bitmap(s_bitmap_layer, s_bitmap);
  bitmap_layer_set_compositing_mode(s_bitmap_layer, GCompOpSet);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_bitmap_layer));
  
  
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));

}
开发者ID:mario-kada,项目名称:toriwatch,代码行数:31,代码来源:main.c


示例4: window_load

static void window_load(Window *window) {
    Layer *window_layer = window_get_root_layer(window);
    GRect bounds = layer_get_bounds(window_layer);

    s_title_layer = stats_window_common_create_title(bounds,  "SETS DURATION");
    
    s_scroll_layer = scroll_layer_create(bounds);
    scroll_layer_set_click_config_onto_window(s_scroll_layer, window);
    scroll_layer_set_content_size(s_scroll_layer, GSize(bounds.size.w, bounds.size.h * 1.7));
    
    scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_title_layer));

    MatchStatistics score_detail= match_statistics_get();

    // score_detail.set_duration[0] = 45* 60;
    // score_detail.set_duration[1] = 53 * 60;
    // score_detail.set_duration[2] = 33 * 60;
    // score_detail.set_duration[3] = 62 * 60;
    // score_detail.set_duration[4] = 39 * 60;    

    int start_from_y =PBL_IF_ROUND_ELSE(40, 30);

    int box_h = 40;
    float every_y = box_h +2;

    for (int i = 0; i < 5; ++i)
    {
        int hours = score_detail.set_duration[i] / 3600;
        int minutes = (score_detail.set_duration[i] / 60) % 60; 
        int seconds = score_detail.set_duration[i] % 60;        
        
        snprintf(buffer_sets_time[i], sizeof(buffer_sets_time[i]), "%.2d:%.2d:%.2d\n", hours, minutes, seconds);
        
        APP_LOG(APP_LOG_LEVEL_DEBUG, "*** window_load  *** set %d lasted %d seconds", 
            i, (int)score_detail.set_duration[i]);

        int padding = PBL_IF_ROUND_ELSE(64, 28);
        int box_x = padding / 2 ;
        int box_w = bounds.size.w - padding;
        s_sets_time_layer[i] = stats_window_common_create_layer(
            GRect(
                box_x, start_from_y + (i * every_y),
                box_w, box_h), 
            buffer_sets_time[i]);

        
        int num_x = PBL_IF_ROUND_ELSE(18, 2);;
        int num_y = start_from_y + (i * every_y) + (box_h / 4);        
        snprintf(buffer_sets_num[i], sizeof(buffer_sets_num[i]), "%d\n", i + 1);
        s_sets_num_layer[i] =create_set_num_layer(GRect(num_x, num_y, 13, 20), buffer_sets_num[i]);

        scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_sets_time_layer[i]));
        scroll_layer_add_child(s_scroll_layer, text_layer_get_layer(s_sets_num_layer[i]));
        layer_add_child(window_layer, scroll_layer_get_layer(s_scroll_layer));
    }
}
开发者ID:gborobio73,项目名称:tennis-poc-menu-c,代码行数:56,代码来源:stats_sets_time_window.c


示例5: bg_update_proc

static void bg_update_proc(Layer *layer, GContext *ctx) {
  graphics_context_set_fill_color(ctx, s_backColor);
  graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
  graphics_context_set_fill_color(ctx, s_textColor);
  for (int i = 0; i < NUM_CLOCK_TICKS; ++i) {
    const int x_offset = PBL_IF_ROUND_ELSE(18, 0);
    const int y_offset = PBL_IF_ROUND_ELSE(6, 0);
    gpath_move_to(s_tick_paths[i], GPoint(x_offset, y_offset));
    gpath_draw_filled(ctx, s_tick_paths[i]);
  }
}
开发者ID:bake-san,项目名称:ANALOG-P-SHOCK,代码行数:11,代码来源:simple_analog.c


示例6: main_window_load

static void main_window_load(Window *window) {

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


  s_battery_layer = text_layer_create(PBL_IF_ROUND_ELSE(
    GRect(38, 12, bounds.size.w-76, 32),
    GRect(8, 6, bounds.size.w-16, 32)));
  text_layer_set_text_color(s_battery_layer, GColorBlack);
  text_layer_set_background_color(s_battery_layer, GColorClear);
  text_layer_set_font(s_battery_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text_alignment(s_battery_layer, GTextAlignmentRight);
  text_layer_set_text(s_battery_layer, "100%");

  s_date_layer = text_layer_create(PBL_IF_ROUND_ELSE(
    GRect(38, 12, bounds.size.w-76, 32),
    GRect(8, 6, bounds.size.w-16, 32)));
  text_layer_set_text_color(s_date_layer, GColorBlack);
  text_layer_set_background_color(s_date_layer, GColorClear);
  text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text_alignment(s_date_layer, GTextAlignmentLeft);
  text_layer_set_text(s_date_layer, "Jan 1");

  s_time_layer = text_layer_create(GRect(0, 48, bounds.size.w, 56));
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_background_color(s_time_layer, GColorMidnightGreen);
  text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_LECO_42_NUMBERS));
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);

  s_steps_layer = text_layer_create(GRect(0, 100, bounds.size.w, 32));
  text_layer_set_text_color(s_steps_layer, GColorBlack);
  text_layer_set_background_color(s_steps_layer, GColorCadetBlue);
  text_layer_set_font(s_steps_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text_alignment(s_steps_layer, GTextAlignmentCenter);
  text_layer_set_text(s_steps_layer, "0 steps");

  s_connection_layer = text_layer_create(GRect(0, 136, bounds.size.w, 20));
  text_layer_set_text_color(s_connection_layer, GColorBlack);
  text_layer_set_background_color(s_connection_layer, GColorClear);
  text_layer_set_font(s_connection_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
  text_layer_set_text_alignment(s_connection_layer, GTextAlignmentCenter);
  handle_bluetooth(connection_service_peek_pebble_app_connection());

  time_t now = time(NULL);
  struct tm *current_time = localtime(&now);
  handle_minute_tick(current_time, MINUTE_UNIT);

  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
  battery_state_service_subscribe(handle_battery);

  connection_service_subscribe((ConnectionHandlers) {
    .pebble_app_connection_handler = handle_bluetooth
  });
开发者ID:csiebler,项目名称:pebble-simplr2,代码行数:54,代码来源:simplr2.c


示例7: prv_date_layer_update_proc

static void prv_date_layer_update_proc(Layer *layer, GContext *ctx) {
  const SprinklesConfiguration *configuration = sprinkles_configuration_get_configuration();
  if (!configuration->date_enabled) {
    return;
  }

  const GRect layer_bounds = layer_get_bounds(layer);
  GRect date_rect = (GRect) { .size = GSize(24, layer_bounds.size.h) };
  grect_align(&date_rect, &layer_bounds, GAlignCenter, true /* clip */);

  graphics_context_set_fill_color(ctx, configuration->date_background_color);
  graphics_fill_rect(ctx, date_rect, 3, GCornersAll);

  // Push the date_rect up a little bit to account for the font cap offset
  date_rect.origin.y -= 4;

  graphics_context_set_text_color(ctx, configuration->date_text_color);
  const GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  char date_string[3] = {0};
  const time_t current_time = time(NULL);
  struct tm *current_time_tm = localtime(&current_time);
  strftime(date_string, ARRAY_LENGTH(date_string), "%d", current_time_tm);
  graphics_draw_text(ctx, date_string, font, date_rect, GTextOverflowModeTrailingEllipsis,
                     GTextAlignmentCenter, NULL);
}

static void prv_homer_eyes_layer_update_proc(Layer *layer, GContext *ctx) {
  const GRect layer_bounds = layer_get_bounds(layer);

  const GPoint donut_orbit_perimeter_point = prv_get_donut_orbit_perimeter_point(&layer_bounds);

  const GEdgeInsets eye_rect_insets = GEdgeInsets(1);

  const GRect right_eye_rect = grect_inset(PBL_IF_ROUND_ELSE(GRect(53, 49, 33, 33),
                                                             GRect(52, 45, 35, 32)),
                                           eye_rect_insets);
  prv_draw_pupil(ctx, &right_eye_rect, &donut_orbit_perimeter_point);

  const GRect left_eye_rect = grect_inset(PBL_IF_ROUND_ELSE(GRect(22, 48, 32, 31),
                                                            GRect(22, 45, 32, 29)),
                                          eye_rect_insets);
  prv_draw_pupil(ctx, &left_eye_rect, &donut_orbit_perimeter_point);
}

static void prv_tick_timer_service_handler(struct tm *tick_time, TimeUnits units_changed) {
  s_app_data->current_hours = tick_time->tm_hour;
  s_app_data->current_minutes = tick_time->tm_min;
  s_app_data->current_seconds = tick_time->tm_sec;
  layer_mark_dirty(s_app_data->homer_eyes_layer);
  layer_mark_dirty(s_app_data->hands_layer);
}
开发者ID:gregoiresage,项目名称:sprinkles,代码行数:51,代码来源:sprinkles.c


示例8: main_window_load

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 GBitmap
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_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));


  // Create the TextLayer with specific bounds
  s_time_layer = text_layer_create(
      GRect(3, PBL_IF_ROUND_ELSE(58, 50), 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);

  // Create GFont
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_48));

  // Apply to TextLayer
  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));

  // Create temperature 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, GColorWhite);
  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_FONT_PERFECT_DOS_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));

}
开发者ID:satblip,项目名称:satface,代码行数:50,代码来源:main.c


示例9: main_window_load

/* Window handler */
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);
  GPoint center = grect_center_point(&bounds);

  // init hand paths
  s_minute_arrow = gpath_create(&MINUTE_HAND_POINTS);
  s_hour_arrow = gpath_create(&HOUR_HAND_POINTS);
  gpath_move_to(s_minute_arrow, center);
  gpath_move_to(s_hour_arrow, center);


  // background all black
  s_bg_layer = layer_create(bounds);
  layer_set_update_proc(s_bg_layer, bg_update_proc);  
  layer_add_child(window_layer, s_bg_layer);
  
  s_draw_layer = layer_create(bounds);
  layer_set_update_proc(s_draw_layer, hands_update_proc);  
  
  s_time_layer = text_layer_create(PBL_IF_ROUND_ELSE(
    GRect(63, center.y / 2 - 15, 56, 20),
    GRect(46, center.y / 2 - 15, 56, 20)));  
  
  text_layer_set_background_color(s_time_layer, GColorBlack);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  

  
  layer_add_child(window_layer, s_draw_layer);
  layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
  // register timetick handler
  tick_timer_service_subscribe(SECOND_UNIT, tick_handler);
  //s_app_timer = app_timer_register(TIMER_INTERVALL,app_timer_handler,window);

  Layer *batteryLayer = init_battery_watcher(GRect(PBL_IF_ROUND_ELSE(30,1), PBL_IF_ROUND_ELSE(19,5), 35, 20));
  if (batteryLayer != NULL) {
    layer_add_child(window_layer, batteryLayer);
  }


  Layer *btLayer = init_bluetooth_layer(GRect(120, 5, 24,24));
  if (btLayer != NULL) {
    layer_add_child(window_layer, btLayer);  
  }
  

}
开发者ID:deicon,项目名称:RoundWatchFace,代码行数:51,代码来源:WatchFace.c


示例10: main_window_load

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 GBitmap
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BG_ONE);

  // 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));
  */
  
  
  // Create the TextLayer with specific bounds
  s_time_layer = text_layer_create(
      GRect(0, PBL_IF_ROUND_ELSE(43, 40), bounds.size.w, 55));
  s_date_layer = text_layer_create(
      GRect(0, PBL_IF_ROUND_ELSE(103, 97), bounds.size.w, 30));
  
  // Improve the layout to be more like a watchface
  text_layer_set_background_color(s_time_layer, GColorDarkGray);
  // text_layer_set_background_color(s_time_layer, GColorMidnightGreen);
  // text_layer_set_text_color(s_time_layer, GColorBlack);
  text_layer_set_text_color(s_time_layer, GColorWhite); 
  // Create time GFont
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CUSTOM_ONE_50));
  text_layer_set_font(s_time_layer, s_time_font);
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  
  // Creative date GFont
  text_layer_set_background_color(s_date_layer, GColorDarkGray);
  text_layer_set_text_color(s_date_layer, GColorWhite); 
  s_date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CUSTOM_ONE_20));
  text_layer_set_font(s_date_layer, s_date_font);
  text_layer_set_text_alignment(s_date_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));
  layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
  
  // Register with TickTimerService
  tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
  tick_timer_service_subscribe(DAY_UNIT, tick_date_handler);
}
开发者ID:ggtx,项目名称:PebbleFace,代码行数:48,代码来源:main.c


示例11: window_load

static void window_load(Window *window) {    
    Layer *window_layer = window_get_root_layer(window);
    
    s_title_layer = stats_window_common_create_and_add_title(window,  "MATCH DURATION");

    GRect bounds = layer_get_bounds(window_layer);

    MatchDuration match_time = match_statistics_calculate_match_duration();
    static char match_time_buffer [9];
    snprintf(match_time_buffer, sizeof(match_time_buffer), "%.2d:%.2d:%.2d\n", 
        match_time.hours, match_time.minutes, match_time.seconds);
    // snprintf(match_time_buffer, sizeof(match_time_buffer), "%.2d:%.2d:%.2d\n", 
    //     4, 27, 35);

    int padding = PBL_IF_ROUND_ELSE(64, 28);
    int box_x = padding / 2 ;
    int box_w = bounds.size.w - padding;
    int box_h = 40;

    s_match_time_layer = stats_window_common_create_and_add_layer(
            window,
            GRect(
                box_x, (bounds.size.h / 2) - (box_h / 2),
                box_w, box_h), 
            match_time_buffer);

}
开发者ID:gborobio73,项目名称:tennis-poc-menu-c,代码行数:27,代码来源:stats_time_window.c


示例12: init_sliding_row

static void init_sliding_row(SlidingTextData *data, SlidingRow *row, GRect pos, GFont font,
        int delay) {
  row->label = text_layer_create(pos);
  text_layer_set_text_alignment(row->label, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft));
  text_layer_set_background_color(row->label, GColorClear);
  text_layer_set_text_color(row->label, GColorWhite);
  if (font) {
    text_layer_set_font(row->label, font);
    row->unchanged_font = true;
  } else {
    row->unchanged_font = false;
  }

  row->state = IN_FRAME;
  row->next_string = NULL;

  row->left_pos = -pos.size.w;
  row->right_pos = pos.size.w;
  row->still_pos = pos.origin.x;

  row->movement_delay = delay;
  row->delay_count = 0;

  data->last_hour = -1;
  data->last_minute = -1;
}
开发者ID:chris838,项目名称:sliding-text,代码行数:26,代码来源:sliding_text.c


示例13: main_window_load

static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  
  s_count_back_layer = text_layer_create(bounds);
  text_layer_set_background_color(s_count_back_layer, GColorBlack);
  layer_add_child(window_layer, text_layer_get_layer(s_count_back_layer));
  
  s_count_data_layer = text_layer_create(GRect(0, bounds.size.h / 2 - 28, bounds.size.w, 28));
  text_layer_set_background_color(s_count_data_layer, GColorClear);
  text_layer_set_font(s_count_data_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_text_color(s_count_data_layer, GColorWhite);
  text_layer_set_text_alignment(s_count_data_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(s_count_data_layer));

  s_count_above_layer = text_layer_create(GRect(bounds.size.w / 2 - PBL_IF_ROUND_ELSE(60, 57), bounds.size.h / 2 - 60, bounds.size.w - PBL_IF_ROUND_ELSE(30, 15), 30));
  format_text_layer(s_count_above_layer, GTextAlignmentLeft);
  text_layer_set_text(s_count_above_layer, "it has been");
  layer_add_child(window_layer, text_layer_get_layer(s_count_above_layer));
  
  s_count_below_layer = text_layer_create(GRect(0, bounds.size.h / 2 + 8, bounds.size.w - PBL_IF_ROUND_ELSE(30, 15), 48));
  format_text_layer(s_count_below_layer, GTextAlignmentRight);
  text_layer_set_text(s_count_below_layer, "since you last\nsaw the time");
  layer_add_child(window_layer, text_layer_get_layer(s_count_below_layer));

}
开发者ID:kid-c-plus,项目名称:LifeTimer,代码行数:26,代码来源:main.c


示例14: hands_update_proc

static void hands_update_proc(Layer *layer, GContext *ctx) {
  GRect bounds = layer_get_bounds(layer);
  GPoint center = grect_center_point(&bounds);
  const int16_t second_hand_length = PBL_IF_ROUND_ELSE((bounds.size.w / 2) - 19, bounds.size.w / 2);

  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  // minute/hour hand
  // 時
  graphics_context_set_stroke_color(ctx, s_backColor);

  graphics_context_set_fill_color(ctx, s_hourHandColor);
  gpath_rotate_to(s_hour_arrow, (TRIG_MAX_ANGLE * (((t->tm_hour % 12) * 6) + (t->tm_min / 10))) / (12 * 6));
  gpath_draw_filled(ctx, s_hour_arrow);
  // 分
  graphics_context_set_fill_color(ctx, s_backColor);
  gpath_rotate_to(s_minute_arrow, (TRIG_MAX_ANGLE * (t->tm_min * 10 + (t->tm_sec/6)) / (60 * 10)));
  graphics_context_set_stroke_width(ctx, 2);
  graphics_context_set_stroke_color(ctx, s_minuteHandColor);
  gpath_draw_outline(ctx, s_minute_arrow);

  // 秒
  int32_t second_angle = TRIG_MAX_ANGLE * t->tm_sec / 60;
  GPoint second_hand = {
    .x = (int16_t)(sin_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.x,
    .y = (int16_t)(-cos_lookup(second_angle) * (int32_t)second_hand_length / TRIG_MAX_RATIO) + center.y,
  };
if (s_show_seconds_hand){
    // second hand
    graphics_context_set_stroke_width(ctx, 3);
    graphics_context_set_stroke_color(ctx, s_secondHandColor);
    graphics_draw_line(ctx, second_hand, center);
    graphics_context_set_stroke_width(ctx, 1);
    graphics_context_set_stroke_color(ctx, s_backColor);
    graphics_draw_line(ctx, second_hand, center);
  }
  // dot in the middle
  // 黒に設定
  graphics_context_set_fill_color(ctx, s_backColor);
  // 円を塗り潰し
  graphics_fill_circle(ctx, center, 7);
  // 線の色を白に設定
  graphics_context_set_stroke_color(ctx, s_secondHandColor);
  graphics_context_set_stroke_width(ctx, 1);
  graphics_draw_circle(ctx, center, 7);
  graphics_draw_circle(ctx, center, 1);
  
}

static void date_update_proc(Layer *layer, GContext *ctx) {
  time_t now = time(NULL);
  struct tm *t = localtime(&now);

  strftime(s_day_buffer, sizeof(s_day_buffer), "%a", t);
  text_layer_set_text(s_day_label, s_day_buffer);

  strftime(s_num_buffer, sizeof(s_num_buffer), "%d", t);
  text_layer_set_text(s_num_label, s_num_buffer);
}
开发者ID:bake-san,项目名称:ANALOG-P-SHOCK,代码行数:60,代码来源:simple_analog.c


示例15: main_window_load

static void main_window_load(Window *window) {

	// Get info about the window
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_layer);

	// Create GFont
	s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_CALIG_48));
	
	// Create GBitmap
	s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BACKGROUND);

	// Create BitmapLayer to display image
	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));

	// 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, s_time_font);
	//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));
}
开发者ID:DaviesH79,项目名称:watchface_1,代码行数:33,代码来源:watchface.c


示例16: menu_draw_row_callback

static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
  	switch (cell_index->section) {
    	default:
			switch (cell_index->row) {
			  	case 0:
				  	menu_cell_basic_draw(ctx, cell_layer, _("Checkin"), NULL, NULL);
				  	break;
			  	case 1:
					menu_cell_basic_draw(ctx, cell_layer, _("Share"), NULL, NULL);
					GRect bounds = layer_get_bounds(cell_layer);
					char* alligators = ">>";
					GFont font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
					graphics_draw_text(ctx, alligators, font,
									   GRect(bounds.size.w - PBL_IF_ROUND_ELSE(45, 35),
											 (bounds.size.h/2) - 18,
											 30, bounds.size.h),
									   GTextOverflowModeWordWrap, 
									   GTextAlignmentRight, 
									   NULL);
					break;
			  	case 2: 
				  	menu_cell_basic_draw(ctx, cell_layer, _("Private Checkin"), NULL, NULL);
				  	break;
			}
			break;
	}
}
开发者ID:thunsaker,项目名称:spoon,代码行数:27,代码来源:checkin_menu.c


示例17: main_window_load

//Loads main_window
static void main_window_load(Window *window) {
  // Here we load the bitmap assets
  s_menu_icons[0] = gbitmap_create_with_resource(RESOURCE_ID_VERYGOOD);
  s_menu_icons[1] = gbitmap_create_with_resource(RESOURCE_ID_GOOD);
  s_menu_icons[2] = gbitmap_create_with_resource(RESOURCE_ID_MED);
  s_menu_icons[3] = gbitmap_create_with_resource(RESOURCE_ID_BAD);
  s_menu_icons[4] = gbitmap_create_with_resource(RESOURCE_ID_VERYBAD);
  s_menu_icons[5] = gbitmap_create_with_resource(RESOURCE_ID_EXAMPLE1);


  // Now we prepare to initialize the menu layer
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);

  //if user presses BACK, the app exits
  window_set_click_config_provider(window, back_click_config_provider);

  // Create the menu layer
  s_menu_layer = menu_layer_create(bounds);
  menu_layer_set_callbacks(s_menu_layer, NULL, (MenuLayerCallbacks){
    .get_num_rows = menu_get_num_rows_callback,
    .get_header_height = PBL_IF_RECT_ELSE(menu_get_header_height_callback, NULL),
    .draw_header = PBL_IF_RECT_ELSE(menu_draw_header_callback, NULL),
    .draw_row = menu_draw_row_callback,
    .select_click = menu_select_callback,
    .get_cell_height = PBL_IF_ROUND_ELSE(get_cell_height_callback, NULL),
  });
开发者ID:Peter-Master,项目名称:PebbleHealthNet,代码行数:28,代码来源:main.c


示例18: main_window_load

static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect window_bounds = layer_get_bounds(window_layer);
  window_set_background_color(s_main_window, GColorMalachite);
  
  s_bitmap = gbitmap_create_with_resource(RESOURCE_ID_FACE);
  s_bitmap_layer = bitmap_layer_create(window_bounds);
  bitmap_layer_set_bitmap(s_bitmap_layer, s_bitmap);
  bitmap_layer_set_compositing_mode(s_bitmap_layer, GCompOpSet);
  layer_add_child(window_layer, bitmap_layer_get_layer(s_bitmap_layer));

  action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(action_bar, s_main_window);
  action_bar_layer_set_click_config_provider(action_bar, click_config_provider);
  
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_UP, menu_daily_up, true);
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_SELECT, menu_stats_select, true);
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_DOWN, menu_settings_down, true);
    
  s_output_layer = text_layer_create(GRect(5, 0, window_bounds.size.w - 5, window_bounds.size.h));
  text_layer_set_font(s_output_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_background_color(s_output_layer, GColorClear);
  text_layer_set_text(s_output_layer, "Press a Button");
  text_layer_set_text_alignment(s_output_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft));
  
  layer_add_child(window_layer, text_layer_get_layer(s_output_layer));
}
开发者ID:fresh-money,项目名称:HACK-UCSC-2016-App,代码行数:27,代码来源:main.c


示例19: main_window_load

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");
  
  // Create GFont
  s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PLAYTIME_WITH_HOT_TODDIES_48));
  
  //Apply to TextLayer
  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));
}
开发者ID:KotovSyndrome,项目名称:PebbleFace,代码行数:25,代码来源:main.c


示例20: handle_layout

void handle_layout() {
  BatteryChargeState charge_state = battery_state_service_peek();
  bool battery_is_low = charge_state.charge_percent <= 20;
  bool showSeconds = seconds_mode == SECONDS_MODE_ALWAYS
    || (seconds_mode == SECONDS_MODE_IFNOTLOW && (!battery_is_low || charge_state.is_plugged));
  bool showBattery = battery_mode == BATTERY_MODE_ALWAYS
    || (battery_mode == BATTERY_MODE_IF_LOW && battery_is_low)
    || charge_state.is_plugged;
  int face_top = PBL_IF_ROUND_ELSE(0, date_pos == DATE_POS_BOTTOM ? 0 : date_pos == DATE_POS_OFF ? 12 : 24);
  int date_top = date_pos == DATE_POS_TOP ? 0 : EXTENT;
  int battery_top = date_pos == DATE_POS_TOP ? 168-10-3 : 3;
  if (hide_seconds != !showSeconds) {
    hide_seconds = !showSeconds;
    tick_timer_service_unsubscribe();
    tick_timer_service_subscribe(hide_seconds ? MINUTE_UNIT : SECOND_UNIT, &handle_tick);
  }
  layer_set_hidden(date_layer, date_pos == DATE_POS_OFF);
  layer_set_hidden(battery_layer, !showBattery);
  layer_set_frame(background_layer, GRect(0, face_top, EXTENT, EXTENT));
  layer_set_frame(date_layer, GRect(0, date_top, EXTENT, 24));
  layer_set_frame(battery_layer, GRect(EXTENT-22-3, battery_top, 22, 10));
  FG_COLOR = graphics_mode == GRAPHICS_MODE_INVERT ? GColorBlack : GColorWhite;
  BG_COLOR = graphics_mode == GRAPHICS_MODE_INVERT ? GColorWhite : GColorBlack;
  window_set_background_color(window, BG_COLOR);
}
开发者ID:ProggroP,项目名称:pebbleone,代码行数:25,代码来源:pebble_one.c



注:本文中的PBL_IF_ROUND_ELSE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PB_RETURN_ERROR函数代码示例发布时间:2022-05-30
下一篇:
C++ PA_WaitForVBL函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap