Slight readability improvements to GUI

This commit is contained in:
Yousef Khadadeh 2025-11-01 18:07:39 +03:00
parent 49d72e384c
commit 30f7856815
8 changed files with 37 additions and 19 deletions

View file

@ -26,8 +26,8 @@ namespace GUIStuff {
theme->fillColor2 = {0.31f, 0.31f, 0.48f, 1.0f};
theme->backColor1 = {0.156f, 0.156f, 0.18f, 1.0f};
theme->backColor2 = {0.24f, 0.24f, 0.29f, 1.0f};
theme->frontColor1 = {0.9f, 0.9f, 0.9f, 1.0f};
theme->frontColor2 = {0.8f, 0.8f, 0.8f, 1.0f};
theme->frontColor1 = {0.87f, 0.87f, 0.87f, 1.0f};
theme->frontColor2 = {0.64f, 0.64f, 0.64f, 1.0f};
return theme;
}

View file

@ -59,7 +59,7 @@ struct Theme {
SkColor4f warningColor = {1.0f, 1.0f, 0.0f, 1.0f};
float hoverExpandTime = 0.1f;
uint16_t childGap1 = 8;
uint16_t childGap1 = 10;
uint16_t padding1 = 8;
float windowCorners1 = 8;
uint16_t windowBorders1 = 0;
@ -108,7 +108,7 @@ struct UpdateInputData {
SkFont get_font(float fSize) const;
uint16_t fontSize = 14;
uint16_t fontSize = 16;
sk_sp<SkTypeface> textTypeface;
sk_sp<skia::textlayout::FontCollection> fontCollection;

View file

@ -35,7 +35,7 @@ void MovableTabList::update(UpdateInputData& io, const std::vector<std::pair<std
CLAY({.layout = {
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
.padding = CLAY_PADDING_ALL(0),
.childGap = 0,
.childGap = 4,
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER },
.layoutDirection = CLAY_LEFT_TO_RIGHT
}

View file

@ -115,6 +115,7 @@ void GUIManager::draw(SkCanvas* canvas) {
skia::textlayout::TextStyle tStyle;
tStyle.setFontSize(config->fontSize);
tStyle.setFontFamilies({SkString{"Roboto"}});
tStyle.setColor(convert_vec4<SkColor4f>(config->textColor).toSkColor());
pStyle.setTextStyle(tStyle);
skia::textlayout::ParagraphBuilderImpl a(pStyle, io->fontCollection, SkUnicodes::ICU::Make());
@ -272,6 +273,10 @@ void GUIManager::text_label_color(const std::string& val, const SkColor4f& color
CLAY_TEXT(strArena.std_str_to_clay_str(val), CLAY_TEXT_CONFIG({.textColor = convert_vec4<Clay_Color>(color), .fontSize = io->fontSize }));
}
void GUIManager::text_label_light(const std::string& val) {
CLAY_TEXT(strArena.std_str_to_clay_str(val), CLAY_TEXT_CONFIG({.textColor = convert_vec4<Clay_Color>(io->theme->frontColor2), .fontSize = io->fontSize }));
}
void GUIManager::text_label(const std::string& val) {
CLAY_TEXT(strArena.std_str_to_clay_str(val), CLAY_TEXT_CONFIG({.textColor = convert_vec4<Clay_Color>(io->theme->frontColor1), .fontSize = io->fontSize }));
}
@ -287,6 +292,17 @@ void GUIManager::text_label_centered(const std::string& val) {
}
}
void GUIManager::text_label_light_centered(const std::string& val) {
CLAY({
.layout = {
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) },
.childAlignment = {.x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER},
}
}) {
CLAY_TEXT(strArena.std_str_to_clay_str(val), CLAY_TEXT_CONFIG({.textColor = convert_vec4<Clay_Color>(io->theme->frontColor2), .fontSize = io->fontSize }));
}
}
bool GUIManager::radio_button(const std::string& id, bool val, const std::function<void()>& elemUpdate) {
push_id(id);
RadioButton* e = insert_element<RadioButton>();

View file

@ -52,7 +52,9 @@ class GUIManager {
void text_paragraph(const std::string& id, std::unique_ptr<skia::textlayout::Paragraph> paragraph, float width, const std::function<void()>& elemUpdate = nullptr);
void text_label_color(const std::string& val, const SkColor4f& color);
void text_label_size(const std::string& val, float modifier);
void text_label_light(const std::string& val);
void text_label(const std::string& val);
void text_label_light_centered(const std::string& val);
void text_label_centered(const std::string& val);
bool text_button_left_transparent(const std::string& id, const std::string& text, bool isSelected = false, const std::function<void()>& elemUpdate = nullptr);
bool text_button(const std::string& id, const std::string& text, bool isSelected = false, const std::function<void()>& elemUpdate = nullptr);