aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-18 00:01:19 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 00:01:19 +0100
commit65fd232e102ff89564d5417771e94bed3d1d31c7 (patch)
tree5e3a159d94a7cc06f7f1807c9b42f3c7218743c6 /src
parent4430b3b0be46f4da389a42cf2e871c05188a159d (diff)
Fix window not being visible on kde because color map is deleted while the window is in use, text editing not working for the first character
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp8
-rw-r--r--src/QuickMedia.cpp14
-rw-r--r--src/Text.cpp8
3 files changed, 9 insertions, 21 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index d8e4acd..cc0f66c 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -1453,12 +1453,12 @@ namespace QuickMedia {
window.draw(border_left);
if(item->embedded_item) {
- mgl::vec2f embedded_item_pos(std::floor(item_pos.x + text_offset_x + embedded_item_border_width + body_spacing[body_theme].padding_x), std::floor(item_pos.y + body_spacing[body_theme].embedded_item_padding_y + 6.0f));
+ mgl::vec2f embedded_item_pos(std::floor(item_pos.x + text_offset_x + embedded_item_border_width + body_spacing[body_theme].padding_x), std::floor(item_pos.y + body_spacing[body_theme].embedded_item_padding_y));
mgl::vec2f embedded_item_size(embedded_item_width, embedded_item_height);
draw_item(window, item->embedded_item, embedded_item_pos, embedded_item_size, false, true);
} else {
embedded_item_load_text.set_string(embedded_item_status_to_string(item->embedded_item_status));
- embedded_item_load_text.set_position(vec2f_floor(item_pos.x + text_offset_x + embedded_item_border_width + body_spacing[body_theme].padding_x, item_pos.y + embedded_item_height * 0.5f - (body_spacing[body_theme].embedded_item_font_size + 5.0f) * 0.5f + 6.0f));
+ embedded_item_load_text.set_position(vec2f_floor(item_pos.x + text_offset_x + embedded_item_border_width + body_spacing[body_theme].padding_x, item_pos.y + embedded_item_height * 0.5f - (body_spacing[body_theme].embedded_item_font_size + 5.0f) * 0.5f));
window.draw(embedded_item_load_text);
}
item_pos.y += embedded_item_height + 4.0f;
@@ -1662,9 +1662,9 @@ namespace QuickMedia {
if(include_embedded_item && item->embedded_item_status != FetchStatus::NONE) {
const float embedded_item_width = std::floor(width - text_offset_x - embedded_item_border_width - body_spacing[body_theme].padding_x);
if(item->embedded_item)
- item_height += (get_item_height(item->embedded_item.get(), embedded_item_width, load_texture, false) + 6.0f + body_spacing[body_theme].embedded_item_padding_y * 2.0f);
+ item_height += (get_item_height(item->embedded_item.get(), embedded_item_width, load_texture, false) + body_spacing[body_theme].embedded_item_padding_y * 2.0f);
else
- item_height += ((body_spacing[body_theme].embedded_item_font_size + 5.0f) + 6.0f + body_spacing[body_theme].embedded_item_padding_y * 2.0f);
+ item_height += ((body_spacing[body_theme].embedded_item_font_size + 5.0f) + body_spacing[body_theme].embedded_item_padding_y * 2.0f);
has_loaded_text = true; // TODO: Remove this
}
if(item->description_text) {
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index c735f55..a9eab08 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3794,14 +3794,6 @@ namespace QuickMedia {
mgl::vec2i prev_mouse_pos;
};
- static mgl::vec2f to_vec2f(mgl::vec2i vec) {
- return mgl::vec2f(vec.x, vec.y);
- }
-
- static mgl::vec2f to_vec2f(mgl::vec2u vec) {
- return mgl::vec2f(vec.x, vec.y);
- }
-
static mgl::vec2f floor(mgl::vec2f vec) {
return { std::floor(vec.x), std::floor(vec.y) };
}
@@ -4052,7 +4044,7 @@ namespace QuickMedia {
navigation_stage = NavigationStage::VIEWING_ATTACHED_IMAGE;
image_control.zoom = 1.0f;
- image_control.offset = to_vec2f(attached_image_texture->get_size()) * 0.5f;
+ image_control.offset = attached_image_texture->get_size().to_vec2f() * 0.5f;
image_control.pressed = window.is_mouse_button_pressed(mgl::Mouse::Left);
image_control.pressed = false;
@@ -4208,14 +4200,14 @@ namespace QuickMedia {
const mgl::vec2i mouse_diff = mgl::vec2i(event.mouse_move.x, event.mouse_move.y) - image_control.prev_mouse_pos;
image_control.prev_mouse_pos.x = event.mouse_move.x;
image_control.prev_mouse_pos.y = event.mouse_move.y;
- image_control.offset -= (to_vec2f(mouse_diff) / image_control.zoom);
+ image_control.offset -= (mouse_diff.to_vec2f() / image_control.zoom);
image_control.moved = true;
idle_active_handler();
} else if(event.type == mgl::Event::KeyPressed) {
if(event.key.code == mgl::Keyboard::W) {
image_control.zoom = 1.0f;
image_control.moved = false;
- image_control.offset = to_vec2f(attached_image_texture->get_size()) * 0.5f;
+ image_control.offset = attached_image_texture->get_size().to_vec2f() * 0.5f;
attached_image_sprite.set_origin(mgl::vec2f(0.0f, 0.0f));
attached_image_sprite.set_scale(mgl::vec2f(1.0f, 1.0f));
}
diff --git a/src/Text.cpp b/src/Text.cpp
index 39e5bbd..18a87f4 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -1013,9 +1013,7 @@ namespace QuickMedia
str += '\n';
} else {
const size_t str_index = get_string_index_from_caret_index(caretIndex);
- if(str_index > 0) {
- str.insert(str_index, 1, '\n');
- }
+ str.insert(str_index, 1, '\n');
}
++caretIndex;
@@ -1044,9 +1042,7 @@ namespace QuickMedia
str += stringToAdd;
} else {
const size_t str_index = get_string_index_from_caret_index(caretIndex);
- if(str_index > 0 && str_index != std::string::npos) {
- str.insert(str_index, stringToAdd);
- }
+ str.insert(str_index, stringToAdd);
}
caretIndex += utf8_get_length(stringToAdd);