Feat: add hidden mode and new documentation
Some checks failed
Deploy Website / deploy (push) Failing after 29s
Some checks failed
Deploy Website / deploy (push) Failing after 29s
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Windows OpenGL context implementation via WGL.
|
||||
|
||||
use std::ffi::{c_void, CString, OsStr};
|
||||
use std::os::windows::ffi::OsStrExt;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! X11 OpenGL context implementation via GLX.
|
||||
|
||||
use std::ffi::{c_void, CString};
|
||||
use std::os::raw::{c_int, c_ulong};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Cross-platform windowing library for plugin UIs, with OpenGL support.
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
mod macos;
|
||||
#[cfg(target_os = "windows")]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! MouseCursor to Win32 LPCWSTR cursor mapping.
|
||||
|
||||
use crate::MouseCursor;
|
||||
use winapi::{
|
||||
shared::ntdef::LPCWSTR,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Win32 keyboard hook to intercept key events in DAW-hosted plugin windows.
|
||||
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
ffi::c_int,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Windows platform backend (Win32 / WinAPI).
|
||||
|
||||
mod cursor;
|
||||
mod drop_target;
|
||||
mod hook;
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Window geometry types with logical/physical coordinate conversion.
|
||||
|
||||
/// The info about the window
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct WindowInfo {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Window creation options.
|
||||
|
||||
use crate::Size;
|
||||
|
||||
/// The dpi scaling policy of the window
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! MouseCursor to X11 cursor name mapping.
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
use x11rb::connection::Connection;
|
||||
|
||||
@@ -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::{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! X11 platform backend (XCB / Xlib).
|
||||
|
||||
mod xcb_connection;
|
||||
use xcb_connection::XcbConnection;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! X11 visual selection for window creation.
|
||||
|
||||
use crate::x11::xcb_connection::XcbConnection;
|
||||
use std::error::Error;
|
||||
use x11rb::connection::Connection;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! X11 window creation, lifecycle, and event dispatch.
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::error::Error;
|
||||
use std::ffi::c_void;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Shared XCB/Xlib connection wrapper.
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::hash_map::{Entry, HashMap};
|
||||
use std::error::Error;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Plugin editor: renders the ratatui TUI inside an egui surface.
|
||||
|
||||
use std::sync::atomic::{AtomicBool, AtomicI64};
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
@@ -147,6 +149,7 @@ struct EditorState {
|
||||
unsafe impl Send for EditorState {}
|
||||
unsafe impl Sync for EditorState {}
|
||||
|
||||
/// Build the egui-based plugin editor with ratatui rendering.
|
||||
pub fn create_editor(
|
||||
params: Arc<CagireParams>,
|
||||
egui_state: Arc<EguiState>,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Cagire as a CLAP/VST3 plugin via NIH-plug.
|
||||
|
||||
mod editor;
|
||||
mod params;
|
||||
|
||||
@@ -20,6 +22,7 @@ use cagire::engine::{
|
||||
use cagire::model::{Dictionary, Rng, Variables};
|
||||
use params::CagireParams;
|
||||
|
||||
/// Channel bridge between the plugin editor and the audio/sequencer threads.
|
||||
pub struct PluginBridge {
|
||||
pub cmd_tx: Sender<SeqCommand>,
|
||||
pub cmd_rx: Receiver<SeqCommand>,
|
||||
@@ -37,6 +40,7 @@ struct PendingNoteOff {
|
||||
note: u8,
|
||||
}
|
||||
|
||||
/// NIH-plug plugin implementing sequencer, synthesis, and MIDI I/O.
|
||||
pub struct CagirePlugin {
|
||||
params: Arc<CagireParams>,
|
||||
seq_state: Option<SequencerState>,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Standalone entry point for the Cagire plugin.
|
||||
|
||||
use cagire_plugins::CagirePlugin;
|
||||
use nih_plug::prelude::*;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Persisted plugin parameters exposed to the DAW.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use cagire_project::Project;
|
||||
@@ -5,6 +7,7 @@ use nih_plug::prelude::*;
|
||||
use nih_plug_egui::EguiState;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
/// DAW-visible parameters and persisted editor/project state.
|
||||
#[derive(Params)]
|
||||
pub struct CagireParams {
|
||||
#[persist = "editor-state"]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Egui integration layer for baseview windows.
|
||||
|
||||
mod renderer;
|
||||
mod translate;
|
||||
mod window;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! GPU renderer backend selection (currently OpenGL only).
|
||||
|
||||
#[cfg(feature = "opengl")]
|
||||
mod opengl;
|
||||
#[cfg(feature = "opengl")]
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
//! OpenGL renderer errors and submodule.
|
||||
|
||||
use egui_glow::PainterError;
|
||||
use thiserror::Error;
|
||||
|
||||
pub mod renderer;
|
||||
|
||||
/// Errors from OpenGL context or painter initialization.
|
||||
#[derive(Error, Debug)]
|
||||
pub enum OpenGlError {
|
||||
#[error("Failed to get baseview's GL context")]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Glow-based OpenGL renderer for egui inside a baseview window.
|
||||
|
||||
use baseview::{PhySize, Window};
|
||||
use egui::FullOutput;
|
||||
use egui_glow::Painter;
|
||||
@@ -5,6 +7,7 @@ use std::sync::Arc;
|
||||
|
||||
use super::OpenGlError;
|
||||
|
||||
/// OpenGL rendering options for the egui painter.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct GraphicsConfig {
|
||||
/// Controls whether to apply dithering to minimize banding artifacts.
|
||||
@@ -32,12 +35,14 @@ impl Default for GraphicsConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/// Manages glow context and egui painter lifecycle.
|
||||
pub struct Renderer {
|
||||
glow_context: Arc<egui_glow::glow::Context>,
|
||||
painter: Painter,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
/// Create a renderer from the baseview window's GL context.
|
||||
pub fn new(window: &Window, config: GraphicsConfig) -> Result<Self, OpenGlError> {
|
||||
let context = window.gl_context().ok_or(OpenGlError::NoContext)?;
|
||||
unsafe {
|
||||
@@ -71,6 +76,7 @@ impl Renderer {
|
||||
self.painter.max_texture_side()
|
||||
}
|
||||
|
||||
/// Render a completed egui frame to the window.
|
||||
pub fn render(
|
||||
&mut self,
|
||||
window: &Window,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Baseview-to-egui event translation.
|
||||
|
||||
pub(crate) fn translate_mouse_button(button: baseview::MouseButton) -> Option<egui::PointerButton> {
|
||||
match button {
|
||||
baseview::MouseButton::Left => Some(egui::PointerButton::Primary),
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Egui window wrapper over baseview, handling input, rendering, and clipboard.
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
use baseview::{
|
||||
@@ -14,6 +16,7 @@ use crate::{renderer::Renderer, GraphicsConfig};
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing::{error, warn};
|
||||
|
||||
/// Deferred command queue available during the update callback.
|
||||
pub struct Queue<'a> {
|
||||
bg_color: &'a mut Rgba,
|
||||
close_requested: &'a mut bool,
|
||||
|
||||
@@ -14,6 +14,7 @@ pub struct ResizableWindow {
|
||||
}
|
||||
|
||||
impl ResizableWindow {
|
||||
/// Create a resizable window with the given ID source.
|
||||
pub fn new(id_source: impl std::hash::Hash) -> Self {
|
||||
Self {
|
||||
id: Id::new(id_source),
|
||||
@@ -28,6 +29,7 @@ impl ResizableWindow {
|
||||
self
|
||||
}
|
||||
|
||||
/// Draw contents inside the resizable window, adding a drag corner.
|
||||
pub fn show<R>(
|
||||
self,
|
||||
context: &Context,
|
||||
@@ -65,6 +67,7 @@ impl ResizableWindow {
|
||||
}
|
||||
}
|
||||
|
||||
/// Draw diagonal lines in the corner as a resize affordance.
|
||||
pub fn paint_resize_corner(ui: &Ui, response: &Response) {
|
||||
let stroke = ui.style().interact(response).fg_stroke;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Horizontal parameter slider widget with drag, granular drag, and text entry.
|
||||
|
||||
use std::sync::{Arc, LazyLock};
|
||||
|
||||
use egui_baseview::egui::emath::GuiRounding;
|
||||
|
||||
Reference in New Issue
Block a user