Browse Source

Cleaned up some compiler warnings.

tags/2021-05-28
jules 13 years ago
parent
commit
0033491cc8
36 changed files with 327 additions and 276 deletions
  1. +12
    -11
      extras/audio plugin demo/Source/PluginProcessor.cpp
  2. +2
    -2
      modules/juce_audio_devices/native/juce_MidiDataConcatenator.h
  3. +10
    -0
      modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp
  4. +10
    -0
      modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp
  5. +5
    -5
      modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp
  6. +10
    -11
      modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm
  7. +12
    -0
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
  8. +6
    -0
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm
  9. +19
    -19
      modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp
  10. +15
    -15
      modules/juce_core/maths/juce_Expression.cpp
  11. +5
    -5
      modules/juce_core/native/juce_mac_Files.mm
  12. +2
    -2
      modules/juce_core/native/juce_posix_SharedCode.h
  13. +2
    -3
      modules/juce_core/text/juce_LocalisedStrings.cpp
  14. +3
    -3
      modules/juce_core/threads/juce_InterProcessLock.h
  15. +9
    -9
      modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp
  16. +12
    -2
      modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp
  17. +1
    -1
      modules/juce_events/native/juce_linux_Messaging.cpp
  18. +10
    -10
      modules/juce_graphics/geometry/juce_Path.cpp
  19. +11
    -0
      modules/juce_graphics/image_formats/juce_JPEGLoader.cpp
  20. +13
    -13
      modules/juce_graphics/images/juce_Image.cpp
  21. +13
    -13
      modules/juce_graphics/native/juce_RenderingHelpers.h
  22. +2
    -2
      modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm
  23. +2
    -2
      modules/juce_graphics/native/juce_mac_Fonts.mm
  24. +2
    -2
      modules/juce_gui_basics/components/juce_Component.cpp
  25. +2
    -0
      modules/juce_gui_basics/components/juce_Desktop.cpp
  26. +12
    -12
      modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp
  27. +7
    -7
      modules/juce_gui_basics/drawables/juce_DrawablePath.cpp
  28. +9
    -9
      modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp
  29. +8
    -8
      modules/juce_gui_basics/misc/juce_DropShadower.cpp
  30. +12
    -13
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm
  31. +5
    -5
      modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp
  32. +3
    -3
      modules/juce_gui_basics/widgets/juce_ComboBox.cpp
  33. +17
    -17
      modules/juce_gui_basics/widgets/juce_ListBox.cpp
  34. +15
    -23
      modules/juce_gui_basics/widgets/juce_TableListBox.cpp
  35. +39
    -39
      modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp
  36. +10
    -10
      modules/juce_gui_extra/misc/juce_ColourSelector.cpp

+ 12
- 11
extras/audio plugin demo/Source/PluginProcessor.cpp View File

