Skip to content

Commit 3bc3b9a

Browse files
committed
Code formatting
1 parent a88aacf commit 3bc3b9a

3 files changed

Lines changed: 57 additions & 45 deletions

File tree

examples/graphics/source/examples/CrossoverDemo.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -420,46 +420,46 @@ class CrossoverDemo : public yup::Component
420420
{
421421
// Configure the CartesianPlane for frequency response display
422422
frequencyDisplay.setTitle ("Crossover Frequency Response");
423-
423+
424424
// Set logarithmic X axis (frequency) and linear Y axis (dB)
425425
frequencyDisplay.setXRange (20.0, 20000.0);
426426
frequencyDisplay.setXScaleType (yup::CartesianPlane::AxisScaleType::logarithmic);
427427
frequencyDisplay.setYRange (-48.0, 12.0);
428428
frequencyDisplay.setYScaleType (yup::CartesianPlane::AxisScaleType::linear);
429-
429+
430430
// Set margins
431431
frequencyDisplay.setMargins (25, 50, 20, 20);
432-
432+
433433
// Add vertical grid lines (frequency)
434434
frequencyDisplay.setVerticalGridLines ({ 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0, 20000.0 });
435-
435+
436436
// Add horizontal grid lines (dB)
437437
frequencyDisplay.setHorizontalGridLines ({ -48.0, -36.0, -24.0, -12.0, -6.0, 0.0, 6.0 });
438-
438+
439439
// Emphasize special lines
440440
frequencyDisplay.addHorizontalGridLine (0.0, yup::Color (0xFF666666), 2.0f, true); // 0dB line
441441
frequencyDisplay.addHorizontalGridLine (-6.0, yup::Color (0xFF444444), 1.0f, true); // -6dB crossover line
442-
442+
443443
// Add axis labels
444444
frequencyDisplay.setXAxisLabels ({ 100.0, 1000.0, 10000.0 });
445445
frequencyDisplay.setYAxisLabels ({ -24.0, -12.0, -6.0, 0.0 });
446-
446+
447447
// Add signals
448448
lowPassSignalIndex = frequencyDisplay.addSignal ("Low", yup::Color (0xFF4488FF), 2.0f);
449449
highPassSignalIndex = frequencyDisplay.addSignal ("High", yup::Color (0xFFFF8844), 2.0f);
450-
450+
451451
// Configure legend
452452
frequencyDisplay.setLegendVisible (true);
453453
frequencyDisplay.setLegendPosition ({ 0.9f, 0.1f });
454-
454+
455455
// Set initial crossover frequency line
456456
setCrossoverFrequency (1000.0);
457457
}
458458

459459
void setCrossoverFrequency (double freq)
460460
{
461461
currentCrossoverFreq = freq;
462-
462+
463463
// Update crossover frequency line
464464
frequencyDisplay.clearVerticalGridLines();
465465
frequencyDisplay.setVerticalGridLines ({ 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0, 20000.0 });
@@ -494,7 +494,7 @@ class CrossoverDemo : public yup::Component
494494
yup::Label highGainLabel;
495495
yup::Slider highGainSlider;
496496
yup::CartesianPlane frequencyDisplay;
497-
497+
498498
// Signal indices for CartesianPlane
499499
int lowPassSignalIndex = -1;
500500
int highPassSignalIndex = -1;

modules/yup_audio_gui/displays/yup_CartesianPlane.cpp

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ Rectangle<float> CartesianPlane::getPlotBounds() const
385385
static_cast<float> (marginLeft),
386386
static_cast<float> (marginTop),
387387
static_cast<float> (bounds.getWidth() - marginLeft - marginRight),
388-
static_cast<float> (bounds.getHeight() - marginTop - marginBottom)
389-
);
388+
static_cast<float> (bounds.getHeight() - marginTop - marginBottom));
390389
}
391390

392391
//==============================================================================
@@ -403,7 +402,7 @@ void CartesianPlane::paint (Graphics& g)
403402
drawAxisLabels (g, plotBounds);
404403
drawTitle (g);
405404

406-
if (showLegend && !signals.empty())
405+
if (showLegend && ! signals.empty())
407406
drawLegend (g, plotBounds);
408407
}
409408

@@ -453,12 +452,12 @@ void CartesianPlane::drawSignals (Graphics& g, const Rectangle<float>& bounds)
453452
{
454453
for (const auto& signal : signals)
455454
{
456-
if (!signal.visible || signal.data.empty())
455+
if (! signal.visible || signal.data.empty())
457456
continue;
458457

459458
g.setStrokeColor (signal.color);
460459
g.setStrokeWidth (signal.strokeWidth);
461-
460+
462461
Path path;
463462
bool firstPoint = true;
464463
Point<float> previousPoint;
@@ -468,10 +467,10 @@ void CartesianPlane::drawSignals (Graphics& g, const Rectangle<float>& bounds)
468467
{
469468
float x = valueToX (point.getX());
470469
float y = valueToY (point.getY());
471-
470+
472471
Point<float> currentPoint (x, y);
473472
bool currentPointInBounds = bounds.contains (currentPoint);
474-
473+
475474
// Handle visibility and path continuity
476475
if (currentPointInBounds)
477476
{
@@ -480,7 +479,7 @@ void CartesianPlane::drawSignals (Graphics& g, const Rectangle<float>& bounds)
480479
path.startNewSubPath (x, y);
481480
firstPoint = false;
482481
}
483-
else if (previousPointValid && !bounds.contains (previousPoint))
482+
else if (previousPointValid && ! bounds.contains (previousPoint))
484483
{
485484
// Previous point was outside, current is inside - find intersection and start new subpath
486485
auto intersection = findBoundsIntersection (previousPoint, currentPoint, bounds);
@@ -508,12 +507,12 @@ void CartesianPlane::drawSignals (Graphics& g, const Rectangle<float>& bounds)
508507
path.lineTo (intersection->getX(), intersection->getY());
509508
}
510509
}
511-
510+
512511
previousPoint = currentPoint;
513512
previousPointValid = true;
514513
}
515514

516-
if (!firstPoint)
515+
if (! firstPoint)
517516
g.strokePath (path);
518517
}
519518
}
@@ -533,8 +532,7 @@ void CartesianPlane::drawAxisLabels (Graphics& g, const Rectangle<float>& bounds
533532
static_cast<int> (x - 30),
534533
static_cast<int> (bounds.getBottom() + 2),
535534
60,
536-
marginBottom - 2
537-
);
535+
marginBottom - 2);
538536

539537
g.fillFittedText (label.text, font, labelBounds, Justification::center);
540538
}
@@ -553,8 +551,7 @@ void CartesianPlane::drawAxisLabels (Graphics& g, const Rectangle<float>& bounds
553551
2,
554552
static_cast<int> (y - 8),
555553
marginLeft - 4,
556-
16
557-
);
554+
16);
558555

559556
g.fillFittedText (label.text, font, labelBounds, Justification::right);
560557
}
@@ -572,8 +569,7 @@ void CartesianPlane::drawTitle (Graphics& g)
572569
marginLeft,
573570
2,
574571
getWidth() - marginLeft - marginRight,
575-
marginTop - 4
576-
);
572+
marginTop - 4);
577573

578574
g.fillFittedText (titleText, titleFont, titleBounds, titleJustification);
579575
}
@@ -584,7 +580,7 @@ void CartesianPlane::drawLegend (Graphics& g, const Rectangle<float>& bounds)
584580
int visibleSignalCount = 0;
585581
for (const auto& signal : signals)
586582
{
587-
if (signal.visible && !signal.name.isEmpty())
583+
if (signal.visible && ! signal.name.isEmpty())
588584
visibleSignalCount++;
589585
}
590586

@@ -622,7 +618,7 @@ void CartesianPlane::drawLegend (Graphics& g, const Rectangle<float>& bounds)
622618

623619
for (const auto& signal : signals)
624620
{
625-
if (!signal.visible || signal.name.isEmpty())
621+
if (! signal.visible || signal.name.isEmpty())
626622
continue;
627623

628624
// Draw color indicator
@@ -635,8 +631,7 @@ void CartesianPlane::drawLegend (Graphics& g, const Rectangle<float>& bounds)
635631
static_cast<int> (legendX + padding + 18),
636632
static_cast<int> (itemY),
637633
legendWidth - padding - 18 - padding,
638-
itemHeight
639-
);
634+
itemHeight);
640635

