Skip to content

Commit 4488bd2

Browse files
committed
GUI element cleanup, WiFi test, progress and confirmation dialogs
1 parent 93e48fc commit 4488bd2

44 files changed

Lines changed: 717 additions & 633 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/gui/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ idf_component_register(
22
SRCS
33
gui_menu.c
44
gui_menu_render.c
5-
gui_footer.c
5+
gui_element_header.c
6+
gui_element_footer.c
7+
gui_element_icontext.c
68
gui_osk.c
79
gui_osk_edit.c
810
gui_edit.c
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "gui_element_footer.h"
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <string.h>
5+
#include "gui_element_icontext.h"
6+
#include "pax_gfx.h"
7+
8+
void gui_footer_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, gui_element_icontext_t* left, size_t left_count,
9+
gui_element_icontext_t* right, size_t right_count) {
10+
gui_element_style_t* style = &theme->footer;
11+
int buffer_width = pax_buf_get_width(pax_buffer);
12+
int buffer_height = pax_buf_get_height(pax_buffer);
13+
int box_height = style->height + (style->vertical_margin * 2);
14+
15+
pax_draw_line(pax_buffer, theme->palette.color_foreground, style->horizontal_margin, buffer_height - box_height,
16+
buffer_width - style->horizontal_margin, buffer_height - box_height);
17+
18+
int x = style->horizontal_margin + style->horizontal_padding;
19+
for (size_t i = 0; i < left_count; i++) {
20+
x += gui_icontext_draw(pax_buffer, theme, x, buffer_height - box_height, &left[i], style->horizontal_padding,
21+
box_height);
22+
}
23+
24+
x = buffer_width - style->horizontal_margin;
25+
for (size_t i = 0; i < right_count; i++) {
26+
x -= gui_icontext_width(theme, buffer_width, buffer_height, &right[i], style->horizontal_padding);
27+
gui_icontext_draw(pax_buffer, theme, x - style->horizontal_padding, buffer_height - box_height, &right[i],
28+
style->horizontal_padding, box_height);
29+
}
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "gui_element_header.h"
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <string.h>
5+
#include "gui_element_icontext.h"
6+
#include "pax_gfx.h"
7+
8+
void gui_header_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, gui_element_icontext_t* left, size_t left_count,
9+
gui_element_icontext_t* right, size_t right_count) {
10+
gui_element_style_t* style = &theme->header;
11+
12+
int buffer_width = pax_buf_get_width(pax_buffer);
13+
int box_height = style->height + (style->vertical_margin * 2);
14+
15+
pax_draw_line(pax_buffer, theme->palette.color_foreground, style->horizontal_margin, box_height,
16+
buffer_width - style->horizontal_margin, box_height);
17+
18+
int x = style->horizontal_margin + style->horizontal_padding;
19+
for (size_t i = 0; i < left_count; i++) {
20+
x += gui_icontext_draw(pax_buffer, theme, x, 0, &left[i], style->horizontal_padding, box_height);
21+
}
22+
23+
x = buffer_width - style->horizontal_margin;
24+
for (size_t i = 0; i < right_count; i++) {
25+
x -= gui_icontext_width(theme, buffer_width, 0, &right[i], style->horizontal_padding);
26+
gui_icontext_draw(pax_buffer, theme, x - style->horizontal_padding, 0, &right[i], style->horizontal_padding,
27+
box_height);
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include "gui_element_icontext.h"
2+
#include <stddef.h>
3+
#include "gui_style.h"
4+
#include "pax_gfx.h"
5+
#include "pax_types.h"
6+
7+
float gui_icontext_width(gui_theme_t* theme, int x, int y, gui_element_icontext_t* content, float padding) {
8+
float icon_width = 0;
9+
if (content->icon) {
10+
icon_width = pax_buf_get_width(content->icon);
11+
}
12+
pax_vec2f text_size = pax_text_size(theme->footer.text_font, theme->footer.text_height, content->text);
13+
return icon_width + padding + text_size.x;
14+
}
15+
16+
float gui_icontext_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, int x, int y, gui_element_icontext_t* content,
17+
float padding, int box_height) {
18+
float icon_width = 0;
19+
if (content->icon) {
20+
icon_width = pax_buf_get_width(content->icon);
21+
float icon_height = pax_buf_get_height(content->icon);
22+
pax_draw_image(pax_buffer, content->icon, x, y + (box_height - icon_height) / 2);
23+
}
24+
pax_draw_text(pax_buffer, theme->palette.color_foreground, theme->footer.text_font, theme->footer.text_height,
25+
x + icon_width + padding, y + ((float)(box_height - theme->footer.text_height)) / 2.0f,
26+
content->text);
27+
pax_vec2f text_size = pax_text_size(theme->footer.text_font, theme->footer.text_height, content->text);
28+
return icon_width + padding + text_size.x;
29+
}

components/gui/gui_footer.c

Lines changed: 0 additions & 82 deletions
This file was deleted.

components/gui/gui_osk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#include <malloc.h>
2727
#include <string.h>
2828
#include "esp_timer.h"
29+
#include "pax_fonts.h"
30+
#include "pax_gfx.h"
31+
#include "pax_shapes.h"
2932

3033
// Initialise the context with default settings.
3134
void gui_osk_init(pax_buf_t* buf, gui_osk_ctx_t* ctx, size_t buffer_cap) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include <stddef.h>
4+
#include "gui_element_icontext.h"
5+
#include "gui_style.h"
6+
#include "pax_types.h"
7+
8+
void gui_footer_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, gui_element_icontext_t* left, size_t left_count,
9+
gui_element_icontext_t* right, size_t right_count);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include <stddef.h>
4+
#include "gui_element_icontext.h"
5+
#include "gui_style.h"
6+
#include "pax_types.h"
7+
8+
void gui_header_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, gui_element_icontext_t* left, size_t left_count,
9+
gui_element_icontext_t* right, size_t right_count);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include <stddef.h>
4+
#include "gui_style.h"
5+
#include "pax_types.h"
6+
7+
typedef struct {
8+
pax_buf_t* icon;
9+
char* text;
10+
} gui_element_icontext_t;
11+
12+
float gui_icontext_width(gui_theme_t* theme, int x, int y, gui_element_icontext_t* content, float padding);
13+
float gui_icontext_draw(pax_buf_t* pax_buffer, gui_theme_t* theme, int x, int y, gui_element_icontext_t* content,
14+
float padding, int box_height);

components/gui/include/gui_footer.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)