@@ -11,14 +11,15 @@
#include "PluginProcessor.h" #include "PluginProcessor.h"
#include "PluginEditor.h" #include "PluginEditor.h"
AudioProcessor* JUCE_CALLTYPE createPluginFilter();
//============================================================================== //==============================================================================
/** A demo synth sound that's just a basic sine wave.. */ /** A demo synth sound that's just a basic sine wave.. */
class SineWaveSound : public SynthesiserSound class SineWaveSound : public SynthesiserSound
{ {
public: public:
SineWaveSound()
{
}
SineWaveSound() {}
bool appliesToNote (const int /*midiNoteNumber*/) { return true; } bool appliesToNote (const int /*midiNoteNumber*/) { return true; }
bool appliesToChannel (const int /*midiChannel*/) { return true; } bool appliesToChannel (const int /*midiChannel*/) { return true; }
@@ -273,7 +274,7 @@ void JuceDemoPluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, Midi
// ask the host for the current time so we can display it... // ask the host for the current time so we can display it...
AudioPlayHead::CurrentPositionInfo newTime; AudioPlayHead::CurrentPositionInfo newTime;
if (getPlayHead() != 0 && getPlayHead()->getCurrentPosition (newTime))
if (getPlayHead() != nullptr && getPlayHead()->getCurrentPosition (newTime))
{ {
// Successfully got the current time from the host.. // Successfully got the current time from the host..
lastPosInfo = newTime; lastPosInfo = newTime;
@@ -318,7 +319,7 @@ void JuceDemoPluginAudioProcessor::setStateInformation (const void* data, int si
// This getXmlFromBinary() helper function retrieves our XML from the binary blob.. // This getXmlFromBinary() helper function retrieves our XML from the binary blob..
ScopedPointer<XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes)); ScopedPointer<XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes));
if (xmlState != 0)
if (xmlState != nullptr)
{ {
// make sure that it's actually our type of XML object.. // make sure that it's actually our type of XML object..
if (xmlState->hasTagName ("MYPLUGINSETTINGS")) if (xmlState->hasTagName ("MYPLUGINSETTINGS"))
@@ -355,20 +356,20 @@ bool JuceDemoPluginAudioProcessor::isOutputChannelStereoPair (int /*index*/) con
bool JuceDemoPluginAudioProcessor::acceptsMidi() const bool JuceDemoPluginAudioProcessor::acceptsMidi() const
{ {
#if JucePlugin_WantsMidiInput
#if JucePlugin_WantsMidiInput
return true; return true;
#else
#else
return false; return false;
#endif
#endif
} }
bool JuceDemoPluginAudioProcessor::producesMidi() const bool JuceDemoPluginAudioProcessor::producesMidi() const
{ {
#if JucePlugin_ProducesMidiOutput
#if JucePlugin_ProducesMidiOutput
return true; return true;
#else
#else
return false; return false;
#endif
#endif
} }
//============================================================================== //==============================================================================


+ 2
- 2
modules/juce_audio_devices/native/juce_MidiDataConcatenator.h View File

@@ -48,10 +48,10 @@ public:
pendingDataTime = 0; pendingDataTime = 0;
} }
void pushMidiData (const void* data, int numBytes, double time,
void pushMidiData (const void* inputData, int numBytes, double time,
MidiInput* input, MidiInputCallback& callback) MidiInput* input, MidiInputCallback& callback)
{ {
const uint8* d = static_cast <const uint8*> (data);
const uint8* d = static_cast <const uint8*> (inputData);
while (numBytes > 0) while (numBytes > 0)
{ {


+ 10
- 0
modules/juce_audio_formats/codecs/juce_FlacAudioFormat.cpp View File

@@ -46,6 +46,12 @@ namespace FlacNamespace
#define SIZE_MAX 0xffffffff #define SIZE_MAX 0xffffffff
#endif #endif
#if JUCE_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wshadow"
#endif
#define __STDC_LIMIT_MACROS 1 #define __STDC_LIMIT_MACROS 1
#include "flac/all.h" #include "flac/all.h"
#include "flac/libFLAC/bitmath.c" #include "flac/libFLAC/bitmath.c"
@@ -67,6 +73,10 @@ namespace FlacNamespace
#else #else
#include <FLAC/all.h> #include <FLAC/all.h>
#endif #endif
#if JUCE_CLANG
#pragma clang diagnostic pop
#endif
} }
#undef max #undef max


+ 10
- 0
modules/juce_audio_formats/codecs/juce_OggVorbisAudioFormat.cpp View File

@@ -37,6 +37,12 @@ namespace OggVorbisNamespace
#pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4305 4189 4706 4995 4365) #pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4305 4189 4706 4995 4365)
#endif #endif
#if JUCE_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wshadow"
#endif
#include "oggvorbis/vorbisenc.h" #include "oggvorbis/vorbisenc.h"
#include "oggvorbis/codec.h" #include "oggvorbis/codec.h"
#include "oggvorbis/vorbisfile.h" #include "oggvorbis/vorbisfile.h"
@@ -68,6 +74,10 @@ namespace OggVorbisNamespace
#if JUCE_MSVC #if JUCE_MSVC
#pragma warning (pop) #pragma warning (pop)
#endif #endif
#if JUCE_CLANG
#pragma clang diagnostic pop
#endif
#else #else
#include <vorbis/vorbisenc.h> #include <vorbis/vorbisenc.h>
#include <vorbis/codec.h> #include <vorbis/codec.h>


+ 5
- 5
modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp View File

@@ -170,11 +170,11 @@ class AudioFormatWriter::ThreadedWriter::Buffer : public AbstractFifo,
private TimeSliceClient private TimeSliceClient
{ {
public: public:
Buffer (TimeSliceThread& timeSliceThread_, AudioFormatWriter* writer_, int numChannels, int bufferSize_)
: AbstractFifo (bufferSize_),
buffer (numChannels, bufferSize_),
timeSliceThread (timeSliceThread_),
writer (writer_),
Buffer (TimeSliceThread& tst, AudioFormatWriter* w, int channels, int bufferSize)
: AbstractFifo (bufferSize),
buffer (channels, bufferSize),
timeSliceThread (tst),
writer (w),
receiver (nullptr), receiver (nullptr),
samplesWritten (0), samplesWritten (0),
isRunning (true) isRunning (true)


+ 10
- 11
modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm View File

@@ -687,8 +687,7 @@ public:
const int numIn = juceFilter->getNumInputChannels(); const int numIn = juceFilter->getNumInputChannels();
const int numOut = juceFilter->getNumOutputChannels(); const int numOut = juceFilter->getNumOutputChannels();
unsigned int i;
for (i = 0; i < outBuffer.mNumberBuffers; ++i)
for (unsigned int i = 0; i < outBuffer.mNumberBuffers; ++i)
{ {
AudioBuffer& buf = outBuffer.mBuffers[i]; AudioBuffer& buf = outBuffer.mBuffers[i];
@@ -710,7 +709,7 @@ public:
int numInChans = 0; int numInChans = 0;
for (i = 0; i < inBuffer.mNumberBuffers; ++i)
for (unsigned int i = 0; i < inBuffer.mNumberBuffers; ++i)
{ {
const AudioBuffer& buf = inBuffer.mBuffers[i]; const AudioBuffer& buf = inBuffer.mBuffers[i];
@@ -767,8 +766,8 @@ public:
if (juceFilter->isSuspended()) if (juceFilter->isSuspended())
{ {
for (int i = 0; i < numOut; ++i)
zeromem (channels [i], sizeof (float) * numSamples);
for (int j = 0; j < numOut; ++j)
zeromem (channels [j], sizeof (float) * numSamples);
} }
else else
{ {
@@ -805,7 +804,7 @@ public:
{ {
nextSpareBufferChan = 0; nextSpareBufferChan = 0;
for (i = 0; i < outBuffer.mNumberBuffers; ++i)
for (unsigned int i = 0; i < outBuffer.mNumberBuffers; ++i)
{ {
AudioBuffer& buf = outBuffer.mBuffers[i]; AudioBuffer& buf = outBuffer.mBuffers[i];
@@ -872,17 +871,17 @@ protected:
presetsArray.ensureSize (sizeof (AUPreset) * numPrograms, true); presetsArray.ensureSize (sizeof (AUPreset) * numPrograms, true);
AUPreset* const presets = (AUPreset*) presetsArray.getData(); AUPreset* const presets = (AUPreset*) presetsArray.getData();
CFMutableArrayRef presetsArray = CFArrayCreateMutable (0, numPrograms, 0);
CFMutableArrayRef presetsArrayRef = CFArrayCreateMutable (0, numPrograms, 0);
for (int i = 0; i < numPrograms; ++i) for (int i = 0; i < numPrograms; ++i)
{ {
presets[i].presetNumber = i; presets[i].presetNumber = i;
presets[i].presetName = juceFilter->getProgramName(i).toCFString(); presets[i].presetName = juceFilter->getProgramName(i).toCFString();
CFArrayAppendValue (presetsArray, presets + i);
CFArrayAppendValue (presetsArrayRef, presets + i);
} }
*outData = (CFArrayRef) presetsArray;
*outData = (CFArrayRef) presetsArrayRef;
} }
return noErr; return noErr;
@@ -1273,7 +1272,7 @@ private:
setBroughtToFrontOnMouseClick (true); setBroughtToFrontOnMouseClick (true);
setSize (editor.getWidth(), editor.getHeight()); setSize (editor.getWidth(), editor.getHeight());
SizeControl (parentHIView, editor.getWidth(), editor.getHeight());
SizeControl (parentHIView, (SInt16) editor.getWidth(), (SInt16) editor.getHeight());
WindowRef windowRef = HIViewGetWindow (parentHIView); WindowRef windowRef = HIViewGetWindow (parentHIView);
hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef]; hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef];
@@ -1355,7 +1354,7 @@ private:
const int w = jmax (32, editor.getWidth()); const int w = jmax (32, editor.getWidth());
const int h = jmax (32, editor.getHeight()); const int h = jmax (32, editor.getHeight());
SizeControl (parentView, w, h);
SizeControl (parentView, (SInt16) w, (SInt16) h);
if (getWidth() != w || getHeight() != h) if (getWidth() != w || getHeight() != h)
setSize (w, h); setSize (w, h);


+ 12
- 0
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -66,6 +66,12 @@
#define __cdecl #define __cdecl
#endif #endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wshadow"
#endif
// VSTSDK V2.4 includes.. // VSTSDK V2.4 includes..
#include <public.sdk/source/vst2.x/audioeffectx.h> #include <public.sdk/source/vst2.x/audioeffectx.h>
#include <public.sdk/source/vst2.x/aeffeditor.h> #include <public.sdk/source/vst2.x/aeffeditor.h>
@@ -76,6 +82,10 @@
#error "It looks like you're trying to include an out-of-date VSTSDK version - make sure you have at least version 2.4" #error "It looks like you're trying to include an out-of-date VSTSDK version - make sure you have at least version 2.4"
#endif #endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
//============================================================================== //==============================================================================
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma pack (push, 8) #pragma pack (push, 8)
@@ -1471,12 +1481,14 @@ namespace
// Mac startup code.. // Mac startup code..
#if JUCE_MAC #if JUCE_MAC
extern "C" __attribute__ ((visibility("default"))) AEffect* VSTPluginMain (audioMasterCallback audioMaster);
extern "C" __attribute__ ((visibility("default"))) AEffect* VSTPluginMain (audioMasterCallback audioMaster) extern "C" __attribute__ ((visibility("default"))) AEffect* VSTPluginMain (audioMasterCallback audioMaster)
{ {
initialiseMac(); initialiseMac();
return pluginEntryPoint (audioMaster); return pluginEntryPoint (audioMaster);
} }
extern "C" __attribute__ ((visibility("default"))) AEffect* main_macho (audioMasterCallback audioMaster);
extern "C" __attribute__ ((visibility("default"))) AEffect* main_macho (audioMasterCallback audioMaster) extern "C" __attribute__ ((visibility("default"))) AEffect* main_macho (audioMasterCallback audioMaster)
{ {
initialiseMac(); initialiseMac();


+ 6
- 0
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.mm View File

@@ -70,6 +70,7 @@ static pascal OSStatus viewBoundsChangedEvent (EventHandlerCallRef, EventRef, vo
#endif #endif
//============================================================================== //==============================================================================
void initialiseMac();
void initialiseMac() void initialiseMac()
{ {
#if ! JUCE_64BIT #if ! JUCE_64BIT
@@ -77,6 +78,7 @@ void initialiseMac()
#endif #endif
} }
void* attachComponentToWindowRef (Component* comp, void* windowRef);
void* attachComponentToWindowRef (Component* comp, void* windowRef) void* attachComponentToWindowRef (Component* comp, void* windowRef)
{ {
JUCE_AUTORELEASEPOOL JUCE_AUTORELEASEPOOL
@@ -166,6 +168,7 @@ void* attachComponentToWindowRef (Component* comp, void* windowRef)
#endif #endif
} }
void detachComponentFromWindowRef (Component* comp, void* nsWindow);
void detachComponentFromWindowRef (Component* comp, void* nsWindow) void detachComponentFromWindowRef (Component* comp, void* nsWindow)
{ {
#if JUCE_64BIT #if JUCE_64BIT
@@ -206,6 +209,7 @@ void detachComponentFromWindowRef (Component* comp, void* nsWindow)
#endif #endif
} }
void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight, const PluginHostType& host);
void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight, const PluginHostType& host) void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight, const PluginHostType& host)
{ {
JUCE_AUTORELEASEPOOL JUCE_AUTORELEASEPOOL
@@ -233,6 +237,7 @@ void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth
#endif #endif
} }
void checkWindowVisibility (void* nsWindow, Component* comp);
void checkWindowVisibility (void* nsWindow, Component* comp) void checkWindowVisibility (void* nsWindow, Component* comp)
{ {
#if ! JUCE_64BIT #if ! JUCE_64BIT
@@ -240,6 +245,7 @@ void checkWindowVisibility (void* nsWindow, Component* comp)
#endif #endif
} }
bool forwardCurrentKeyEventToHost (Component* comp);
bool forwardCurrentKeyEventToHost (Component* comp) bool forwardCurrentKeyEventToHost (Component* comp)
{ {
#if JUCE_64BIT #if JUCE_64BIT


+ 19
- 19
modules/juce_audio_utils/gui/juce_AudioThumbnail.cpp View File

@@ -313,7 +313,7 @@ public:
result.set (1, 0); result.set (1, 0);
} }
void write (const MinMaxValue* const source, const int startIndex, const int numValues)
void write (const MinMaxValue* const values, const int startIndex, const int numValues)
{ {
resetPeak(); resetPeak();
@@ -323,7 +323,7 @@ public:
MinMaxValue* const dest = getData (startIndex); MinMaxValue* const dest = getData (startIndex);
for (int i = 0; i < numValues; ++i) for (int i = 0; i < numValues; ++i)
dest[i] = source[i];
dest[i] = values[i];
} }
void resetPeak() noexcept void resetPeak() noexcept
@@ -377,11 +377,11 @@ public:
void drawChannel (Graphics& g, const Rectangle<int>& area, void drawChannel (Graphics& g, const Rectangle<int>& area,
const double startTime, const double endTime, const double startTime, const double endTime,
const int channelNum, const float verticalZoomFactor, const int channelNum, const float verticalZoomFactor,
const double sampleRate, const int numChannels, const int samplesPerThumbSample,
LevelDataSource* levelData, const OwnedArray<ThumbData>& channels)
const double rate, const int numChans, const int sampsPerThumbSample,
LevelDataSource* levelData, const OwnedArray<ThumbData>& chans)
{ {
refillCache (area.getWidth(), startTime, endTime, sampleRate,
numChannels, samplesPerThumbSample, levelData, channels);
refillCache (area.getWidth(), startTime, endTime, rate,
numChans, sampsPerThumbSample, levelData, chans);
if (isPositiveAndBelow (channelNum, numChannelsCached)) if (isPositiveAndBelow (channelNum, numChannelsCached))
{ {
@@ -417,19 +417,19 @@ private:
bool cacheNeedsRefilling; bool cacheNeedsRefilling;
void refillCache (const int numSamples, double startTime, const double endTime, void refillCache (const int numSamples, double startTime, const double endTime,
const double sampleRate, const int numChannels, const int samplesPerThumbSample,
LevelDataSource* levelData, const OwnedArray<ThumbData>& channels)
const double rate, const int numChans, const int sampsPerThumbSample,
LevelDataSource* levelData, const OwnedArray<ThumbData>& chans)
{ {
const double timePerPixel = (endTime - startTime) / numSamples; const double timePerPixel = (endTime - startTime) / numSamples;
if (numSamples <= 0 || timePerPixel <= 0.0 || sampleRate <= 0)
if (numSamples <= 0 || timePerPixel <= 0.0 || rate <= 0)
{ {
invalidate(); invalidate();
return; return;
} }
if (numSamples == numSamplesCached if (numSamples == numSamplesCached
&& numChannelsCached == numChannels
&& numChannelsCached == numChans
&& startTime == cachedStart && startTime == cachedStart
&& timePerPixel == cachedTimePerPixel && timePerPixel == cachedTimePerPixel
&& ! cacheNeedsRefilling) && ! cacheNeedsRefilling)
@@ -438,22 +438,22 @@ private:
} }
numSamplesCached = numSamples; numSamplesCached = numSamples;
numChannelsCached = numChannels;
numChannelsCached = numChans;
cachedStart = startTime; cachedStart = startTime;
cachedTimePerPixel = timePerPixel; cachedTimePerPixel = timePerPixel;
cacheNeedsRefilling = false; cacheNeedsRefilling = false;
ensureSize (numSamples); ensureSize (numSamples);
if (timePerPixel * sampleRate <= samplesPerThumbSample && levelData != nullptr)
if (timePerPixel * rate <= sampsPerThumbSample && levelData != nullptr)
{ {
int sample = roundToInt (startTime * sampleRate);
int sample = roundToInt (startTime * rate);
Array<float> levels; Array<float> levels;
int i; int i;
for (i = 0; i < numSamples; ++i) for (i = 0; i < numSamples; ++i)
{ {
const int nextSample = roundToInt ((startTime + timePerPixel) * sampleRate);
const int nextSample = roundToInt ((startTime + timePerPixel) * rate);
if (sample >= 0) if (sample >= 0)
{ {
@@ -462,9 +462,9 @@ private:
levelData->getLevels (sample, jmax (1, nextSample - sample), levels); levelData->getLevels (sample, jmax (1, nextSample - sample), levels);
const int numChans = jmin (levels.size() / 2, numChannelsCached);
const int totalChans = jmin (levels.size() / 2, numChannelsCached);
for (int chan = 0; chan < numChans; ++chan)
for (int chan = 0; chan < totalChans; ++chan)
getData (chan, i)->setFloat (levels.getUnchecked (chan * 2), getData (chan, i)->setFloat (levels.getUnchecked (chan * 2),
levels.getUnchecked (chan * 2 + 1)); levels.getUnchecked (chan * 2 + 1));
} }
@@ -477,14 +477,14 @@ private:
} }
else else
{ {
jassert (channels.size() == numChannelsCached);
jassert (chans.size() == numChannelsCached);
for (int channelNum = 0; channelNum < numChannelsCached; ++channelNum) for (int channelNum = 0; channelNum < numChannelsCached; ++channelNum)
{ {
ThumbData* channelData = channels.getUnchecked (channelNum);
ThumbData* channelData = chans.getUnchecked (channelNum);
MinMaxValue* cacheData = getData (channelNum, 0); MinMaxValue* cacheData = getData (channelNum, 0);
const double timeToThumbSampleFactor = sampleRate / (double) samplesPerThumbSample;
const double timeToThumbSampleFactor = rate / (double) sampsPerThumbSample;
startTime = cachedStart; startTime = cachedStart;
int sample = roundToInt (startTime * timeToThumbSampleFactor); int sample = roundToInt (startTime * timeToThumbSampleFactor);


+ 15
- 15
modules/juce_core/maths/juce_Expression.cpp View File

@@ -350,8 +350,8 @@ struct Expression::Helpers
class EvaluationVisitor : public Scope::Visitor class EvaluationVisitor : public Scope::Visitor
{ {
public: public:
EvaluationVisitor (const TermPtr& term, const int recursion)
: input (term), output (term), recursionCount (recursion) {}
EvaluationVisitor (const TermPtr& t, const int recursion)
: input (t), output (t), recursionCount (recursion) {}
void visit (const Scope& scope) { output = input->resolve (scope, recursionCount); } void visit (const Scope& scope) { output = input->resolve (scope, recursionCount); }
@@ -366,8 +366,8 @@ struct Expression::Helpers
class SymbolVisitingVisitor : public Scope::Visitor class SymbolVisitingVisitor : public Scope::Visitor
{ {
public: public:
SymbolVisitingVisitor (const TermPtr& term, SymbolVisitor& v, const int recursion)
: input (term), visitor (v), recursionCount (recursion) {}
SymbolVisitingVisitor (const TermPtr& t, SymbolVisitor& v, const int recursion)
: input (t), visitor (v), recursionCount (recursion) {}
void visit (const Scope& scope) { input->visitAllSymbols (visitor, scope, recursionCount); } void visit (const Scope& scope) { input->visitAllSymbols (visitor, scope, recursionCount); }
@@ -382,8 +382,8 @@ struct Expression::Helpers
class SymbolRenamingVisitor : public Scope::Visitor class SymbolRenamingVisitor : public Scope::Visitor
{ {
public: public:
SymbolRenamingVisitor (const TermPtr& term, const Expression::Symbol& symbol_, const String& newName_, const int recursionCount_)
: input (term), symbol (symbol_), newName (newName_), recursionCount (recursionCount_) {}
SymbolRenamingVisitor (const TermPtr& t, const Expression::Symbol& symbol_, const String& newName_, const int recursionCount_)
: input (t), symbol (symbol_), newName (newName_), recursionCount (recursionCount_) {}
void visit (const Scope& scope) { input->renameSymbol (symbol, newName, scope, recursionCount); } void visit (const Scope& scope) { input->renameSymbol (symbol, newName, scope, recursionCount); }
@@ -405,9 +405,9 @@ struct Expression::Helpers
class Negate : public Term class Negate : public Term
{ {
public: public:
explicit Negate (const TermPtr& term) : input (term)
explicit Negate (const TermPtr& t) : input (t)
{ {
jassert (term != nullptr);
jassert (t != nullptr);
} }
Type getType() const noexcept { return operatorType; } Type getType() const noexcept { return operatorType; }
@@ -424,10 +424,10 @@ struct Expression::Helpers
String getName() const { return "-"; } String getName() const { return "-"; }
TermPtr negated() { return input; } TermPtr negated() { return input; }
TermPtr createTermToEvaluateInput (const Scope& scope, const Term* term, double overallTarget, Term* topLevelTerm) const
TermPtr createTermToEvaluateInput (const Scope& scope, const Term* t, double overallTarget, Term* topLevelTerm) const
{ {
(void) term;
jassert (term == input);
(void) t;
jassert (t == input);
const Term* const dest = findDestinationFor (topLevelTerm, this); const Term* const dest = findDestinationFor (topLevelTerm, this);
@@ -813,15 +813,15 @@ struct Expression::Helpers
char opType; char opType;
if (readOperator ("+-", &opType)) if (readOperator ("+-", &opType))
{ {
TermPtr term (readUnaryExpression());
TermPtr e (readUnaryExpression());
if (term == nullptr)
if (e == nullptr)
throw ParseError ("Expected expression after \"" + String::charToString ((juce_wchar) (uint8) opType) + "\""); throw ParseError ("Expected expression after \"" + String::charToString ((juce_wchar) (uint8) opType) + "\"");
if (opType == '-') if (opType == '-')
term = term->negated();
e = e->negated();
return term;
return e;
} }
return readPrimaryExpression(); return readPrimaryExpression();


+ 5
- 5
modules/juce_core/native/juce_mac_Files.mm View File

@@ -351,11 +351,11 @@ public:
if (fnmatch (wildcardUTF8, filenameFound.toUTF8(), FNM_CASEFOLD) != 0) if (fnmatch (wildcardUTF8, filenameFound.toUTF8(), FNM_CASEFOLD) != 0)
continue; continue;
const String path (parentDir + filenameFound);
updateStatInfoForFile (path, isDir, fileSize, modTime, creationTime, isReadOnly);
const String fullPath (parentDir + filenameFound);
updateStatInfoForFile (fullPath, isDir, fileSize, modTime, creationTime, isReadOnly);
if (isHidden != nullptr) if (isHidden != nullptr)
*isHidden = FileHelpers::isHiddenFile (path);
*isHidden = FileHelpers::isHiddenFile (fullPath);
return true; return true;
} }
@@ -368,8 +368,8 @@ private:
JUCE_DECLARE_NON_COPYABLE (Pimpl); JUCE_DECLARE_NON_COPYABLE (Pimpl);
}; };
DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildCard)
: pimpl (new DirectoryIterator::NativeIterator::Pimpl (directory, wildCard))
DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildcard)
: pimpl (new DirectoryIterator::NativeIterator::Pimpl (directory, wildcard))
{ {
} }


+ 2
- 2
modules/juce_core/native/juce_posix_SharedCode.h View File

@@ -701,7 +701,7 @@ String juce_getOutputFromCommand (const String& command)
class InterProcessLock::Pimpl class InterProcessLock::Pimpl
{ {
public: public:
Pimpl (const String& name, const int timeOutMillisecs)
Pimpl (const String& lockName, const int timeOutMillisecs)
: handle (0), refCount (1) : handle (0), refCount (1)
{ {
#if JUCE_IOS #if JUCE_IOS
@@ -718,7 +718,7 @@ public:
tempFolder = "/tmp"; tempFolder = "/tmp";
#endif #endif
const File temp (tempFolder.getChildFile (name));
const File temp (tempFolder.getChildFile (lockName));
temp.create(); temp.create();
handle = open (temp.getFullPathName().toUTF8(), O_RDWR); handle = open (temp.getFullPathName().toUTF8(), O_RDWR);


+ 2
- 3
modules/juce_core/text/juce_LocalisedStrings.cpp View File

@@ -180,9 +180,8 @@ String translate (const String& text, const String& resultIfNotFound)
{ {
const SpinLock::ScopedLockType sl (currentMappingsLock); const SpinLock::ScopedLockType sl (currentMappingsLock);
const LocalisedStrings* const currentMappings = LocalisedStrings::getCurrentMappings();
if (currentMappings != nullptr)
return currentMappings->translate (text, resultIfNotFound);
if (const LocalisedStrings* const mappings = LocalisedStrings::getCurrentMappings())
return mappings->translate (text, resultIfNotFound);
return resultIfNotFound; return resultIfNotFound;
} }

+ 3
- 3
modules/juce_core/threads/juce_InterProcessLock.h View File

@@ -90,7 +90,7 @@ public:
otherwise there are no guarantees what will happen! Best just to use it otherwise there are no guarantees what will happen! Best just to use it
as a local stack object, rather than creating one with the new() operator. as a local stack object, rather than creating one with the new() operator.
*/ */
explicit ScopedLockType (InterProcessLock& lock) : ipLock (lock) { lockWasSuccessful = lock.enter(); }
explicit ScopedLockType (InterProcessLock& l) : ipLock (l) { lockWasSuccessful = l.enter(); }
/** Destructor. /** Destructor.
@@ -99,10 +99,10 @@ public:
Make sure this object is created and deleted by the same thread, Make sure this object is created and deleted by the same thread,
otherwise there are no guarantees what will happen! otherwise there are no guarantees what will happen!
*/ */
inline ~ScopedLockType() { ipLock.exit(); }
inline ~ScopedLockType() { ipLock.exit(); }
/** Returns true if the InterProcessLock was successfully locked. */ /** Returns true if the InterProcessLock was successfully locked. */
bool isLocked() const noexcept { return lockWasSuccessful; }
bool isLocked() const noexcept { return lockWasSuccessful; }
private: private:
//============================================================================== //==============================================================================


+ 9
- 9
modules/juce_core/zip/juce_GZIPCompressorOutputStream.cpp View File

@@ -46,26 +46,26 @@ public:
zlibNamespace::deflateEnd (&stream); zlibNamespace::deflateEnd (&stream);
} }
bool write (const uint8* data, int dataSize, OutputStream& destStream)
bool write (const uint8* data, int dataSize, OutputStream& out)
{ {
// When you call flush() on a gzip stream, the stream is closed, and you can // When you call flush() on a gzip stream, the stream is closed, and you can
// no longer continue to write data to it! // no longer continue to write data to it!
jassert (! finished); jassert (! finished);
while (dataSize > 0) while (dataSize > 0)
if (! doNextBlock (data, dataSize, destStream, Z_NO_FLUSH))
if (! doNextBlock (data, dataSize, out, Z_NO_FLUSH))
return false; return false;
return true; return true;
} }
void finish (OutputStream& destStream)
void finish (OutputStream& out)
{ {
const uint8* data = nullptr; const uint8* data = nullptr;
int dataSize = 0; int dataSize = 0;
while (! finished) while (! finished)
doNextBlock (data, dataSize, destStream, Z_FINISH);
doNextBlock (data, dataSize, out, Z_FINISH);
} }
private: private:
@@ -76,7 +76,7 @@ private:
bool isFirstDeflate, streamIsValid, finished; bool isFirstDeflate, streamIsValid, finished;
zlibNamespace::Bytef buffer[32768]; zlibNamespace::Bytef buffer[32768];
bool doNextBlock (const uint8*& data, int& dataSize, OutputStream& destStream, const int flushMode)
bool doNextBlock (const uint8*& data, int& dataSize, OutputStream& out, const int flushMode)
{ {
using namespace zlibNamespace; using namespace zlibNamespace;
if (streamIsValid) if (streamIsValid)
@@ -100,7 +100,7 @@ private:
data += dataSize - stream.avail_in; data += dataSize - stream.avail_in;
dataSize = (int) stream.avail_in; dataSize = (int) stream.avail_in;
const int bytesDone = ((int) sizeof (buffer)) - (int) stream.avail_out; const int bytesDone = ((int) sizeof (buffer)) - (int) stream.avail_out;
return bytesDone <= 0 || destStream.write (buffer, bytesDone);
return bytesDone <= 0 || out.write (buffer, bytesDone);
} }
default: default:
@@ -115,14 +115,14 @@ private:
}; };
//============================================================================== //==============================================================================
GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const destStream_,
GZIPCompressorOutputStream::GZIPCompressorOutputStream (OutputStream* const out,
const int compressionLevel, const int compressionLevel,
const bool deleteDestStream, const bool deleteDestStream,
const int windowBits) const int windowBits)
: destStream (destStream_, deleteDestStream),
: destStream (out, deleteDestStream),
helper (new GZIPCompressorHelper (compressionLevel, windowBits)) helper (new GZIPCompressorHelper (compressionLevel, windowBits))
{ {
jassert (destStream_ != nullptr);
jassert (out != nullptr);
} }
GZIPCompressorOutputStream::~GZIPCompressorOutputStream() GZIPCompressorOutputStream::~GZIPCompressorOutputStream()


+ 12
- 2
modules/juce_core/zip/juce_GZIPDecompressorInputStream.cpp View File

@@ -31,6 +31,12 @@
namespace zlibNamespace namespace zlibNamespace
{ {
#if JUCE_INCLUDE_ZLIB_CODE #if JUCE_INCLUDE_ZLIB_CODE
#if JUCE_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wshadow"
#endif
#undef OS_CODE #undef OS_CODE
#undef fdopen #undef fdopen
#define ZLIB_INTERNAL #define ZLIB_INTERNAL
@@ -55,6 +61,10 @@ namespace zlibNamespace
#include "zlib/trees.c" #include "zlib/trees.c"
#include "zlib/zutil.c" #include "zlib/zutil.c"
#undef Byte #undef Byte
#if JUCE_CLANG
#pragma clang diagnostic pop
#endif
#else #else
#include JUCE_ZLIB_INCLUDE_PATH #include JUCE_ZLIB_INCLUDE_PATH
#endif #endif
@@ -70,7 +80,7 @@ namespace zlibNamespace
class GZIPDecompressorInputStream::GZIPDecompressHelper class GZIPDecompressorInputStream::GZIPDecompressHelper
{ {
public: public:
GZIPDecompressHelper (const bool noWrap)
GZIPDecompressHelper (const bool dontWrap)
: finished (true), : finished (true),
needsDictionary (false), needsDictionary (false),
error (true), error (true),
@@ -80,7 +90,7 @@ public:
{ {
using namespace zlibNamespace; using namespace zlibNamespace;
zerostruct (stream); zerostruct (stream);
streamIsValid = (inflateInit2 (&stream, noWrap ? -MAX_WBITS : MAX_WBITS) == Z_OK);
streamIsValid = (inflateInit2 (&stream, dontWrap ? -MAX_WBITS : MAX_WBITS) == Z_OK);
finished = error = ! streamIsValid; finished = error = ! streamIsValid;
} }


+ 1
- 1
modules/juce_events/native/juce_linux_Messaging.cpp View File

@@ -31,7 +31,7 @@ Display* display = nullptr;
Window juce_messageWindowHandle = None; Window juce_messageWindowHandle = None;
XContext windowHandleXContext; // This is referenced from Windowing.cpp XContext windowHandleXContext; // This is referenced from Windowing.cpp
extern void juce_windowMessageReceive (XEvent*); // Defined in Windowing.cpp
extern void juce_windowMessageReceive (XEvent* event); // Defined in Windowing.cpp
extern void juce_handleSelectionRequest (XSelectionRequestEvent&); // Defined in Clipboard.cpp extern void juce_handleSelectionRequest (XSelectionRequestEvent&); // Defined in Clipboard.cpp
//============================================================================== //==============================================================================


+ 10
- 10
modules/juce_graphics/geometry/juce_Path.cpp View File

@@ -941,15 +941,15 @@ AffineTransform Path::getTransformToScaleToFit (const float x, const float y,
const bool preserveProportions, const bool preserveProportions,
const Justification& justification) const const Justification& justification) const
{ {
Rectangle<float> bounds (getBounds());
Rectangle<float> boundsRect (getBounds());
if (preserveProportions) if (preserveProportions)
{ {
if (w <= 0 || h <= 0 || bounds.isEmpty())
if (w <= 0 || h <= 0 || boundsRect.isEmpty())
return AffineTransform::identity; return AffineTransform::identity;
float newW, newH; float newW, newH;
const float srcRatio = bounds.getHeight() / bounds.getWidth();
const float srcRatio = boundsRect.getHeight() / boundsRect.getWidth();
if (srcRatio > h / w) if (srcRatio > h / w)
{ {
@@ -973,17 +973,17 @@ AffineTransform Path::getTransformToScaleToFit (const float x, const float y,
else if (justification.testFlags (Justification::bottom)) newYCentre += h - newH * 0.5f; else if (justification.testFlags (Justification::bottom)) newYCentre += h - newH * 0.5f;
else newYCentre += h * 0.5f; else newYCentre += h * 0.5f;
return AffineTransform::translation (bounds.getWidth() * -0.5f - bounds.getX(),
bounds.getHeight() * -0.5f - bounds.getY())
.scaled (newW / bounds.getWidth(),
newH / bounds.getHeight())
return AffineTransform::translation (boundsRect.getWidth() * -0.5f - boundsRect.getX(),
boundsRect.getHeight() * -0.5f - boundsRect.getY())
.scaled (newW / boundsRect.getWidth(),
newH / boundsRect.getHeight())
.translated (newXCentre, newYCentre); .translated (newXCentre, newYCentre);
} }
else else
{ {
return AffineTransform::translation (-bounds.getX(), -bounds.getY())
.scaled (w / bounds.getWidth(),
h / bounds.getHeight())
return AffineTransform::translation (-boundsRect.getX(), -boundsRect.getY())
.scaled (w / boundsRect.getWidth(),
h / boundsRect.getHeight())
.translated (x, y); .translated (x, y);
} }
} }


+ 11
- 0
modules/juce_graphics/image_formats/juce_JPEGLoader.cpp View File

@@ -34,6 +34,13 @@ namespace jpeglibNamespace
#if JUCE_MINGW #if JUCE_MINGW
typedef unsigned char boolean; typedef unsigned char boolean;
#endif #endif
#if JUCE_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wconversion"
#endif
#define JPEG_INTERNALS #define JPEG_INTERNALS
#undef FAR #undef FAR
#include "jpglib/jpeglib.h" #include "jpglib/jpeglib.h"
@@ -106,6 +113,10 @@ namespace jpeglibNamespace
#include "jpglib/jquant2.c" #include "jpglib/jquant2.c"
#include "jpglib/jutils.c" #include "jpglib/jutils.c"
#include "jpglib/transupp.c" #include "jpglib/transupp.c"
#if JUCE_CLANG
#pragma clang diagnostic pop
#endif
#else #else
#define JPEG_INTERNALS #define JPEG_INTERNALS
#undef FAR #undef FAR


+ 13
- 13
modules/juce_graphics/images/juce_Image.cpp View File

@@ -338,36 +338,36 @@ NamedValueSet* Image::getProperties() const
} }
//============================================================================== //==============================================================================
Image::BitmapData::BitmapData (Image& image, const int x, const int y, const int w, const int h, BitmapData::ReadWriteMode mode)
Image::BitmapData::BitmapData (Image& im, const int x, const int y, const int w, const int h, BitmapData::ReadWriteMode mode)
: width (w), height (h) : width (w), height (h)
{ {
// The BitmapData class must be given a valid image, and a valid rectangle within it! // The BitmapData class must be given a valid image, and a valid rectangle within it!
jassert (image.image != nullptr);
jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= image.getWidth() && y + h <= image.getHeight());
jassert (im.image != nullptr);
jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= im.getWidth() && y + h <= im.getHeight());
image.image->initialiseBitmapData (*this, x, y, mode);
im.image->initialiseBitmapData (*this, x, y, mode);
jassert (data != nullptr && pixelStride > 0 && lineStride != 0); jassert (data != nullptr && pixelStride > 0 && lineStride != 0);
} }
Image::BitmapData::BitmapData (const Image& image, const int x, const int y, const int w, const int h)
Image::BitmapData::BitmapData (const Image& im, const int x, const int y, const int w, const int h)
: width (w), height (h) : width (w), height (h)
{ {
// The BitmapData class must be given a valid image, and a valid rectangle within it! // The BitmapData class must be given a valid image, and a valid rectangle within it!
jassert (image.image != nullptr);
jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= image.getWidth() && y + h <= image.getHeight());
jassert (im.image != nullptr);
jassert (x >= 0 && y >= 0 && w > 0 && h > 0 && x + w <= im.getWidth() && y + h <= im.getHeight());
image.image->initialiseBitmapData (*this, x, y, readOnly);
im.image->initialiseBitmapData (*this, x, y, readOnly);
jassert (data != nullptr && pixelStride > 0 && lineStride != 0); jassert (data != nullptr && pixelStride > 0 && lineStride != 0);
} }
Image::BitmapData::BitmapData (const Image& image, BitmapData::ReadWriteMode mode)
: width (image.getWidth()),
height (image.getHeight())
Image::BitmapData::BitmapData (const Image& im, BitmapData::ReadWriteMode mode)
: width (im.getWidth()),
height (im.getHeight())
{ {
// The BitmapData class must be given a valid image! // The BitmapData class must be given a valid image!
jassert (image.image != nullptr);
jassert (im.image != nullptr);
image.image->initialiseBitmapData (*this, 0, 0, mode);
im.image->initialiseBitmapData (*this, 0, 0, mode);
jassert (data != nullptr && pixelStride > 0 && lineStride != 0); jassert (data != nullptr && pixelStride > 0 && lineStride != 0);
} }


+ 13
- 13
modules/juce_graphics/native/juce_RenderingHelpers.h View File

@@ -1357,24 +1357,24 @@ namespace EdgeTableFillers
pixelOffset (offsetFloat), pixelOffsetInt (offsetInt) pixelOffset (offsetFloat), pixelOffsetInt (offsetInt)
{} {}
void setStartOfLine (float x, float y, const int numPixels) noexcept
void setStartOfLine (float sx, float sy, const int numPixels) noexcept
{ {
jassert (numPixels > 0); jassert (numPixels > 0);
x += pixelOffset;
y += pixelOffset;
float x1 = x, y1 = y;
x += numPixels;
inverseTransform.transformPoints (x1, y1, x, y);
sx += pixelOffset;
sy += pixelOffset;
float x1 = sx, y1 = sy;
sx += numPixels;
inverseTransform.transformPoints (x1, y1, sx, sy);
xBresenham.set ((int) (x1 * 256.0f), (int) (x * 256.0f), numPixels, pixelOffsetInt);
yBresenham.set ((int) (y1 * 256.0f), (int) (y * 256.0f), numPixels, pixelOffsetInt);
xBresenham.set ((int) (x1 * 256.0f), (int) (sx * 256.0f), numPixels, pixelOffsetInt);
yBresenham.set ((int) (y1 * 256.0f), (int) (sy * 256.0f), numPixels, pixelOffsetInt);
} }
void next (int& x, int& y) noexcept
void next (int& px, int& py) noexcept
{ {
x = xBresenham.n; xBresenham.stepToNext();
y = yBresenham.n; yBresenham.stepToNext();
px = xBresenham.n; xBresenham.stepToNext();
py = yBresenham.n; yBresenham.stepToNext();
} }
private: private:
@@ -1383,12 +1383,12 @@ namespace EdgeTableFillers
public: public:
BresenhamInterpolator() noexcept {} BresenhamInterpolator() noexcept {}
void set (const int n1, const int n2, const int numSteps_, const int pixelOffsetInt) noexcept
void set (const int n1, const int n2, const int numSteps_, const int offsetInt) noexcept
{ {
numSteps = numSteps_; numSteps = numSteps_;
step = (n2 - n1) / numSteps; step = (n2 - n1) / numSteps;
remainder = modulo = (n2 - n1) % numSteps; remainder = modulo = (n2 - n1) % numSteps;
n = n1 + pixelOffsetInt;
n = n1 + offsetInt;
if (modulo <= 0) if (modulo <= 0)
{ {


+ 2
- 2
modules/juce_graphics/native/juce_mac_CoreGraphicsContext.mm View File

@@ -585,7 +585,7 @@ void CoreGraphicsContext::drawGlyph (int glyphNumber, const AffineTransform& tra
{ {
CGContextSetTextMatrix (context, state->fontTransform); // have to set this each time, as it's not saved as part of the state CGContextSetTextMatrix (context, state->fontTransform); // have to set this each time, as it's not saved as part of the state
CGGlyph g = glyphNumber;
CGGlyph g = (CGGlyph) glyphNumber;
CGContextShowGlyphsAtPoint (context, transform.getTranslationX(), CGContextShowGlyphsAtPoint (context, transform.getTranslationX(),
flipHeight - roundToInt (transform.getTranslationY()), &g, 1); flipHeight - roundToInt (transform.getTranslationY()), &g, 1);
} }
@@ -599,7 +599,7 @@ void CoreGraphicsContext::drawGlyph (int glyphNumber, const AffineTransform& tra
t.d = -t.d; t.d = -t.d;
CGContextSetTextMatrix (context, t); CGContextSetTextMatrix (context, t);
CGGlyph g = glyphNumber;
CGGlyph g = (CGGlyph) glyphNumber;
CGContextShowGlyphsAtPoint (context, 0, 0, &g, 1); CGContextShowGlyphsAtPoint (context, 0, 0, &g, 1);
CGContextRestoreGState (context); CGContextRestoreGState (context);


+ 2
- 2
modules/juce_graphics/native/juce_mac_Fonts.mm View File

@@ -426,8 +426,8 @@ public:
fontRef = CTFontCopyGraphicsFont (ctFontRef, nullptr); fontRef = CTFontCopyGraphicsFont (ctFontRef, nullptr);
const int totalHeight = abs (CGFontGetAscent (fontRef)) + abs (CGFontGetDescent (fontRef));
const float ctTotalHeight = abs (CTFontGetAscent (ctFontRef)) + abs (CTFontGetDescent (ctFontRef));
const int totalHeight = std::abs (CGFontGetAscent (fontRef)) + std::abs (CGFontGetDescent (fontRef));
const float ctTotalHeight = std::abs (CTFontGetAscent (ctFontRef)) + std::abs (CTFontGetDescent (ctFontRef));
unitsToHeightScaleFactor = 1.0f / ctTotalHeight; unitsToHeightScaleFactor = 1.0f / ctTotalHeight;
fontHeightToCGSizeFactor = CGFontGetUnitsPerEm (fontRef) / (float) totalHeight; fontHeightToCGSizeFactor = CGFontGetUnitsPerEm (fontRef) / (float) totalHeight;


+ 2
- 2
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -1427,11 +1427,11 @@ void Component::addAndMakeVisible (Component* const child, int zOrder)
} }
} }
void Component::addChildAndSetID (Component* const child, const String& componentID)
void Component::addChildAndSetID (Component* const child, const String& childID)
{ {
if (child != nullptr) if (child != nullptr)
{ {
child->setComponentID (componentID);
child->setComponentID (childID);
addAndMakeVisible (child); addAndMakeVisible (child);
} }
} }


+ 2
- 0
modules/juce_gui_basics/components/juce_Desktop.cpp View File

@@ -379,6 +379,7 @@ Rectangle<int> Desktop::Displays::getTotalBounds (bool userAreasOnly) const
return getRectangleList (userAreasOnly).getBounds(); return getRectangleList (userAreasOnly).getBounds();
} }
bool operator== (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept;
bool operator== (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept bool operator== (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept
{ {
return d1.userArea == d2.userArea return d1.userArea == d2.userArea
@@ -387,6 +388,7 @@ bool operator== (const Desktop::Displays::Display& d1, const Desktop::Displays::
&& d1.isMain == d2.isMain; && d1.isMain == d2.isMain;
} }
bool operator!= (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept;
bool operator!= (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept bool operator!= (const Desktop::Displays::Display& d1, const Desktop::Displays::Display& d2) noexcept
{ {
return ! (d1 == d2); return ! (d1 == d2);


+ 12
- 12
modules/juce_gui_basics/drawables/juce_DrawableComposite.cpp View File

@@ -271,24 +271,24 @@ void DrawableComposite::ValueTreeWrapper::resetBoundingBoxToContentArea (UndoMan
RelativeRectangle DrawableComposite::ValueTreeWrapper::getContentArea() const RelativeRectangle DrawableComposite::ValueTreeWrapper::getContentArea() const
{ {
MarkerList::ValueTreeWrapper markersX (getMarkerList (true));
MarkerList::ValueTreeWrapper markersY (getMarkerList (false));
MarkerList::ValueTreeWrapper marksX (getMarkerList (true));
MarkerList::ValueTreeWrapper marksY (getMarkerList (false));
return RelativeRectangle (markersX.getMarker (markersX.getMarkerState (0)).position,
markersX.getMarker (markersX.getMarkerState (1)).position,
markersY.getMarker (markersY.getMarkerState (0)).position,
markersY.getMarker (markersY.getMarkerState (1)).position);
return RelativeRectangle (marksX.getMarker (marksX.getMarkerState (0)).position,
marksX.getMarker (marksX.getMarkerState (1)).position,
marksY.getMarker (marksY.getMarkerState (0)).position,
marksY.getMarker (marksY.getMarkerState (1)).position);
} }
void DrawableComposite::ValueTreeWrapper::setContentArea (const RelativeRectangle& newArea, UndoManager* undoManager) void DrawableComposite::ValueTreeWrapper::setContentArea (const RelativeRectangle& newArea, UndoManager* undoManager)
{ {
MarkerList::ValueTreeWrapper markersX (getMarkerListCreating (true, nullptr));
MarkerList::ValueTreeWrapper markersY (getMarkerListCreating (false, nullptr));
MarkerList::ValueTreeWrapper marksX (getMarkerListCreating (true, nullptr));
MarkerList::ValueTreeWrapper marksY (getMarkerListCreating (false, nullptr));
markersX.setMarker (MarkerList::Marker (contentLeftMarkerName, newArea.left), undoManager);
markersX.setMarker (MarkerList::Marker (contentRightMarkerName, newArea.right), undoManager);
markersY.setMarker (MarkerList::Marker (contentTopMarkerName, newArea.top), undoManager);
markersY.setMarker (MarkerList::Marker (contentBottomMarkerName, newArea.bottom), undoManager);
marksX.setMarker (MarkerList::Marker (contentLeftMarkerName, newArea.left), undoManager);
marksX.setMarker (MarkerList::Marker (contentRightMarkerName, newArea.right), undoManager);
marksY.setMarker (MarkerList::Marker (contentTopMarkerName, newArea.top), undoManager);
marksY.setMarker (MarkerList::Marker (contentBottomMarkerName, newArea.bottom), undoManager);
} }
MarkerList::ValueTreeWrapper DrawableComposite::ValueTreeWrapper::getMarkerList (bool xAxis) const MarkerList::ValueTreeWrapper DrawableComposite::ValueTreeWrapper::getMarkerList (bool xAxis) const


+ 7
- 7
modules/juce_gui_basics/drawables/juce_DrawablePath.cpp View File

@@ -174,20 +174,20 @@ void DrawablePath::ValueTreeWrapper::setUsesNonZeroWinding (bool b, UndoManager*
state.setProperty (nonZeroWinding, b, undoManager); state.setProperty (nonZeroWinding, b, undoManager);
} }
void DrawablePath::ValueTreeWrapper::readFrom (const RelativePointPath& relativePath, UndoManager* undoManager)
void DrawablePath::ValueTreeWrapper::readFrom (const RelativePointPath& p, UndoManager* undoManager)
{ {
setUsesNonZeroWinding (relativePath.usesNonZeroWinding, undoManager);
setUsesNonZeroWinding (p.usesNonZeroWinding, undoManager);
ValueTree pathTree (getPathState()); ValueTree pathTree (getPathState());
pathTree.removeAllChildren (undoManager); pathTree.removeAllChildren (undoManager);
for (int i = 0; i < relativePath.elements.size(); ++i)
pathTree.addChild (relativePath.elements.getUnchecked(i)->createTree(), -1, undoManager);
for (int i = 0; i < p.elements.size(); ++i)
pathTree.addChild (p.elements.getUnchecked(i)->createTree(), -1, undoManager);
} }
void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& relativePath) const
void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& p) const
{ {
relativePath.usesNonZeroWinding = usesNonZeroWinding();
p.usesNonZeroWinding = usesNonZeroWinding();
RelativePoint points[3]; RelativePoint points[3];
const ValueTree pathTree (state.getChildWithName (path)); const ValueTree pathTree (state.getChildWithName (path));
@@ -210,7 +210,7 @@ void DrawablePath::ValueTreeWrapper::writeTo (RelativePointPath& relativePath) c
else if (t == Element::cubicToElement) newElement = new RelativePointPath::CubicTo (points[0], points[1], points[2]); else if (t == Element::cubicToElement) newElement = new RelativePointPath::CubicTo (points[0], points[1], points[2]);
else jassertfalse; else jassertfalse;
relativePath.addElement (newElement);
p.addElement (newElement);
} }
} }


+ 9
- 9
modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp View File

@@ -138,25 +138,25 @@ public:
class ProxyComponent : public Component class ProxyComponent : public Component
{ {
public: public:
ProxyComponent (Component& component)
: image (component.createComponentSnapshot (component.getLocalBounds()))
ProxyComponent (Component& c)
: image (c.createComponentSnapshot (c.getLocalBounds()))
{ {
setBounds (component.getBounds());
setTransform (component.getTransform());
setAlpha (component.getAlpha());
setBounds (c.getBounds());
setTransform (c.getTransform());
setAlpha (c.getAlpha());
setInterceptsMouseClicks (false, false); setInterceptsMouseClicks (false, false);
Component* const parent = component.getParentComponent();
Component* const parent = c.getParentComponent();
if (parent != nullptr) if (parent != nullptr)
parent->addAndMakeVisible (this); parent->addAndMakeVisible (this);
else if (component.isOnDesktop() && component.getPeer() != nullptr)
addToDesktop (component.getPeer()->getStyleFlags() | ComponentPeer::windowIgnoresKeyPresses);
else if (c.isOnDesktop() && c.getPeer() != nullptr)
addToDesktop (c.getPeer()->getStyleFlags() | ComponentPeer::windowIgnoresKeyPresses);
else else
jassertfalse; // seem to be trying to animate a component that's not visible.. jassertfalse; // seem to be trying to animate a component that's not visible..
setVisible (true); setVisible (true);
toBehind (&component);
toBehind (&c);
} }
void paint (Graphics& g) void paint (Graphics& g)


+ 8
- 8
modules/juce_gui_basics/misc/juce_DropShadower.cpp View File

@@ -26,24 +26,24 @@
class DropShadower::ShadowWindow : public Component class DropShadower::ShadowWindow : public Component
{ {
public: public:
ShadowWindow (Component& owner, const int type_, const Image shadowImageSections [12])
: topLeft (shadowImageSections [type_ * 3]),
bottomRight (shadowImageSections [type_ * 3 + 1]),
filler (shadowImageSections [type_ * 3 + 2]),
type (type_)
ShadowWindow (Component& comp, const int shadowType, const Image imageSections [12])
: topLeft (imageSections [shadowType * 3]),
bottomRight (imageSections [shadowType * 3 + 1]),
filler (imageSections [shadowType * 3 + 2]),
type (shadowType)
{ {
setInterceptsMouseClicks (false, false); setInterceptsMouseClicks (false, false);
if (owner.isOnDesktop())
if (comp.isOnDesktop())
{ {
setSize (1, 1); // to keep the OS happy by not having zero-size windows setSize (1, 1); // to keep the OS happy by not having zero-size windows
addToDesktop (ComponentPeer::windowIgnoresMouseClicks addToDesktop (ComponentPeer::windowIgnoresMouseClicks
| ComponentPeer::windowIsTemporary | ComponentPeer::windowIsTemporary
| ComponentPeer::windowIgnoresKeyPresses); | ComponentPeer::windowIgnoresKeyPresses);
} }
else if (owner.getParentComponent() != nullptr)
else if (Component* const parent = comp.getParentComponent())
{ {
owner.getParentComponent()->addChildComponent (this);
parent->addChildComponent (this);
} }
} }


+ 12
- 13
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -241,16 +241,16 @@ public:
Rectangle<int> getBounds (const bool global) const Rectangle<int> getBounds (const bool global) const
{ {
NSRect r = [view frame]; NSRect r = [view frame];
NSWindow* window = [view window];
NSWindow* viewWindow = [view window];
if (global && window != nil)
if (global && viewWindow != nil)
{ {
r = [[view superview] convertRect: r toView: nil]; r = [[view superview] convertRect: r toView: nil];
#if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
r = [window convertRectToScreen: r];
r = [viewWindow convertRectToScreen: r];
#else #else
r.origin = [window convertBaseToScreen: r.origin];
r.origin = [viewWindow convertBaseToScreen: r.origin];
#endif #endif
r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.origin.y - r.size.height; r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.origin.y - r.size.height;
@@ -396,9 +396,8 @@ public:
if (hasNativeTitleBar()) if (hasNativeTitleBar())
{ {
const Rectangle<int> screen (getFrameSize().subtractedFrom (component.getParentMonitorArea())); const Rectangle<int> screen (getFrameSize().subtractedFrom (component.getParentMonitorArea()));
const Rectangle<int> window (component.getScreenBounds());
fullScreen = window.expanded (2, 2).contains (screen);
fullScreen = component.getScreenBounds().expanded (2, 2).contains (screen);
} }
} }
@@ -1791,16 +1790,16 @@ void Desktop::createMouseInputSources()
} }
//============================================================================== //==============================================================================
void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars)
void Desktop::setKioskComponent (Component* kioskComp, bool enableOrDisable, bool allowMenusAndBars)
{ {
#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
NSViewComponentPeer* const peer = dynamic_cast<NSViewComponentPeer*> (kioskModeComponent->getPeer());
NSViewComponentPeer* const peer = dynamic_cast<NSViewComponentPeer*> (kioskComp->getPeer());
jassert (peer != nullptr); // (this should have been checked by the caller)
#if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (peer != nullptr
&& peer->hasNativeTitleBar()
&& [peer->window respondsToSelector: @selector (toggleFullScreen:)])
if (peer->hasNativeTitleBar()
&& [peer->window respondsToSelector: @selector (toggleFullScreen:)])
{ {
[peer->window performSelector: @selector (toggleFullScreen:) [peer->window performSelector: @selector (toggleFullScreen:)
withObject: [NSNumber numberWithBool: (BOOL) enableOrDisable]]; withObject: [NSNumber numberWithBool: (BOOL) enableOrDisable]];
@@ -1815,7 +1814,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis
[NSApp setPresentationOptions: (allowMenusAndBars ? (NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar) [NSApp setPresentationOptions: (allowMenusAndBars ? (NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)
: (NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar))]; : (NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar))];
kioskModeComponent->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea);
kioskComp->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea);
peer->becomeKeyWindow(); peer->becomeKeyWindow();
} }
else else
@@ -1833,7 +1832,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis
if (enableOrDisable) if (enableOrDisable)
{ {
SetSystemUIMode (kUIModeAllSuppressed, allowMenusAndBars ? kUIOptionAutoShowMenuBar : 0); SetSystemUIMode (kUIModeAllSuppressed, allowMenusAndBars ? kUIOptionAutoShowMenuBar : 0);
kioskModeComponent->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea);
kioskComp->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea);
} }
else else
{ {


+ 5
- 5
modules/juce_gui_basics/properties/juce_TextPropertyComponent.cpp View File

@@ -42,16 +42,16 @@ public:
TextEditor* createEditorComponent() TextEditor* createEditorComponent()
{ {
TextEditor* const textEditor = Label::createEditorComponent();
textEditor->setInputRestrictions (maxChars);
TextEditor* const ed = Label::createEditorComponent();
ed->setInputRestrictions (maxChars);
if (isMultiline) if (isMultiline)
{ {
textEditor->setMultiLine (true, true);
textEditor->setReturnKeyStartsNewLine (true);
ed->setMultiLine (true, true);
ed->setReturnKeyStartsNewLine (true);
} }
return textEditor;
return ed;
} }
void textWasEdited() void textWasEdited()


+ 3
- 3
modules/juce_gui_basics/widgets/juce_ComboBox.cpp View File

@@ -118,10 +118,10 @@ void ComboBox::addItem (const String& newItemText, const int newItemId)
} }
} }
void ComboBox::addItemList (const StringArray& items, const int firstItemIdOffset)
void ComboBox::addItemList (const StringArray& itemsToAdd, const int firstItemIdOffset)
{ {
for (int i = 0; i < items.size(); ++i)
addItem (items[i], i + firstItemIdOffset);
for (int i = 0; i < itemsToAdd.size(); ++i)
addItem (itemsToAdd[i], i + firstItemIdOffset);
} }
void ComboBox::addSeparator() void ComboBox::addSeparator()


+ 17
- 17
modules/juce_gui_basics/widgets/juce_ListBox.cpp View File

@@ -209,14 +209,14 @@ public:
void updateContents() void updateContents()
{ {
hasUpdated = true; hasUpdated = true;
const int rowHeight = owner.getRowHeight();
const int rowH = owner.getRowHeight();
if (rowHeight > 0)
if (rowH > 0)
{ {
const int y = getViewPositionY(); const int y = getViewPositionY();
const int w = getViewedComponent()->getWidth(); const int w = getViewedComponent()->getWidth();
const int numNeeded = 2 + getMaximumVisibleHeight() / rowHeight;
const int numNeeded = 2 + getMaximumVisibleHeight() / rowH;
rows.removeRange (numNeeded, rows.size()); rows.removeRange (numNeeded, rows.size());
while (numNeeded > rows.size()) while (numNeeded > rows.size())
@@ -226,9 +226,9 @@ public:
getViewedComponent()->addAndMakeVisible (newRow); getViewedComponent()->addAndMakeVisible (newRow);
} }
firstIndex = y / rowHeight;
firstWholeIndex = (y + rowHeight - 1) / rowHeight;
lastWholeIndex = (y + getMaximumVisibleHeight() - 1) / rowHeight;
firstIndex = y / rowH;
firstWholeIndex = (y + rowH - 1) / rowH;
lastWholeIndex = (y + getMaximumVisibleHeight() - 1) / rowH;
for (int i = 0; i < numNeeded; ++i) for (int i = 0; i < numNeeded; ++i)
{ {
@@ -237,7 +237,7 @@ public:
if (rowComp != nullptr) if (rowComp != nullptr)
{ {
rowComp->setBounds (0, row * rowHeight, w, rowHeight);
rowComp->setBounds (0, row * rowH, w, rowH);
rowComp->update (row, owner.isRowSelected (row)); rowComp->update (row, owner.isRowSelected (row));
} }
} }
@@ -251,30 +251,30 @@ public:
owner.headerComponent->getHeight()); owner.headerComponent->getHeight());
} }
void selectRow (const int row, const int rowHeight, const bool dontScroll,
const int lastRowSelected, const int totalItems, const bool isMouseClick)
void selectRow (const int row, const int rowH, const bool dontScroll,
const int lastSelectedRow, const int totalRows, const bool isMouseClick)
{ {
hasUpdated = false; hasUpdated = false;
if (row < firstWholeIndex && ! dontScroll) if (row < firstWholeIndex && ! dontScroll)
{ {
setViewPosition (getViewPositionX(), row * rowHeight);
setViewPosition (getViewPositionX(), row * rowH);
} }
else if (row >= lastWholeIndex && ! dontScroll) else if (row >= lastWholeIndex && ! dontScroll)
{ {
const int rowsOnScreen = lastWholeIndex - firstWholeIndex; const int rowsOnScreen = lastWholeIndex - firstWholeIndex;
if (row >= lastRowSelected + rowsOnScreen
&& rowsOnScreen < totalItems - 1
if (row >= lastSelectedRow + rowsOnScreen
&& rowsOnScreen < totalRows - 1
&& ! isMouseClick) && ! isMouseClick)
{ {
setViewPosition (getViewPositionX(), setViewPosition (getViewPositionX(),
jlimit (0, jmax (0, totalItems - rowsOnScreen), row) * rowHeight);
jlimit (0, jmax (0, totalRows - rowsOnScreen), row) * rowH);
} }
else else
{ {
setViewPosition (getViewPositionX(), setViewPosition (getViewPositionX(),
jmax (0, (row + 1) * rowHeight - getMaximumVisibleHeight()));
jmax (0, (row + 1) * rowH - getMaximumVisibleHeight()));
} }
} }
@@ -282,16 +282,16 @@ public:
updateContents(); updateContents();
} }
void scrollToEnsureRowIsOnscreen (const int row, const int rowHeight)
void scrollToEnsureRowIsOnscreen (const int row, const int rowH)
{ {
if (row < firstWholeIndex) if (row < firstWholeIndex)
{ {
setViewPosition (getViewPositionX(), row * rowHeight);
setViewPosition (getViewPositionX(), row * rowH);
} }
else if (row >= lastWholeIndex) else if (row >= lastWholeIndex)
{ {
setViewPosition (getViewPositionX(), setViewPosition (getViewPositionX(),
jmax (0, (row + 1) * rowHeight - getMaximumVisibleHeight()));
jmax (0, (row + 1) * rowH - getMaximumVisibleHeight()));
} }
} }


+ 15
- 23
modules/juce_gui_basics/widgets/juce_TableListBox.cpp View File

@@ -27,34 +27,31 @@ class TableListBox::RowComp : public Component,
public TooltipClient public TooltipClient
{ {
public: public:
RowComp (TableListBox& owner_)
: owner (owner_), row (-1), isSelected (false)
RowComp (TableListBox& tlb) : owner (tlb), row (-1), isSelected (false)
{ {
} }
void paint (Graphics& g) void paint (Graphics& g)
{ {
TableListBoxModel* const model = owner.getModel();
if (model != nullptr)
if (TableListBoxModel* const tableModel = owner.getModel())
{ {
model->paintRowBackground (g, row, getWidth(), getHeight(), isSelected);
tableModel->paintRowBackground (g, row, getWidth(), getHeight(), isSelected);
const TableHeaderComponent& header = owner.getHeader();
const int numColumns = header.getNumColumns (true);
const TableHeaderComponent& headerComp = owner.getHeader();
const int numColumns = headerComp.getNumColumns (true);
for (int i = 0; i < numColumns; ++i) for (int i = 0; i < numColumns; ++i)
{ {
if (columnComponents[i] == nullptr) if (columnComponents[i] == nullptr)
{ {
const int columnId = header.getColumnIdOfIndex (i, true);
const Rectangle<int> columnRect (header.getColumnPosition(i).withHeight (getHeight()));
const int columnId = headerComp.getColumnIdOfIndex (i, true);
const Rectangle<int> columnRect (headerComp.getColumnPosition(i).withHeight (getHeight()));
Graphics::ScopedSaveState ss (g); Graphics::ScopedSaveState ss (g);
g.reduceClipRegion (columnRect); g.reduceClipRegion (columnRect);
g.setOrigin (columnRect.getX(), 0); g.setOrigin (columnRect.getX(), 0);
model->paintCell (g, row, columnId, columnRect.getWidth(), columnRect.getHeight(), isSelected);
tableModel->paintCell (g, row, columnId, columnRect.getWidth(), columnRect.getHeight(), isSelected);
} }
} }
} }
@@ -71,9 +68,9 @@ public:
repaint(); repaint();
} }
TableListBoxModel* const model = owner.getModel();
TableListBoxModel* const tableModel = owner.getModel();
if (model != nullptr && row < owner.getNumRows())
if (tableModel != nullptr && row < owner.getNumRows())
{ {
const Identifier columnProperty ("_tableColumnId"); const Identifier columnProperty ("_tableColumnId");
const int numColumns = owner.getHeader().getNumColumns (true); const int numColumns = owner.getHeader().getNumColumns (true);
@@ -89,7 +86,7 @@ public:
comp = nullptr; comp = nullptr;
} }
comp = model->refreshComponentForCell (row, columnId, isSelected, comp);
comp = tableModel->refreshComponentForCell (row, columnId, isSelected, comp);
columnComponents.set (i, comp, false); columnComponents.set (i, comp, false);
if (comp != nullptr) if (comp != nullptr)
@@ -117,9 +114,7 @@ public:
void resizeCustomComp (const int index) void resizeCustomComp (const int index)
{ {
Component* const c = columnComponents.getUnchecked (index);
if (c != nullptr)
if (Component* const c = columnComponents.getUnchecked (index))
c->setBounds (owner.getHeader().getColumnPosition (index) c->setBounds (owner.getHeader().getColumnPosition (index)
.withY (0).withHeight (getHeight())); .withY (0).withHeight (getHeight()));
} }
@@ -216,10 +211,7 @@ private:
class TableListBox::Header : public TableHeaderComponent class TableListBox::Header : public TableHeaderComponent
{ {
public: public:
Header (TableListBox& owner_)
: owner (owner_)
{
}
Header (TableListBox& tlb) : owner (tlb) {}
void addMenuItems (PopupMenu& menu, int columnIdClicked) void addMenuItems (PopupMenu& menu, int columnIdClicked)
{ {
@@ -252,10 +244,10 @@ private:
}; };
//============================================================================== //==============================================================================
TableListBox::TableListBox (const String& name, TableListBoxModel* const model_)
TableListBox::TableListBox (const String& name, TableListBoxModel* const m)
: ListBox (name, nullptr), : ListBox (name, nullptr),
header (nullptr), header (nullptr),
model (model_),
model (m),
autoSizeOptionsShown (true) autoSizeOptionsShown (true)
{ {
ListBox::model = this; ListBox::model = this;


+ 39
- 39
modules/juce_gui_extra/code_editor/juce_CodeEditorComponent.cpp View File

@@ -30,41 +30,41 @@ public:
{ {
} }
bool update (CodeDocument& document, int lineNum,
bool update (CodeDocument& codeDoc, int lineNum,
CodeDocument::Iterator& source, CodeDocument::Iterator& source,
CodeTokeniser* tokeniser, const int spacesPerTab,
const CodeDocument::Position& selectionStart,
const CodeDocument::Position& selectionEnd)
CodeTokeniser* tokeniser, const int tabSpaces,
const CodeDocument::Position& selStart,
const CodeDocument::Position& selEnd)
{ {
Array <SyntaxToken> newTokens; Array <SyntaxToken> newTokens;
newTokens.ensureStorageAllocated (8); newTokens.ensureStorageAllocated (8);
if (tokeniser == nullptr) if (tokeniser == nullptr)
{ {
const String line (document.getLine (lineNum));
const String line (codeDoc.getLine (lineNum));
addToken (newTokens, line, line.length(), -1); addToken (newTokens, line, line.length(), -1);
} }
else if (lineNum < document.getNumLines())
else if (lineNum < codeDoc.getNumLines())
{ {
const CodeDocument::Position pos (document, lineNum, 0);
const CodeDocument::Position pos (codeDoc, lineNum, 0);
createTokens (pos.getPosition(), pos.getLineText(), createTokens (pos.getPosition(), pos.getLineText(),
source, *tokeniser, newTokens); source, *tokeniser, newTokens);
} }
replaceTabsWithSpaces (newTokens, spacesPerTab);
replaceTabsWithSpaces (newTokens, tabSpaces);
int newHighlightStart = 0; int newHighlightStart = 0;
int newHighlightEnd = 0; int newHighlightEnd = 0;
if (selectionStart.getLineNumber() <= lineNum && selectionEnd.getLineNumber() >= lineNum)
if (selStart.getLineNumber() <= lineNum && selEnd.getLineNumber() >= lineNum)
{ {
const String line (document.getLine (lineNum));
const String line (codeDoc.getLine (lineNum));
CodeDocument::Position lineStart (document, lineNum, 0), lineEnd (document, lineNum + 1, 0);
newHighlightStart = indexToColumn (jmax (0, selectionStart.getPosition() - lineStart.getPosition()),
line, spacesPerTab);
newHighlightEnd = indexToColumn (jmin (lineEnd.getPosition() - lineStart.getPosition(), selectionEnd.getPosition() - lineStart.getPosition()),
line, spacesPerTab);
CodeDocument::Position lineStart (codeDoc, lineNum, 0), lineEnd (codeDoc, lineNum + 1, 0);
newHighlightStart = indexToColumn (jmax (0, selStart.getPosition() - lineStart.getPosition()),
line, tabSpaces);
newHighlightEnd = indexToColumn (jmin (lineEnd.getPosition() - lineStart.getPosition(), selEnd.getPosition() - lineStart.getPosition()),
line, tabSpaces);
} }
if (newHighlightStart != highlightColumnStart || newHighlightEnd != highlightColumnEnd) if (newHighlightStart != highlightColumnStart || newHighlightEnd != highlightColumnEnd)
@@ -81,17 +81,17 @@ public:
return true; return true;
} }
void draw (CodeEditorComponent& owner, Graphics& g, const Font& font,
void draw (CodeEditorComponent& owner, Graphics& g, const Font& fontToUse,
const float leftClip, const float rightClip, const float leftClip, const float rightClip,
const float xOffset, const int y, const int baselineOffset,
const int lineHeight, const float charWidth,
const float x, const int y, const int baselineOffset,
const int lineH, const float characterWidth,
const Colour& highlightColour) const const Colour& highlightColour) const
{ {
if (highlightColumnStart < highlightColumnEnd) if (highlightColumnStart < highlightColumnEnd)
{ {
g.setColour (highlightColour); g.setColour (highlightColour);
g.fillRect (roundToInt (xOffset + highlightColumnStart * owner.getCharWidth()), y,
roundToInt ((highlightColumnEnd - highlightColumnStart) * owner.getCharWidth()), lineHeight);
g.fillRect (roundToInt (x + highlightColumnStart * characterWidth), y,
roundToInt ((highlightColumnEnd - highlightColumnStart) * characterWidth), lineH);
} }
const float baselineY = (float) (y + baselineOffset); const float baselineY = (float) (y + baselineOffset);
@@ -101,7 +101,7 @@ public:
for (int i = 0; i < tokens.size(); ++i) for (int i = 0; i < tokens.size(); ++i)
{ {
const float tokenX = xOffset + column * charWidth;
const float tokenX = x + column * characterWidth;
if (tokenX > rightClip) if (tokenX > rightClip)
break; break;
@@ -119,9 +119,9 @@ public:
column += token.length; column += token.length;
if (xOffset + column * charWidth >= leftClip)
ga.addCurtailedLineOfText (font, token.text, tokenX, baselineY,
(rightClip - tokenX) + charWidth, false);
if (x + column * characterWidth >= leftClip)
ga.addCurtailedLineOfText (fontToUse, token.text, tokenX, baselineY,
(rightClip - tokenX) + characterWidth, false);
} }
ga.draw (g); ga.draw (g);
@@ -207,7 +207,7 @@ private:
} }
} }
int indexToColumn (int index, const String& line, int spacesPerTab) const noexcept
int indexToColumn (int index, const String& line, int tabSpaces) const noexcept
{ {
jassert (index <= line.length()); jassert (index <= line.length());
@@ -218,7 +218,7 @@ private:
if (t.getAndAdvance() != '\t') if (t.getAndAdvance() != '\t')
++col; ++col;
else else
col += spacesPerTab - (col % spacesPerTab);
col += tabSpaces - (col % tabSpaces);
} }
return col; return col;
@@ -316,10 +316,10 @@ public:
.overlaidWith (editor.findColour (lineNumberBackgroundId))); .overlaidWith (editor.findColour (lineNumberBackgroundId)));
const Rectangle<int> clip (g.getClipBounds()); const Rectangle<int> clip (g.getClipBounds());
const int lineHeight = editor.lineHeight;
const float lineHeightFloat = (float) lineHeight;
const int firstLineToDraw = jmax (0, clip.getY() / lineHeight);
const int lastLineToDraw = jmin (editor.lines.size(), clip.getBottom() / lineHeight + 1,
const int lineH = editor.lineHeight;
const float lineHeightFloat = (float) lineH;
const int firstLineToDraw = jmax (0, clip.getY() / lineH);
const int lastLineToDraw = jmin (editor.lines.size(), clip.getBottom() / lineH + 1,
lastNumLines - editor.firstLineOnScreen); lastNumLines - editor.firstLineOnScreen);
const Font lineNumberFont (editor.getFont().withHeight (jmin (13.0f, lineHeightFloat * 0.8f))); const Font lineNumberFont (editor.getFont().withHeight (jmin (13.0f, lineHeightFloat * 0.8f)));
@@ -328,7 +328,7 @@ public:
GlyphArrangement ga; GlyphArrangement ga;
for (int i = firstLineToDraw; i < lastLineToDraw; ++i) for (int i = firstLineToDraw; i < lastLineToDraw; ++i)
ga.addFittedText (lineNumberFont, String (editor.firstLineOnScreen + i + 1), ga.addFittedText (lineNumberFont, String (editor.firstLineOnScreen + i + 1),
0, (float) (lineHeight * i), w, lineHeightFloat,
0, (float) (lineH * i), w, lineHeightFloat,
Justification::centredRight, 1, 0.2f); Justification::centredRight, 1, 0.2f);
g.setColour (editor.findColour (lineNumberTextId)); g.setColour (editor.findColour (lineNumberTextId));
@@ -481,8 +481,8 @@ void CodeEditorComponent::paint (Graphics& g)
g.fillAll (findColour (CodeEditorComponent::backgroundColourId)); g.fillAll (findColour (CodeEditorComponent::backgroundColourId));
const int gutter = getGutterSize();
g.reduceClipRegion (gutter, 0, verticalScrollBar.getX() - gutter, horizontalScrollBar.getY());
const int gutterSize = getGutterSize();
g.reduceClipRegion (gutterSize, 0, verticalScrollBar.getX() - gutterSize, horizontalScrollBar.getY());
g.setFont (font); g.setFont (font);
const int baselineOffset = (int) font.getAscent(); const int baselineOffset = (int) font.getAscent();
@@ -491,7 +491,7 @@ void CodeEditorComponent::paint (Graphics& g)
const Rectangle<int> clip (g.getClipBounds()); const Rectangle<int> clip (g.getClipBounds());
const int firstLineToDraw = jmax (0, clip.getY() / lineHeight); const int firstLineToDraw = jmax (0, clip.getY() / lineHeight);
const int lastLineToDraw = jmin (lines.size(), clip.getBottom() / lineHeight + 1); const int lastLineToDraw = jmin (lines.size(), clip.getBottom() / lineHeight + 1);
const float x = (float) (gutter - xOffset * charWidth);
const float x = (float) (gutterSize - xOffset * charWidth);
const float leftClip = (float) clip.getX(); const float leftClip = (float) clip.getX();
const float rightClip = (float) clip.getRight(); const float rightClip = (float) clip.getRight();
@@ -709,12 +709,12 @@ void CodeEditorComponent::scrollBy (int deltaLines)
scrollToLine (firstLineOnScreen + deltaLines); scrollToLine (firstLineOnScreen + deltaLines);
} }
void CodeEditorComponent::scrollToKeepLinesOnScreen (const Range<int>& lines)
void CodeEditorComponent::scrollToKeepLinesOnScreen (const Range<int>& rangeToShow)
{ {
if (lines.getStart() < firstLineOnScreen)
scrollBy (lines.getStart() - firstLineOnScreen);
else if (lines.getEnd() >= firstLineOnScreen + linesOnScreen)
scrollBy (lines.getEnd() - (firstLineOnScreen + linesOnScreen - 1));
if (rangeToShow.getStart() < firstLineOnScreen)
scrollBy (rangeToShow.getStart() - firstLineOnScreen);
else if (rangeToShow.getEnd() >= firstLineOnScreen + linesOnScreen)
scrollBy (rangeToShow.getEnd() - (firstLineOnScreen + linesOnScreen - 1));
} }
void CodeEditorComponent::scrollToKeepCaretOnScreen() void CodeEditorComponent::scrollToKeepCaretOnScreen()


+ 10
- 10
modules/juce_gui_extra/misc/juce_ColourSelector.cpp View File

@@ -167,17 +167,17 @@ public:
void paint (Graphics& g) void paint (Graphics& g)
{ {
const float w = (float) getWidth();
const float h = (float) getHeight();
const float cw = (float) getWidth();
const float ch = (float) getHeight();
Path p; Path p;
p.addTriangle (1.0f, 1.0f, p.addTriangle (1.0f, 1.0f,
w * 0.3f, h * 0.5f,
1.0f, h - 1.0f);
cw * 0.3f, ch * 0.5f,
1.0f, ch - 1.0f);
p.addTriangle (w - 1.0f, 1.0f,
w * 0.7f, h * 0.5f,
w - 1.0f, h - 1.0f);
p.addTriangle (cw - 1.0f, 1.0f,
cw * 0.7f, ch * 0.5f,
cw - 1.0f, ch - 1.0f);
g.setColour (Colours::white.withAlpha (0.75f)); g.setColour (Colours::white.withAlpha (0.75f));
g.fillPath (p); g.fillPath (p);
@@ -255,11 +255,11 @@ public:
void paint (Graphics& g) void paint (Graphics& g)
{ {
const Colour colour (owner.getSwatchColour (index));
const Colour c (owner.getSwatchColour (index));
g.fillCheckerBoard (getLocalBounds(), 6, 6, g.fillCheckerBoard (getLocalBounds(), 6, 6,
Colour (0xffdddddd).overlaidWith (colour),
Colour (0xffffffff).overlaidWith (colour));
Colour (0xffdddddd).overlaidWith (c),
Colour (0xffffffff).overlaidWith (c));
} }
void mouseDown (const MouseEvent&) void mouseDown (const MouseEvent&)


Loading…
Cancel
Save