Rebuild the chrome band: full-width piano strip with uniform key widths, note tooltips, one toolbar font
This commit is contained in:
@@ -10,14 +10,20 @@ namespace reasampler::instrument::ui {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int kStripBandHeight = 40; // the root/piano strip's own height inside the row
|
||||
// The toolbar row carries the whole control run, so it is taller than the Browse modal's
|
||||
// plain kTitleHeight bar — the velocity knob cell (knob over label) sets the floor. Both
|
||||
// rows still fit the band the allocator hands out (kTitleHeight + kChromeRowHeight).
|
||||
constexpr int kToolbarHeight = 44;
|
||||
constexpr int kStripBandHeight = 30;
|
||||
|
||||
// The control row's fixed right-anchored run, right to left.
|
||||
constexpr int kRunGap = 6; // between adjacent items of the toolbar run
|
||||
constexpr int kChanSegW = 52;
|
||||
constexpr int kChanSegH = 18;
|
||||
constexpr int kCurveBtnSize = 28;
|
||||
constexpr int kVelCellW = 48;
|
||||
constexpr int kCurveBtnSize = 24;
|
||||
constexpr int kVelCellW = 44;
|
||||
constexpr int kVelLabelH = 12;
|
||||
constexpr int kPreviewBtnW = 64;
|
||||
constexpr int kRunButtonH = 24; // Browse and Preview
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -25,46 +31,61 @@ ChromeRects chromeRects(const Rect& chrome, int knobSize) {
|
||||
ChromeRects r;
|
||||
if (chrome.empty()) return r;
|
||||
|
||||
const int titleH = std::min(kTitleHeight, chrome.height);
|
||||
r.toolbar = Rect::ltrb(chrome.x, chrome.y, chrome.right(), chrome.y + titleH);
|
||||
const int toolbarH = std::min(kToolbarHeight, chrome.height);
|
||||
r.toolbar = Rect::ltrb(chrome.x, chrome.y, chrome.right(), chrome.y + toolbarH);
|
||||
r.controls = Rect::ltrb(chrome.x, r.toolbar.bottom(), chrome.right(), chrome.bottom());
|
||||
|
||||
const int navTop = r.toolbar.y + 2;
|
||||
const int navBot = std::max(navTop, r.toolbar.bottom() - 2);
|
||||
r.navBrowse = Rect::ltrb(std::max(chrome.x, chrome.right() - kPad - kNavButtonWidth),
|
||||
navTop, std::max(chrome.x, chrome.right() - kPad), navBot);
|
||||
const Rect& row = r.toolbar;
|
||||
const auto topFor = [&row](int h) { return row.y + (row.height - h) / 2; };
|
||||
const auto leftOf = [&row](int edge, int w) { return std::max(row.x, edge - w); };
|
||||
|
||||
if (r.controls.empty()) return r;
|
||||
const Rect& row = r.controls;
|
||||
// The fixed run, right to left: Browse, Mono|Stereo, curve, velocity cell, preview.
|
||||
const int navH = std::min(kRunButtonH, row.height);
|
||||
const int navTop = topFor(navH);
|
||||
const int navRight = std::max(row.x, row.right() - kPad);
|
||||
r.navBrowse = Rect::ltrb(leftOf(navRight, kNavButtonWidth), navTop, navRight,
|
||||
navTop + navH);
|
||||
|
||||
// Vertically centre the two heights the row uses: the tall strip band (which the preview
|
||||
// button and velocity cell align to) and the smaller square/segment controls.
|
||||
const int stripTop = row.y + (row.height - kStripBandHeight) / 2;
|
||||
const int stripBot = stripTop + kStripBandHeight;
|
||||
|
||||
const int chanTop = row.y + (row.height - kChanSegH) / 2;
|
||||
const int chanRight = row.right() - kPad;
|
||||
r.chanStereo = Rect::ltrb(chanRight - kChanSegW, chanTop, chanRight, chanTop + kChanSegH);
|
||||
r.chanMono = Rect::ltrb(r.chanStereo.x - kChanSegW, chanTop, r.chanStereo.x,
|
||||
const int chanTop = topFor(kChanSegH);
|
||||
const int chanRight = leftOf(r.navBrowse.x, kRunGap);
|
||||
r.chanStereo = Rect::ltrb(leftOf(chanRight, kChanSegW), chanTop, chanRight,
|
||||
chanTop + kChanSegH);
|
||||
r.chanMono = Rect::ltrb(leftOf(r.chanStereo.x, kChanSegW), chanTop, r.chanStereo.x,
|
||||
chanTop + kChanSegH);
|
||||
|
||||
const int curveTop = row.y + (row.height - kCurveBtnSize) / 2;
|
||||
r.curveBtn = Rect::ltrb(r.chanMono.x - kPad - kCurveBtnSize, curveTop,
|
||||
r.chanMono.x - kPad, curveTop + kCurveBtnSize);
|
||||
const int curveTop = topFor(kCurveBtnSize);
|
||||
const int curveRight = leftOf(r.chanMono.x, kRunGap);
|
||||
r.curveBtn = Rect::ltrb(leftOf(curveRight, kCurveBtnSize), curveTop, curveRight,
|
||||
curveTop + kCurveBtnSize);
|
||||
|
||||
r.velCell = Rect::ltrb(r.curveBtn.x - kPad - kVelCellW, stripTop,
|
||||
r.curveBtn.x - kPad, stripBot);
|
||||
const int knobLeft = r.velCell.x + (kVelCellW - knobSize) / 2;
|
||||
const int cellH = std::min(row.height, knobSize + kVelLabelH);
|
||||
const int cellTop = topFor(cellH);
|
||||
const int cellRight = leftOf(r.curveBtn.x, kRunGap);
|
||||
r.velCell = Rect::ltrb(leftOf(cellRight, kVelCellW), cellTop, cellRight, cellTop + cellH);
|
||||
const int knobLeft = r.velCell.x + (r.velCell.width - knobSize) / 2;
|
||||
r.velKnob = Rect::ltrb(knobLeft, r.velCell.y, knobLeft + knobSize,
|
||||
r.velCell.y + knobSize);
|
||||
r.velCell.y + std::min(knobSize, cellH));
|
||||
r.velLabel = Rect::ltrb(r.velCell.x, r.velKnob.bottom(), r.velCell.right(),
|
||||
r.velCell.bottom());
|
||||
|
||||
r.preview = Rect::ltrb(r.velCell.x - kPad - kPreviewBtnW, stripTop,
|
||||
r.velCell.x - kPad, stripBot);
|
||||
// Remainder width; clamped so a narrow window collapses the strip rather than inverting it.
|
||||
r.rootStrip = Rect::ltrb(row.x + kPad, stripTop,
|
||||
std::max(row.x + kPad, r.preview.x - kPad), stripBot);
|
||||
const int prevTop = topFor(std::min(kRunButtonH, row.height));
|
||||
const int prevRight = leftOf(r.velCell.x, kRunGap);
|
||||
r.preview = Rect::ltrb(leftOf(prevRight, kPreviewBtnW), prevTop, prevRight,
|
||||
prevTop + std::min(kRunButtonH, row.height));
|
||||
|
||||
// The title takes what the run leaves; clamped so a narrow window collapses it rather
|
||||
// than inverting it.
|
||||
r.title = Rect::ltrb(row.x + kPad, row.y, std::max(row.x + kPad, r.preview.x - kRunGap),
|
||||
row.bottom());
|
||||
|
||||
if (r.controls.empty()) return r;
|
||||
// The strip row belongs to the strip alone — inset only by the shared band pad, so it
|
||||
// lines up with the waveform band directly beneath it.
|
||||
const int stripH = std::min(kStripBandHeight, r.controls.height);
|
||||
const int stripTop = r.controls.y + (r.controls.height - stripH) / 2;
|
||||
r.rootStrip = Rect::ltrb(r.controls.x + kPad, stripTop,
|
||||
std::max(r.controls.x + kPad, r.controls.right() - kPad),
|
||||
stripTop + stripH);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user