mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 01:49:44 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
bf59e520a7
109 changed files with 1908 additions and 474 deletions
|
|
@ -29,6 +29,10 @@ Font::Font(
|
|||
if (this->fontFile.has_value()) {
|
||||
if (auto fontPtr = this->fontFile->lock()) {
|
||||
monospace = fontPtr->isMonospace();
|
||||
if (monospace && this->glyphs.size() > '0' &&
|
||||
this->glyphs['0'].xAdvance > 0) {
|
||||
glyphInterval = this->glyphs['0'].xAdvance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -62,21 +66,13 @@ bool Font::isPrintableChar(uint codepoint) const {
|
|||
|
||||
int FontMetrics::calcWidth(std::wstring_view text, size_t offset, size_t length) const {
|
||||
auto font = this->font.has_value() ? this->font->lock() : nullptr;
|
||||
if (font == nullptr || font->isMonospace()) {
|
||||
return std::min(text.length() - offset, length) * _glyphInterval;
|
||||
if (font != nullptr) {
|
||||
return font->calcWidth(text, offset, length);
|
||||
}
|
||||
int totalWidth = 0;
|
||||
for (int i = offset; i < offset + length && i < text.length(); i++) {
|
||||
auto codepoint = text[i];
|
||||
if (!font->isPrintableChar(codepoint)) {
|
||||
totalWidth += _glyphInterval;
|
||||
} else if (auto glyph = font->getGlyph(codepoint)) {
|
||||
totalWidth += glyph->xAdvance;
|
||||
} else {
|
||||
totalWidth += _glyphInterval;
|
||||
}
|
||||
if (offset >= text.length()) {
|
||||
return 0;
|
||||
}
|
||||
return totalWidth;
|
||||
return std::min(text.length() - offset, length) * _glyphInterval;
|
||||
}
|
||||
|
||||
int Font::calcWidth(std::wstring_view text, size_t length) const {
|
||||
|
|
@ -84,7 +80,24 @@ int Font::calcWidth(std::wstring_view text, size_t length) const {
|
|||
}
|
||||
|
||||
int Font::calcWidth(std::wstring_view text, size_t offset, size_t length) const {
|
||||
return std::min(text.length()-offset, length) * glyphInterval;
|
||||
if (offset >= text.length()) {
|
||||
return 0;
|
||||
}
|
||||
size_t end = offset + std::min(text.length() - offset, length);
|
||||
int width = 0;
|
||||
for (size_t i = offset; i < end; i++) {
|
||||
width += getAdvance(text[i]);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
int Font::getAdvance(uint codepoint) const {
|
||||
if (isPrintableChar(codepoint)) {
|
||||
if (auto glyph = getGlyph(codepoint)) {
|
||||
return glyph->xAdvance;
|
||||
}
|
||||
}
|
||||
return glyphInterval;
|
||||
}
|
||||
|
||||
static inline void draw_glyph(
|
||||
|
|
@ -176,7 +189,7 @@ static inline void draw_text(
|
|||
int y = 0;
|
||||
bool hasLines = false;
|
||||
|
||||
float baseAdvance = glm::length(right);
|
||||
const float cellAdvance = interval * font.getLineHeight();
|
||||
|
||||
do {
|
||||
for (size_t i = 0; i < text.length(); i++) {
|
||||
|
|
@ -193,12 +206,11 @@ static inline void draw_text(
|
|||
continue;
|
||||
}
|
||||
int yOffset = 0;
|
||||
float advance = baseAdvance;
|
||||
int xOffset = 0;
|
||||
float advance = font.getAdvance(c) / cellAdvance;
|
||||
if (auto glyph = font.getGlyph(c)) {
|
||||
yOffset = glyph->yOffset;
|
||||
advance = glyph->xAdvance /
|
||||
static_cast<float>(font.getLineHeight()) * 2.0f *
|
||||
baseAdvance;
|
||||
xOffset = glyph->xOffset;
|
||||
}
|
||||
uint charpage = c >> 8;
|
||||
if (charpage == page){
|
||||
|
|
@ -207,7 +219,7 @@ static inline void draw_text(
|
|||
batch,
|
||||
pos,
|
||||
glm::vec2(
|
||||
x,
|
||||
x + xOffset / cellAdvance,
|
||||
y - yOffset * (is3d ? -1 : 1) /
|
||||
static_cast<float>(font.getLineHeight())
|
||||
),
|
||||
|
|
@ -221,7 +233,7 @@ static inline void draw_text(
|
|||
else if (charpage > page && charpage < next){
|
||||
next = charpage;
|
||||
}
|
||||
x += advance / baseAdvance;
|
||||
x += advance;
|
||||
}
|
||||
page = next;
|
||||
next = MAX_CODEPAGES;
|
||||
|
|
@ -325,27 +337,26 @@ std::unique_ptr<Font> Font::createBitmapFont(
|
|||
return std::make_unique<Font>(std::move(textures), std::move(glyphs), res, 4);
|
||||
}
|
||||
|
||||
const Glyph* Font::getGlyph(int codepoint) {
|
||||
const Glyph* Font::getGlyph(int codepoint) const {
|
||||
if (codepoint < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
if (codepoint < glyphs.size()) {
|
||||
const int codepage = codepoint >> 8;
|
||||
if (codepoint < glyphs.size() &&
|
||||
(!fontFile.has_value() ||
|
||||
(codepage < pages.size() && pages[codepage]))) {
|
||||
return &glyphs.at(codepoint);
|
||||
}
|
||||
if (!this->fontFile.has_value() || this->fontFile->expired()) {
|
||||
return nullptr;
|
||||
}
|
||||
int codepage = codepoint >> 8;
|
||||
if (codepage >= 1024) {
|
||||
return nullptr;
|
||||
}
|
||||
if (glyphs.size() < (codepage << 8)) {
|
||||
glyphs.resize(codepage << 8);
|
||||
}
|
||||
auto fontFile = this->fontFile->lock();
|
||||
if (pages.size() <= codepage) {
|
||||
pages.resize(codepage);
|
||||
pages.resize(codepage + 1);
|
||||
}
|
||||
pages.push_back(fontFile->renderPage(codepage, glyphs, lineHeight));
|
||||
pages[codepage] = fontFile->renderPage(codepage, glyphs, lineHeight);
|
||||
return &glyphs.at(codepoint);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ namespace vector_fonts {
|
|||
struct Glyph {
|
||||
int yOffset;
|
||||
int xAdvance;
|
||||
int xOffset = 0;
|
||||
};
|
||||
|
||||
class Font {
|
||||
|
|
@ -56,6 +57,10 @@ public:
|
|||
/// @return pixel width of the substring
|
||||
int calcWidth(std::wstring_view text, size_t offset, size_t length) const;
|
||||
|
||||
/// @brief Get the horizontal advance of a character in pixels
|
||||
/// @param codepoint character unicode codepoint
|
||||
int getAdvance(uint codepoint) const;
|
||||
|
||||
/// @brief Check if character is visible (non-whitespace)
|
||||
/// @param codepoint character unicode codepoint
|
||||
bool isPrintableChar(uint codepoint) const;
|
||||
|
|
@ -86,7 +91,7 @@ public:
|
|||
return {std::nullopt, lineHeight, yoffset, glyphInterval};
|
||||
}
|
||||
|
||||
const Glyph* getGlyph(int codepoint);
|
||||
const Glyph* getGlyph(int codepoint) const;
|
||||
|
||||
static std::unique_ptr<Font> createBitmapFont(
|
||||
std::vector<std::unique_ptr<ImageData>> pages
|
||||
|
|
@ -96,7 +101,7 @@ private:
|
|||
int yoffset;
|
||||
int glyphInterval;
|
||||
bool monospace = true;
|
||||
std::vector<std::unique_ptr<Texture>> pages;
|
||||
std::vector<Glyph> glyphs;
|
||||
mutable std::vector<std::unique_ptr<Texture>> pages;
|
||||
mutable std::vector<Glyph> glyphs;
|
||||
std::optional<std::weak_ptr<vector_fonts::FontFile>> fontFile;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -113,8 +113,6 @@ static inline auto shader_deleter = [](GLuint* shader) {
|
|||
delete shader;
|
||||
};
|
||||
|
||||
inline const uint GL_LOG_LEN = 512;
|
||||
|
||||
// shader should be deleted after shader program linking
|
||||
using glshader = std::unique_ptr<GLuint, decltype(shader_deleter)>;
|
||||
|
||||
|
|
@ -125,12 +123,14 @@ glshader compile_shader(GLenum type, const GLchar* source, const std::string& fi
|
|||
glCompileShader(shader);
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
|
||||
if (!success) {
|
||||
GLchar infoLog[GL_LOG_LEN];
|
||||
glGetShaderInfoLog(shader, GL_LOG_LEN, nullptr, infoLog);
|
||||
GLint infoLogLength;
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
auto infoLog = std::make_unique<GLchar[]>(infoLogLength);
|
||||
glGetShaderInfoLog(shader, infoLogLength, nullptr, infoLog.get());
|
||||
glDeleteShader(shader);
|
||||
throw std::runtime_error(
|
||||
"vertex shader compilation failed (" + file + "):\n" +
|
||||
std::string(infoLog)
|
||||
std::string(infoLog.get(), infoLogLength)
|
||||
);
|
||||
}
|
||||
return glshader(new GLuint(shader), shader_deleter); //-V508
|
||||
|
|
@ -172,10 +172,14 @@ static GLuint compile_program(
|
|||
glGetProgramiv(program, GL_LINK_STATUS, &success);
|
||||
|
||||
if (!success) {
|
||||
GLchar infoLog[GL_LOG_LEN];
|
||||
glGetProgramInfoLog(program, GL_LOG_LEN, nullptr, infoLog);
|
||||
GLint infoLogLength;
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
auto infoLog = std::make_unique<GLchar[]>(infoLogLength);
|
||||
glGetProgramInfoLog(program, infoLogLength, nullptr, infoLog.get());
|
||||
glDeleteProgram(program);
|
||||
throw std::runtime_error(
|
||||
"shader program linking failed:\n" + std::string(infoLog)
|
||||
"shader program linking failed:\n" +
|
||||
std::string(infoLog.get(), infoLogLength)
|
||||
);
|
||||
}
|
||||
return program;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ static debug::Logger logger("chunks-render");
|
|||
|
||||
size_t ChunksRenderer::visibleChunks = 0;
|
||||
|
||||
static constexpr inline size_t MAX_CHUNKS_ENQUEUED_IN_FRAME = 4;
|
||||
static constexpr inline size_t MAX_CHUNKS_ENQUEUED_IN_FRAME = 64;
|
||||
|
||||
class RendererWorker : public util::Worker<RendererJob, RendererResult> {
|
||||
BlocksRenderer renderer;
|
||||
|
|
@ -197,8 +197,7 @@ void ChunksRenderer::update() {
|
|||
|
||||
int loadDistance = settings.chunks.loadDistance.get();
|
||||
|
||||
const int topN = 10;
|
||||
int top = std::min<int>(meshBuildQueue.size(), topN);
|
||||
int top = std::min<int>(meshBuildQueue.size(), MAX_CHUNKS_ENQUEUED_IN_FRAME);
|
||||
for (int i = 0; i < top; i++) {
|
||||
glm::ivec2 offset = meshBuildQueue[i];
|
||||
size_t index =
|
||||
|
|
|
|||
|
|
@ -8,6 +8,22 @@
|
|||
#include "debug/Logger.hpp"
|
||||
#include "core_defs.hpp"
|
||||
|
||||
inline constexpr uint FACE_WEST = FACE_MX;
|
||||
inline constexpr uint FACE_EAST = FACE_PX;
|
||||
inline constexpr uint FACE_BOTTOM = FACE_MY;
|
||||
inline constexpr uint FACE_TOP = FACE_PY;
|
||||
inline constexpr uint FACE_SOUTH = FACE_MZ;
|
||||
inline constexpr uint FACE_NORTH = FACE_PZ;
|
||||
|
||||
inline constexpr std::array<uint8_t, 6> LEGACY_CUSTOM_MODEL_TEXTURE_ORDER = {
|
||||
FACE_WEST,
|
||||
FACE_EAST,
|
||||
FACE_BOTTOM,
|
||||
FACE_TOP,
|
||||
FACE_SOUTH,
|
||||
FACE_NORTH,
|
||||
};
|
||||
|
||||
static debug::Logger logger("models-generator");
|
||||
|
||||
static void configure_textures(
|
||||
|
|
@ -49,6 +65,21 @@ static inline UVRegion get_region_for(
|
|||
return texreg.region;
|
||||
}
|
||||
|
||||
static inline void map_legacy_box_textures(
|
||||
const std::vector<std::string>& modelTextures,
|
||||
size_t offset,
|
||||
UVRegion (&boxtexfaces)[6],
|
||||
const Assets& assets
|
||||
) {
|
||||
for (size_t i = 0; i < 6; ++i) {
|
||||
const auto legacyFace = LEGACY_CUSTOM_MODEL_TEXTURE_ORDER[i];
|
||||
boxtexfaces[legacyFace] = get_region_for(modelTextures[offset + i], assets);
|
||||
}
|
||||
boxtexfaces[FACE_TOP].scale(glm::vec2(-1, 1));
|
||||
boxtexfaces[FACE_EAST].scale(glm::vec2(-1, 1));
|
||||
boxtexfaces[FACE_NORTH].scale(glm::vec2(-1, 1));
|
||||
}
|
||||
|
||||
void ModelsGenerator::prepareModel(
|
||||
Assets& assets, const Block& def, Variant& variant, uint8_t variantId
|
||||
) {
|
||||
|
|
@ -120,16 +151,8 @@ model::Model ModelsGenerator::fromCustom(
|
|||
for (size_t i = 0; i < modelBoxes.size(); i++) {
|
||||
auto& mesh = model.addMesh("blocks:");
|
||||
mesh.shading = lighting;
|
||||
UVRegion boxtexfaces[6] = {
|
||||
get_region_for(modelTextures[i * 6 + 5], assets),
|
||||
get_region_for(modelTextures[i * 6 + 4], assets),
|
||||
get_region_for(modelTextures[i * 6 + 3], assets),
|
||||
get_region_for(modelTextures[i * 6 + 2], assets),
|
||||
get_region_for(modelTextures[i * 6 + 1], assets),
|
||||
get_region_for(modelTextures[i * 6 + 0], assets)
|
||||
};
|
||||
boxtexfaces[2].scale(glm::vec2(-1));
|
||||
boxtexfaces[5].scale(glm::vec2(-1, 1));
|
||||
UVRegion boxtexfaces[6] = {};
|
||||
map_legacy_box_textures(modelTextures, i * 6, boxtexfaces, assets);
|
||||
|
||||
bool enabled[6] {1,1,1,1,1,1};
|
||||
mesh.addBox(
|
||||
|
|
@ -232,17 +255,14 @@ model::Model ModelsGenerator::loadCustomBlockModel(
|
|||
modelBoxes.push_back(modelbox);
|
||||
|
||||
if (boxarr.size() == 7) {
|
||||
for (uint j = 6; j < 12; j++) {
|
||||
modelTextures.emplace_back(boxarr[6].asString());
|
||||
}
|
||||
const auto texture = boxarr[6].asString();
|
||||
modelTextures.insert(modelTextures.end(), 6, texture);
|
||||
} else if (boxarr.size() == 12) {
|
||||
for (uint j = 6; j < 12; j++) {
|
||||
modelTextures.emplace_back(boxarr[j].asString());
|
||||
}
|
||||
} else {
|
||||
for (uint j = 6; j < 12; j++) {
|
||||
modelTextures.emplace_back("notfound");
|
||||
}
|
||||
modelTextures.insert(modelTextures.end(), 6, "notfound");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ WorldRenderer::WorldRenderer(
|
|||
debugLines = std::make_unique<DebugLinesRenderer>(level);
|
||||
cloudsRenderer = std::make_unique<CloudsRenderer>();
|
||||
|
||||
keepAlive(observe_setting(settings.graphics.enableFog, dirtySettings));
|
||||
keepAlive(observe_setting(settings.graphics.advancedRender, dirtySettings));
|
||||
keepAlive(observe_setting(settings.graphics.shadowsQuality, dirtySettings));
|
||||
keepAlive(observe_setting(settings.graphics.ssao, dirtySettings));
|
||||
|
|
@ -156,10 +157,12 @@ void WorldRenderer::refreshSettings() {
|
|||
gbufferPipeline = graphics.advancedRender.get();
|
||||
|
||||
int shadowsQuality = graphics.shadowsQuality.get() * gbufferPipeline;
|
||||
bool enableFog = graphics.enableFog.get();
|
||||
shadowMapping->setQuality(shadowsQuality);
|
||||
|
||||
std::vector<std::string> defines;
|
||||
if (shadowsQuality != 0) defines.emplace_back("ENABLE_SHADOWS");
|
||||
if (enableFog) defines.emplace_back("ENABLE_FOG");
|
||||
if (graphics.ssao.get()) defines.emplace_back("ENABLE_SSAO");
|
||||
if (gbufferPipeline) defines.emplace_back("ADVANCED_RENDER");
|
||||
|
||||
|
|
|
|||
|
|
@ -25,14 +25,25 @@ void InlineFrame::setDocument(const std::shared_ptr<UiDocument>& document) {
|
|||
if (document == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto newRoot = document->getRoot();
|
||||
if (newRoot->hasParent()) {
|
||||
return;
|
||||
}
|
||||
this->document = document;
|
||||
this->root = document->getRoot();
|
||||
this->root = std::move(newRoot);
|
||||
add(root);
|
||||
|
||||
root->setSize(size);
|
||||
|
||||
gui.postRunnable([this]() {
|
||||
scripting::on_ui_open(*this->document, {});
|
||||
gui.postRunnable([weak = weak_from_this(), document]() {
|
||||
auto node = weak.lock();
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (static_cast<InlineFrame&>(*node).document != document) {
|
||||
return;
|
||||
}
|
||||
scripting::on_ui_open(*document, {});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
if (size.x <= 0 || size.y <= 0) {
|
||||
return;
|
||||
}
|
||||
fbo = std::make_unique<Framebuffer>(size.x, size.y);
|
||||
fbo = std::make_unique<Framebuffer>(size.x, size.y, true);
|
||||
}
|
||||
fbo->resize(size.x, size.y);
|
||||
{
|
||||
|
|
@ -130,7 +130,13 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
ctx.setViewport({size.x, size.y});
|
||||
ctx.setDepthTest(true);
|
||||
ctx.setCullFace(true);
|
||||
GLfloat clearColor[4];
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
display::clear();
|
||||
glClearColor(
|
||||
clearColor[0], clearColor[1], clearColor[2], clearColor[3]
|
||||
);
|
||||
|
||||
auto& ui3dShader = assets.require<Shader>("ui3d");
|
||||
ui3dShader.use();
|
||||
|
|
|
|||
|
|
@ -255,9 +255,9 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
// drawing caret here
|
||||
if (isFocused() && editable && static_cast<int>((time - caretLastMove) * 2) % 2 == 0) {
|
||||
uint line = label->getLineByTextIndex(caret);
|
||||
auto linestart = label->getTextLineOffset(line);
|
||||
uint lcaret = caret - label->getTextLineOffset(line);
|
||||
int width = rawTextCache.metrics.calcWidth(input.substr(linestart), 0, lcaret);
|
||||
size_t lineStart = label->getTextLineOffset(line);
|
||||
size_t lineCaret = caret - lineStart;
|
||||
int width = rawTextCache.metrics.calcWidth(input, lineStart, lineCaret);
|
||||
|
||||
batch->rect(
|
||||
lcoord.x + width,
|
||||
|
|
@ -275,11 +275,13 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
uint endLine = label->getLineByTextIndex(selectionEnd);
|
||||
|
||||
batch->setColor(glm::vec4(0.8f, 0.9f, 1.0f, 0.25f));
|
||||
size_t startLineOffset = label->getTextLineOffset(startLine);
|
||||
size_t endLineOffset = label->getTextLineOffset(endLine);
|
||||
int start = rawTextCache.metrics.calcWidth(
|
||||
labelText, 0, selectionStart - label->getTextLineOffset(startLine)
|
||||
labelText, startLineOffset, selectionStart - startLineOffset
|
||||
);
|
||||
int end = rawTextCache.metrics.calcWidth(
|
||||
labelText, 0, selectionEnd - label->getTextLineOffset(endLine)
|
||||
labelText, endLineOffset, selectionEnd - endLineOffset
|
||||
);
|
||||
int lineY = label->getLineYOffset(startLine);
|
||||
|
||||
|
|
@ -352,6 +354,11 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
}
|
||||
|
||||
void TextBox::drawBackground(const DrawContext& pctx, const Assets& assets) {
|
||||
if (lineNumbersLabel->getFontName() != label->getFontName()) {
|
||||
lineNumbersLabel->setFontName(label->getFontName());
|
||||
}
|
||||
lineNumbersLabel->setLineInterval(label->getLineInterval());
|
||||
|
||||
auto font = assets.getShared<Font>(label->getFontName());
|
||||
if (font != nullptr) {
|
||||
rawTextCache.prepare(font, font->getMetrics(), label->getSize().x);
|
||||
|
|
@ -681,13 +688,19 @@ int TextBox::calcIndexAt(int x, int y) const {
|
|||
uint line = label->getLineByYOffset(y - lcoord.y);
|
||||
line = std::min(line, label->getLinesNumber() - 1);
|
||||
size_t lineLength = getLineLength(line);
|
||||
size_t lineStart = label->getTextLineOffset(line);
|
||||
uint offset = 0;
|
||||
while (lcoord.x + rawTextCache.metrics.calcWidth(labelText, 0, offset) < x &&
|
||||
offset < lineLength - 1) {
|
||||
while (offset < lineLength - 1) {
|
||||
int width = rawTextCache.metrics.calcWidth(
|
||||
labelText, lineStart, offset
|
||||
);
|
||||
if (lcoord.x + width >= x) {
|
||||
break;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
return std::min(
|
||||
offset + label->getTextLineOffset(line), labelText.length()
|
||||
offset + lineStart, labelText.length()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1224,9 +1237,12 @@ void TextBox::setCaret(size_t position) {
|
|||
offset -= getSize().y;
|
||||
scrolled(-glm::ceil(offset / static_cast<double>(scrollStep) + 0.5f));
|
||||
}
|
||||
int lcaret = caret - rawTextCache.getTextLineOffset(line);
|
||||
int realoffset = rawTextCache.metrics.calcWidth(labelText, 0, lcaret) -
|
||||
static_cast<int>(textOffset);
|
||||
size_t lineStart = rawTextCache.getTextLineOffset(line);
|
||||
size_t lineCaret = caret - lineStart;
|
||||
int caretWidth = rawTextCache.metrics.calcWidth(
|
||||
labelText, lineStart, lineCaret
|
||||
);
|
||||
int realoffset = caretWidth - static_cast<int>(textOffset);
|
||||
|
||||
if (realoffset - width > 0) {
|
||||
setTextOffset(textOffset + realoffset - width);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ bool UINode::isHover() const {
|
|||
return hover;
|
||||
}
|
||||
|
||||
bool UINode::hasParent() const {
|
||||
return parent != nullptr;
|
||||
}
|
||||
|
||||
void UINode::setParent(UINode* node) {
|
||||
parent = node;
|
||||
}
|
||||
|
|
@ -376,14 +380,14 @@ void UINode::setGravity(Gravity gravity) {
|
|||
}
|
||||
}
|
||||
|
||||
bool UINode::isSubnodeOf(const UINode* node) {
|
||||
bool UINode::isDescendantOf(const UINode* node) {
|
||||
if (parent == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (parent == node) {
|
||||
return true;
|
||||
}
|
||||
return parent->isSubnodeOf(node);
|
||||
return parent->isDescendantOf(node);
|
||||
}
|
||||
|
||||
void UINode::getIndices(
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ namespace gui {
|
|||
void setMouseOver(bool flag);
|
||||
|
||||
virtual void setParent(UINode* node);
|
||||
bool hasParent() const;
|
||||
UINode* getParent() const;
|
||||
std::shared_ptr<UINode> getParentShared() const;
|
||||
|
||||
|
|
@ -290,7 +291,7 @@ namespace gui {
|
|||
|
||||
virtual void setGravity(Gravity gravity);
|
||||
|
||||
bool isSubnodeOf(const UINode* node);
|
||||
bool isDescendantOf(const UINode* node);
|
||||
|
||||
/// @brief collect all nodes having id
|
||||
static void getIndices(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue