Skip to content

Commit

Permalink
improved graphics handling, changed badge button to image button
Browse files Browse the repository at this point in the history
  • Loading branch information
astriiddev committed Jan 17, 2024
1 parent 488e8d5 commit 077e9ba
Show file tree
Hide file tree
Showing 12 changed files with 101,148 additions and 101,022 deletions.
8 changes: 4 additions & 4 deletions BitDos.jucer
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<JUCERPROJECT id="vEorUV" name="BitDOS" projectType="audioplug" useAppConfig="0"
addUsingNamespaceToJuceHeader="0" displaySplashScreen="1" jucerFormatVersion="1"
pluginFormats="buildVST3" pluginVST3Category="Distortion,Fx"
pluginManufacturer="_astriid_" cppLanguageStandard="latest" pluginDesc="Bit-inversion Distortion">
pluginManufacturer="_astriid_" cppLanguageStandard="17" pluginDesc="Bit-inversion Distortion">
<MAINGROUP id="CesUeg" name="BitDOS">
<GROUP id="{41D9674B-C42C-D48E-066B-AD74628F42AB}" name="res">
<FILE id="ARrwfh" name="bitdos_gui.png" compile="0" resource="1" file="res/bitdos_gui.png"/>
<FILE id="Qc8gAE" name="bitdos_badge.png" compile="0" resource="1"
file="res/bitdos_badge.png"/>
<FILE id="RoJhNN" name="bitdos_gui.png" compile="0" resource="1" file="res/bitdos_gui.png"/>
<FILE id="rqjtw7" name="bitdos_on.png" compile="0" resource="1" file="res/bitdos_on.png"/>
<FILE id="jpXOk3" name="floppy_btn.png" compile="0" resource="1" file="res/floppy_btn.png"/>
<FILE id="Wmc9YY" name="seg_7.otf" compile="0" resource="1" file="res/seg_7.otf"/>
Expand All @@ -17,8 +19,6 @@
<FILE id="BQVc9x" name="NumberScreen.cpp" compile="1" resource="0"
file="Source/NumberScreen.cpp"/>
<FILE id="Htc3c8" name="NumberScreen.h" compile="0" resource="0" file="Source/NumberScreen.h"/>
<FILE id="W7NZAR" name="LookAndFeel.cpp" compile="1" resource="0" file="Source/LookAndFeel.cpp"/>
<FILE id="WMy0kg" name="LookAndFeel.h" compile="0" resource="0" file="Source/LookAndFeel.h"/>
<FILE id="h66Zmz" name="PluginProcessor.cpp" compile="1" resource="0"
file="Source/PluginProcessor.cpp"/>
<FILE id="amejnI" name="PluginProcessor.h" compile="0" resource="0"
Expand Down
201,902 changes: 101,061 additions & 100,841 deletions JuceLibraryCode/BinaryData.cpp

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions JuceLibraryCode/BinaryData.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@

