diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-12-01 21:03:59 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-12-01 21:04:17 +0100 |
commit | b0a681964a5db50b970e59a90c89a09f568f5447 (patch) | |
tree | 08179fec8d70dd9c6a359de3c0d64a0dd77876d2 /src/Entry.cpp | |
parent | 4afa53a8bb6b02c07db8c54362311c21444a3ced (diff) |
Add more texts to config font size, set colors for all text from theme, add dark and light theme, choose icons based on theme brightness
Remove matrix logo from matrix chat
Diffstat (limited to 'src/Entry.cpp')
-rw-r--r-- | src/Entry.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/Entry.cpp b/src/Entry.cpp index af35de0..8357216 100644 --- a/src/Entry.cpp +++ b/src/Entry.cpp @@ -13,20 +13,20 @@ namespace QuickMedia { return (int)v; } - static const float background_margin_horizontal = floor(5.0f * get_config().scale * get_config().spacing_scale); - static const float padding_vertical = floor(5.0f * get_config().scale * get_config().spacing_scale); - static const float background_margin_vertical = floor(0.0f * get_config().scale * get_config().spacing_scale); + static const float background_margin_horizontal = 5.0f + floor(get_config().input.font_size * get_config().scale * get_config().font_scale * 0.6f); + static const float background_margin_vertical = 2.0f + floor(get_config().input.font_size * get_config().scale * get_config().font_scale * 0.25f); Entry::Entry(const std::string &placeholder_text, mgl::Shader *rounded_rectangle_shader) : on_submit_callback(nullptr), draw_background(true), text("", false, floor(get_config().input.font_size * get_config().scale * get_config().font_scale), 0.0f), width(0.0f), - background(mgl::vec2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().selected_color, rounded_rectangle_shader), + background(mgl::vec2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().shade_color, rounded_rectangle_shader), placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().input.font_size * get_config().scale * get_config().font_scale)), mouse_left_inside(false) { text.setEditable(true); + text.set_color(get_theme().text_color); placeholder.set_color(get_theme().placeholder_text_color); } @@ -109,13 +109,13 @@ namespace QuickMedia { void Entry::set_position(const mgl::vec2f &pos) { background.set_position(pos); - text.set_position(pos + mgl::vec2f(background_margin_horizontal, background_margin_vertical)); - placeholder.set_position(pos + mgl::vec2f(background_margin_horizontal, background_margin_vertical + floor(3.0f * get_config().scale))); + text.set_position(pos + mgl::vec2f(background_margin_horizontal * padding_scale, background_margin_vertical * padding_scale - text.get_character_size() * 0.3f).floor()); + placeholder.set_position(pos + mgl::vec2f(background_margin_horizontal * padding_scale, background_margin_vertical * padding_scale - text.get_character_size() * 0.005f).floor()); } void Entry::set_max_width(float width) { this->width = width; - text.setMaxWidth(this->width - background_margin_horizontal * 2.0f); + text.setMaxWidth(this->width - background_margin_horizontal * padding_scale * 2.0f); } bool Entry::is_editable() const { @@ -124,10 +124,19 @@ namespace QuickMedia { float Entry::get_height() { text.updateGeometry(); - return floor(text.getHeight() + background_margin_vertical * 2.0f + padding_vertical * 2.0f); + return floor(text.getHeight() + background_margin_vertical * padding_scale * 2.0f); } const std::string& Entry::get_text() const { return text.getString(); } + + void Entry::set_background_color(mgl::Color color) { + background.set_color(color); + } + + void Entry::set_padding_scale(float scale) { + padding_scale = scale; + set_max_width(width); + } }
\ No newline at end of file |