Skip to content

Commit 764bb1a

Browse files
committed
Updated JUCE, fixed a wide array of warnings and issues on Android, upgraded the ImageDemo.
1 parent 94dc627 commit 764bb1a

File tree

11 files changed

+198
-83
lines changed

11 files changed

+198
-83
lines changed

demo/JuceLibraryCode/AppConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// [END_USER_CODE_SECTION]
2222

23-
#define JUCE_PROJUCER_VERSION 0x80007
23+
#define JUCE_PROJUCER_VERSION 0x80008
2424

2525
//==============================================================================
2626
#define JUCE_MODULE_AVAILABLE_juce_analytics 1

demo/source/core/SharedObjects.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,7 @@ void SharedObjects::restoreWindowDimensions (DocumentWindow& dw)
149149

150150
Image SharedObjects::getWindowIcon()
151151
{
152-
static Image windowIcon;
153-
154-
if (windowIcon.isNull())
155-
{
156-
windowIcon = ImageCache::getFromMemory (BinaryData::SquarePine_Logo_png, BinaryData::SquarePine_Logo_pngSize);
157-
windowIcon.setBackupEnabled (false);
158-
}
159-
160-
return windowIcon;
152+
return ImageCache::getFromMemory (BinaryData::SquarePine_Logo_png, BinaryData::SquarePine_Logo_pngSize);
161153
}
162154

163155
//==============================================================================

demo/source/demos/ImageDemo.h

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,62 @@ class ImageDemo final : public DemoBase,
1010
{
1111
imageFormatManager.registerBasicFormats();
1212

13+
SafePointer sp (this);
14+
15+
open.onClick = [this, sp]()
16+
{
17+
if (sp == nullptr)
18+
return;
19+
20+
if (fileChooser != nullptr)
21+
{
22+
return;
23+
}
24+
25+
fileChooser = std::make_unique<FileChooser> (TRANS ("Find an image to load."),
26+
File::getSpecialLocation (File::userPicturesDirectory),
27+
imageFormatManager.getWildcardForAllFormats());
28+
29+
fileChooser->launchAsync (FileBrowserComponent::openMode, [sp] (const FileChooser& chooser)
30+
{
31+
if (sp == nullptr)
32+
return;
33+
34+
sp->setImage (chooser.getURLResult());
35+
sp->fileChooser.reset();
36+
});
37+
};
38+
1339
addAndMakeVisible (imageComponent);
1440
addAndMakeVisible (open);
1541
}
1642

43+
//==============================================================================
44+
/** Changes the currently displayed with the given one.
45+
If the given image is null, the underlying image component will be cleared.
46+
*/
47+
void setImage (const Image& image)
48+
{
49+
imageComponent.setImage (image);
50+
repaint();
51+
}
52+
53+
/** Changes the currently displayed with one from the given file.
54+
If the given image fails to load, the underlying image component will be cleared.
55+
*/
56+
void setImage (const File& file)
57+
{
58+
setImage (imageFormatManager.loadFrom (file));
59+
}
60+
61+
/** Changes the currently displayed with one from the given URL.
62+
If the given image fails to load, the underlying image component will be cleared.
63+
*/
64+
void setImage (const URL& url)
65+
{
66+
setImage (imageFormatManager.loadFrom (url));
67+
}
68+
1769
//==============================================================================
1870
/** @internal */
1971
void paint (Graphics& g) override
@@ -37,7 +89,7 @@ class ImageDemo final : public DemoBase,
3789
}
3890

3991
/** @internal */
40-
bool isInterestedInTextDrag (const String& text) override { return isBase64 (text); }
92+
bool isInterestedInTextDrag (const String& text) override { return isPossiblyBase64 (text); }
4193

4294
/** @internal */
4395
bool isInterestedInFileDrag (const StringArray& files) override
@@ -58,7 +110,7 @@ class ImageDemo final : public DemoBase,
58110
const File file (path);
59111
if (file.existsAsFile() && imageFormatManager.findFormatForFile (file) != nullptr)
60112
{
61-
setImage (imageFormatManager.loadFrom (file));
113+
setImage (file);
62114
return;
63115
}
64116
}
@@ -67,7 +119,7 @@ class ImageDemo final : public DemoBase,
67119
/** @internal */
68120
void textDropped (const String& text, int, int) override
69121
{
70-
if (isBase64 (text))
122+
if (isPossiblyBase64 (text))
71123
setImage (imageFormatManager.fromBase64 (text));
72124
}
73125

@@ -82,15 +134,10 @@ class ImageDemo final : public DemoBase,
82134
ImageFormatManager imageFormatManager;
83135
HighQualityImageComponent imageComponent;
84136
TextButton open;
137+
std::unique_ptr<FileChooser> fileChooser;
85138