namespace BinaryData
{
extern const char* bitdos_badge_png;
const int bitdos_badge_pngSize = 23226;

extern const char* bitdos_gui_png;
const int bitdos_gui_pngSize = 8366308;
const int bitdos_gui_pngSize = 8358640;

extern const char* bitdos_on_png;
const int bitdos_on_pngSize = 479348;
Expand All @@ -21,7 +24,7 @@ namespace BinaryData
const int seg_7_otfSize = 10464;

// Number of elements in the namedResourceList and originalFileNames arrays.
const int namedResourceListSize = 4;
const int namedResourceListSize = 5;

// Points to the start of a list of resource names.
extern const char* namedResourceList[];
Expand Down
12 changes: 6 additions & 6 deletions JuceLibraryCode/BinaryData2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace BinaryData
{

//================== bitdos_on.png ==================
static const unsigned char temp_binary_data_1[] =
static const unsigned char temp_binary_data_2[] =
{ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,38,0,0,1,32,16,6,0,0,0,73,13,2,132,0,0,1,129,105,67,67,80,115,82,71,66,32,73,69,67,54,49,57,54,54,45,50,46,49,0,0,40,145,117,145,187,75,3,65,16,135,191,36,138,175,136,130,34,10,22,65,162,85,34,26,33,
104,99,145,224,11,212,34,137,96,212,38,57,243,16,242,56,238,18,36,216,10,182,130,130,104,227,171,208,191,64,91,193,90,16,20,69,16,91,173,21,109,52,156,115,38,16,17,179,203,238,124,251,219,153,97,118,22,172,161,148,146,214,107,6,32,157,201,105,129,9,159,
99,62,188,224,168,123,166,129,46,58,100,186,35,138,174,206,4,199,67,84,29,31,119,88,76,123,227,54,115,85,247,251,119,52,45,199,116,5,44,245,194,163,138,170,229,132,39,133,167,87,115,170,201,219,194,237,74,50,178,44,124,42,236,210,164,64,225,91,83,143,
Expand Down Expand Up @@ -6807,10 +6807,10 @@ static const unsigned char temp_binary_data_1[] =
151,101,22,112,169,156,110,238,129,172,44,251,119,58,21,194,119,126,86,184,9,56,75,222,144,231,192,245,119,99,221,13,144,157,147,126,151,254,14,246,66,215,217,173,0,182,233,52,30,0,63,88,95,8,91,192,236,207,249,146,128,172,150,35,164,59,84,29,180,167,
198,206,209,255,57,251,222,107,175,189,246,218,235,63,148,153,37,219,220,129,123,31,195,189,246,218,235,127,221,255,1,161,40,20,105,86,62,5,175,0,0,0,0,73,69,78,68,174,66,96,130,0,0 };

const char* bitdos_on_png = (const char*) temp_binary_data_1;
const char* bitdos_on_png = (const char*) temp_binary_data_2;

//================== floppy_btn.png ==================
static const unsigned char temp_binary_data_2[] =
static const unsigned char temp_binary_data_3[] =
{ 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,130,0,0,0,47,16,6,0,0,0,127,17,206,142,0,0,1,129,105,67,67,80,115,82,71,66,32,73,69,67,54,49,57,54,54,45,50,46,49,0,0,40,145,117,145,187,75,3,65,16,135,191,36,138,175,136,130,34,10,22,65,162,85,34,26,
33,104,99,145,224,11,212,34,137,96,212,38,57,243,16,242,56,238,18,36,216,10,182,130,130,104,227,171,208,191,64,91,193,90,16,20,69,16,91,173,21,109,52,156,115,38,16,17,179,203,238,124,251,219,153,97,118,22,172,161,148,146,214,107,6,32,157,201,105,129,
9,159,99,62,188,224,168,123,166,129,46,58,100,186,35,138,174,206,4,199,67,84,29,31,119,88,76,123,227,54,115,85,247,251,119,52,45,199,116,5,44,245,194,163,138,170,229,132,39,133,167,87,115,170,201,219,194,237,74,50,178,44,124,42,236,210,164,64,225,91,
Expand Down Expand Up @@ -7249,10 +7249,10 @@ static const unsigned char temp_binary_data_2[] =
110,115,193,22,104,19,5,65,43,85,140,24,232,53,178,49,11,244,147,170,115,20,172,28,251,245,35,112,132,62,252,12,26,161,135,69,138,243,40,158,39,33,188,202,13,46,222,190,29,139,168,232,127,109,221,122,57,118,231,241,251,249,14,29,250,183,254,255,7,65,
189,183,90,151,250,181,135,0,0,0,0,73,69,78,68,174,66,96,130,0,0 };

const char* floppy_btn_png = (const char*) temp_binary_data_2;
const char* floppy_btn_png = (const char*) temp_binary_data_3;

//================== seg_7.otf ==================
static const unsigned char temp_binary_data_3[] =
static const unsigned char temp_binary_data_4[] =
{ 79,84,84,79,0,14,0,128,0,3,0,96,66,65,83,69,0,9,0,4,0,0,38,172,0,0,0,14,67,70,70,32,185,155,211,18,0,0,7,236,0,0,29,186,70,70,84,77,107,165,240,68,0,0,38,188,0,0,0,28,71,68,69,70,2,177,2,162,0,0,37,168,0,0,0,74,71,80,79,83,174,239,189,212,0,0,38,44,0,
0,0,126,71,83,85,66,68,216,76,230,0,0,37,244,0,0,0,56,79,83,47,50,88,212,98,44,0,0,1,80,0,0,0,96,99,109,97,112,49,87,53,44,0,0,5,132,0,0,2,70,104,101,97,100,2,99,64,79,0,0,0,236,0,0,0,54,104,104,101,97,7,83,0,95,0,0,1,36,0,0,0,36,104,109,116,120,22,210,
14,104,0,0,38,216,0,0,2,6,109,97,120,112,1,1,80,0,0,0,1,72,0,0,0,6,110,97,109,101,138,14,199,93,0,0,1,176,0,0,3,210,112,111,115,116,0,0,0,1,0,0,7,204,0,0,0,32,0,1,0,0,0,1,0,0,229,86,151,84,95,15,60,245,0,11,3,232,0,0,0,0,207,184,126,137,0,0,0,0,207,184,
Expand Down Expand Up @@ -7386,5 +7386,5 @@ static const unsigned char temp_binary_data_3[] =
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,47,0,47,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,47,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0 };

const char* seg_7_otf = (const char*) temp_binary_data_3;
const char* seg_7_otf = (const char*) temp_binary_data_4;
}
116 changes: 54 additions & 62 deletions Source/Background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,20 @@ Background::Background(BitDosAudioProcessor& p) : audioProcessor(p)
{
addAndMakeVisible(bgImg);

addAndMakeVisible(onBtn);
addAndMakeVisible(fpBtn);
addAndMakeVisible(badge);

onBtn.setClickingTogglesState(true);

auto bg = juce::ImageCache::getFromMemory(BinaryData::bitdos_gui_png,
BinaryData::bitdos_gui_pngSize);
setRepaintsOnMouseActivity(false);
const juce::Image bg = juce::ImageCache::getFromMemory(BinaryData::bitdos_gui_png,
BinaryData::bitdos_gui_pngSize);
if (!bg.isNull())
bgImg.setImage(bg, juce::RectanglePlacement::stretchToFit);
else
jassert(!bg.isNull());

auto on = juce::ImageCache::getFromMemory(BinaryData::bitdos_on_png,
BinaryData::bitdos_on_pngSize);
if (!on.isNull())
onBtn.setImages(true, true, true,
on, 1.0, juce::Colour(0),
on, 1.0, juce::Colour(0),
on, 0.0, juce::Colour(0),
0.0f);
else
jassert(!on.isNull());

auto fp = juce::ImageCache::getFromMemory(BinaryData::floppy_btn_png,
BinaryData::floppy_btn_pngSize);
if (!fp.isNull())
fpBtn.setImages(true, true, true,
fp, 0.0, juce::Colour(0),
fp, 0.0, juce::Colour(0),
fp, 1.0, juce::Colour(0),
0.0f);
else
jassert(!fp.isNull());

onBtn.addListener(this);
fpBtn.addListener(this);
badge.addListener(this);

onBtn.setMouseCursor(juce::MouseCursor::PointingHandCursor);
fpBtn.setMouseCursor(juce::MouseCursor::PointingHandCursor);
badge.setMouseCursor(juce::MouseCursor::PointingHandCursor);
initImgButton(&bdgBtn,1.0f, 1.0f, BinaryData::bitdos_badge_png, BinaryData::bitdos_badge_pngSize);
initImgButton(&fpBtn, 0.0f, 1.0f, BinaryData::floppy_btn_png, BinaryData::floppy_btn_pngSize);
initImgButton(&onBtn, 1.0f, 0.0f, BinaryData::bitdos_on_png, BinaryData::bitdos_on_pngSize);

bgImg.setBufferedToImage(true);
onBtn.setBufferedToImage(true);
fpBtn.setBufferedToImage(true);

badge.setAlpha(0.0f);
}

Background::~Background()
Expand All @@ -72,26 +38,27 @@ Background::~Background()

void Background::paintOverChildren(juce::Graphics& g)
{
if (!audioProcessor.getBypassState())
if (audioProcessor.getBypassState())
{
if (audioProcessor.inSignedMode())
g.setColour(juce::Colour(0x80DD0000));
else
g.setColour(juce::Colour(0x5000DD00));

if (fpBtn.getState() != juce::Button::buttonDown)
g.fillRect(onLED);
onBtn.setToggleState(true, juce::NotificationType::dontSendNotification);
return;
}

if (audioProcessor.inSignedMode())
g.setColour(juce::Colour(0x80DD0000));
else
onBtn.setToggleState(true, juce::NotificationType::dontSendNotification);
g.setColour(juce::Colour(0x5000DD00));

if (fpBtn.getState() != juce::Button::buttonDown)
g.fillRect(onLED);
}

void Background::resized()
{
bgImg.setBounds(0, 0, 720, 526);
onBtn.setBounds(485, 278, 147, 144);
fpBtn.setBounds(350, 87, 65, 23);
badge.setBounds(540, 65, 110, 110);
bdgBtn.setBounds(550, 70, 100, 100);
}

void Background::buttonClicked(juce::Button* button)
Expand All @@ -102,21 +69,46 @@ void Background::buttonClicked(juce::Button* button)
repaint();
}

