mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
trying to add skinny black borders around things
This commit is contained in:
parent
9035353893
commit
1fe60bff5f
9 changed files with 845 additions and 532 deletions
|
|
@ -2,6 +2,8 @@ use crate::*;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct JackPort<T: PortSpec> {
|
||||
/// Port name
|
||||
pub name: String,
|
||||
/// Handle to JACK client, for receiving reconnect events.
|
||||
pub jack: Arc<RwLock<JackConnection>>,
|
||||
/// Port handle.
|
||||
|
|
@ -10,7 +12,7 @@ pub struct JackPort<T: PortSpec> {
|
|||
pub connect: Vec<PortConnection>
|
||||
}
|
||||
impl<T: PortSpec> JackPort<T> {
|
||||
pub fn connect_to_matching (&mut self) {
|
||||
pub fn connect_to_matching (&mut self) -> Usually<()> {
|
||||
use PortConnectionName::*;
|
||||
use PortConnectionScope::*;
|
||||
use PortConnectionStatus::*;
|
||||
|
|
@ -21,7 +23,8 @@ impl<T: PortSpec> JackPort<T> {
|
|||
if port.as_str() == &**name {
|
||||
if let Some(port) = self.jack.port_by_name(port.as_str()) {
|
||||
let port_status = Self::try_both_ways(&self.jack, &port, &self.port);
|
||||
status.push((port, port_status));
|
||||
let name = port.name()?;
|
||||
status.push((port, name, port_status));
|
||||
if port_status == Connected {
|
||||
break
|
||||
}
|
||||
|
|
@ -31,7 +34,8 @@ impl<T: PortSpec> JackPort<T> {
|
|||
RegExp(re) => for port in self.jack.ports(Some(&re), None, PortFlags::empty()).iter() {
|
||||
if let Some(port) = self.jack.port_by_name(port.as_str()) {
|
||||
let port_status = Self::try_both_ways(&self.jack, &port, &self.port);
|
||||
status.push((port, port_status));
|
||||
let name = port.name()?;
|
||||
status.push((port, name, port_status));
|
||||
if port_status == Connected && connect.scope == One {
|
||||
break
|
||||
}
|
||||
|
|
@ -40,6 +44,7 @@ impl<T: PortSpec> JackPort<T> {
|
|||
}
|
||||
connect.status = status
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn try_both_ways <A: PortSpec, B: PortSpec> (
|
||||
jack: &impl ConnectPort, port_a: &Port<A>, port_b: &Port<B>
|
||||
|
|
@ -59,7 +64,7 @@ impl<T: PortSpec> JackPort<T> {
|
|||
pub struct PortConnection {
|
||||
pub name: PortConnectionName,
|
||||
pub scope: PortConnectionScope,
|
||||
pub status: Vec<(Port<Unowned>, PortConnectionStatus)>,
|
||||
pub status: Vec<(Port<Unowned>, String, PortConnectionStatus)>,
|
||||
}
|
||||
impl PortConnection {
|
||||
pub fn collect (exact: &[impl AsRef<str>], re: &[impl AsRef<str>], re_all: &[impl AsRef<str>])
|
||||
|
|
@ -84,11 +89,22 @@ impl PortConnection {
|
|||
let name = PortConnectionName::RegExp(name.as_ref().into());
|
||||
Self { name, scope: PortConnectionScope::All, status: vec![] }
|
||||
}
|
||||
pub fn info (&self) -> String {
|
||||
format!("{} {} {}", match self.scope {
|
||||
PortConnectionScope::One => " ",
|
||||
PortConnectionScope::All => "*",
|
||||
}, match &self.name {
|
||||
PortConnectionName::Exact(name) => format!("= {name}"),
|
||||
PortConnectionName::RegExp(name) => format!("~ {name}"),
|
||||
}, self.status.len())
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum PortConnectionName {
|
||||
/** Exact match */ Exact(Arc<str>),
|
||||
/** Match regular expression */ RegExp(Arc<str>),
|
||||
/** Exact match */
|
||||
Exact(Arc<str>),
|
||||
/** Match regular expression */
|
||||
RegExp(Arc<str>),
|
||||
}
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum PortConnectionScope { One, All }
|
||||
|
|
@ -106,10 +122,11 @@ impl JackPort<MidiIn> {
|
|||
) -> Usually<Self> {
|
||||
let mut port = JackPort {
|
||||
jack: jack.clone(),
|
||||
port: jack.midi_in(name)?,
|
||||
port: jack.midi_in(name.as_ref())?,
|
||||
name: name.as_ref().to_string(),
|
||||
connect: connect.to_vec()
|
||||
};
|
||||
port.connect_to_matching();
|
||||
port.connect_to_matching()?;
|
||||
Ok(port)
|
||||
}
|
||||
}
|
||||
|
|
@ -119,10 +136,11 @@ impl JackPort<MidiOut> {
|
|||
) -> Usually<Self> {
|
||||
let mut port = Self {
|
||||
jack: jack.clone(),
|
||||
port: jack.midi_out(name)?,
|
||||
port: jack.midi_out(name.as_ref())?,
|
||||
name: name.as_ref().to_string(),
|
||||
connect: connect.to_vec()
|
||||
};
|
||||
port.connect_to_matching();
|
||||
port.connect_to_matching()?;
|
||||
Ok(port)
|
||||
}
|
||||
}
|
||||
|
|
@ -132,10 +150,11 @@ impl JackPort<AudioIn> {
|
|||
) -> Usually<Self> {
|
||||
let mut port = Self {
|
||||
jack: jack.clone(),
|
||||
port: jack.audio_in(name)?,
|
||||
port: jack.audio_in(name.as_ref())?,
|
||||
name: name.as_ref().to_string(),
|
||||
connect: connect.to_vec()
|
||||
};
|
||||
port.connect_to_matching();
|
||||
port.connect_to_matching()?;
|
||||
Ok(port)
|
||||
}
|
||||
}
|
||||
|
|
@ -145,10 +164,11 @@ impl JackPort<AudioOut> {
|
|||
) -> Usually<Self> {
|
||||
let mut port = Self {
|
||||
jack: jack.clone(),
|
||||
port: jack.audio_out(name)?,
|
||||
port: jack.audio_out(name.as_ref())?,
|
||||
name: name.as_ref().to_string(),
|
||||
connect: connect.to_vec()
|
||||
};
|
||||
port.connect_to_matching();
|
||||
port.connect_to_matching()?;
|
||||
Ok(port)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue