#include "Window.h" #include Window::Window(const std::string& title, int width, int height) : window_(nullptr), width_(width), height_(height), title_(title) { window_ = SDL_CreateWindow( title.c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN ); if (!window_) { std::cerr << "Window creation failed: " << SDL_GetError() << std::endl; } } Window::~Window() { if (window_) { SDL_DestroyWindow(window_); window_ = nullptr; } } Window::Window(Window&& other) noexcept : window_(other.window_), width_(other.width_), height_(other.height_), title_(std::move(other.title_)) { other.window_ = nullptr; other.width_ = 0; other.height_ = 0; } Window& Window::operator=(Window&& other) noexcept { if (this != &other) { if (window_) { SDL_DestroyWindow(window_); } window_ = other.window_; width_ = other.width_; height_ = other.height_; title_ = std::move(other.title_); other.window_ = nullptr; other.width_ = 0; other.height_ = 0; } return *this; } void Window::show() { if (window_) { SDL_ShowWindow(window_); } } void Window::hide() { if (window_) { SDL_HideWindow(window_); } } void Window::setTitle(const std::string& title) { title_ = title; if (window_) { SDL_SetWindowTitle(window_, title.c_str()); } }