if(!audioProcessor.getBypassState())
if (audioProcessor.getBypassState()) return;

if (button == &fpBtn)
{
audioProcessor.setSignedMode();
repaint(onLED);
}

if (button == &bdgBtn)
{
if (button == &fpBtn)
audioProcessor.setSignedMode();

if (button == &badge)
{
audioProcessor.setBitMode();
repaint(100, 375, 400, 100);
}
audioProcessor.setBitMode();
repaint(100, 375, 400, 100);
}
}

void Background::buttonStateChanged(juce::Button* button)
void Background::initImgButton(juce::ImageButton* b, const float up, const float down, const void* imgData, const int dataSize)
{
if(button == &fpBtn)
repaint(onLED);
juce::Image img;

if (b == nullptr) return;
if (imgData == nullptr) return;

img = juce::ImageCache::getFromMemory(imgData, dataSize);

if (img.isNull())
{
jassert(!img.isNull());
return;
}

addAndMakeVisible(*b);

b->addListener(this);
b->setRepaintsOnMouseActivity(false);
b->setMouseCursor(juce::MouseCursor::PointingHandCursor);

b->setImages(true, true, true,
img, up, juce::Colours::transparentWhite,
img, up, juce::Colours::transparentWhite,
img, down, juce::Colours::transparentWhite);

b->setBufferedToImage(true);
}
8 changes: 3 additions & 5 deletions Source/Background.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ class Background : public juce::Component,

private:
void buttonClicked(juce::Button* button) override;
void buttonStateChanged(juce::Button* button) override;
void mouseMove(const juce::MouseEvent&) override {}

juce::ImageComponent bgImg;
void initImgButton(juce::ImageButton*, const float up, const float down, const void* imgData, const int dataSize);

juce::ImageButton onBtn;
juce::ImageButton fpBtn;
juce::ImageComponent bgImg;

juce::TextButton badge;
juce::ImageButton onBtn, fpBtn, bdgBtn;

const juce::Rectangle<int> onLED{ 122, 94, 23, 10 };

Expand Down
34 changes: 0 additions & 34 deletions Source/LookAndFeel.cpp

This file was deleted.

34 changes: 0 additions & 34 deletions Source/LookAndFeel.h

This file was deleted.

Loading

0 comments on commit 077e9ba

Please sign in to comment.