mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 12:31:51 +00:00
add 'font' xml property to label, button, bindbox, select, textbox
This commit is contained in:
parent
5505622395
commit
b0d9a162ca
9 changed files with 51 additions and 0 deletions
|
|
@ -91,6 +91,10 @@ void Button::setTextAlign(Align align) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Label> Button::getLabel() const {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
Align Button::getTextAlign() const {
|
Align Button::getTextAlign() const {
|
||||||
if (label) {
|
if (label) {
|
||||||
return label->getAlign();
|
return label->getAlign();
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ namespace gui {
|
||||||
virtual Align getTextAlign() const;
|
virtual Align getTextAlign() const;
|
||||||
virtual void setTextAlign(Align align);
|
virtual void setTextAlign(Align align);
|
||||||
|
|
||||||
|
std::shared_ptr<Label> getLabel() const;
|
||||||
|
|
||||||
virtual void setText(std::wstring text);
|
virtual void setText(std::wstring text);
|
||||||
virtual std::wstring getText() const;
|
virtual std::wstring getText() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,3 +38,7 @@ void InputBindBox::keyPressed(Keycode key) {
|
||||||
}
|
}
|
||||||
defocus();
|
defocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Label> InputBindBox::getLabel() const {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,7 @@ namespace gui {
|
||||||
bool isFocuskeeper() const override {
|
bool isFocuskeeper() const override {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Label> getLabel() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,3 +86,7 @@ void SelectBox::drawBackground(const DrawContext& pctx, const Assets&) {
|
||||||
pos.y + size.y / 2.0f + heightHalf
|
pos.y + size.y / 2.0f + heightHalf
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Label> SelectBox::getLabel() const {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,7 @@ namespace gui {
|
||||||
void setOptions(std::vector<Option>&& options);
|
void setOptions(std::vector<Option>&& options);
|
||||||
|
|
||||||
void drawBackground(const DrawContext& pctx, const Assets&) override;
|
void drawBackground(const DrawContext& pctx, const Assets&) override;
|
||||||
|
|
||||||
|
std::shared_ptr<Label> getLabel() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1289,3 +1289,7 @@ void TextBox::setMarkup(std::string_view lang) {
|
||||||
const std::string& TextBox::getMarkup() const {
|
const std::string& TextBox::getMarkup() const {
|
||||||
return markup;
|
return markup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Label> TextBox::getLabel() const {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -255,5 +255,7 @@ namespace gui {
|
||||||
|
|
||||||
virtual void setMarkup(std::string_view lang);
|
virtual void setMarkup(std::string_view lang);
|
||||||
virtual const std::string& getMarkup() const;
|
virtual const std::string& getMarkup() const;
|
||||||
|
|
||||||
|
std::shared_ptr<Label> getLabel() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,9 @@ static std::shared_ptr<UINode> read_label(
|
||||||
std::wstring text = parse_inner_text(element, reader.getContext());
|
std::wstring text = parse_inner_text(element, reader.getContext());
|
||||||
auto label = std::make_shared<Label>(reader.getGUI(), text);
|
auto label = std::make_shared<Label>(reader.getGUI(), text);
|
||||||
read_uinode(reader, element, *label);
|
read_uinode(reader, element, *label);
|
||||||
|
if (element.has("font")) {
|
||||||
|
label->setFontName(element.attr("font").getText());
|
||||||
|
}
|
||||||
if (element.has("text-align")) {
|
if (element.has("text-align")) {
|
||||||
label->setAlign(align_from_string(
|
label->setAlign(align_from_string(
|
||||||
element.attr("text-align").getText(), label->getAlign()
|
element.attr("text-align").getText(), label->getAlign()
|
||||||
|
|
@ -428,6 +431,12 @@ static std::shared_ptr<UINode> read_button(
|
||||||
element.attr("text-align").getText(), button->getTextAlign()
|
element.attr("text-align").getText(), button->getTextAlign()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
if (element.has("font")) {
|
||||||
|
if (auto label = button->getLabel()) {
|
||||||
|
label->setFontName(element.attr("font").getText());
|
||||||
|
button->setMustRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -489,6 +498,12 @@ static std::shared_ptr<UINode> read_select(
|
||||||
GUI&, const std::string& value
|
GUI&, const std::string& value
|
||||||
) { callback(value); });
|
) { callback(value); });
|
||||||
}
|
}
|
||||||
|
if (element.has("font")) {
|
||||||
|
if (auto label = selectBox->getLabel()) {
|
||||||
|
label->setFontName(element.attr("font").getText());
|
||||||
|
selectBox->setMustRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
read_panel_impl(reader, element, *selectBox, false);
|
read_panel_impl(reader, element, *selectBox, false);
|
||||||
return selectBox;
|
return selectBox;
|
||||||
}
|
}
|
||||||
|
|
@ -625,6 +640,12 @@ static std::shared_ptr<UINode> read_text_box(
|
||||||
if (auto onDownPressed = create_runnable(reader, element, "ondown")) {
|
if (auto onDownPressed = create_runnable(reader, element, "ondown")) {
|
||||||
textbox->setOnDownPressed(onDownPressed);
|
textbox->setOnDownPressed(onDownPressed);
|
||||||
}
|
}
|
||||||
|
if (element.has("font")) {
|
||||||
|
if (auto label = textbox->getLabel()) {
|
||||||
|
label->setFontName(element.attr("font").getText());
|
||||||
|
textbox->setMustRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
return textbox;
|
return textbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -703,6 +724,12 @@ static std::shared_ptr<UINode> read_input_bind_box(
|
||||||
glm::vec4 padding = element.attr("padding", "6").asVec4();
|
glm::vec4 padding = element.attr("padding", "6").asVec4();
|
||||||
auto bindbox =
|
auto bindbox =
|
||||||
std::make_shared<InputBindBox>(reader.getGUI(), found, padding);
|
std::make_shared<InputBindBox>(reader.getGUI(), found, padding);
|
||||||
|
if (element.has("font")) {
|
||||||
|
if (auto label = bindbox->getLabel()) {
|
||||||
|
label->setFontName(element.attr("font").getText());
|
||||||
|
bindbox->setMustRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
read_panel_impl(reader, element, *bindbox);
|
read_panel_impl(reader, element, *bindbox);
|
||||||
return bindbox;
|
return bindbox;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue