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
+4 -12
View File
@@ -1,5 +1,4 @@
// component_geometry — pure implementation. See component_geometry.h. NO REAPER / SWELL /
// LICE / vendor. Standard library only.
// component_geometry — pure implementation. See component_geometry.h.
#include "core/ui/component_geometry.h"
@@ -19,14 +18,13 @@ KitButtonBox computeButtonBox(const KitBox& cell, int padding) {
b.y = cell.y + padding;
b.width = cell.width - 2 * padding;
b.height = cell.height - 2 * padding;
if (b.empty()) return {}; // padding collapsed the cell -> suppress
if (b.empty()) return {};
return KitButtonBox{b};
}
SliderGeometry computeSlider(const KitBox& control, double value,
int handleSize, int trackThickness) {
if (control.empty() || handleSize <= 0 || trackThickness <= 0) return {};
// The handle must fit in both axes; too small -> nothing sensible to draw.
if (control.width < handleSize || control.height < handleSize) return {};
if (value < 0.0) value = 0.0;
@@ -34,8 +32,6 @@ SliderGeometry computeSlider(const KitBox& control, double value,
const int half = handleSize / 2;
// Track: horizontally inset by half the handle at each end so the handle's centre
// travels only within the control; vertically centred at trackThickness.
KitBox track;
track.x = control.x + half;
track.width = control.width - handleSize; // travel span for the handle centre
@@ -43,7 +39,6 @@ SliderGeometry computeSlider(const KitBox& control, double value,
track.height = trackThickness;
track.y = control.y + (control.height - trackThickness) / 2;
// Handle centre travels [track.x, track.x + track.width]; its box is centred on that.
const int centre = track.x + static_cast<int>(value * track.width + 0.5);
KitBox handle;
handle.x = centre - half;
@@ -51,7 +46,6 @@ SliderGeometry computeSlider(const KitBox& control, double value,
handle.width = handleSize;
handle.height = handleSize;
// Filled portion: from the track's left up to the handle centre.
KitBox filled;
filled.x = track.x;
filled.y = track.y;
@@ -79,24 +73,22 @@ double sliderValueAt(int px, const KitBox& control, int handleSize) {
ListRowBox computeListRow(const KitBox& list, int index, int rowHeight) {
if (list.empty() || rowHeight <= 0 || index < 0) return {};
const int top = list.y + index * rowHeight;
// Fully below the list bottom -> clipped away entirely -> no box.
if (top >= list.y + list.height) return {};
KitBox b;
b.x = list.x;
b.y = top;
b.width = list.width;
b.height = rowHeight; // a partially-visible last row keeps full height; caller clips
b.height = rowHeight;
return ListRowBox{index, b};
}
int hitTestListRow(int px, int py, const KitBox& list, int rowHeight, int rowCount) {
if (list.empty() || rowHeight <= 0 || rowCount <= 0) return -1;
// Outside the list band entirely.
if (px < list.x || px >= list.x + list.width ||
py < list.y || py >= list.y + list.height)
return -1;
const int row = (py - list.y) / rowHeight;
if (row < 0 || row >= rowCount) return -1; // in the empty tail past the last row
if (row < 0 || row >= rowCount) return -1;
return row;
}