/* Crafter®.Graphics Copyright (C) 2025 Catcrafts® catcrafts.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3.0 as published by the Free Software Foundation; This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ module Crafter.Graphics:WindowFramebuffer_impl; import :WindowFramebuffer; import :Window; import std; import :Types; import :UiElement; import Crafter.Event; namespace Crafter { WindowFramebuffer::WindowFramebuffer(WindowBase& window) : window(window) { } WindowFramebuffer::WindowFramebuffer(WindowBase& window, std::uint_fast32_t width, std::uint_fast32_t height) : window(window) { Create(width, height); } WindowFramebuffer::~WindowFramebuffer() { Destroy(); } ScaleData WindowFramebuffer::ScaleElement(const UiElementBase& element) { ScaleData data; if(element.ignoreScaling) { data.width = element.relativeWidth*width; data.height = element.relativeHeight*height; } else { data.width = element.relativeWidth*width*scale; data.height = element.relativeHeight*height*scale; } data.x = ((element.anchorX*width)-(element.anchorOffsetX*data.width)); data.y = ((element.anchorY*height)-(element.anchorOffsetY*data.height)); return data; } }