add debug GUI render mode (F8)
This commit is contained in:
@@ -172,11 +172,11 @@ void Container::add(const std::shared_ptr<UINode>& node, glm::vec2 pos) {
|
||||
add(node);
|
||||
}
|
||||
|
||||
void Container::remove(const std::shared_ptr<UINode>& selected) {
|
||||
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 == selected;
|
||||
return node.get() == selected;
|
||||
}
|
||||
), nodes.end());
|
||||
refresh();
|
||||
@@ -185,7 +185,7 @@ void Container::remove(const std::shared_ptr<UINode>& selected) {
|
||||
void Container::remove(const std::string& id) {
|
||||
for (auto& node : nodes) {
|
||||
if (node->getId() == id) {
|
||||
return remove(node);
|
||||
return remove(node.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace gui {
|
||||
virtual void add(const std::shared_ptr<UINode>& node);
|
||||
virtual void add(const std::shared_ptr<UINode>& node, glm::vec2 pos);
|
||||
virtual void clear();
|
||||
virtual void remove(const std::shared_ptr<UINode>& node);
|
||||
virtual void remove(UINode* node);
|
||||
virtual void remove(const std::string& id);
|
||||
virtual void scrolled(int value) override;
|
||||
virtual void setScrollable(bool flag);
|
||||
|
||||
@@ -207,7 +207,7 @@ void SlotView::draw(const DrawContext& pctx, const Assets& assets) {
|
||||
drawItemIcon(batch, stack, item, assets, tint, pos);
|
||||
|
||||
if (stack.getCount() > 1 || stack.getFields() != nullptr) {
|
||||
const auto& font = assets.require<Font>("normal");
|
||||
const auto& font = assets.require<Font>(FONT_DEFAULT);
|
||||
drawItemInfo(batch, stack, item, font, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "UINode.hpp"
|
||||
#include "constants.hpp"
|
||||
|
||||
class Font;
|
||||
struct FontStylesScheme;
|
||||
@@ -61,8 +62,8 @@ namespace gui {
|
||||
|
||||
std::unique_ptr<FontStylesScheme> styles;
|
||||
public:
|
||||
Label(const std::string& text, std::string fontName="normal");
|
||||
Label(const std::wstring& text, std::string fontName="normal");
|
||||
Label(const std::string& text, std::string fontName=FONT_DEFAULT);
|
||||
Label(const std::wstring& text, std::string fontName=FONT_DEFAULT);
|
||||
|
||||
virtual ~Label();
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ void Menu::setPage(const std::string &name, bool history) {
|
||||
|
||||
void Menu::setPage(Page page, bool history) {
|
||||
if (current.panel) {
|
||||
Container::remove(current.panel);
|
||||
Container::remove(current.panel.get());
|
||||
if (history && !current.temporal) {
|
||||
pageStack.push(current);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ void Menu::clearHistory() {
|
||||
void Menu::reset() {
|
||||
clearHistory();
|
||||
if (current.panel) {
|
||||
Container::remove(current.panel);
|
||||
Container::remove(current.panel.get());
|
||||
current = Page {"", nullptr};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ void Panel::add(const std::shared_ptr<UINode> &node) {
|
||||
fullRefresh();
|
||||
}
|
||||
|
||||
void Panel::remove(const std::shared_ptr<UINode> &node) {
|
||||
void Panel::remove(UINode* node) {
|
||||
Container::remove(node);
|
||||
fullRefresh();
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ namespace gui {
|
||||
class Panel : public Container {
|
||||
protected:
|
||||
Orientation orientation = Orientation::vertical;
|
||||
glm::vec4 padding {2.0f};
|
||||
glm::vec4 padding;
|
||||
float interval = 2.0f;
|
||||
int minLength = 0;
|
||||
int maxLength = 0;
|
||||
public:
|
||||
Panel(
|
||||
glm::vec2 size,
|
||||
glm::vec4 padding=glm::vec4(2.0f),
|
||||
glm::vec4 padding=glm::vec4(0.0f),
|
||||
float interval=2.0f
|
||||
);
|
||||
virtual ~Panel();
|
||||
@@ -25,7 +25,7 @@ namespace gui {
|
||||
Orientation getOrientation() const;
|
||||
|
||||
virtual void add(const std::shared_ptr<UINode>& node) override;
|
||||
virtual void remove(const std::shared_ptr<UINode>& node) override;
|
||||
virtual void remove(UINode* node) override;
|
||||
|
||||
virtual void refresh() override;
|
||||
virtual void fullRefresh() override;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "graphics/core/DrawContext.hpp"
|
||||
#include "assets/Assets.hpp"
|
||||
#include "util/stringutil.hpp"
|
||||
#include "constants.hpp"
|
||||
|
||||
using namespace gui;
|
||||
|
||||
@@ -37,7 +38,7 @@ void Plotter::draw(const DrawContext& pctx, const Assets& assets) {
|
||||
}
|
||||
|
||||
int current_point = static_cast<int>(points[index % dmwidth]);
|
||||
auto font = assets.get<Font>("normal");
|
||||
auto font = assets.get<Font>(FONT_DEFAULT);
|
||||
for (int y = 0; y < dmheight; y += labelsInterval) {
|
||||
std::wstring string;
|
||||
if (current_point/16 == y/labelsInterval) {
|
||||
|
||||
@@ -266,7 +266,7 @@ void UINode::moveInto(
|
||||
) {
|
||||
auto parent = node->getParent();
|
||||
if (auto container = dynamic_cast<Container*>(parent)) {
|
||||
container->remove(node);
|
||||
container->remove(node.get());
|
||||
}
|
||||
if (parent) {
|
||||
parent->scrolled(0);
|
||||
|
||||
Reference in New Issue
Block a user