Browse Source

Added an alertwindow font setting to the lookandfeel class. Made sure the ComponentListener::componentChildrenChanged is called when component z-order changes. Fix for CoreMidi output timestamps.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
e2ef26e91c
14 changed files with 124 additions and 105 deletions
  1. +5
    -5
      extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp
  2. +3
    -0
      extras/audio plugin host/Source/GraphEditorPanel.cpp
  3. +53
    -46
      juce_amalgamated.cpp
  4. +6
    -5
      juce_amalgamated.h
  5. +14
    -9
      src/audio/audio_sources/juce_ResamplingAudioSource.cpp
  6. +1
    -1
      src/core/juce_StandardHeader.h
  7. +29
    -32
      src/gui/components/juce_Component.cpp
  8. +2
    -1
      src/gui/components/juce_Component.h
  9. +5
    -0
      src/gui/components/lookandfeel/juce_LookAndFeel.cpp
  10. +1
    -0
      src/gui/components/lookandfeel/juce_LookAndFeel.h
  11. +1
    -1
      src/gui/components/windows/juce_AlertWindow.cpp
  12. +1
    -2
      src/gui/graphics/drawables/juce_DrawableComposite.h
  13. +1
    -1
      src/io/files/juce_File.h
  14. +2
    -2
      src/native/mac/juce_mac_CoreMidi.cpp

+ 5
- 5
extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp View File

@@ -362,22 +362,22 @@ JUCER_COMPONENT_METADATA_START
constructorParams="Project& project_" memberInitialisers="project (project_)">
<COMPONENTS>
<TABBEDCOMPONENT id="962c1575c4142253" memberName="configTabBox" focusOrder="0"
position="8, 0, configTabBox.left + parent.right - 16, configTabBox.top + parent.bottom - 36"/>
position="8, 0, this.left + parent.right - 16, this.top + parent.bottom - 36"/>
<TEXTBUTTON id="b6625dfcdb1f4755" memberName="editConfigsButton" focusOrder="0"
text="Add/Remove Configurations..." createCallback="1" radioGroup="0"
connectedLeft="0" connectedRight="0" connectedTop="0" connectedBottom="0"
backgroundColour="" textColour="" backgroundColourOn="" textColourOn=""
position="8, parent.bottom - 30, editConfigsButton.left + 192, editConfigsButton.top + 22"/>
position="8, parent.bottom - 30, this.left + 192, this.top + 22"/>
<TEXTBUTTON id="a550a652e2666ee7" memberName="openProjectButton" focusOrder="0"
text="Open Project in " createCallback="1" radioGroup="0" connectedLeft="0"
connectedRight="0" connectedTop="0" connectedBottom="0" backgroundColour=""
textColour="" backgroundColourOn="" textColourOn="" position="608, parent.bottom - 30, openProjectButton.left + 208, openProjectButton.top + 22"/>
textColour="" backgroundColourOn="" textColourOn="" position="608, parent.bottom - 30, this.left + 208, this.top + 22"/>
<TEXTBUTTON id="c1f6e5f9811b307e" memberName="editExportersButton" focusOrder="0"
text="Add/Remove Exporters..." createCallback="1" radioGroup="0"
connectedLeft="0" connectedRight="0" connectedTop="0" connectedBottom="0"
backgroundColour="" textColour="" backgroundColourOn="" textColourOn=""
position="208, parent.bottom - 30, editExportersButton.left + 160, editExportersButton.top + 22"/>
<TEXTBUTTON id="dRGMyYx" name="" memberName="saveAndOpenButton" position="391, parent.bottom - 30, saveAndOpenButton.left + 208, saveAndOpenButton.top + 22"
position="208, parent.bottom - 30, this.left + 160, this.top + 22"/>
<TEXTBUTTON id="dRGMyYx" name="" memberName="saveAndOpenButton" position="391, parent.bottom - 30, this.left + 208, this.top + 22"
text="Save And Open in" createCallback="1" radioGroup="0" connectedLeft="0"
connectedRight="0" connectedTop="0" connectedBottom="0"/>
</COMPONENTS>


+ 3
- 0
extras/audio plugin host/Source/GraphEditorPanel.cpp View File

