Skip to content

Commit fcd8a62

Browse files
committed
ui: buttons builder cleanup
1 parent ba097f4 commit fcd8a62

15 files changed

Lines changed: 398 additions & 465 deletions

src/shell/clipboard/clipboard_panel.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,14 @@ namespace {
138138
.glyph = std::move(glyph),
139139
.glyphSize = Style::fontSizeBody * scale,
140140
.variant = variant,
141+
// Compact entry action style.
142+
.minWidth = Style::controlHeightSm * scale,
143+
.minHeight = Style::controlHeightSm * scale,
144+
.padding = Style::spaceXs * scale,
145+
.radius = Style::scaledRadiusMd(scale),
141146
.visible = visible,
142147
.participatesInLayout = participatesInLayout,
143148
.onClick = std::move(onClick),
144-
.configure =
145-
[scale](Button& button) {
146-
button.setMinWidth(Style::controlHeightSm * scale);
147-
button.setMinHeight(Style::controlHeightSm * scale);
148-
button.setPadding(Style::spaceXs * scale);
149-
button.setRadius(Style::scaledRadiusMd(scale));
150-
},
151149
});
152150
}
153151

@@ -541,9 +539,15 @@ void ClipboardPanel::create() {
541539
ui::button({
542540
.out = &m_closeButton,
543541
.glyph = "close",
542+
.glyphSize = Style::fontSizeBody * scale,
543+
.minWidth = Style::controlHeightSm * scale,
544+
.minHeight = Style::controlHeightSm * scale,
545+
.padding = Style::spaceXs * scale,
546+
.radius = Style::scaledRadiusMd(scale),
544547
.onClick = []() { PanelManager::instance().close(); },
548+
// Preview header icon style.
545549
.configure = [scale, opacity = panelCardOpacity()](
546-
Button& button) { panel_button_style::configureHeaderIconButton(button, scale, opacity); },
550+
Button& button) { panel_button_style::applyHeaderButtonStyle(button, opacity); },
547551
}));
548552

549553
auto previewHeader = ui::row(

src/shell/settings/bar_widget_editor.cpp

Lines changed: 67 additions & 104 deletions
Large diffs are not rendered by default.

src/shell/settings/config_export_dialog_popup.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,6 @@ namespace settings {
176176
.padding = popupPadding,
177177
});
178178

179-
const auto configureIconButton = [this](Button& button) {
180-
button.setMinWidth(Style::controlHeightSm * m_scale);
181-
button.setMinHeight(Style::controlHeightSm * m_scale);
182-
button.setPadding(Style::spaceXs * m_scale);
183-
button.setRadius(Style::scaledRadiusMd(m_scale));
184-
};
185-
186179
root->addChild(ui::row(
187180
{
188181
.align = FlexAlign::Center,
@@ -199,8 +192,12 @@ namespace settings {
199192
.glyph = "close",
200193
.glyphSize = Style::fontSizeBody * m_scale,
201194
.variant = ButtonVariant::Default,
195+
// Dialog header icon style.
196+
.minWidth = Style::controlHeightSm * m_scale,
197+
.minHeight = Style::controlHeightSm * m_scale,
198+
.padding = Style::spaceXs * m_scale,
199+
.radius = Style::scaledRadiusMd(m_scale),
202200
.onClick = [this]() { DeferredCall::callLater([this]() { close(); }); },
203-
.configure = configureIconButton,
204201
})));
205202

