Cut core/ui and core/audio comment bloat ~60% (comments only, zero code change)

This commit is contained in:
2026-07-29 20:49:02 -04:00
parent 1f24c4b095
commit 3d3415f943
29 changed files with 527 additions and 1225 deletions
+13 -25
View File
@@ -1,4 +1,4 @@
// action_bar — pure implementation. See action_bar.h. NO REAPER / SWELL / LICE / vendor.
// action_bar — pure implementation. See action_bar.h.
#include "core/ui/action_bar.h"
@@ -8,7 +8,6 @@ namespace reasampler::ui {
namespace {
// The total button count across all clusters (empty clusters contribute nothing).
int totalButtons(const std::vector<ClusterSpec>& clusters) {
int n = 0;
for (const ClusterSpec& c : clusters)
@@ -16,21 +15,16 @@ int totalButtons(const std::vector<ClusterSpec>& clusters) {
return n;
}
// Fills a slot's label rect from its box. The label spans the full button height — a single-row
// short label (L6: keybinding sub-row removed from the face; binding is in the hover tooltip).
// Insets horizontally so text clears the button edge.
void fillTextRects(ActionBarSlot& s, const ActionBarSpec& /*spec*/) {
const int hpad = 4; // horizontal text inset inside the button
const int hpad = 4;
const int innerX = s.x + hpad;
const int innerW = s.width - 2 * hpad;
if (innerW <= 0) return; // too narrow for text; leave label rect empty
if (innerW <= 0) return;
s.labelX = innerX; s.labelY = s.y; s.labelW = innerW; s.labelH = s.height;
}
// Tiles the first `visible` buttons into slots, cluster by cluster, left to right. This is the
// ONE placement routine; both computeBarSlots and hitTestActionBar drive it so draw and
// hit-test can never drift. `visible` is assumed already clamped to [0, total]. Returns the
// slots in ascending flat-index order.
// The one placement routine; computeBarSlots and hitTestActionBar both drive it so draw and
// hit-test can't drift apart.
std::vector<ActionBarSlot> tile(const ActionBarRect& bar,
const std::vector<ClusterSpec>& clusters,
const ActionBarSpec& spec, int visible) {
@@ -43,21 +37,20 @@ std::vector<ActionBarSlot> tile(const ActionBarRect& bar,
if (btnH <= 0) return slots;
int cursorX = bar.x + spec.sidePad;
int flatIndex = 0; // running flat action index across all clusters
int placed = 0; // buttons placed so far (stops at `visible`)
int flatIndex = 0;
int placed = 0;
bool firstClusterEmitted = false;
for (const ClusterSpec& c : clusters) {
if (c.count <= 0) continue; // skip empty clusters (no gap emitted)
if (c.count <= 0) continue;
if (placed >= visible) break;
// Gap BEFORE this cluster (except the first non-empty one).
if (firstClusterEmitted) cursorX += spec.clusterGap;
firstClusterEmitted = true;
for (int i = 0; i < c.count; ++i, ++flatIndex) {
if (placed >= visible) return slots; // overflow cut — stop cleanly
if (i > 0) cursorX += spec.buttonGap; // gap between buttons in the cluster
if (placed >= visible) return slots;
if (i > 0) cursorX += spec.buttonGap;
ActionBarSlot s;
s.index = flatIndex;
@@ -76,9 +69,7 @@ std::vector<ActionBarSlot> tile(const ActionBarRect& bar,
return slots;
}
// The rightmost pixel the first `visible` buttons would occupy (bar.x + sidePad based). Used by
// computeBarFit to test whether a candidate visible-count fits within the bar's usable width.
// Mirrors tile()'s advance math exactly (gaps included) so fit and layout agree.
// Mirrors tile()'s advance math so fit and layout agree.
int rightEdgeFor(const ActionBarRect& bar, const std::vector<ClusterSpec>& clusters,
const ActionBarSpec& spec, int visible) {
if (visible <= 0) return bar.x + spec.sidePad;
@@ -93,7 +84,7 @@ int rightEdgeFor(const ActionBarRect& bar, const std::vector<ClusterSpec>& clust
for (int i = 0; i < c.count; ++i) {
if (placed >= visible) return cursorX;
if (i > 0) cursorX += spec.buttonGap;
cursorX += spec.buttonWidth; // this button's right edge
cursorX += spec.buttonWidth;
++placed;
if (placed >= visible) return cursorX;
}
@@ -113,8 +104,6 @@ BarFit computeBarFit(const ActionBarRect& bar, const std::vector<ClusterSpec>& c
}
const int usableRight = bar.x + bar.width - spec.sidePad;
// Largest prefix of buttons whose right edge stays within the usable right bound. Buttons
// never shrink; trailing ones that do not fit are the overflow (dropped whole).
int visible = 0;
for (int cand = 1; cand <= total; ++cand) {
if (rightEdgeFor(bar, clusters, spec, cand) <= usableRight)
@@ -138,7 +127,6 @@ std::vector<ActionBarSlot> computeBarSlots(const ActionBarRect& bar,
int hitTestActionBar(int px, int py, const ActionBarRect& bar,
const std::vector<ClusterSpec>& clusters, const ActionBarSpec& spec) {
if (bar.height <= 0 || bar.width <= 0) return -1;
// Reject outside the bar band first (half-open bounds match the slots).
if (px < bar.x || px >= bar.x + bar.width ||
py < bar.y || py >= bar.y + bar.height)
return -1;
@@ -148,7 +136,7 @@ int hitTestActionBar(int px, int py, const ActionBarRect& bar,
if (px >= s.x && px < s.x + s.width && py >= s.y && py < s.y + s.height)
return s.index;
}
return -1; // inter-button/cluster gap or the overflow dead-zone — a clean miss
return -1;
}
} // namespace reasampler::ui