OmniaFramework/src/ogfx/gui/widgets/RootWidget.cpp

55 lines
1.7 KiB
C++

/*
OmniaFramework - A collection of useful functionality
Copyright (C) 2025 OmniaX-Dev
This file is part of OmniaFramework.
OmniaFramework is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OmniaFramework 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with OmniaFramework. If not, see <https://www.gnu.org/licenses/>.
*/
#include "RootWidget.hpp"
#include "../../render/BasicRenderer.hpp"
#include "../Window.hpp"
namespace ogfx
{
namespace gui
{
namespace widgets
{
RootWidget::RootWidget(WindowCore& window) : Widget({ 0, 0, 0, 0 }, window)
{
disableDrawBox();
m_rootChild = true;
setSize(static_cast<float>(window.getWindowWidth()), static_cast<float>(window.getWindowHeight()));
setTypeName("ogfx::gui::widgets::RootWidget");
}
void RootWidget::onWindowResized(const Event& event)
{
setSize(static_cast<float>(event.windowResized->new_width), static_cast<float>(event.windowResized->new_height));
}
void RootWidget::applyTheme(const ostd::Stylesheet& theme)
{
m_color = getThemeValue<ostd::Color>(theme, "window.backgroundColor", getWindow().getClearColor());
}
void RootWidget::onDraw(ogfx::BasicRenderer2D& gfx)
{
gfx.fillRect({ 0, 0, static_cast<float>(getWindow().getWindowWidth()), static_cast<float>(getWindow().getWindowHeight()) }, m_color);
}
}
}
}