Feat: add hidden mode and new documentation

This commit is contained in:
2026-02-26 12:31:56 +01:00
parent e1cf57918e
commit 70032acc75
95 changed files with 1055 additions and 286 deletions

View File

@@ -1,3 +1,5 @@
//! Cross-platform clipboard abstraction.
#[cfg(target_os = "macos")]
use crate::macos as platform;
#[cfg(target_os = "windows")]
@@ -5,6 +7,7 @@ use crate::win as platform;
#[cfg(target_os = "linux")]
use crate::x11 as platform;
/// Copy the given string to the system clipboard.
pub fn copy_to_clipboard(data: &str) {
platform::copy_to_clipboard(data)
}

View File

@@ -1,9 +1,12 @@
//! Window event types for mouse, keyboard, and window lifecycle.
use std::path::PathBuf;
use keyboard_types::{KeyboardEvent, Modifiers};
use crate::{Point, WindowInfo};
/// A mouse button identifier.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum MouseButton {
Left,
@@ -34,6 +37,7 @@ pub enum ScrollDelta {
},
}
/// A mouse input event.
#[derive(Debug, Clone, PartialEq)]
pub enum MouseEvent {
/// The mouse cursor was moved
@@ -116,6 +120,7 @@ pub enum MouseEvent {
},
}
/// A window lifecycle event.
#[derive(Debug, Clone)]
pub enum WindowEvent {
Resized(WindowInfo),
@@ -124,6 +129,7 @@ pub enum WindowEvent {
WillClose,
}
/// Top-level input event dispatched to a [`WindowHandler`](crate::WindowHandler).
#[derive(Debug, Clone)]
pub enum Event {
Mouse(MouseEvent),
@@ -131,6 +137,7 @@ pub enum Event {
Window(WindowEvent),
}
/// The effect to apply when a drag-and-drop operation completes.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum DropEffect {
Copy,
@@ -139,6 +146,7 @@ pub enum DropEffect {
Scroll,
}
/// Data payload carried by a drag-and-drop operation.
#[derive(Debug, Clone, PartialEq)]
pub enum DropData {
None,

View File

@@ -1,3 +1,5 @@
//! macOS OpenGL context implementation via NSOpenGLView.
// This is required because the objc crate is causing a lot of warnings: https://github.com/SSheldon/rust-objc/issues/125
// Eventually we should migrate to the objc2 crate and remove this.
#![allow(unexpected_cfgs)]

View File

@@ -1,3 +1,5 @@
//! OpenGL context creation and management, with platform-specific backends.
use std::ffi::c_void;
use std::marker::PhantomData;
@@ -21,6 +23,7 @@ mod macos;
#[cfg(target_os = "macos")]
use macos as platform;
/// OpenGL framebuffer and context configuration.
#[derive(Clone, Debug)]
pub struct GlConfig {
pub version: (u8, u8),
@@ -56,12 +59,14 @@ impl Default for GlConfig {
}
}
/// OpenGL profile to request.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Profile {
Compatibility,
Core,
}
/// Error returned when creating an OpenGL context fails.
#[derive(Debug)]
pub enum GlError {
InvalidWindowHandle,
@@ -69,6 +74,7 @@ pub enum GlError {
CreationFailed(platform::CreationFailedError),
}
/// Platform-independent OpenGL context handle.
pub struct GlContext {
context: platform::GlContext,
phantom: PhantomData<*mut ()>,
@@ -91,18 +97,22 @@ impl GlContext {
GlContext { context, phantom: PhantomData }
}
/// Bind this context to the current thread.
pub unsafe fn make_current(&self) {
self.context.make_current();
}
/// Unbind this context from the current thread.
pub unsafe fn make_not_current(&self) {
self.context.make_not_current();
}
/// Look up an OpenGL function pointer by name.
pub fn get_proc_address(&self, symbol: &str) -> *const c_void {
self.context.get_proc_address(symbol)
}
/// Swap the front and back framebuffers.
pub fn swap_buffers(&self) {
self.context.swap_buffers();
}

View File

@@ -1,3 +1,5 @@
//! Windows OpenGL context implementation via WGL.
use std::ffi::{c_void, CString, OsStr};
use std::os::windows::ffi::OsStrExt;

View File

@@ -1,3 +1,5 @@
//! X11 OpenGL context implementation via GLX.
use std::ffi::{c_void, CString};
use std::os::raw::{c_int, c_ulong};

View File

@@ -1,3 +1,5 @@
//! Safe X11 error handling for GLX context creation.
use std::ffi::CStr;
use std::fmt::{Debug, Display, Formatter};
use x11::xlib;

View File

@@ -1,3 +1,5 @@
//! Cross-platform windowing library for plugin UIs, with OpenGL support.
#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "windows")]

View File

@@ -1,3 +1,5 @@
//! macOS platform backend (Cocoa / AppKit).
// This is required because the objc crate is causing a lot of warnings: https://github.com/SSheldon/rust-objc/issues/125
// Eventually we should migrate to the objc2 crate and remove this.
#![allow(unexpected_cfgs)]

View File

@@ -1,3 +1,5 @@
//! NSView subclass that handles input events and drag-and-drop.
use std::ffi::c_void;
use cocoa::appkit::{NSEvent, NSFilenamesPboardType, NSView, NSWindow};

View File

@@ -1,3 +1,5 @@
//! macOS window creation, lifecycle, and event dispatch.
use std::cell::{Cell, RefCell};
use std::collections::VecDeque;
use std::ffi::c_void;

View File

@@ -1,3 +1,6 @@
//! Mouse cursor icon definitions.
/// System mouse cursor style.
#[derive(Debug, Default, Eq, PartialEq, Clone, Copy, PartialOrd, Ord, Hash)]
pub enum MouseCursor {
#[default]

View File

@@ -1,3 +1,5 @@
//! MouseCursor to Win32 LPCWSTR cursor mapping.
use crate::MouseCursor;
use winapi::{
shared::ntdef::LPCWSTR,

View File

@@ -1,3 +1,5 @@
//! COM IDropTarget implementation for drag-and-drop support.
use std::ffi::OsString;
use std::mem::transmute;
use std::os::windows::prelude::OsStringExt;

View File

@@ -1,3 +1,5 @@
//! Win32 keyboard hook to intercept key events in DAW-hosted plugin windows.
use std::{
collections::HashSet,
ffi::c_int,

View File

@@ -1,3 +1,5 @@
//! Windows platform backend (Win32 / WinAPI).
mod cursor;
mod drop_target;
mod hook;

View File

@@ -1,3 +1,5 @@
//! Win32 window creation, message loop, and event dispatch.
use winapi::shared::guiddef::GUID;
use winapi::shared::minwindef::{ATOM, FALSE, LOWORD, LPARAM, LRESULT, UINT, WPARAM};
use winapi::shared::windef::{HWND, POINT, RECT};

View File

@@ -1,3 +1,5 @@
//! Platform-independent window API and handler trait.
use std::marker::PhantomData;
use raw_window_handle::{
@@ -15,6 +17,7 @@ use crate::win as platform;
#[cfg(target_os = "linux")]
use crate::x11 as platform;
/// Opaque handle to an open window, used to close it or check liveness.
pub struct WindowHandle {
window_handle: platform::WindowHandle,
// so that WindowHandle is !Send on all platforms
@@ -44,11 +47,13 @@ unsafe impl HasRawWindowHandle for WindowHandle {
}
}
/// Trait implemented by the application to receive window events and frame callbacks.
pub trait WindowHandler {
fn on_frame(&mut self, window: &mut Window);
fn on_event(&mut self, window: &mut Window, event: Event) -> EventStatus;
}
/// A window that can be drawn to and receive events.
pub struct Window<'a> {
window: platform::Window<'a>,
@@ -67,6 +72,7 @@ impl<'a> Window<'a> {
Window { window, phantom: PhantomData }
}
/// Open a window as a child of the given parent.
pub fn open_parented<P, H, B>(parent: &P, options: WindowOpenOptions, build: B) -> WindowHandle
where
P: HasRawWindowHandle,
@@ -78,6 +84,7 @@ impl<'a> Window<'a> {
WindowHandle::new(window_handle)
}
/// Open a standalone window and block until it is closed.
pub fn open_blocking<H, B>(options: WindowOpenOptions, build: B)
where
H: WindowHandler + 'static,
@@ -103,14 +110,17 @@ impl<'a> Window<'a> {
self.window.resize(size);
}
/// Set the mouse cursor icon.
pub fn set_mouse_cursor(&mut self, cursor: MouseCursor) {
self.window.set_mouse_cursor(cursor);
}
/// Whether this window currently has keyboard focus.
pub fn has_focus(&mut self) -> bool {
self.window.has_focus()
}
/// Request keyboard focus for this window.
pub fn focus(&mut self) {
self.window.focus()
}

View File

@@ -1,3 +1,5 @@
//! Window geometry types with logical/physical coordinate conversion.
/// The info about the window
#[derive(Debug, Copy, Clone)]
pub struct WindowInfo {

View File

@@ -1,3 +1,5 @@
//! Window creation options.
use crate::Size;
/// The dpi scaling policy of the window

View File

@@ -1,3 +1,5 @@
//! MouseCursor to X11 cursor name mapping.
use std::error::Error;
use x11rb::connection::Connection;

View File

@@ -1,3 +1,5 @@
//! X11 event loop: polls XCB events and dispatches to the window handler.
use crate::x11::keyboard::{convert_key_press_event, convert_key_release_event, key_mods};
use crate::x11::{ParentHandle, Window, WindowInner};
use crate::{

View File

@@ -1,3 +1,5 @@
//! X11 platform backend (XCB / Xlib).
mod xcb_connection;
use xcb_connection::XcbConnection;

View File

@@ -1,3 +1,5 @@
//! X11 visual selection for window creation.
use crate::x11::xcb_connection::XcbConnection;
use std::error::Error;
use x11rb::connection::Connection;

View File

@@ -1,3 +1,5 @@
//! X11 window creation, lifecycle, and event dispatch.
use std::cell::Cell;
use std::error::Error;
use std::ffi::c_void;

View File

@@ -1,3 +1,5 @@
//! Shared XCB/Xlib connection wrapper.
use std::cell::RefCell;
use std::collections::hash_map::{Entry, HashMap};
use std::error::Error;