window pos

This commit is contained in:
2025-12-20 13:46:50 -05:00
parent 4574ff0f84
commit 99e56eabdf
4 changed files with 34 additions and 3 deletions

View File

@@ -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)

View File

@@ -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);

View File

@@ -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) \

View File

@@ -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;
}