86139
//==============================================================================
87-
void setImage (const Image& image)
88-
{
89-
imageComponent.setImage (image);
90-
repaint();
91-
}
92-
93-
static bool isBase64 (const String& text)
140+
static bool isPossiblyBase64 (const String& text)
94141
{
95142
const String b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
96143

demo/source/main/Main.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,6 @@ class MainWindow final : public DocumentWindow
6464
customLookAndFeel (sharedObjects),
6565
mainComponent (sharedObjects)
6666
{
67-
RuntimePermissions::request (RuntimePermissions::recordAudio, [this] (bool)
68-
{
69-
audioWaiter.signal();
70-
});
71-
72-
audioWaiter.wait();
73-
74-
if (! RuntimePermissions::isGranted (RuntimePermissions::recordAudio))
75-
{
76-
closeButtonPressed();
77-
return;
78-
}
79-
8067
googleAnalyticsReporter->startSession();
8168

8269
setUsingNativeTitleBar (true);
@@ -125,7 +112,6 @@ class MainWindow final : public DocumentWindow
125112

126113
private:
127114
//==============================================================================
128-
WaitableEvent audioWaiter;
129115
SharedObjects sharedObjects;
130116
SharedResourcePointer<sp::GoogleAnalyticsReporter> googleAnalyticsReporter;
131117
DemoLookAndFeel customLookAndFeel;

demo/source/main/MainComponent.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ MainComponent::MainComponent (SharedObjects& sharedObjs)
4444
};
4545

4646
addDemo (new EaseListComponent (sharedObjs));
47-
addDemo (new EffectChainDemo (sharedObjs));
4847
addDemo (new ImageDemo (sharedObjs));
49-
addDemo (new CodeEditorDemo (sharedObjs));
50-
addDemo (new MediaDeviceListerDemo (sharedObjs));
5148
addDemo (new AnimationDemo (sharedObjs));
5249
addDemo (new ParticleSystemDemo (sharedObjs));
50+
addDemo (new EffectChainDemo (sharedObjs));
51+
addDemo (new MediaDeviceListerDemo (sharedObjs));
5352

5453
#if SQUAREPINE_USE_ICUESDK
5554
addDemo (new iCUESDKDemo (sharedObjs));
@@ -63,6 +62,7 @@ MainComponent::MainComponent (SharedObjects& sharedObjs)
6362
addDemo (new OpenGLDetailsDemo (sharedObjs, rendererConfigurator));
6463
#endif
6564

65+
addDemo (new CodeEditorDemo (sharedObjs));
6666
addDemo (new SettingsComponent (sharedObjs));
6767

6868
popupButton.onClick = [this, ptr = SafePointer (this)]()

modules/squarepine_animation/particles/ParticleSystem.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class Particle
185185
juce::Rectangle<float> bounds;
186186
juce::Point<float> velocity;
187187
Colour colour;
188-
} JUCE_PACKED;
188+
};
189189

190190
Details changeable;
191191

@@ -198,7 +198,7 @@ class Particle
198198

199199
//==============================================================================
200200
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Particle)
201-
} JUCE_PACKED;
201+
};
202202

203203
//==============================================================================
204204
class RainParticle final : public Particle
@@ -220,7 +220,7 @@ class RainParticle final : public Particle
220220

221221
private:
222222
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RainParticle)
223-
} JUCE_PACKED;
223+
};
224224

