ok remake pt4

This commit is contained in:
2025-07-15 20:56:12 +03:00
parent bb793e876a
commit 22ad2002e4

View File

@@ -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, &current_mouse_x, &current_mouse_y);
if (dragging_window) {
if (is_held) {
double current_mouse_x, current_mouse_y;
glfwGetCursorPos(window, &current_mouse_x, &current_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<int>(dx),
drag_start_window_y + static_cast<int>(dy));
} else {
dragging_window = false;
glfwSetWindowPos(window,
drag_start_window_x + static_cast<int>(dx),
drag_start_window_y + static_cast<int>(dy));
} else {
dragging_window = false;
}
}
// Menu items