From 9c98df20dfa67b69cbc2e018aa28af2f5afb954e Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 22 Jun 2023 14:45:35 +0200 Subject: [PATCH] Tweak UI --- site/index.html | 28 ++++++++++++++++++---------- site/index.js | 18 +++++++----------- src/event_loop.rs | 8 -------- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/site/index.html b/site/index.html index eafefc3..a0631a8 100644 --- a/site/index.html +++ b/site/index.html @@ -12,10 +12,10 @@ padding: 0; } - html, - body { + html { width: 100%; height: 100%; + user-select: none; background: black; } @@ -50,7 +50,7 @@ } #overlay { - padding: 0.4em; + padding: 0.6em; color: white; position: absolute; top: 0px; @@ -62,6 +62,11 @@ .hidden { display: none; } + + .input-row { + display: flex; + align-items: center; + } @@ -82,17 +87,20 @@

wgpu Game of life



- -
+ + +
Size:

- - -
-
- Source + + + + +
+
+ Source diff --git a/site/index.js b/site/index.js index 82278b8..8fe196c 100644 --- a/site/index.js +++ b/site/index.js @@ -13,9 +13,10 @@ globalThis.setNewState = function (ruleIdx, size, seed, density) { document.title = ruleSelect.options[ruleIdx].textContent; sizeElement.textContent = size + 'x' + size; ruleSelect.value = ruleIdx; - window.location.hash = `rule=${ruleIdx}&size=${size}&seed=${seed}&density=${density}`; + const queryString = `?rule=${ruleIdx}&size=${size}&seed=${seed}&density=${density}`; + window.history.replaceState({}, '', queryString); densityInput.value = density; - densityDisplay.textContent = '0.' + density; + densityDisplay.innerHTML = ' 0.' + density; overlayElement.style.display = 'block'; } @@ -43,15 +44,10 @@ try { document.getElementById('fullscreenButton').addEventListener('click', toggleFullscreen); document.getElementById('hideControlsButton').addEventListener('click', toggleControls); - let rule = null; - let seed = null; - let density = null; - if (window.location.hash) { - const urlParams = new URLSearchParams(window.location.hash.substring(1)); - rule = parseInt(urlParams.get('rule')); - seed = parseInt(urlParams.get('seed')); - density = parseInt(urlParams.get('density')); - } + const urlParams = new URLSearchParams(window.location.search); + const rule = parseInt(urlParams.get('rule')); + const seed = parseInt(urlParams.get('seed')); + const density = parseInt(urlParams.get('density')); await run(rule, seed, density); diff --git a/src/event_loop.rs b/src/event_loop.rs index 8060594..9c9ff18 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -130,22 +130,14 @@ pub fn handle_event_loop( state.paused = !state.paused; } WindowEvent::Resized(physical_size) => { - log::info!("resize: {:?}", physical_size); state.resize(*physical_size); } WindowEvent::ScaleFactorChanged { new_inner_size, .. } => { - log::info!("scale factor: {:?}", new_inner_size); state.resize(**new_inner_size); } WindowEvent::CursorMoved { position, .. } => { state.cursor_position = *position; } - WindowEvent::MouseInput { - state: winit::event::ElementState::Pressed, - .. - } => { - log::error!("Mouse pressed: {:?}", state.cursor_position); - } WindowEvent::KeyboardInput { event: winit::event::KeyEvent {