Merge pull request #917 from MihailRis/small-ui-fixes

small ui fixes
This commit is contained in:
MihailRis 2026-08-07 23:39:27 +03:00 • committed by GitHub
commit b3d7180b93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 229 additions and 196 deletions

View file

@ -6,7 +6,7 @@
#include "Panel.hpp"
namespace gui {
class CheckBox : public UINode {
class CheckBox final : public UINode {
protected:
glm::vec4 checkColor {1.0f, 1.0f, 1.0f, 0.4f};
boolsupplier supplier = nullptr;
@ -15,23 +15,22 @@ namespace gui {
public:
explicit CheckBox(GUI& gui, bool checked = false);
virtual void draw(const DrawContext& pctx, const Assets& assets)
override;
void draw(const DrawContext& pctx, const Assets& assets) override;
virtual void mouseRelease(int x, int y) override;
void mouseRelease(int x, int y) override;
virtual void setSupplier(boolsupplier supplier);
virtual void setConsumer(boolconsumer consumer);
void setSupplier(boolsupplier supplier);
void setConsumer(boolconsumer consumer);
virtual CheckBox* setChecked(bool flag);
CheckBox* setChecked(bool flag);
virtual bool isChecked() const {
bool isChecked() const {
if (supplier) return supplier();
return checked;
}
};
class FullCheckBox : public Panel {
class FullCheckBox final : public Panel {
protected:
std::shared_ptr<CheckBox> checkbox;
std::shared_ptr<Label> label;
@ -43,28 +42,28 @@ namespace gui {
bool checked = false
);
virtual void setSupplier(boolsupplier supplier) {
void setSupplier(boolsupplier supplier) {
checkbox->setSupplier(std::move(supplier));
}
virtual void setConsumer(boolconsumer consumer) {
void setConsumer(boolconsumer consumer) {
checkbox->setConsumer(std::move(consumer));
}
virtual void setChecked(bool flag) {
void setChecked(bool flag) {
checkbox->setChecked(flag);
}
virtual bool isChecked() const {
bool isChecked() const {
return checkbox->isChecked();
}
virtual void setTooltip(const std::wstring& text) override {
void setTooltip(const std::wstring& text) override {
Panel::setTooltip(text);
checkbox->setTooltip(text);
}
virtual void setSize(const glm::vec2& new_size) override {
void setSize(const glm::vec2& new_size) override {
Panel::setSize(new_size);
checkbox->setSize(glm::vec2(size.y, size.y));
}

View file

@ -1,9 +1,9 @@
#include "Container.hpp"
#include "graphics/core/DrawContext.hpp"
#include "graphics/core/Batch2D.hpp"
#include "window/Window.hpp"
#include "../GUI.hpp"
#include "graphics/core/Batch2D.hpp"
#include "graphics/core/DrawContext.hpp"
#include "window/Window.hpp"
#include <algorithm>
#include <utility>
@ -11,7 +11,7 @@
using namespace gui;
Container::Container(GUI& gui, glm::vec2 size) : UINode(gui, size) {
actualLength = size.y;
actualLengthY = size.y;
setColor(glm::vec4());
}
@ -26,15 +26,15 @@ std::shared_ptr<UINode> Container::getAt(const glm::vec2& pos) {
if (!isInside(pos)) {
return nullptr;
}
int diff = (actualLength-size.y);
if (scrollable && diff > 0 && pos.x > calcPos().x + getSize().x - scrollBarWidth) {
int diff = (actualLengthY - size.y);
if (scrollable && diff > 0 &&
pos.x > calcPos().x + getSize().x - scrollBarWidth) {
return UINode::getAt(pos);
}
for (int i = nodes.size()-1; i >= 0; i--) {
for (int i = nodes.size() - 1; i >= 0; i--) {
auto& node = nodes[i];
if (!node->isVisible())
continue;
if (!node->isVisible()) continue;
auto hover = node->getAt(pos);
if (hover != nullptr) {
return hover;
@ -45,7 +45,7 @@ std::shared_ptr<UINode> Container::getAt(const glm::vec2& pos) {
void Container::click(int x, int y) {
UINode::click(x, y);
if (scrollable) {
auto pos = calcPos();
x -= pos.x;
@ -65,11 +65,12 @@ void Container::mouseMove(int x, int y) {
auto pos = calcPos();
x -= pos.x;
y -= pos.y;
int diff = (actualLength-size.y);
int diff = (actualLengthY - size.y);
if (diff > 0) {
scroll -= (y - prevScrollY) / static_cast<float>(size.y) * actualLength;
scroll = -glm::min(
glm::max(static_cast<float>(-scroll), 0.0f), actualLength - size.y
scrollY -=
(y - prevScrollY) / static_cast<float>(size.y) * actualLengthY;
scrollY = -glm::min(
glm::max(static_cast<float>(-scrollY), 0.0f), actualLengthY - size.y
);
}
prevScrollY = y;
@ -101,23 +102,28 @@ void Container::act(float delta) {
}
}
}
intervalEvents.erase(std::remove_if(
intervalEvents.begin(), intervalEvents.end(),
[](const IntervalEvent& event) {
return event.repeat == 0;
}
), intervalEvents.end());
intervalEvents.erase(
std::remove_if(
intervalEvents.begin(),
intervalEvents.end(),
[](const IntervalEvent& event) { return event.repeat == 0; }
),
intervalEvents.end()
);
}
void Container::scrolled(int value) {
int diff = (actualLength-getSize().y);
auto size = getSize();
bool isVertical = actualLengthY > size.y;
int diff = (isVertical ? actualLengthY - size.y : actualLengthX - size.x);
int& scroll = (isVertical ? scrollY : scrollX);
if (scroll < 0 && diff <= 0) {
scroll = 0;
}
if (diff > 0 && scrollable) {
scroll += value * scrollStep;
if (scroll > 0)
scroll = 0;
if (scroll > 0) scroll = 0;
if (-scroll > diff) {
scroll = -diff;
}
@ -140,21 +146,25 @@ void Container::draw(const DrawContext& pctx, const Assets& assets) {
if (!nodes.empty()) {
batch->flush();
DrawContext ctx = pctx.sub();
ctx.setScissors(glm::vec4(pos.x, pos.y, glm::ceil(size.x), glm::ceil(size.y)));
ctx.setScissors(
glm::vec4(pos.x, pos.y, glm::ceil(size.x), glm::ceil(size.y))
);
for (const auto& node : nodes) {
if (node->isVisible())
node->draw(pctx, assets);
if (node->isVisible()) node->draw(pctx, assets);
}
int diff = (actualLength-size.y);
int diff = (actualLengthY - size.y);
if (scrollable && diff > 0) {
int h = glm::max(size.y / actualLength * size.y, scrollBarWidth / 2.0f);
int h = glm::max(
size.y / actualLengthY * size.y, scrollBarWidth / 2.0f
);
batch->untexture();
batch->setColor(glm::vec4(1, 1, 1, 0.3f));
batch->rect(
pos.x + size.x - scrollBarWidth,
pos.y - scroll / static_cast<float>(diff) * (size.y - h),
scrollBarWidth, h
pos.y - scrollY / static_cast<float>(diff) * (size.y - h),
scrollBarWidth,
h
);
}
batch->flush();
@ -163,8 +173,7 @@ void Container::draw(const DrawContext& pctx, const Assets& assets) {
void Container::drawBackground(const DrawContext& pctx, const Assets&) {
glm::vec4 color = calcColor();
if (color.a <= 0.001f)
return;
if (color.a <= 0.001f) return;
glm::vec2 pos = calcPos();
auto batch = pctx.getBatch2D();
@ -194,11 +203,16 @@ void Container::add(const std::shared_ptr<UINode>& node, glm::vec2 pos) {
void Container::remove(UINode* selected) {
selected->setParent(nullptr);
nodes.erase(std::remove_if(nodes.begin(), nodes.end(),
[selected](const std::shared_ptr<UINode>& node) {
return node.get() == selected;
}
), nodes.end());
nodes.erase(
std::remove_if(
nodes.begin(),
nodes.end(),
[selected](const std::shared_ptr<UINode>& node) {
return node.get() == selected;
}
),
nodes.end()
);
refresh();
}
@ -242,13 +256,17 @@ void Container::setScrollStep(int step) {
}
void Container::refresh() {
std::stable_sort(nodes.begin(), nodes.end(), [](const auto& a, const auto& b) {
return a->getZIndex() < b->getZIndex();
});
std::stable_sort(
nodes.begin(),
nodes.end(),
[](const auto& a, const auto& b) {
return a->getZIndex() < b->getZIndex();
}
);
}
void Container::setScroll(int scroll) {
this->scroll = scroll;
this->scrollY = scroll;
}
const std::vector<std::shared_ptr<UINode>>& Container::getNodes() const {

View file

@ -13,10 +13,12 @@ namespace gui {
protected:
std::vector<std::shared_ptr<UINode>> nodes;
std::vector<IntervalEvent> intervalEvents;
int scroll = 0;
int scrollY = 0;
int scrollX = 0;
int scrollStep = 40;
int scrollBarWidth = 10;
int actualLength = 0;
int actualLengthY = 0;
int actualLengthX = 0;
bool scrollable = true;
bool isScrolling() const {
@ -40,7 +42,7 @@ namespace gui {
virtual void setScrollable(bool flag);
void listenInterval(float interval, OnTimeOut callback, int repeat=-1);
virtual glm::vec2 getContentOffset() const override {
return glm::vec2(0.0f, scroll);
return glm::vec2(scrollX, scrollY);
};
virtual void setSize(const glm::vec2& size) override;
virtual int getScrollStep() const;

View file

@ -9,7 +9,7 @@ namespace gui {
class Frame final : public Container {
public:
Frame(GUI& gui, std::string id, std::string outputTexture);
virtual ~Frame();
~Frame();
void draw(const DrawContext& pctx, const Assets& assets) override;

View file

@ -51,7 +51,7 @@ namespace gui {
);
};
class SlotView : public gui::UINode {
class SlotView final : public gui::UINode {
struct {
ItemStack stack {};
std::wstring countStr;
@ -89,14 +89,14 @@ namespace gui {
public:
SlotView(GUI& gui, SlotLayout layout);
virtual void draw(const DrawContext& pctx, const Assets& assets) override;
void draw(const DrawContext& pctx, const Assets& assets) override;
void setHighlighted(bool flag);
bool isHighlighted() const;
virtual void clicked(Mousecode) override;
virtual void onFocus() override;
virtual const std::wstring& getTooltip() const override;
void clicked(Mousecode) override;
void onFocus() override;
const std::wstring& getTooltip() const override;
void bind(
int64_t inventoryid,

View file

@ -30,7 +30,7 @@ namespace gui {
uint getLineByTextIndex(size_t index) const;
};
class Label : public UINode {
class Label final : public UINode {
LabelCache cache;
glm::vec2 calcSize();
@ -69,64 +69,64 @@ namespace gui {
Label(GUI& gui, const std::string& text, std::string fontName="normal");
Label(GUI& gui, const std::wstring& text, std::string fontName="normal");
virtual ~Label();
~Label();
virtual void setText(std::wstring text);
void setText(std::wstring text);
const std::wstring& getText() const;
virtual void setFontName(std::string name);
virtual const std::string& getFontName() const;
void setFontName(std::string name);
const std::string& getFontName() const;
/// @brief Set text vertical alignment (default value: center)
/// @param align Align::top / Align::center / Align::bottom
virtual void setVerticalAlign(Align align);
virtual Align getVerticalAlign() const;
void setVerticalAlign(Align align);
Align getVerticalAlign() const;
/// @brief Get line height multiplier used for multiline labels
/// (default value: 1.5)
virtual float getLineInterval() const;
float getLineInterval() const;
/// @brief Set line height multiplier used for multiline labels
virtual void setLineInterval(float interval);
void setLineInterval(float interval);
/// @brief Get Y position of the text relative to label position
/// @return Y offset
virtual int getTextYOffset() const;
int getTextYOffset() const;
/// @brief Get Y position of the line relative to label position
/// @param line target line index
/// @return Y offset
virtual int getLineYOffset(uint line) const;
int getLineYOffset(uint line) const;
/// @brief Get position of line start in the text
/// @param line target line index
/// @return position in the text [0..length]
virtual size_t getTextLineOffset(size_t line) const;
size_t getTextLineOffset(size_t line) const;
/// @brief Get line index by its Y offset relative to label position
/// @param offset target Y offset
/// @return line index [0..+]
virtual uint getLineByYOffset(int offset) const;
virtual uint getLineByTextIndex(size_t index) const;
virtual uint getLinesNumber() const;
virtual bool isFakeLine(size_t line) const;
uint getLineByYOffset(int offset) const;
uint getLineByTextIndex(size_t index) const;
uint getLinesNumber() const;
bool isFakeLine(size_t line) const;
virtual void draw(const DrawContext& pctx, const Assets& assets) override;
void draw(const DrawContext& pctx, const Assets& assets) override;
virtual void textSupplier(wstringsupplier supplier);
void textSupplier(wstringsupplier supplier);
virtual void setAutoResize(bool flag);
virtual bool isAutoResize() const;
void setAutoResize(bool flag);
bool isAutoResize() const;
virtual void setMultiline(bool multiline);
virtual bool isMultiline() const;
void setMultiline(bool multiline);
bool isMultiline() const;
virtual void setTextWrapping(bool flag);
virtual bool isTextWrapping() const;
void setTextWrapping(bool flag);
bool isTextWrapping() const;
virtual void setMarkup(std::string_view lang);
virtual const std::string& getMarkup() const;
void setMarkup(std::string_view lang);
const std::string& getMarkup() const;
virtual void setStyles(std::unique_ptr<FontStylesScheme> styles);
void setStyles(std::unique_ptr<FontStylesScheme> styles);
};
}

View file

@ -13,7 +13,7 @@ namespace gui {
using PageLoaderFunc = std::function<std::shared_ptr<UINode>(const std::string&)>;
class Menu : public Container {
class Menu final : public Container {
protected:
std::unordered_map<std::string, Page> pages;
std::stack<Page> pageStack;

View file

@ -1,15 +1,16 @@
#pragma once
#include "Container.hpp"
#include "window/Camera.hpp"
#include <memory>
#include <string>
#include "Container.hpp"
#include "window/Camera.hpp"
class Batch3D;
class Framebuffer;
namespace gui {
class ModelViewer : public Container {
class ModelViewer final : public Container {
private:
std::string modelName;
Camera camera;

View file

@ -41,10 +41,14 @@ glm::vec2 Panel::getContentSize() const {
void Panel::cropToContent() {
if (maxLength > 0.0f) {
setSize(glm::vec2(
getSize().x, glm::max(minLength, glm::min(maxLength, actualLength))
glm::max(minLength, glm::min(maxLength, actualLengthX)),
glm::max(minLength, glm::min(maxLength, actualLengthY))
));
} else {
setSize(glm::vec2(getSize().x, glm::max(minLength, actualLength)));
setSize(glm::vec2(
glm::max(minLength, actualLengthX),
glm::max(minLength, actualLengthY)
));
}
}
@ -93,21 +97,30 @@ void Panel::refresh() {
y += nodeSize.y + margin.w + interval;
maxw = fmax(maxw, ex + nodeSize.x + margin.z + padding.z);
}
actualLength = y + padding.w;
actualLengthX = size.x;
actualLengthY = y + padding.w;
} else {
float maxh = size.y;
for (auto& node : nodes) {
glm::vec2 nodesize = node->getSize();
const glm::vec4 margin = node->getMargin();
x += margin.x;
node->setPos(glm::vec2(x, y + margin.y));
x += nodesize.x + margin.z + interval;
node->refresh();
maxh = fmax(
maxh, y + margin.y + node->getSize().y + margin.w + padding.w
float ey = y + margin.y;
node->setPos(glm::vec2(x, ey));
int height = glm::floor(
size.y - padding.y - padding.w - margin.y - margin.w
);
if (node->isResizing()) {
node->setMaxSize({node->getMaxSize().x, height});
node->setSize(glm::vec2(node->getSize().x, height));
}
node->refresh();
glm::vec2 nodesize = node->getSize();
x += nodesize.x + margin.z + interval;
maxh = fmax(maxh, ey + nodesize.y + margin.w + padding.w);
}
actualLength = size.y;
actualLengthY = size.y;
actualLengthX = x + padding.z;
}
}

View file

@ -10,7 +10,7 @@ class Assets;
class DrawContext;
namespace gui {
class Plotter : public UINode {
class Plotter final : public UINode {
std::unique_ptr<int[]> points;
float multiplier;
int index = 0;

View file

@ -452,7 +452,7 @@ void TextBox::refreshLabel() {
uint height = label->getLinesNumber() * rawTextCache.metrics.lineHeight *
label->getLineInterval();
label->setSize(glm::vec2(label->getSize().x, height));
actualLength = height;
actualLengthY = height;
} else {
setScrollable(false);
}
@ -1133,10 +1133,10 @@ void TextBox::setOnControlCombination(key_handler handler) {
}
void TextBox::setFocusedColor(glm::vec4 color) {
this->focusedColor = color;
this->focusedColor = std::move(color);
}
glm::vec4 TextBox::getFocusedColor() const {
const glm::vec4& TextBox::getFocusedColor() const {
return focusedColor;
}
@ -1144,7 +1144,7 @@ void TextBox::setTextColor(glm::vec4 color) {
this->textColor = color;
}
glm::vec4 TextBox::getTextColor() const {
const glm::vec4& TextBox::getTextColor() const {
return textColor;
}
@ -1248,7 +1248,7 @@ void TextBox::setPadding(glm::vec4 padding) {
refresh();
}
glm::vec4 TextBox::getPadding() const {
const glm::vec4& TextBox::getPadding() const {
return padding;
}

View file

@ -8,7 +8,7 @@ class ActionsHistory;
namespace gui {
class TextBoxHistorian;
class TextBox : public Container {
class TextBox final : public Container {
const Input& inputEvents;
LabelCache rawTextCache;
std::shared_ptr<ActionsHistory> history;
@ -100,124 +100,124 @@ namespace gui {
glm::vec4 padding=glm::vec4(4.0f)
);
virtual ~TextBox();
~TextBox();
void paste(const std::wstring& text, bool history=true);
void erase(size_t start, size_t length);
void resetSelection();
virtual void setTextSupplier(wstringsupplier supplier);
void setTextSupplier(wstringsupplier supplier);
/// @brief Consumer called on stop editing text (textbox defocus)
/// @param consumer std::wstring consumer function
virtual void setTextConsumer(wstringconsumer consumer);
void setTextConsumer(wstringconsumer consumer);
/// @brief Sub-consumer called while editing text
/// @param consumer std::wstring consumer function
virtual void setTextSubConsumer(wstringconsumer consumer);
void setTextSubConsumer(wstringconsumer consumer);
/// @brief Text validator called while text editing and returns true if
/// text is valid
/// @param validator std::wstring consumer returning boolean
virtual void setTextValidator(wstringchecker validator);
void setTextValidator(wstringchecker validator);
virtual void setOnControlCombination(key_handler handler);
void setOnControlCombination(key_handler handler);
virtual void setFocusedColor(glm::vec4 color);
virtual glm::vec4 getFocusedColor() const;
void setFocusedColor(glm::vec4 color);
const glm::vec4& getFocusedColor() const;
virtual void setTextColor(glm::vec4 color);
virtual glm::vec4 getTextColor() const;
void setTextColor(glm::vec4 color);
const glm::vec4& getTextColor() const;
/// @brief Set color of textbox marked by validator as invalid
virtual void setErrorColor(glm::vec4 color);
void setErrorColor(glm::vec4 color);
/// @brief Get color of textbox marked by validator as invalid
virtual glm::vec4 getErrorColor() const;
glm::vec4 getErrorColor() const;
/// @brief Get TextBox content text or placeholder if empty
virtual const std::wstring& getText() const;
const std::wstring& getText() const;
/// @brief Set TextBox content text
virtual void setText(const std::wstring &value);
void setText(const std::wstring &value);
/// @brief Get text placeholder
virtual const std::wstring& getPlaceholder() const;
const std::wstring& getPlaceholder() const;
/// @brief Set text placeholder
/// @param text will be used instead of empty
virtual void setPlaceholder(const std::wstring& text);
void setPlaceholder(const std::wstring& text);
/// @brief Get textbox hint
virtual const std::wstring& getHint() const;
const std::wstring& getHint() const;
/// @brief Set textbox hint
/// @param text will be shown instead of empty
virtual void setHint(const std::wstring& text);
void setHint(const std::wstring& text);
/// @brief Get selected text
virtual std::wstring getSelection() const;
std::wstring getSelection() const;
/// @brief Get current caret position in text
/// @return integer in range [0, text.length()]
virtual size_t getCaret() const;
size_t getCaret() const;
/// @brief Set caret position in the text
/// @param position integer in range [0, text.length()]
virtual void setCaret(size_t position);
void setCaret(size_t position);
/// @brief Set caret position in the text
/// @param position integer in range [-text.length(), text.length()]
virtual void setCaret(ptrdiff_t position);
void setCaret(ptrdiff_t position);
/// @brief Select part of the text
/// @param start index of the first selected character
/// @param end index of the last selected character + 1
virtual void select(int start, int end);
void select(int start, int end);
/// @brief Get number of line at specific position in text
/// @param position target position
/// @return line number
virtual uint getLineAt(size_t position) const;
uint getLineAt(size_t position) const;
/// @brief Get specific line text position
/// @param line target line
/// @return line position in text
virtual size_t getLinePos(uint line) const;
size_t getLinePos(uint line) const;
int calcIndexAt(int x, int y) const;
int getLineYOffset(int line) const;
/// @brief Check text with validator set with setTextValidator
/// @return true if text is valid
virtual bool validate();
bool validate();
virtual void setValid(bool valid);
virtual bool isValid() const;
void setValid(bool valid);
bool isValid() const;
/// @brief Enable/disable multiline mode
virtual void setMultiline(bool multiline);
void setMultiline(bool multiline);
/// @brief Check if multiline mode is enabled
virtual bool isMultiline() const;
bool isMultiline() const;
/// @brief Enable/disable text wrapping
virtual void setTextWrapping(bool flag);
void setTextWrapping(bool flag);
/// @brief Check if text wrapping is enabled
virtual bool isTextWrapping() const;
bool isTextWrapping() const;
/// @brief Enable/disable text editing feature
virtual void setEditable(bool editable);
void setEditable(bool editable);
/// @brief Check if text editing feature is enabled
virtual bool isEditable() const;
bool isEditable() const;
virtual bool isEdited() const;
virtual void setUnedited();
bool isEdited() const;
void setUnedited();
virtual void setPadding(glm::vec4 padding);
glm::vec4 getPadding() const;
void setPadding(glm::vec4 padding);
const glm::vec4& getPadding() const;
size_t getSelectionStart() const;
size_t getSelectionEnd() const;
@ -226,34 +226,34 @@ namespace gui {
bool isKeepLineSelection() const;
/// @brief Set runnable called on textbox focus
virtual void setOnEditStart(runnable oneditstart);
void setOnEditStart(runnable oneditstart);
virtual void setAutoResize(bool flag);
virtual bool isAutoResize() const;
void setAutoResize(bool flag);
bool isAutoResize() const;
virtual void setShowLineNumbers(bool flag);
virtual bool isShowLineNumbers() const;
void setShowLineNumbers(bool flag);
bool isShowLineNumbers() const;
virtual void reposition() override;
virtual void onFocus() override;
virtual void refresh() override;
virtual void doubleClick(int x, int y) override;
virtual void click(int, int) override;
virtual void mouseMove(int x, int y) override;
virtual bool isFocuskeeper() const override {return true;}
virtual void draw(const DrawContext& pctx, const Assets& assets) override;
virtual void drawBackground(const DrawContext& pctx, const Assets& assets) override;
virtual void typed(unsigned int codepoint) override;
virtual void keyPressed(Keycode key) override;
virtual std::shared_ptr<UINode> getAt(const glm::vec2& pos) override;
virtual void setOnUpPressed(const runnable &callback);
virtual void setOnDownPressed(const runnable &callback);
void reposition() override;
void onFocus() override;
void refresh() override;
void doubleClick(int x, int y) override;
void click(int, int) override;
void mouseMove(int x, int y) override;
bool isFocuskeeper() const override {return true;}
void draw(const DrawContext& pctx, const Assets& assets) override;
void drawBackground(const DrawContext& pctx, const Assets& assets) override;
void typed(unsigned int codepoint) override;
void keyPressed(Keycode key) override;
std::shared_ptr<UINode> getAt(const glm::vec2& pos) override;
void setOnUpPressed(const runnable& callback);
void setOnDownPressed(const runnable& callback);
virtual void setSyntax(std::string_view lang);
virtual const std::string& getSyntax() const;
void setSyntax(std::string_view lang);
const std::string& getSyntax() const;
virtual void setMarkup(std::string_view lang);
virtual const std::string& getMarkup() const;
void setMarkup(std::string_view lang);
const std::string& getMarkup() const;
std::shared_ptr<Label> getLabel() const;
};

View file

@ -99,7 +99,7 @@ int TrackBar::getTrackWidth() const {
return trackWidth;
}
glm::vec4 TrackBar::getTrackColor() const {
const glm::vec4& TrackBar::getTrackColor() const {
return trackColor;
}

View file

@ -3,7 +3,7 @@
#include "UINode.hpp"
namespace gui {
class TrackBar : public UINode {
class TrackBar final : public UINode {
protected:
glm::vec4 trackColor {1.0f, 1.0f, 1.0f, 0.4f};
doublesupplier supplier = nullptr;
@ -24,29 +24,29 @@ namespace gui {
double step = 1.0,
int trackWidth = 12
);
virtual void draw(const DrawContext& pctx, const Assets& assets) override;
void draw(const DrawContext& pctx, const Assets& assets) override;
virtual void setSupplier(doublesupplier);
virtual void setConsumer(doubleconsumer);
virtual void setSubConsumer(doubleconsumer);
void setSupplier(doublesupplier);
void setConsumer(doubleconsumer);
void setSubConsumer(doubleconsumer);
virtual void mouseMove(int x, int y) override;
virtual void mouseRelease(int x, int y) override;
void mouseMove(int x, int y) override;
void mouseRelease(int x, int y) override;
virtual double getValue() const;
virtual double getMin() const;
virtual double getMax() const;
virtual double getStep() const;
virtual int getTrackWidth() const;
virtual glm::vec4 getTrackColor() const;
virtual bool isChangeOnRelease() const;
double getValue() const;
double getMin() const;
double getMax() const;
double getStep() const;
int getTrackWidth() const;
const glm::vec4& getTrackColor() const;
bool isChangeOnRelease() const;
virtual void setValue(double);
virtual void setMin(double);
virtual void setMax(double);
virtual void setStep(double);
virtual void setTrackWidth(int);
virtual void setTrackColor(glm::vec4);
virtual void setChangeOnRelease(bool);
void setValue(double);
void setMin(double);
void setMax(double);
void setStep(double);
void setTrackWidth(int);
void setTrackColor(glm::vec4);
void setChangeOnRelease(bool);
};
}