Skip to content

Commit 077e9ba

Browse files
author
astriiddev
committed
improved graphics handling, changed badge button to image button
1 parent 488e8d5 commit 077e9ba

File tree

12 files changed

+101148
-101022
lines changed

12 files changed

+101148
-101022
lines changed

BitDos.jucer

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
<JUCERPROJECT id="vEorUV" name="BitDOS" projectType="audioplug" useAppConfig="0"
44
addUsingNamespaceToJuceHeader="0" displaySplashScreen="1" jucerFormatVersion="1"
55
pluginFormats="buildVST3" pluginVST3Category="Distortion,Fx"
6-
pluginManufacturer="_astriid_" cppLanguageStandard="latest" pluginDesc="Bit-inversion Distortion">
6+
pluginManufacturer="_astriid_" cppLanguageStandard="17" pluginDesc="Bit-inversion Distortion">
77
<MAINGROUP id="CesUeg" name="BitDOS">
88
<GROUP id="{41D9674B-C42C-D48E-066B-AD74628F42AB}" name="res">
9-
<FILE id="ARrwfh" name="bitdos_gui.png" compile="0" resource="1" file="res/bitdos_gui.png"/>
9+
<FILE id="Qc8gAE" name="bitdos_badge.png" compile="0" resource="1"
10+
file="res/bitdos_badge.png"/>
11+
<FILE id="RoJhNN" name="bitdos_gui.png" compile="0" resource="1" file="res/bitdos_gui.png"/>
1012
<FILE id="rqjtw7" name="bitdos_on.png" compile="0" resource="1" file="res/bitdos_on.png"/>
1113
<FILE id="jpXOk3" name="floppy_btn.png" compile="0" resource="1" file="res/floppy_btn.png"/>
1214
<FILE id="Wmc9YY" name="seg_7.otf" compile="0" resource="1" file="res/seg_7.otf"/>
@@ -17,8 +19,6 @@
1719
<FILE id="BQVc9x" name="NumberScreen.cpp" compile="1" resource="0"
1820
file="Source/NumberScreen.cpp"/>
1921
<FILE id="Htc3c8" name="NumberScreen.h" compile="0" resource="0" file="Source/NumberScreen.h"/>
20-
<FILE id="W7NZAR" name="LookAndFeel.cpp" compile="1" resource="0" file="Source/LookAndFeel.cpp"/>
21-
<FILE id="WMy0kg" name="LookAndFeel.h" compile="0" resource="0" file="Source/LookAndFeel.h"/>
2222
<FILE id="h66Zmz" name="PluginProcessor.cpp" compile="1" resource="0"
2323
file="Source/PluginProcessor.cpp"/>
2424
<FILE id="amejnI" name="PluginProcessor.h" compile="0" resource="0"

JuceLibraryCode/BinaryData.cpp

Lines changed: 101061 additions & 100841 deletions
Large diffs are not rendered by default.

