# WUI (Window User Interface Library) **WUI** — кроссплатформенная C++ библиотека для создания графических интерфейсов. ## Quick Start ```cpp #include #include #include int main() { wui::framework::init(); auto window = std::make_shared(); auto button = std::make_shared("Click me", []() { // Handle click }); window->add_control(button, {10, 10, 100, 35}); window->init("Hello WUI!", {-1, -1, 400, 300}); wui::framework::run(); return 0; } ``` ## Key Features - **C++17** — современный стандарт без исключений - **Кроссплатформа** — Windows (WinAPI+GDI), Linux (X11+xcb), macOS в разработке - **Минимум зависимостей** — 0 внешних библиотек (json/utf bundled в thirdparty/) - **Плоская модель владения** — контролы владеются через std::shared_ptr - **События через хаб** — std::function коллбеки, без макросов и MOC - **Прозрачная архитектура** — весь платформенный код в 2 файлах (window.cpp, graphic.cpp) ## Architecture ``` ┌─────────────────────────────────────────┐ │ Cross-Platform Core │ │ (Controls, Events, Layout, Logic) │ └────────────────────┬────────────────────┘ │ ┌───────────┴───────────┐ ▼ ▼ ┌─────────────────┐ ┌─────────────────┐ │ window.cpp │ │ graphic.cpp │ │ WinAPI / XCB │ │ GDI / Cairo │ │ Window & Input │ │ Rendering │ └─────────────────┘ └─────────────────┘ ``` ## Installation ```bash # CMake find_package(libwui REQUIRED) target_link_libraries(your_app PRIVATE wui) # Или напрямую в проекте add_subdirectory(wui) target_link_libraries(your_app PRIVATE wui) ``` ## Components ### Core - `window` — окно, системные события, управление контролами - `control` — базовый класс для всех контролов - `graphic` — интерфейс отрисовки (абстракция над GDI/Cairo) ### Controls - `button` — кнопка с текстом/иконой - `text` — текстовая метка - `image` — изображение - `text_field` — поле ввода текста - `list` — список - `panel` — панель-контейнер - `dialog` — модальное/немодальное окно ### Common Types - `rect` — прямоугольник (x, y, width, height) - `color` — цвет (r, g, b, a) - `font` — шрифт (family, size, weight) ### Events - `event_type::mouse` — события мыши - `event_type::keyboard` — события клавиатуры - `event_type::system` — системные события - `event_type::internal` — внутренние события контролов ## Event System ```cpp // Подписка на события std::string sub_id = window->subscribe( [](const wui::event& ev) { if (ev.type == wui::event_type::keyboard) { // Handle keyboard event } }, wui::event_type::keyboard | wui::event_type::system ); // Отписка window->unsubscribe(sub_id); ``` ## Flat Ownership Model ```cpp class MyDialog { std::shared_ptr window_; std::shared_ptr ok_button_; std::shared_ptr cancel_button_; public: MyDialog() { window_ = std::make_shared(); ok_button_ = std::make_shared("OK", []() { /* ... */ }); cancel_button_ = std::make_shared("Cancel", []() { /* ... */ }); window_->add_control(ok_button_, {10, 10, 80, 30}); window_->add_control(cancel_button_, {100, 10, 80, 30}); } }; // При уничтожении MyDialog все контролы автоматически освобождаются ``` ## Platform Support | Platform | Status | Backend | |----------|--------|---------| | Windows XP–11 | ✅ Stable | WinAPI + GDI | | Linux (glibc 2.23+) | ✅ Stable | X11 + xcb + Cairo | | macOS | 🔄 Coming soon | TBD | ## License **BSL-1.0** (Boost Software License) - ✅ Коммерческое использование без ограничений - ✅ Можно закрывать код продукта - ✅ Нет необходимости платить лицензионные отчисления - ⚠️ Укажите автора в документации ## Resources - **GitHub**: https://github.com/intent-garden/wui - **Documentation**: https://libwui.org/doc/ (EN), https://libwui.org/doc_ru/ (RU) - **Telegram**: https://t.me/libwui_chat - **Email**: info@libwui.org ## Used By - **Decima-8** — нейроморфная IDE (4096 тайлов @ 60 FPS, ~1.3 MB бинарь) - **VideoGrace** — on-premise видеоконференцсвязь (~10 MB static link) ## Third-Party Libraries WUI включает bundled версии: - `json` — работа с JSON - `utf` — UTF-8 обработка Обе библиотеки находятся в `thirdparty/` и не требуют внешней установки.