Textbox height fixed when only accepting single line

This commit is contained in:
Yousef Khadadeh 2025-11-02 09:38:15 +03:00
parent 86e0999a5c
commit 640d4673ad
5 changed files with 15 additions and 10 deletions

View file

@ -3,7 +3,7 @@
namespace GUIStuff {
constexpr float WHEEL_WIDTH = 10.0f;
constexpr float WHEEL_WIDTH = 13.0f;
constexpr double ROTATE_BAR_SNAP_DISTANCE = 0.3;
constexpr double ROTATE_BAR_SNAP_DISTRIBUTION = std::numbers::pi * 0.25;

View file

@ -4,12 +4,17 @@
namespace GUIStuff {
void SelectableButton::update(UpdateInputData& io, DrawType drawType, const std::function<void(SelectionHelper&, bool)>& elemUpdate, bool isSelected) {
bool hasBorders = selection.held || ((isSelected || selection.hovered) && drawType == DrawType::TRANSPARENT_BORDER);
SkColor4f borderColor = hasBorders ? io.theme->fillColor1 : SkColor4f{0.0f, 0.0f, 0.0f, 0.0f};
SkColor4f borderColor;
SkColor4f backgroundColorHighlight;
SkColor4f backgroundColor;
if(selection.held || ((isSelected || selection.hovered) && drawType == DrawType::TRANSPARENT_BORDER))
borderColor = io.theme->fillColor1;
else if(drawType == DrawType::TRANSPARENT_BORDER)
borderColor = io.theme->backColor2;
else
borderColor = SkColor4f{0.0f, 0.0f, 0.0f, 0.0f};
if(isSelected)
backgroundColorHighlight = color_mul_alpha(io.theme->fillColor1, 0.4f);
else if(selection.hovered || selection.held)

View file

@ -21,7 +21,7 @@ template <typename T> class TextBox : public Element {
CLAY({
.layout = {
.sizing = {.width = CLAY_SIZING_GROW(static_cast<float>(io.fontSize * 2)), .height = CLAY_SIZING_GROW(static_cast<float>(io.fontSize * 1.25f))}
.sizing = {.width = CLAY_SIZING_GROW(static_cast<float>(io.fontSize * 2)), .height = singleLine ? CLAY_SIZING_FIXED(static_cast<float>(io.fontSize * 1.25f)) : CLAY_SIZING_GROW(static_cast<float>(io.fontSize * 1.25f))}
},
.custom = { .customData = this }
}) {

View file

@ -545,7 +545,7 @@ void GUIManager::dropdown_select(const std::string& id, size_t* val, const std::
CLAY({.layout = {.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)}}}) {}
CLAY({
.layout = {
.sizing = {.width = CLAY_SIZING_FIT(20), .height = CLAY_SIZING_FIT(20)}
.sizing = {.width = CLAY_SIZING_FIT(SMALL_BUTTON_SIZE), .height = CLAY_SIZING_FIT(SMALL_BUTTON_SIZE)}
}
}) {
svg_icon("dropico", "data/icons/droparrow.svg", dropDownOpen);

View file

@ -719,7 +719,7 @@ void Toolbar::grid_menu(bool justOpened) {
gui.input_text("grid text input", &gridMenu.newName, [&](GUIStuff::SelectionHelper& s) {
addByEnter = s.selected && io->key.enter;
});
if(gui.svg_icon_button("grid add button", "data/icons/plus.svg", false, 25.0f) || (addByEnter && !gridMenu.newName.empty())) {
if(gui.svg_icon_button("grid add button", "data/icons/plus.svg", false, GUIStuff::GUIManager::SMALL_BUTTON_SIZE) || (addByEnter && !gridMenu.newName.empty())) {
main.world->drawProg.modify_grid(main.world->gridMan.add_default_grid(gridMenu.newName));
stop_displaying_grid_menu();
}
@ -805,7 +805,7 @@ void Toolbar::bookmark_menu(bool justOpened) {
addByEnter = s.selected && io->key.enter;
});
if(!bookmarkExists) {
if((gui.svg_icon_button("bookmark add button", "data/icons/plus.svg", false, 25.0f) || addByEnter) && !bookMenu.newName.empty())
if((gui.svg_icon_button("bookmark add button", "data/icons/plus.svg", false, GUIStuff::GUIManager::SMALL_BUTTON_SIZE) || addByEnter) && !bookMenu.newName.empty())
main.world->bMan.add_bookmark(bookMenu.newName);
}
});
@ -1015,7 +1015,7 @@ void Toolbar::drawing_program_gui() {
if(colorLeft) {
CLAY({
.layout = {
.sizing = {.width = CLAY_SIZING_FIT(250), .height = CLAY_SIZING_FIT(0)},
.sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0)},
.padding = CLAY_PADDING_ALL(io->theme->padding1),
.childGap = io->theme->childGap1,
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
@ -1040,7 +1040,7 @@ void Toolbar::drawing_program_gui() {
if(colorRight) {
CLAY({
.layout = {
.sizing = {.width = CLAY_SIZING_FIT(250), .height = CLAY_SIZING_FIT(0)},
.sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0)},
.padding = CLAY_PADDING_ALL(io->theme->padding1),
.childGap = io->theme->childGap1,
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},