88#include " shell/control_center/tab.h"
99#include " shell/panel/panel_manager.h"
1010#include " time/time_format.h"
11- #include " ui/controls/button.h"
12- #include " ui/controls/flex.h"
11+ #include " ui/builders.h"
1312#include " ui/controls/grid_tile.h"
1413#include " ui/controls/grid_view.h"
15- #include " ui/controls/label.h"
1614
1715#include < algorithm>
1816#include < array>
@@ -95,11 +93,11 @@ CalendarTab::CalendarTab(ConfigService* config) : m_config(config) {}
9593std::unique_ptr<Flex> CalendarTab::create () {
9694 const float scale = contentScale ();
9795
98- auto tab = std::make_unique<Flex>();
99- tab-> setDirection (FlexDirection::Horizontal);
100- tab-> setAlign ( FlexAlign::Stretch);
101- tab-> setGap ( Style::spaceMd * scale);
102- m_rootLayout = tab. get ( );
96+ auto tab = ui::row ({
97+ . out = &m_rootLayout,
98+ . align = FlexAlign::Stretch,
99+ . gap = Style::spaceMd * scale,
100+ } );
103101
104102 auto calendarArea = std::make_unique<InputArea>();
105103 calendarArea->setFlexGrow (3 .0f );
@@ -124,111 +122,98 @@ std::unique_ptr<Flex> CalendarTab::create() {
124122 });
125123 m_calendarArea = calendarArea.get ();
126124
127- auto calendarCard = std::make_unique<Flex>();
128- control_center::applySectionCardStyle (*calendarCard, scale, panelCardOpacity (), panelBordersEnabled ());
129- calendarCard->setGap (Style::spaceMd * scale);
130- m_card = calendarCard.get ();
131-
132- auto header = std::make_unique<Flex>();
133- header->setDirection (FlexDirection::Horizontal);
134- header->setAlign (FlexAlign::Center);
135- header->setJustify (FlexJustify::SpaceBetween);
136- header->setGap (Style::spaceSm * scale);
137- header->setMinHeight (kCalendarHeaderHeight * scale);
138- m_header = header.get ();
139-
140- auto previousSlot = std::make_unique<Flex>();
141- previousSlot->setDirection (FlexDirection::Horizontal);
142- previousSlot->setAlign (FlexAlign::Center);
143- previousSlot->setJustify (FlexJustify::Center);
144- m_previousSlot = previousSlot.get ();
145-
146- auto previous = std::make_unique<Button>();
147- previous->setGlyph (" chevron-left" );
148- previous->setVariant (ButtonVariant::Ghost);
149- previous->setMinWidth (kCalendarNavButtonSize * scale);
150- previous->setMinHeight (kCalendarNavButtonSize * scale);
151- previous->setOnClick ([this ]() {
152- --m_monthOffset;
153- PanelManager::instance ().refresh ();
125+ auto calendarCard = ui::column ({
126+ .out = &m_card,
127+ .gap = Style::spaceMd * scale,
128+ .configure = [scale, opacity = panelCardOpacity (), borders = panelBordersEnabled ()](
129+ Flex& card) { control_center::applySectionCardStyle (card, scale, opacity, borders); },
130+ });
131+
132+ auto header = ui::row ({
133+ .out = &m_header,
134+ .align = FlexAlign::Center,
135+ .justify = FlexJustify::SpaceBetween,
136+ .gap = Style::spaceSm * scale,
137+ .minHeight = kCalendarHeaderHeight * scale,
154138 });
155- m_previousButton = previous.get ();
156- previousSlot->addChild (std::move (previous));
139+
140+ auto previousSlot = ui::row ({.out = &m_previousSlot, .align = FlexAlign::Center, .justify = FlexJustify::Center},
141+ ui::button ({
142+ .out = &m_previousButton,
143+ .glyph = " chevron-left" ,
144+ .variant = ButtonVariant::Ghost,
145+ .minWidth = kCalendarNavButtonSize * scale,
146+ .minHeight = kCalendarNavButtonSize * scale,
147+ .onClick =
148+ [this ]() {
149+ --m_monthOffset;
150+ PanelManager::instance ().refresh ();
151+ },
152+ }));
157153 header->addChild (std::move (previousSlot));
158154
159- auto monthWrap = std::make_unique<Flex>();
160- monthWrap->setDirection (FlexDirection::Vertical);
161- monthWrap->setAlign (FlexAlign::Center);
162- monthWrap->setJustify (FlexJustify::Center);
163- monthWrap->setFlexGrow (1 .0f );
164- m_monthWrap = monthWrap.get ();
165-
166- auto month = std::make_unique<Label>();
167- month->setFontWeight (FontWeight::Bold);
168- month->setFontSize ((Style::fontSizeTitle + Style::spaceXs) * scale);
169- month->setMaxLines (1 );
170- month->setColor (colorSpecFromRole (ColorRole::OnSurface));
171- m_monthLabel = month.get ();
172- monthWrap->addChild (std::move (month));
173-
174- auto monthSub = std::make_unique<Label>();
175- monthSub->setText (formatShellDate (m_config));
176- monthSub->setCaptionStyle ();
177- monthSub->setFontSize (Style::fontSizeCaption * scale);
178- monthSub->setColor (colorSpecFromRole (ColorRole::OnSurfaceVariant));
179- monthSub->setMaxLines (1 );
180- m_monthSubLabel = monthSub.get ();
181- monthWrap->addChild (std::move (monthSub));
155+ auto monthWrap =
156+ ui::column ({.out = &m_monthWrap, .align = FlexAlign::Center, .justify = FlexJustify::Center, .flexGrow = 1 .0f },
157+ ui::label ({
158+ .out = &m_monthLabel,
159+ .fontSize = (Style::fontSizeTitle + Style::spaceXs) * scale,
160+ .color = colorSpecFromRole (ColorRole::OnSurface),
161+ .maxLines = 1 ,
162+ .fontWeight = FontWeight::Bold,
163+ }),
164+ ui::label ({
165+ .out = &m_monthSubLabel,
166+ .text = formatShellDate (m_config),
167+ .fontSize = Style::fontSizeCaption * scale,
168+ .color = colorSpecFromRole (ColorRole::OnSurfaceVariant),
169+ .maxLines = 1 ,
170+ .configure = [](Label& label) { label.setCaptionStyle (); },
171+ }));
182172 header->addChild (std::move (monthWrap));
183173
184- auto nextSlot = std::make_unique<Flex>();
185- nextSlot->setDirection (FlexDirection::Horizontal);
186- nextSlot->setAlign (FlexAlign::Center);
187- nextSlot->setJustify (FlexJustify::Center);
188- m_nextSlot = nextSlot.get ();
189-
190- auto next = std::make_unique<Button>();
191- next->setGlyph (" chevron-right" );
192- next->setVariant (ButtonVariant::Ghost);
193- next->setMinWidth (kCalendarNavButtonSize * scale);
194- next->setMinHeight (kCalendarNavButtonSize * scale);
195- next->setOnClick ([this ]() {
196- ++m_monthOffset;
197- PanelManager::instance ().refresh ();
198- });
199- m_nextButton = next.get ();
200- nextSlot->addChild (std::move (next));
174+ auto nextSlot = ui::row ({.out = &m_nextSlot, .align = FlexAlign::Center, .justify = FlexJustify::Center},
175+ ui::button ({
176+ .out = &m_nextButton,
177+ .glyph = " chevron-right" ,
178+ .variant = ButtonVariant::Ghost,
179+ .minWidth = kCalendarNavButtonSize * scale,
180+ .minHeight = kCalendarNavButtonSize * scale,
181+ .onClick =
182+ [this ]() {
183+ ++m_monthOffset;
184+ PanelManager::instance ().refresh ();
185+ },
186+ }));
201187 header->addChild (std::move (nextSlot));
202188
203189 calendarCard->addChild (std::move (header));
204190
205- auto grid = std::make_unique<Flex>();
206- grid-> setDirection (FlexDirection::Vertical);
207- grid-> setAlign ( FlexAlign::Stretch);
208- grid-> setGap ( kCalendarGridGap * scale);
209- grid-> setFlexGrow ( 1 .0f );
210- m_grid = grid. get ( );
191+ auto grid = ui::column ({
192+ . out = &m_grid,
193+ . align = FlexAlign::Stretch,
194+ . gap = kCalendarGridGap * scale,
195+ . flexGrow = 1 .0f ,
196+ } );
211197 calendarCard->addChild (std::move (grid));
212198 calendarArea->addChild (std::move (calendarCard));
213199 tab->addChild (std::move (calendarArea));
214200
215- auto tasksCard = std::make_unique<Flex>();
216- control_center::applySectionCardStyle (*tasksCard, scale, panelCardOpacity (), panelBordersEnabled ());
217- tasksCard->setFlexGrow (2 .0f );
218-
219- auto tasksTitle = std::make_unique<Label>();
220- tasksTitle->setText (i18n::tr (" control-center.calendar.tasks" ));
221- tasksTitle->setFontWeight (FontWeight::Bold);
222- tasksTitle->setFontSize (Style::fontSizeTitle * scale);
223- tasksTitle->setColor (colorSpecFromRole (ColorRole::OnSurface));
224- tasksCard->addChild (std::move (tasksTitle));
225-
226- auto tasksBody = std::make_unique<Label>();
227- tasksBody->setText (i18n::tr (" control-center.calendar.no-tasks" ));
228- tasksBody->setFontSize (Style::fontSizeBody * scale);
229- tasksBody->setColor (colorSpecFromRole (ColorRole::OnSurfaceVariant));
230- tasksBody->setMaxLines (3 );
231- tasksCard->addChild (std::move (tasksBody));
201+ auto tasksCard = ui::column (
202+ {.flexGrow = 2 .0f ,
203+ .configure = [scale, opacity = panelCardOpacity (), borders = panelBordersEnabled ()](
204+ Flex& card) { control_center::applySectionCardStyle (card, scale, opacity, borders); }},
205+ ui::label ({
206+ .text = i18n::tr (" control-center.calendar.tasks" ),
207+ .fontSize = Style::fontSizeTitle * scale,
208+ .color = colorSpecFromRole (ColorRole::OnSurface),
209+ .fontWeight = FontWeight::Bold,
210+ }),
211+ ui::label ({
212+ .text = i18n::tr (" control-center.calendar.no-tasks" ),
213+ .fontSize = Style::fontSizeBody * scale,
214+ .color = colorSpecFromRole (ColorRole::OnSurfaceVariant),
215+ .maxLines = 3 ,
216+ }));
232217
233218 tab->addChild (std::move (tasksCard));
234219
@@ -373,14 +358,14 @@ void CalendarTab::rebuild() {
373358 dayCell->setAlign (FlexAlign::Center);
374359 dayCell->setJustify (FlexJustify::Center);
375360
376- auto dayLabel = std::make_unique<Label>();
377- dayLabel->setText (weekdays[i]);
378- dayLabel->setFontSize ((Style::fontSizeCaption + 1 .0f ) * scale);
379- dayLabel->setFontWeight (FontWeight::Bold);
380361 const int columnWeekday = (firstDayOfWeek + static_cast <int >(i)) % 7 ;
381362 const bool weekend = columnWeekday == 0 || columnWeekday == 6 ;
382- dayLabel->setColor (colorSpecFromRole (weekend ? ColorRole::Secondary : ColorRole::OnSurfaceVariant));
383- dayCell->addChild (std::move (dayLabel));
363+ dayCell->addChild (ui::label ({
364+ .text = weekdays[i],
365+ .fontSize = (Style::fontSizeCaption + 1 .0f ) * scale,
366+ .color = colorSpecFromRole (weekend ? ColorRole::Secondary : ColorRole::OnSurfaceVariant),
367+ .fontWeight = FontWeight::Bold,
368+ }));
384369
385370 weekdayRow->addChild (std::move (dayCell));
386371 }
@@ -406,16 +391,18 @@ void CalendarTab::rebuild() {
406391 dayTile->setAlign (FlexAlign::Center);
407392 dayTile->setJustify (FlexJustify::Center);
408393
409- auto dayButton = std::make_unique<Button>();
410- dayButton->setVariant (ButtonVariant::Ghost);
411- dayButton->setContentAlign (ButtonContentAlign::Center);
412- dayButton->setPadding (0 .0f );
413- dayButton->setMinWidth (dayButtonSize);
414- dayButton->setMinHeight (dayButtonSize);
415- dayButton->setSize (dayButtonSize, dayButtonSize);
416- dayButton->setRadius (Style::scaledRadiusMd (scale));
417- dayButton->setFontSize (Style::fontSizeBody * scale);
418- dayButton->setText (" " );
394+ auto dayButton = ui::button ({
395+ .text = " " ,
396+ .fontSize = Style::fontSizeBody * scale,
397+ .contentAlign = ButtonContentAlign::Center,
398+ .variant = ButtonVariant::Ghost,
399+ .minWidth = dayButtonSize,
400+ .minHeight = dayButtonSize,
401+ .padding = 0 .0f ,
402+ .radius = Style::scaledRadiusMd (scale),
403+ .width = dayButtonSize,
404+ .height = dayButtonSize,
405+ });
419406
420407 if (index < firstWeekdayOffset) {
421408 const int leadingDay = previousMonthDays - firstWeekdayOffset + index + 1 ;
0 commit comments