Skip to content

Commit

Permalink
web: Fix canvas to the top left of the screen
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Jul 4, 2024
1 parent 9fd5471 commit c26eccf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dist/web/source/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,10 @@ a:hover {
#logo {
height: 25%;
margin-top: 50px;
}

.canvas-fixed {
position: absolute;
top: 0;
left: 0;
}
8 changes: 8 additions & 0 deletions main/gui/source/window/web_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ EM_JS(void, resizeCanvas, (), {
js_resizeCanvas();
});

EM_JS(void, fixCanvasInPlace, (), {
document.getElementById('canvas').classList.add('canvas-fixed');
});

EM_JS(void, setupThemeListener, (), {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
Module._handleThemeChange();
Expand Down Expand Up @@ -88,13 +92,17 @@ namespace hex {
return;
alert("Failed to load permanent file system: "+err);
});

// Center splash screen
document.getElementById('canvas').classList.remove('canvas-fixed');
});
}

void Window::setupNativeWindow() {
resizeCanvas();
setupThemeListener();
setupInputModeListener();
fixCanvasInPlace();

bool themeFollowSystem = ImHexApi::System::usesSystemThemeDetection();
EventOSThemeChanged::subscribe(this, [themeFollowSystem] {
Expand Down

0 comments on commit c26eccf

Please sign in to comment.