Skip to content

Commit 3f091e2

Browse files
committed
placing works sometimes, scaling is weird
1 parent 04bfbe7 commit 3f091e2

File tree

5 files changed

+76
-21
lines changed

5 files changed

+76
-21
lines changed

index.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,13 @@
22
<head>
33
<link data-trunk rel="scss" href="index.scss" />
44
</head>
5-
<body></body>
5+
<body>
6+
7+
<div class="centered" id="center_text">
8+
<p style="font-size:16px">
9+
Loading...
10+
</p>
11+
<div class="lds-dual-ring"></div>
12+
</div>
13+
</body>
614
</html>

index.scss

+59-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,66 @@
11
body {
22
margin: 0;
33
padding: 0;
4-
}
4+
background-color: #191919;
5+
}
56

67
canvas {
8+
margin-right: auto !important;
9+
margin-left: auto !important;
10+
display: block !important;
11+
position: absolute !important;
12+
top: 0 !important;
13+
left: 0 !important;
714
width: 100% !important;
815
height: 100% !important;
9-
}
16+
}
17+
18+
.centered {
19+
margin-right: auto;
20+
margin-left: auto;
21+
display: block;
22+
position: absolute;
23+
top: 50%;
24+
left: 50%;
25+
transform: translate(-50%, -50%);
26+
color: #f0f0f0;
27+
font-size: 24px;
28+
font-family: Ubuntu-Light, Helvetica, sans-serif;
29+
text-align: center;
30+
}
31+
32+
/* ---------------------------------------------- */
33+
/* Loading animation from https://loading.io/css/ */
34+
35+
.lds-dual-ring {
36+
/* change color here */
37+
color: #fff
38+
}
39+
.lds-dual-ring,
40+
.lds-dual-ring:after {
41+
box-sizing: border-box;
42+
}
43+
.lds-dual-ring {
44+
display: inline-block;
45+
width: 40px;
46+
height: 40px;
47+
}
48+
.lds-dual-ring:after {
49+
content: " ";
50+
display: block;
51+
width: 48px;
52+
height: 48px;
53+
margin: 8px;
54+
border-radius: 50%;
55+
border: 6.4px solid currentColor;
56+
border-color: currentColor transparent currentColor transparent;
57+
animation: lds-dual-ring 1.2s linear infinite;
58+
}
59+
@keyframes lds-dual-ring {
60+
0% {
61+
transform: rotate(0deg);
62+
}
63+
100% {
64+
transform: rotate(360deg);
65+
}
66+
}

src/input/systems.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use bevy::app::AppExit;
22
use bevy::prelude::*;
3-
use bevy::window::PrimaryWindow;
43

54
use crate::components::microphone::Microphone;
65
use crate::components::source::{Source, SourceType};
@@ -84,7 +83,6 @@ pub fn button_input(
8483
mouse_buttons: Res<ButtonInput<MouseButton>>,
8584
keys: Res<ButtonInput<KeyCode>>,
8685
mut commands: Commands,
87-
q_windows: Query<&Window, With<PrimaryWindow>>,
8886
mut wall_update_ev: EventWriter<UpdateWalls>,
8987
mut component_ids: ResMut<ComponentIDs>,
9088
mut ui_state: ResMut<UiState>,
@@ -104,6 +102,7 @@ pub fn button_input(
104102
MoveCircWalls,
105103
ResizeCircWalls,
106104
)>,
105+
touches: Res<Touches>,
107106
) {
108107
#[cfg(not(target_os = "macos"))]
109108
let ctrl = keys.any_pressed([KeyCode::ControlLeft, KeyCode::ControlRight]);
@@ -113,15 +112,14 @@ pub fn button_input(
113112

114113
// depending on the tool, a click could relate to different actions
115114
// add `Move`, `WResize` or `Selected` tags to the entities as needed
116-
if mouse_buttons.just_pressed(MouseButton::Left)
115+
if touches.any_just_pressed()
117116
&& ui_state.tools_enabled
118117
&& ui_state.tool_use_enabled
119118
{
120-
let window = q_windows.single();
121119
selected.iter_mut().for_each(|entity| {
122120
commands.entity(entity).remove::<Selected>();
123121
});
124-
if let Some(position) = window.cursor_position() {
122+
if let Some(position) = touches.first_pressed_position() {
125123
match ui_state.current_tool {
126124
ToolType::Select => {
127125
if let Some((x, y)) =
@@ -318,10 +316,8 @@ pub fn button_input(
318316
}
319317

320318
// while the mouse is held down, move the selected object(s)
321-
if mouse_buttons.pressed(MouseButton::Left) && ui_state.tools_enabled {
322-
let window = q_windows.single();
323-
324-
if let Some(position) = window.cursor_position() {
319+
if touches.any_just_pressed() && ui_state.tools_enabled {
320+
if let Some(position) = touches.first_pressed_position() {
325321
match ui_state.current_tool {
326322
ToolType::Edit => {
327323
if let Some((x, y)) =
@@ -461,10 +457,6 @@ pub fn button_input(
461457
}
462458
}
463459

464-
if mouse_buttons.just_released(MouseButton::Left) && ui_state.tool_use_enabled {
465-
ui_state.collapse_header = true;
466-
}
467-
468460
// handle all other keyboard shortcuts
469461
if keys.just_pressed(KeyCode::Space) {
470462
ui_state.is_running = !ui_state.is_running;

src/ui/draw.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ pub fn draw_egui(
146146
egui_extras::install_image_loaders(ctx);
147147
// disable window shadows
148148
ctx.style_mut(|style| style.visuals.window_shadow = egui::epaint::Shadow::NONE);
149+
// ctx.set_zoom_factor(2.0);
150+
// println!("zoom factor: {}", ctx.zoom_factor());
149151

150152
// Quick Settings
151153
egui::TopBottomPanel::bottom("quick_settings_bottom_panel").show(ctx, |ui| {
@@ -598,6 +600,4 @@ pub fn draw_egui(
598600
}
599601
}
600602
});
601-
602-
ui_state.collapse_header = false;
603603
}

src/ui/state.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ pub struct UiState {
9191
pub highest_y_volume_plot: f64,
9292
pub show_fft_approx: bool,
9393
pub fft_window_size: usize,
94-
pub collapse_header: bool,
9594
pub max_gradient: f32,
9695
pub min_gradient: f32,
9796
pub hide_gizmos: bool,
@@ -116,12 +115,11 @@ impl Default for UiState {
116115
reset_on_change: true,
117116
tool_use_enabled: true,
118117
fft_scaling: FftScaling::Normalized,
119-
framerate: 60.,
118+
framerate: 30.,
120119
scroll_volume_plot: true,
121120
highest_y_volume_plot: 0.,
122121
show_fft_approx: false,
123122
fft_window_size: 1024,
124-
collapse_header: false,
125123
max_gradient: 1.25,
126124
min_gradient: -1.25,
127125
hide_gizmos: false,

0 commit comments

Comments
 (0)