|
3 | 3 | #include "dbus/upower/upower_service.h" |
4 | 4 | #include "render/core/renderer.h" |
5 | 5 | #include "render/scene/input_area.h" |
6 | | -#include "ui/controls/box.h" |
7 | | -#include "ui/controls/glyph.h" |
8 | | -#include "ui/controls/label.h" |
| 6 | +#include "ui/builders.h" |
9 | 7 | #include "ui/palette.h" |
10 | 8 | #include "ui/style.h" |
11 | 9 |
|
@@ -85,51 +83,51 @@ void BatteryWidget::create() { |
85 | 83 | void BatteryWidget::createGraphicMode() { |
86 | 84 | auto* container = static_cast<InputArea*>(root()); |
87 | 85 |
|
88 | | - auto bodyBg = std::make_unique<Box>(); |
89 | | - bodyBg->setFill(withOpacity(widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface)), 0.25f)); |
90 | | - m_bodyBg = bodyBg.get(); |
91 | | - container->addChild(std::move(bodyBg)); |
| 86 | + container->addChild(ui::box({ |
| 87 | + .out = &m_bodyBg, |
| 88 | + .fill = withOpacity(widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface)), 0.25f), |
| 89 | + })); |
92 | 90 |
|
93 | | - auto fillRect = std::make_unique<Box>(); |
94 | | - m_fillRect = fillRect.get(); |
95 | | - container->addChild(std::move(fillRect)); |
| 91 | + container->addChild(ui::box({ |
| 92 | + .out = &m_fillRect, |
| 93 | + })); |
96 | 94 |
|
97 | | - auto terminalNub = std::make_unique<Box>(); |
98 | | - terminalNub->setFill(withOpacity(widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface)), 0.25f)); |
99 | | - m_terminalNub = terminalNub.get(); |
100 | | - container->addChild(std::move(terminalNub)); |
| 95 | + container->addChild(ui::box({ |
| 96 | + .out = &m_terminalNub, |
| 97 | + .fill = withOpacity(widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface)), 0.25f), |
| 98 | + })); |
101 | 99 |
|
102 | 100 | if (m_showLabel) { |
103 | | - auto overlayLabel = std::make_unique<Label>(); |
104 | | - overlayLabel->setFontWeight(labelFontWeight()); |
105 | | - overlayLabel->setColor(widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface))); |
106 | | - m_overlayLabel = overlayLabel.get(); |
107 | | - container->addChild(std::move(overlayLabel)); |
| 101 | + container->addChild(ui::label({ |
| 102 | + .out = &m_overlayLabel, |
| 103 | + .color = widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface)), |
| 104 | + .fontWeight = labelFontWeight(), |
| 105 | + })); |
108 | 106 | } |
109 | 107 |
|
110 | | - auto overlayGlyph = std::make_unique<Glyph>(); |
111 | | - overlayGlyph->setColor(widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface))); |
112 | | - overlayGlyph->setVisible(false); |
113 | | - m_overlayGlyph = overlayGlyph.get(); |
114 | | - container->addChild(std::move(overlayGlyph)); |
| 108 | + container->addChild(ui::glyph({ |
| 109 | + .out = &m_overlayGlyph, |
| 110 | + .color = widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface)), |
| 111 | + .visible = false, |
| 112 | + })); |
115 | 113 | } |
116 | 114 |
|
117 | 115 | void BatteryWidget::createIconMode() { |
118 | 116 | auto* container = static_cast<InputArea*>(root()); |
119 | 117 |
|
120 | | - auto glyph = std::make_unique<Glyph>(); |
121 | | - glyph->setGlyph("battery-4"); |
122 | | - glyph->setGlyphSize(Style::barGlyphSize * m_contentScale); |
123 | | - glyph->setColor(widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface))); |
124 | | - m_glyph = glyph.get(); |
125 | | - container->addChild(std::move(glyph)); |
126 | | - |
127 | | - auto label = std::make_unique<Label>(); |
128 | | - label->setFontWeight(labelFontWeight()); |
129 | | - label->setFontSize(Style::fontSizeBody * m_contentScale); |
130 | | - label->setVisible(m_showLabel); |
131 | | - m_label = label.get(); |
132 | | - container->addChild(std::move(label)); |
| 118 | + container->addChild(ui::glyph({ |
| 119 | + .out = &m_glyph, |
| 120 | + .glyph = "battery-4", |
| 121 | + .glyphSize = Style::barGlyphSize * m_contentScale, |
| 122 | + .color = widgetForegroundOr(colorSpecFromRole(ColorRole::OnSurface)), |
| 123 | + })); |
| 124 | + |
| 125 | + container->addChild(ui::label({ |
| 126 | + .out = &m_label, |
| 127 | + .fontSize = Style::fontSizeBody * m_contentScale, |
| 128 | + .fontWeight = labelFontWeight(), |
| 129 | + .visible = m_showLabel, |
| 130 | + })); |
133 | 131 | } |
134 | 132 |
|
135 | 133 | void BatteryWidget::doLayout(Renderer& renderer, float containerWidth, float containerHeight) { |
|
0 commit comments