From 520c61ec64c001d2c9c9d953051aa58715831731 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 6 Aug 2024 08:22:42 +0200 Subject: Add checkbox, scale more sizes by window scale --- include/gui/Button.hpp | 2 ++ include/gui/CheckBox.hpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 include/gui/CheckBox.hpp (limited to 'include') diff --git a/include/gui/Button.hpp b/include/gui/Button.hpp index 4f8b404..f4c44ef 100644 --- a/include/gui/Button.hpp +++ b/include/gui/Button.hpp @@ -19,11 +19,13 @@ namespace gsr { void draw(mgl::Window &window, mgl::vec2f offset) override; mgl::vec2f get_size() override; + void set_border_scale(float scale); std::function on_click; private: mgl::vec2f size; mgl::Color bg_color; mgl::Text text; + float border_scale = 0.0015f; }; } \ No newline at end of file diff --git a/include/gui/CheckBox.hpp b/include/gui/CheckBox.hpp new file mode 100644 index 0000000..4459976 --- /dev/null +++ b/include/gui/CheckBox.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include "Widget.hpp" +#include + +#include +#include + +namespace gsr { + class CheckBox : public Widget { + public: + CheckBox(mgl::Font *font, const char *text); + CheckBox(const CheckBox&) = delete; + CheckBox& operator=(const CheckBox&) = delete; + + bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override; + void draw(mgl::Window &window, mgl::vec2f offset) override; + + mgl::vec2f get_size() override; + + std::function on_click; + private: + mgl::vec2f get_checkbox_size(); + private: + mgl::Text text; + bool checked = false; + }; +} \ No newline at end of file -- cgit v1.2.3