2020#include " system/weather_service.h"
2121#include " theme/theme_service.h"
2222#include " time/time_service.h"
23- #include " ui/controls/box.h"
24- #include " ui/controls/flex.h"
23+ #include " ui/builders.h"
2524#include " ui/palette.h"
2625#include " ui/style.h"
2726#include " util/string_utils.h"
@@ -1495,16 +1494,21 @@ void Bar::attachWidgetsToSections(BarInstance& instance) {
14951494 auto shell = std::make_unique<Node>();
14961495 Node* shellPtr = shell.get ();
14971496 shellPtr->setClipChildren (true );
1498- auto capsuleBg = std::make_unique<Box>();
1499- Box* bgPtr = capsuleBg.get ();
1500- capsuleBg->setFill (withOpacity (cap.fill , cap.opacity ));
15011497 const float scale = widget.contentScale ();
1502- if (cap.border .has_value ()) {
1503- capsuleBg->setBorder (*cap.border , Style::borderWidth * scale);
1504- } else {
1505- capsuleBg->clearBorder ();
1506- }
1507- capsuleBg->setZIndex (-1 );
1498+ Box* bgPtr = nullptr ;
1499+ auto capsuleBg = ui::box ({
1500+ .out = &bgPtr,
1501+ .fill = withOpacity (cap.fill , cap.opacity ),
1502+ .configure =
1503+ [&cap, scale](Box& bg) {
1504+ if (cap.border .has_value ()) {
1505+ bg.setBorder (*cap.border , Style::borderWidth * scale);
1506+ } else {
1507+ bg.clearBorder ();
1508+ }
1509+ bg.setZIndex (-1 );
1510+ },
1511+ });
15081512 shellPtr->addChild (std::move (capsuleBg));
15091513 shellPtr->addChild (widget.releaseRoot ());
15101514 widget.setBarCapsuleScene (shellPtr, bgPtr);
@@ -1571,23 +1575,29 @@ void Bar::attachWidgetsToSections(BarInstance& instance) {
15711575 auto shell = std::make_unique<Node>();
15721576 Node* shellPtr = shell.get ();
15731577 shellPtr->setClipChildren (true );
1574- auto capsuleBg = std::make_unique<Box>();
1575- Box* bgPtr = capsuleBg.get ();
1576- capsuleBg->setFill (withOpacity (cap.fill , cap.opacity ));
15771578 const float scale = widget->contentScale ();
1578- if (cap.border .has_value ()) {
1579- capsuleBg->setBorder (*cap.border , Style::borderWidth * scale);
1580- } else {
1581- capsuleBg->clearBorder ();
1582- }
1583- capsuleBg->setZIndex (-1 );
1579+ Box* bgPtr = nullptr ;
1580+ auto capsuleBg = ui::box ({
1581+ .out = &bgPtr,
1582+ .fill = withOpacity (cap.fill , cap.opacity ),
1583+ .configure =
1584+ [&cap, scale](Box& bg) {
1585+ if (cap.border .has_value ()) {
1586+ bg.setBorder (*cap.border , Style::borderWidth * scale);
1587+ } else {
1588+ bg.clearBorder ();
1589+ }
1590+ bg.setZIndex (-1 );
1591+ },
1592+ });
15841593 shellPtr->addChild (std::move (capsuleBg));
15851594
1586- auto inner = std::make_unique<Flex>();
1595+ auto inner =
1596+ ui::makeFlex (isVertical ? FlexDirection::Vertical : FlexDirection::Horizontal, {
1597+ .align = FlexAlign::Center,
1598+ .gap = widgetSpacing,
1599+ });
15871600 Flex* innerPtr = inner.get ();
1588- innerPtr->setDirection (isVertical ? FlexDirection::Vertical : FlexDirection::Horizontal);
1589- innerPtr->setGap (widgetSpacing);
1590- innerPtr->setAlign (FlexAlign::Center);
15911601 shellPtr->addChild (std::move (inner));
15921602
15931603 BarCapsuleRun run;
@@ -1847,28 +1857,25 @@ void Bar::buildScene(BarInstance& instance, std::uint32_t width, std::uint32_t h
18471857 instance.slideRoot = instance.sceneRoot ->addChild (std::move (slide));
18481858
18491859 // Bar background
1850- auto bg = std::make_unique<Box>();
1851- instance.bg = static_cast <Box*>(instance.slideRoot ->addChild (std::move (bg)));
1860+ instance.bg = static_cast <Box*>(instance.slideRoot ->addChild (ui::box ()));
18521861
18531862 // Shadow — bar shape copy rendered with large SDF softness to simulate a blurred drop shadow.
18541863 if (shadowSize > 0 .0f ) {
1855- auto shadow = std::make_unique <Box>();
1856- shadow-> setHitTestVisible (false );
1857- instance. shadow = static_cast <Box*>(instance. slideRoot -> addChild ( std::move (shadow )));
1864+ instance. shadow = static_cast <Box*>(instance. slideRoot -> addChild ( ui::box ({
1865+ . configure = [](Box& shadow) { shadow. setHitTestVisible (false ); },
1866+ } )));
18581867
18591868 auto leftClip = std::make_unique<Node>();
18601869 leftClip->setClipChildren (true );
18611870 leftClip->setZIndex (-1 );
18621871 instance.shadowLeftClip = instance.slideRoot ->addChild (std::move (leftClip));
1863- auto leftShadow = std::make_unique<Box>();
1864- instance.shadowLeft = static_cast <Box*>(instance.shadowLeftClip ->addChild (std::move (leftShadow)));
1872+ instance.shadowLeft = static_cast <Box*>(instance.shadowLeftClip ->addChild (ui::box ()));
18651873
18661874 auto rightClip = std::make_unique<Node>();
18671875 rightClip->setClipChildren (true );
18681876 rightClip->setZIndex (-1 );
18691877 instance.shadowRightClip = instance.slideRoot ->addChild (std::move (rightClip));
1870- auto rightShadow = std::make_unique<Box>();
1871- instance.shadowRight = static_cast <Box*>(instance.shadowRightClip ->addChild (std::move (rightShadow)));
1878+ instance.shadowRight = static_cast <Box*>(instance.shadowRightClip ->addChild (ui::box ()));
18721879 }
18731880 // Note: shadow is inserted before bar sections so it renders below them (z=-1 is set below).
18741881
@@ -1887,11 +1894,11 @@ void Bar::buildScene(BarInstance& instance, std::uint32_t width, std::uint32_t h
18871894
18881895 // Create section boxes
18891896 auto makeSection = [widgetSpacing, isVertical]() {
1890- auto box = std::make_unique<Flex>();
1891- box-> setDirection (isVertical ? FlexDirection::Vertical : FlexDirection::Horizontal);
1892- box-> setGap (widgetSpacing);
1893- box-> setAlign (FlexAlign::Center);
1894- return box ;
1897+ return ui::makeFlex (isVertical ? FlexDirection::Vertical : FlexDirection::Horizontal,
1898+ {
1899+ . align = FlexAlign::Center,
1900+ . gap = widgetSpacing,
1901+ }) ;
18951902 };
18961903
18971904 instance.startSection = static_cast <Flex*>(instance.startSlot ->addChild (makeSection ()));
0 commit comments