206203
root->addChild(ui::column(
@@ -213,12 +210,6 @@ namespace settings {
213210
makeOption(ConfigExportMode::FullEffective, i18n::tr("settings.export-config.full-effective-title"),
214211
i18n::tr("settings.export-config.full-effective-description"))));
215212

216-
const auto configureFooterButton = [this](Button& button) {
217-
button.setMinHeight(Style::controlHeight * m_scale);
218-
button.setPadding(Style::spaceXs * m_scale, Style::spaceMd * m_scale);
219-
button.setRadius(Style::scaledRadiusMd(m_scale));
220-
};
221-
222213
root->addChild(ui::row(
223214
{
224215
.align = FlexAlign::Center,
@@ -229,15 +220,23 @@ namespace settings {
229220
.text = i18n::tr("common.actions.cancel"),
230221
.fontSize = Style::fontSizeBody * m_scale,
231222
.variant = ButtonVariant::Ghost,
223+
// Dialog footer action style.
224+
.minHeight = Style::controlHeight * m_scale,
225+
.paddingV = Style::spaceXs * m_scale,
226+
.paddingH = Style::spaceMd * m_scale,
227+
.radius = Style::scaledRadiusMd(m_scale),
232228
.onClick = [this]() { DeferredCall::callLater([this]() { close(); }); },
233-
.configure = configureFooterButton,
234229
}),
235230
ui::button({
236231
.text = i18n::tr("settings.export-config.export"),
237232
.fontSize = Style::fontSizeBody * m_scale,
238233
.variant = ButtonVariant::Primary,
234+
// Dialog footer action style.
235+
.minHeight = Style::controlHeight * m_scale,
236+
.paddingV = Style::spaceXs * m_scale,
237+
.paddingH = Style::spaceMd * m_scale,
238+
.radius = Style::scaledRadiusMd(m_scale),
239239
.onClick = [this]() { DeferredCall::callLater([this]() { accept(); }); },
240-
.configure = configureFooterButton,
241240
})));
242241

243242
contentParent->addChild(std::move(root));

src/shell/settings/search_picker_popup.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,11 @@ namespace settings {
125125
.glyph = "close",
126126
.glyphSize = Style::fontSizeBody * m_scale,
127127
.variant = ButtonVariant::Default,
128+
.minWidth = Style::controlHeightSm * m_scale,
129+
.minHeight = Style::controlHeightSm * m_scale,
130+
.padding = Style::spaceXs * m_scale,
131+
.radius = Style::scaledRadiusMd(m_scale),
128132
.onClick = [this]() { DeferredCall::callLater([this]() { close(); }); },
129-
.configure =
130-
[this](Button& button) {
131-
button.setMinWidth(Style::controlHeightSm * m_scale);
132-
button.setMinHeight(Style::controlHeightSm * m_scale);
133-
button.setPadding(Style::spaceXs * m_scale);
134-
button.setRadius(Style::scaledRadiusMd(m_scale));
135-
},
136133
})),
137134
ui::searchPicker({
138135
.out = &m_searchPicker,

src/shell/settings/session_actions_editor_popup.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,33 +146,35 @@ namespace settings {
146146
}));
147147
header->addChild(ui::spacer());
148148

149-
const auto configureIconButton = [this](Button& button) {
150-
button.setGlyphSize(Style::fontSizeBody * m_scale);
151-
button.setMinWidth(Style::controlHeightSm * m_scale);
152-
button.setMinHeight(Style::controlHeightSm * m_scale);
153-
button.setPadding(Style::spaceXs * m_scale);
154-
button.setRadius(Style::scaledRadiusMd(m_scale));
155-
};
156-
157149
if (m_removeAction) {
158150
header->addChild(ui::button({
159151
.glyph = "trash",
152+
.glyphSize = Style::fontSizeBody * m_scale,
160153
.variant = ButtonVariant::Destructive,
154+
// Sheet header icon style.
155+
.minWidth = Style::controlHeightSm * m_scale,
156+
.minHeight = Style::controlHeightSm * m_scale,
157+
.padding = Style::spaceXs * m_scale,
158+
.radius = Style::scaledRadiusMd(m_scale),
161159
.onClick =
162160
[removeAction = m_removeAction]() {
163161
if (removeAction) {
164162
DeferredCall::callLater(removeAction);
165163
}
166164
},
167-
.configure = configureIconButton,
168165
}));
169166
}
170167

171168
header->addChild(ui::button({
172169
.glyph = "close",
170+
.glyphSize = Style::fontSizeBody * m_scale,
173171
.variant = ButtonVariant::Default,
172+
// Sheet header icon style.
173+
.minWidth = Style::controlHeightSm * m_scale,
174+
.minHeight = Style::controlHeightSm * m_scale,
175+
.padding = Style::spaceXs * m_scale,
176+
.radius = Style::scaledRadiusMd(m_scale),
174177
.onClick = [this]() { DeferredCall::callLater([this]() { close(); }); },
175-
.configure = configureIconButton,
176178
}));
177179
root->addChild(std::move(header));
178180

src/shell/settings/settings_bar_management.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ namespace settings {
4040
props.fontSize = Style::fontSizeCaption * scale;
4141
props.enabled = enabled;
4242
props.variant = variant;
43+
props.minHeight = Style::controlHeightSm * scale;
44+
props.paddingV = Style::spaceXs * scale;
45+
props.paddingH = Style::spaceSm * scale;
46+
props.radius = Style::scaledRadiusSm(scale);
4347
props.onClick = std::move(onClick);
44-
props.configure = [scale](Button& button) {
45-
button.setMinHeight(Style::controlHeightSm * scale);
46-
button.setPadding(Style::spaceXs * scale, Style::spaceSm * scale);
47-
button.setRadius(Style::scaledRadiusSm(scale));
48-
};
4948
return ui::button(std::move(props));
5049
}
5150

0 commit comments

Comments
 (0)