aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-30 16:14:20 +0200
committerdec05eba <dec05eba@protonmail.com>2022-03-30 16:15:11 +0200
commit2c879c34c9aeddae528d2818f7baa6a915d5d77a (patch)
treea45a5e100abd15d0cf9512914b884d724617107a
parent5b97ed133553f92875872a32728221bcda53be38 (diff)
Proper y offset for text, add option to create hidden window and add function to make it visible (map, unmap), fix incorrect copy/move text
m---------depends/mgl0
-rw-r--r--include/mglpp/window/Window.hpp2
-rw-r--r--src/graphics/Text.cpp7
-rw-r--r--src/window/Window.cpp4
4 files changed, 9 insertions, 4 deletions
diff --git a/depends/mgl b/depends/mgl
-Subproject 131a2f0b5c51fc821224bf7637ba58df0a5ae15
+Subproject 956c86fe4728e6e5239202f1402fd65260ece7c
diff --git a/include/mglpp/window/Window.hpp b/include/mglpp/window/Window.hpp
index 655f63d..93918f4 100644
--- a/include/mglpp/window/Window.hpp
+++ b/include/mglpp/window/Window.hpp
@@ -35,6 +35,7 @@ namespace mgl {
mgl::vec2i min_size; /* (0, 0) = no limit */
mgl::vec2i max_size; /* (0, 0) = no limit */
WindowHandle parent_window = 0; /* 0 = root window */
+ bool hidden = false;
};
Window();
@@ -53,6 +54,7 @@ namespace mgl {
void draw(const Vertex *vertices, size_t vertex_count, PrimitiveType primitive_type, Shader *shader = nullptr);
void display();
+ void set_visible(bool visible);
bool is_open() const;
bool has_focus() const;
void close();
diff --git a/src/graphics/Text.cpp b/src/graphics/Text.cpp
index fa82a88..a30cdf3 100644
--- a/src/graphics/Text.cpp
+++ b/src/graphics/Text.cpp
@@ -24,16 +24,15 @@ namespace mgl {
Text& Text::operator=(const Text &other) {
font = other.font;
str = other.str;
- mgl_text_init(&text, font ? font->internal_font() : nullptr, str.c_str(), str.size());
- mgl_text_set_position(&text, { other.text.position.x, other.text.position.y });
+ text = other.text;
+ mgl_text_set_string(&text, str.c_str(), str.size());
return *this;
}
Text::Text(Text &&other) {
font = std::move(other.font);
- str = std::move(other.str);
text = std::move(other.text);
- mgl_text_init(&text, font ? font->internal_font() : nullptr, str.c_str(), str.size());
+ set_string(std::move(other.str));
other.font = nullptr;
other.str.clear();
diff --git a/src/window/Window.cpp b/src/window/Window.cpp
index c41a0c6..dbb77a3 100644
--- a/src/window/Window.cpp
+++ b/src/window/Window.cpp
@@ -63,6 +63,10 @@ namespace mgl {
mgl_window_display(&window);
}
+ void Window::set_visible(bool visible) {
+ mgl_window_set_visible(&window, visible);
+ }
+
bool Window::is_open() const {
return mgl_window_is_open(&window);
}