Merge pull request #323 from Sergwest585/main

FullCheckBox resize function
This commit is contained in:
MihailRis 2024-10-22 06:07:17 +03:00 committed by GitHub
commit 3ea6d2ccf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 13 additions and 6 deletions

View File

@ -5,7 +5,7 @@
consumer='change_sensitivity'>
</trackbar>
<panel id='search_panel' size='380,60' padding='2' interval='1' color='#0000004C'>
<textbox id='search_textbox' multiline='false' size='300,20' consumer='function(x) search_text=x refresh_search() end'></textbox>
<textbox id='search_textbox' multiline='false' size='300,20' consumer='function(x) refresh_search() end'></textbox>
</panel>
<panel id='bindings_panel' size='380,204' padding='2' interval='1' max-length='300' color='#0000004C'>
<!-- content is generated in script -->

View File

@ -45,7 +45,7 @@ function on_open()
refresh_sensitivity()
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")
))

2
run.sh
View File

@ -1,4 +1,4 @@
mkdir build
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . -j$(nproc)

View File

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

View File

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