feat: add Anvil sub anchor and Crucible resampler
Check and Windows preview / check (anvil) (push) Successful in 2m41s
Check and Windows preview / check (crucible) (push) Successful in 2m7s
Check and Windows preview / check (patina) (push) Successful in 2m5s
Check and Windows preview / check (rivet) (push) Successful in 1m33s
Check and Windows preview / previews (push) Successful in 1m10s
Check and Windows preview / windows (push) Successful in 2m2s
Independent plugin release / publish (push) Successful in 8s
Independent plugin release / plan (push) Successful in 7s
Independent plugin release / build (push) Successful in 3m3s
Check and Windows preview / check (anvil) (push) Successful in 2m41s
Check and Windows preview / check (crucible) (push) Successful in 2m7s
Check and Windows preview / check (patina) (push) Successful in 2m5s
Check and Windows preview / check (rivet) (push) Successful in 1m33s
Check and Windows preview / previews (push) Successful in 1m10s
Check and Windows preview / windows (push) Successful in 2m2s
Independent plugin release / publish (push) Successful in 8s
Independent plugin release / plan (push) Successful in 7s
Independent plugin release / build (push) Successful in 3m3s
Two new CLAP effects aimed at riddim and dubstep production, plus shared crates so all four plugins keep one look and reuse DSP. Anvil 0.1.0 (io.storyboard.sub-anchor): - Replaces the band below Split with a clean mono sine. Every note gets the same peak level and restarts at the same phase, so switch-ups keep their weight and kick hits line up. - Pitch and note starts come from the audio (YIN, 80 ms lookahead reported to the host) or from MIDI notes sent to the effect. - Dynamics, Drive, Octave, Glide, Phase, Gate and Keep; Solo sub monitor, note readout, level meters and a low-band oscilloscope. Crucible 0.1.0 (io.storyboard.resampler): - Records its input continuously in a lock-free ring with host transport markers. Capture takes the newest 1-16 complete bars on the bar grid, following tempo changes, or the newest audio when stopped. - Grid (straight and triplet) or transient slicing, manual cuts, slice audition without audio-thread allocation. - Export writes the loop, trimmed, declicked and normalised slices named and tagged with their root note, and an optional 2048-sample wavetable for Serum and Vital. Shared: - common-ui holds the palette, fonts, knobs and panels taken from Patina; Patina renders identically. Rotary knobs at their minimum no longer tessellate a zero-length arc into NaN vertices. - common-dsp holds biquads, a Linkwitz-Riley crossover, YIN, note helpers and a float WAV writer with sampler root and Serum frame chunks. - Catalog, CI matrix, release tags, editor previews and docs cover both plugins; a script test keeps the catalog and workflows in step.
This commit is contained in:
1 parent
f1366280ff
commit
f36ff0780c
57 files changed
+10373
-285
No files matched your search
@@ -0,0 +1,567 @@
|
||||
//! Crucible editor, shared by the CLAP wrapper and the headless renderer.
|
||||
use common_ui::*;
|
||||
use crucible_core::{
|
||||
capture, export, render, Division, Exported, Mode, Queues, Ring, Settings, Take, Transport,
|
||||
OVERVIEW,
|
||||
};
|
||||
use egui::{self, Color32, FontId, Pos2, Rect, RichText, Sense, Stroke, Vec2};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
pub use common_ui::style;
|
||||
pub const WIDTH: u32 = 1040;
|
||||
pub const HEIGHT: u32 = 680;
|
||||
const MAX_TAKES: usize = 8;
|
||||
const DEFAULT_HELP: &str =
|
||||
"Play your bass, press Capture, then drag the exported files from FL's browser.";
|
||||
|
||||
/// Connection to the audio thread.
|
||||
pub struct Link {
|
||||
pub ring: Option<Arc<Ring>>,
|
||||
pub queues: Arc<Queues>,
|
||||
}
|
||||
|
||||
pub struct State {
|
||||
pub takes: Vec<Take>,
|
||||
pub take: Option<usize>,
|
||||
pub slice: Option<usize>,
|
||||
pub status: String,
|
||||
pub help: String,
|
||||
pub peak: f32,
|
||||
pub transport: Option<Transport>,
|
||||
pub folder: String,
|
||||
counter: usize,
|
||||
names: Vec<String>,
|
||||
/// Filled by the export thread when it finishes.
|
||||
job: Option<Arc<Mutex<Option<std::io::Result<Exported>>>>>,
|
||||
last_export: Option<std::path::PathBuf>,
|
||||
}
|
||||
impl Default for State {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
takes: Vec::new(),
|
||||
take: None,
|
||||
slice: None,
|
||||
status: String::new(),
|
||||
help: DEFAULT_HELP.into(),
|
||||
peak: 0.,
|
||||
transport: None,
|
||||
folder: String::new(),
|
||||
counter: 0,
|
||||
names: Vec::new(),
|
||||
job: None,
|
||||
last_export: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl State {
|
||||
/// Adds a take (newest first) and slices it with the current settings.
|
||||
pub fn add(&mut self, mut take: Take, settings: &Settings) {
|
||||
take.slice(settings);
|
||||
self.counter += 1;
|
||||
self.names.insert(
|
||||
0,
|
||||
format!(
|
||||
"Take {} · {} bar{} · {:.0} BPM",
|
||||
self.counter,
|
||||
take.bars,
|
||||
if take.bars == 1 { "" } else { "s" },
|
||||
take.tempo()
|
||||
),
|
||||
);
|
||||
self.takes.insert(0, take);
|
||||
self.takes.truncate(MAX_TAKES);
|
||||
self.names.truncate(MAX_TAKES);
|
||||
self.take = Some(0);
|
||||
self.slice = None;
|
||||
}
|
||||
fn current(&mut self) -> Option<&mut Take> {
|
||||
self.take.and_then(|i| self.takes.get_mut(i))
|
||||
}
|
||||
}
|
||||
|
||||
fn hint(r: &egui::Response, state: &mut State, text: &str) {
|
||||
if r.hovered() {
|
||||
state.help = text.into();
|
||||
}
|
||||
}
|
||||
fn chip(ui: &mut egui::Ui, on: bool, label: &str) -> egui::Response {
|
||||
ui.selectable_label(on, RichText::new(label).size(13.))
|
||||
}
|
||||
fn unix_now() -> u64 {
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map_or(0, |d| d.as_secs())
|
||||
}
|
||||
fn open_folder(path: &std::path::Path) {
|
||||
let program = if cfg!(windows) {
|
||||
"explorer"
|
||||
} else {
|
||||
"xdg-open"
|
||||
};
|
||||
let _ = std::process::Command::new(program).arg(path).spawn();
|
||||
}
|
||||
|
||||
fn audition(link: &Link, take: &Take, index: usize, settings: &Settings) {
|
||||
if let Some(slice) = take.slices.get(index) {
|
||||
link.queues.play(Arc::from(render(take, slice, settings)));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show(ui: &mut egui::Ui, settings: &mut Settings, state: &mut State, link: &Link) {
|
||||
backdrop(ui);
|
||||
link.queues.drain();
|
||||
state.help = DEFAULT_HELP.into();
|
||||
if let Some(ring) = &link.ring {
|
||||
let p = ring.take_peak();
|
||||
state.peak = p.max(state.peak * 0.9);
|
||||
if let Some(m) = ring.markers().last() {
|
||||
state.transport = Some(m.transport);
|
||||
}
|
||||
}
|
||||
let finished = state
|
||||
.job
|
||||
.as_ref()
|
||||
.and_then(|job| job.lock().ok().and_then(|mut slot| slot.take()));
|
||||
if let Some(result) = finished {
|
||||
state.job = None;
|
||||
state.status = match result {
|
||||
Ok(done) => {
|
||||
let mut s = format!("Exported {} files to {}", done.files, done.folder.display());
|
||||
if let Some(why) = done.wavetable_skipped {
|
||||
s += &format!(" (no wavetable: {why})");
|
||||
}
|
||||
state.last_export = Some(done.folder);
|
||||
s
|
||||
}
|
||||
Err(e) => format!("Export failed: {e}"),
|
||||
};
|
||||
}
|
||||
ui.add_space(2.);
|
||||
header(ui, "CRUCIBLE", "RESAMPLER", |ui| {
|
||||
let db = 20. * state.peak.max(1e-6).log10();
|
||||
ui.label(
|
||||
RichText::new(if db < -90. {
|
||||
"—".into()
|
||||
} else {
|
||||
format!("{db:.1} dB")
|
||||
})
|
||||
.monospace()
|
||||
.size(12.)
|
||||
.color(if db > -0.1 { ACCENT } else { MUTED }),
|
||||
);
|
||||
caption(ui, "INPUT");
|
||||
});
|
||||
ui.add_space(6.);
|
||||
panel(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
ui.horizontal(|ui| capture_row(ui, settings, state, link));
|
||||
});
|
||||
ui.add_space(6.);
|
||||
let body = 300.;
|
||||
ui.horizontal_top(|ui| {
|
||||
panel(ui, |ui| {
|
||||
ui.set_width(190.);
|
||||
ui.set_min_height(body);
|
||||
ui.vertical(|ui| takes(ui, state));
|
||||
});
|
||||
ui.add_space(4.);
|
||||
panel(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
waveform(ui, settings, state, link, body);
|
||||
});
|
||||
});
|
||||
ui.add_space(6.);
|
||||
panel(ui, |ui| {
|
||||
ui.set_width(ui.available_width());
|
||||
ui.vertical(|ui| controls(ui, settings, state, link));
|
||||
});
|
||||
ui.separator();
|
||||
let line = if state.status.is_empty() || state.help != DEFAULT_HELP {
|
||||
state.help.clone()
|
||||
} else {
|
||||
state.status.clone()
|
||||
};
|
||||
ui.label(RichText::new(line).color(MUTED));
|
||||
}
|
||||
|
||||
fn capture_row(ui: &mut egui::Ui, settings: &mut Settings, state: &mut State, link: &Link) {
|
||||
let button = egui::Button::new(
|
||||
RichText::new("CAPTURE")
|
||||
.font(FontId::new(17., egui::FontFamily::Name("medium".into())))
|
||||
.color(Color32::WHITE),
|
||||
)
|
||||
.fill(Color32::from_rgb(150, 0, 56))
|
||||
.stroke(Stroke::new(1.0_f32, ACCENT))
|
||||
.min_size(Vec2::new(130., 34.));
|
||||
let r = ui.add_enabled(link.ring.is_some(), button);
|
||||
hint(
|
||||
&r,
|
||||
state,
|
||||
"Grab the newest complete bars. While stopped, grabs the newest audio instead.",
|
||||
);
|
||||
if r.clicked() {
|
||||
if let Some(ring) = &link.ring {
|
||||
match capture(ring, settings.bars) {
|
||||
Ok(take) => {
|
||||
let synced = take.synced;
|
||||
state.add(take, settings);
|
||||
state.status = if synced {
|
||||
format!("Captured {} bars on the bar grid.", settings.bars)
|
||||
} else {
|
||||
"Transport stopped: captured the newest audio at the last tempo.".into()
|
||||
};
|
||||
}
|
||||
Err(e) => state.status = e.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
ui.add_space(10.);
|
||||
caption(ui, "BARS");
|
||||
for bars in Settings::BARS {
|
||||
if chip(ui, settings.bars == bars, &bars.to_string()).clicked() {
|
||||
settings.bars = bars;
|
||||
}
|
||||
}
|
||||
ui.add_space(10.);
|
||||
ui.separator();
|
||||
let text = match state.transport {
|
||||
Some(t) => format!(
|
||||
"{:.1} BPM · {}/{} · {}",
|
||||
t.tempo,
|
||||
t.numerator,
|
||||
t.denominator,
|
||||
if t.playing { "playing" } else { "stopped" }
|
||||
),
|
||||
None if link.ring.is_some() => "No host tempo yet · 140 BPM assumed".into(),
|
||||
None => "Audio engine inactive".into(),
|
||||
};
|
||||
ui.label(RichText::new(text).monospace().size(13.).color(STEEL));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if let Some(ring) = &link.ring {
|
||||
ui.label(
|
||||
RichText::new(format!(
|
||||
"{:.0} s history",
|
||||
ring.capacity() as f32 / ring.rate()
|
||||
))
|
||||
.size(12.)
|
||||
.color(MUTED),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn takes(ui: &mut egui::Ui, state: &mut State) {
|
||||
caption(ui, "TAKES");
|
||||
if state.takes.is_empty() {
|
||||
ui.label(RichText::new("Nothing captured yet.").color(DIM));
|
||||
}
|
||||
let mut pick = None;
|
||||
for (i, name) in state.names.iter().enumerate() {
|
||||
let r = ui.add_sized(
|
||||
Vec2::new(ui.available_width(), 26.),
|
||||
egui::SelectableLabel::new(state.take == Some(i), RichText::new(name).size(13.)),
|
||||
);
|
||||
if r.clicked() {
|
||||
pick = Some(i);
|
||||
}
|
||||
}
|
||||
if let Some(i) = pick {
|
||||
state.take = Some(i);
|
||||
state.slice = None;
|
||||
}
|
||||
if let Some(i) = state.take {
|
||||
ui.add_space(8.);
|
||||
if ui.button(RichText::new("REMOVE TAKE").size(12.)).clicked() {
|
||||
state.takes.remove(i);
|
||||
state.names.remove(i);
|
||||
state.take = (!state.takes.is_empty()).then_some(0);
|
||||
state.slice = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn waveform(ui: &mut egui::Ui, settings: &Settings, state: &mut State, link: &Link, height: f32) {
|
||||
let (rect, response) =
|
||||
ui.allocate_exact_size(Vec2::new(ui.available_width(), height), Sense::click());
|
||||
let p = ui.painter_at(rect);
|
||||
p.rect_filled(rect, 2., SCREEN);
|
||||
let Some(ti) = state.take.filter(|i| *i < state.takes.len()) else {
|
||||
p.text(
|
||||
rect.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
"Play the part you want to resample, then press CAPTURE",
|
||||
FontId::proportional(15.),
|
||||
DIM,
|
||||
);
|
||||
return;
|
||||
};
|
||||
let take = &state.takes[ti];
|
||||
let frames = take.frames().max(1) as f32;
|
||||
let label_band = 18.;
|
||||
let wave = Rect::from_min_max(rect.min + Vec2::new(0., label_band), rect.max);
|
||||
let x_of = |frame: usize| wave.left() + wave.width() * frame as f32 / frames;
|
||||
// Slices: tint, disabled dimming, selection.
|
||||
for (i, s) in take.slices.iter().enumerate() {
|
||||
let r = Rect::from_min_max(
|
||||
Pos2::new(x_of(s.start), wave.top()),
|
||||
Pos2::new(x_of(s.end), wave.bottom()),
|
||||
);
|
||||
let fill = if state.slice == Some(i) {
|
||||
Color32::from_rgba_unmultiplied(255, 1, 96, 28)
|
||||
} else if !s.enabled {
|
||||
Color32::from_rgba_unmultiplied(0, 0, 0, 120)
|
||||
} else {
|
||||
Color32::TRANSPARENT
|
||||
};
|
||||
p.rect_filled(r, 0., fill);
|
||||
if r.width() > 26. {
|
||||
let text = s.root.map_or("·".into(), common_dsp::note_name);
|
||||
p.text(
|
||||
Pos2::new(r.center().x, rect.top() + 3.),
|
||||
egui::Align2::CENTER_TOP,
|
||||
text,
|
||||
FontId::proportional(11.),
|
||||
if s.enabled { STEEL } else { DIM },
|
||||
);
|
||||
}
|
||||
}
|
||||
// Bar and beat grid.
|
||||
let quarters = take.quarters();
|
||||
let bar = take.bar_quarters();
|
||||
let mut q = 0.;
|
||||
while q <= quarters + 1e-6 {
|
||||
let x = x_of(take.frame_at(q).round() as usize);
|
||||
let is_bar = ((q / bar).round() * bar - q).abs() < 1e-6;
|
||||
p.line_segment(
|
||||
[Pos2::new(x, wave.top()), Pos2::new(x, wave.bottom())],
|
||||
Stroke::new(
|
||||
1.0_f32,
|
||||
if is_bar {
|
||||
Color32::from_rgb(60, 64, 72)
|
||||
} else {
|
||||
Color32::from_rgb(28, 30, 34)
|
||||
},
|
||||
),
|
||||
);
|
||||
q += 1.;
|
||||
}
|
||||
// Overview waveform.
|
||||
let mid = wave.center().y;
|
||||
let half = wave.height() * 0.46;
|
||||
let peak = take
|
||||
.overview
|
||||
.iter()
|
||||
.fold(0.01f32, |m, v| m.max(v[0].abs()).max(v[1].abs()));
|
||||
let columns = wave.width().max(1.) as usize;
|
||||
for c in 0..columns {
|
||||
let a = c * OVERVIEW / columns;
|
||||
let z = ((c + 1) * OVERVIEW / columns).max(a + 1).min(OVERVIEW);
|
||||
let (mut lo, mut hi) = (0f32, 0f32);
|
||||
for v in &take.overview[a..z] {
|
||||
lo = lo.min(v[0]);
|
||||
hi = hi.max(v[1]);
|
||||
}
|
||||
let x = wave.left() + c as f32 + 0.5;
|
||||
p.line_segment(
|
||||
[
|
||||
Pos2::new(x, mid - hi / peak * half),
|
||||
Pos2::new(x, mid - lo / peak * half + 0.5),
|
||||
],
|
||||
Stroke::new(1.0_f32, STEEL),
|
||||
);
|
||||
}
|
||||
// Cuts.
|
||||
for c in &take.cuts[1..take.cuts.len().saturating_sub(1)] {
|
||||
let x = x_of(*c);
|
||||
p.line_segment(
|
||||
[Pos2::new(x, rect.top()), Pos2::new(x, rect.bottom())],
|
||||
Stroke::new(1.0_f32, ACCENT),
|
||||
);
|
||||
}
|
||||
p.rect_stroke(
|
||||
rect,
|
||||
2.,
|
||||
Stroke::new(1.0_f32, EDGE),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
let frame_at =
|
||||
|pos: Pos2| (((pos.x - wave.left()) / wave.width()).clamp(0., 1.) * frames) as usize;
|
||||
if response.hovered() {
|
||||
state.help =
|
||||
"Click a slice to hear it. Double-click to add a cut, right-click to remove the nearest."
|
||||
.into();
|
||||
}
|
||||
let pointer = response.interact_pointer_pos();
|
||||
if response.double_clicked() {
|
||||
if let Some(pos) = pointer {
|
||||
let f = frame_at(pos);
|
||||
if let Some(t) = state.current() {
|
||||
if t.add_cut(f) {
|
||||
state.slice = state.takes[ti].slice_at(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if response.clicked() {
|
||||
if let Some(pos) = pointer {
|
||||
let f = frame_at(pos);
|
||||
state.slice = state.takes[ti].slice_at(f);
|
||||
if let Some(i) = state.slice {
|
||||
audition(link, &state.takes[ti], i, settings);
|
||||
}
|
||||
}
|
||||
} else if response.secondary_clicked() {
|
||||
if let Some(pos) = pointer {
|
||||
let f = frame_at(pos);
|
||||
if let Some(t) = state.current() {
|
||||
t.remove_cut(f);
|
||||
}
|
||||
state.slice = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn controls(ui: &mut egui::Ui, settings: &mut Settings, state: &mut State, link: &Link) {
|
||||
let before = settings.clone();
|
||||
ui.horizontal(|ui| {
|
||||
caption(ui, "SLICE BY");
|
||||
for (mode, label) in [(Mode::Grid, "GRID"), (Mode::Transient, "TRANSIENTS")] {
|
||||
if chip(ui, settings.mode == mode, label).clicked() {
|
||||
settings.mode = mode;
|
||||
}
|
||||
}
|
||||
ui.add_space(8.);
|
||||
match settings.mode {
|
||||
Mode::Grid => {
|
||||
for d in Division::ALL {
|
||||
if chip(ui, settings.division == d, d.label()).clicked() {
|
||||
settings.division = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
Mode::Transient => {
|
||||
caption(ui, "SENSITIVITY");
|
||||
let r = ui.add(
|
||||
egui::Slider::new(&mut settings.sensitivity, 0. ..=100.)
|
||||
.suffix(" %")
|
||||
.clamping(egui::SliderClamping::Always),
|
||||
);
|
||||
hint(&r, state, "Higher finds quieter hits.");
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
caption(ui, "DECLICK");
|
||||
let r = ui.add(
|
||||
egui::Slider::new(&mut settings.declick, 0. ..=20.)
|
||||
.suffix(" ms")
|
||||
.clamping(egui::SliderClamping::Always),
|
||||
);
|
||||
hint(
|
||||
&r,
|
||||
state,
|
||||
"Fade at both ends of every slice, so cuts never click.",
|
||||
);
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
let r = chip(ui, settings.trim, "TRIM SILENCE");
|
||||
if r.clicked() {
|
||||
settings.trim = !settings.trim;
|
||||
}
|
||||
hint(&r, state, "Remove silence before the first sound of a slice.");
|
||||
let r = chip(ui, settings.normalize, "NORMALIZE");
|
||||
if r.clicked() {
|
||||
settings.normalize = !settings.normalize;
|
||||
}
|
||||
hint(&r, state, "Peak every slice at −0.3 dBFS.");
|
||||
let r = chip(ui, settings.wavetable, "WAVETABLE");
|
||||
if r.clicked() {
|
||||
settings.wavetable = !settings.wavetable;
|
||||
}
|
||||
hint(
|
||||
&r,
|
||||
state,
|
||||
"Also write wavetable.wav from the selected slice: 2048-sample frames for Serum or Vital.",
|
||||
);
|
||||
ui.separator();
|
||||
let take = state.take;
|
||||
let slice = state.slice;
|
||||
match (take.and_then(|t| state.takes.get_mut(t)), slice) {
|
||||
(Some(t), Some(i)) if i < t.slices.len() => {
|
||||
let s = &mut t.slices[i];
|
||||
let seconds = (s.end - s.start) as f32 / t.rate;
|
||||
ui.label(
|
||||
RichText::new(format!(
|
||||
"SLICE {} · {} · {:.2} s",
|
||||
i + 1,
|
||||
s.root.map_or("no pitch".into(), common_dsp::note_name),
|
||||
seconds
|
||||
))
|
||||
.size(13.)
|
||||
.color(TEXT),
|
||||
);
|
||||
ui.checkbox(&mut s.enabled, "Export");
|
||||
if ui.small_button("▶").clicked() {
|
||||
audition(link, t, i, settings);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
ui.label(RichText::new("No slice selected").size(13.).color(DIM));
|
||||
}
|
||||
}
|
||||
});
|
||||
let recut = settings.mode != before.mode
|
||||
|| settings.division != before.division
|
||||
|| (settings.mode == Mode::Transient && settings.sensitivity != before.sensitivity);
|
||||
if recut {
|
||||
if let Some(t) = state.current() {
|
||||
t.slice(settings);
|
||||
}
|
||||
state.slice = None;
|
||||
}
|
||||
ui.add_space(4.);
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
caption(ui, "FOLDER");
|
||||
if state.folder.is_empty() {
|
||||
state.folder = settings.folder().display().to_string();
|
||||
}
|
||||
let r = ui.add(egui::TextEdit::singleline(&mut state.folder).desired_width(420.));
|
||||
if r.changed() {
|
||||
settings.folder = state.folder.clone();
|
||||
}
|
||||
hint(
|
||||
&r,
|
||||
state,
|
||||
"Add this folder to FL's browser once; exports then appear there for dragging.",
|
||||
);
|
||||
let can = state.take.is_some() && state.job.is_none();
|
||||
let export_button =
|
||||
egui::Button::new(RichText::new("EXPORT").size(14.).color(Color32::WHITE))
|
||||
.fill(Color32::from_rgb(150, 0, 56))
|
||||
.stroke(Stroke::new(1.0_f32, ACCENT));
|
||||
if ui.add_enabled(can, export_button).clicked() {
|
||||
if let Some(take) = state.take.and_then(|i| state.takes.get(i)).cloned() {
|
||||
let slot = Arc::new(Mutex::new(None));
|
||||
let done = slot.clone();
|
||||
let settings = settings.clone();
|
||||
let selected = state.slice;
|
||||
std::thread::spawn(move || {
|
||||
let folder = settings.folder();
|
||||
let result = export(&take, &settings, selected, &folder, unix_now());
|
||||
if let Ok(mut slot) = done.lock() {
|
||||
*slot = Some(result);
|
||||
}
|
||||
});
|
||||
state.job = Some(slot);
|
||||
state.status = "Exporting…".into();
|
||||
}
|
||||
}
|
||||
if ui.button(RichText::new("OPEN FOLDER").size(13.)).clicked() {
|
||||
let path = state
|
||||
.last_export
|
||||
.clone()
|
||||
.unwrap_or_else(|| settings.folder());
|
||||
let _ = std::fs::create_dir_all(&path);
|
||||
open_folder(&path);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user