diff options
author | ache <ache@ache.one> | 2022-11-06 22:48:23 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2022-11-06 22:48:23 +0100 |
commit | 2f5efc821ba09d39d5f316bca32cbb71330c7315 (patch) | |
tree | 279f678e2378a82e7f15cf3d0d4689d33ce6431a /src/render.c | |
parent | Locale set (diff) |
Show date
Diffstat (limited to 'src/render.c')
-rw-r--r-- | src/render.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/src/render.c b/src/render.c index e3ed98f..1b40fcd 100644 --- a/src/render.c +++ b/src/render.c @@ -281,6 +281,39 @@ void draw_logo(saver_state_t *state) set_layer_needs_draw(state, LAYER_LOGO, false); } +void draw_date_field(saver_state_t *state) +{ + const double cursor_height = 40.0; + const double cursor_width = 30.0; + const double field_x = kLogoBackgroundWidth + 50.0; + const double field_y = (state->canvas_height - cursor_height) / 2.0; + const double field_padding = 10.0; + + cairo_t *cr = state->ctx; + + // Common color for status and password field + cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, state->password_opacity); + + char date[256] = ""; + char datePrompt[256] = ""; + time_t nowInstant = time(NULL); + struct tm* now = localtime(&nowInstant); + + strftime(date, 256, "%T %a %d/%m/%y", now); + sprintf(datePrompt, "%s/%s", date, state->password_prompt); + + // Measure status text + const char *prompt = datePrompt; + pango_layout_set_font_description(state->pango_layout, state->status_font); + pango_layout_set_text(state->pango_layout, prompt, -1); + + int t_width, t_height; + pango_layout_get_size(state->pango_layout, &t_width, &t_height); + double line_height = t_height / PANGO_SCALE; + + + +} void draw_password_field(saver_state_t *state) { const double cursor_height = 40.0; @@ -288,14 +321,22 @@ void draw_password_field(saver_state_t *state) const double field_x = kLogoBackgroundWidth + 50.0; const double field_y = (state->canvas_height - cursor_height) / 2.0; const double field_padding = 10.0; - + cairo_t *cr = state->ctx; // Common color for status and password field cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, state->password_opacity); + char date[256] = ""; + char datePrompt[256] = ""; + time_t nowInstant = time(NULL); + struct tm* now = localtime(&nowInstant); + + strftime(date, 256, "%T %a %d/%m/%y", now); + sprintf(datePrompt, "%s\n%s", date, state->password_prompt); + // Measure status text - const char *prompt = state->password_prompt; + const char *prompt = datePrompt; pango_layout_set_font_description(state->pango_layout, state->status_font); pango_layout_set_text(state->pango_layout, prompt, -1); |