@@ -1026,6 +1026,7 @@ GraphDocumentComponent::GraphDocumentComponent (AudioDeviceManager* deviceManage
addAndMakeVisible (statusBar = new TooltipBar());
deviceManager->addAudioCallback (&graphPlayer);
deviceManager->addMidiInputCallback (String::empty, &graphPlayer.getMidiMessageCollector());
graphPanel->updateComponents();
}
@@ -1033,6 +1034,8 @@ GraphDocumentComponent::GraphDocumentComponent (AudioDeviceManager* deviceManage
GraphDocumentComponent::~GraphDocumentComponent()
{
deviceManager->removeAudioCallback (&graphPlayer);
deviceManager->removeMidiInputCallback (String::empty, &graphPlayer.getMidiMessageCollector());
deleteAllChildren();
graphPlayer.setProcessor (0);


+ 53
- 46
juce_amalgamated.cpp View File

@@ -24896,15 +24896,20 @@ void ResamplingAudioSource::releaseResources()

void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info)
{
const ScopedLock sl (ratioLock);
float localRatio;

{
const ScopedLock sl (ratioLock);
localRatio = ratio;
}

if (lastRatio != ratio)
if (lastRatio != localRatio)
{
createLowPass (ratio);
lastRatio = ratio;
createLowPass (localRatio);
lastRatio = localRatio;
}

const int sampsNeeded = roundToInt (info.numSamples * ratio) + 2;
const int sampsNeeded = roundToInt (info.numSamples * localRatio) + 2;

int bufferSize = buffer.getNumSamples();

@@ -24934,7 +24939,7 @@ void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& inf

input->getNextAudioBlock (readInfo);

if (ratio > 1.0001)
if (localRatio > 1.0001)
{
// for down-sampling, pre-apply the filter..

@@ -24961,7 +24966,7 @@ void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& inf
for (int channel = 0; channel < channelsToProcess; ++channel)
*destBuffers[channel]++ = srcBuffers[channel][bufferPos] * invAlpha + srcBuffers[channel][nextPos] * alpha;

subSampleOffset += ratio;
subSampleOffset += localRatio;

jassert (sampsInBuffer > 0);

@@ -24977,13 +24982,13 @@ void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& inf
}
}

if (ratio < 0.9999)
if (localRatio < 0.9999)
{
// for up-sampling, apply the filter after transposing..
for (int i = channelsToProcess; --i >= 0;)
applyFilter (info.buffer->getSampleData (i, info.startSample), info.numSamples, filterStates[i]);
}
else if (ratio <= 1.0001)
else if (localRatio <= 1.0001)
{
// if the filter's not currently being applied, keep it stoked with the last couple of samples to avoid discontinuities
for (int i = channelsToProcess; --i >= 0;)
@@ -40241,6 +40246,21 @@ void Component::setBufferedToImage (const bool shouldBeBuffered)
}
}

void Component::moveChildInternal (const int sourceIndex, const int destIndex)
{
if (sourceIndex != destIndex)
{
Component* const c = childComponentList.getUnchecked (sourceIndex);
jassert (c != 0);
c->repaintParent();

childComponentList.move (sourceIndex, destIndex);

sendFakeMouseMove();
internalChildrenChanged();
}
}

void Component::toFront (const bool setAsForeground)
{
// if component methods are being called from threads other than the message
@@ -40261,7 +40281,7 @@ void Component::toFront (const bool setAsForeground)
}
else if (parentComponent != 0)
{
Array<Component*>& childList = parentComponent->childComponentList;
const Array<Component*>& childList = parentComponent->childComponentList;

if (childList.getLast() != this)
{
@@ -40279,13 +40299,7 @@ void Component::toFront (const bool setAsForeground)
--insertIndex;
}

if (index != insertIndex)
{
childList.move (index, insertIndex);
sendFakeMouseMove();

repaintParent();
}
parentComponent->moveChildInternal (index, insertIndex);
}
}

@@ -40306,8 +40320,7 @@ void Component::toBehind (Component* const other)

if (parentComponent != 0)
{
Array<Component*>& childList = parentComponent->childComponentList;

const Array<Component*>& childList = parentComponent->childComponentList;
const int index = childList.indexOf (this);

if (index >= 0 && childList [index + 1] != other)
@@ -40319,10 +40332,7 @@ void Component::toBehind (Component* const other)
if (index < otherIndex)
--otherIndex;

childList.move (index, otherIndex);

sendFakeMouseMove();
repaintParent();
parentComponent->moveChildInternal (index, otherIndex);
}
}
}
@@ -40345,35 +40355,27 @@ void Component::toBehind (Component* const other)

