add FontStylesScheme
This commit is contained in:
@@ -194,9 +194,9 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
|
||||
int y = pos.y+slotSize-16;
|
||||
|
||||
batch->setColor({0, 0, 0, 1.0f});
|
||||
font->draw(*batch, text, x+1, y+1);
|
||||
font->draw(*batch, text, x+1, y+1, nullptr);
|
||||
batch->setColor(glm::vec4(1.0f));
|
||||
font->draw(*batch, text, x, y);
|
||||
font->draw(*batch, text, x, y, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ Label::Label(const std::wstring& text, std::string fontName)
|
||||
cache.update(this->text, multiline, textWrap);
|
||||
}
|
||||
|
||||
Label::~Label() = default;
|
||||
|
||||
glm::vec2 Label::calcSize() {
|
||||
auto font = cache.font;
|
||||
uint lineHeight = font->getLineHeight();
|
||||
@@ -201,10 +203,10 @@ void Label::draw(const DrawContext* pctx, Assets* assets) {
|
||||
if (i < cache.lines.size()-1) {
|
||||
view = std::wstring_view(text.c_str()+offset, cache.lines.at(i+1).offset-offset);
|
||||
}
|
||||
font->draw(*batch, view, pos.x, pos.y + i * totalLineHeight);
|
||||
font->draw(*batch, view, pos.x, pos.y + i * totalLineHeight, styles.get());
|
||||
}
|
||||
} else {
|
||||
font->draw(*batch, text, pos.x, pos.y);
|
||||
font->draw(*batch, text, pos.x, pos.y, styles.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,3 +241,7 @@ void Label::setTextWrapping(bool flag) {
|
||||
bool Label::isTextWrapping() const {
|
||||
return textWrap;
|
||||
}
|
||||
|
||||
void Label::setStyles(std::unique_ptr<FontStylesScheme> styles) {
|
||||
this->styles = std::move(styles);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "UINode.hpp"
|
||||
|
||||
class Font;
|
||||
struct FontStylesScheme;
|
||||
|
||||
namespace gui {
|
||||
struct LineScheme {
|
||||
@@ -51,10 +52,14 @@ namespace gui {
|
||||
|
||||
/// @brief Auto resize label to fit text
|
||||
bool autoresize = false;
|
||||
|
||||
std::unique_ptr<FontStylesScheme> styles;
|
||||
public:
|
||||
Label(const std::string& text, std::string fontName="normal");
|
||||
Label(const std::wstring& text, std::string fontName="normal");
|
||||
|
||||
virtual ~Label();
|
||||
|
||||
virtual void setText(const std::wstring& text);
|
||||
const std::wstring& getText() const;
|
||||
|
||||
@@ -107,5 +112,7 @@ namespace gui {
|
||||
|
||||
virtual void setTextWrapping(bool flag);
|
||||
virtual bool isTextWrapping() const;
|
||||
|
||||
virtual void setStyles(std::unique_ptr<FontStylesScheme> styles);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -47,6 +47,12 @@ void Plotter::draw(const DrawContext* pctx, Assets* assets) {
|
||||
batch->setColor({1,1,1,0.2f});
|
||||
string = util::to_wstring(y / multiplier, 3);
|
||||
}
|
||||
font->draw(*batch, string, pos.x+dmwidth+2, pos.y+dmheight-y-labelsInterval);
|
||||
font->draw(
|
||||
*batch,
|
||||
string,
|
||||
pos.x + dmwidth + 2,
|
||||
pos.y + dmheight - y - labelsInterval,
|
||||
nullptr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user