fix fullcheckbox resize function

This commit is contained in:
Sergwest585 2024-10-22 03:22:54 +03:00
parent c725775939
commit daae8a3707
3 changed files with 11 additions and 4 deletions

View File

@ -45,7 +45,7 @@ function on_open()
refresh_sensitivity() refresh_sensitivity()
document.search_panel:add(string.format( document.search_panel:add(string.format(
"<checkbox size='20,20' id='search_key_checkbox' consumer='function(x) refresh_search() end' tooltip='%s'>%s</checkbox>", "<checkbox size='100,24' id='search_key_checkbox' consumer='function(x) refresh_search() end' tooltip='%s'>%s</checkbox>",
gui.str("controls.key.tooltip", "settings"), gui.str("Key", "settings") gui.str("controls.key.tooltip", "settings"), gui.str("Key", "settings")
)) ))

View File

@ -46,13 +46,13 @@ CheckBox* CheckBox::setChecked(bool flag) {
FullCheckBox::FullCheckBox(const std::wstring& text, glm::vec2 size, bool checked) FullCheckBox::FullCheckBox(const std::wstring& text, glm::vec2 size, bool checked)
: Panel(size), : Panel(size),
checkbox(std::make_shared<CheckBox>(checked)){ checkbox(std::make_shared<CheckBox>(checked)),
label(std::make_shared<Label>(text)) {
setColor(glm::vec4(0.0f)); setColor(glm::vec4(0.0f));
setOrientation(Orientation::horizontal); setOrientation(Orientation::horizontal);
add(checkbox); add(checkbox);
auto label = std::make_shared<Label>(text);
label->setMargin(glm::vec4(5.f, 5.f, 0.f, 0.f)); label->setMargin(glm::vec4(5.f, 5.f, 0.f, 0.f));
add(label); add(label);
} }

View File

@ -3,6 +3,7 @@
#include <utility> #include <utility>
#include "Panel.hpp" #include "Panel.hpp"
#include "Label.hpp"
namespace gui { namespace gui {
class CheckBox : public UINode { class CheckBox : public UINode {
@ -33,6 +34,7 @@ namespace gui {
class FullCheckBox : public Panel { class FullCheckBox : public Panel {
protected: protected:
std::shared_ptr<CheckBox> checkbox; std::shared_ptr<CheckBox> checkbox;
std::shared_ptr<Label> label;
public: public:
FullCheckBox(const std::wstring& text, glm::vec2 size, bool checked=false); FullCheckBox(const std::wstring& text, glm::vec2 size, bool checked=false);
@ -56,5 +58,10 @@ namespace gui {
Panel::setTooltip(text); Panel::setTooltip(text);
checkbox->setTooltip(text); checkbox->setTooltip(text);
} }
virtual void setSize(glm::vec2 new_size) override {
Panel::setSize(new_size);
checkbox->setSize(glm::vec2(size.y, size.y));
}
}; };
} }