Browse Source

update size return prototype, be more explicit about variables

master
Odilitime 5 years ago
parent
commit
ee91f3e1b6
  1. 24
      src/graphics/components/TextComponent.cpp
  2. 2
      src/graphics/components/TextComponent.h

24
src/graphics/components/TextComponent.cpp

@ -110,16 +110,16 @@ void TextComponent::rasterize(const int rawX, const int rawY) { @@ -110,16 +110,16 @@ void TextComponent::rasterize(const int rawX, const int rawY) {
//bool wrapped;
//glyphs = textRasterizer->rasterize(text, rawX, windowWidth, wrapToX, width, height, glyphCount, endingX, endingY, wrapped);
rasterizationRequest request;
request.text = text;
request.text = this->text;
request.startX = rawX; // - x
if (!boundToPage) {
// startX needs to be relative to the parent x. Why?
request.startX -= x;
request.startX -= this->x;
}
//std::cout << "TextComponent::rasterize - [" << text << "] request.startX: " << request.startX << " x: " << x << " rawX: " << rawX << std::endl;
request.availableWidth = availableWidth;
request.sourceStartX = rasterStartX;
request.sourceStartY = rasterStartY;
request.availableWidth = this->availableWidth;
request.sourceStartX = this->rasterStartX;
request.sourceStartY = this->rasterStartY;
if (this->win) {
request.maxTextureSize = this->win->maxTextureSize & INT_MAX;
} // else called from input cstr, no win yet
@ -330,16 +330,16 @@ void TextComponent::sanitize(std::string &str) { @@ -330,16 +330,16 @@ void TextComponent::sanitize(std::string &str) {
}
}
std::unique_ptr<std::pair<int, int>> TextComponent::size() const {
std::unique_ptr<sizeResponse> TextComponent::size() const {
const std::shared_ptr<TextRasterizer> textRasterizer=rasterizerCache->loadFont(fontSize, bold);
rasterizationRequest request;
request.text = text;
request.text = this->text;
// startX needs to be relative to the parent x
request.startX = x;
request.availableWidth = windowWidth;
request.sourceStartX = rasterStartX;
request.sourceStartY = rasterStartY;
request.noWrap = noWrap;
request.startX = this->x;
request.availableWidth = this->windowWidth;
request.sourceStartX = this->rasterStartX;
request.sourceStartY = this->rasterStartY;
request.noWrap = this->noWrap;
return textRasterizer->size(request);
}

2
src/graphics/components/TextComponent.h

@ -31,7 +31,7 @@ public: @@ -31,7 +31,7 @@ public:
void resize(const int passedWindowWidth, const int passedWindowHeight, const int passedAvailableWidth); // more detailed control
void sanitize(std::string &str);
void updateHighlight();
std::unique_ptr<std::pair<int, int>> size() const;
std::unique_ptr<sizeResponse> size() const;
// input needed stuff
int rasterStartX = 0; // start reading text source at and place at destination 0

Loading…
Cancel
Save