/
SilovAndrey
/
easel_gui
Обзор
Документация
Войти
/
SilovAndrey
/
easel_gui
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/vstack.cpp
45 строк
1 KB
Andrey HomePC
первая рабочая версия
21 июл 2026, 11:50
21 июл 2026, 11:50
38b8d4a
Код
Авторство
О чём код?
module; #include <vector> #include <memory> #include <thorvg.h> module Easel.GUI; namespace easel::gui { WidgetPtr vstack(std::vector<WidgetPtr> children, Theme const& theme) { struct VStackWidget : Widget { VStackWidget(std::vector<std::unique_ptr<Widget>> ch, Theme const& th) : m_children(std::move(ch)), m_theme(th) {} void render(tvg::Canvas* canvas) override { for (auto& child : m_children) child->render(canvas); } bool on_event(Event const& evt) override { for (auto it = m_children.rbegin(); it != m_children.rend(); ++it) if ((*it)->on_event(evt)) return true; return false; } protected: void on_resize(rect const& bounds) override { float y = bounds.y; for (auto& child : m_children) { float h = child->bounds().h > 0 ? child->bounds().h : 40; child->resize({bounds.x + m_theme.spacing, y, bounds.w - m_theme.spacing * 2, h}); y += h + m_theme.spacing; } } private: std::vector<std::unique_ptr<Widget>> m_children; Theme m_theme; }; return std::make_unique<VStackWidget>(std::move(children), theme); } } // namespace easel::gui