Make sure all sizes are scaled by window size, make sure all elements are visible for very low resolutions and text doesn't get too small

This commit is contained in:
dec05eba
2024-08-06 08:59:38 +02:00
parent b3f5a53ece
commit b229b060ad
8 changed files with 81 additions and 45 deletions

View File

@@ -7,10 +7,10 @@
#include <mglpp/system/FloatRect.hpp>
namespace gsr {
static const float padding_top = 10.0f;
static const float padding_bottom = 10.0f;
static const float padding_left = 10.0f;
static const float padding_right = 10.0f;
static const float padding_top_scale = 0.004629f;
static const float padding_bottom_scale = 0.004629f;
static const float padding_left_scale = 0.007f;
static const float padding_right_scale = 0.007f;
Button::Button(mgl::Font *font, const char *text, mgl::vec2f size, mgl::Color bg_color) : size(size), bg_color(bg_color), text(text, *font) {
@@ -40,10 +40,15 @@ namespace gsr {
const bool mouse_inside = mgl::FloatRect(draw_pos, item_size).contains(window.get_mouse_position().to_vec2f());
if(mouse_inside)
draw_rectangle_outline(window, draw_pos, item_size, gsr::get_theme().tint_color, border_scale * gsr::get_theme().window_height);
draw_rectangle_outline(window, draw_pos, item_size, get_theme().tint_color, border_scale * get_theme().window_height);
}
mgl::vec2f Button::get_size() {
const int padding_top = padding_top_scale * get_theme().window_height;
const int padding_bottom = padding_bottom_scale * get_theme().window_height;
const int padding_left = padding_left_scale * get_theme().window_height;
const int padding_right = padding_right_scale * get_theme().window_height;
const mgl::vec2f text_bounds = text.get_bounds().size;
mgl::vec2f s = size;
if(s.x < 0.0001f)