Skip to content

Commit 452cc58

Browse files
committed
feat(plugins): expose radius and padding on button nodes
Button already inherits Flex's setRadius/setPadding; allowlist the props and apply them the same way the row/column branch does, so plugin chips can render as capsules without giving up click handling. Written with AI assistance (Claude Fable 5).
1 parent ab16afc commit 452cc58

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

src/ui/ui_tree_reconciler.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,11 @@ namespace ui {
279279
"color", "spacing", "orientation"};
280280
static const std::unordered_set<std::string> kProgress = {"width", "height", "flexGrow", "opacity", "visible",
281281
"progress", "fill", "track", "radius"};
282-
static const std::unordered_set<std::string> kButton = {"width", "height", "flexGrow", "opacity",
283-
"visible", "text", "glyph", "fontSize",
284-
"glyphSize", "variant", "contentAlign", "enabled",
285-
"selected", "onClick", "onRightClick"};
282+
static const std::unordered_set<std::string> kButton = {"width", "height", "flexGrow", "opacity",
283+
"visible", "text", "glyph", "fontSize",
284+
"glyphSize", "variant", "contentAlign", "enabled",
285+
"selected", "onClick", "onRightClick", "radius",
286+
"padding", "paddingH", "paddingV"};
286287
static const std::unordered_set<std::string> kGraph = {"width", "height", "flexGrow", "opacity",
287288
"visible", "values", "values2", "color",
288289
"color2", "lineWidth", "fillOpacity"};
@@ -894,6 +895,21 @@ namespace ui {
894895
button->setMinHeight(0.0f);
895896
button->setPadding(Style::spaceXs * m_scale);
896897
}
898+
// Button is a Flex, so shape/inset setters are inherited; expose them
899+
// the same way the row/column branch does. Applied after the compact
900+
// block so explicit props always win over host chrome defaults.
901+
if (const double* radius = numProp(desired, "radius")) {
902+
button->setRadius(scaled(*radius));
903+
}
904+
const double* padding = numProp(desired, "padding");
905+
const double* paddingV = numProp(desired, "paddingV");
906+
const double* paddingH = numProp(desired, "paddingH");
907+
if (padding != nullptr || paddingV != nullptr || paddingH != nullptr) {
908+
const float fallback = padding != nullptr ? scaled(*padding) : 0.0f;
909+
button->setPadding(
910+
paddingV != nullptr ? scaled(*paddingV) : fallback, paddingH != nullptr ? scaled(*paddingH) : fallback
911+
);
912+
}
897913
if (width != nullptr) {
898914
button->setMinWidth(scaled(*width));
899915
button->setMaxWidth(scaled(*width));

0 commit comments

Comments
 (0)