mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-19 01:04:20 +00:00
Major change to the way the Image class works, making it use value semantics and internally shared data (see the forum notes for more info on this). Also minor changes to win32 browser plugin object ref counting and linux millisecond timers.
This commit is contained in:
parent
1baaa016bd
commit
24673283eb
121 changed files with 2763 additions and 2930 deletions
|
|
@ -144,6 +144,7 @@
|
|||
#include "../src/threads/juce_Thread.cpp"
|
||||
#include "../src/threads/juce_ThreadPool.cpp"
|
||||
#include "../src/threads/juce_TimeSliceThread.cpp"
|
||||
#include "../src/utilities/juce_DeletedAtShutdown.cpp"
|
||||
#endif
|
||||
|
||||
#if JUCE_BUILD_MISC
|
||||
|
|
@ -154,7 +155,6 @@
|
|||
#include "../src/application/juce_ApplicationCommandManager.cpp"
|
||||
#include "../src/application/juce_ApplicationCommandTarget.cpp"
|
||||
#include "../src/application/juce_ApplicationProperties.cpp"
|
||||
#include "../src/utilities/juce_DeletedAtShutdown.cpp"
|
||||
#include "../src/utilities/juce_PropertiesFile.cpp"
|
||||
#include "../src/utilities/juce_FileBasedDocument.cpp"
|
||||
#include "../src/utilities/juce_RecentlyOpenedFilesList.cpp"
|
||||
|
|
|
|||
|
|
@ -275,12 +275,12 @@ const ValueTree DrawableDocument::performNewItemMenuItem (int menuResultCode)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
Image* DrawableDocument::getImageForIdentifier (const var& imageIdentifier)
|
||||
const Image DrawableDocument::getImageForIdentifier (const var& imageIdentifier)
|
||||
{
|
||||
return ImageCache::getFromMemory (BinaryData::juce_icon_png, BinaryData::juce_icon_pngSize);
|
||||
}
|
||||
|
||||
const var DrawableDocument::getIdentifierForImage (Image* image)
|
||||
const var DrawableDocument::getIdentifierForImage (const Image& image)
|
||||
{
|
||||
return var::null; //xxx todo
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ public:
|
|||
const String getNonexistentMarkerName (const String& name);
|
||||
void renameAnchor (const String& oldName, const String& newName);
|
||||
|
||||
Image* getImageForIdentifier (const var& imageIdentifier);
|
||||
const var getIdentifierForImage (Image* image);
|
||||
const Image getImageForIdentifier (const var& imageIdentifier);
|
||||
const var getIdentifierForImage (const Image& image);
|
||||
|
||||
//==============================================================================
|
||||
void valueTreePropertyChanged (ValueTree& tree, const Identifier& name);
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ bool Project::Item::addFile (const File& file, int insertIndex)
|
|||
return true;
|
||||
}
|
||||
|
||||
Image* Project::Item::getIcon() const
|
||||
const Image Project::Item::getIcon() const
|
||||
{
|
||||
if (isFile())
|
||||
return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage();
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public:
|
|||
|
||||
Item getParent() const;
|
||||
|
||||
Image* getIcon() const;
|
||||
const Image getIcon() const;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace ComponentEditorTreeView
|
|||
const String getDisplayName() const { return getRenamingName(); }
|
||||
const String getRenamingName() const { return componentState [ComponentDocument::memberNameProperty]; }
|
||||
|
||||
Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage(); }
|
||||
const Image getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage(); }
|
||||
|
||||
const String getDragSourceDescription() { return getDragIdFor (editor); }
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ namespace ComponentEditorTreeView
|
|||
|
||||
const String getDisplayName() const { return getRenamingName(); }
|
||||
const String getRenamingName() const { return "Components"; }
|
||||
Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); }
|
||||
const Image getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); }
|
||||
const String getDragSourceDescription() { return String::empty; }
|
||||
|
||||
bool isInterestedInDragSource (const String& sourceDescription, Component* sourceComponent)
|
||||
|
|
@ -299,7 +299,7 @@ namespace ComponentEditorTreeView
|
|||
const String getDisplayName() const { return getRenamingName(); }
|
||||
const String getRenamingName() const { return markerState [MarkerListBase::getMarkerNameProperty()]; }
|
||||
|
||||
Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage(); }
|
||||
const Image getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage(); }
|
||||
|
||||
const String getDragSourceDescription() { return String::empty; }
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ namespace ComponentEditorTreeView
|
|||
|
||||
const String getDisplayName() const { return getRenamingName(); }
|
||||
const String getRenamingName() const { return isX ? "Markers (X-axis)" : "Markers (Y-axis)"; }
|
||||
Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); }
|
||||
const Image getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); }
|
||||
const String getDragSourceDescription() { return String::empty; }
|
||||
|
||||
private:
|
||||
|
|
@ -388,7 +388,7 @@ namespace ComponentEditorTreeView
|
|||
|
||||
const String getDisplayName() const { return getRenamingName(); }
|
||||
const String getRenamingName() const { return editor.getDocument().getClassName().toString(); }
|
||||
Image* getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); }
|
||||
const Image getIcon() const { return LookAndFeel::getDefaultLookAndFeel().getDefaultFolderImage(); }
|
||||
const String getDragSourceDescription() { return String::empty; }
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public:
|
|||
|
||||
bool isMissing() { return false; }
|
||||
|
||||
Image* getIcon() const
|
||||
const Image getIcon() const
|
||||
{
|
||||
return LookAndFeel::getDefaultLookAndFeel().getDefaultDocumentFileImage();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -454,9 +454,15 @@ public:
|
|||
{
|
||||
lasso->dragLasso (e);
|
||||
}
|
||||
else if (mouseDownCompUID.isNotEmpty() && (! e.mouseWasClicked()) && (! e.mods.isPopupMenu()))
|
||||
else
|
||||
{
|
||||
if (! isDraggingClickedComp)
|
||||
if ((! isDraggingClickedComp)
|
||||
&& mouseDownCompUID.isNotEmpty()
|
||||
&& (! e.mouseWasClicked())
|
||||
&& (! e.mods.isPopupMenu())
|
||||
&& e.getDistanceFromDragStart() > 7) // whenever this drag occurs, it's selecting the object
|
||||
// and beginning a drag, so allow for more wobble than
|
||||
// when when dragging an already-selected object
|
||||
{
|
||||
isDraggingClickedComp = true;
|
||||
canvas->enableResizingMode();
|
||||
|
|
@ -464,8 +470,11 @@ public:
|
|||
canvas->beginDrag (e.withNewPosition (e.getMouseDownPosition()), ResizableBorderComponent::Zone (ResizableBorderComponent::Zone::centre));
|
||||
}
|
||||
|
||||
canvas->continueDrag (e);
|
||||
showSizeGuides();
|
||||
if (isDraggingClickedComp)
|
||||
{
|
||||
canvas->continueDrag (e);
|
||||
showSizeGuides();
|
||||
}
|
||||
}
|
||||
|
||||
autoScrollForMouseEvent (e);
|
||||
|
|
|
|||
|
|
@ -190,10 +190,9 @@ private:
|
|||
|
||||
void paint (Graphics& g)
|
||||
{
|
||||
Image* im = ImageCache::getFromMemory (BinaryData::brushed_aluminium_png, BinaryData::brushed_aluminium_pngSize);
|
||||
g.setTiledImageFill (*im, 0, 0, 1.0f);
|
||||
g.setTiledImageFill (ImageCache::getFromMemory (BinaryData::brushed_aluminium_png, BinaryData::brushed_aluminium_pngSize),
|
||||
0, 0, 1.0f);
|
||||
g.fillAll();
|
||||
ImageCache::release (im);
|
||||
}
|
||||
|
||||
void paintOverChildren (Graphics& g)
|
||||
|
|
|
|||
|
|
@ -97,16 +97,9 @@ public:
|
|||
void paint (Graphics& g)
|
||||
{
|
||||
int x = getHeight() + 6;
|
||||
Image* icon = item.getIcon();
|
||||
|
||||
if (icon != 0)
|
||||
{
|
||||
g.drawImageWithin (icon, 2, 2, x - 4, getHeight() - 4,
|
||||
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
|
||||
false);
|
||||
|
||||
ImageCache::release (icon);
|
||||
}
|
||||
g.drawImageWithin (item.getIcon(), 2, 2, x - 4, getHeight() - 4,
|
||||
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
|
||||
false);
|
||||
|
||||
g.setColour (Colours::black);
|
||||
g.setFont (getHeight() * 0.6f);
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ void ItemPreviewComponent::tryToLoadImage (InputStream* in)
|
|||
|
||||
image = ImageFileFormat::loadFrom (*input);
|
||||
|
||||
if (image != 0)
|
||||
facts.add (String (image->getWidth()) + " x " + String (image->getHeight()) + formatName);
|
||||
if (image.isValid())
|
||||
facts.add (String (image.getWidth()) + " x " + String (image.getHeight()) + formatName);
|
||||
|
||||
const int64 totalSize = input->getTotalLength();
|
||||
|
||||
|
|
@ -73,19 +73,14 @@ void ItemPreviewComponent::tryToLoadImage (InputStream* in)
|
|||
|
||||
void ItemPreviewComponent::paint (Graphics& g)
|
||||
{
|
||||
if (image != 0)
|
||||
{
|
||||
g.drawImageWithin (image,
|
||||
2, 22, getWidth() - 4, getHeight() - 24,
|
||||
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
|
||||
false);
|
||||
}
|
||||
g.drawImageWithin (image, 2, 22, getWidth() - 4, getHeight() - 24,
|
||||
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
|
||||
false);
|
||||
|
||||
g.setFont (15.0f, Font::bold);
|
||||
g.setColour (Colours::white);
|
||||
g.drawMultiLineText (facts.joinIntoString ("\n"),
|
||||
10, 15, getWidth() - 16);
|
||||
|
||||
}
|
||||
|
||||
void ItemPreviewComponent::resized()
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public:
|
|||
private:
|
||||
StringArray facts;
|
||||
File file;
|
||||
ScopedPointer <Image> image;
|
||||
Image image;
|
||||
|
||||
void tryToLoadImage (InputStream* input);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -175,10 +175,9 @@ ProjectInformationComponent::~ProjectInformationComponent()
|
|||
void ProjectInformationComponent::paint (Graphics& g)
|
||||
{
|
||||
//[UserPrePaint] Add your own custom painting code here..
|
||||
Image* im = ImageCache::getFromMemory (BinaryData::brushed_aluminium_png, BinaryData::brushed_aluminium_pngSize);
|
||||
g.setTiledImageFill (*im, 0, 0, 1.0f);
|
||||
g.setTiledImageFill (ImageCache::getFromMemory (BinaryData::brushed_aluminium_png, BinaryData::brushed_aluminium_pngSize),
|
||||
0, 0, 1.0f);
|
||||
g.fillAll();
|
||||
ImageCache::release (im);
|
||||
drawRecessedShadows (g, getWidth(), getHeight(), 14);
|
||||
//[/UserPrePaint]
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ protected:
|
|||
//==============================================================================
|
||||
virtual void addSubItems();
|
||||
virtual ProjectTreeViewBase* createSubItem (const Project::Item& node) = 0;
|
||||
Image* getIcon() const { return item.getIcon(); }
|
||||
const Image getIcon() const { return item.getIcon(); }
|
||||
|
||||
//==============================================================================
|
||||
void triggerAsyncRename (const Project::Item& itemToRename);
|
||||
|
|
|
|||
|
|
@ -54,16 +54,10 @@ void JucerTreeViewBase::paintItem (Graphics& g, int width, int height)
|
|||
const int x = getTextX();
|
||||
|
||||
g.setColour (isMissing() ? Colours::red : Colours::black);
|
||||
Image* icon = getIcon();
|
||||
|
||||
if (icon != 0)
|
||||
{
|
||||
g.drawImageWithin (icon, 2, 2, x - 4, height - 4,
|
||||
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
|
||||
false);
|
||||
|
||||
ImageCache::release (icon);
|
||||
}
|
||||
g.drawImageWithin (getIcon(), 2, 2, x - 4, height - 4,
|
||||
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
|
||||
false);
|
||||
|
||||
g.setFont (getFont());
|
||||
g.drawFittedText (getDisplayName(), x, 0, width - x, height, Justification::centredLeft, 1, 0.8f);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public:
|
|||
virtual const String getDisplayName() const = 0;
|
||||
virtual void setName (const String& newName) = 0;
|
||||
virtual bool isMissing() = 0;
|
||||
virtual Image* getIcon() const = 0;
|
||||
virtual const Image getIcon() const = 0;
|
||||
|
||||
virtual void showRenameBox();
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ public:
|
|||
else if (b == &imageButton)
|
||||
{
|
||||
if (! currentFill.isTiledImage())
|
||||
setFillType (FillType (*StoredSettings::getInstance()->getFallbackImage(),
|
||||
setFillType (FillType (StoredSettings::getInstance()->getFallbackImage(),
|
||||
AffineTransform::identity));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,9 +135,9 @@ const StringArray& StoredSettings::getFontNames()
|
|||
return fontNames;
|
||||
}
|
||||
|
||||
Image* StoredSettings::getFallbackImage()
|
||||
const Image StoredSettings::getFallbackImage()
|
||||
{
|
||||
if (fallbackImage == 0)
|
||||
if (fallbackImage.isNull())
|
||||
fallbackImage = ImageFileFormat::loadFrom (BinaryData::juce_icon_png, BinaryData::juce_icon_pngSize);
|
||||
|
||||
return fallbackImage;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
Image* getFallbackImage();
|
||||
const Image getFallbackImage();
|
||||
|
||||
//==============================================================================
|
||||
juce_UseDebuggingNewOperator
|
||||
|
|
@ -78,7 +78,7 @@ private:
|
|||
ScopedPointer<PropertiesFile> props;
|
||||
StringArray fontNames;
|
||||
|
||||
ScopedPointer<Image> fallbackImage;
|
||||
Image fallbackImage;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class IDispatchWrappingDynamicObject : public IDispatch
|
|||
public:
|
||||
IDispatchWrappingDynamicObject (const var& object_)
|
||||
: object (object_),
|
||||
refCount (0)
|
||||
refCount (1)
|
||||
{
|
||||
DBG ("num Juce wrapper objs: " + String (++numJuceSO));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ public:
|
|||
|
||||
cameraDevice = 0;
|
||||
cameraPreviewComp = 0;
|
||||
lastSnapshot = 0;
|
||||
recordingMovie = false;
|
||||
|
||||
addAndMakeVisible (cameraSelectorComboBox = new ComboBox (T("Camera")));
|
||||
|
|
@ -65,16 +64,14 @@ public:
|
|||
{
|
||||
deleteAllChildren();
|
||||
delete cameraDevice;
|
||||
delete lastSnapshot;
|
||||
}
|
||||
|
||||
void paint (Graphics& g)
|
||||
{
|
||||
if (lastSnapshot != 0)
|
||||
g.drawImageWithin (lastSnapshot,
|
||||
getWidth() / 2 + 10, 40,
|
||||
getWidth() / 2 - 20, getHeight() - 50,
|
||||
RectanglePlacement::centred, false);
|
||||
g.drawImageWithin (lastSnapshot,
|
||||
getWidth() / 2 + 10, 40,
|
||||
getWidth() / 2 - 20, getHeight() - 50,
|
||||
RectanglePlacement::centred, false);
|
||||
}
|
||||
|
||||
void resized()
|
||||
|
|
@ -160,7 +157,7 @@ public:
|
|||
}
|
||||
|
||||
// This is called by the camera device when a new image arrives
|
||||
void imageReceived (Image& image)
|
||||
void imageReceived (const Image& image)
|
||||
{
|
||||
// In this app we just want to take one image, so as soon as this happens,
|
||||
// we'll unregister ourselves as a listener.
|
||||
|
|
@ -170,8 +167,7 @@ public:
|
|||
// This callback won't be on the message thread, so need to lock it before using
|
||||
// data that may already be in use..
|
||||
const MessageManagerLock mm;
|
||||
deleteAndZero (lastSnapshot);
|
||||
lastSnapshot = image.createCopy();
|
||||
lastSnapshot = image;
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +181,7 @@ private:
|
|||
Component* cameraPreviewComp;
|
||||
bool recordingMovie;
|
||||
|
||||
Image* lastSnapshot;
|
||||
Image lastSnapshot;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class DemoOpenGLCanvas : public OpenGLComponent,
|
|||
public Timer
|
||||
{
|
||||
float rotation, delta;
|
||||
Image* image;
|
||||
Image image;
|
||||
|
||||
public:
|
||||
DemoOpenGLCanvas()
|
||||
|
|
@ -69,12 +69,12 @@ public:
|
|||
rotation = 0.0f;
|
||||
delta = 1.0f;
|
||||
|
||||
Image* im = ImageFileFormat::loadFrom (BinaryData::juce_png, BinaryData::juce_pngSize);
|
||||
image = new Image (Image::RGB, 512, 512, true);
|
||||
Graphics g (*image);
|
||||
image = Image (Image::RGB, 512, 512, true, Image::SoftwareImage);
|
||||
Graphics g (image);
|
||||
|
||||
g.fillAll (Colours::white);
|
||||
g.drawImage (im, 0, 0, 512, 512, 0, 0, im->getWidth(), im->getHeight());
|
||||
delete im;
|
||||
g.drawImageWithin (ImageFileFormat::loadFrom (BinaryData::juce_png, BinaryData::juce_pngSize),
|
||||
0, 0, 512, 512, RectanglePlacement::stretchToFit);
|
||||
|
||||
startTimer (20);
|
||||
|
||||
|
|
@ -107,7 +107,6 @@ public:
|
|||
|
||||
~DemoOpenGLCanvas()
|
||||
{
|
||||
delete image;
|
||||
}
|
||||
|
||||
// when the component creates a new internal context, this is called, and
|
||||
|
|
@ -133,9 +132,9 @@ public:
|
|||
|
||||
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
|
||||
|
||||
Image::BitmapData srcData (*image, 0, 0, image->getWidth(), image->getHeight());
|
||||
Image::BitmapData srcData (image, 0, 0, image.getWidth(), image.getHeight());
|
||||
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, 4, image->getWidth(), image->getHeight(),
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, 4, image.getWidth(), image.getHeight(),
|
||||
0, GL_RGB,
|
||||
GL_UNSIGNED_BYTE, srcData.data);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@ public:
|
|||
|
||||
~RenderingTestCanvas()
|
||||
{
|
||||
delete rgbImage;
|
||||
delete argbImage;
|
||||
delete svgDrawable;
|
||||
}
|
||||
|
||||
|
|
@ -151,8 +149,7 @@ private:
|
|||
RenderingTestComponent& owner;
|
||||
double averageTime;
|
||||
|
||||
Image* rgbImage;
|
||||
Image* argbImage;
|
||||
Image rgbImage, argbImage;
|
||||
DrawableComposite* svgDrawable;
|
||||
GlyphArrangement glyphs;
|
||||
ColourGradient linearGradient, radialGradient;
|
||||
|
|
@ -191,12 +188,12 @@ private:
|
|||
|
||||
void clipToImage (Graphics& g)
|
||||
{
|
||||
AffineTransform transform (AffineTransform::translation (argbImage->getWidth() / -2.0f, argbImage->getHeight() / -2.0f)
|
||||
AffineTransform transform (AffineTransform::translation (argbImage.getWidth() / -2.0f, argbImage.getHeight() / -2.0f)
|
||||
.rotated (bouncingNumber[3])
|
||||
.scaled (bouncingNumber[2] + 4.0f, bouncingNumber[2] + 4.0f)
|
||||
.translated (bouncingPointX[2], bouncingPointY[2]));
|
||||
g.reduceClipRegion (*argbImage,
|
||||
Rectangle<int> (0, 0, argbImage->getWidth(), argbImage->getHeight()),
|
||||
g.reduceClipRegion (argbImage,
|
||||
Rectangle<int> (0, 0, argbImage.getWidth(), argbImage.getHeight()),
|
||||
transform);
|
||||
}
|
||||
|
||||
|
|
@ -264,24 +261,24 @@ private:
|
|||
g.strokePath (p, stroke, AffineTransform::identity);
|
||||
}
|
||||
|
||||
void drawImages (Graphics& g, Image* image)
|
||||
void drawImages (Graphics& g, const Image& image)
|
||||
{
|
||||
AffineTransform transform (AffineTransform::translation ((float) (image->getWidth() / -2),
|
||||
(float) (image->getHeight() / -2))
|
||||
AffineTransform transform (AffineTransform::translation ((float) (image.getWidth() / -2),
|
||||
(float) (image.getHeight() / -2))
|
||||
.followedBy (getTransform()));
|
||||
|
||||
g.setOpacity ((float) owner.opacitySlider->getValue());
|
||||
g.drawImageTransformed (image, image->getBounds(),
|
||||
g.drawImageTransformed (image, image.getBounds(),
|
||||
transform, false);
|
||||
}
|
||||
|
||||
void drawTiling (Graphics& g, Image* image)
|
||||
void drawTiling (Graphics& g, const Image& image)
|
||||
{
|
||||
AffineTransform transform (AffineTransform::translation ((float) (image->getWidth() / -2),
|
||||
(float) (image->getHeight() / -2))
|
||||
AffineTransform transform (AffineTransform::translation ((float) (image.getWidth() / -2),
|
||||
(float) (image.getHeight() / -2))
|
||||
.followedBy (getTransform()));
|
||||
|
||||
FillType fill (*image, transform);
|
||||
FillType fill (image, transform);
|
||||
fill.setOpacity ((float) owner.opacitySlider->getValue());
|
||||
g.setFillType (fill);
|
||||
g.fillAll();
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ public:
|
|||
over.setStrokeThickness (5.0f);
|
||||
|
||||
DrawableImage down;
|
||||
down.setImage (ImageCache::getFromMemory (BinaryData::juce_png, BinaryData::juce_pngSize), true);
|
||||
down.setImage (ImageCache::getFromMemory (BinaryData::juce_png, BinaryData::juce_pngSize));
|
||||
down.setOverlayColour (Colours::black.withAlpha (0.3f));
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -567,10 +567,7 @@ public:
|
|||
ImageButton* imageButton = new ImageButton ("imagebutton");
|
||||
addAndMakeVisible (imageButton);
|
||||
|
||||
Image* juceImage = ImageCache::getFromMemory (BinaryData::juce_png, BinaryData::juce_pngSize);
|
||||
ImageCache::incReferenceCount (juceImage);
|
||||
ImageCache::incReferenceCount (juceImage);
|
||||
|
||||
Image juceImage = ImageCache::getFromMemory (BinaryData::juce_png, BinaryData::juce_pngSize);
|
||||
imageButton->setImages (true, true, true,
|
||||
juceImage, 0.7f, Colours::transparentBlack,
|
||||
juceImage, 1.0f, Colours::transparentBlack,
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public:
|
|||
const String resName (getImageResource (ib, role));
|
||||
|
||||
if (resName.isEmpty())
|
||||
return "0";
|
||||
return "Image()";
|
||||
|
||||
return "ImageCache::getFromMemory (" + resName + ", " + resName + "Size)";
|
||||
}
|
||||
|
|
@ -522,9 +522,9 @@ public:
|
|||
//==============================================================================
|
||||
static void updateButtonImages (JucerDocument& document, ImageButton* const ib)
|
||||
{
|
||||
Image* norm = document.getResources().getImageFromCache (getImageResource (ib, normalImage));
|
||||
Image* over = document.getResources().getImageFromCache (getImageResource (ib, overImage));
|
||||
Image* down = document.getResources().getImageFromCache (getImageResource (ib, downImage));
|
||||
Image norm = document.getResources().getImageFromCache (getImageResource (ib, normalImage));
|
||||
Image over = document.getResources().getImageFromCache (getImageResource (ib, overImage));
|
||||
Image down = document.getResources().getImageFromCache (getImageResource (ib, downImage));
|
||||
|
||||
ib->setImages (false, true, doesImageKeepProportions (ib),
|
||||
norm,
|
||||
|
|
|
|||
|
|
@ -199,14 +199,14 @@ const Drawable* BinaryResources::getDrawable (const String& name) const
|
|||
return res->drawable;
|
||||
}
|
||||
|
||||
Image* BinaryResources::getImageFromCache (const String& name) const
|
||||
const Image BinaryResources::getImageFromCache (const String& name) const
|
||||
{
|
||||
const BinaryResources::BinaryResource* const res = getResource (name);
|
||||
|
||||
if (res != 0 && res->data.getSize() > 0)
|
||||
return ImageCache::getFromMemory (res->data.getData(), (int) res->data.getSize());
|
||||
|
||||
return 0;
|
||||
return Image();
|
||||
}
|
||||
|
||||
void BinaryResources::loadFromCpp (const File& cppFileLocation, const String& cppFile)
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public:
|
|||
const StringArray getResourceNames() const;
|
||||
|
||||
const Drawable* getDrawable (const String& name) const;
|
||||
Image* getImageFromCache (const String& name) const;
|
||||
const Image getImageFromCache (const String& name) const;
|
||||
|
||||
template <class ElementComparator>
|
||||
void sort (ElementComparator& sorter)
|
||||
|
|
|
|||
|
|
@ -98,16 +98,13 @@ void GeneratedCode::addImageResourceLoader (const String& imageMemberName, const
|
|||
initialisers.add (initialiser);
|
||||
|
||||
privateMemberDeclarations
|
||||
<< "Image* " << imageMemberName << ";\n";
|
||||
<< "Image " << imageMemberName << ";\n";
|
||||
|
||||
if (resourceName.isNotEmpty())
|
||||
{
|
||||
constructorCode
|
||||
<< imageMemberName << " = ImageCache::getFromMemory ("
|
||||
<< resourceName << ", " << resourceName << "Size);\n";
|
||||
|
||||
destructorCode
|
||||
<< "ImageCache::release (" << imageMemberName << ");\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ JucerFillType::JucerFillType()
|
|||
|
||||
JucerFillType::JucerFillType (const JucerFillType& other)
|
||||
{
|
||||
image = 0;
|
||||
image = Image();
|
||||
mode = other.mode;
|
||||
colour = other.colour;
|
||||
gradCol1 = other.gradCol1;
|
||||
|
|
@ -50,9 +50,7 @@ JucerFillType::JucerFillType (const JucerFillType& other)
|
|||
|
||||
JucerFillType& JucerFillType::operator= (const JucerFillType& other)
|
||||
{
|
||||
ImageCache::release (image);
|
||||
image = 0;
|
||||
|
||||
image = Image();
|
||||
mode = other.mode;
|
||||
colour = other.colour;
|
||||
gradCol1 = other.gradCol1;
|
||||
|
|
@ -68,7 +66,6 @@ JucerFillType& JucerFillType::operator= (const JucerFillType& other)
|
|||
|
||||
JucerFillType::~JucerFillType()
|
||||
{
|
||||
ImageCache::release (image);
|
||||
}
|
||||
|
||||
bool JucerFillType::operator== (const JucerFillType& other) const throw()
|
||||
|
|
@ -91,9 +88,7 @@ bool JucerFillType::operator!= (const JucerFillType& other) const throw()
|
|||
|
||||
void JucerFillType::reset()
|
||||
{
|
||||
ImageCache::release (image);
|
||||
image = 0;
|
||||
|
||||
image = Image();
|
||||
mode = solidColour;
|
||||
colour = Colours::brown.withHue (Random::getSystemRandom().nextFloat());
|
||||
gradCol1 = Colours::red;
|
||||
|
|
@ -114,9 +109,7 @@ void JucerFillType::setFillType (Graphics& g, JucerDocument* const document, con
|
|||
{
|
||||
if (mode == solidColour)
|
||||
{
|
||||
ImageCache::release (image);
|
||||
image = 0;
|
||||
|
||||
image = Image();
|
||||
g.setColour (colour);
|
||||
}
|
||||
else if (mode == imageBrush)
|
||||
|
|
@ -125,12 +118,11 @@ void JucerFillType::setFillType (Graphics& g, JucerDocument* const document, con
|
|||
|
||||
Rectangle<int> r (imageAnchor.getRectangle (parentArea, document->getComponentLayout()));
|
||||
|
||||
g.setTiledImageFill (*image, r.getX(), r.getY(), (float) imageOpacity);
|
||||
g.setTiledImageFill (image, r.getX(), r.getY(), (float) imageOpacity);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageCache::release (image);
|
||||
image = 0;
|
||||
image = Image();
|
||||
|
||||
Rectangle<int> r1 (gradPos1.getRectangle (parentArea, document->getComponentLayout()));
|
||||
Rectangle<int> r2 (gradPos2.getRectangle (parentArea, document->getComponentLayout()));
|
||||
|
|
@ -285,9 +277,9 @@ bool JucerFillType::isOpaque() const
|
|||
return gradCol1.isOpaque() && gradCol1.isOpaque();
|
||||
|
||||
case imageBrush:
|
||||
return image != 0
|
||||
return image.isValid()
|
||||
&& imageOpacity >= 1.0f
|
||||
&& ! image->hasAlphaChannel();
|
||||
&& ! image.hasAlphaChannel();
|
||||
|
||||
default:
|
||||
jassertfalse
|
||||
|
|
@ -321,28 +313,28 @@ bool JucerFillType::isInvisible() const
|
|||
|
||||
void JucerFillType::loadImage (JucerDocument* const document)
|
||||
{
|
||||
if (image == 0)
|
||||
if (image.isNull())
|
||||
{
|
||||
if (document != 0)
|
||||
image = document->getResources().getImageFromCache (imageResourceName);
|
||||
|
||||
if (image == 0)
|
||||
if (image.isNull())
|
||||
{
|
||||
const int hashCode = 0x3437856f;
|
||||
image = ImageCache::getFromHashCode (hashCode);
|
||||
|
||||
if (image == 0)
|
||||
if (image.isNull())
|
||||
{
|
||||
image = new Image (Image::RGB, 100, 100, true);
|
||||
image = Image (Image::RGB, 100, 100, true);
|
||||
|
||||
Graphics g (*image);
|
||||
g.fillCheckerBoard (0, 0, image->getWidth(), image->getHeight(),
|
||||
image->getWidth() / 2, image->getHeight() / 2,
|
||||
Graphics g (image);
|
||||
g.fillCheckerBoard (0, 0, image.getWidth(), image.getHeight(),
|
||||
image.getWidth() / 2, image.getHeight() / 2,
|
||||
Colours::white, Colours::lightgrey);
|
||||
|
||||
g.setFont (12.0f);
|
||||
g.setColour (Colours::grey);
|
||||
g.drawText (T("(image missing)"), 0, 0, image->getWidth(), image->getHeight() / 2, Justification::centred, true);
|
||||
g.drawText (T("(image missing)"), 0, 0, image.getWidth(), image.getHeight() / 2, Justification::centred, true);
|
||||
|
||||
ImageCache::addImageToCache (image, hashCode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
private:
|
||||
Image* image;
|
||||
Image image;
|
||||
|
||||
void reset();
|
||||
void loadImage (JucerDocument* const document);
|
||||
|
|
|
|||
|
|
@ -184,10 +184,10 @@ const Rectangle<int> ComponentLayoutEditor::getComponentArea() const
|
|||
}
|
||||
}
|
||||
|
||||
Image* ComponentLayoutEditor::createComponentLayerSnapshot() const
|
||||
const Image ComponentLayoutEditor::createComponentLayerSnapshot() const
|
||||
{
|
||||
((SubComponentHolderComp*) subCompHolder)->dontFillBackground = true;
|
||||
Image* const im = subCompHolder->createComponentSnapshot (Rectangle<int> (0, 0, subCompHolder->getWidth(), subCompHolder->getHeight()));
|
||||
Image im = subCompHolder->createComponentSnapshot (Rectangle<int> (0, 0, subCompHolder->getWidth(), subCompHolder->getHeight()));
|
||||
((SubComponentHolderComp*) subCompHolder)->dontFillBackground = false;
|
||||
|
||||
return im;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
const Rectangle<int> getComponentArea() const;
|
||||
|
||||
Image* createComponentLayerSnapshot() const;
|
||||
const Image createComponentLayerSnapshot() const;
|
||||
|
||||
//==============================================================================
|
||||
juce_UseDebuggingNewOperator
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ const Rectangle<int> ComponentLayoutPanel::getComponentArea() const
|
|||
return ((ComponentLayoutEditor*) editor)->getComponentArea();
|
||||
}
|
||||
|
||||
Image* ComponentLayoutPanel::createComponentSnapshot() const
|
||||
const Image ComponentLayoutPanel::createComponentSnapshot() const
|
||||
{
|
||||
return ((ComponentLayoutEditor*) editor)->createComponentLayerSnapshot();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public:
|
|||
void updatePropertiesList();
|
||||
const Rectangle<int> getComponentArea() const;
|
||||
|
||||
Image* createComponentSnapshot() const;
|
||||
const Image createComponentSnapshot() const;
|
||||
|
||||
//==============================================================================
|
||||
juce_UseDebuggingNewOperator
|
||||
|
|
|
|||
|
|
@ -1300,10 +1300,10 @@ JucerDocumentHolder* JucerDocumentHolder::getActiveDocumentHolder()
|
|||
return dynamic_cast <JucerDocumentHolder*> (target);
|
||||
}
|
||||
|
||||
Image* JucerDocumentHolder::createComponentLayerSnapshot() const
|
||||
const Image JucerDocumentHolder::createComponentLayerSnapshot() const
|
||||
{
|
||||
if (compLayoutPanel != 0)
|
||||
return compLayoutPanel->createComponentSnapshot();
|
||||
|
||||
return 0;
|
||||
return Image();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public:
|
|||
void setViewportToLastPos (Viewport* vp);
|
||||
void storeLastViewportPos (Viewport* vp);
|
||||
|
||||
Image* createComponentLayerSnapshot() const;
|
||||
const Image createComponentLayerSnapshot() const;
|
||||
|
||||
//==============================================================================
|
||||
void paint (Graphics& g);
|
||||
|
|
|
|||
|
|
@ -53,8 +53,6 @@ PaintRoutineEditor::~PaintRoutineEditor()
|
|||
|
||||
removeChildComponent (&lassoComp);
|
||||
deleteAllChildren();
|
||||
|
||||
delete componentOverlay;
|
||||
}
|
||||
|
||||
void PaintRoutineEditor::removeAllElementComps()
|
||||
|
|
@ -99,10 +97,10 @@ void PaintRoutineEditor::paint (Graphics& g)
|
|||
|
||||
void PaintRoutineEditor::paintOverChildren (Graphics& g)
|
||||
{
|
||||
if (componentOverlay == 0 && document.getComponentOverlayOpacity() > 0.0f)
|
||||
if (componentOverlay.isNull() && document.getComponentOverlayOpacity() > 0.0f)
|
||||
updateComponentOverlay();
|
||||
|
||||
if (componentOverlay != 0)
|
||||
if (componentOverlay.isValid())
|
||||
{
|
||||
const Rectangle<int> clip (getComponentArea());
|
||||
g.drawImageAt (componentOverlay, clip.getX(), clip.getY());
|
||||
|
|
@ -113,7 +111,7 @@ void PaintRoutineEditor::resized()
|
|||
{
|
||||
if (getWidth() > 0 && getHeight() > 0)
|
||||
{
|
||||
deleteAndZero (componentOverlay);
|
||||
componentOverlay = Image();
|
||||
refreshAllElements();
|
||||
}
|
||||
}
|
||||
|
|
@ -133,11 +131,10 @@ void PaintRoutineEditor::updateChildBounds()
|
|||
|
||||
void PaintRoutineEditor::updateComponentOverlay()
|
||||
{
|
||||
if (componentOverlay != 0)
|
||||
if (componentOverlay.isValid())
|
||||
repaint();
|
||||
|
||||
deleteAndZero (componentOverlay);
|
||||
|
||||
componentOverlay = Image();
|
||||
componentOverlayOpacity = document.getComponentOverlayOpacity();
|
||||
|
||||
if (componentOverlayOpacity > 0.0f)
|
||||
|
|
@ -145,9 +142,9 @@ void PaintRoutineEditor::updateComponentOverlay()
|
|||
if (documentHolder != 0)
|
||||
componentOverlay = documentHolder->createComponentLayerSnapshot();
|
||||
|
||||
if (componentOverlay != 0)
|
||||
if (componentOverlay.isValid())
|
||||
{
|
||||
componentOverlay->multiplyAllAlphas (componentOverlayOpacity);
|
||||
componentOverlay.multiplyAllAlphas (componentOverlayOpacity);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
|
@ -165,7 +162,7 @@ void PaintRoutineEditor::visibilityChanged()
|
|||
else
|
||||
{
|
||||
document.removeChangeListener (this);
|
||||
deleteAndZero (componentOverlay);
|
||||
componentOverlay = Image();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +207,7 @@ void PaintRoutineEditor::refreshAllElements()
|
|||
|
||||
if (componentOverlayOpacity != document.getComponentOverlayOpacity())
|
||||
{
|
||||
deleteAndZero (componentOverlay);
|
||||
componentOverlay = Image();
|
||||
componentOverlayOpacity = document.getComponentOverlayOpacity();
|
||||
repaint();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ private:
|
|||
JucerDocumentHolder* const documentHolder;
|
||||
LassoComponent <PaintElement*> lassoComp;
|
||||
SnapGridPainter grid;
|
||||
Image* componentOverlay;
|
||||
Image componentOverlay;
|
||||
float componentOverlayOpacity;
|
||||
|
||||
Colour currentBackgroundColour;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public:
|
|||
class AboutPage : public Component
|
||||
{
|
||||
HyperlinkButton* link;
|
||||
Image* logo;
|
||||
Image logo;
|
||||
TextLayout text1, text2;
|
||||
|
||||
public:
|
||||
|
|
@ -89,7 +89,6 @@ public:
|
|||
~AboutPage()
|
||||
{
|
||||
deleteAllChildren();
|
||||
ImageCache::release (logo);
|
||||
}
|
||||
|
||||
void paint (Graphics& g)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ SnapGridPainter::SnapGridPainter()
|
|||
|
||||
SnapGridPainter::~SnapGridPainter()
|
||||
{
|
||||
delete backgroundFill;
|
||||
}
|
||||
|
||||
bool SnapGridPainter::updateFromDesign (JucerDocument& design)
|
||||
|
|
@ -48,7 +47,7 @@ bool SnapGridPainter::updateFromDesign (JucerDocument& design)
|
|||
snapGridSize = design.getSnappingGridSize();
|
||||
snapShown = design.isSnapShown() && design.isSnapActive (false);
|
||||
|
||||
deleteAndZero (backgroundFill);
|
||||
backgroundFill = Image();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -57,16 +56,16 @@ bool SnapGridPainter::updateFromDesign (JucerDocument& design)
|
|||
|
||||
void SnapGridPainter::updateColour()
|
||||
{
|
||||
deleteAndZero (backgroundFill);
|
||||
backgroundFill = Image();
|
||||
}
|
||||
|
||||
void SnapGridPainter::draw (Graphics& g, PaintRoutine* backgroundGraphics)
|
||||
{
|
||||
if (backgroundFill == 0 && snapShown)
|
||||
if (backgroundFill.isNull() && snapShown)
|
||||
{
|
||||
backgroundFill = new Image (Image::ARGB, snapGridSize, snapGridSize, true);
|
||||
backgroundFill = Image (Image::ARGB, snapGridSize, snapGridSize, true);
|
||||
|
||||
Graphics g (*backgroundFill);
|
||||
Graphics g (backgroundFill);
|
||||
|
||||
Colour col (Colours::black);
|
||||
|
||||
|
|
@ -83,9 +82,9 @@ void SnapGridPainter::draw (Graphics& g, PaintRoutine* backgroundGraphics)
|
|||
g.setPixel (0, 0);
|
||||
}
|
||||
|
||||
if (backgroundFill != 0)
|
||||
if (backgroundFill.isValid())
|
||||
{
|
||||
g.setTiledImageFill (*backgroundFill, 0, 0, 1.0f);
|
||||
g.setTiledImageFill (backgroundFill, 0, 0, 1.0f);
|
||||
g.fillAll();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public:
|
|||
private:
|
||||
int snapGridSize;
|
||||
bool snapShown;
|
||||
Image* backgroundFill;
|
||||
Image backgroundFill;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
1894
juce_amalgamated.cpp
1894
juce_amalgamated.cpp
File diff suppressed because it is too large
Load diff
1240
juce_amalgamated.h
1240
juce_amalgamated.h
File diff suppressed because it is too large
Load diff
|
|
@ -28,27 +28,11 @@
|
|||
BEGIN_JUCE_NAMESPACE
|
||||
|
||||
#include "juce_Identifier.h"
|
||||
#include "../utilities/juce_DeletedAtShutdown.h"
|
||||
#include "../core/juce_Singleton.h"
|
||||
#include "../text/juce_StringPool.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class Identifier::Pool : public DeletedAtShutdown
|
||||
{
|
||||
public:
|
||||
Pool() {}
|
||||
~Pool() { clearSingletonInstance(); }
|
||||
StringPool Identifier::pool;
|
||||
|
||||
StringPool pool;
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (Pool);
|
||||
};
|
||||
|
||||
juce_ImplementSingleton_SingleThreaded (Identifier::Pool);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
Identifier::Identifier() throw()
|
||||
: name (0)
|
||||
{
|
||||
|
|
@ -66,7 +50,7 @@ Identifier& Identifier::operator= (const Identifier& other) throw()
|
|||
}
|
||||
|
||||
Identifier::Identifier (const String& name_)
|
||||
: name (Identifier::Pool::getInstance()->pool.getPooledString (name_))
|
||||
: name (Identifier::pool.getPooledString (name_))
|
||||
{
|
||||
/* An Identifier string must be suitable for use as a script variable or XML
|
||||
attribute, so it can only contain this limited set of characters.. */
|
||||
|
|
@ -74,7 +58,7 @@ Identifier::Identifier (const String& name_)
|
|||
}
|
||||
|
||||
Identifier::Identifier (const char* const name_)
|
||||
: name (Identifier::Pool::getInstance()->pool.getPooledString (name_))
|
||||
: name (Identifier::pool.getPooledString (name_))
|
||||
{
|
||||
/* An Identifier string must be suitable for use as a script variable or XML
|
||||
attribute, so it can only contain this limited set of characters.. */
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
#ifndef __JUCE_IDENTIFIER_JUCEHEADER__
|
||||
#define __JUCE_IDENTIFIER_JUCEHEADER__
|
||||
|
||||
#include "../text/juce_String.h"
|
||||
#include "../text/juce_StringPool.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -82,7 +82,7 @@ private:
|
|||
//==============================================================================
|
||||
const juce_wchar* name;
|
||||
|
||||
class Pool;
|
||||
static StringPool pool;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,16 @@ RSAKey::~RSAKey()
|
|||
{
|
||||
}
|
||||
|
||||
bool RSAKey::operator== (const RSAKey& other) const throw()
|
||||
{
|
||||
return part1 == other.part1 && part2 == other.part2;
|
||||
}
|
||||
|
||||
bool RSAKey::operator!= (const RSAKey& other) const throw()
|
||||
{
|
||||
return ! operator== (other);
|
||||
}
|
||||
|
||||
const String RSAKey::toString() const
|
||||
{
|
||||
return part1.toString (16) + "," + part2.toString (16);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ public:
|
|||
/** Destructor. */
|
||||
~RSAKey();
|
||||
|
||||
bool operator== (const RSAKey& other) const throw();
|
||||
bool operator!= (const RSAKey& other) const throw();
|
||||
|
||||
//==============================================================================
|
||||
/** Turns the key into a string representation.
|
||||
|
||||
|
|
|
|||
|
|
@ -50,40 +50,30 @@ ImageButton::ImageButton (const String& text_)
|
|||
|
||||
ImageButton::~ImageButton()
|
||||
{
|
||||
deleteImages();
|
||||
}
|
||||
|
||||
void ImageButton::deleteImages()
|
||||
{
|
||||
ImageCache::releaseOrDelete (normalImage);
|
||||
ImageCache::releaseOrDelete (overImage);
|
||||
ImageCache::releaseOrDelete (downImage);
|
||||
}
|
||||
|
||||
void ImageButton::setImages (const bool resizeButtonNowToFitThisImage,
|
||||
const bool rescaleImagesWhenButtonSizeChanges,
|
||||
const bool preserveImageProportions,
|
||||
Image* const normalImage_,
|
||||
const Image& normalImage_,
|
||||
const float imageOpacityWhenNormal,
|
||||
const Colour& overlayColourWhenNormal,
|
||||
Image* const overImage_,
|
||||
const Image& overImage_,
|
||||
const float imageOpacityWhenOver,
|
||||
const Colour& overlayColourWhenOver,
|
||||
Image* const downImage_,
|
||||
const Image& downImage_,
|
||||
const float imageOpacityWhenDown,
|
||||
const Colour& overlayColourWhenDown,
|
||||
const float hitTestAlphaThreshold)
|
||||
{
|
||||
deleteImages();
|
||||
|
||||
normalImage = normalImage_;
|
||||
overImage = overImage_;
|
||||
downImage = downImage_;
|
||||
|
||||
if (resizeButtonNowToFitThisImage && normalImage != 0)
|
||||
if (resizeButtonNowToFitThisImage && normalImage.isValid())
|
||||
{
|
||||
imageW = normalImage->getWidth();
|
||||
imageH = normalImage->getHeight();
|
||||
imageW = normalImage.getWidth();
|
||||
imageH = normalImage.getHeight();
|
||||
|
||||
setSize (imageW, imageH);
|
||||
}
|
||||
|
|
@ -103,7 +93,7 @@ void ImageButton::setImages (const bool resizeButtonNowToFitThisImage,
|
|||
repaint();
|
||||
}
|
||||
|
||||
Image* ImageButton::getCurrentImage() const
|
||||
const Image ImageButton::getCurrentImage() const
|
||||
{
|
||||
if (isDown() || getToggleState())
|
||||
return getDownImage();
|
||||
|
|
@ -114,21 +104,21 @@ Image* ImageButton::getCurrentImage() const
|
|||
return getNormalImage();
|
||||
}
|
||||
|
||||
Image* ImageButton::getNormalImage() const throw()
|
||||
const Image ImageButton::getNormalImage() const
|
||||
{
|
||||
return normalImage;
|
||||
}
|
||||
|
||||
Image* ImageButton::getOverImage() const throw()
|
||||
const Image ImageButton::getOverImage() const
|
||||
{
|
||||
return (overImage != 0) ? overImage
|
||||
: normalImage;
|
||||
return overImage.isValid() ? overImage
|
||||
: normalImage;
|
||||
}
|
||||
|
||||
Image* ImageButton::getDownImage() const throw()
|
||||
const Image ImageButton::getDownImage() const
|
||||
{
|
||||
return (downImage != 0) ? downImage
|
||||
: getOverImage();
|
||||
return downImage.isValid() ? downImage
|
||||
: getOverImage();
|
||||
}
|
||||
|
||||
void ImageButton::paintButton (Graphics& g,
|
||||
|
|
@ -141,12 +131,12 @@ void ImageButton::paintButton (Graphics& g,
|
|||
isButtonDown = false;
|
||||
}
|
||||
|
||||
Image* const im = getCurrentImage();
|
||||
Image im (getCurrentImage());
|
||||
|
||||
if (im != 0)
|
||||
if (im.isValid())
|
||||
{
|
||||
const int iw = im->getWidth();
|
||||
const int ih = im->getHeight();
|
||||
const int iw = im.getWidth();
|
||||
const int ih = im.getHeight();
|
||||
imageW = getWidth();
|
||||
imageH = getHeight();
|
||||
imageX = (imageW - iw) >> 1;
|
||||
|
|
@ -189,7 +179,7 @@ void ImageButton::paintButton (Graphics& g,
|
|||
imageH = ih;
|
||||
}
|
||||
|
||||
getLookAndFeel().drawImageButton (g, im, imageX, imageY, imageW, imageH,
|
||||
getLookAndFeel().drawImageButton (g, &im, imageX, imageY, imageW, imageH,
|
||||
isButtonDown ? downOverlay
|
||||
: (isMouseOverButton ? overOverlay
|
||||
: normalOverlay),
|
||||
|
|
@ -205,12 +195,11 @@ bool ImageButton::hitTest (int x, int y)
|
|||
if (alphaThreshold == 0)
|
||||
return true;
|
||||
|
||||
Image* const im = getCurrentImage();
|
||||
Image im (getCurrentImage());
|
||||
|
||||
return im == 0
|
||||
|| (imageW > 0 && imageH > 0
|
||||
&& alphaThreshold < im->getPixelAt (((x - imageX) * im->getWidth()) / imageW,
|
||||
((y - imageY) * im->getHeight()) / imageH).getAlpha());
|
||||
return im.isNull() || (imageW > 0 && imageH > 0
|
||||
&& alphaThreshold < im.getPixelAt (((x - imageX) * im.getWidth()) / imageW,
|
||||
((y - imageY) * im.getHeight()) / imageH).getAlpha());
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -57,10 +57,6 @@ public:
|
|||
//==============================================================================
|
||||
/** Sets up the images to draw in various states.
|
||||
|
||||
Important! Bear in mind that if you pass the same image in for more than one of
|
||||
these parameters, this button will delete it (or release from the ImageCache)
|
||||
multiple times!
|
||||
|
||||
@param resizeButtonNowToFitThisImage if true, the button will be immediately
|
||||
resized to the same dimensions as the normal image
|
||||
@param rescaleImagesWhenButtonSizeChanges if true, the image will be rescaled to fit the
|
||||
|
|
@ -69,9 +65,7 @@ public:
|
|||
the button will keep the image's x and y proportions
|
||||
correct - i.e. it won't distort its shape, although
|
||||
this might create gaps around the edges
|
||||
@param normalImage the image to use when the button is in its normal state. The
|
||||
image passed in will be deleted (or released if it
|
||||
was created by the ImageCache class) when the
|
||||
@param normalImage the image to use when the button is in its normal state.
|
||||
button no longer needs it.
|
||||
@param imageOpacityWhenNormal the opacity to use when drawing the normal image.
|
||||
@param overlayColourWhenNormal an overlay colour to use to fill the alpha channel of the
|
||||
|
|
@ -81,19 +75,15 @@ public:
|
|||
colour to the image to brighten or darken it
|
||||
@param overImage the image to use when the mouse is over the button. If
|
||||
you want to use the same image as was set in the normalImage
|
||||
parameter, this value can be 0. As for normalImage, it
|
||||
will be deleted or released by the button when no longer
|
||||
needed
|
||||
parameter, this value can be a null image.
|
||||
@param imageOpacityWhenOver the opacity to use when drawing the image when the mouse
|
||||
is over the button
|
||||
@param overlayColourWhenOver an overlay colour to use to fill the alpha channel of the
|
||||
image when the mouse is over - if this colour is transparent,
|
||||
no overlay will be drawn
|
||||
@param downImage an image to use when the button is pressed down. If set
|
||||
to zero, the 'over' image will be drawn instead (or the
|
||||
normal image if there isn't an 'over' image either). This
|
||||
image will be deleted or released by the button when no
|
||||
longer needed
|
||||
to a null image, the 'over' image will be drawn instead (or the
|
||||
normal image if there isn't an 'over' image either).
|
||||
@param imageOpacityWhenDown the opacity to use when drawing the image when the button
|
||||
is pressed
|
||||
@param overlayColourWhenDown an overlay colour to use to fill the alpha channel of the
|
||||
|
|
@ -109,33 +99,33 @@ public:
|
|||
void setImages (bool resizeButtonNowToFitThisImage,
|
||||
bool rescaleImagesWhenButtonSizeChanges,
|
||||
bool preserveImageProportions,
|
||||
Image* normalImage,
|
||||
const Image& normalImage,
|
||||
float imageOpacityWhenNormal,
|
||||
const Colour& overlayColourWhenNormal,
|
||||
Image* overImage,
|
||||
const Image& overImage,
|
||||
float imageOpacityWhenOver,
|
||||
const Colour& overlayColourWhenOver,
|
||||
Image* downImage,
|
||||
const Image& downImage,
|
||||
float imageOpacityWhenDown,
|
||||
const Colour& overlayColourWhenDown,
|
||||
float hitTestAlphaThreshold = 0.0f);
|
||||
|
||||
/** Returns the currently set 'normal' image. */
|
||||
Image* getNormalImage() const throw();
|
||||
const Image getNormalImage() const;
|
||||
|
||||
/** Returns the image that's drawn when the mouse is over the button.
|
||||
|
||||
If an 'over' image has been set, this will return it; otherwise it'll
|
||||
If a valid 'over' image has been set, this will return it; otherwise it'll
|
||||
just return the normal image.
|
||||
*/
|
||||
Image* getOverImage() const throw();
|
||||
const Image getOverImage() const;
|
||||
|
||||
/** Returns the image that's drawn when the button is held down.
|
||||
|
||||
If a 'down' image has been set, this will return it; otherwise it'll
|
||||
If a valid 'down' image has been set, this will return it; otherwise it'll
|
||||
return the 'over' image or normal image, depending on what's available.
|
||||
*/
|
||||
Image* getDownImage() const throw();
|
||||
const Image getDownImage() const;
|
||||
|
||||
//==============================================================================
|
||||
juce_UseDebuggingNewOperator
|
||||
|
|
@ -153,14 +143,11 @@ private:
|
|||
bool scaleImageToFit, preserveProportions;
|
||||
unsigned char alphaThreshold;
|
||||
int imageX, imageY, imageW, imageH;
|
||||
Image* normalImage;
|
||||
Image* overImage;
|
||||
Image* downImage;
|
||||
Image normalImage, overImage, downImage;
|
||||
float normalOpacity, overOpacity, downOpacity;
|
||||
Colour normalOverlay, overOverlay, downOverlay;
|
||||
|
||||
Image* getCurrentImage() const;
|
||||
void deleteImages();
|
||||
const Image getCurrentImage() const;
|
||||
|
||||
ImageButton (const ImageButton&);
|
||||
ImageButton& operator= (const ImageButton&);
|
||||
|
|
|
|||
|
|
@ -72,11 +72,14 @@ void ToolbarButton::paintButtonArea (Graphics& g,
|
|||
if (! isEnabled())
|
||||
{
|
||||
Image im (Image::ARGB, width, height, true);
|
||||
Graphics g2 (im);
|
||||
d->drawWithin (g2, 0, 0, width, height, RectanglePlacement::centred, 1.0f);
|
||||
im.desaturate();
|
||||
|
||||
g.drawImageAt (&im, 0, 0);
|
||||
{
|
||||
Graphics g2 (im);
|
||||
d->drawWithin (g2, 0, 0, width, height, RectanglePlacement::centred, 1.0f);
|
||||
}
|
||||
|
||||
im.desaturate();
|
||||
g.drawImageAt (im, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -880,7 +880,7 @@ void ListBox::repaintRow (const int rowNumber) throw()
|
|||
repaint (getRowPosition (rowNumber, true));
|
||||
}
|
||||
|
||||
Image* ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
|
||||
const Image ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
|
||||
{
|
||||
Rectangle<int> imageArea;
|
||||
const int firstRow = getRowContainingPosition (0, 0);
|
||||
|
|
@ -901,7 +901,7 @@ Image* ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
|
|||
imageArea = imageArea.getIntersection (getLocalBounds());
|
||||
imageX = imageArea.getX();
|
||||
imageY = imageArea.getY();
|
||||
Image* snapshot = Image::createNativeImage (Image::ARGB, imageArea.getWidth(), imageArea.getHeight(), true);
|
||||
Image snapshot (Image::ARGB, imageArea.getWidth(), imageArea.getHeight(), true, Image::NativeImage);
|
||||
|
||||
for (i = getNumRowsOnScreen() + 2; --i >= 0;)
|
||||
{
|
||||
|
|
@ -911,7 +911,7 @@ Image* ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
|
|||
{
|
||||
const Point<int> pos (rowComp->relativePositionToOtherComponent (this, Point<int>()));
|
||||
|
||||
Graphics g (*snapshot);
|
||||
Graphics g (snapshot);
|
||||
g.setOrigin (pos.getX() - imageX, pos.getY() - imageY);
|
||||
if (g.reduceClipRegion (0, 0, rowComp->getWidth(), rowComp->getHeight()))
|
||||
rowComp->paintEntireComponent (g);
|
||||
|
|
@ -929,8 +929,8 @@ void ListBox::startDragAndDrop (const MouseEvent& e, const String& dragDescripti
|
|||
if (dragContainer != 0)
|
||||
{
|
||||
int x, y;
|
||||
Image* dragImage = createSnapshotOfSelectedRows (x, y);
|
||||
dragImage->multiplyAllAlphas (0.6f);
|
||||
Image dragImage (createSnapshotOfSelectedRows (x, y));
|
||||
dragImage.multiplyAllAlphas (0.6f);
|
||||
|
||||
MouseEvent e2 (e.getEventRelativeTo (this));
|
||||
const Point<int> p (x - e2.x, y - e2.y);
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ public:
|
|||
|
||||
@see Component::createComponentSnapshot
|
||||
*/
|
||||
Image* createSnapshotOfSelectedRows (int& x, int& y);
|
||||
const Image createSnapshotOfSelectedRows (int& x, int& y);
|
||||
|
||||
/** Returns the viewport that this ListBox uses.
|
||||
|
||||
|
|
|
|||
|
|
@ -38,10 +38,11 @@ BEGIN_JUCE_NAMESPACE
|
|||
class DragOverlayComp : public Component
|
||||
{
|
||||
public:
|
||||
DragOverlayComp (Image* const image_)
|
||||
DragOverlayComp (const Image& image_)
|
||||
: image (image_)
|
||||
{
|
||||
image->multiplyAllAlphas (0.8f);
|
||||
image.duplicateIfShared();
|
||||
image.multiplyAllAlphas (0.8f);
|
||||
setAlwaysOnTop (true);
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
ScopedPointer <Image> image;
|
||||
Image image;
|
||||
|
||||
DragOverlayComp (const DragOverlayComp&);
|
||||
DragOverlayComp& operator= (const DragOverlayComp&);
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public:
|
|||
|
||||
if (dnd != 0)
|
||||
{
|
||||
dnd->startDragging (Toolbar::toolbarDragDescriptor, getParentComponent(), 0, true);
|
||||
dnd->startDragging (Toolbar::toolbarDragDescriptor, getParentComponent(), Image(), true);
|
||||
|
||||
ToolbarItemComponent* const tc = dynamic_cast <ToolbarItemComponent*> (getParentComponent());
|
||||
|
||||
|
|
|
|||
|
|
@ -139,10 +139,10 @@ public:
|
|||
if (dragContainer != 0)
|
||||
{
|
||||
pos.setSize (pos.getWidth(), item->itemHeight);
|
||||
Image* dragImage = Component::createComponentSnapshot (pos, true);
|
||||
dragImage->multiplyAllAlphas (0.6f);
|
||||
Image dragImage (Component::createComponentSnapshot (pos, true));
|
||||
dragImage.multiplyAllAlphas (0.6f);
|
||||
|
||||
Point<int> imageOffset (pos.getX() - e.x, pos.getY() - e.y);
|
||||
Point<int> imageOffset (pos.getPosition() - e.getPosition());
|
||||
dragContainer->startDragging (dragDescription, &owner, dragImage, true, &imageOffset);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "../../graphics/imaging/juce_ImageCache.h"
|
||||
#include "../../../events/juce_AsyncUpdater.h"
|
||||
|
||||
Image* juce_createIconForFile (const File& file);
|
||||
const Image juce_createIconForFile (const File& file);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -107,7 +107,7 @@ public:
|
|||
{
|
||||
getLookAndFeel().drawFileBrowserRow (g, getWidth(), getHeight(),
|
||||
file.getFileName(),
|
||||
icon,
|
||||
&icon,
|
||||
fileSize, modTime,
|
||||
isDirectory, highlighted,
|
||||
index);
|
||||
|
|
@ -164,12 +164,11 @@ public:
|
|||
clearIcon();
|
||||
}
|
||||
|
||||
if (file != File::nonexistent
|
||||
&& icon == 0 && ! isDirectory)
|
||||
if (file != File::nonexistent && icon.isNull() && ! isDirectory)
|
||||
{
|
||||
updateIcon (true);
|
||||
|
||||
if (icon == 0)
|
||||
if (! icon.isValid())
|
||||
thread.addTimeSliceClient (this);
|
||||
}
|
||||
}
|
||||
|
|
@ -196,31 +195,30 @@ private:
|
|||
File file;
|
||||
String fileSize;
|
||||
String modTime;
|
||||
Image* icon;
|
||||
Image icon;
|
||||
bool isDirectory;
|
||||
|
||||
void clearIcon()
|
||||
{
|
||||
ImageCache::release (icon);
|
||||
icon = 0;
|
||||
icon = Image();
|
||||
}
|
||||
|
||||
void updateIcon (const bool onlyUpdateIfCached)
|
||||
{
|
||||
if (icon == 0)
|
||||
if (icon.isNull())
|
||||
{
|
||||
const int hashCode = (file.getFullPathName() + "_iconCacheSalt").hashCode();
|
||||
Image* im = ImageCache::getFromHashCode (hashCode);
|
||||
Image im (ImageCache::getFromHashCode (hashCode));
|
||||
|
||||
if (im == 0 && ! onlyUpdateIfCached)
|
||||
if (im.isNull() && ! onlyUpdateIfCached)
|
||||
{
|
||||
im = juce_createIconForFile (file);
|
||||
|
||||
if (im != 0)
|
||||
if (im.isValid())
|
||||
ImageCache::addImageToCache (im, hashCode);
|
||||
}
|
||||
|
||||
if (im != 0)
|
||||
if (im.isValid())
|
||||
{
|
||||
icon = im;
|
||||
triggerAsyncUpdate();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "../../graphics/imaging/juce_ImageCache.h"
|
||||
#include "../../../events/juce_AsyncUpdater.h"
|
||||
|
||||
Image* juce_createIconForFile (const File& file);
|
||||
const Image juce_createIconForFile (const File& file);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -77,7 +77,6 @@ public:
|
|||
thread.removeTimeSliceClient (this);
|
||||
|
||||
clearSubItems();
|
||||
ImageCache::release (icon);
|
||||
|
||||
if (canDeleteSubContentsList)
|
||||
delete subContentsList;
|
||||
|
|
@ -145,15 +144,14 @@ public:
|
|||
{
|
||||
updateIcon (true);
|
||||
|
||||
if (icon == 0)
|
||||
if (icon.isNull())
|
||||
thread.addTimeSliceClient (this);
|
||||
}
|
||||
|
||||
owner.getLookAndFeel()
|
||||
.drawFileBrowserRow (g, width, height,
|
||||
file.getFileName(),
|
||||
icon,
|
||||
fileSize, modTime,
|
||||
&icon, fileSize, modTime,
|
||||
isDirectory, isSelected(),
|
||||
indexInContentsList);
|
||||
}
|
||||
|
|
@ -199,26 +197,26 @@ private:
|
|||
DirectoryContentsList* subContentsList;
|
||||
bool isDirectory, canDeleteSubContentsList;
|
||||
TimeSliceThread& thread;
|
||||
Image* icon;
|
||||
Image icon;
|
||||
String fileSize;
|
||||
String modTime;
|
||||
|
||||
void updateIcon (const bool onlyUpdateIfCached)
|
||||
{
|
||||
if (icon == 0)
|
||||
if (icon.isNull())
|
||||
{
|
||||
const int hashCode = (file.getFullPathName() + "_iconCacheSalt").hashCode();
|
||||
Image* im = ImageCache::getFromHashCode (hashCode);
|
||||
Image im (ImageCache::getFromHashCode (hashCode));
|
||||
|
||||
if (im == 0 && ! onlyUpdateIfCached)
|
||||
if (im.isNull() && ! onlyUpdateIfCached)
|
||||
{
|
||||
im = juce_createIconForFile (file);
|
||||
|
||||
if (im != 0)
|
||||
if (im.isValid())
|
||||
ImageCache::addImageToCache (im, hashCode);
|
||||
}
|
||||
|
||||
if (im != 0)
|
||||
if (im.isValid())
|
||||
{
|
||||
icon = im;
|
||||
triggerAsyncUpdate();
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ void ImagePreviewComponent::timerCallback()
|
|||
{
|
||||
stopTimer();
|
||||
|
||||
currentThumbnail = 0;
|
||||
currentThumbnail = Image();
|
||||
currentDetails = String::empty;
|
||||
repaint();
|
||||
|
||||
|
|
@ -82,10 +82,10 @@ void ImagePreviewComponent::timerCallback()
|
|||
{
|
||||
currentThumbnail = format->decodeImage (*in);
|
||||
|
||||
if (currentThumbnail != 0)
|
||||
if (currentThumbnail.isValid())
|
||||
{
|
||||
int w = currentThumbnail->getWidth();
|
||||
int h = currentThumbnail->getHeight();
|
||||
int w = currentThumbnail.getWidth();
|
||||
int h = currentThumbnail.getHeight();
|
||||
|
||||
currentDetails
|
||||
<< fileToLoad.getFileName() << "\n"
|
||||
|
|
@ -95,7 +95,7 @@ void ImagePreviewComponent::timerCallback()
|
|||
|
||||
getThumbSize (w, h);
|
||||
|
||||
currentThumbnail = currentThumbnail->createCopy (w, h);
|
||||
currentThumbnail = currentThumbnail.rescaled (w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -103,12 +103,12 @@ void ImagePreviewComponent::timerCallback()
|
|||
|
||||
void ImagePreviewComponent::paint (Graphics& g)
|
||||
{
|
||||
if (currentThumbnail != 0)
|
||||
if (currentThumbnail.isValid())
|
||||
{
|
||||
g.setFont (13.0f);
|
||||
|
||||
int w = currentThumbnail->getWidth();
|
||||
int h = currentThumbnail->getHeight();
|
||||
int w = currentThumbnail.getWidth();
|
||||
int h = currentThumbnail.getHeight();
|
||||
getThumbSize (w, h);
|
||||
|
||||
const int numLines = 4;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
private:
|
||||
File fileToLoad;
|
||||
ScopedPointer <Image> currentThumbnail;
|
||||
Image currentThumbnail;
|
||||
String currentDetails;
|
||||
|
||||
void getThumbSize (int& w, int& h) const;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ Component::~Component()
|
|||
for (int i = childComponentList_.size(); --i >= 0;)
|
||||
childComponentList_.getUnchecked(i)->parentComponent_ = 0;
|
||||
|
||||
delete bufferedImage_;
|
||||
delete mouseListeners_;
|
||||
delete keyListeners_;
|
||||
}
|
||||
|
|
@ -258,7 +257,6 @@ public:
|
|||
|
||||
~FadeOutProxyComponent()
|
||||
{
|
||||
delete image;
|
||||
}
|
||||
|
||||
void paint (Graphics& g)
|
||||
|
|
@ -267,7 +265,7 @@ public:
|
|||
|
||||
g.drawImage (image,
|
||||
0, 0, getWidth(), getHeight(),
|
||||
0, 0, image->getWidth(), image->getHeight());
|
||||
0, 0, image.getWidth(), image.getHeight());
|
||||
}
|
||||
|
||||
void timerCallback()
|
||||
|
|
@ -290,8 +288,8 @@ public:
|
|||
centreY += yChangePerMs * msPassed;
|
||||
scale += scaleChangePerMs * msPassed;
|
||||
|
||||
const int w = roundToInt (image->getWidth() * scale);
|
||||
const int h = roundToInt (image->getHeight() * scale);
|
||||
const int w = roundToInt (image.getWidth() * scale);
|
||||
const int h = roundToInt (image.getHeight() * scale);
|
||||
|
||||
setBounds (roundToInt (centreX) - w / 2,
|
||||
roundToInt (centreY) - h / 2,
|
||||
|
|
@ -309,7 +307,7 @@ public:
|
|||
juce_UseDebuggingNewOperator
|
||||
|
||||
private:
|
||||
Image* image;
|
||||
Image image;
|
||||
uint32 lastTime;
|
||||
float alpha, alphaChangePerMs;
|
||||
float centreX, xChangePerMs;
|
||||
|
|
@ -511,7 +509,7 @@ void Component::setBufferedToImage (const bool shouldBeBuffered)
|
|||
{
|
||||
if (shouldBeBuffered != flags.bufferToImageFlag)
|
||||
{
|
||||
deleteAndZero (bufferedImage_);
|
||||
bufferedImage_ = Image();
|
||||
flags.bufferToImageFlag = shouldBeBuffered;
|
||||
}
|
||||
}
|
||||
|
|
@ -1549,7 +1547,7 @@ void Component::repaint()
|
|||
void Component::repaint (const int x, const int y,
|
||||
const int w, const int h)
|
||||
{
|
||||
deleteAndZero (bufferedImage_);
|
||||
bufferedImage_ = Image();
|
||||
|
||||
if (flags.visibleFlag)
|
||||
internalRepaint (x, y, w, h);
|
||||
|
|
@ -1619,12 +1617,12 @@ void Component::renderComponent (Graphics& g)
|
|||
{
|
||||
if (flags.bufferToImageFlag)
|
||||
{
|
||||
if (bufferedImage_ == 0)
|
||||
if (bufferedImage_.isNull())
|
||||
{
|
||||
bufferedImage_ = Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB,
|
||||
getWidth(), getHeight(), ! flags.opaqueFlag);
|
||||
bufferedImage_ = Image (flags.opaqueFlag ? Image::RGB : Image::ARGB,
|
||||
getWidth(), getHeight(), ! flags.opaqueFlag, Image::NativeImage);
|
||||
|
||||
Graphics imG (*bufferedImage_);
|
||||
Graphics imG (bufferedImage_);
|
||||
paint (imG);
|
||||
}
|
||||
|
||||
|
|
@ -1684,15 +1682,15 @@ void Component::paintEntireComponent (Graphics& g)
|
|||
|
||||
if (effect_ != 0)
|
||||
{
|
||||
ScopedPointer<Image> effectImage (Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB,
|
||||
getWidth(), getHeight(),
|
||||
! flags.opaqueFlag));
|
||||
Image effectImage (flags.opaqueFlag ? Image::RGB : Image::ARGB,
|
||||
getWidth(), getHeight(),
|
||||
! flags.opaqueFlag, Image::NativeImage);
|
||||
{
|
||||
Graphics g2 (*effectImage);
|
||||
Graphics g2 (effectImage);
|
||||
renderComponent (g2);
|
||||
}
|
||||
|
||||
effect_->applyEffect (*effectImage, g);
|
||||
effect_->applyEffect (effectImage, g);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1705,24 +1703,24 @@ void Component::paintEntireComponent (Graphics& g)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
Image* Component::createComponentSnapshot (const Rectangle<int>& areaToGrab,
|
||||
const bool clipImageToComponentBounds)
|
||||
const Image Component::createComponentSnapshot (const Rectangle<int>& areaToGrab,
|
||||
const bool clipImageToComponentBounds)
|
||||
{
|
||||
Rectangle<int> r (areaToGrab);
|
||||
|
||||
if (clipImageToComponentBounds)
|
||||
r = r.getIntersection (getLocalBounds());
|
||||
|
||||
ScopedPointer<Image> componentImage (Image::createNativeImage (flags.opaqueFlag ? Image::RGB : Image::ARGB,
|
||||
jmax (1, r.getWidth()),
|
||||
jmax (1, r.getHeight()),
|
||||
true));
|
||||
Image componentImage (flags.opaqueFlag ? Image::RGB : Image::ARGB,
|
||||
jmax (1, r.getWidth()),
|
||||
jmax (1, r.getHeight()),
|
||||
true);
|
||||
|
||||
Graphics imageContext (*componentImage);
|
||||
Graphics imageContext (componentImage);
|
||||
imageContext.setOrigin (-r.getX(), -r.getY());
|
||||
paintEntireComponent (imageContext);
|
||||
|
||||
return componentImage.release();
|
||||
return componentImage;
|
||||
}
|
||||
|
||||
void Component::setComponentEffect (ImageEffectFilter* const effect)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "keyboard/juce_KeyListener.h"
|
||||
#include "keyboard/juce_KeyboardFocusTraverser.h"
|
||||
#include "../graphics/effects/juce_ImageEffectFilter.h"
|
||||
#include "../graphics/imaging/juce_Image.h"
|
||||
#include "../graphics/geometry/juce_RectangleList.h"
|
||||
#include "../graphics/geometry/juce_BorderSize.h"
|
||||
#include "../../events/juce_MessageListener.h"
|
||||
|
|
@ -867,12 +868,10 @@ public:
|
|||
the size of the component, it'll be clipped. If clipImageToComponentBounds is false
|
||||
then parts of the component beyond its bounds can be drawn.
|
||||
|
||||
The caller is responsible for deleting the image that is returned.
|
||||
|
||||
@see paintEntireComponent
|
||||
*/
|
||||
Image* createComponentSnapshot (const Rectangle<int>& areaToGrab,
|
||||
bool clipImageToComponentBounds = true);
|
||||
const Image createComponentSnapshot (const Rectangle<int>& areaToGrab,
|
||||
bool clipImageToComponentBounds = true);
|
||||
|
||||
/** Draws this component and all its subcomponents onto the specified graphics
|
||||
context.
|
||||
|
|
@ -2016,7 +2015,7 @@ private:
|
|||
LookAndFeel* lookAndFeel_;
|
||||
MouseCursor cursor_;
|
||||
ImageEffectFilter* effect_;
|
||||
Image* bufferedImage_;
|
||||
Image bufferedImage_;
|
||||
Array <MouseListener*>* mouseListeners_;
|
||||
Array <KeyListener*>* keyListeners_;
|
||||
ListenerList <ComponentListener> componentListeners;
|
||||
|
|
|
|||
|
|
@ -1084,7 +1084,7 @@ void LookAndFeel::drawPopupMenuItem (Graphics& g,
|
|||
|
||||
if (image != 0)
|
||||
{
|
||||
g.drawImageWithin (image,
|
||||
g.drawImageWithin (*image,
|
||||
2, 1, leftBorder - 4, height - 2,
|
||||
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, false);
|
||||
}
|
||||
|
|
@ -1701,7 +1701,7 @@ void LookAndFeel::drawImageButton (Graphics& g, Image* image,
|
|||
{
|
||||
g.setOpacity (imageOpacity);
|
||||
|
||||
g.drawImage (image, imageX, imageY, imageW, imageH,
|
||||
g.drawImage (*image, imageX, imageY, imageW, imageH,
|
||||
0, 0, image->getWidth(), image->getHeight(), false);
|
||||
}
|
||||
|
||||
|
|
@ -1709,7 +1709,7 @@ void LookAndFeel::drawImageButton (Graphics& g, Image* image,
|
|||
{
|
||||
g.setColour (overlayColour);
|
||||
|
||||
g.drawImage (image, imageX, imageY, imageW, imageH,
|
||||
g.drawImage (*image, imageX, imageY, imageW, imageH,
|
||||
0, 0, image->getWidth(), image->getHeight(), true);
|
||||
}
|
||||
}
|
||||
|
|
@ -1804,7 +1804,7 @@ void LookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window,
|
|||
if (icon != 0)
|
||||
{
|
||||
g.setOpacity (isActive ? 1.0f : 0.6f);
|
||||
g.drawImageWithin (icon, textX, (h - iconH) / 2, iconW, iconH,
|
||||
g.drawImageWithin (*icon, textX, (h - iconH) / 2, iconW, iconH,
|
||||
RectanglePlacement::centred, false);
|
||||
textX += iconW;
|
||||
textW -= iconW;
|
||||
|
|
@ -2559,24 +2559,21 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height,
|
|||
g.setColour (findColour (DirectoryContentsDisplayComponent::textColourId));
|
||||
g.setFont (height * 0.7f);
|
||||
|
||||
Image* im = icon;
|
||||
Image* toRelease = 0;
|
||||
Image im;
|
||||
if (icon != 0)
|
||||
im = *icon;
|
||||
|
||||
if (im == 0)
|
||||
{
|
||||
toRelease = im = (isDirectory ? getDefaultFolderImage()
|
||||
: getDefaultDocumentFileImage());
|
||||
}
|
||||
if (im.isNull())
|
||||
im = isDirectory ? getDefaultFolderImage()
|
||||
: getDefaultDocumentFileImage();
|
||||
|
||||
const int x = 32;
|
||||
|
||||
if (im != 0)
|
||||
if (im.isValid())
|
||||
{
|
||||
g.drawImageWithin (im, 2, 2, x - 4, height - 4,
|
||||
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize,
|
||||
false);
|
||||
|
||||
ImageCache::release (toRelease);
|
||||
}
|
||||
|
||||
if (width > 450 && ! isDirectory)
|
||||
|
|
@ -2663,7 +2660,7 @@ void LookAndFeel::layoutFileBrowserComponent (FileBrowserComponent& browserComp,
|
|||
filenameBox->setBounds (x + 50, y, w - 50, controlsHeight);
|
||||
}
|
||||
|
||||
Image* LookAndFeel::getDefaultFolderImage()
|
||||
const Image LookAndFeel::getDefaultFolderImage()
|
||||
{
|
||||
static const unsigned char foldericon_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,32,0,0,0,28,8,6,0,0,0,0,194,189,34,0,0,0,4,103,65,77,65,0,0,175,200,55,5,
|
||||
138,233,0,0,0,25,116,69,88,116,83,111,102,116,119,97,114,101,0,65,100,111,98,101,32,73,109,97,103,101,82,101,97,100,121,113,201,101,60,0,0,9,46,73,68,65,84,120,218,98,252,255,255,63,3,50,240,41,95,192,
|
||||
|
|
@ -2713,7 +2710,7 @@ Image* LookAndFeel::getDefaultFolderImage()
|
|||
return ImageCache::getFromMemory (foldericon_png, sizeof (foldericon_png));
|
||||
}
|
||||
|
||||
Image* LookAndFeel::getDefaultDocumentFileImage()
|
||||
const Image LookAndFeel::getDefaultDocumentFileImage()
|
||||
{
|
||||
static const unsigned char fileicon_png[] = { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,32,0,0,0,32,8,6,0,0,0,115,122,122,244,0,0,0,4,103,65,77,65,0,0,175,200,55,5,
|
||||
138,233,0,0,0,25,116,69,88,116,83,111,102,116,119,97,114,101,0,65,100,111,98,101,32,73,109,97,103,101,82,101,97,100,121,113,201,101,60,0,0,4,99,73,68,65,84,120,218,98,252,255,255,63,3,12,48,50,50,50,1,
|
||||
|
|
|
|||
|
|
@ -294,8 +294,8 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
// these return an image from the ImageCache, so use ImageCache::release() to free it
|
||||
virtual Image* getDefaultFolderImage();
|
||||
virtual Image* getDefaultDocumentFileImage();
|
||||
virtual const Image getDefaultFolderImage();
|
||||
virtual const Image getDefaultDocumentFileImage();
|
||||
|
||||
virtual void createFileChooserHeaderText (const String& title,
|
||||
const String& instructions,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public:
|
|||
const String& text_,
|
||||
const bool active_,
|
||||
const bool isTicked_,
|
||||
const Image* im,
|
||||
const Image& im,
|
||||
const Colour& textColour_,
|
||||
const bool usesColour_,
|
||||
PopupMenuCustomComponent* const customComp_,
|
||||
|
|
@ -62,15 +62,12 @@ public:
|
|||
ApplicationCommandManager* const commandManager_)
|
||||
: itemId (itemId_), text (text_), textColour (textColour_),
|
||||
active (active_), isSeparator (false), isTicked (isTicked_),
|
||||
usesColour (usesColour_), customComp (customComp_),
|
||||
usesColour (usesColour_), image (im), customComp (customComp_),
|
||||
commandManager (commandManager_)
|
||||
{
|
||||
if (subMenu_ != 0)
|
||||
subMenu = new PopupMenu (*subMenu_);
|
||||
|
||||
if (im != 0)
|
||||
image = im->createCopy();
|
||||
|
||||
if (commandManager_ != 0 && itemId_ != 0)
|
||||
{
|
||||
String shortcutKey;
|
||||
|
|
@ -106,14 +103,12 @@ public:
|
|||
isSeparator (other.isSeparator),
|
||||
isTicked (other.isTicked),
|
||||
usesColour (other.usesColour),
|
||||
image (other.image),
|
||||
customComp (other.customComp),
|
||||
commandManager (other.commandManager)
|
||||
{
|
||||
if (other.subMenu != 0)
|
||||
subMenu = new PopupMenu (*(other.subMenu));
|
||||
|
||||
if (other.image != 0)
|
||||
image = other.image->createCopy();
|
||||
}
|
||||
|
||||
~Item()
|
||||
|
|
@ -136,7 +131,7 @@ public:
|
|||
String text;
|
||||
const Colour textColour;
|
||||
const bool active, isSeparator, isTicked, usesColour;
|
||||
ScopedPointer <Image> image;
|
||||
Image image;
|
||||
ReferenceCountedObjectPtr <PopupMenuCustomComponent> customComp;
|
||||
ScopedPointer <PopupMenu> subMenu;
|
||||
ApplicationCommandManager* const commandManager;
|
||||
|
|
@ -207,7 +202,7 @@ public:
|
|||
itemInfo.isTicked,
|
||||
itemInfo.subMenu != 0,
|
||||
mainText, endText,
|
||||
itemInfo.image,
|
||||
itemInfo.image.isValid() ? &itemInfo.image : 0,
|
||||
itemInfo.usesColour ? &(itemInfo.textColour) : 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1317,7 +1312,7 @@ void PopupMenu::addItem (const int itemResultId,
|
|||
const String& itemText,
|
||||
const bool isActive,
|
||||
const bool isTicked,
|
||||
const Image* const iconToUse)
|
||||
const Image& iconToUse)
|
||||
{
|
||||
jassert (itemResultId != 0); // 0 is used as a return value to indicate that the user
|
||||
// didn't pick anything, so you shouldn't use it as the id
|
||||
|
|
@ -1325,8 +1320,8 @@ void PopupMenu::addItem (const int itemResultId,
|
|||
|
||||
addSeparatorIfPending();
|
||||
|
||||
items.add (new Item (itemResultId, itemText, isActive, isTicked,
|
||||
iconToUse, Colours::black, false, 0, 0, 0));
|
||||
items.add (new Item (itemResultId, itemText, isActive, isTicked, iconToUse,
|
||||
Colours::black, false, 0, 0, 0));
|
||||
}
|
||||
|
||||
void PopupMenu::addCommandItem (ApplicationCommandManager* commandManager,
|
||||
|
|
@ -1349,7 +1344,7 @@ void PopupMenu::addCommandItem (ApplicationCommandManager* commandManager,
|
|||
: info.shortName,
|
||||
target != 0 && (info.flags & ApplicationCommandInfo::isDisabled) == 0,
|
||||
(info.flags & ApplicationCommandInfo::isTicked) != 0,
|
||||
0,
|
||||
Image(),
|
||||
Colours::black,
|
||||
false,
|
||||
0, 0,
|
||||
|
|
@ -1362,7 +1357,7 @@ void PopupMenu::addColouredItem (const int itemResultId,
|
|||
const Colour& itemTextColour,
|
||||
const bool isActive,
|
||||
const bool isTicked,
|
||||
const Image* const iconToUse)
|
||||
const Image& iconToUse)
|
||||
{
|
||||
jassert (itemResultId != 0); // 0 is used as a return value to indicate that the user
|
||||
// didn't pick anything, so you shouldn't use it as the id
|
||||
|
|
@ -1370,8 +1365,8 @@ void PopupMenu::addColouredItem (const int itemResultId,
|
|||
|
||||
addSeparatorIfPending();
|
||||
|
||||
items.add (new Item (itemResultId, itemText, isActive, isTicked,
|
||||
iconToUse, itemTextColour, true, 0, 0, 0));
|
||||
items.add (new Item (itemResultId, itemText, isActive, isTicked, iconToUse,
|
||||
itemTextColour, true, 0, 0, 0));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -1384,7 +1379,7 @@ void PopupMenu::addCustomItem (const int itemResultId,
|
|||
|
||||
addSeparatorIfPending();
|
||||
|
||||
items.add (new Item (itemResultId, String::empty, true, false, 0,
|
||||
items.add (new Item (itemResultId, String::empty, true, false, Image(),
|
||||
Colours::black, false, customComponent, 0, 0));
|
||||
}
|
||||
|
||||
|
|
@ -1439,7 +1434,7 @@ void PopupMenu::addCustomItem (const int itemResultId,
|
|||
void PopupMenu::addSubMenu (const String& subMenuName,
|
||||
const PopupMenu& subMenu,
|
||||
const bool isActive,
|
||||
Image* const iconToUse,
|
||||
const Image& iconToUse,
|
||||
const bool isTicked)
|
||||
{
|
||||
addSeparatorIfPending();
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ public:
|
|||
const String& itemText,
|
||||
bool isActive = true,
|
||||
bool isTicked = false,
|
||||
const Image* iconToUse = 0);
|
||||
const Image& iconToUse = Image());
|
||||
|
||||
/** Adds an item that represents one of the commands in a command manager object.
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ public:
|
|||
const Colour& itemTextColour,
|
||||
bool isActive = true,
|
||||
bool isTicked = false,
|
||||
const Image* iconToUse = 0);
|
||||
const Image& iconToUse = Image());
|
||||
|
||||
/** Appends a custom menu item.
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ public:
|
|||
void addSubMenu (const String& subMenuName,
|
||||
const PopupMenu& subMenu,
|
||||
bool isActive = true,
|
||||
Image* iconToUse = 0,
|
||||
const Image& iconToUse = Image(),
|
||||
bool isTicked = false);
|
||||
|
||||
/** Appends a separator to the menu, to help break it up into sections.
|
||||
|
|
@ -357,7 +357,7 @@ public:
|
|||
bool isCustomComponent;
|
||||
bool isSectionHeader;
|
||||
const Colour* customColour;
|
||||
const Image* customImage;
|
||||
Image customImage;
|
||||
ApplicationCommandManager* commandManager;
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class DragImageComponent : public Component,
|
|||
public Timer
|
||||
{
|
||||
public:
|
||||
DragImageComponent (Image* const im,
|
||||
DragImageComponent (const Image& im,
|
||||
const String& desc,
|
||||
Component* const sourceComponent,
|
||||
Component* const mouseDragSource_,
|
||||
|
|
@ -61,7 +61,7 @@ public:
|
|||
hasCheckedForExternalDrag (false),
|
||||
drawImage (true)
|
||||
{
|
||||
setSize (im->getWidth(), im->getHeight());
|
||||
setSize (im.getWidth(), im.getHeight());
|
||||
|
||||
if (mouseDragSource == 0)
|
||||
mouseDragSource = source;
|
||||
|
|
@ -280,7 +280,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
ScopedPointer<Image> image;
|
||||
Image image;
|
||||
Component::SafePointer<Component> source;
|
||||
Component::SafePointer<Component> mouseDragSource;
|
||||
DragAndDropContainer* const owner;
|
||||
|
|
@ -312,11 +312,11 @@ DragAndDropContainer::~DragAndDropContainer()
|
|||
|
||||
void DragAndDropContainer::startDragging (const String& sourceDescription,
|
||||
Component* sourceComponent,
|
||||
Image* dragImage_,
|
||||
const Image& dragImage_,
|
||||
const bool allowDraggingToExternalWindows,
|
||||
const Point<int>* imageOffsetFromMouse)
|
||||
{
|
||||
ScopedPointer <Image> dragImage (dragImage_);
|
||||
Image dragImage (dragImage_);
|
||||
|
||||
if (dragImageComponent == 0)
|
||||
{
|
||||
|
|
@ -339,32 +339,24 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
|
|||
const Point<int> lastMouseDown (Desktop::getLastMouseDownPosition());
|
||||
Point<int> imageOffset;
|
||||
|
||||
if (dragImage == 0)
|
||||
if (dragImage.isNull())
|
||||
{
|
||||
dragImage = sourceComponent->createComponentSnapshot (sourceComponent->getLocalBounds());
|
||||
dragImage = sourceComponent->createComponentSnapshot (sourceComponent->getLocalBounds())
|
||||
.convertedToFormat (Image::ARGB);
|
||||
|
||||
if (dragImage->getFormat() != Image::ARGB)
|
||||
{
|
||||
Image* newIm = Image::createNativeImage (Image::ARGB, dragImage->getWidth(), dragImage->getHeight(), true);
|
||||
Graphics g2 (*newIm);
|
||||
g2.drawImageAt (dragImage, 0, 0);
|
||||
|
||||
dragImage = newIm;
|
||||
}
|
||||
|
||||
dragImage->multiplyAllAlphas (0.6f);
|
||||
dragImage.multiplyAllAlphas (0.6f);
|
||||
|
||||
const int lo = 150;
|
||||
const int hi = 400;
|
||||
|
||||
Point<int> relPos (sourceComponent->globalPositionToRelative (lastMouseDown));
|
||||
Point<int> clipped (dragImage->getBounds().getConstrainedPoint (relPos));
|
||||
Point<int> clipped (dragImage.getBounds().getConstrainedPoint (relPos));
|
||||
|
||||
for (int y = dragImage->getHeight(); --y >= 0;)
|
||||
for (int y = dragImage.getHeight(); --y >= 0;)
|
||||
{
|
||||
const double dy = (y - clipped.getY()) * (y - clipped.getY());
|
||||
|
||||
for (int x = dragImage->getWidth(); --x >= 0;)
|
||||
for (int x = dragImage.getWidth(); --x >= 0;)
|
||||
{
|
||||
const int dx = x - clipped.getX();
|
||||
const int distance = roundToInt (std::sqrt (dx * dx + dy));
|
||||
|
|
@ -375,7 +367,7 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
|
|||
: (hi - distance) / (float) (hi - lo)
|
||||
+ Random::getSystemRandom().nextFloat() * 0.008f;
|
||||
|
||||
dragImage->multiplyAlphaAt (x, y, alpha);
|
||||
dragImage.multiplyAlphaAt (x, y, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -385,12 +377,12 @@ void DragAndDropContainer::startDragging (const String& sourceDescription,
|
|||
else
|
||||
{
|
||||
if (imageOffsetFromMouse == 0)
|
||||
imageOffset = -dragImage->getBounds().getCentre();
|
||||
imageOffset = -dragImage.getBounds().getCentre();
|
||||
else
|
||||
imageOffset = -(dragImage->getBounds().getConstrainedPoint (-*imageOffsetFromMouse));
|
||||
imageOffset = -(dragImage.getBounds().getConstrainedPoint (-*imageOffsetFromMouse));
|
||||
}
|
||||
|
||||
dragImageComponent = new DragImageComponent (dragImage.release(), sourceDescription, sourceComponent,
|
||||
dragImageComponent = new DragImageComponent (dragImage, sourceDescription, sourceComponent,
|
||||
draggingSource->getComponentUnderMouse(), this, imageOffset);
|
||||
|
||||
currentDragDesc = sourceDescription;
|
||||
|
|
|
|||
|
|
@ -78,10 +78,8 @@ public:
|
|||
dropped-onto so they can decide if they want to handle it or
|
||||
not
|
||||
@param sourceComponent the component that is being dragged
|
||||
@param dragImage the image to drag around underneath the mouse. If this is
|
||||
zero, a snapshot of the sourceComponent will be used instead. An
|
||||
image passed-in will be deleted by this object when no longer
|
||||
needed.
|
||||
@param dragImage the image to drag around underneath the mouse. If this is a null image,
|
||||
a snapshot of the sourceComponent will be used instead.
|
||||
@param allowDraggingToOtherJuceWindows if true, the dragged component will appear as a desktop
|
||||
window, and can be dragged to DragAndDropTargets that are the
|
||||
children of components other than this one.
|
||||
|
|
@ -92,7 +90,7 @@ public:
|
|||
*/
|
||||
void startDragging (const String& sourceDescription,
|
||||
Component* sourceComponent,
|
||||
Image* dragImage = 0,
|
||||
const Image& dragImage = Image(),
|
||||
bool allowDraggingToOtherJuceWindows = false,
|
||||
const Point<int>* imageOffsetFromMouse = 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -114,13 +114,13 @@ public:
|
|||
|
||||
void paint (Graphics& g)
|
||||
{
|
||||
if (colours == 0)
|
||||
if (colours.isNull())
|
||||
{
|
||||
const int width = getWidth() / 2;
|
||||
const int height = getHeight() / 2;
|
||||
colours = new Image (Image::RGB, width, height, false);
|
||||
colours = Image (Image::RGB, width, height, false);
|
||||
|
||||
Image::BitmapData pixels (*colours, 0, 0, width, height, true);
|
||||
Image::BitmapData pixels (colours, 0, 0, width, height, true);
|
||||
|
||||
for (int y = 0; y < height; ++y)
|
||||
{
|
||||
|
|
@ -129,17 +129,15 @@ public:
|
|||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
const float sat = x / (float) width;
|
||||
const Colour col (h, sat, val, 1.0f);
|
||||
|
||||
PixelRGB* const pix = (PixelRGB*) pixels.getPixelPointer (x, y);
|
||||
pix->set (col.getPixelARGB());
|
||||
pixels.setPixelColour (x, y, Colour (h, sat, val, 1.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g.setOpacity (1.0f);
|
||||
g.drawImage (colours, edge, edge, getWidth() - edge * 2, getHeight() - edge * 2,
|
||||
0, 0, colours->getWidth(), colours->getHeight());
|
||||
0, 0, colours.getWidth(), colours.getHeight());
|
||||
}
|
||||
|
||||
void mouseDown (const MouseEvent& e)
|
||||
|
|
@ -160,7 +158,7 @@ public:
|
|||
if (lastHue != h)
|
||||
{
|
||||
lastHue = h;
|
||||
colours = 0;
|
||||
colours = Image();
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
|
@ -169,7 +167,7 @@ public:
|
|||
|
||||
void resized()
|
||||
{
|
||||
colours = 0;
|
||||
colours = Image();
|
||||
updateMarker();
|
||||
}
|
||||
|
||||
|
|
@ -181,8 +179,7 @@ private:
|
|||
float lastHue;
|
||||
ColourSpaceMarker* marker;
|
||||
const int edge;
|
||||
|
||||
ScopedPointer <Image> colours;
|
||||
Image colours;
|
||||
|
||||
void updateMarker() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,17 +39,19 @@ BEGIN_JUCE_NAMESPACE
|
|||
class ShadowWindow : public Component
|
||||
{
|
||||
Component* owner;
|
||||
Image** shadowImageSections;
|
||||
Image shadowImageSections [12];
|
||||
const int type; // 0 = left, 1 = right, 2 = top, 3 = bottom. left + right are full-height
|
||||
|
||||
public:
|
||||
ShadowWindow (Component* const owner_,
|
||||
const int type_,
|
||||
Image** const shadowImageSections_)
|
||||
const Image shadowImageSections_ [12])
|
||||
: owner (owner_),
|
||||
shadowImageSections (shadowImageSections_),
|
||||
type (type_)
|
||||
{
|
||||
for (int i = 0; i < numElementsInArray (shadowImageSections); ++i)
|
||||
shadowImageSections [i] = shadowImageSections_ [i];
|
||||
|
||||
setInterceptsMouseClicks (false, false);
|
||||
|
||||
if (owner_->isOnDesktop())
|
||||
|
|
@ -71,41 +73,41 @@ public:
|
|||
|
||||
void paint (Graphics& g)
|
||||
{
|
||||
Image* const topLeft = shadowImageSections [type * 3];
|
||||
Image* const bottomRight = shadowImageSections [type * 3 + 1];
|
||||
Image* const filler = shadowImageSections [type * 3 + 2];
|
||||
const Image& topLeft = shadowImageSections [type * 3];
|
||||
const Image& bottomRight = shadowImageSections [type * 3 + 1];
|
||||
const Image& filler = shadowImageSections [type * 3 + 2];
|
||||
|
||||
g.setOpacity (1.0f);
|
||||
|
||||
if (type < 2)
|
||||
{
|
||||
int imH = jmin (topLeft->getHeight(), getHeight() / 2);
|
||||
int imH = jmin (topLeft.getHeight(), getHeight() / 2);
|
||||
g.drawImage (topLeft,
|
||||
0, 0, topLeft->getWidth(), imH,
|
||||
0, 0, topLeft->getWidth(), imH);
|
||||
0, 0, topLeft.getWidth(), imH,
|
||||
0, 0, topLeft.getWidth(), imH);
|
||||
|
||||
imH = jmin (bottomRight->getHeight(), getHeight() - getHeight() / 2);
|
||||
imH = jmin (bottomRight.getHeight(), getHeight() - getHeight() / 2);
|
||||
g.drawImage (bottomRight,
|
||||
0, getHeight() - imH, bottomRight->getWidth(), imH,
|
||||
0, bottomRight->getHeight() - imH, bottomRight->getWidth(), imH);
|
||||
0, getHeight() - imH, bottomRight.getWidth(), imH,
|
||||
0, bottomRight.getHeight() - imH, bottomRight.getWidth(), imH);
|
||||
|
||||
g.setTiledImageFill (*filler, 0, 0, 1.0f);
|
||||
g.fillRect (0, topLeft->getHeight(), getWidth(), getHeight() - (topLeft->getHeight() + bottomRight->getHeight()));
|
||||
g.setTiledImageFill (filler, 0, 0, 1.0f);
|
||||
g.fillRect (0, topLeft.getHeight(), getWidth(), getHeight() - (topLeft.getHeight() + bottomRight.getHeight()));
|
||||
}
|
||||
else
|
||||
{
|
||||
int imW = jmin (topLeft->getWidth(), getWidth() / 2);
|
||||
int imW = jmin (topLeft.getWidth(), getWidth() / 2);
|
||||
g.drawImage (topLeft,
|
||||
0, 0, imW, topLeft->getHeight(),
|
||||
0, 0, imW, topLeft->getHeight());
|
||||
0, 0, imW, topLeft.getHeight(),
|
||||
0, 0, imW, topLeft.getHeight());
|
||||
|
||||
imW = jmin (bottomRight->getWidth(), getWidth() - getWidth() / 2);
|
||||
imW = jmin (bottomRight.getWidth(), getWidth() - getWidth() / 2);
|
||||
g.drawImage (bottomRight,
|
||||
getWidth() - imW, 0, imW, bottomRight->getHeight(),
|
||||
bottomRight->getWidth() - imW, 0, imW, bottomRight->getHeight());
|
||||
getWidth() - imW, 0, imW, bottomRight.getHeight(),
|
||||
bottomRight.getWidth() - imW, 0, imW, bottomRight.getHeight());
|
||||
|
||||
g.setTiledImageFill (*filler, 0, 0, 1.0f);
|
||||
g.fillRect (topLeft->getWidth(), 0, getWidth() - (topLeft->getWidth() + bottomRight->getWidth()), getHeight());
|
||||
g.setTiledImageFill (filler, 0, 0, 1.0f);
|
||||
g.fillRect (topLeft.getWidth(), 0, getWidth() - (topLeft.getWidth() + bottomRight.getWidth()), getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -155,9 +157,6 @@ void DropShadower::deleteShadowWindows()
|
|||
for (i = numShadows; --i >= 0;)
|
||||
delete shadowWindows[i];
|
||||
|
||||
for (i = 12; --i >= 0;)
|
||||
delete shadowImageSections[i];
|
||||
|
||||
numShadows = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -235,31 +234,31 @@ void DropShadower::updateShadows()
|
|||
|
||||
const int hash = imageId.hashCode();
|
||||
|
||||
Image* bigIm = ImageCache::getFromHashCode (hash);
|
||||
Image bigIm (ImageCache::getFromHashCode (hash));
|
||||
|
||||
if (bigIm == 0)
|
||||
if (bigIm.isNull())
|
||||
{
|
||||
bigIm = Image::createNativeImage (Image::ARGB, shadowEdge * 5, shadowEdge * 5, true);
|
||||
bigIm = Image (Image::ARGB, shadowEdge * 5, shadowEdge * 5, true, Image::NativeImage);
|
||||
|
||||
Graphics bigG (*bigIm);
|
||||
Graphics bigG (bigIm);
|
||||
bigG.setColour (Colours::black.withAlpha (alpha));
|
||||
bigG.fillRect (shadowEdge + xOffset,
|
||||
shadowEdge + yOffset,
|
||||
bigIm->getWidth() - (shadowEdge * 2),
|
||||
bigIm->getHeight() - (shadowEdge * 2));
|
||||
bigIm.getWidth() - (shadowEdge * 2),
|
||||
bigIm.getHeight() - (shadowEdge * 2));
|
||||
|
||||
ImageConvolutionKernel blurKernel (roundToInt (blurRadius * 2.0f));
|
||||
blurKernel.createGaussianBlur (blurRadius);
|
||||
|
||||
blurKernel.applyToImage (*bigIm, 0,
|
||||
blurKernel.applyToImage (bigIm, bigIm,
|
||||
Rectangle<int> (xOffset, yOffset,
|
||||
bigIm->getWidth(), bigIm->getHeight()));
|
||||
bigIm.getWidth(), bigIm.getHeight()));
|
||||
|
||||
ImageCache::addImageToCache (bigIm, hash);
|
||||
}
|
||||
|
||||
const int iw = bigIm->getWidth();
|
||||
const int ih = bigIm->getHeight();
|
||||
const int iw = bigIm.getWidth();
|
||||
const int ih = bigIm.getHeight();
|
||||
const int shadowEdge2 = shadowEdge * 2;
|
||||
|
||||
setShadowImage (bigIm, 0, shadowEdge, shadowEdge2, 0, 0);
|
||||
|
|
@ -275,8 +274,6 @@ void DropShadower::updateShadows()
|
|||
setShadowImage (bigIm, 10, shadowEdge, shadowEdge, iw - shadowEdge2, ih - shadowEdge);
|
||||
setShadowImage (bigIm, 11, shadowEdge, shadowEdge, shadowEdge2, ih - shadowEdge);
|
||||
|
||||
ImageCache::release (bigIm);
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
shadowWindows[numShadows] = new ShadowWindow (owner, i, shadowImageSections);
|
||||
|
|
@ -324,12 +321,12 @@ void DropShadower::updateShadows()
|
|||
bringShadowWindowsToFront();
|
||||
}
|
||||
|
||||
void DropShadower::setShadowImage (Image* const src, const int num, const int w, const int h,
|
||||
void DropShadower::setShadowImage (const Image& src, const int num, const int w, const int h,
|
||||
const int sx, const int sy)
|
||||
{
|
||||
shadowImageSections[num] = new Image (Image::ARGB, w, h, true);
|
||||
shadowImageSections[num] = Image (Image::ARGB, w, h, true, Image::NativeImage);
|
||||
|
||||
Graphics g (*shadowImageSections[num]);
|
||||
Graphics g (shadowImageSections[num]);
|
||||
g.drawImage (src, 0, 0, w, h, sx, sy, w, h);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,13 +86,13 @@ private:
|
|||
Component* owner;
|
||||
int numShadows;
|
||||
Component* shadowWindows[4];
|
||||
Image* shadowImageSections[12];
|
||||
Image shadowImageSections[12];
|
||||
const int shadowEdge, xOffset, yOffset;
|
||||
const float alpha, blurRadius;
|
||||
bool inDestructor, reentrant;
|
||||
|
||||
void updateShadows();
|
||||
void setShadowImage (Image* const src,
|
||||
void setShadowImage (const Image& src,
|
||||
const int num,
|
||||
const int w, const int h,
|
||||
const int sx, const int sy);
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ void MagnifierComponent::paint (Graphics& g)
|
|||
}
|
||||
|
||||
g.setImageResamplingQuality (quality);
|
||||
g.drawImageTransformed (&temp, temp.getBounds(),
|
||||
g.drawImageTransformed (temp, temp.getBounds(),
|
||||
AffineTransform::scale ((float) scaleFactor, (float) scaleFactor),
|
||||
false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,16 +67,16 @@ void PreferencesPanel::addSettingsPage (const String& title,
|
|||
}
|
||||
|
||||
void PreferencesPanel::addSettingsPage (const String& title,
|
||||
const char* imageData,
|
||||
const void* imageData,
|
||||
const int imageDataSize)
|
||||
{
|
||||
DrawableImage icon, iconOver, iconDown;
|
||||
icon.setImage (ImageCache::getFromMemory (imageData, imageDataSize), true);
|
||||
icon.setImage (ImageCache::getFromMemory (imageData, imageDataSize));
|
||||
|
||||
iconOver.setImage (ImageCache::getFromMemory (imageData, imageDataSize), true);
|
||||
iconOver.setImage (ImageCache::getFromMemory (imageData, imageDataSize));
|
||||
iconOver.setOverlayColour (Colours::black.withAlpha (0.12f));
|
||||
|
||||
iconDown.setImage (ImageCache::getFromMemory (imageData, imageDataSize), true);
|
||||
iconDown.setImage (ImageCache::getFromMemory (imageData, imageDataSize));
|
||||
iconDown.setOverlayColour (Colours::black.withAlpha (0.25f));
|
||||
|
||||
addSettingsPage (title, &icon, &iconOver, &iconDown);
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public:
|
|||
@param imageDataSize the size of the image data, in bytes
|
||||
*/
|
||||
void addSettingsPage (const String& pageTitle,
|
||||
const char* imageData,
|
||||
const void* imageData,
|
||||
int imageDataSize);
|
||||
|
||||
/** Utility method to display this panel in a DialogWindow.
|
||||
|
|
|
|||
|
|
@ -107,9 +107,9 @@ void DocumentWindow::setName (const String& newName)
|
|||
}
|
||||
}
|
||||
|
||||
void DocumentWindow::setIcon (const Image* imageToUse)
|
||||
void DocumentWindow::setIcon (const Image& imageToUse)
|
||||
{
|
||||
titleBarIcon = imageToUse != 0 ? imageToUse->createCopy() : 0;
|
||||
titleBarIcon = imageToUse;
|
||||
repaintTitleBar();
|
||||
}
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ void DocumentWindow::paint (Graphics& g)
|
|||
titleBarArea.getHeight(),
|
||||
titleSpaceX1,
|
||||
jmax (1, titleSpaceX2 - titleSpaceX1),
|
||||
titleBarIcon,
|
||||
titleBarIcon.isValid() ? &titleBarIcon : 0,
|
||||
! drawTitleTextCentred);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public:
|
|||
image after calling this. If 0 is passed-in, any existing icon will be
|
||||
removed.
|
||||
*/
|
||||
void setIcon (const Image* imageToUse);
|
||||
void setIcon (const Image& imageToUse);
|
||||
|
||||
/** Changes the height of the title-bar. */
|
||||
void setTitleBarHeight (int newHeight);
|
||||
|
|
@ -249,7 +249,7 @@ private:
|
|||
int titleBarHeight, menuBarHeight, requiredButtons;
|
||||
bool positionTitleBarButtonsOnLeft, drawTitleTextCentred;
|
||||
ScopedPointer <Button> titleBarButtons [3];
|
||||
ScopedPointer <Image> titleBarIcon;
|
||||
Image titleBarIcon;
|
||||
ScopedPointer <MenuBarComponent> menuBar;
|
||||
MenuBarModel* menuBarModel;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,34 +36,32 @@ BEGIN_JUCE_NAMESPACE
|
|||
|
||||
//==============================================================================
|
||||
SplashScreen::SplashScreen()
|
||||
: backgroundImage (0)
|
||||
{
|
||||
setOpaque (true);
|
||||
}
|
||||
|
||||
SplashScreen::~SplashScreen()
|
||||
{
|
||||
ImageCache::releaseOrDelete (backgroundImage);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void SplashScreen::show (const String& title,
|
||||
Image* const backgroundImage_,
|
||||
const Image& backgroundImage_,
|
||||
const int minimumTimeToDisplayFor,
|
||||
const bool useDropShadow,
|
||||
const bool removeOnMouseClick)
|
||||
{
|
||||
backgroundImage = backgroundImage_;
|
||||
|
||||
jassert (backgroundImage_ != 0);
|
||||
jassert (backgroundImage_.isValid());
|
||||
|
||||
if (backgroundImage_ != 0)
|
||||
if (backgroundImage_.isValid())
|
||||
{
|
||||
setOpaque (! backgroundImage_->hasAlphaChannel());
|
||||
setOpaque (! backgroundImage_.hasAlphaChannel());
|
||||
|
||||
show (title,
|
||||
backgroundImage_->getWidth(),
|
||||
backgroundImage_->getHeight(),
|
||||
backgroundImage_.getWidth(),
|
||||
backgroundImage_.getHeight(),
|
||||
minimumTimeToDisplayFor,
|
||||
useDropShadow,
|
||||
removeOnMouseClick);
|
||||
|
|
@ -101,14 +99,11 @@ void SplashScreen::show (const String& title,
|
|||
//==============================================================================
|
||||
void SplashScreen::paint (Graphics& g)
|
||||
{
|
||||
if (backgroundImage != 0)
|
||||
{
|
||||
g.setOpacity (1.0f);
|
||||
g.setOpacity (1.0f);
|
||||
|
||||
g.drawImage (backgroundImage,
|
||||
0, 0, getWidth(), getHeight(),
|
||||
0, 0, backgroundImage->getWidth(), backgroundImage->getHeight());
|
||||
}
|
||||
g.drawImage (backgroundImage,
|
||||
0, 0, getWidth(), getHeight(),
|
||||
0, 0, backgroundImage.getWidth(), backgroundImage.getHeight());
|
||||
}
|
||||
|
||||
void SplashScreen::timerCallback()
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public:
|
|||
the mouse (anywhere)
|
||||
*/
|
||||
void show (const String& title,
|
||||
Image* backgroundImage,
|
||||
const Image& backgroundImage,
|
||||
int minimumTimeToDisplayFor,
|
||||
bool useDropShadow,
|
||||
bool removeOnMouseClick = true);
|
||||
|
|
@ -141,7 +141,7 @@ public:
|
|||
juce_UseDebuggingNewOperator
|
||||
|
||||
private:
|
||||
Image* backgroundImage;
|
||||
Image backgroundImage;
|
||||
Time earliestTimeToDelete;
|
||||
int originalClickCounter;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ FillType::FillType (const ColourGradient& gradient_)
|
|||
}
|
||||
|
||||
FillType::FillType (const Image& image_, const AffineTransform& transform_) throw()
|
||||
: colour (0xff000000), image (&image_), transform (transform_)
|
||||
: colour (0xff000000), image (image_), transform (transform_)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ bool FillType::operator!= (const FillType& other) const
|
|||
void FillType::setColour (const Colour& newColour) throw()
|
||||
{
|
||||
gradient = 0;
|
||||
image = 0;
|
||||
image = Image();
|
||||
colour = newColour;
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ void FillType::setGradient (const ColourGradient& newGradient)
|
|||
}
|
||||
else
|
||||
{
|
||||
image = 0;
|
||||
image = Image();
|
||||
gradient = new ColourGradient (newGradient);
|
||||
colour = Colours::black;
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ void FillType::setGradient (const ColourGradient& newGradient)
|
|||
void FillType::setTiledImage (const Image& image_, const AffineTransform& transform_) throw()
|
||||
{
|
||||
gradient = 0;
|
||||
image = &image_;
|
||||
image = image_;
|
||||
transform = transform_;
|
||||
colour = Colours::black;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
#define __JUCE_FILLTYPE_JUCEHEADER__
|
||||
|
||||
#include "../colour/juce_ColourGradient.h"
|
||||
#include "../imaging/juce_Image.h"
|
||||
#include "../../../containers/juce_ScopedPointer.h"
|
||||
class Image;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -72,13 +72,13 @@ public:
|
|||
~FillType() throw();
|
||||
|
||||
/** Returns true if this is a solid colour fill, and not a gradient or image. */
|
||||
bool isColour() const throw() { return gradient == 0 && image == 0; }
|
||||
bool isColour() const throw() { return gradient == 0 && image.isNull(); }
|
||||
|
||||
/** Returns true if this is a gradient fill. */
|
||||
bool isGradient() const throw() { return gradient != 0; }
|
||||
|
||||
/** Returns true if this is a tiled image pattern fill. */
|
||||
bool isTiledImage() const throw() { return image != 0; }
|
||||
bool isTiledImage() const throw() { return image.isValid(); }
|
||||
|
||||
/** Turns this object into a solid colour fill.
|
||||
If the object was an image or gradient, those fields will no longer be valid. */
|
||||
|
|
@ -123,13 +123,11 @@ public:
|
|||
*/
|
||||
ScopedPointer <ColourGradient> gradient;
|
||||
|
||||
/** Returns the image that should be used for tiling.
|
||||
The FillType object just keeps a pointer to this image, it doesn't own it, so you have to
|
||||
be careful to make sure the image doesn't get deleted while it's being used.
|
||||
/** The image that should be used for tiling.
|
||||
If an image fill is active, the overall opacity with which it should be applied
|
||||
is indicated by the alpha channel of the colour variable.
|
||||
*/
|
||||
const Image* image;
|
||||
Image image;
|
||||
|
||||
/** The transform that should be applied to the image or gradient that's being drawn.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ BEGIN_JUCE_NAMESPACE
|
|||
#include "../geometry/juce_PathStrokeType.h"
|
||||
#include "juce_LowLevelGraphicsContext.h"
|
||||
|
||||
|
||||
static const Graphics::ResamplingQuality defaultQuality = Graphics::mediumResamplingQuality;
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -56,7 +57,7 @@ LowLevelGraphicsContext::~LowLevelGraphicsContext()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
Graphics::Graphics (Image& imageToDrawOnto)
|
||||
Graphics::Graphics (const Image& imageToDrawOnto)
|
||||
: context (imageToDrawOnto.createLowLevelContext()),
|
||||
contextToDelete (context),
|
||||
saveStatePending (false)
|
||||
|
|
@ -608,23 +609,20 @@ void Graphics::setImageResamplingQuality (const Graphics::ResamplingQuality newQ
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void Graphics::drawImageAt (const Image* const imageToDraw,
|
||||
void Graphics::drawImageAt (const Image& imageToDraw,
|
||||
const int topLeftX, const int topLeftY,
|
||||
const bool fillAlphaChannelWithCurrentBrush) const
|
||||
{
|
||||
if (imageToDraw != 0)
|
||||
{
|
||||
const int imageW = imageToDraw->getWidth();
|
||||
const int imageH = imageToDraw->getHeight();
|
||||
const int imageW = imageToDraw.getWidth();
|
||||
const int imageH = imageToDraw.getHeight();
|
||||
|
||||
drawImage (imageToDraw,
|
||||
topLeftX, topLeftY, imageW, imageH,
|
||||
0, 0, imageW, imageH,
|
||||
fillAlphaChannelWithCurrentBrush);
|
||||
}
|
||||
drawImage (imageToDraw,
|
||||
topLeftX, topLeftY, imageW, imageH,
|
||||
0, 0, imageW, imageH,
|
||||
fillAlphaChannelWithCurrentBrush);
|
||||
}
|
||||
|
||||
void Graphics::drawImageWithin (const Image* const imageToDraw,
|
||||
void Graphics::drawImageWithin (const Image& imageToDraw,
|
||||
const int destX, const int destY,
|
||||
const int destW, const int destH,
|
||||
const RectanglePlacement& placementWithinTarget,
|
||||
|
|
@ -633,10 +631,10 @@ void Graphics::drawImageWithin (const Image* const imageToDraw,
|
|||
// passing in a silly number can cause maths problems in rendering!
|
||||
jassert (areCoordsSensibleNumbers (destX, destY, destW, destH));
|
||||
|
||||
if (imageToDraw != 0)
|
||||
if (imageToDraw.isValid())
|
||||
{
|
||||
const int imageW = imageToDraw->getWidth();
|
||||
const int imageH = imageToDraw->getHeight();
|
||||
const int imageW = imageToDraw.getWidth();
|
||||
const int imageH = imageToDraw.getHeight();
|
||||
|
||||
if (imageW > 0 && imageH > 0)
|
||||
{
|
||||
|
|
@ -659,7 +657,7 @@ void Graphics::drawImageWithin (const Image* const imageToDraw,
|
|||
}
|
||||
}
|
||||
|
||||
void Graphics::drawImage (const Image* const imageToDraw,
|
||||
void Graphics::drawImage (const Image& imageToDraw,
|
||||
int dx, int dy, int dw, int dh,
|
||||
int sx, int sy, int sw, int sh,
|
||||
const bool fillAlphaChannelWithCurrentBrush) const
|
||||
|
|
@ -668,7 +666,7 @@ void Graphics::drawImage (const Image* const imageToDraw,
|
|||
jassert (areCoordsSensibleNumbers (dx, dy, dw, dh));
|
||||
jassert (areCoordsSensibleNumbers (sx, sy, sw, sh));
|
||||
|
||||
if (context->clipRegionIntersects (Rectangle<int> (dx, dy, dw, dh)))
|
||||
if (imageToDraw.isValid() && context->clipRegionIntersects (Rectangle<int> (dx, dy, dw, dh)))
|
||||
{
|
||||
drawImageTransformed (imageToDraw, Rectangle<int> (sx, sy, sw, sh),
|
||||
AffineTransform::scale (dw / (float) sw, dh / (float) sh)
|
||||
|
|
@ -677,25 +675,25 @@ void Graphics::drawImage (const Image* const imageToDraw,
|
|||
}
|
||||
}
|
||||
|
||||
void Graphics::drawImageTransformed (const Image* const imageToDraw,
|
||||
void Graphics::drawImageTransformed (const Image& imageToDraw,
|
||||
const Rectangle<int>& imageSubRegion,
|
||||
const AffineTransform& transform,
|
||||
const bool fillAlphaChannelWithCurrentBrush) const
|
||||
{
|
||||
if (imageToDraw != 0 && ! context->isClipEmpty())
|
||||
if (imageToDraw.isValid() && ! context->isClipEmpty())
|
||||
{
|
||||
const Rectangle<int> srcClip (imageSubRegion.getIntersection (imageToDraw->getBounds()));
|
||||
const Rectangle<int> srcClip (imageSubRegion.getIntersection (imageToDraw.getBounds()));
|
||||
|
||||
if (fillAlphaChannelWithCurrentBrush)
|
||||
{
|
||||
context->saveState();
|
||||
context->clipToImageAlpha (*imageToDraw, srcClip, transform);
|
||||
context->clipToImageAlpha (imageToDraw, srcClip, transform);
|
||||
fillAll();
|
||||
context->restoreState();
|
||||
}
|
||||
else
|
||||
{
|
||||
context->drawImage (*imageToDraw, srcClip, transform, false);
|
||||
context->drawImage (imageToDraw, srcClip, transform, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,11 @@
|
|||
#include "../geometry/juce_PathStrokeType.h"
|
||||
#include "../geometry/juce_Line.h"
|
||||
#include "../colour/juce_Colours.h"
|
||||
#include "juce_FillType.h"
|
||||
#include "../colour/juce_ColourGradient.h"
|
||||
#include "juce_RectanglePlacement.h"
|
||||
class LowLevelGraphicsContext;
|
||||
class Image;
|
||||
class FillType;
|
||||
class RectangleList;
|
||||
|
||||
|
||||
|
|
@ -64,7 +65,7 @@ public:
|
|||
|
||||
Obviously you shouldn't delete the image before this context is deleted.
|
||||
*/
|
||||
explicit Graphics (Image& imageToDrawOnto);
|
||||
explicit Graphics (const Image& imageToDrawOnto);
|
||||
|
||||
/** Destructor. */
|
||||
~Graphics();
|
||||
|
|
@ -462,7 +463,7 @@ public:
|
|||
don't want it to be drawn semi-transparently, be sure to call setOpacity (1.0f)
|
||||
(or setColour() with an opaque colour) before drawing images.
|
||||
*/
|
||||
void drawImageAt (const Image* const imageToDraw, int topLeftX, int topLeftY,
|
||||
void drawImageAt (const Image& imageToDraw, int topLeftX, int topLeftY,
|
||||
bool fillAlphaChannelWithCurrentBrush = false) const;
|
||||
|
||||
/** Draws part of an image, rescaling it to fit in a given target region.
|
||||
|
|
@ -490,7 +491,7 @@ public:
|
|||
it will just fill the target with a solid rectangle)
|
||||
@see setImageResamplingQuality, drawImageAt, drawImageWithin, fillAlphaMap
|
||||
*/
|
||||
void drawImage (const Image* const imageToDraw,
|
||||
void drawImage (const Image& imageToDraw,
|
||||
int destX, int destY, int destWidth, int destHeight,
|
||||
int sourceX, int sourceY, int sourceWidth, int sourceHeight,
|
||||
bool fillAlphaChannelWithCurrentBrush = false) const;
|
||||
|
|
@ -516,7 +517,7 @@ public:
|
|||
|
||||
@see setImageResamplingQuality, drawImage
|
||||
*/
|
||||
void drawImageTransformed (const Image* imageToDraw,
|
||||
void drawImageTransformed (const Image& imageToDraw,
|
||||
const Rectangle<int>& imageSubRegion,
|
||||
const AffineTransform& transform,
|
||||
bool fillAlphaChannelWithCurrentBrush = false) const;
|
||||
|
|
@ -542,7 +543,7 @@ public:
|
|||
similar to fillAlphaMap(), and see also drawImage()
|
||||
@see setImageResamplingQuality, drawImage, drawImageTransformed, drawImageAt, RectanglePlacement
|
||||
*/
|
||||
void drawImageWithin (const Image* imageToDraw,
|
||||
void drawImageWithin (const Image& imageToDraw,
|
||||
int destX, int destY, int destWidth, int destHeight,
|
||||
const RectanglePlacement& placementWithinTarget,
|
||||
bool fillAlphaChannelWithCurrentBrush = false) const;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "../geometry/juce_Path.h"
|
||||
#include "../geometry/juce_RectangleList.h"
|
||||
#include "../colour/juce_ColourGradient.h"
|
||||
#include "juce_FillType.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -1925,7 +1925,7 @@ public:
|
|||
}
|
||||
else if (fillType.isTiledImage())
|
||||
{
|
||||
renderImage (image, *(fillType.image), fillType.image->getBounds(), fillType.transform, shapeToFill);
|
||||
renderImage (image, fillType.image, fillType.image.getBounds(), fillType.transform, shapeToFill);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2012,13 +2012,13 @@ private:
|
|||
|
||||
|
||||
//==============================================================================
|
||||
LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (Image& image_)
|
||||
LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (const Image& image_)
|
||||
: image (image_)
|
||||
{
|
||||
currentState = new SavedState (image_.getBounds(), 0, 0);
|
||||
}
|
||||
|
||||
LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (Image& image_, const int xOffset, const int yOffset,
|
||||
LowLevelGraphicsSoftwareRenderer::LowLevelGraphicsSoftwareRenderer (const Image& image_, const int xOffset, const int yOffset,
|
||||
const RectangleList& initialClip)
|
||||
: image (image_)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ class JUCE_API LowLevelGraphicsSoftwareRenderer : public LowLevelGraphicsCon
|
|||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
LowLevelGraphicsSoftwareRenderer (Image& imageToRenderOn);
|
||||
LowLevelGraphicsSoftwareRenderer (Image& imageToRenderOn, int xOffset, int yOffset, const RectangleList& initialClip);
|
||||
LowLevelGraphicsSoftwareRenderer (const Image& imageToRenderOn);
|
||||
LowLevelGraphicsSoftwareRenderer (const Image& imageToRenderOn, int xOffset, int yOffset, const RectangleList& initialClip);
|
||||
~LowLevelGraphicsSoftwareRenderer();
|
||||
|
||||
bool isVectorDevice() const;
|
||||
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
protected:
|
||||
//==============================================================================
|
||||
Image& image;
|
||||
Image image;
|
||||
|
||||
class GlyphCache;
|
||||
class CachedGlyph;
|
||||
|
|
|
|||
|
|
@ -91,12 +91,12 @@ Drawable* Drawable::createFromImageData (const void* data, const size_t numBytes
|
|||
{
|
||||
Drawable* result = 0;
|
||||
|
||||
Image* const image = ImageFileFormat::loadFrom (data, (int) numBytes);
|
||||
Image image (ImageFileFormat::loadFrom (data, (int) numBytes));
|
||||
|
||||
if (image != 0)
|
||||
if (image.isValid())
|
||||
{
|
||||
DrawableImage* const di = new DrawableImage();
|
||||
di->setImage (image, true);
|
||||
di->setImage (image);
|
||||
result = di;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -201,13 +201,13 @@ public:
|
|||
The image that is returned will be owned by the caller, but it may come
|
||||
from the ImageCache.
|
||||
*/
|
||||
virtual Image* getImageForIdentifier (const var& imageIdentifier) = 0;
|
||||
virtual const Image getImageForIdentifier (const var& imageIdentifier) = 0;
|
||||
|
||||
/** Returns an identifier to be used to refer to a given image.
|
||||
This is used when converting a drawable into a ValueTree, so if you're
|
||||
only loading drawables, you can just return a var::null here.
|
||||
*/
|
||||
virtual const var getIdentifierForImage (Image* image) = 0;
|
||||
virtual const var getIdentifierForImage (const Image& image) = 0;
|
||||
};
|
||||
|
||||
/** Tries to create a Drawable from a previously-saved ValueTree.
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ void DrawableComposite::render (const Drawable::RenderingContext& context) const
|
|||
}
|
||||
|
||||
context.g.setOpacity (context.opacity);
|
||||
context.g.drawImageAt (&tempImage, clipBounds.getX(), clipBounds.getY());
|
||||
context.g.drawImageAt (tempImage, clipBounds.getX(), clipBounds.getY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ BEGIN_JUCE_NAMESPACE
|
|||
//==============================================================================
|
||||
DrawableImage::DrawableImage()
|
||||
: image (0),
|
||||
canDeleteImage (false),
|
||||
opacity (1.0f),
|
||||
overlayColour (0x00000000)
|
||||
{
|
||||
|
|
@ -44,53 +43,28 @@ DrawableImage::DrawableImage()
|
|||
}
|
||||
|
||||
DrawableImage::DrawableImage (const DrawableImage& other)
|
||||
: image (0),
|
||||
canDeleteImage (false),
|
||||
: image (other.image),
|
||||
opacity (other.opacity),
|
||||
overlayColour (other.overlayColour)
|
||||
{
|
||||
for (int i = 0; i < numElementsInArray (controlPoints); ++i)
|
||||
controlPoints[i] = other.controlPoints[i];
|
||||
|
||||
if (other.image != 0)
|
||||
{
|
||||
if ((! other.canDeleteImage) || ! ImageCache::isImageInCache (other.image))
|
||||
{
|
||||
setImage (*other.image);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageCache::incReferenceCount (other.image);
|
||||
setImage (other.image, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DrawableImage::~DrawableImage()
|
||||
{
|
||||
setImage (0, false);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void DrawableImage::setImage (const Image& imageToCopy)
|
||||
void DrawableImage::setImage (const Image& imageToUse)
|
||||
{
|
||||
setImage (new Image (imageToCopy), true);
|
||||
}
|
||||
|
||||
void DrawableImage::setImage (Image* imageToUse,
|
||||
const bool releaseWhenNotNeeded)
|
||||
{
|
||||
if (canDeleteImage)
|
||||
ImageCache::releaseOrDelete (image);
|
||||
|
||||
image = imageToUse;
|
||||
canDeleteImage = releaseWhenNotNeeded;
|
||||
|
||||
if (image != 0)
|
||||
if (image.isValid())
|
||||
{
|
||||
controlPoints[0] = RelativePoint (Point<float> (0.0f, 0.0f));
|
||||
controlPoints[1] = RelativePoint (Point<float> ((float) image->getWidth(), 0.0f));
|
||||
controlPoints[2] = RelativePoint (Point<float> (0.0f, (float) image->getHeight()));
|
||||
controlPoints[1] = RelativePoint (Point<float> ((float) image.getWidth(), 0.0f));
|
||||
controlPoints[2] = RelativePoint (Point<float> (0.0f, (float) image.getHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,15 +90,15 @@ void DrawableImage::setTransform (const RelativePoint& imageTopLeftPosition,
|
|||
//==============================================================================
|
||||
const AffineTransform DrawableImage::calculateTransform() const
|
||||
{
|
||||
if (image == 0)
|
||||
if (image.isNull())
|
||||
return AffineTransform::identity;
|
||||
|
||||
Point<float> resolved[3];
|
||||
for (int i = 0; i < 3; ++i)
|
||||
resolved[i] = controlPoints[i].resolve (parent);
|
||||
|
||||
const Point<float> tr (resolved[0] + (resolved[1] - resolved[0]) / (float) image->getWidth());
|
||||
const Point<float> bl (resolved[0] + (resolved[2] - resolved[0]) / (float) image->getHeight());
|
||||
const Point<float> tr (resolved[0] + (resolved[1] - resolved[0]) / (float) image.getWidth());
|
||||
const Point<float> bl (resolved[0] + (resolved[2] - resolved[0]) / (float) image.getHeight());
|
||||
|
||||
return AffineTransform::fromTargetPoints (resolved[0].getX(), resolved[0].getY(),
|
||||
tr.getX(), tr.getY(),
|
||||
|
|
@ -133,27 +107,27 @@ const AffineTransform DrawableImage::calculateTransform() const
|
|||
|
||||
void DrawableImage::render (const Drawable::RenderingContext& context) const
|
||||
{
|
||||
if (image != 0)
|
||||
if (image.isValid())
|
||||
{
|
||||
const AffineTransform t (calculateTransform().followedBy (context.transform));
|
||||
|
||||
if (opacity > 0.0f && ! overlayColour.isOpaque())
|
||||
{
|
||||
context.g.setOpacity (context.opacity * opacity);
|
||||
context.g.drawImageTransformed (image, image->getBounds(), t, false);
|
||||
context.g.drawImageTransformed (image, image.getBounds(), t, false);
|
||||
}
|
||||
|
||||
if (! overlayColour.isTransparent())
|
||||
{
|
||||
context.g.setColour (overlayColour.withMultipliedAlpha (context.opacity));
|
||||
context.g.drawImageTransformed (image, image->getBounds(), t, true);
|
||||
context.g.drawImageTransformed (image, image.getBounds(), t, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Rectangle<float> DrawableImage::getBounds() const
|
||||
{
|
||||
if (image == 0)
|
||||
if (image.isNull())
|
||||
return Rectangle<float>();
|
||||
|
||||
Point<float> resolved[3];
|
||||
|
|
@ -179,7 +153,7 @@ const Rectangle<float> DrawableImage::getBounds() const
|
|||
|
||||
bool DrawableImage::hitTest (float x, float y) const
|
||||
{
|
||||
if (image == 0)
|
||||
if (image.isNull())
|
||||
return false;
|
||||
|
||||
calculateTransform().inverted().transformPoint (x, y);
|
||||
|
|
@ -189,9 +163,9 @@ bool DrawableImage::hitTest (float x, float y) const
|
|||
|
||||
return ix >= 0
|
||||
&& iy >= 0
|
||||
&& ix < image->getWidth()
|
||||
&& iy < image->getHeight()
|
||||
&& image->getPixelAt (ix, iy).getAlpha() >= 127;
|
||||
&& ix < image.getWidth()
|
||||
&& iy < image.getHeight()
|
||||
&& image.getPixelAt (ix, iy).getAlpha() >= 127;
|
||||
}
|
||||
|
||||
Drawable* DrawableImage::createCopy() const
|
||||
|
|
@ -296,7 +270,7 @@ const Rectangle<float> DrawableImage::refreshFromValueTree (const ValueTree& tre
|
|||
const float newOpacity = controller.getOpacity();
|
||||
const Colour newOverlayColour (controller.getOverlayColour());
|
||||
|
||||
Image* newImage = 0;
|
||||
Image newImage;
|
||||
const var imageIdentifier (controller.getImageIdentifier());
|
||||
|
||||
jassert (imageProvider != 0 || imageIdentifier.isVoid()); // if you're using images, you need to provide something that can load and save them!
|
||||
|
|
@ -320,20 +294,11 @@ const Rectangle<float> DrawableImage::refreshFromValueTree (const ValueTree& tre
|
|||
controlPoints[0] = newControlPoint[0];
|
||||
controlPoints[1] = newControlPoint[1];
|
||||
controlPoints[2] = newControlPoint[2];
|
||||
|
||||
if (image != newImage)
|
||||
{
|
||||
if (canDeleteImage)
|
||||
ImageCache::releaseOrDelete (image);
|
||||
|
||||
canDeleteImage = true;
|
||||
image = newImage;
|
||||
}
|
||||
image = newImage;
|
||||
|
||||
return damage.getUnion (getBounds());
|
||||
}
|
||||
|
||||
ImageCache::release (newImage);
|
||||
return Rectangle<float>();
|
||||
}
|
||||
|
||||
|
|
@ -349,7 +314,7 @@ const ValueTree DrawableImage::createValueTree (ImageProvider* imageProvider) co
|
|||
v.setTargetPositionForTopRight (controlPoints[1], 0);
|
||||
v.setTargetPositionForBottomLeft (controlPoints[2], 0);
|
||||
|
||||
if (image != 0)
|
||||
if (image.isValid())
|
||||
{
|
||||
jassert (imageProvider != 0); // if you're using images, you need to provide something that can load and save them!
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#define __JUCE_DRAWABLEIMAGE_JUCEHEADER__
|
||||
|
||||
#include "juce_Drawable.h"
|
||||
#include "../imaging/juce_Image.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -46,30 +47,11 @@ public:
|
|||
virtual ~DrawableImage();
|
||||
|
||||
//==============================================================================
|
||||
/** Sets the image that this drawable will render.
|
||||
|
||||
An internal copy is made of the image passed-in. If you want to provide an
|
||||
image that this object can take charge of without needing to create a copy,
|
||||
use the other setImage() method.
|
||||
*/
|
||||
void setImage (const Image& imageToCopy);
|
||||
|
||||
/** Sets the image that this drawable will render.
|
||||
|
||||
A good way to use this is with the ImageCache - if you create an image
|
||||
with ImageCache and pass it in here with releaseWhenNotNeeded = true, then
|
||||
it'll be released neatly with its reference count being decreased.
|
||||
|
||||
@param imageToUse the image to render (may be a null pointer)
|
||||
@param releaseWhenNotNeeded if false, a simple pointer is kept to the image; if true,
|
||||
then the image will be deleted when this object no longer
|
||||
needs it - unless the image was created by the ImageCache,
|
||||
in which case it will be released with ImageCache::release().
|
||||
*/
|
||||
void setImage (Image* imageToUse, bool releaseWhenNotNeeded);
|
||||
/** Sets the image that this drawable will render. */
|
||||
void setImage (const Image& imageToUse);
|
||||
|
||||
/** Returns the current image. */
|
||||
Image* getImage() const throw() { return image; }
|
||||
const Image getImage() const { return image; }
|
||||
|
||||
/** Sets the opacity to use when drawing the image. */
|
||||
void setOpacity (float newOpacity);
|
||||
|
|
@ -176,8 +158,7 @@ public:
|
|||
juce_UseDebuggingNewOperator
|
||||
|
||||
private:
|
||||
Image* image;
|
||||
bool canDeleteImage;
|
||||
Image image;
|
||||
float opacity;
|
||||
Colour overlayColour;
|
||||
RelativePoint controlPoints[3];
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "juce_Drawable.h"
|
||||
#include "../colour/juce_ColourGradient.h"
|
||||
#include "../contexts/juce_FillType.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -102,10 +102,10 @@ void DropShadowEffect::applyEffect (Image& image, Graphics& g)
|
|||
}
|
||||
|
||||
g.setColour (Colours::black.withAlpha (opacity));
|
||||
g.drawImageAt (&shadowImage, offsetX, offsetY, true);
|
||||
g.drawImageAt (shadowImage, offsetX, offsetY, true);
|
||||
|
||||
g.setOpacity (1.0f);
|
||||
g.drawImageAt (&image, 0, 0);
|
||||
g.drawImageAt (image, 0, 0);
|
||||
}
|
||||
|
||||
#if JUCE_MSVC && JUCE_DEBUG
|
||||
|
|
|
|||
|
|
@ -58,13 +58,13 @@ void GlowEffect::applyEffect (Image& image, Graphics& g)
|
|||
blurKernel.createGaussianBlur (radius);
|
||||
blurKernel.rescaleAllValues (radius);
|
||||
|
||||
blurKernel.applyToImage (temp, &image, image.getBounds());
|
||||
blurKernel.applyToImage (temp, image, image.getBounds());
|
||||
|
||||
g.setColour (colour);
|
||||
g.drawImageAt (&temp, 0, 0, true);
|
||||
g.drawImageAt (temp, 0, 0, true);
|
||||
|
||||
g.setOpacity (1.0f);
|
||||
g.drawImageAt (&image, 0, 0, false);
|
||||
g.drawImageAt (image, 0, 0, false);
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void ReduceOpacityEffect::setOpacity (const float newOpacity)
|
|||
void ReduceOpacityEffect::applyEffect (Image& image, Graphics& g)
|
||||
{
|
||||
g.setOpacity (opacity);
|
||||
g.drawImageAt (&image, 0, 0);
|
||||
g.drawImageAt (image, 0, 0);
|
||||
}
|
||||
|
||||
END_JUCE_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -204,25 +204,6 @@ namespace RelativeCoordinateHelpers
|
|||
|
||||
return String (n, 3).trimCharactersAtEnd ("0").trimCharactersAtEnd (".");
|
||||
}
|
||||
|
||||
static bool couldBeMistakenForPathCommand (const String& s)
|
||||
{
|
||||
switch (s[0])
|
||||
{
|
||||
case 'a':
|
||||
case 'm':
|
||||
case 'l':
|
||||
case 'z':
|
||||
case 'q':
|
||||
case 'c':
|
||||
return s[1] == 0 || CharacterFunctions::isWhitespace (s[1]);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -632,7 +613,7 @@ RelativePointPath::RelativePointPath (const RelativePointPath& other)
|
|||
containsDynamicPoints (false)
|
||||
{
|
||||
ValueTree state (DrawablePath::valueTreeType);
|
||||
writeTo (state, 0);
|
||||
other.writeTo (state, 0);
|
||||
parse (state);
|
||||
}
|
||||
|
||||
|
|
@ -663,7 +644,7 @@ RelativePointPath::RelativePointPath (const Path& path)
|
|||
}
|
||||
}
|
||||
|
||||
void RelativePointPath::writeTo (ValueTree state, UndoManager* undoManager)
|
||||
void RelativePointPath::writeTo (ValueTree state, UndoManager* undoManager) const
|
||||
{
|
||||
DrawablePath::ValueTreeWrapper wrapper (state);
|
||||
wrapper.setUsesNonZeroWinding (usesNonZeroWinding, undoManager);
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ public:
|
|||
bool containsAnyDynamicPoints() const;
|
||||
|
||||
/** Writes the path to this drawable encoding. */
|
||||
void writeTo (ValueTree state, UndoManager* undoManager);
|
||||
void writeTo (ValueTree state, UndoManager* undoManager) const;
|
||||
|
||||
/** Quickly swaps the contents of this path with another. */
|
||||
void swapWith (RelativePointPath& other) throw();
|
||||
|
|
|
|||
|
|
@ -97,8 +97,8 @@ GIFLoader::GIFLoader (InputStream& in)
|
|||
if (! readPalette (numColours))
|
||||
break;
|
||||
|
||||
image = Image::createNativeImage ((transparent >= 0) ? Image::ARGB : Image::RGB,
|
||||
imageWidth, imageHeight, (transparent >= 0));
|
||||
image = Image ((transparent >= 0) ? Image::ARGB : Image::RGB,
|
||||
imageWidth, imageHeight, (transparent >= 0));
|
||||
|
||||
readImage (imageWidth, imageHeight,
|
||||
(buf[8] & 0x40) != 0,
|
||||
|
|
@ -382,9 +382,9 @@ bool GIFLoader::readImage (const int width, const int height,
|
|||
int index;
|
||||
int xpos = 0, ypos = 0, pass = 0;
|
||||
|
||||
const Image::BitmapData destData (*image, 0, 0, width, height, true);
|
||||
const Image::BitmapData destData (image, 0, 0, width, height, true);
|
||||
uint8* p = destData.data;
|
||||
const bool hasAlpha = image->hasAlphaChannel();
|
||||
const bool hasAlpha = image.hasAlphaChannel();
|
||||
|
||||
while ((index = readLZWByte (false, c)) >= 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ public:
|
|||
GIFLoader (InputStream& in);
|
||||
~GIFLoader();
|
||||
|
||||
Image* getImage() const { return image; }
|
||||
const Image& getImage() const { return image; }
|
||||
|
||||
private:
|
||||
Image* image;
|
||||
Image image;
|
||||
InputStream& input;
|
||||
uint8 buffer [300];
|
||||
uint8 palette [256][4];
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ bool JPEGImageFormat::canUnderstand (InputStream& in)
|
|||
return false;
|
||||
}
|
||||
|
||||
Image* JPEGImageFormat::decodeImage (InputStream& in)
|
||||
const Image JPEGImageFormat::decodeImage (InputStream& in)
|
||||
{
|
||||
using namespace jpeglibNamespace;
|
||||
using namespace JPEGHelpers;
|
||||
|
|
@ -257,7 +257,7 @@ Image* JPEGImageFormat::decodeImage (InputStream& in)
|
|||
MemoryBlock mb;
|
||||
in.readIntoMemoryBlock (mb);
|
||||
|
||||
Image* image = 0;
|
||||
Image image;
|
||||
|
||||
if (mb.getSize() > 16)
|
||||
{
|
||||
|
|
@ -299,10 +299,10 @@ Image* JPEGImageFormat::decodeImage (InputStream& in)
|
|||
|
||||
if (jpeg_start_decompress (&jpegDecompStruct))
|
||||
{
|
||||
image = Image::createNativeImage (Image::RGB, width, height, false);
|
||||
const bool hasAlphaChan = image->hasAlphaChannel();
|
||||
image = Image (Image::RGB, width, height, false);
|
||||
const bool hasAlphaChan = image.hasAlphaChannel(); // (the native image creator may not give back what we expect)
|
||||
|
||||
const Image::BitmapData destData (*image, 0, 0, width, height, true);
|
||||
const Image::BitmapData destData (image, 0, 0, width, height, true);
|
||||
|
||||
for (int y = 0; y < height; ++y)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -151,10 +151,10 @@ bool PNGImageFormat::canUnderstand (InputStream& in)
|
|||
&& header[3] == 'G';
|
||||
}
|
||||
|
||||
Image* PNGImageFormat::decodeImage (InputStream& in)
|
||||
const Image PNGImageFormat::decodeImage (InputStream& in)
|
||||
{
|
||||
using namespace pnglibNamespace;
|
||||
Image* image = 0;
|
||||
Image image;
|
||||
|
||||
png_structp pngReadStruct;
|
||||
png_infop pngInfoStruct;
|
||||
|
|
@ -168,7 +168,7 @@ Image* PNGImageFormat::decodeImage (InputStream& in)
|
|||
if (pngInfoStruct == 0)
|
||||
{
|
||||
png_destroy_read_struct (&pngReadStruct, 0, 0);
|
||||
return 0;
|
||||
return Image();
|
||||
}
|
||||
|
||||
png_set_error_fn (pngReadStruct, 0, PNGHelpers::errorCallback, PNGHelpers::errorCallback );
|
||||
|
|
@ -221,12 +221,12 @@ Image* PNGImageFormat::decodeImage (InputStream& in)
|
|||
png_destroy_read_struct (&pngReadStruct, &pngInfoStruct, 0);
|
||||
|
||||
// now convert the data to a juce image format..
|
||||
image = Image::createNativeImage (hasAlphaChan ? Image::ARGB : Image::RGB,
|
||||
(int) width, (int) height, hasAlphaChan);
|
||||
image = Image (hasAlphaChan ? Image::ARGB : Image::RGB,
|
||||
(int) width, (int) height, hasAlphaChan);
|
||||
|
||||
hasAlphaChan = image->hasAlphaChannel(); // (the native image creator may not give back what we expect)
|
||||
hasAlphaChan = image.hasAlphaChannel(); // (the native image creator may not give back what we expect)
|
||||
|
||||
const Image::BitmapData destData (*image, 0, 0, (int) width, (int) height, true);
|
||||
const Image::BitmapData destData (image, 0, 0, (int) width, (int) height, true);
|
||||
uint8* srcRow = tempBuffer;
|
||||
uint8* destRow = destData.data;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public:
|
|||
and make sure that you process the data as quickly as possible to
|
||||
avoid glitching!
|
||||
*/
|
||||
virtual void imageReceived (Image& image) = 0;
|
||||
virtual void imageReceived (const Image& image) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue