Cut shell/instrument comment bloat ~34% (comments only, zero code change)
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
// editor_internal.h — INTERNAL shared helpers for the ReaSamplerEditor TU family
|
||||
// (Q-W2v: the eight face-axis TUs split out of the former reasampler_editor.cpp).
|
||||
// Included ONLY by the editor's own shell TUs (editor_session / editor_controls /
|
||||
// editor_paint_* / editor_input_* / editor_platform) — never a public seam. Holds the
|
||||
// former god-TU's anonymous-namespace helpers that more than one split TU needs: the
|
||||
// Rect<->kit adapters, the small draw primitives (knob face / spectral strip / root
|
||||
// marker / title band), the label helpers, the deck group ids, and the velocity-curve
|
||||
// box derivation. All inline; behavior-identical to the pre-split definitions.
|
||||
// editor_internal.h — shared helpers for the ReaSamplerEditor TU family. Included ONLY by
|
||||
// the editor's own shell TUs (editor_session / editor_controls / editor_paint_* /
|
||||
// editor_input_* / editor_platform) — never a public seam. Holds the Rect<->kit adapters,
|
||||
// small draw primitives (knob face / spectral strip / root marker / title band), label
|
||||
// helpers, deck group ids, and the velocity-curve box derivation. All inline.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -24,7 +21,7 @@
|
||||
|
||||
#include "core/audio/peaks.h" // Envelope (drawEnvelope)
|
||||
#include "core/instrument/ui/capture_browser.h" // BrowserLayout / cardThumbnailRect (thumbBins)
|
||||
#include "core/instrument/ui/param_slider.h" // KnobGeometry / KnobArc (drawKnobFace, FA4)
|
||||
#include "core/instrument/ui/param_slider.h" // KnobGeometry / KnobArc (drawKnobFace)
|
||||
#include "core/instrument/ui/keyboard_strip.h" // StripLayout / keyRect / isNaturalKey (spectral strip)
|
||||
#include "core/ui/component_geometry.h" // KitBox / waveformColumnCount
|
||||
#include "core/ui/theme.h" // Role / InteractionState / KitColor / spectralColor
|
||||
@@ -33,8 +30,7 @@
|
||||
|
||||
namespace reasampler::vst {
|
||||
|
||||
// The deck group ids (shell-owned; knob_deck treats them opaquely). Left-to-right deck
|
||||
// order. Shared by the deck-desc builders (editor_controls) and the deck painter.
|
||||
// Deck group ids (shell-owned; knob_deck treats them opaquely), left-to-right order.
|
||||
enum DeckGroup {
|
||||
kGroupAmpEnv = 0,
|
||||
kGroupPitch,
|
||||
@@ -43,17 +39,14 @@ enum DeckGroup {
|
||||
kGroupMaster,
|
||||
};
|
||||
|
||||
// The S-VIEW-10 velocity-curve editor box metrics. Since r11/FB2 BOTH surfaces host the
|
||||
// curve in the POPUP (curve_popup), each summoned from its own mini preview button. The
|
||||
// INSET keeps node handles + the pick radius inside the border so an endpoint at amp 0/1
|
||||
// stays grabbable — the ONE curveBoxFromRect grammar the popup derives its mapping box
|
||||
// through. Drag-off: release beyond box+margin deletes the dragged node.
|
||||
// Velocity-curve editor box metrics. The inset keeps node handles + the pick radius
|
||||
// inside the border so an endpoint at amp 0/1 stays grabbable; drag-off beyond
|
||||
// box+margin deletes the dragged node.
|
||||
inline constexpr int kVelCurveInset = 14;
|
||||
inline constexpr int kCurveDragOffMargin = 24;
|
||||
|
||||
// The pure-module mapping Box for a drawn curve rect: inset from the border so node
|
||||
// handles and the pick radius stay inside the box. Every consumer (paint, hit-test, add,
|
||||
// drag) derives the Box through this ONE formula, so drawn nodes and grabs never drift.
|
||||
// The pure-module mapping Box for a drawn curve rect. Every consumer (paint, hit-test,
|
||||
// add, drag) derives it through this ONE formula, so drawn nodes and grabs never drift.
|
||||
inline instrument::engine::VelocityCurve::Box curveBoxFromRect(
|
||||
const instrument::ui::Rect& r) {
|
||||
return instrument::engine::VelocityCurve::Box{
|
||||
@@ -74,8 +67,8 @@ inline std::string noteLabel(int note) {
|
||||
}
|
||||
|
||||
// A display name for a bank sample id: the snapshotted bank list first, then the
|
||||
// instance-OWNED ref's displayName (pS — the label survives with the extension absent /
|
||||
// bank unreadable). "?" only when neither source knows the id.
|
||||
// instance-owned ref's displayName (survives with the extension absent). "?" if neither
|
||||
// source knows the id.
|
||||
inline std::string sampleLabel(const std::vector<instrument::map::SampleChoice>& samples,
|
||||
const instrument::map::SampleRefs& refs,
|
||||
const std::string& id) {
|
||||
@@ -90,11 +83,9 @@ inline std::string sampleLabel(const std::vector<instrument::map::SampleChoice>&
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// --- Rect <-> kit adapters (Phase L, L3) -------------------------------------
|
||||
//
|
||||
// The editor's own sub-rect type is `Rect` (editor_geometry); the kit draws against
|
||||
// `KitBox` (component_geometry). This is the single boundary that bridges them so every
|
||||
// draw routes through the L1 kit (theme roles + draw_kit).
|
||||
// draw routes through the shared kit (theme roles + draw_kit).
|
||||
inline ui::KitBox toKitBox(const instrument::ui::Rect& r) {
|
||||
return ui::KitBox{r.x, r.y, r.width, r.height};
|
||||
}
|
||||
@@ -110,23 +101,22 @@ inline void kitTextCentered(LICE_IBitmap* bmp, const instrument::ui::Rect& r,
|
||||
text(bmp, toKitBox(r), s, font, role, Align::Center);
|
||||
}
|
||||
|
||||
// Draw a peak envelope in `r` through the kit's shared waveform primitive (Phase L, L3).
|
||||
// Draw a peak envelope in `r` through the kit's shared waveform primitive.
|
||||
inline void drawEnvelope(LICE_IBitmap* bmp, const instrument::ui::Rect& r,
|
||||
const audio::Envelope& env) {
|
||||
drawWaveform(bmp, toKitBox(r), env);
|
||||
}
|
||||
|
||||
// The bin count a card's thumbnail is computed at: one bin per drawn pixel column — the
|
||||
// gap-free render comes from peaks::columnMinMax's exact partition, not from extra bins.
|
||||
// thumbnailFor clamps the request to the decoded frame count.
|
||||
// The bin count a card's thumbnail is computed at: one bin per drawn pixel column (the
|
||||
// gap-free render comes from peaks::columnMinMax's exact partition).
|
||||
inline int thumbBins(const instrument::ui::BrowserLayout& layout) {
|
||||
return (std::max)(1, kWaveformOversample *
|
||||
ui::waveformColumnCount(toKitBox(
|
||||
instrument::ui::cardThumbnailRect(layout, 0))));
|
||||
}
|
||||
|
||||
// Draw the title band with the live readout. Shared by the Sample face (nav visible) —
|
||||
// Browse/Zone draw their own back button in place of the nav.
|
||||
// Draws the title band with the live readout. Browse/Zone draw their own back button in
|
||||
// place of the nav.
|
||||
inline void drawTitleBand(LICE_IBitmap* bmp, const instrument::ui::Rect& title,
|
||||
const std::string& readout) {
|
||||
fillSurface(bmp, toKitBox(title), ui::Role::BgPanel, ui::InteractionState::Rest);
|
||||
@@ -135,12 +125,10 @@ inline void drawTitleBand(LICE_IBitmap* bmp, const instrument::ui::Rect& title,
|
||||
kitText(bmp, titleText, readout.c_str(), Font::Title, ui::Role::TextPrimary);
|
||||
}
|
||||
|
||||
// Draw one radial knob face (r11): the FA4 param_slider primitive owns the value<->angle
|
||||
// map; this turns it into LICE calls through the kit's palette roles. LICE's arc
|
||||
// convention matches param_slider's (angle 0 = 12 o'clock, positive clockwise) — but LICE
|
||||
// takes RADIANS, and drawing the 7->5 o'clock sweep THROUGH the top needs a continuous
|
||||
// angle span, so the degrees convert as (deg - 360) * pi/180, mapping 210..510 onto
|
||||
// -150..+150 degrees. One conversion, both arcs.
|
||||
// Draws one radial knob face: param_slider owns the value<->angle map; this turns it into
|
||||
// LICE calls. LICE takes radians, and drawing the 7->5 o'clock sweep through the top needs
|
||||
// a continuous angle span, so degrees convert as (deg - 360) * pi/180, mapping 210..510
|
||||
// onto -150..+150 degrees.
|
||||
inline void drawKnobFace(LICE_IBitmap* bmp, const instrument::ui::Rect& knobRect,
|
||||
double value01, ui::InteractionState st) {
|
||||
using instrument::ui::KnobArc;
|
||||
@@ -149,14 +137,13 @@ inline void drawKnobFace(LICE_IBitmap* bmp, const instrument::ui::Rect& knobRect
|
||||
const KnobGeometry kg = instrument::ui::computeKnob(knobRect);
|
||||
if (kg.radius <= 1.0) return;
|
||||
constexpr double kDegToRad = 3.14159265358979323846 / 180.0;
|
||||
const KnobArc arc{}; // the FA4 default 7->5 o'clock sweep
|
||||
const KnobArc arc{}; // the default 7->5 o'clock sweep
|
||||
const float cx = static_cast<float>(kg.centerX);
|
||||
const float cy = static_cast<float>(kg.centerY);
|
||||
const float rOuter = static_cast<float>(kg.radius) - 0.5f;
|
||||
const bool disabled = (st == ui::InteractionState::Disabled);
|
||||
const bool hot = (st == ui::InteractionState::Dragging || st == ui::InteractionState::Hover);
|
||||
|
||||
// Face: a filled circle in the cell surface color under the interaction state.
|
||||
LICE_FillCircle(bmp, cx, cy, rOuter - 1.f, toLice(ui::roleColorState(ui::Role::BgCell, st)),
|
||||
1.0f, 0, true);
|
||||
// Track: the full sweep as a hairline arc (the dead 60-degree arc at the bottom stays bare).
|
||||
@@ -165,8 +152,6 @@ inline void drawKnobFace(LICE_IBitmap* bmp, const instrument::ui::Rect& knobRect
|
||||
(arc.startDeg + instrument::ui::knobSweepDeg(arc) - 360.0) * kDegToRad);
|
||||
LICE_Arc(bmp, cx, cy, rOuter, a0, a1, toLice(ui::roleColor(ui::Role::LineHairline)), 1.0f, 0,
|
||||
true);
|
||||
// Value arc: start -> the value's angle, in the live accent (hot while under the pointer /
|
||||
// dragging, dim when disabled).
|
||||
const double v = value01 < 0.0 ? 0.0 : (value01 > 1.0 ? 1.0 : value01);
|
||||
if (v > 0.0) {
|
||||
const float av = static_cast<float>(
|
||||
@@ -185,11 +170,9 @@ inline void drawKnobFace(LICE_IBitmap* bmp, const instrument::ui::Rect& knobRect
|
||||
toLice(ui::roleColor(needleRole)), 1.0f, 0, true);
|
||||
}
|
||||
|
||||
// Draw the pastel spectral keyboard-strip background (Phase L, L3) — the signature
|
||||
// surface. Fills each MIDI key column with its spectral hue, then draws faint per-octave
|
||||
// hairline ticks. Shared by the setup face + the Zones strip so both read as the same
|
||||
// spectrum. S-VIEW-7: accidentals get a dark bg/base wash over the hue (an OVERLAY, not
|
||||
// a keyboard shape) so pitch position reads as a keyboard at a glance.
|
||||
// Draws the pastel spectral keyboard-strip background: each MIDI key column filled with
|
||||
// its spectral hue, accidentals darkened with an overlay wash so pitch position reads as
|
||||
// a keyboard at a glance. Shared by the setup face + the Zones strip.
|
||||
inline void drawSpectralStrip(LICE_IBitmap* bmp, const instrument::ui::Rect& stripArea) {
|
||||
using instrument::ui::StripLayout;
|
||||
if (stripArea.width <= 0 || stripArea.height <= 0) return;
|
||||
@@ -218,8 +201,8 @@ inline void drawSpectralStrip(LICE_IBitmap* bmp, const instrument::ui::Rect& str
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the single-capture root marker on the strip: an accent-primary bar with a soft
|
||||
// STATIC glow (a wider, lower-alpha accent bar behind it) — the "this is live" mark.
|
||||
// Draws the single-capture root marker: an accent-primary bar with a soft static glow —
|
||||
// the "this is live" mark.
|
||||
inline void drawRootMarker(LICE_IBitmap* bmp, const instrument::ui::Rect& stripArea,
|
||||
const instrument::ui::StripLayout& sl, int root) {
|
||||
const int sx = stripArea.x;
|
||||
|
||||
Reference in New Issue
Block a user