void Component::toBack()
{
Array<Component*>& childList = parentComponent->childComponentList;

if (isOnDesktop())
{
jassertfalse; //xxx need to add this to native window
}
else if (parentComponent != 0 && childList.getFirst() != this)
else if (parentComponent != 0)
{
const int index = childList.indexOf (this);
const Array<Component*>& childList = parentComponent->childComponentList;

if (index > 0)
if (childList.getFirst() != this)
{
int insertIndex = 0;
const int index = childList.indexOf (this);

if (flags.alwaysOnTopFlag)
if (index > 0)
{
while (insertIndex < childList.size()
&& ! childList.getUnchecked (insertIndex)->isAlwaysOnTop())
{
++insertIndex;
}
}
int insertIndex = 0;

if (index != insertIndex)
{
childList.move (index, insertIndex);
if (flags.alwaysOnTopFlag)
while (insertIndex < childList.size() && ! childList.getUnchecked (insertIndex)->isAlwaysOnTop())
++insertIndex;

sendFakeMouseMove();
repaintParent();
parentComponent->moveChildInternal (index, insertIndex);
}
}
}
@@ -65444,6 +65446,11 @@ int LookAndFeel::getAlertWindowButtonHeight()
return 28;
}

const Font LookAndFeel::getAlertWindowMessageFont()
{
return Font (15.0f);
}

