From 22ad2002e4add6a835a53a9e5d26dbee87956b90 Mon Sep 17 00:00:00 2001 From: KevinKor01 Date: Tue, 15 Jul 2025 20:56:12 +0300 Subject: [PATCH] ok remake pt4 --- Osmium.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Osmium.cpp b/Osmium.cpp index 93fa9af..479913b 100644 --- a/Osmium.cpp +++ b/Osmium.cpp @@ -13,9 +13,10 @@ int main(int argc, char **argv) { glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - //glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); + glfwWindowHint(GLFW_DECORATED, GLFW_FALSE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + // make the window GLFWwindow *window = glfwCreateWindow(640, 480, "OpenGL Demo", NULL, NULL); if (!window) { @@ -63,31 +64,32 @@ int main(int argc, char **argv) { ImGui::NewFrame(); ImGui::BeginMainMenuBar(); + bool is_hovered = ImGui::IsWindowHovered(); + bool is_clicked = ImGui::IsMouseClicked(0); + bool is_held = ImGui::IsMouseDown(0); - if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(0)) { + if (is_hovered && is_clicked) { dragging_window = true; - + // Get initial mouse and window positions glfwGetCursorPos(window, &drag_start_mouse_x, &drag_start_mouse_y); - - // Get window pos glfwGetWindowPos(window, &drag_start_window_x, &drag_start_window_y); } - if (dragging_window && ImGui::IsMouseDown(0)) { - double current_mouse_x, current_mouse_y; - glfwGetCursorPos(window, ¤t_mouse_x, ¤t_mouse_y); + if (dragging_window) { + if (is_held) { + double current_mouse_x, current_mouse_y; + glfwGetCursorPos(window, ¤t_mouse_x, ¤t_mouse_y); + double dx = current_mouse_x - drag_start_mouse_x; + double dy = current_mouse_y - drag_start_mouse_y; - double dx = current_mouse_x - drag_start_mouse_x; - double dy = current_mouse_y - drag_start_mouse_y; - - // Move window - glfwSetWindowPos(window, - drag_start_window_x + static_cast(dx), - drag_start_window_y + static_cast(dy)); - } else { - dragging_window = false; + glfwSetWindowPos(window, + drag_start_window_x + static_cast(dx), + drag_start_window_y + static_cast(dy)); + } else { + dragging_window = false; + } } // Menu items