641636
g.setFillColor (Colors::white);
642637
g.fillFittedText (signal.name, font, textBounds, Justification::centerLeft);
@@ -668,25 +663,25 @@ String CartesianPlane::formatAxisValue (double value, AxisScaleType scaleType) c
668663
std::optional<Point<float>> CartesianPlane::findBoundsIntersection (const Point<float>& p1, const Point<float>& p2, const Rectangle<float>& bounds) const
669664
{
670665
// Find intersection of line segment p1-p2 with rectangle bounds
671-
666+
672667
float dx = p2.getX() - p1.getX();
673668
float dy = p2.getY() - p1.getY();
674-
669+
675670
if (std::abs (dx) < 1e-6f && std::abs (dy) < 1e-6f)
676671
return std::nullopt; // Points are the same
677-
672+
678673
float t_min = 0.0f;
679674
float t_max = 1.0f;
680-
675+
681676
// Check intersection with vertical bounds (left and right edges)
682677
if (std::abs (dx) > 1e-6f)
683678
{
684679
float t_left = (bounds.getX() - p1.getX()) / dx;
685680
float t_right = (bounds.getRight() - p1.getX()) / dx;
686-
681+
687682
float t_min_x = jmin (t_left, t_right);
688683
float t_max_x = jmax (t_left, t_right);
689-
684+
690685
t_min = jmax (t_min, t_min_x);
691686
t_max = jmin (t_max, t_max_x);
692687
}
@@ -696,16 +691,16 @@ std::optional<Point<float>> CartesianPlane::findBoundsIntersection (const Point<
696691
if (p1.getX() < bounds.getX() || p1.getX() > bounds.getRight())
697692
return std::nullopt;
698693
}
699-
694+
700695
// Check intersection with horizontal bounds (top and bottom edges)
701696
if (std::abs (dy) > 1e-6f)
702697
{
703698
float t_top = (bounds.getY() - p1.getY()) / dy;
704699
float t_bottom = (bounds.getBottom() - p1.getY()) / dy;
705-
700+
706701
float t_min_y = jmin (t_top, t_bottom);
707702
float t_max_y = jmax (t_top, t_bottom);
708-
703+
709704
t_min = jmax (t_min, t_min_y);
710705
t_max = jmin (t_max, t_max_y);
711706
}
@@ -715,10 +710,10 @@ std::optional<Point<float>> CartesianPlane::findBoundsIntersection (const Point<
715710
if (p1.getY() < bounds.getY() || p1.getY() > bounds.getBottom())
716711
return std::nullopt;
717712
}
718-
713+
719714
if (t_min <= t_max && t_min >= 0.0f && t_min <= 1.0f)
720715
return Point<float> (p1.getX() + t_min * dx, p1.getY() + t_min * dy);
721-
716+
722717
return std::nullopt;
723718
}
724719

modules/yup_audio_gui/displays/yup_CartesianPlane.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ class YUP_API CartesianPlane : public Component
5656
bool visible { true };
5757

5858
PlotSignal() = default;
59+
5960
PlotSignal (const String& signalName, const Color& signalColor = Colors::white, float width = 2.0f)
60-
: name (signalName), color (signalColor), strokeWidth (width) {}
61+
: name (signalName)
62+
, color (signalColor)
63+
, strokeWidth (width)
64+
{
65+
}
6166
};
6267

6368
//==============================================================================
@@ -70,8 +75,14 @@ class YUP_API CartesianPlane : public Component
7075
bool emphasize { false };
7176

7277
GridLine() = default;
78+
7379
GridLine (double val, const Color& col = Color (0xFF333333), float width = 1.0f, bool emp = false)
74-
: value (val), color (col), strokeWidth (width), emphasize (emp) {}
80+
: value (val)
81+
, color (col)
82+
, strokeWidth (width)
83+
, emphasize (emp)
84+
{
85+
}
7586
};
7687

7788
//==============================================================================
@@ -84,8 +95,14 @@ class YUP_API CartesianPlane : public Component
8495
float fontSize { 10.0f };
8596

8697
AxisLabel() = default;
98+
8799
AxisLabel (double val, const String& labelText, const Color& col = Colors::white, float size = 10.0f)
88-
: value (val), text (labelText), color (col), fontSize (size) {}
100+
: value (val)
101+
, text (labelText)
102+
, color (col)
103+
, fontSize (size)
104+
{
105+
}
89106
};
90107

91108
//==============================================================================

0 commit comments

Comments
 (0)