diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-08-01 18:38:06 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-08-01 18:38:06 +0200 |
commit | 6624db873c91087bc1805b9d018c92c455b85190 (patch) | |
tree | 169010942015f1ff209cd56600f4de433c8792ef /src/gui/Utils.cpp | |
parent | 5d40409fc6e54af4c4dccdab11f03bce21c5a9a2 (diff) |
Move dropdown button text and icon code to dropdown button class
Diffstat (limited to 'src/gui/Utils.cpp')
-rw-r--r-- | src/gui/Utils.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/gui/Utils.cpp b/src/gui/Utils.cpp new file mode 100644 index 0000000..20c7b73 --- /dev/null +++ b/src/gui/Utils.cpp @@ -0,0 +1,43 @@ +#include "../../include/gui/Utils.hpp" +#include <mglpp/window/Window.hpp> +#include <mglpp/graphics/Rectangle.hpp> + +namespace gsr { + // TODO: Use vertices to make it one draw call + void draw_rectangle_outline(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size, mgl::Color color, float border_size) { + pos = pos.floor(); + size = size.floor(); + border_size = (int)border_size; + // Green line at top + { + mgl::Rectangle rect({ size.x, border_size }); + rect.set_position(pos); + rect.set_color(color); + window.draw(rect); + } + + // Green line at bottom + { + mgl::Rectangle rect({ size.x, border_size }); + rect.set_position(pos + mgl::vec2f(0.0f, size.y - border_size)); + rect.set_color(color); + window.draw(rect); + } + + // Green line at left + { + mgl::Rectangle rect({ border_size, size.y - border_size * 2 }); + rect.set_position(pos + mgl::vec2f(0, border_size)); + rect.set_color(color); + window.draw(rect); + } + + // Green line at right + { + mgl::Rectangle rect({ border_size, size.y - border_size * 2 }); + rect.set_position(pos + mgl::vec2f(size.x - border_size, border_size)); + rect.set_color(color); + window.draw(rect); + } + } +}
\ No newline at end of file |