From 99e56eabdf73253f1dafd10003d21df9b1216e8f Mon Sep 17 00:00:00 2001 From: shweet Date: Sat, 20 Dec 2025 13:46:50 -0500 Subject: [PATCH] window pos --- src/imgui/window/timeline.cpp | 3 ++- src/loader.cpp | 32 ++++++++++++++++++++++++++++++-- src/settings.h | 1 + src/state.cpp | 1 + 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/imgui/window/timeline.cpp b/src/imgui/window/timeline.cpp index 4cdd1f8..759d7eb 100644 --- a/src/imgui/window/timeline.cpp +++ b/src/imgui/window/timeline.cpp @@ -1035,11 +1035,12 @@ namespace anm2ed::imgui if (isDragging) { playback.time = hoveredTime; + playback.clamp(settings.playbackIsClamp ? length : anm2::FRAME_NUM_MAX); document.frameTime = playback.time; } playback.clamp(settings.playbackIsClamp ? length : anm2::FRAME_NUM_MAX); - + if (ImGui::IsMouseReleased(ImGuiMouseButton_Left)) isDragging = false; if (length > 0) diff --git a/src/loader.cpp b/src/loader.cpp index 6de9a9c..81cbcc4 100644 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -135,6 +135,15 @@ namespace anm2ed logger.info("Initialized SDL"); + auto windowProperties = SDL_CreateProperties(); + + if (windowProperties == 0) + { + logger.fatal(std::format("Could not initialize window properties! {}", SDL_GetError())); + isError = true; + return; + } + if (settings.isDefault) { if (auto display = SDL_GetPrimaryDisplay(); display != 0) @@ -157,8 +166,27 @@ namespace anm2ed else logger.info("Initialized SDL_mixer"); - window = SDL_CreateWindow("Anm2Ed", settings.windowSize.x, settings.windowSize.y, - SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_HIGH_PIXEL_DENSITY); + SDL_SetStringProperty(windowProperties, SDL_PROP_WINDOW_CREATE_TITLE_STRING, "Anm2Ed"); + SDL_SetNumberProperty(windowProperties, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, settings.windowSize.x); + SDL_SetNumberProperty(windowProperties, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, settings.windowSize.y); + + SDL_SetNumberProperty(windowProperties, SDL_PROP_WINDOW_CREATE_X_NUMBER, + settings.isDefault ? SDL_WINDOWPOS_CENTERED : settings.windowPosition.x); + SDL_SetNumberProperty(windowProperties, SDL_PROP_WINDOW_CREATE_Y_NUMBER, + settings.isDefault ? SDL_WINDOWPOS_CENTERED : settings.windowPosition.y); + + SDL_SetBooleanProperty(windowProperties, SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN, true); + SDL_SetBooleanProperty(windowProperties, SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, true); + SDL_SetBooleanProperty(windowProperties, SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, true); + + window = SDL_CreateWindowWithProperties(windowProperties); + + if (!window) + { + logger.fatal(std::format("Could not initialize window! {}", SDL_GetError())); + isError = true; + return; + } SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); diff --git a/src/settings.h b/src/settings.h index 5d09ef4..15e063b 100644 --- a/src/settings.h +++ b/src/settings.h @@ -51,6 +51,7 @@ namespace anm2ed #define SETTINGS_MEMBERS \ /* Symbol / Name / String / Type / Default */ \ X(WINDOW_SIZE, windowSize, STRING_UNDEFINED, IVEC2_WH, {1200, 720}) \ + X(WINDOW_POSITION, windowPosition, STRING_UNDEFINED, IVEC2, glm::ivec2()) \ X(IS_VSYNC, isVsync, STRING_UNDEFINED, BOOL, true) \ X(UI_SCALE, uiScale, STRING_UNDEFINED, FLOAT, 1.0f) \ X(THEME, theme, STRING_UNDEFINED, INT, types::theme::DARK) \ diff --git a/src/state.cpp b/src/state.cpp index 9072c2c..c9fa2ee 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -112,6 +112,7 @@ namespace anm2ed toasts.update(); SDL_GetWindowSize(window, &settings.windowSize.x, &settings.windowSize.y); + SDL_GetWindowPosition(window, &settings.windowPosition.x, &settings.windowPosition.y); if (isQuitting && manager.documents.empty()) isQuit = true; }