225225
//==============================================================================
226226
/**
@@ -249,7 +249,7 @@ class SnowParticle final : public Particle
249249

250250
private:
251251
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SnowParticle)
252-
} JUCE_PACKED;
252+
};
253253

254254
#if JUCE_MSVC
255255
#pragma pack (pop)

modules/squarepine_audio/codecs/REXAudioFormat.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,25 +178,26 @@ namespace REXError
178178
#pragma pack (push, 8)
179179
#endif
180180

181-
struct REXInfo
181+
struct REXInfo final
182182
{
183-
REXInfo() noexcept { zerostruct (*this); }
184-
185-
int numChannels, sampleRate, numSlices;
186-
int tempo; // Tempo set when exported from ReCycle, 123.456 BPM stored as 123456L etc.
187-
int originalTempo; // Original tempo of loop, as calculated by ReCycle from the locator positions and bars/beats/sign settings.
188-
int ppqLength, timeSignatureNumerator, timeSignatureDenominator, bitDepth;
189-
} JUCE_PACKED;
183+
int numChannels = 0,
184+
sampleRate = 0,
185+
numSlices = 0,
186+
tempo = 0, // Tempo set when exported from ReCycle, 123.456 BPM stored as 123456L etc.
187+
originalTempo = 0, // Original tempo of loop, as calculated by ReCycle from the locator positions and bars/beats/sign settings.
188+
ppqLength = 0,
189+
timeSignatureNumerator = 0,
190+
timeSignatureDenominator = 0,
191+
bitDepth = 0;
192+
};
190193

191-
struct REXSliceInfo
194+
struct REXSliceInfo final
192195
{
193-
REXSliceInfo() noexcept { zerostruct (*this); }
194-
195-
int ppqPos; // Position of slice in loop
196-
int sampleLength; // Length of rendered slice, at its original sample rate.
197-
} JUCE_PACKED;
196+
int ppqPos = 0, // Position of slice in loop
197+
sampleLength = 0; // Length of rendered slice, at its original sample rate.
198+
};
198199

199-
struct REXCreatorInfo
200+
struct REXCreatorInfo final
200201
{
201202
REXCreatorInfo() noexcept { zerostruct (*this); }
202203

@@ -207,7 +208,7 @@ struct REXCreatorInfo
207208
char url[kREXStringSize];
208209
char email[kREXStringSize];
209210
char freeText[kREXStringSize];
210-
} JUCE_PACKED;
211+
};
211212

212213
#if JUCE_MSVC
213214
#pragma pack (pop)

modules/squarepine_core/misc/Macros.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
/** This section removes stupid min/max macros to avoid clashing
2-
with STL min/max implementations.
2+
with STL min/max implementations, avoiding clashing of any kind,
3+
and clearing up the already zany global namespace.
34
45
Too many idiot coders enjoy redefining the min/max macros in their libraries...
56
And someone behind the STL implementation at MSFT decided it was a good idea
6-
to provide inane (and ugly) versions of them too! (hashtag YOLO and IHEARTRECREATINGMINMAXBRO)
7-
8-
This section of code should help avoid clashing of sorts,
9-
and clearing up the already zany global namespace.
7+
to provide inane (and ugly) versions of them too! (#YOLO #IHEARTRECREATINGMINMAXBRO)
108
11-
Give me a break - use std::min() and std::max() instead!
12-
JUCE is equally at fault here, with its std::min() and std::max() functions.
9+
And give me a break - use std::min() and std::max() instead!
10+
JUCE is equally at fault here with its jmin() and jmax() functions.
1311
*/
1412

15-
#undef NOMINMAX // Avoids additional clashing
13+
#undef NOMINMAX
1614
#define NOMINMAX 1
1715

1816
#undef min
@@ -30,9 +28,11 @@
3028

3129
//==============================================================================
3230
#if DOXYGEN || JUCE_WINDOWS || JUCE_LINUX || JUCE_MAC || JUCE_BSD || JUCE_WASM
33-
#define SQUAREPINE_IS_DESKTOP 1 // Currently running on a desktop.
31+
/** You're currently running on a desktop. */
32+
#define SQUAREPINE_IS_DESKTOP 1
3433
#elif JUCE_ANDROID || JUCE_IPHONE || JUCE_IOS
35-
#define SQUAREPINE_IS_MOBILE 1 // Currently running on a mobile device.
34+
/** You're currently running on a mobile device. */
35+
#define SQUAREPINE_IS_MOBILE 1
3636
#else
3737
#error "What kind of operating system is this? Please fix the project platform format macro!"
3838
#endif

modules/squarepine_cryptography/rng/Xorshift.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class XorshiftForwarder
134134

135135
private:
136136
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (XorshiftForwarder)
137-
} JUCE_PACKED;
137+
};
138138

139139
template<auto func, size_t numElements>
140140
class Xorshift64Base : public XorshiftForwarder
@@ -147,7 +147,7 @@ class Xorshift64Base : public XorshiftForwarder
147147

148148
private:
149149
std::array<uint64, numElements> data;
150-
} JUCE_PACKED;
150+
};
151151

152152
class Xorshift1024s final : public XorshiftForwarder
153153
{
@@ -160,7 +160,7 @@ class Xorshift1024s final : public XorshiftForwarder
160160
private:
161161
std::array<uint64, 16> data;
162162
int index = 0;
163-
} JUCE_PACKED;
163+
};
164164

165165
struct Xorshift64::Pimpl final
166166
{
@@ -183,7 +183,7 @@ struct Xorshift64::Pimpl final
183183

184184
private:
185185
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl)
186-
} JUCE_PACKED;
186+
};
187187

188188
#if JUCE_MSVC
189189
#pragma pack (pop)

0 commit comments

Comments
 (0)