idk
This commit is contained in:
@ -43,6 +43,9 @@ void VNManager::onInit() {
|
||||
listeners.push_back(getScene()->onUnpausedUpdate.listen([&](const float_t d) {
|
||||
|
||||
}));
|
||||
|
||||
auto w = label->getWidth();
|
||||
auto cw = container->getWidth();
|
||||
}
|
||||
|
||||
void VNManager::onDispose() {
|
||||
|
@ -14,8 +14,10 @@ void UILabel::getSelfQuads(UICanvas &ctx) {
|
||||
glm::vec4 quad;
|
||||
glm::vec2 pos = glm::vec2(0, this->texture->fontSize);
|
||||
bool_t lastCharWasSpace = false;
|
||||
size_t len = Math::min<size_t>(this->text.size(), this->renderCharacterCount);
|
||||
float_t maxWidth = this->hasExplicitWidth() ? this->size.x : std::numeric_limits<float_t>::max();
|
||||
|
||||
for(size_t i = 0; i < text.size(); i++) {
|
||||
for(size_t i = 0; i < len; i++) {
|
||||
wchar_t c = text[i];
|
||||
auto info = texture->getCharacterData(c);
|
||||
|
||||
@ -47,7 +49,7 @@ void UILabel::getSelfQuads(UICanvas &ctx) {
|
||||
// Will this character fit on the row? If not the whole word will wrap.
|
||||
auto info2 = texture->getCharacterData(c);
|
||||
wordWidth += info.advance.x;
|
||||
if(wordWidth > size.x) {
|
||||
if(wordWidth > maxWidth) {
|
||||
pos.x = 0;
|
||||
pos.y += this->texture->fontSize;
|
||||
break;
|
||||
@ -172,4 +174,5 @@ void UILabel::setFont(std::shared_ptr<TrueTypeTexture> texture) {
|
||||
|
||||
void UILabel::setText(const std::wstring &text) {
|
||||
this->text = text;
|
||||
this->renderCharacterCount = text.size();
|
||||
}
|
@ -19,6 +19,7 @@ namespace Dawn {
|
||||
public:
|
||||
bool_t wordWrap = true;
|
||||
struct Color color = COLOR_WHITE;
|
||||
size_t renderCharacterCount = 0;
|
||||
|
||||
float_t getContentWidth() override;
|
||||
float_t getContentHeight() override;
|
||||
|
Reference in New Issue
Block a user