Rhythmusraster, kompaktes Layout für „Singen“, Akkorde auf dem Raster
- Akkordgrenzen rasten auf die Zählzeiten des Rasters ein - Rhythmusraster im Stil des GuiTacheles-Blatts (Felder anklickbar, speicherbar) - Singen-Ansicht ohne Scrollen: Kopfzeile, Notenfeld füllt den Rest, Mischpult als Leiste, Fenster „Mehr“ und „Ergebnis“ - Regler verbrauchen das Mausrad (Fenster scrollt nicht mehr mit) - Raster/Muster-Änderungen wirken auch nach Transponieren und während einer Session Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -98,19 +98,34 @@ fn dim(c: Color32, k: f32) -> Color32 {
|
||||
|
||||
/// Frontplatte: dunkles Metall mit Rand, gravierter Überschrift und vier Schrauben.
|
||||
pub fn panel<R>(ui: &mut Ui, title: &str, add: impl FnOnce(&mut Ui) -> R) -> R {
|
||||
panel_with(ui, Some(title), add)
|
||||
}
|
||||
|
||||
/// Niedrige Frontplatte ohne Überschrift, für schmale Leisten.
|
||||
pub fn bar<R>(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> R {
|
||||
panel_with(ui, None, add)
|
||||
}
|
||||
|
||||
fn panel_with<R>(ui: &mut Ui, title: Option<&str>, add: impl FnOnce(&mut Ui) -> R) -> R {
|
||||
let frame = egui::Frame::new()
|
||||
.fill(PLATE_BG)
|
||||
.stroke(Stroke::new(1.5, PLATE_EDGE))
|
||||
.corner_radius(8.0)
|
||||
.inner_margin(egui::Margin::symmetric(14, 10));
|
||||
.inner_margin(if title.is_some() {
|
||||
egui::Margin::symmetric(14, 10)
|
||||
} else {
|
||||
egui::Margin::symmetric(14, 6)
|
||||
});
|
||||
let out = frame.show(ui, |ui| {
|
||||
ui.label(
|
||||
egui::RichText::new(title.to_uppercase())
|
||||
.small()
|
||||
.strong()
|
||||
.color(ENGRAVING),
|
||||
);
|
||||
ui.add_space(2.0);
|
||||
if let Some(title) = title {
|
||||
ui.label(
|
||||
egui::RichText::new(title.to_uppercase())
|
||||
.small()
|
||||
.strong()
|
||||
.color(ENGRAVING),
|
||||
);
|
||||
ui.add_space(2.0);
|
||||
}
|
||||
add(ui)
|
||||
});
|
||||
let r = out.response.rect;
|
||||
@ -154,14 +169,29 @@ pub fn led(p: &egui::Painter, c: egui::Pos2, on: bool, color: Color32, r: f32) {
|
||||
pub fn knob(
|
||||
ui: &mut Ui,
|
||||
value: &mut f32,
|
||||
(min, max): (f32, f32),
|
||||
range: (f32, f32),
|
||||
default: f32,
|
||||
label: &str,
|
||||
show: impl Fn(f32) -> String,
|
||||
enabled: bool,
|
||||
) -> Response {
|
||||
const SIZE: f32 = 64.0;
|
||||
let width = SIZE.max(
|
||||
knob_sized(ui, value, range, default, label, show, enabled, 64.0)
|
||||
}
|
||||
|
||||
/// Wie [`knob`], mit wählbarem Durchmesser des Reglerkörpers (Punkte; ab etwa 40 gut bedienbar).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn knob_sized(
|
||||
ui: &mut Ui,
|
||||
value: &mut f32,
|
||||
(min, max): (f32, f32),
|
||||
default: f32,
|
||||
label: &str,
|
||||
show: impl Fn(f32) -> String,
|
||||
enabled: bool,
|
||||
size: f32,
|
||||
) -> Response {
|
||||
let big = size;
|
||||
let width = big.max(
|
||||
ui.fonts_mut(|f| {
|
||||
f.layout_no_wrap(
|
||||
label.to_string(),
|
||||
@ -173,7 +203,7 @@ pub fn knob(
|
||||
}) + 6.0,
|
||||
);
|
||||
let (rect, mut resp) = ui.allocate_exact_size(
|
||||
vec2(width, SIZE + 34.0),
|
||||
vec2(width, big + 34.0),
|
||||
if enabled {
|
||||
Sense::click_and_drag()
|
||||
} else {
|
||||
@ -191,6 +221,8 @@ pub fn knob(
|
||||
if scroll != 0.0 {
|
||||
*value = knob_drag(*value, min, max, scroll * 0.5, fine);
|
||||
resp.mark_changed();
|
||||
// Radbewegung verbrauchen, sonst scrollt zusätzlich das Fenster.
|
||||
ui.input_mut(|i| i.smooth_scroll_delta = egui::Vec2::ZERO);
|
||||
}
|
||||
}
|
||||
if resp.double_clicked() {
|
||||
@ -204,7 +236,7 @@ pub fn knob(
|
||||
0.0
|
||||
};
|
||||
let p = ui.painter_at(rect);
|
||||
let c = pos2(rect.center().x, rect.top() + SIZE / 2.0 + 2.0);
|
||||
let c = pos2(rect.center().x, rect.top() + big / 2.0 + 2.0);
|
||||
let alpha = if enabled { 1.0 } else { 0.4 };
|
||||
// Skala: 11 Striche, bis zum Wert beleuchtet.
|
||||
for i in 0..=10 {
|
||||
@ -212,8 +244,8 @@ pub fn knob(
|
||||
let a = knob_angle(f);
|
||||
let (s, co) = a.sin_cos();
|
||||
let (r0, r1) = (
|
||||
SIZE / 2.0 + 1.0,
|
||||
SIZE / 2.0 + if i % 5 == 0 { 7.0 } else { 5.0 },
|
||||
big / 2.0 + 1.0,
|
||||
big / 2.0 + if i % 5 == 0 { 7.0 } else { 5.0 },
|
||||
);
|
||||
let lit = f <= frac + 0.001 && frac > 0.0;
|
||||
p.line_segment(
|
||||
@ -233,20 +265,20 @@ pub fn knob(
|
||||
}
|
||||
// Reglerkörper: Rand, Fläche, Glanz.
|
||||
let hot = resp.hovered() || resp.dragged();
|
||||
p.circle_filled(c, SIZE / 2.0 - 2.0, Color32::from_rgb(20, 19, 18));
|
||||
p.circle_filled(c, big / 2.0 - 2.0, Color32::from_rgb(20, 19, 18));
|
||||
p.circle_filled(
|
||||
c,
|
||||
SIZE / 2.0 - 5.0,
|
||||
big / 2.0 - 5.0,
|
||||
dim(Color32::from_rgb(70, 66, 62), alpha),
|
||||
);
|
||||
p.circle_filled(
|
||||
c,
|
||||
SIZE / 2.0 - 9.0,
|
||||
big / 2.0 - 9.0,
|
||||
dim(Color32::from_rgb(54, 50, 47), alpha),
|
||||
);
|
||||
p.circle_filled(
|
||||
c - vec2(6.0, 8.0),
|
||||
SIZE / 2.0 - 22.0,
|
||||
(big / 2.0 - 22.0).max(3.0),
|
||||
Color32::from_white_alpha(if hot { 14 } else { 8 }),
|
||||
);
|
||||
let a = knob_angle(frac);
|
||||
@ -254,7 +286,7 @@ pub fn knob(
|
||||
p.line_segment(
|
||||
[
|
||||
c + vec2(s * 8.0, -co * 8.0),
|
||||
c + vec2(s * (SIZE / 2.0 - 8.0), -co * (SIZE / 2.0 - 8.0)),
|
||||
c + vec2(s * (big / 2.0 - 8.0), -co * (big / 2.0 - 8.0)),
|
||||
],
|
||||
Stroke::new(3.5, dim(AMBER, alpha)),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user