slint/demos/home-automation/ui/components/camera.slint
Tasuku Suzuki 0188abe315
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / files-changed (push) Waiting to run
CI / build_and_test (ubuntu-22.04, 1.88) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, 1.88) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (macos-14) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
CI / material-components (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.88) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
Torizon am62 nogpu (#9602)
* Torizon: Remove Mesa OpenGL packages for software renderer builds

When BUILD_HOME_AUTOMATION_SW_RENDERER=true, remove Mesa OpenGL packages
to force Skia Software renderer on GPU-less devices. Preserves libgbm1
as it's required for DRM buffer management.

* home-automation: Disable animations on software renderer for performance

- Conditionally disable camera view animations when no GPU accelerator available
- Remove complex timer-based widget loading animations in software renderer mode
- Simplifies rendering pipeline to improve performance on CPU-only devices
2025-10-07 10:58:31 +03:00

96 lines
2.9 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
import { Colors } from "../common.slint";
import { Control } from "control.slint";
import { AppState } from "../appState.slint";
import { HaText } from "general/haText.slint";
enum CameraView {
front,
back
}
export component Camera inherits Control {
property <int> current-page: AppState.current-page;
property <bool> unlocked: false;
property <image> cam: @image-url("../images/front-porch.jpg");
property <bool> is-active: false;
property <CameraView> camera-view: CameraView.front;
control-background: @image-url("../images/overhead-frame.png", nine-slice(50));
function toggle-view() {
if camera-view == CameraView.front {
camera-view = CameraView.back;
} else {
camera-view = CameraView.front;
}
}
tile := Rectangle {
x: 0;
Image {
x: 1px;
source: root.cam;
width: tile.width - 2px;
image-fit: cover;
height: 60%;
horizontal-alignment: center;
vertical-alignment: center;
}
Image {
x: 1px;
source: @image-url("../images/back-yard.jpg");
width: tile.width - 2px;
image-fit: cover;
height: 60%;
horizontal-alignment: center;
vertical-alignment: center;
states [
// Separate states for with and without animation
// https://github.com/slint-ui/slint/issues/7999
back-with-animation when camera-view == CameraView.back && AppState.graphics-accelerator-available: {
opacity: 1;
in-out {
animate opacity { duration: 300ms; }
}
}
front-with-animation when camera-view == CameraView.front && AppState.graphics-accelerator-available: {
opacity: 0;
in-out {
animate opacity { duration: 300ms; }
}
}
back-without-animation when camera-view == CameraView.back && !AppState.graphics-accelerator-available: {
opacity: 1;
}
front-without-animation when camera-view == CameraView.front && !AppState.graphics-accelerator-available: {
opacity: 0;
}
]
}
TouchArea {
clicked => {
toggle-view();
}
}
HaText {
y: root.height - self.height - 10px;
text: camera-view == CameraView.back ? "Back Yard" : "Front Porch";
color: Colors.white;
font-size: 1.5rem;
font-weight: 200;
}
}
Timer {
interval: 2s;
running: AppState.kiosk-mode;
triggered => {
toggle-view();
}
}
}