diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-27 21:15:00 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-29 15:58:42 +0200 |
| commit | d862e56e34ad1a76836cc2716b473a61879f2205 (patch) | |
| tree | bf7279fe478810fca345567fbf6ed5fa1ffa8603 /apps | |
| parent | d08fbd73e1d1257d87ed21e85fb4dcfc33c094e1 (diff) | |
| download | opencut-d862e56e34ad1a76836cc2716b473a61879f2205.tar.gz | |
feat: init desktop app
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/desktop/Cargo.toml | 11 | ||||
| -rw-r--r-- | apps/desktop/README.md | 47 | ||||
| -rw-r--r-- | apps/desktop/script/setup | 110 | ||||
| -rw-r--r-- | apps/desktop/script/setup.ps1 | 27 | ||||
| -rw-r--r-- | apps/desktop/src/main.rs | 41 |
5 files changed, 236 insertions, 0 deletions
diff --git a/apps/desktop/Cargo.toml b/apps/desktop/Cargo.toml new file mode 100644 index 00000000..e09443ab --- /dev/null +++ b/apps/desktop/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "opencut-desktop" +version = "0.1.0" +edition = "2021" + +[[bin]] +name = "opencut" +path = "src/main.rs" + +[dependencies] +gpui = "0.2.2" diff --git a/apps/desktop/README.md b/apps/desktop/README.md new file mode 100644 index 00000000..9cff04e1 --- /dev/null +++ b/apps/desktop/README.md @@ -0,0 +1,47 @@ +# Desktop + +The native desktop app, built with [GPUI](https://gpui.rs). + +## Getting started + +**1. Install Rust:** + +```bash +# Linux / macOS / WSL +./script/setup-rust +``` + +```powershell +# Windows +powershell -ExecutionPolicy Bypass -File .\script\setup-rust.ps1 +``` + +Both scripts skip installation if Rust is already present. On Linux/macOS/WSL only: after a fresh install, reload your shell with `source "$HOME/.cargo/env"` + +**2. Install native dependencies:** + +```bash +# Linux / macOS / WSL +./apps/desktop/script/setup +``` + +```powershell +# Windows +powershell -ExecutionPolicy Bypass -File .\apps\desktop\script\setup.ps1 +``` + +**3. Run:** + +```bash +cargo run -p opencut-desktop +``` + +## Platform notes + +**Linux:** supports apt (Debian/Ubuntu/Mint), dnf (Fedora/RHEL), and pacman (Arch). + +**macOS:** installs Xcode Command Line Tools if missing. + +**Windows:** the setup script checks for Visual Studio Build Tools. If missing, it prints the install link. + +**WSL:** runs the same scripts as Linux. Window rendering works via WSLg on Windows 11 and Windows 10 22H2+. If you're on an older build, test on the host instead. diff --git a/apps/desktop/script/setup b/apps/desktop/script/setup new file mode 100644 index 00000000..3152a080 --- /dev/null +++ b/apps/desktop/script/setup @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +# Installs the native system libraries GPUI needs to compile on Linux/macOS. +# Run script/setup-rust first if you don't have Rust installed yet. + +set -euo pipefail + +if [ "$(id -u)" -eq 0 ]; then + maysudo='' +else + maysudo="$(command -v sudo || command -v doas || true)" +fi + +# Ubuntu, Debian, Mint, Pop!_OS, Kali, Raspbian, etc. +apt=$(command -v apt-get || true) +if [[ -n $apt ]]; then + deps=( + curl + build-essential + pkg-config + gcc + g++ + make + libasound2-dev + libfontconfig-dev + libglib2.0-dev + libssl-dev + libva-dev + libvulkan1 + libwayland-dev + libx11-xcb-dev + libxkbcommon-x11-dev + libzstd-dev + libsqlite3-dev + ) + + $maysudo "$apt" update + $maysudo "$apt" install -y "${deps[@]}" + echo "Desktop native dependencies installed." + exit 0 +fi + +# Fedora, RHEL, CentOS, Alma, etc. +dnf=$(command -v dnf || true) +if [[ -n $dnf ]]; then + deps=( + gcc + gcc-c++ + make + pkg-config + alsa-lib-devel + fontconfig-devel + glib2-devel + openssl-devel + libva-devel + vulkan-loader + wayland-devel + libxcb-devel + libxkbcommon-x11-devel + libzstd-devel + sqlite-devel + curl + ) + + $maysudo "$dnf" install -y "${deps[@]}" + echo "Desktop native dependencies installed." + exit 0 +fi + +# Arch, Manjaro, etc. +pacman=$(command -v pacman || true) +if [[ -n $pacman ]]; then + deps=( + gcc + make + pkgconf + alsa-lib + fontconfig + glib2 + openssl + libva + vulkan-loader + wayland + libxcb + libxkbcommon-x11 + zstd + sqlite + curl + ) + + $maysudo "$pacman" -Syu --needed --noconfirm "${deps[@]}" + echo "Desktop native dependencies installed." + exit 0 +fi + +# macOS +if [[ "$(uname)" == "Darwin" ]]; then + if ! xcode-select -p &> /dev/null; then + echo "Installing Xcode Command Line Tools..." + xcode-select --install + echo "Re-run this script after the Xcode install completes." + exit 0 + fi + + echo "Desktop native dependencies installed." + exit 0 +fi + +echo "Unsupported platform. See apps/desktop/README.md for manual setup instructions." +exit 1 diff --git a/apps/desktop/script/setup.ps1 b/apps/desktop/script/setup.ps1 new file mode 100644 index 00000000..63f7fd1a --- /dev/null +++ b/apps/desktop/script/setup.ps1 @@ -0,0 +1,27 @@ +# Installs the native build tools GPUI needs to compile on Windows. +# Run script/setup-rust.ps1 first if you don't have Rust installed yet. + +$ErrorActionPreference = "Stop" + +function Check-VSBuildTools { + $vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" + + if (-not (Test-Path $vswhere)) { + return $false + } + + $result = & $vswhere -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath + return $result -and $result.Trim().Length -gt 0 +} + +if (-not (Check-VSBuildTools)) { + Write-Output "" + Write-Output "Visual Studio Build Tools with 'Desktop development with C++' not found." + Write-Output "" + Write-Output "Install it from: https://visualstudio.microsoft.com/visual-cpp-build-tools/" + Write-Output "Check the 'Desktop development with C++' workload during setup, then re-run this script." + Write-Output "" + exit 1 +} + +Write-Output "Desktop native dependencies ready." diff --git a/apps/desktop/src/main.rs b/apps/desktop/src/main.rs new file mode 100644 index 00000000..e456f136 --- /dev/null +++ b/apps/desktop/src/main.rs @@ -0,0 +1,41 @@ +use gpui::{ + App, Application, Bounds, Context, SharedString, Window, WindowBounds, WindowOptions, div, + prelude::*, px, rgb, size, +}; + +struct AppWindow { + title: SharedString, +} + +impl Render for AppWindow { + fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement { + div() + .size_full() + .bg(rgb(0x0f0f0f)) + .flex() + .justify_center() + .items_center() + .text_xl() + .text_color(rgb(0xffffff)) + .child(self.title.clone()) + } +} + +fn main() { + Application::new().run(|cx: &mut App| { + let bounds = Bounds::centered(None, size(px(1280.), px(720.)), cx); + cx.open_window( + WindowOptions { + window_bounds: Some(WindowBounds::Windowed(bounds)), + ..Default::default() + }, + |_, cx| { + cx.new(|_| AppWindow { + title: "OpenCut".into(), + }) + }, + ) + .unwrap(); + cx.activate(true); + }); +} |
