Skip to content

Commit

Permalink
Volume control derives ceiling from TEMPERATURE_CEILING const
Browse files Browse the repository at this point in the history
  • Loading branch information
molenick committed Aug 1, 2023
1 parent 199b7db commit 83d2670
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
4 changes: 4 additions & 0 deletions katniss-test/src/bin/spaceship-gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ slint::include_modules!();
// #5
// See about making a knob sim, slider works ok for demo though.

const TEMPERATURE_CEILING: i32 = 1000;

fn set_jumpdrive_temperature(status: Arc<Mutex<JumpDriveStatus>>, new_temp: i32) {
let mut status = status.lock().unwrap();
status.temperature = new_temp;
Expand All @@ -51,6 +53,8 @@ fn main() -> Result<(), Box<dyn Error>> {
let gui_status = status.clone();
let slider_control_status = status.clone();

window.set_temperature_ceiling(TEMPERATURE_CEILING);

thread::spawn(move || {
tokio::runtime::Runtime::new()
.unwrap()
Expand Down
26 changes: 9 additions & 17 deletions katniss-test/src/bin/ui/main.slint
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HyperdriveConsole } from "hyperdrive_console.slint";
import { VerticalVolume } from "vertical_volume.slint";

export component MainWindow inherits Window {
width: 1080px;
width: 540px;
height: 960px;
callback temperature_changed(float);

Expand All @@ -21,7 +21,7 @@ export component MainWindow inherits Window {
HorizontalBox {
VerticalVolume {
value: temperature;
ceiling: 1000; // magic
ceiling: temperature_ceiling;
bar-height: 4px;
bar-spacing: 4px;
background: black;
Expand All @@ -31,22 +31,14 @@ export component MainWindow inherits Window {
height: 800px;
}
}
}
VerticalBox {
width: 540px;
Rectangle {
background: #444;
VerticalBox {
Slider {
width: 500px;
value: 0;
minimum: 0;
maximum: 1000; // magic
Slider {
width: 500px;
value: 0;
minimum: 0;
maximum: temperature_ceiling;

changed(change) => {
root.temperature-changed(change);
}
}
changed(change) => {
root.temperature-changed(change);
}
}
}
Expand Down

0 comments on commit 83d2670

Please sign in to comment.