// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "UILabel.hpp" using namespace Dawn; void UILabel::getSelfQuads(const glm::vec2 t, UICanvas &ctx) { std::vector quads; if(this->texture == nullptr || this->text.empty()) return; glm::vec2 position = t; glm::vec4 quad; for(wchar_t c : text) { auto info = texture->getCharacterData(c); ctx.addQuad( { position.x + info.offset.x, position.y + info.offset.y, position.x + info.size.x + info.offset.x, position.y + info.size.y + info.offset.y }, { info.quad.x, info.quad.y, info.quad.z, info.quad.w }, COLOR_WHITE, UIShaderQuadStyle::FONT, texture->texture ); position += info.advance; } } std::shared_ptr UILabel::getFont() { return this->texture; } std::wstring UILabel::getText() { return this->text; } void UILabel::setFont(std::shared_ptr texture) { this->texture = texture; } void UILabel::setText(const std::wstring &text) { this->text = text; }