// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "assert/assert.hpp" #include "UIContainer.hpp" using namespace Dawn; std::vector> UIContainer::getChildren() { return this->children; } float_t UIContainer::getContentWidth() { float_t width = 0; auto children = this->getChildren(); for(auto child : children) { width = Math::max(width, child->getWidth()); } return width; } float_t UIContainer::getContentHeight() { float_t height = 0; auto children = this->getChildren(); for(auto child : children) { height = Math::max(height, child->getHeight()); } return height; } void UIContainer::appendChild(std::shared_ptr child) { assertNotNull(child, "Cannot append a null child!"); this->children.push_back(child); } void UIContainer::removeChild(std::shared_ptr child) { assertNotNull(child, "Cannot remove a null child!"); auto it = std::find(this->children.begin(), this->children.end(), child); if(it == this->children.end()) return; this->children.erase(it); } void UIContainer::clearChildren() { this->children.clear(); }