JuceLibraryCode/BinaryData.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
namespace BinaryData
1010
{
11+
extern const char* bitdos_badge_png;
12+
const int bitdos_badge_pngSize = 23226;
13+
1114
extern const char* bitdos_gui_png;
12-
const int bitdos_gui_pngSize = 8366308;
15+
const int bitdos_gui_pngSize = 8358640;
1316

1417
extern const char* bitdos_on_png;
1518
const int bitdos_on_pngSize = 479348;
@@ -21,7 +24,7 @@ namespace BinaryData
2124
const int seg_7_otfSize = 10464;
2225

2326
// Number of elements in the namedResourceList and originalFileNames arrays.
24-
const int namedResourceListSize = 4;
27+
const int namedResourceListSize = 5;
2528

2629
// Points to the start of a list of resource names.
2730
extern const char* namedResourceList[];

JuceLibraryCode/BinaryData2.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace BinaryData
1010
{
1111

1212
//================== bitdos_on.png ==================
13-
static const unsigned char temp_binary_data_1[] =
13+
static const unsigned char temp_binary_data_2[] =
1414
{ 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,
1515
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,
1616
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,
@@ -6807,10 +6807,10 @@ static const unsigned char temp_binary_data_1[] =
68076807
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,
68086808
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 };
68096809

6810-
const char* bitdos_on_png = (const char*) temp_binary_data_1;
6810+
const char* bitdos_on_png = (const char*) temp_binary_data_2;
68116811

68126812
//================== floppy_btn.png ==================
6813-
static const unsigned char temp_binary_data_2[] =
6813+
static const unsigned char temp_binary_data_3[] =
68146814
{ 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,
68156815
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,
68166816
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,
@@ -7249,10 +7249,10 @@ static const unsigned char temp_binary_data_2[] =
72497249
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,
72507250
189,183,90,151,250,181,135,0,0,0,0,73,69,78,68,174,66,96,130,0,0 };
72517251

7252-
const char* floppy_btn_png = (const char*) temp_binary_data_2;
7252+
const char* floppy_btn_png = (const char*) temp_binary_data_3;
72537253

72547254
//================== seg_7.otf ==================
7255-
static const unsigned char temp_binary_data_3[] =
7255+
static const unsigned char temp_binary_data_4[] =
72567256
{ 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,
72577257
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,
72587258
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,
@@ -7386,5 +7386,5 @@ static const unsigned char temp_binary_data_3[] =
73867386
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,
73877387
0,0,0,0 };
73887388

7389-
const char* seg_7_otf = (const char*) temp_binary_data_3;
7389+
const char* seg_7_otf = (const char*) temp_binary_data_4;
73907390
}

Source/Background.cpp

Lines changed: 54 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,20 @@ Background::Background(BitDosAudioProcessor& p) : audioProcessor(p)
1616
{
1717
addAndMakeVisible(bgImg);
1818

19-
addAndMakeVisible(onBtn);
20-
addAndMakeVisible(fpBtn);
21-
addAndMakeVisible(badge);
22-
2319
onBtn.setClickingTogglesState(true);
24-
25-
auto bg = juce::ImageCache::getFromMemory(BinaryData::bitdos_gui_png,
26-
BinaryData::bitdos_gui_pngSize);
20+
setRepaintsOnMouseActivity(false);
21+
const juce::Image bg = juce::ImageCache::getFromMemory(BinaryData::bitdos_gui_png,
22+
BinaryData::bitdos_gui_pngSize);
2723
if (!bg.isNull())
2824
bgImg.setImage(bg, juce::RectanglePlacement::stretchToFit);
2925
else
3026
jassert(!bg.isNull());
3127

32-
auto on = juce::ImageCache::getFromMemory(BinaryData::bitdos_on_png,
33-
BinaryData::bitdos_on_pngSize);
34-
if (!on.isNull())
35-
onBtn.setImages(true, true, true,
36-
on, 1.0, juce::Colour(0),
37-
on, 1.0, juce::Colour(0),
38-
on, 0.0, juce::Colour(0),
39-
0.0f);
40-
else
41-
jassert(!on.isNull());
42-
43-
auto fp = juce::ImageCache::getFromMemory(BinaryData::floppy_btn_png,
44-
BinaryData::floppy_btn_pngSize);
45-
if (!fp.isNull())
46-
fpBtn.setImages(true, true, true,
47-
fp, 0.0, juce::Colour(0),
48-
fp, 0.0, juce::Colour(0),
49-
fp, 1.0, juce::Colour(0),
50-
0.0f);
51-
else
52-
jassert(!fp.isNull());
53-
54-
onBtn.addListener(this);
55-
fpBtn.addListener(this);
56-
badge.addListener(this);
57-
58-
onBtn.setMouseCursor(juce::MouseCursor::PointingHandCursor);
59-
fpBtn.setMouseCursor(juce::MouseCursor::PointingHandCursor);
60-
badge.setMouseCursor(juce::MouseCursor::PointingHandCursor);
28+
initImgButton(&bdgBtn,1.0f, 1.0f, BinaryData::bitdos_badge_png, BinaryData::bitdos_badge_pngSize);
29+
initImgButton(&fpBtn, 0.0f, 1.0f, BinaryData::floppy_btn_png, BinaryData::floppy_btn_pngSize);
30+
initImgButton(&onBtn, 1.0f, 0.0f, BinaryData::bitdos_on_png, BinaryData::bitdos_on_pngSize);
6131

6232
bgImg.setBufferedToImage(true);
63-
onBtn.setBufferedToImage(true);
64-
fpBtn.setBufferedToImage(true);
65-
66-
badge.setAlpha(0.0f);
6733
}
6834

6935
Background::~Background()
@@ -72,26 +38,27 @@ Background::~Background()
7238

7339
void Background::paintOverChildren(juce::Graphics& g)
7440
{
75-
if (!audioProcessor.getBypassState())
41+
if (audioProcessor.getBypassState())
7642
{
77-
if (audioProcessor.inSignedMode())
78-
g.setColour(juce::Colour(0x80DD0000));
79-
else
80-
g.setColour(juce::Colour(0x5000DD00));
81-
82-
if (fpBtn.getState() != juce::Button::buttonDown)
83-
g.fillRect(onLED);
43+
onBtn.setToggleState(true, juce::NotificationType::dontSendNotification);
44+
return;
8445
}
46+
47+
if (audioProcessor.inSignedMode())
48+
g.setColour(juce::Colour(0x80DD0000));
8549
else
86-
onBtn.setToggleState(true, juce::NotificationType::dontSendNotification);
50+
g.setColour(juce::Colour(0x5000DD00));
51+
52+
if (fpBtn.getState() != juce::Button::buttonDown)
53+
g.fillRect(onLED);
8754
}
8855

8956
void Background::resized()
9057
{
9158
bgImg.setBounds(0, 0, 720, 526);
9259
onBtn.setBounds(485, 278, 147, 144);
9360
fpBtn.setBounds(350, 87, 65, 23);
94-
badge.setBounds(540, 65, 110, 110);
61+
bdgBtn.setBounds(550, 70, 100, 100);
9562
}
9663

9764
void Background::buttonClicked(juce::Button* button)
@@ -102,21 +69,46 @@ void Background::buttonClicked(juce::Button* button)
10269
repaint();
10370
}
10471

