aboutsummaryrefslogtreecommitdiff
path: root/src/gui/ComboBox.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-08-06 08:22:42 +0200
committerdec05eba <dec05eba@protonmail.com>2024-08-06 08:22:42 +0200
commit520c61ec64c001d2c9c9d953051aa58715831731 (patch)
tree2c0e10995d1a85374f628e78a53321f727013bf3 /src/gui/ComboBox.cpp
parent9b6033e2b97f6f572cb69a393d4d1d1ea41b5d72 (diff)
Add checkbox, scale more sizes by window scale
Diffstat (limited to 'src/gui/ComboBox.cpp')
-rw-r--r--src/gui/ComboBox.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/ComboBox.cpp b/src/gui/ComboBox.cpp
index 851e3da..058254f 100644
--- a/src/gui/ComboBox.cpp
+++ b/src/gui/ComboBox.cpp
@@ -12,6 +12,7 @@ namespace gsr {
static const float padding_bottom = 10.0f;
static const float padding_left = 10.0f;
static const float padding_right = 10.0f;
+ static const float border_scale = 0.0015f;
ComboBox::ComboBox(mgl::Font *font) : font(font), dropdown_arrow(&get_theme().combobox_arrow) {
assert(font);
@@ -82,12 +83,13 @@ namespace gsr {
window.draw(dropdown_arrow);
}
+ const bool mouse_inside = mgl::FloatRect(draw_pos, item_size).contains(window.get_mouse_position().to_vec2f());
mgl::vec2f pos = draw_pos + mgl::vec2f(padding_left, padding_top);
Item &item = items[selected_item];
item.text.set_position(pos.floor());
- if(show_dropdown) {
- const int border_size = 3;
+ if(show_dropdown || mouse_inside) {
+ const int border_size = border_scale * gsr::get_theme().window_height;
const mgl::Color border_color = gsr::get_theme().tint_color;
draw_rectangle_outline(window, pos - mgl::vec2f(padding_left, padding_top), item_size.floor(), border_color, border_size);
}