Browse Source

Moved ImageButton painting into the LookAndFeel, added a couple of methods to AudioSampleBuffer, and fixed a compile error in VS2003

tags/2021-05-28
jules 16 years ago
parent
commit
2f5a2ad613
9 changed files with 303 additions and 56 deletions
  1. +0
    -8
      build/win32/vc6/JUCE.dsp
  2. +106
    -24
      juce_amalgamated.cpp
  3. +43
    -0
      juce_amalgamated.h
  4. +61
    -0
      src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp
  5. +37
    -0
      src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.h
  6. +12
    -22
      src/juce_appframework/gui/components/buttons/juce_ImageButton.cpp
  7. +26
    -0
      src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.cpp
  8. +8
    -0
      src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h
  9. +10
    -2
      src/juce_appframework/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp

+ 0
- 8
build/win32/vc6/JUCE.dsp View File

@@ -535,14 +535,6 @@ SOURCE=..\..\..\src\juce_appframework\audio\processors\juce_GenericAudioProcesso
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\src\juce_appframework\audio\plugins\formats\juce_AudioUnitPluginFormat.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\src\juce_appframework\audio\plugins\formats\juce_AudioUnitPluginFormat.h
# End Source File
# Begin Source File
SOURCE=..\..\..\src\juce_appframework\audio\plugins\formats\juce_DirectXPluginFormat.h
# End Source File
# Begin Source File


+ 106
- 24
juce_amalgamated.cpp View File

@@ -602,6 +602,7 @@
#import <IOKit/network/IONetworkInterface.h>
#import <IOKit/network/IOEthernetController.h>
#import <IOKit/pwr_mgt/IOPMLib.h>
#import <SystemConfiguration/SCDynamicStore.h>

#include <sys/sysctl.h>
#include <sys/stat.h>
@@ -23993,6 +23994,67 @@ void AudioSampleBuffer::copyFrom (const int destChannel,
}
}

void AudioSampleBuffer::copyFrom (const int destChannel,
const int destStartSample,
const float* source,
int numSamples,
const float gain) throw()
{
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (source != 0);

if (numSamples > 0 && gain != 0)
{
float* d = channels [destChannel] + destStartSample;

if (gain != 1.0f)
{
while (--numSamples >= 0)
*d++ = gain * *source++;
}
else
{
memcpy (d, source, sizeof (float) * numSamples);
}
}
}

void AudioSampleBuffer::copyFromWithRamp (const int destChannel,
const int destStartSample,
const float* source,
int numSamples,
float startGain,
float endGain) throw()
{
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (source != 0);

if (startGain == endGain)
{
copyFrom (destChannel,
destStartSample,
source,
numSamples,
startGain);
}
else
{
if (numSamples > 0 && (startGain != 0.0f || endGain != 0.0f))
{
const float increment = (endGain - startGain) / numSamples;
float* d = channels [destChannel] + destStartSample;

while (--numSamples >= 0)
{
*d++ = startGain * *source++;
startGain += increment;
}
}
}
}

void AudioSampleBuffer::findMinMax (const int channel,
const int startSample,
int numSamples,
@@ -42477,31 +42539,20 @@ void ImageButton::paintButton (Graphics& g,
}
}

const Colour& overlayColour = (isButtonDown) ? downOverlay
: ((isMouseOverButton) ? overOverlay
: normalOverlay);

if (! overlayColour.isOpaque())
if (! scaleImageToFit)
{
g.setOpacity ((isButtonDown) ? downOpacity
: ((isMouseOverButton) ? overOpacity
: normalOpacity));

if (scaleImageToFit)
g.drawImage (im, imageX, imageY, imageW, imageH, 0, 0, iw, ih, false);
else
g.drawImageAt (im, imageX, imageY, false);
imageW = iw;
imageH = ih;
}

