Somewhat Fixed Checkbox drawing.

This commit is contained in:
2025-06-26 06:02:30 -05:00
parent 67416540d4
commit 393ad1b2b3
2 changed files with 4 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ namespace JUI {
protected:
bool checked = false;
Color4 check_color = Style::Checkbox::CheckmarkColor;
Color4 uncheck_color = Style::BackgroundColor;
};
class Checkbox : public Button, public CheckboxBase {

View File

@@ -22,12 +22,14 @@ namespace JUI {
void Checkbox::InnerDraw() {
Rect::InnerDraw();
// TODO: Renders too large with BorderMode::Inset
if (checked) {
Vector2 pos_pad = ComputeElementPadding(GetAbsoluteSize(), {PaddingLeft(), PaddingTop()});
Vector2 size_pad = ComputeElementPadding(GetAbsoluteSize(), {PaddingLeft()+PaddingRight(), PaddingTop()+PaddingBottom()});
Vector2 padded_pos = GetAbsolutePosition() + pos_pad;
Vector2 padded_size = GetAbsoluteSize() - size_pad;
RectBase::Draw(check_color, check_color, padded_pos, padded_size);
RectBase::Draw(check_color, border_color, padded_pos, padded_size);
}
}
}