Skip to content

Commit

Permalink
gui overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
ArdenButterfield committed Sep 27, 2023
1 parent 4e7128c commit 81f3b49
Show file tree
Hide file tree
Showing 23 changed files with 469 additions and 385 deletions.
57 changes: 30 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,45 +99,31 @@ set(SourceFiles
Source/lib/blade/bladeenc/codec.c
Source/lib/blade/bladeenc/l3bitstream.c
Source/lib/blade/bladeenc/encoder.h
Source/GUIelements/ReassignmentSection.cpp
Source/GUIelements/guiUtil.h
Source/GUIelements/ReassignmentSection.cpp
Source/GUIelements/MainArea.cpp
Source/GUIelements/PostSection.h
Source/GUIelements/StageWindow.cpp
Source/GUIelements/PsychoacousticSection.h
Source/GUIelements/EncoderBitrateSection.h
Source/GUIelements/StageWindow.h
Source/GUIelements/LineGraph.h
Source/GUIelements/PsychoanalGraph.cpp
Source/GUIelements/PostSection.cpp
Source/GUIelements/MiscellaneaSection.cpp
Source/GUIelements/MDCTGraphSection.cpp
Source/GUIelements/DragBox.cpp
Source/GUIelements/MiscellaneaSection.h
Source/GUIelements/MiscellaneaSection.cpp
Source/GUIelements/MDCTGraphSection.cpp
Source/GUIelements/MiscellaneaSection.h
Source/GUIelements/MainArea.h
Source/GUIelements/IndicatorLight.cpp
Source/GUIelements/ReassignmentSection.h
Source/GUIelements/ReassignmentSection.h
Source/GUIelements/IndicatorLight.h
Source/GUIelements/PsychoanalGraph.h
Source/GUIelements/MDCTGraphSection.h
Source/GUIelements/MDCTGraphSection.h
Source/GUIelements/DragBox.h
Source/GUIelements/PsychoacousticSection.cpp
Source/MP3ControllerManager.cpp
Source/BladeController.h
Source/MP3ControllerManager.h
Source/PluginProcessor.cpp
Source/MP3Controller.cpp
Source/QueueBuffer.h
Source/RootMeanSquare.cpp
Source/PluginEditor.h
Source/RootMeanSquare.h
Source/AutoGain.cpp
Source/PluginEditor.cpp
Source/LameController.h
Source/AutoGain.h
Source/LameController.cpp
Source/PluginProcessor.h
Source/BladeController.cpp
Source/MP3Controller.h
Source/GUIelements/DragBox.cpp
Source/GUIelements/SquishFlipDragBox.cpp
Source/GUIelements/SquishFlipDragBox.h
Source/GUIelements/ButterflyDragBox.cpp
Source/GUIelements/ButterflyDragBox.h
Source/GUIelements/EncoderBitrateSection.cpp
Source/GUIelements/TiltGraph.cpp
Source/GUIelements/TiltGraph.h
Source/GUIelements/TitlePanel.h
Expand All @@ -155,6 +141,23 @@ set(SourceFiles
Source/GUIelements/ArrayAssignerButtons/ArrayAssignerButton.cpp
Source/GUIelements/ArrayAssignerButtons/ArrayAssignerButton.h
Source/GUIelements/MaimColours.h
Source/MP3ControllerManager.cpp
Source/BladeController.h
Source/MP3ControllerManager.h
Source/PluginProcessor.cpp
Source/MP3Controller.cpp
Source/QueueBuffer.h
Source/RootMeanSquare.cpp
Source/PluginEditor.h
Source/RootMeanSquare.h
Source/AutoGain.cpp
Source/PluginEditor.cpp
Source/LameController.h
Source/AutoGain.h
Source/LameController.cpp
Source/PluginProcessor.h
Source/BladeController.cpp
Source/MP3Controller.h
)
target_include_directories("${PROJECT_NAME}"
PRIVATE
Expand Down
108 changes: 108 additions & 0 deletions Source/GUIelements/ButterflyDragBox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//
// Created by arden on 9/26/23.
//

#include "ButterflyDragBox.h"
#include "MaimLookAndFeel.h"


void ButterflyDragBox::calculateGridLines(const float minVal,
const float maxVal,
const float step,
const float outMin,
const float outMax,
std::vector<int>* v)
{
v->clear();
auto minGridlineIndex = ceil(minVal / step);
for (auto i = minGridlineIndex; i * step < maxVal; ++i) {
v->push_back(rescaleRange(i, minVal, maxVal, outMin, outMax));
}
}

void ButterflyDragBox::drawGridlines(juce::Graphics& g)
{
g.setColour(MaimColours::BEVEL_DARK);
for (const auto x: verticalGridlines) {
g.drawVerticalLine(x, box.getY(), box.getBottom());
}
for (const auto y: horizontalGridlines) {
g.drawHorizontalLine(y, box.getX(), box.getRight());
}
}

void ButterflyDragBox::drawGradients(juce::Graphics& g)
{
const auto numGradients = 10;
const auto gradientStep = (box.getRight() - activeZone.getX()) / numGradients;

const juce::Colour verticalColour = MaimColours::SPLASH_COLOR_DARK.withAlpha(0.2f);
const juce::Colour horizontalColour = MaimColours::CONTRAST_COLOR_DARK.withAlpha(0.2f);

for (auto i = 0; i < numGradients; ++i) {
auto barWidth = gradientStep * i * 0.7 / (numGradients);
g.setColour(horizontalColour);
g.fillRect(box.getX(), activeZone.getY() + i * gradientStep, box.getWidth(), barWidth);
g.setColour(verticalColour);
g.fillRect(activeZone.getX() + i * gradientStep, box.getY(), barWidth, box.getHeight());
}

}

juce::Colour ButterflyDragBox::overlayFilm(const juce::Colour light, const juce::Colour film) {
auto r = film.getFloatRed();
auto g = film.getFloatGreen();
auto b = film.getFloatBlue();
auto a = film.getFloatAlpha();
auto lr = light.getFloatRed();
auto lg = light.getFloatGreen();
auto lb = light.getFloatBlue();

return juce::Colour::fromFloatRGBA(
lr * r * a + lr * (1.f - a),
lg * g * a + lg * (1.f - a),
lb * b * a + lb * (1.f - a),
light.getFloatAlpha()
);
}

void ButterflyDragBox::drawBackground(juce::Graphics& g, int x, int y)
{
drawGradients(g);
drawGridlines(g);
}

juce::Colour ButterflyDragBox::getThumbFillColour(int x, int y)
{
auto fillColour = MaimColours::BEVEL_LIGHT;
float amountX = (xSlider->getValue() - xSlider->getMinimum()) / (xSlider->getMaximum() - xSlider->getMinimum());
float amountY = (ySlider->getValue() - ySlider->getMinimum()) / (ySlider->getMaximum() - ySlider->getMinimum());
fillColour = overlayFilm(fillColour, MaimColours::SPLASH_COLOR_DARK.withAlpha(amountX));
fillColour = overlayFilm(fillColour, MaimColours::CONTRAST_COLOR_DARK.withAlpha(amountY));
return fillColour;
}

juce::Colour ButterflyDragBox::getOutlineColour (int x, int y)
{
return MaimColours::BEVEL_BLACK;
}

juce::Colour ButterflyDragBox::getBackgroundColour (int x, int y)
{
return MaimColours::BEVEL_LIGHT;
}
void ButterflyDragBox::calculationsOnResize()
{
calculateGridLines(xSlider->getMinimum(),
xSlider->getMaximum(),
gridStep,
activeZone.getX(),
activeZone.getRight(),
&verticalGridlines);
calculateGridLines(ySlider->getMinimum(),
ySlider->getMaximum(),
gridStep,
activeZone.getY(),
activeZone.getBottom(),
&horizontalGridlines);
}
38 changes: 38 additions & 0 deletions Source/GUIelements/ButterflyDragBox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Created by arden on 9/26/23.
//

#ifndef MAIM_BUTTERFLYDRAGBOX_H
#define MAIM_BUTTERFLYDRAGBOX_H

#include "DragBox.h"

class ButterflyDragBox : public DragBox
{
public:
ButterflyDragBox(juce::AudioProcessorValueTreeState& p,
const juce::String& xParamID,
const juce::String& yParamID) : DragBox(p, xParamID, yParamID) {}
private:
void drawBackground(juce::Graphics& g, int x, int y) override;
juce::Colour getThumbFillColour(int x, int y) override;
juce::Colour getOutlineColour(int x, int y) override;
juce::Colour getBackgroundColour(int x, int y) override;
void calculationsOnResize() override;

const float gridStep = 2.0f;
std::vector<int> horizontalGridlines;
std::vector<int> verticalGridlines;
void calculateGridLines(const float minVal,
const float maxVal,
const float step,
const float outMin,
const float outMax,
std::vector<int>* v);
static juce::Colour overlayFilm(const juce::Colour light, const juce::Colour film);

void drawGradients(juce::Graphics& g);
void drawGridlines(juce::Graphics&);
};

#endif //MAIM_BUTTERFLYDRAGBOX_H
106 changes: 15 additions & 91 deletions Source/GUIelements/DragBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@
#include "DragBox.h"
#include "MaimLookAndFeel.h"

float rescaleRange(const float v,
const float oldMin,
const float oldMax,
const float newMin,
const float newMax)
{
float v2 = juce::jmax(juce::jmin(v, oldMax), oldMin);
return (v2 - oldMin) / (oldMax - oldMin) * (newMax - newMin) + newMin;
}

//==============================================================================
DragBox::DragBox(juce::AudioProcessorValueTreeState& p,
const juce::String& xID,
Expand All @@ -46,65 +36,16 @@ DragBox::~DragBox()
parameters.removeParameterListener(yParamID, this);
}

void DragBox::calculateGridLines(const float minVal,
const float maxVal,
const float step,
const float outMin,
const float outMax,
std::vector<int>* v)
{
v->clear();
auto minGridlineIndex = ceil(minVal / step);
for (auto i = minGridlineIndex; i * step < maxVal; ++i) {
v->push_back(rescaleRange(i, minVal, maxVal, outMin, outMax));
}
}

void DragBox::drawGridlines(juce::Graphics& g)
float DragBox::rescaleRange(const float v,
const float oldMin,
const float oldMax,
const float newMin,
const float newMax)
{
g.setColour(MaimColours::BEVEL_DARK);
for (const auto x: verticalGridlines) {
g.drawVerticalLine(x, box.getY(), box.getBottom());
}
for (const auto y: horizontalGridlines) {
g.drawHorizontalLine(y, box.getX(), box.getRight());
}
}

void DragBox::drawGradients(juce::Graphics& g)
{
const auto numGradients = 10;
const auto gradientStep = (box.getRight() - activeZone.getX()) / numGradients;

const juce::Colour verticalColour = MaimColours::SPLASH_COLOR_DARK.withAlpha(0.2f);
const juce::Colour horizontalColour = MaimColours::CONTRAST_COLOR_DARK.withAlpha(0.2f);

for (auto i = 0; i < numGradients; ++i) {
auto barWidth = gradientStep * i * 0.7 / (numGradients);
g.setColour(horizontalColour);
g.fillRect(box.getX(), activeZone.getY() + i * gradientStep, box.getWidth(), barWidth);
g.setColour(verticalColour);
g.fillRect(activeZone.getX() + i * gradientStep, box.getY(), barWidth, box.getHeight());
}

float v2 = juce::jmax(juce::jmin(v, oldMax), oldMin);
return (v2 - oldMin) / (oldMax - oldMin) * (newMax - newMin) + newMin;
}

juce::Colour DragBox::overlayFilm(const juce::Colour light, const juce::Colour film) {
auto r = film.getFloatRed();
auto g = film.getFloatGreen();
auto b = film.getFloatBlue();
auto a = film.getFloatAlpha();
auto lr = light.getFloatRed();
auto lg = light.getFloatGreen();
auto lb = light.getFloatBlue();

return juce::Colour::fromFloatRGBA(
lr * r * a + lr * (1.f - a),
lg * g * a + lg * (1.f - a),
lb * b * a + lb * (1.f - a),
light.getFloatAlpha()
);
}

void DragBox::paint (juce::Graphics& g)
{
Expand All @@ -120,30 +61,24 @@ void DragBox::paint (juce::Graphics& g)
activeZone.getBottom());
thumb.setXY(x, y);

g.setColour(MaimColours::BEVEL_LIGHT);
g.setColour(getBackgroundColour(x, y));
g.fillRoundedRectangle(box.getX(), box.getY(), box.getWidth(), box.getHeight(), (float)thumbDrawRadius); // clear the background

drawGradients(g);
drawGridlines(g);

g.setColour (MaimColours::BEVEL_BLACK);
drawBackground(g, x, y);

g.setColour (getOutlineColour(x, y));
g.drawRoundedRectangle(box.getX(), box.getY(), box.getWidth(), box.getHeight(), (float)thumbDrawRadius, 3.f);

if (thumbHovered) {
auto fillColour = MaimColours::BEVEL_LIGHT;
float amountX = (xSlider->getValue() - xSlider->getMinimum()) / (xSlider->getMaximum() - xSlider->getMinimum());
float amountY = (ySlider->getValue() - ySlider->getMinimum()) / (ySlider->getMaximum() - ySlider->getMinimum());
fillColour = overlayFilm(fillColour, MaimColours::SPLASH_COLOR_DARK.withAlpha(amountX));
fillColour = overlayFilm(fillColour, MaimColours::CONTRAST_COLOR_DARK.withAlpha(amountY));
g.setColour (fillColour);
g.setColour (getThumbFillColour(x, y));
g.fillEllipse(x - thumbDrawRadius,
y - thumbDrawRadius,
thumbDrawRadius * 2,
thumbDrawRadius * 2);

}

g.setColour (MaimColours::BEVEL_BLACK);
g.setColour (getOutlineColour(x, y));
g.drawEllipse(x - thumbDrawRadius,
y - thumbDrawRadius,
thumbDrawRadius * 2,
Expand All @@ -164,19 +99,8 @@ void DragBox::resized()
box = getLocalBounds().withSizeKeepingCentre(side - 10, side - 10);
activeZone = box.withSizeKeepingCentre(box.getWidth() - thumbDrawRadius * 2,
box.getHeight() - thumbDrawRadius * 2);

calculateGridLines(xSlider->getMinimum(),
xSlider->getMaximum(),
gridStep,
activeZone.getX(),
activeZone.getRight(),
&verticalGridlines);
calculateGridLines(ySlider->getMinimum(),
ySlider->getMaximum(),
gridStep,
activeZone.getY(),
activeZone.getBottom(),
&horizontalGridlines);

calculationsOnResize();
}

void DragBox::mouseMove(const juce::MouseEvent& event)
Expand Down
Loading

0 comments on commit 81f3b49

Please sign in to comment.