if (! overlayColour.isTransparent())
{
g.setColour (overlayColour);

if (scaleImageToFit)
g.drawImage (im, imageX, imageY, imageW, imageH, 0, 0, iw, ih, true);
else
g.drawImageAt (im, imageX, imageY, true);
}
getLookAndFeel().drawImageButton (g, im, imageX, imageY, imageW, imageH,
isButtonDown ? downOverlay
: (isMouseOverButton ? overOverlay
: normalOverlay),
isButtonDown ? downOpacity
: (isMouseOverButton ? overOpacity
: normalOpacity),
*this);
}
}

@@ -61278,6 +61329,29 @@ void LookAndFeel::layoutFilenameComponent (FilenameComponent& filenameComp,
filenameBox->setBounds (0, 0, browseButton->getX(), filenameComp.getHeight());
}

void LookAndFeel::drawImageButton (Graphics& g, Image* image,
int imageX, int imageY, int imageW, int imageH,
const Colour& overlayColour,
float imageOpacity,
ImageButton& button)
{
if (! overlayColour.isOpaque())
{
g.setOpacity (imageOpacity);

g.drawImage (image, imageX, imageY, imageW, imageH,
0, 0, image->getWidth(), image->getHeight(), false);
}

if (! overlayColour.isTransparent())
{
g.setColour (overlayColour);

g.drawImage (image, imageX, imageY, imageW, imageH,
0, 0, image->getWidth(), image->getHeight(), true);
}
}

void LookAndFeel::drawCornerResizer (Graphics& g,
int w, int h,
bool /*isMouseOver*/,
@@ -213920,8 +213994,11 @@ namespace pnglibNamespace
using namespace zlibNamespace;

#if JUCE_INCLUDE_PNGLIB_CODE
using ::malloc;
using ::free;

#if (! defined(_MSC_VER)) || _MSC_VER != 1310
using ::malloc; // (causes conflict in VS.NET 2003)
using ::free;
#endif

extern "C"
{
@@ -239320,6 +239397,11 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row)
BEGIN_JUCE_NAMESPACE

using namespace pnglibNamespace;

#if defined (_MSC_VER) && _MSC_VER == 1310 && ! defined (JUCE_DEBUG)
using ::calloc; // (needed in VS.NET 2003)
#endif

using ::malloc;
using ::free;



+ 43
- 0
juce_amalgamated.h View File

@@ -26998,6 +26998,42 @@ public:
const float* source,
int numSamples) throw();

/** Copies samples from an array of floats into one of the channels, applying a gain to it.

@param destChannel the channel within this buffer to copy the samples to
@param destStartSample the start sample within this buffer's channel
@param source the source buffer to read from
@param numSamples the number of samples to process
@param gain the gain to apply

@see addFrom
*/
void copyFrom (const int destChannel,
const int destStartSample,
const float* source,
int numSamples,
const float gain) throw();

/** Copies samples from an array of floats into one of the channels, applying a gain ramp.

@param destChannel the channel within this buffer to copy the samples to
@param destStartSample the start sample within this buffer's channel
@param source the source buffer to read from
@param numSamples the number of samples to process
@param startGain the gain to apply to the first sample (this is multiplied with
the source samples before they are copied to this buffer)
@param endGain the gain to apply to the final sample. The gain is linearly
interpolated between the first and last samples.

@see addFrom
*/
void copyFromWithRamp (const int destChannel,
const int destStartSample,
const float* source,
int numSamples,
float startGain,
float endGain) throw();