const Font LookAndFeel::getAlertWindowFont()
{
return Font (12.0f);
@@ -76484,7 +76491,7 @@ void AlertWindow::setMessage (const String& message)
{
text = newMessage;

font.setHeight (15.0f);
font = getLookAndFeel().getAlertWindowMessageFont();

Font titleFont (font.getHeight() * 1.1f, Font::bold);
textLayout.setText (getName() + "\n\n", titleFont);
@@ -270305,7 +270312,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message)

for (int i = 0; i < numPackets; ++i)
{
p->timeStamp = 0;
p->timeStamp = AudioGetCurrentHostTime();
p->length = jmin (maxPacketSize, bytesLeft);
memcpy (p->data, message.getRawData() + pos, p->length);
pos += p->length;
@@ -270319,7 +270326,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message)
{
MIDIPacketList packets;
packets.numPackets = 1;
packets.packet[0].timeStamp = 0;
packets.packet[0].timeStamp = AudioGetCurrentHostTime();
packets.packet[0].length = message.getRawDataSize();
*(int*) (packets.packet[0].data) = *(const int*) message.getRawData();

@@ -278808,7 +278815,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message)

for (int i = 0; i < numPackets; ++i)
{
p->timeStamp = 0;
p->timeStamp = AudioGetCurrentHostTime();
p->length = jmin (maxPacketSize, bytesLeft);
memcpy (p->data, message.getRawData() + pos, p->length);
pos += p->length;
@@ -278822,7 +278829,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message)
{
MIDIPacketList packets;
packets.numPackets = 1;
packets.packet[0].timeStamp = 0;
packets.packet[0].timeStamp = AudioGetCurrentHostTime();
packets.packet[0].length = message.getRawDataSize();
*(int*) (packets.packet[0].data) = *(const int*) message.getRawData();



+ 6
- 5
juce_amalgamated.h View File

@@ -73,7 +73,7 @@ namespace JuceDummyNamespace {}
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 7
#define JUCE_BUILDNUMBER 8

/** Current Juce version number.

@@ -9459,7 +9459,7 @@ public:
the file first and then re-writing it, it creates a new temporary file,
writes the data to that, and then moves the new file to replace the existing
file. This means that if the power gets pulled out or something crashes,
you're a lot less likely to end up with an empty file..
you're a lot less likely to end up with a corrupted or unfinished file..

Returns true if the operation succeeds, or false if it fails.

@@ -29038,7 +29038,8 @@ private:
void internalModifierKeysChanged();
void internalChildrenChanged();
void internalHierarchyChanged();
Component* removeChildComponent (const int index, bool sendParentEvents, bool sendChildEvents);
Component* removeChildComponent (int index, bool sendParentEvents, bool sendChildEvents);
void moveChildInternal (int sourceIndex, int destIndex);
void paintComponentAndChildren (Graphics& g);
void paintComponent (Graphics& g);
void paintWithinParentContext (Graphics& g);
@@ -56179,6 +56180,7 @@ public:

virtual int getAlertWindowButtonHeight();

virtual const Font getAlertWindowMessageFont();
virtual const Font getAlertWindowFont();

/** Draws a progress bar.
@@ -61769,8 +61771,7 @@ protected:

@see Drawable
*/
class JUCE_API DrawableComposite : public Drawable//,
// public Expression::EvaluationContext
class JUCE_API DrawableComposite : public Drawable
{
public:



+ 14
- 9
src/audio/audio_sources/juce_ResamplingAudioSource.cpp View File

@@ -88,15 +88,20 @@ void ResamplingAudioSource::releaseResources()
void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& info)
{
const ScopedLock sl (ratioLock);
float localRatio;
{
const ScopedLock sl (ratioLock);
localRatio = ratio;
}
if (lastRatio != ratio)
if (lastRatio != localRatio)
{
createLowPass (ratio);
lastRatio = ratio;
createLowPass (localRatio);
lastRatio = localRatio;
}
const int sampsNeeded = roundToInt (info.numSamples * ratio) + 2;
const int sampsNeeded = roundToInt (info.numSamples * localRatio) + 2;
int bufferSize = buffer.getNumSamples();
@@ -126,7 +131,7 @@ void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& inf
input->getNextAudioBlock (readInfo);
if (ratio > 1.0001)
if (localRatio > 1.0001)
{
// for down-sampling, pre-apply the filter..
@@ -153,7 +158,7 @@ void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& inf
for (int channel = 0; channel < channelsToProcess; ++channel)
*destBuffers[channel]++ = srcBuffers[channel][bufferPos] * invAlpha + srcBuffers[channel][nextPos] * alpha;
subSampleOffset += ratio;
subSampleOffset += localRatio;
jassert (sampsInBuffer > 0);
@@ -169,13 +174,13 @@ void ResamplingAudioSource::getNextAudioBlock (const AudioSourceChannelInfo& inf
}
}
if (ratio < 0.9999)
if (localRatio < 0.9999)
{
// for up-sampling, apply the filter after transposing..
for (int i = channelsToProcess; --i >= 0;)
applyFilter (info.buffer->getSampleData (i, info.startSample), info.numSamples, filterStates[i]);
}
else if (ratio <= 1.0001)
else if (localRatio <= 1.0001)
{
// if the filter's not currently being applied, keep it stoked with the last couple of samples to avoid discontinuities
for (int i = channelsToProcess; --i >= 0;)


+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 7
#define JUCE_BUILDNUMBER 8
/** Current Juce version number.


+ 29
- 32
src/gui/components/juce_Component.cpp View File

@@ -732,6 +732,21 @@ void Component::setBufferedToImage (const bool shouldBeBuffered)
}
//==============================================================================
void Component::moveChildInternal (const int sourceIndex, const int destIndex)
{
if (sourceIndex != destIndex)
{
Component* const c = childComponentList.getUnchecked (sourceIndex);
jassert (c != 0);
c->repaintParent();
childComponentList.move (sourceIndex, destIndex);
sendFakeMouseMove();
internalChildrenChanged();
}
}
void Component::toFront (const bool setAsForeground)
{
// if component methods are being called from threads other than the message
@@ -752,7 +767,7 @@ void Component::toFront (const bool setAsForeground)
}
else if (parentComponent != 0)
{
Array<Component*>& childList = parentComponent->childComponentList;
const Array<Component*>& childList = parentComponent->childComponentList;
if (childList.getLast() != this)
{
@@ -770,13 +785,7 @@ void Component::toFront (const bool setAsForeground)
--insertIndex;
}
if (index != insertIndex)
{
childList.move (index, insertIndex);
sendFakeMouseMove();
repaintParent();
}
parentComponent->moveChildInternal (index, insertIndex);
}
}
@@ -797,8 +806,7 @@ void Component::toBehind (Component* const other)
if (parentComponent != 0)
{
Array<Component*>& childList = parentComponent->childComponentList;
const Array<Component*>& childList = parentComponent->childComponentList;
const int index = childList.indexOf (this);
if (index >= 0 && childList [index + 1] != other)
@@ -810,10 +818,7 @@ void Component::toBehind (Component* const other)
if (index < otherIndex)
--otherIndex;
childList.move (index, otherIndex);
sendFakeMouseMove();
repaintParent();
parentComponent->moveChildInternal (index, otherIndex);
}
}
}
@@ -836,35 +841,27 @@ void Component::toBehind (Component* const other)
void Component::toBack()
{
Array<Component*>& childList = parentComponent->childComponentList;
if (isOnDesktop())
{
jassertfalse; //xxx need to add this to native window
}
else if (parentComponent != 0 && childList.getFirst() != this)
else if (parentComponent != 0)
{
const int index = childList.indexOf (this);
const Array<Component*>& childList = parentComponent->childComponentList;
if (index > 0)
if (childList.getFirst() != this)
{
int insertIndex = 0;
const int index = childList.indexOf (this);
if (flags.alwaysOnTopFlag)
if (index > 0)
{
while (insertIndex < childList.size()
&& ! childList.getUnchecked (insertIndex)->isAlwaysOnTop())
{
++insertIndex;
}
}
int insertIndex = 0;
if (index != insertIndex)
{
childList.move (index, insertIndex);
if (flags.alwaysOnTopFlag)
while (insertIndex < childList.size() && ! childList.getUnchecked (insertIndex)->isAlwaysOnTop())
++insertIndex;
sendFakeMouseMove();
repaintParent();
parentComponent->moveChildInternal (index, insertIndex);
}
}
}


+ 2
- 1
src/gui/components/juce_Component.h View File

@@ -2239,7 +2239,8 @@ private:
void internalModifierKeysChanged();
void internalChildrenChanged();
void internalHierarchyChanged();
Component* removeChildComponent (const int index, bool sendParentEvents, bool sendChildEvents);
Component* removeChildComponent (int index, bool sendParentEvents, bool sendChildEvents);
void moveChildInternal (int sourceIndex, int destIndex);
void paintComponentAndChildren (Graphics& g);
void paintComponent (Graphics& g);
void paintWithinParentContext (Graphics& g);


+ 5
- 0
src/gui/components/lookandfeel/juce_LookAndFeel.cpp View File

@@ -685,6 +685,11 @@ int LookAndFeel::getAlertWindowButtonHeight()
return 28;
}
const Font LookAndFeel::getAlertWindowMessageFont()
{
return Font (15.0f);
}
const Font LookAndFeel::getAlertWindowFont()
{
return Font (12.0f);


+ 1
- 0
src/gui/components/lookandfeel/juce_LookAndFeel.h View File

@@ -199,6 +199,7 @@ public:
virtual int getAlertWindowButtonHeight();
virtual const Font getAlertWindowMessageFont();
virtual const Font getAlertWindowFont();
/** Draws a progress bar.


+ 1
- 1
src/gui/components/windows/juce_AlertWindow.cpp View File

@@ -125,7 +125,7 @@ void AlertWindow::setMessage (const String& message)
{
text = newMessage;
font.setHeight (15.0f);
font = getLookAndFeel().getAlertWindowMessageFont();
Font titleFont (font.getHeight() * 1.1f, Font::bold);
textLayout.setText (getName() + "\n\n", titleFont);


+ 1
- 2
src/gui/graphics/drawables/juce_DrawableComposite.h View File

@@ -38,8 +38,7 @@
@see Drawable
*/
class JUCE_API DrawableComposite : public Drawable//,
// public Expression::EvaluationContext
class JUCE_API DrawableComposite : public Drawable
{
public:
//==============================================================================


+ 1
- 1
src/io/files/juce_File.h View File

@@ -624,7 +624,7 @@ public:
the file first and then re-writing it, it creates a new temporary file,
writes the data to that, and then moves the new file to replace the existing
file. This means that if the power gets pulled out or something crashes,
you're a lot less likely to end up with an empty file..
you're a lot less likely to end up with a corrupted or unfinished file..
Returns true if the operation succeeds, or false if it fails.


+ 2
- 2
src/native/mac/juce_mac_CoreMidi.cpp View File

@@ -399,7 +399,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message)
for (int i = 0; i < numPackets; ++i)
{
p->timeStamp = 0;
p->timeStamp = AudioGetCurrentHostTime();
p->length = jmin (maxPacketSize, bytesLeft);
memcpy (p->data, message.getRawData() + pos, p->length);
pos += p->length;
@@ -413,7 +413,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message)
{
MIDIPacketList packets;
packets.numPackets = 1;
packets.packet[0].timeStamp = 0;
packets.packet[0].timeStamp = AudioGetCurrentHostTime();
packets.packet[0].length = message.getRawDataSize();
*(int*) (packets.packet[0].data) = *(const int*) message.getRawData();


Loading…
Cancel
Save