mirror of
https://codeberg.org/armin/trommelkiste.git
synced 2026-09-01 04:10:46 +02:00
init
This commit is contained in:
commit
8d5ffc6b56
168 changed files with 1436 additions and 0 deletions
81
Source/PluginEditor.h
Normal file
81
Source/PluginEditor.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#pragma once
|
||||
#include "PluginProcessor.h"
|
||||
#include <juce_gui_basics/juce_gui_basics.h>
|
||||
|
||||
class TrommelkisteLookAndFeel : public juce::LookAndFeel_V4
|
||||
{
|
||||
public:
|
||||
juce::Colour bg{0xFF1A1A1A};
|
||||
juce::Colour rowAlt{0xFF222222};
|
||||
juce::Colour accent{0xFFE8600A};
|
||||
float fontScale = 1.5f;
|
||||
|
||||
void drawRotarySlider(juce::Graphics&, int x, int y, int w, int h,
|
||||
float pos, float start, float end, juce::Slider&) override;
|
||||
void drawButtonBackground(juce::Graphics&, juce::Button&, const juce::Colour&,
|
||||
bool, bool) override;
|
||||
void drawComboBox(juce::Graphics&, int w, int h, bool down,
|
||||
int bx, int by, int bw, int bh, juce::ComboBox&) override;
|
||||
void positionComboBoxText(juce::ComboBox&, juce::Label&) override;
|
||||
};
|
||||
|
||||
struct KnobSlider : juce::Slider
|
||||
{
|
||||
std::function<juce::String(double)> formatFn;
|
||||
juce::String getTextFromValue(double v) override
|
||||
{
|
||||
if (formatFn) return formatFn(v);
|
||||
return Slider::getTextFromValue(v);
|
||||
}
|
||||
};
|
||||
|
||||
class TrommelkisteEditor : public juce::AudioProcessorEditor, private juce::Timer
|
||||
{
|
||||
public:
|
||||
TrommelkisteEditor(TrommelkisteProcessor&);
|
||||
~TrommelkisteEditor() override;
|
||||
|
||||
void paint(juce::Graphics&) override;
|
||||
void resized() override;
|
||||
void mouseDown(const juce::MouseEvent&) override;
|
||||
void timerCallback() override { repaint(); }
|
||||
|
||||
private:
|
||||
TrommelkisteProcessor& proc;
|
||||
TrommelkisteLookAndFeel lnf;
|
||||
|
||||
juce::ComboBox scaleCombo;
|
||||
float uiScale = 1.5f;
|
||||
|
||||
int scaled(int v) const { return (int)(v * uiScale + 0.5f); }
|
||||
void scaleChanged();
|
||||
|
||||
struct TrackUI
|
||||
{
|
||||
using SliderAtt = juce::AudioProcessorValueTreeState::SliderAttachment;
|
||||
using ComboAtt = juce::AudioProcessorValueTreeState::ComboBoxAttachment;
|
||||
|
||||
juce::TextButton prevBtn{"<"};
|
||||
juce::TextButton nextBtn{">"};
|
||||
KnobSlider level, length, velocity, pitch, tone, pan;
|
||||
juce::ComboBox decay;
|
||||
juce::Label fileLabel;
|
||||
|
||||
std::unique_ptr<SliderAtt> levelAtt, lengthAtt, velAtt, pitchAtt, toneAtt, panAtt;
|
||||
std::unique_ptr<ComboAtt> decayAtt;
|
||||
};
|
||||
|
||||
TrackUI ui[NUM_TRACKS];
|
||||
juce::FileChooser chooser{"Load Sample", juce::File{}, "*.wav;*.aif;*.aiff;*.flac"};
|
||||
|
||||
// Preset selector
|
||||
juce::ComboBox presetCombo;
|
||||
juce::TextButton presetPrevBtn{"<"};
|
||||
juce::TextButton presetNextBtn{">"};
|
||||
|
||||
void loadForTrack(int idx);
|
||||
void updateFileLabel(int idx);
|
||||
void refreshPresetCombo();
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TrommelkisteEditor)
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue