Skip to content

feat(UI): reset window positions after resolution change #2067

Merged
alandtse merged 8 commits into
community-shaders:devfrom
Dlizzio:window-reset-resolution
Apr 9, 2026
Merged

feat(UI): reset window positions after resolution change #2067
alandtse merged 8 commits into
community-shaders:devfrom
Dlizzio:window-reset-resolution

Conversation

@Dlizzio
Copy link
Copy Markdown
Contributor

@Dlizzio Dlizzio commented Apr 6, 2026

Resets the window positions in the UI when detecting a change in game resolution.

Summary by CodeRabbit

  • New Features

    • Display size is persisted across sessions so window layout restores consistently.
  • Improvements

    • Initial window positioning now honors an explicit reset flag to control first-use vs forced resets.
    • Layout automatically resets when the display resolution changes to maintain correct window placement.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b636eb46-cafa-4353-bcb0-d2d760dcfe7c

📥 Commits

Reviewing files that changed from the base of the PR and between 01e028a and fb5e7f0.

📒 Files selected for processing (1)
  • src/Menu.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Menu.cpp

📝 Walkthrough

Walkthrough

Registers an ImGui "CommunityShaders" settings handler to persist ImGui::GetIO().DisplaySize across sessions, tracks runtime display size changes, and triggers conditional layout resets when resolution changes are detected.

Changes

Cohort / File(s) Summary
State Management
src/Menu.h
Added lastDisplaySize (float2) and resetLayout (bool) members to persist display size and signal layout resets.
Settings Persistence
src/Menu.cpp
Registered an ImGuiSettingsHandler named "CommunityShaders" that reads/writes DisplaySize=<w>,<h> into ImGui settings; DrawSettings() now applies initial window position/size with ImGuiCond_Always when resetLayout is set, otherwise ImGuiCond_FirstUseEver.
Runtime Monitoring & Reset
src/Menu/OverlayRenderer.cpp
InitializeImGuiFrame() captures current swap-chain display dims, compares with menu.lastDisplaySize, logs transitions, sets resetLayout = true (also on EditorWindow), and updates lastDisplaySize.

Sequence Diagram

sequenceDiagram
    participant AppInit as App Init
    participant Settings as ImGuiSettingsHandler
    participant Overlay as OverlayRenderer::InitializeImGuiFrame
    participant Menu as Menu::DrawSettings
    participant ImGui as ImGui

    AppInit->>Settings: Register "CommunityShaders"
    Settings->>Settings: ReadOpenFn / ReadLineFn -> set lastDisplaySize

    Overlay->>Overlay: Cache displayW, displayH
    Overlay->>Overlay: Compare with menu.lastDisplaySize
    alt Display size changed
        Overlay->>Overlay: Log change
        Overlay->>Menu: set resetLayout = true
        Overlay->>Overlay: Update lastDisplaySize
    else No change
        Overlay->>Overlay: Update lastDisplaySize
    end

    Menu->>Menu: Check resetLayout
    alt resetLayout == true
        Menu->>ImGui: Set position/size with ImGuiCond_Always
        Menu->>Menu: resetLayout = false
    else
        Menu->>ImGui: Set position/size with ImGuiCond_FirstUseEver
    end

    Settings->>Settings: WriteAllFn -> serialize current DisplaySize
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • doodlum
  • davo0411

Poem

🐰
I hop where pixels stretch and hide,
I pen the size the screen applied,
When resolutions change their tune,
I nudge the layout back in bloom,
A tiny rabbit saving views.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main objective: resetting window positions after resolution changes, which matches the primary purpose of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Menu.cpp`:
- Around line 587-601: The ImGuiSettingsHandler instance is not
value-initialized; change the declaration of ImGuiSettingsHandler handler to use
value-initialization (e.g., ImGuiSettingsHandler handler{} ) so all fields
(including optional callbacks like ClearAllFn/ReadInitFn/ApplyAllFn) are
zero-initialized before assigning ReadOpenFn, ReadLineFn and WriteAllFn and
pushing to ImGui::GetCurrentContext()->SettingsHandlers.

In `@src/Menu/OverlayRenderer.cpp`:
- Around line 228-232: The code should not set
EditorWindow::GetSingleton()->resetLayout while the editor is closed; instead,
move or gate that assignment so it only occurs when the editor is actually
rendering this frame (i.e., after calling UpdateOpenState()). Concretely: stop
directly writing EditorWindow::GetSingleton()->resetLayout = true where
menu.lastDisplaySize triggers a layout reset; instead, propagate
menu.resetLayout and after calling EditorWindow::UpdateOpenState() check the
editor window instance (e.g., auto editorWindow = EditorWindow::GetSingleton())
and only set editorWindow->resetLayout = true when editorWindow->open is true
(one-shot behavior preserved by leaving menu.resetLayout cleared elsewhere).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b1069cda-0139-4058-9395-209ff1a63c17

📥 Commits

Reviewing files that changed from the base of the PR and between b4abab7 and 01e028a.

📒 Files selected for processing (3)
  • src/Menu.cpp
  • src/Menu.h
  • src/Menu/OverlayRenderer.cpp

Comment thread src/Menu.cpp Outdated
Comment thread src/Menu/OverlayRenderer.cpp
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 6, 2026

✅ A pre-release build is available for this PR:
Download

@alandtse alandtse merged commit 79d4389 into community-shaders:dev Apr 9, 2026
15 checks passed
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 2, 2026
@Dlizzio Dlizzio deleted the window-reset-resolution branch May 3, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants