Merge branch 'main' into devel
This commit is contained in:
@@ -51,7 +51,7 @@ void LabelCache::update(std::wstring_view text, bool multiline, bool wrap) {
|
||||
if (text[i] == L'\n') {
|
||||
lines.push_back(LineScheme {i+1, false});
|
||||
len = 0;
|
||||
} else if (i > 0 && wrap && text[i+1] != L'\n') {
|
||||
} else if (i > 0 && i+1 < text.length() && wrap && text[i+1] != L'\n') {
|
||||
size_t width = font->calcWidth(text, i-len-1, i-(i-len)+2);
|
||||
if (width >= wrapWidth) {
|
||||
// starting a fake line
|
||||
|
||||
@@ -160,9 +160,9 @@ CursorShape UINode::getCursor() const {
|
||||
|
||||
glm::vec2 UINode::calcPos() const {
|
||||
if (parent) {
|
||||
return pos + parent->calcPos() + parent->getContentOffset();
|
||||
return glm::ivec2(pos + parent->calcPos() + parent->getContentOffset());
|
||||
}
|
||||
return pos;
|
||||
return glm::ivec2(pos);
|
||||
}
|
||||
|
||||
void UINode::scrolled(int value) {
|
||||
@@ -300,11 +300,13 @@ const std::string& UINode::getId() const {
|
||||
|
||||
void UINode::reposition() {
|
||||
if (sizefunc) {
|
||||
auto newSize = sizefunc();
|
||||
auto defsize = newSize;
|
||||
glm::ivec2 newSize = sizefunc();
|
||||
glm::ivec2 defsize = newSize;
|
||||
if (parent) {
|
||||
defsize = parent->getSize();
|
||||
}
|
||||
newSize.x = newSize.x == 0 ? size.x : newSize.x;
|
||||
newSize.y = newSize.y == 0 ? size.y : newSize.y;
|
||||
setSize(
|
||||
{newSize.x < 0 ? defsize.x + (newSize.x + 1) : newSize.x,
|
||||
newSize.y < 0 ? defsize.y + (newSize.y + 1) : newSize.y}
|
||||
|
||||
+32
-2
@@ -6,6 +6,7 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "debug/Logger.hpp"
|
||||
#include "graphics/core/ImageData.hpp"
|
||||
@@ -32,6 +33,7 @@ bool Window::fullscreen = false;
|
||||
CursorShape Window::cursor = CursorShape::ARROW;
|
||||
|
||||
static util::ObjectsKeeper observers_keeper;
|
||||
static std::unordered_set<std::string> extensionsCache;
|
||||
|
||||
static const char* gl_error_name(int error) {
|
||||
switch (error) {
|
||||
@@ -223,8 +225,10 @@ int Window::initialize(DisplaySettings* settings) {
|
||||
}
|
||||
}
|
||||
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glDebugMessageCallback(gl_message_callback, 0);
|
||||
if (isGlExtensionSupported("GL_KHR_debug")) {
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glDebugMessageCallback(gl_message_callback, nullptr);
|
||||
}
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1);
|
||||
@@ -501,3 +505,29 @@ void Window::setIcon(const ImageData* image) {
|
||||
image->getData()};
|
||||
glfwSetWindowIcon(window, 1, &icon);
|
||||
}
|
||||
|
||||
static void initGlExtensionsCache() {
|
||||
if (!extensionsCache.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GLint numExtensions = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
|
||||
|
||||
for (GLint i = 0; i < numExtensions; ++i) {
|
||||
const char *ext = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
|
||||
if (ext) {
|
||||
extensionsCache.insert(ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::isGlExtensionSupported(const char *extension) {
|
||||
if (!extension || !*extension) {
|
||||
return false;
|
||||
}
|
||||
|
||||
initGlExtensionsCache();
|
||||
|
||||
return extensionsCache.find(extension) != extensionsCache.end();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ class Window {
|
||||
static CursorShape cursor;
|
||||
|
||||
static bool tryToMaximize(GLFWwindow* window, GLFWmonitor* monitor);
|
||||
static bool isGlExtensionSupported(const char *extension);
|
||||
public:
|
||||
static int posX;
|
||||
static int posY;
|
||||
|
||||
Reference in New Issue
Block a user