<commit_before>#include "watchface_preferences.h"

#include <pebble.h>

#define MASK_CONTAINS_FLAG(mask, flag) (((mask) & (flag)) == (flag))
#define APP_TICK_UNITS (MINUTE_UNIT | DAY_UNIT)
#define APP_TIME_BUFFER_MAX_SIZE (8)
#define APP_DATE_BUFFER_MAX_SIZE (20)

typedef struct tm Time;

typedef struct AppData {
  WatchfacePrefs prefs;
  bool is_connected;
  char time_buffer[APP_TIME_BUFFER_MAX_SIZE];
  char date_buffer[APP_DATE_BUFFER_MAX_SIZE];
  GFont number_font;
  GFont date_font;
  Window *window;
  Layer *root_layer;
#if PBL_RECT
  GPath *disconnect_indicator_path;
#endif
} AppData;

static AppData s_data;

#if PBL_RECT
#define WATCH_SCREEN_WIDTH (144)
#define APP_DISCONNECT_INDICATOR_SIDE_LENGTH (25)

static const GPathInfo s_disconnect_indicator_path_info = { // A corner triangle
    .num_points = 3,
    .points = (GPoint []) {
      {(WATCH_SCREEN_WIDTH - APP_DISCONNECT_INDICATOR_SIDE_LENGTH), 0},
      {WATCH_SCREEN_WIDTH, 0},
      {WATCH_SCREEN_WIDTH, APP_DISCONNECT_INDICATOR_SIDE_LENGTH}
    }
  };
#endif

static void prv_draw_disconnect_indicator(int layer_width, GContext *context, AppData *data) {
  graphics_context_set_fill_color(context, data->prefs.disconnect_indicator_color);
#if PBL_RECT // draws a corner triangle
  gpath_draw_filled(context, data->disconnect_indicator_path);
#else // draws a circle at top of the screen
  const GPoint indicator_centre = GPoint((layer_width / 2), -3);
  const int radius = 10;
  graphics_fill_circle(context, indicator_centre, radius);
#endif
}

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

  // background
  graphics_context_set_fill_color(context, s_data.prefs.background_color);
  graphics_fill_rect(context, layer_bounds, 0, GCornerNone);

  const int band_height = 50;
  const int band_top_bottom_padding = (layer_bounds.size.h - band_height) / 2;
  const int band_left_right_padding = -2;
  const GRect band_rect = grect_inset(layer_bounds, GEdgeInsets2(band_top_bottom_padding,
                                      band_left_right_padding));
  graphics_context_set_fill_color(context, s_data.prefs.band_color);
  graphics_fill_rect(context, band_rect, 0, GCornerNone);

  // time
  GRect text_bounds = band_rect;
  const int time_text_padding_reduction = 3;
  text_bounds.origin.y -= time_text_padding_reduction;
  graphics_context_set_text_color(context, s_data.prefs.time_text_color);
  graphics_draw_text(context, s_data.time_buffer, s_data.number_font, text_bounds,
                     GTextOverflowModeFill , GTextAlignmentCenter, NULL);

  // date
  text_bounds.origin.y += band_height;
  graphics_context_set_text_color(context, s_data.prefs.date_text_color);
  graphics_draw_text(context, s_data.date_buffer, s_data.date_font, text_bounds,
                     GTextOverflowModeFill , GTextAlignmentCenter, NULL);<commit_msg>Minor padding / margin changes<commit_after>#include "watchface_preferences.h"

#include <pebble.h>

#define MASK_CONTAINS_FLAG(mask, flag) (((mask) & (flag)) == (flag))
#define APP_TICK_UNITS (MINUTE_UNIT | DAY_UNIT)
#define APP_TIME_BUFFER_MAX_SIZE (8)
#define APP_DATE_BUFFER_MAX_SIZE (20)

typedef struct tm Time;

typedef struct AppData {
  WatchfacePrefs prefs;
  bool is_connected;
  char time_buffer[APP_TIME_BUFFER_MAX_SIZE];
  char date_buffer[APP_DATE_BUFFER_MAX_SIZE];
  GFont number_font;
  GFont date_font;
  Window *window;
  Layer *root_layer;
#if PBL_RECT
  GPath *disconnect_indicator_path;
#endif
} AppData;

static AppData s_data;

#if PBL_RECT
#define WATCH_SCREEN_WIDTH (144)
#define APP_DISCONNECT_INDICATOR_SIDE_LENGTH (25)

static const GPathInfo s_disconnect_indicator_path_info = { // A corner triangle
    .num_points = 3,
    .points = (GPoint []) {
      {(WATCH_SCREEN_WIDTH - APP_DISCONNECT_INDICATOR_SIDE_LENGTH), 0},
      {WATCH_SCREEN_WIDTH, 0},
      {WATCH_SCREEN_WIDTH, APP_DISCONNECT_INDICATOR_SIDE_LENGTH}
    }
  };
#endif

static void prv_draw_disconnect_indicator(int layer_width, GContext *context, AppData *data) {
  graphics_context_set_fill_color(context, data->prefs.disconnect_indicator_color);
#if PBL_RECT // draws a corner triangle
  gpath_draw_filled(context, data->disconnect_indicator_path);
#else // draws a circle at top of the screen
  const GPoint indicator_centre = GPoint((layer_width / 2), -3);
  const int radius = 10;
  graphics_fill_circle(context, indicator_centre, radius);
#endif
}

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

  // background
  graphics_context_set_fill_color(context, s_data.prefs.background_color);
  graphics_fill_rect(context, layer_bounds, 0, GCornerNone);

  const int band_height = 50;
  const int band_top_bottom_padding = (layer_bounds.size.h - band_height) / 2;
  const int band_left_right_padding = 0;
  const GRect band_rect = grect_inset(layer_bounds, GEdgeInsets2(band_top_bottom_padding,
                                      band_left_right_padding));
  graphics_context_set_fill_color(context, s_data.prefs.band_color);
  graphics_fill_rect(context, band_rect, 0, GCornerNone);

  // time
  GRect text_bounds = band_rect;
  const int time_text_padding_reduction = 2;
  text_bounds.origin.y -= time_text_padding_reduction;
  graphics_context_set_text_color(context, s_data.prefs.time_text_color);
  graphics_draw_text(context, s_data.time_buffer, s_data.number_font, text_bounds,
                     GTextOverflowModeFill , GTextAlignmentCenter, NULL);

  // date
  text_bounds.origin.y += band_height;
  graphics_context_set_text_color(context, s_data.prefs.date_text_color);
  graphics_draw_text(context, s_data.date_buffer, s_data.date_font, text_bounds,
                     GTextOverflowModeFill , GTextAlignmentCenter, NULL);
{'fraction_non_alphanumeric': 0.08685204256779952, 'fraction_numerical': 0.00789564023343632, 'mean_word_length': 5.179215270413573, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6452721', 'n_tokens_mistral': 2072, 'n_tokens_neox': 2010, 'n_words': 390}