105-
if(!audioProcessor.getBypassState())
72+
if (audioProcessor.getBypassState()) return;
73+
74+
if (button == &fpBtn)
75+
{
76+
audioProcessor.setSignedMode();
77+
repaint(onLED);
78+
}
79+
80+
if (button == &bdgBtn)
10681
{
107-
if (button == &fpBtn)
108-
audioProcessor.setSignedMode();
109-
110-
if (button == &badge)
111-
{
112-
audioProcessor.setBitMode();
113-
repaint(100, 375, 400, 100);
114-
}
82+
audioProcessor.setBitMode();
83+
repaint(100, 375, 400, 100);
11584
}
11685
}
11786

118-
void Background::buttonStateChanged(juce::Button* button)
87+
void Background::initImgButton(juce::ImageButton* b, const float up, const float down, const void* imgData, const int dataSize)
11988
{
120-
if(button == &fpBtn)
121-
repaint(onLED);
89+
juce::Image img;
90+
91+
if (b == nullptr) return;
92+
if (imgData == nullptr) return;
93+
94+
img = juce::ImageCache::getFromMemory(imgData, dataSize);
95+
96+
if (img.isNull())
97+
{
98+
jassert(!img.isNull());
99+
return;
100+
}
101+
102+
addAndMakeVisible(*b);
103+
104+
b->addListener(this);
105+
b->setRepaintsOnMouseActivity(false);
106+
b->setMouseCursor(juce::MouseCursor::PointingHandCursor);
107+
108+
b->setImages(true, true, true,
109+
img, up, juce::Colours::transparentWhite,
110+
img, up, juce::Colours::transparentWhite,
111+
img, down, juce::Colours::transparentWhite);
112+
113+
b->setBufferedToImage(true);
122114
}

Source/Background.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ class Background : public juce::Component,
2929

3030
private:
3131
void buttonClicked(juce::Button* button) override;
32-
void buttonStateChanged(juce::Button* button) override;
3332
void mouseMove(const juce::MouseEvent&) override {}
3433

35-
juce::ImageComponent bgImg;
34+
void initImgButton(juce::ImageButton*, const float up, const float down, const void* imgData, const int dataSize);
3635

37-
juce::ImageButton onBtn;
38-
juce::ImageButton fpBtn;
36+
juce::ImageComponent bgImg;
3937

40-
juce::TextButton badge;
38+
juce::ImageButton onBtn, fpBtn, bdgBtn;
4139

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

Source/LookAndFeel.cpp

Lines changed: 0 additions & 34 deletions
This file was deleted.

Source/LookAndFeel.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)