/** Finds the highest and lowest sample values in a given range.

@param channel the channel to read from
@@ -52970,6 +53006,7 @@ class ProgressBar;
class FileBrowserComponent;
class DirectoryContentsDisplayComponent;
class FilePreviewComponent;
class ImageButton;

/**
LookAndFeel objects define the appearance of all the JUCE widgets, and subclasses
@@ -53415,6 +53452,12 @@ public:

virtual Button* createTabBarExtrasButton();

virtual void drawImageButton (Graphics& g, Image* image,
int imageX, int imageY, int imageW, int imageH,
const Colour& overlayColour,
float imageOpacity,
ImageButton& button);

virtual void drawTableHeaderBackground (Graphics& g, TableHeaderComponent& header);

virtual void drawTableHeaderColumn (Graphics& g, const String& columnName, int columnId,


+ 61
- 0
src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.cpp View File

@@ -453,6 +453,67 @@ void AudioSampleBuffer::copyFrom (const int destChannel,
}
}
void AudioSampleBuffer::copyFrom (const int destChannel,
const int destStartSample,
const float* source,
int numSamples,
const float gain) throw()
{
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (source != 0);
if (numSamples > 0 && gain != 0)
{
float* d = channels [destChannel] + destStartSample;
if (gain != 1.0f)
{
while (--numSamples >= 0)
*d++ = gain * *source++;
}
else
{
memcpy (d, source, sizeof (float) * numSamples);
}
}
}
void AudioSampleBuffer::copyFromWithRamp (const int destChannel,
const int destStartSample,
const float* source,
int numSamples,
float startGain,
float endGain) throw()
{
jassert (((unsigned int) destChannel) < (unsigned int) numChannels);
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (source != 0);
if (startGain == endGain)
{
copyFrom (destChannel,
destStartSample,
source,
numSamples,
startGain);
}
else
{
if (numSamples > 0 && (startGain != 0.0f || endGain != 0.0f))
{
const float increment = (endGain - startGain) / numSamples;
float* d = channels [destChannel] + destStartSample;
while (--numSamples >= 0)
{
*d++ = startGain * *source++;
startGain += increment;
}
}
}
}
void AudioSampleBuffer::findMinMax (const int channel,
const int startSample,
int numSamples,


+ 37
- 0
src/juce_appframework/audio/dsp/juce_AudioSampleBuffer.h View File

@@ -306,6 +306,43 @@ public:
const float* source,
int numSamples) throw();
/** Copies samples from an array of floats into one of the channels, applying a gain to it.
@param destChannel the channel within this buffer to copy the samples to
@param destStartSample the start sample within this buffer's channel
@param source the source buffer to read from
@param numSamples the number of samples to process
@param gain the gain to apply
@see addFrom
*/
void copyFrom (const int destChannel,
const int destStartSample,
const float* source,
int numSamples,
const float gain) throw();
/** Copies samples from an array of floats into one of the channels, applying a gain ramp.
@param destChannel the channel within this buffer to copy the samples to
@param destStartSample the start sample within this buffer's channel
@param source the source buffer to read from
@param numSamples the number of samples to process
@param startGain the gain to apply to the first sample (this is multiplied with
the source samples before they are copied to this buffer)
@param endGain the gain to apply to the final sample. The gain is linearly
interpolated between the first and last samples.
@see addFrom
*/
void copyFromWithRamp (const int destChannel,
const int destStartSample,
const float* source,
int numSamples,
float startGain,
float endGain) throw();
/** Finds the highest and lowest sample values in a given range.
@param channel the channel to read from


+ 12
- 22
src/juce_appframework/gui/components/buttons/juce_ImageButton.cpp View File

@@ -35,6 +35,7 @@ BEGIN_JUCE_NAMESPACE
#include "juce_ImageButton.h"
#include "../../graphics/imaging/juce_ImageCache.h"
#include "../lookandfeel/juce_LookAndFeel.h"
//==============================================================================
@@ -208,31 +209,20 @@ void ImageButton::paintButton (Graphics& g,
}
}
const Colour& overlayColour = (isButtonDown) ? downOverlay
: ((isMouseOverButton) ? overOverlay
: normalOverlay);
if (! overlayColour.isOpaque())
if (! scaleImageToFit)
{
g.setOpacity ((isButtonDown) ? downOpacity
: ((isMouseOverButton) ? overOpacity
: normalOpacity));
if (scaleImageToFit)
g.drawImage (im, imageX, imageY, imageW, imageH, 0, 0, iw, ih, false);
else
g.drawImageAt (im, imageX, imageY, false);
imageW = iw;
imageH = ih;
}
if (! overlayColour.isTransparent())
{
g.setColour (overlayColour);
if (scaleImageToFit)
g.drawImage (im, imageX, imageY, imageW, imageH, 0, 0, iw, ih, true);
else
g.drawImageAt (im, imageX, imageY, true);
}
getLookAndFeel().drawImageButton (g, im, imageX, imageY, imageW, imageH,
isButtonDown ? downOverlay
: (isMouseOverButton ? overOverlay
: normalOverlay),
isButtonDown ? downOpacity
: (isMouseOverButton ? overOpacity
: normalOpacity),
*this);
}
}


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

@@ -38,6 +38,7 @@ BEGIN_JUCE_NAMESPACE
#include "../buttons/juce_ToggleButton.h"
#include "../buttons/juce_ShapeButton.h"
#include "../buttons/juce_ArrowButton.h"
#include "../buttons/juce_ImageButton.h"
#include "../buttons/juce_DrawableButton.h"
#include "../buttons/juce_HyperlinkButton.h"
#include "../windows/juce_AlertWindow.h"
@@ -1619,6 +1620,31 @@ void LookAndFeel::layoutFilenameComponent (FilenameComponent& filenameComp,
filenameBox->setBounds (0, 0, browseButton->getX(), filenameComp.getHeight());
}
//==============================================================================
void LookAndFeel::drawImageButton (Graphics& g, Image* image,
int imageX, int imageY, int imageW, int imageH,
const Colour& overlayColour,
float imageOpacity,
ImageButton& button)
{
if (! overlayColour.isOpaque())
{
g.setOpacity (imageOpacity);
g.drawImage (image, imageX, imageY, imageW, imageH,
0, 0, image->getWidth(), image->getHeight(), false);
}
if (! overlayColour.isTransparent())
{
g.setColour (overlayColour);
g.drawImage (image, imageX, imageY, imageW, imageH,
0, 0, image->getWidth(), image->getHeight(), true);
}
}
//==============================================================================
void LookAndFeel::drawCornerResizer (Graphics& g,
int w, int h,


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

@@ -61,6 +61,7 @@ class ProgressBar;
class FileBrowserComponent;
class DirectoryContentsDisplayComponent;
class FilePreviewComponent;
class ImageButton;
//==============================================================================
@@ -534,6 +535,13 @@ public:
virtual Button* createTabBarExtrasButton();
//==============================================================================
virtual void drawImageButton (Graphics& g, Image* image,
int imageX, int imageY, int imageW, int imageH,
const Colour& overlayColour,
float imageOpacity,
ImageButton& button);
//==============================================================================
virtual void drawTableHeaderBackground (Graphics& g, TableHeaderComponent& header);


+ 10
- 2
src/juce_appframework/gui/graphics/imaging/image_file_formats/juce_PNGLoader.cpp View File

@@ -53,8 +53,11 @@ namespace pnglibNamespace
using namespace zlibNamespace;
#if JUCE_INCLUDE_PNGLIB_CODE
using ::malloc;
using ::free;
#if (! defined(_MSC_VER)) || _MSC_VER != 1310
using ::malloc; // (causes conflict in VS.NET 2003)
using ::free;
#endif
extern "C"
{
@@ -105,6 +108,11 @@ BEGIN_JUCE_NAMESPACE
#include "../../colour/juce_PixelFormats.h"
using namespace pnglibNamespace;
#if defined (_MSC_VER) && _MSC_VER == 1310 && ! defined (JUCE_DEBUG)
using ::calloc; // (needed in VS.NET 2003)
#endif
using ::malloc;
using ::free;


Loading…
Cancel
Save