From 7de921836587cdc359c2c4b84ed6446ada16c008 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 22 May 2022 17:05:00 +0200 Subject: refactor: remove window class --- src/engine/graphics/scene.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/engine/graphics/scene.cpp') diff --git a/src/engine/graphics/scene.cpp b/src/engine/graphics/scene.cpp index 73c1292..52613d8 100644 --- a/src/engine/graphics/scene.cpp +++ b/src/engine/graphics/scene.cpp @@ -5,17 +5,17 @@ #include #include + #include +#include #include Scene::Scene( IMatrixFactory matrix_factory, - std::shared_ptr cursor_controller, - std::shared_ptr window) noexcept + std::shared_ptr cursor_controller) noexcept : _is_shown(false), - _matrix(matrix_factory(window->size() - Bounds({.width = 0U, .height = 1U}))), - _cursor_controller(std::move(cursor_controller)), - _window(std::move(window)) + _matrix(matrix_factory(size() - Bounds({.width = 0U, .height = 1U}))), + _cursor_controller(std::move(cursor_controller)) { _matrix->fill(" "); } @@ -46,6 +46,16 @@ void Scene::leave() noexcept _is_shown = false; } +auto Scene::size() const noexcept -> Bounds +{ + winsize window_size = {}; + + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) + ioctl(0, TIOCGWINSZ, &window_size); + + return Bounds({window_size.ws_col, window_size.ws_row}); +} + auto Scene::get_matrix() const noexcept -> const std::shared_ptr> & { -- cgit v1.2.3-18-g5258