| @@ -211,12 +211,19 @@ private: | |||
| { | |||
| const String buildDirName ("build"); | |||
| const String intermediatesDirName (buildDirName + "/intermediate/" + config.getName().toString()); | |||
| String outputDir (buildDirName); | |||
| if (config.getTargetBinaryRelativePath().toString().isNotEmpty()) | |||
| { | |||
| RelativePath binaryPath (config.getTargetBinaryRelativePath().toString(), RelativePath::projectFolder); | |||
| outputDir = binaryPath.rebased (project.getFile().getParentDirectory(), getTargetFolder(), RelativePath::buildTargetFolder).toUnixStyle(); | |||
| } | |||
| out << "ifeq ($(CONFIG)," << escapeSpaces (config.getName().toString()) << ")" << newLine; | |||
| out << " BINDIR := " << escapeSpaces (buildDirName) << newLine | |||
| << " LIBDIR := " << escapeSpaces (buildDirName) << newLine | |||
| << " OBJDIR := " << escapeSpaces (intermediatesDirName) << newLine | |||
| << " OUTDIR := " << escapeSpaces (buildDirName) << newLine; | |||
| << " OUTDIR := " << escapeSpaces (outputDir) << newLine; | |||
| writeCppFlags (out, config); | |||
| @@ -21666,7 +21666,7 @@ public: | |||
| void setThumbnail (AudioThumbnail* thumb) | |||
| { | |||
| if (thumb != 0) | |||
| thumb->reset (buffer.getNumChannels(), writer->sampleRate); | |||
| thumb->reset (buffer.getNumChannels(), writer->getSampleRate()); | |||
| const ScopedLock sl (thumbnailLock); | |||
| thumbnailToUpdate = thumb; | |||
| @@ -33165,7 +33165,7 @@ namespace | |||
| } | |||
| } | |||
| typedef AEffect* (*MainCall) (audioMasterCallback); | |||
| typedef AEffect* (VSTCALLBACK *MainCall) (audioMasterCallback); | |||
| static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt); | |||
| @@ -42117,8 +42117,6 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel | |||
| { | |||
| if (flags.mouseDownFlag) | |||
| { | |||
| Desktop& desktop = Desktop::getInstance(); | |||
| flags.mouseDownFlag = false; | |||
| BailOutChecker checker (this); | |||
| @@ -42138,6 +42136,7 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel | |||
| if (checker.shouldBailOut()) | |||
| return; | |||
| Desktop& desktop = Desktop::getInstance(); | |||
| desktop.resetTimer(); | |||
| desktop.mouseListeners.callChecked (checker, &MouseListener::mouseUp, me); | |||
| @@ -42164,8 +42163,6 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r | |||
| { | |||
| if (flags.mouseDownFlag) | |||
| { | |||
| Desktop& desktop = Desktop::getInstance(); | |||
| flags.mouseOverFlag = reallyContains (relativePos, false); | |||
| BailOutChecker checker (this); | |||
| @@ -42182,6 +42179,7 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r | |||
| if (checker.shouldBailOut()) | |||
| return; | |||
| Desktop& desktop = Desktop::getInstance(); | |||
| desktop.resetTimer(); | |||
| desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me); | |||
| @@ -51383,7 +51381,8 @@ void TableHeaderComponent::paint (Graphics& g) | |||
| || dragOverlayComp == 0 | |||
| || ! dragOverlayComp->isVisible())) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (x, 0); | |||
| g.reduceClipRegion (0, 0, ci->width, getHeight()); | |||
| @@ -51391,8 +51390,6 @@ void TableHeaderComponent::paint (Graphics& g) | |||
| ci->id == columnIdUnderMouse, | |||
| ci->id == columnIdUnderMouse && isMouseButtonDown(), | |||
| ci->propertyFlags); | |||
| g.restoreState(); | |||
| } | |||
| x += ci->width; | |||
| @@ -51807,11 +51804,11 @@ public: | |||
| const int columnId = header.getColumnIdOfIndex (i, true); | |||
| const Rectangle<int> columnRect (header.getColumnPosition(i).withHeight (getHeight())); | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.reduceClipRegion (columnRect); | |||
| g.setOrigin (columnRect.getX(), 0); | |||
| model->paintCell (g, row, columnId, columnRect.getWidth(), columnRect.getHeight(), isSelected); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| } | |||
| @@ -53771,12 +53768,6 @@ void TextEditor::insertTextAtCaret (const String& newText_) | |||
| if (allowedCharacters.isNotEmpty()) | |||
| newText = newText.retainCharacters (allowedCharacters); | |||
| if ((! returnKeyStartsNewLine) && newText == "\n") | |||
| { | |||
| returnPressed(); | |||
| return; | |||
| } | |||
| if (! isMultiLine()) | |||
| newText = newText.replaceCharacters ("\r\n", " "); | |||
| else | |||
| @@ -54207,7 +54198,11 @@ bool TextEditor::keyPressed (const KeyPress& key) | |||
| else if (key == KeyPress::returnKey) | |||
| { | |||
| newTransaction(); | |||
| insertTextAtCaret ("\n"); | |||
| if (returnKeyStartsNewLine) | |||
| insertTextAtCaret ("\n"); | |||
| else | |||
| returnPressed(); | |||
| } | |||
| else if (key.isKeyCode (KeyPress::escapeKey)) | |||
| { | |||
| @@ -55772,13 +55767,12 @@ void ToolbarItemComponent::paintButton (Graphics& g, const bool over, const bool | |||
| if (! contentArea.isEmpty()) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.reduceClipRegion (contentArea); | |||
| g.setOrigin (contentArea.getX(), contentArea.getY()); | |||
| paintButtonArea (g, contentArea.getWidth(), contentArea.getHeight(), over, down); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| @@ -57310,14 +57304,12 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) | |||
| const int itemW = itemWidth < 0 ? width - indent : itemWidth; | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (indent, 0); | |||
| if (g.reduceClipRegion (drawsInLeftMargin ? -indent : 0, 0, | |||
| drawsInLeftMargin ? itemW + indent : itemW, itemHeight)) | |||
| paintItem (g, itemW, itemHeight); | |||
| g.restoreState(); | |||
| } | |||
| g.setColour (ownerView->findColour (TreeView::linesColourId)); | |||
| @@ -57369,15 +57361,14 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) | |||
| if (mightContainSubItems()) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (depth * indentWidth, 0); | |||
| g.reduceClipRegion (0, 0, indentWidth, itemHeight); | |||
| paintOpenCloseButton (g, indentWidth, itemHeight, | |||
| static_cast <TreeViewContentComponent*> (ownerView->viewport->getViewedComponent()) | |||
| ->isMouseOverButton (this)); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| @@ -57396,13 +57387,12 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) | |||
| if (relY + ti->totalHeight >= clip.getY()) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (0, relY); | |||
| if (g.reduceClipRegion (0, 0, width, ti->totalHeight)) | |||
| ti->paintRecursively (g, width); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| } | |||
| @@ -68388,7 +68378,8 @@ void MenuBarComponent::paint (Graphics& g) | |||
| { | |||
| for (int i = 0; i < menuNames.size(); ++i) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (xPositions [i], 0); | |||
| g.reduceClipRegion (0, 0, xPositions[i + 1] - xPositions[i], getHeight()); | |||
| @@ -68401,8 +68392,6 @@ void MenuBarComponent::paint (Graphics& g) | |||
| i == currentPopupIndex, | |||
| isMouseOverBar, | |||
| *this); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| } | |||
| @@ -71178,13 +71167,12 @@ public: | |||
| return 0; | |||
| } | |||
| const Point<int> getScreenPosition() | |||
| const Point<int> getScreenPosition() const | |||
| { | |||
| // This must only be called with the message manager locked! | |||
| jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); | |||
| setScreenPos (MouseInputSource::getCurrentMousePosition(), Time::currentTimeMillis(), false); | |||
| return lastScreenPos + unboundedMouseOffset; | |||
| // This needs to return the live position if possible, but it mustn't update the lastScreenPos | |||
| // value, because that can cause continuity problems. | |||
| return unboundedMouseOffset + (isMouseDevice ? MouseInputSource::getCurrentMousePosition() | |||
| : lastScreenPos); | |||
| } | |||
| void sendMouseEnter (Component* const comp, const Point<int>& screenPos, const int64 time) | |||
| @@ -76371,10 +76359,6 @@ public: | |||
| setSelectAllWhenFocused (true); | |||
| } | |||
| ~AlertWindowTextEditor() | |||
| { | |||
| } | |||
| void returnPressed() | |||
| { | |||
| // pass these up the component hierarchy to be trigger the buttons | |||
| @@ -77318,9 +77302,9 @@ void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo) | |||
| { | |||
| Graphics g (&contextToPaintTo); | |||
| #if JUCE_ENABLE_REPAINT_DEBUGGING | |||
| #if JUCE_ENABLE_REPAINT_DEBUGGING | |||
| g.saveState(); | |||
| #endif | |||
| #endif | |||
| JUCE_TRY | |||
| { | |||
| @@ -77328,18 +77312,16 @@ void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo) | |||
| } | |||
| JUCE_CATCH_EXCEPTION | |||
| #if JUCE_ENABLE_REPAINT_DEBUGGING | |||
| #if JUCE_ENABLE_REPAINT_DEBUGGING | |||
| // enabling this code will fill all areas that get repainted with a colour overlay, to show | |||
| // clearly when things are being repainted. | |||
| { | |||
| g.restoreState(); | |||
| g.restoreState(); | |||
| g.fillAll (Colour ((uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) 0x50)); | |||
| } | |||
| #endif | |||
| g.fillAll (Colour ((uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) 0x50)); | |||
| #endif | |||
| /** If this fails, it's probably be because your CPU floating-point precision mode has | |||
| been set to low.. This setting is sometimes changed by things like Direct3D, and can | |||
| @@ -82523,6 +82505,17 @@ void Graphics::drawImageTransformed (const Image& imageToDraw, | |||
| } | |||
| } | |||
| Graphics::ScopedSaveState::ScopedSaveState (Graphics& g) | |||
| : context (g) | |||
| { | |||
| context.saveState(); | |||
| } | |||
| Graphics::ScopedSaveState::~ScopedSaveState() | |||
| { | |||
| context.restoreState(); | |||
| } | |||
| END_JUCE_NAMESPACE | |||
| /*** End of inlined file: juce_Graphics.cpp ***/ | |||
| @@ -85673,7 +85666,8 @@ void Drawable::draw (Graphics& g, float opacity, const AffineTransform& transfor | |||
| void Drawable::nonConstDraw (Graphics& g, float opacity, const AffineTransform& transform) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| const float oldOpacity = getAlpha(); | |||
| setAlpha (opacity); | |||
| g.addTransform (AffineTransform::translation ((float) -originRelativeToComponent.getX(), | |||
| @@ -85685,7 +85679,6 @@ void Drawable::nonConstDraw (Graphics& g, float opacity, const AffineTransform& | |||
| paintEntireComponent (g, false); | |||
| setAlpha (oldOpacity); | |||
| g.restoreState(); | |||
| } | |||
| void Drawable::drawAt (Graphics& g, float x, float y, float opacity) const | |||
| @@ -252875,10 +252868,12 @@ public: | |||
| const int rx = roundToInt (dx), ry = roundToInt (dy); | |||
| const int rw = roundToInt (dw), rh = roundToInt (dh); | |||
| g.saveState(); | |||
| g.excludeClipRegion (Rectangle<int> (rx, ry, rw, rh)); | |||
| g.fillAll (Colours::black); | |||
| g.restoreState(); | |||
| { | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.excludeClipRegion (Rectangle<int> (rx, ry, rw, rh)); | |||
| g.fillAll (Colours::black); | |||
| } | |||
| g.drawImage (activeImage, rx, ry, rw, rh, 0, 0, width, height); | |||
| } | |||
| @@ -64,7 +64,7 @@ | |||
| */ | |||
| #define JUCE_MAJOR_VERSION 1 | |||
| #define JUCE_MINOR_VERSION 52 | |||
| #define JUCE_BUILDNUMBER 102 | |||
| #define JUCE_BUILDNUMBER 103 | |||
| /** Current Juce version number. | |||
| @@ -1198,12 +1198,14 @@ inline bool isPositiveAndBelow (Type valueToTest, Type upperLimit) throw() | |||
| return Type() <= valueToTest && valueToTest < upperLimit; | |||
| } | |||
| #if ! JUCE_VC6 | |||
| template <> | |||
| inline bool isPositiveAndBelow (const int valueToTest, const int upperLimit) throw() | |||
| { | |||
| jassert (upperLimit >= 0); // makes no sense to call this if the upper limit is itself below zero.. | |||
| return static_cast <unsigned int> (valueToTest) < static_cast <unsigned int> (upperLimit); | |||
| } | |||
| #endif | |||
| /** Returns true if a value is at least zero, and also less than or equal to a specified upper limit. | |||
| This is basically a quicker way to write: | |||
| @@ -1217,12 +1219,14 @@ inline bool isPositiveAndNotGreaterThan (Type valueToTest, Type upperLimit) thro | |||
| return Type() <= valueToTest && valueToTest <= upperLimit; | |||
| } | |||
| #if ! JUCE_VC6 | |||
| template <> | |||
| inline bool isPositiveAndNotGreaterThan (const int valueToTest, const int upperLimit) throw() | |||
| { | |||
| jassert (upperLimit >= 0); // makes no sense to call this if the upper limit is itself below zero.. | |||
| return static_cast <unsigned int> (valueToTest) <= static_cast <unsigned int> (upperLimit); | |||
| } | |||
| #endif | |||
| /** Handy function to swap two values over. | |||
| */ | |||
| @@ -25090,15 +25094,32 @@ public: | |||
| bool isClipEmpty() const; | |||
| /** Saves the current graphics state on an internal stack. | |||
| To restore the state, use restoreState(). | |||
| @see ScopedSaveState | |||
| */ | |||
| void saveState(); | |||
| /** Restores a graphics state that was previously saved with saveState(). | |||
| @see ScopedSaveState | |||
| */ | |||
| void restoreState(); | |||
| /** Uses RAII to save and restore the state of a graphics context. | |||
| On construction, this calls Graphics::saveState(), and on destruction it calls | |||
| Graphics::restoreState() on the Graphics object that you supply. | |||
| */ | |||
| class ScopedSaveState | |||
| { | |||
| public: | |||
| ScopedSaveState (Graphics& g); | |||
| ~ScopedSaveState(); | |||
| private: | |||
| Graphics& context; | |||
| JUCE_DECLARE_NON_COPYABLE (ScopedSaveState); | |||
| }; | |||
| /** Begins rendering to an off-screen bitmap which will later be flattened onto the current | |||
| context with the given opacity. | |||
| @@ -264,7 +264,7 @@ public: | |||
| void setThumbnail (AudioThumbnail* thumb) | |||
| { | |||
| if (thumb != 0) | |||
| thumb->reset (buffer.getNumChannels(), writer->sampleRate); | |||
| thumb->reset (buffer.getNumChannels(), writer->getSampleRate()); | |||
| const ScopedLock sl (thumbnailLock); | |||
| thumbnailToUpdate = thumb; | |||
| @@ -212,7 +212,7 @@ namespace | |||
| } | |||
| //============================================================================== | |||
| typedef AEffect* (*MainCall) (audioMasterCallback); | |||
| typedef AEffect* (VSTCALLBACK *MainCall) (audioMasterCallback); | |||
| static VstIntPtr VSTCALLBACK audioMaster (AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt); | |||
| @@ -227,12 +227,14 @@ inline bool isPositiveAndBelow (Type valueToTest, Type upperLimit) throw() | |||
| return Type() <= valueToTest && valueToTest < upperLimit; | |||
| } | |||
| #if ! JUCE_VC6 | |||
| template <> | |||
| inline bool isPositiveAndBelow (const int valueToTest, const int upperLimit) throw() | |||
| { | |||
| jassert (upperLimit >= 0); // makes no sense to call this if the upper limit is itself below zero.. | |||
| return static_cast <unsigned int> (valueToTest) < static_cast <unsigned int> (upperLimit); | |||
| } | |||
| #endif | |||
| /** Returns true if a value is at least zero, and also less than or equal to a specified upper limit. | |||
| This is basically a quicker way to write: | |||
| @@ -246,12 +248,14 @@ inline bool isPositiveAndNotGreaterThan (Type valueToTest, Type upperLimit) thro | |||
| return Type() <= valueToTest && valueToTest <= upperLimit; | |||
| } | |||
| #if ! JUCE_VC6 | |||
| template <> | |||
| inline bool isPositiveAndNotGreaterThan (const int valueToTest, const int upperLimit) throw() | |||
| { | |||
| jassert (upperLimit >= 0); // makes no sense to call this if the upper limit is itself below zero.. | |||
| return static_cast <unsigned int> (valueToTest) <= static_cast <unsigned int> (upperLimit); | |||
| } | |||
| #endif | |||
| //============================================================================== | |||
| /** Handy function to swap two values over. | |||
| @@ -33,7 +33,7 @@ | |||
| */ | |||
| #define JUCE_MAJOR_VERSION 1 | |||
| #define JUCE_MINOR_VERSION 52 | |||
| #define JUCE_BUILDNUMBER 102 | |||
| #define JUCE_BUILDNUMBER 103 | |||
| /** Current Juce version number. | |||
| @@ -543,7 +543,8 @@ void TableHeaderComponent::paint (Graphics& g) | |||
| || dragOverlayComp == 0 | |||
| || ! dragOverlayComp->isVisible())) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (x, 0); | |||
| g.reduceClipRegion (0, 0, ci->width, getHeight()); | |||
| @@ -551,8 +552,6 @@ void TableHeaderComponent::paint (Graphics& g) | |||
| ci->id == columnIdUnderMouse, | |||
| ci->id == columnIdUnderMouse && isMouseButtonDown(), | |||
| ci->propertyFlags); | |||
| g.restoreState(); | |||
| } | |||
| x += ci->width; | |||
| @@ -63,11 +63,11 @@ public: | |||
| const int columnId = header.getColumnIdOfIndex (i, true); | |||
| const Rectangle<int> columnRect (header.getColumnPosition(i).withHeight (getHeight())); | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.reduceClipRegion (columnRect); | |||
| g.setOrigin (columnRect.getX(), 0); | |||
| model->paintCell (g, row, columnId, columnRect.getWidth(), columnRect.getHeight(), isSelected); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| } | |||
| @@ -1602,12 +1602,6 @@ void TextEditor::insertTextAtCaret (const String& newText_) | |||
| if (allowedCharacters.isNotEmpty()) | |||
| newText = newText.retainCharacters (allowedCharacters); | |||
| if ((! returnKeyStartsNewLine) && newText == "\n") | |||
| { | |||
| returnPressed(); | |||
| return; | |||
| } | |||
| if (! isMultiLine()) | |||
| newText = newText.replaceCharacters ("\r\n", " "); | |||
| else | |||
| @@ -2043,7 +2037,11 @@ bool TextEditor::keyPressed (const KeyPress& key) | |||
| else if (key == KeyPress::returnKey) | |||
| { | |||
| newTransaction(); | |||
| insertTextAtCaret ("\n"); | |||
| if (returnKeyStartsNewLine) | |||
| insertTextAtCaret ("\n"); | |||
| else | |||
| returnPressed(); | |||
| } | |||
| else if (key.isKeyCode (KeyPress::escapeKey)) | |||
| { | |||
| @@ -205,13 +205,12 @@ void ToolbarItemComponent::paintButton (Graphics& g, const bool over, const bool | |||
| if (! contentArea.isEmpty()) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.reduceClipRegion (contentArea); | |||
| g.setOrigin (contentArea.getX(), contentArea.getY()); | |||
| paintButtonArea (g, contentArea.getWidth(), contentArea.getHeight(), over, down); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| @@ -1437,14 +1437,12 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) | |||
| const int itemW = itemWidth < 0 ? width - indent : itemWidth; | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (indent, 0); | |||
| if (g.reduceClipRegion (drawsInLeftMargin ? -indent : 0, 0, | |||
| drawsInLeftMargin ? itemW + indent : itemW, itemHeight)) | |||
| paintItem (g, itemW, itemHeight); | |||
| g.restoreState(); | |||
| } | |||
| g.setColour (ownerView->findColour (TreeView::linesColourId)); | |||
| @@ -1497,15 +1495,14 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) | |||
| if (mightContainSubItems()) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (depth * indentWidth, 0); | |||
| g.reduceClipRegion (0, 0, indentWidth, itemHeight); | |||
| paintOpenCloseButton (g, indentWidth, itemHeight, | |||
| static_cast <TreeViewContentComponent*> (ownerView->viewport->getViewedComponent()) | |||
| ->isMouseOverButton (this)); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| @@ -1524,13 +1521,12 @@ void TreeViewItem::paintRecursively (Graphics& g, int width) | |||
| if (relY + ti->totalHeight >= clip.getY()) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (0, relY); | |||
| if (g.reduceClipRegion (0, 0, width, ti->totalHeight)) | |||
| ti->paintRecursively (g, width); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| } | |||
| @@ -2426,8 +2426,6 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel | |||
| { | |||
| if (flags.mouseDownFlag) | |||
| { | |||
| Desktop& desktop = Desktop::getInstance(); | |||
| flags.mouseDownFlag = false; | |||
| BailOutChecker checker (this); | |||
| @@ -2447,6 +2445,7 @@ void Component::internalMouseUp (MouseInputSource& source, const Point<int>& rel | |||
| if (checker.shouldBailOut()) | |||
| return; | |||
| Desktop& desktop = Desktop::getInstance(); | |||
| desktop.resetTimer(); | |||
| desktop.mouseListeners.callChecked (checker, &MouseListener::mouseUp, me); | |||
| @@ -2473,8 +2472,6 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r | |||
| { | |||
| if (flags.mouseDownFlag) | |||
| { | |||
| Desktop& desktop = Desktop::getInstance(); | |||
| flags.mouseOverFlag = reallyContains (relativePos, false); | |||
| BailOutChecker checker (this); | |||
| @@ -2491,6 +2488,7 @@ void Component::internalMouseDrag (MouseInputSource& source, const Point<int>& r | |||
| if (checker.shouldBailOut()) | |||
| return; | |||
| Desktop& desktop = Desktop::getInstance(); | |||
| desktop.resetTimer(); | |||
| desktop.mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me); | |||
| @@ -91,7 +91,8 @@ void MenuBarComponent::paint (Graphics& g) | |||
| { | |||
| for (int i = 0; i < menuNames.size(); ++i) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.setOrigin (xPositions [i], 0); | |||
| g.reduceClipRegion (0, 0, xPositions[i + 1] - xPositions[i], getHeight()); | |||
| @@ -104,8 +105,6 @@ void MenuBarComponent::paint (Graphics& g) | |||
| i == currentPopupIndex, | |||
| isMouseOverBar, | |||
| *this); | |||
| g.restoreState(); | |||
| } | |||
| } | |||
| } | |||
| @@ -89,13 +89,12 @@ public: | |||
| return 0; | |||
| } | |||
| const Point<int> getScreenPosition() | |||
| const Point<int> getScreenPosition() const | |||
| { | |||
| // This must only be called with the message manager locked! | |||
| jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); | |||
| setScreenPos (MouseInputSource::getCurrentMousePosition(), Time::currentTimeMillis(), false); | |||
| return lastScreenPos + unboundedMouseOffset; | |||
| // This needs to return the live position if possible, but it mustn't update the lastScreenPos | |||
| // value, because that can cause continuity problems. | |||
| return unboundedMouseOffset + (isMouseDevice ? MouseInputSource::getCurrentMousePosition() | |||
| : lastScreenPos); | |||
| } | |||
| //============================================================================== | |||
| @@ -47,10 +47,6 @@ public: | |||
| setSelectAllWhenFocused (true); | |||
| } | |||
| ~AlertWindowTextEditor() | |||
| { | |||
| } | |||
| void returnPressed() | |||
| { | |||
| // pass these up the component hierarchy to be trigger the buttons | |||
| @@ -120,9 +120,9 @@ void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo) | |||
| { | |||
| Graphics g (&contextToPaintTo); | |||
| #if JUCE_ENABLE_REPAINT_DEBUGGING | |||
| #if JUCE_ENABLE_REPAINT_DEBUGGING | |||
| g.saveState(); | |||
| #endif | |||
| #endif | |||
| JUCE_TRY | |||
| { | |||
| @@ -130,18 +130,16 @@ void ComponentPeer::handlePaint (LowLevelGraphicsContext& contextToPaintTo) | |||
| } | |||
| JUCE_CATCH_EXCEPTION | |||
| #if JUCE_ENABLE_REPAINT_DEBUGGING | |||
| #if JUCE_ENABLE_REPAINT_DEBUGGING | |||
| // enabling this code will fill all areas that get repainted with a colour overlay, to show | |||
| // clearly when things are being repainted. | |||
| { | |||
| g.restoreState(); | |||
| g.restoreState(); | |||
| g.fillAll (Colour ((uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) 0x50)); | |||
| } | |||
| #endif | |||
| g.fillAll (Colour ((uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) Random::getSystemRandom().nextInt (255), | |||
| (uint8) 0x50)); | |||
| #endif | |||
| /** If this fails, it's probably be because your CPU floating-point precision mode has | |||
| been set to low.. This setting is sometimes changed by things like Direct3D, and can | |||
| @@ -719,5 +719,17 @@ void Graphics::drawImageTransformed (const Image& imageToDraw, | |||
| } | |||
| } | |||
| //============================================================================== | |||
| Graphics::ScopedSaveState::ScopedSaveState (Graphics& g) | |||
| : context (g) | |||
| { | |||
| context.saveState(); | |||
| } | |||
| Graphics::ScopedSaveState::~ScopedSaveState() | |||
| { | |||
| context.restoreState(); | |||
| } | |||
| END_JUCE_NAMESPACE | |||
| @@ -603,16 +603,35 @@ public: | |||
| /** Returns true if no drawing can be done because the clip region is zero. */ | |||
| bool isClipEmpty() const; | |||
| //============================================================================== | |||
| /** Saves the current graphics state on an internal stack. | |||
| To restore the state, use restoreState(). | |||
| @see ScopedSaveState | |||
| */ | |||
| void saveState(); | |||
| /** Restores a graphics state that was previously saved with saveState(). | |||
| @see ScopedSaveState | |||
| */ | |||
| void restoreState(); | |||
| /** Uses RAII to save and restore the state of a graphics context. | |||
| On construction, this calls Graphics::saveState(), and on destruction it calls | |||
| Graphics::restoreState() on the Graphics object that you supply. | |||
| */ | |||
| class ScopedSaveState | |||
| { | |||
| public: | |||
| ScopedSaveState (Graphics& g); | |||
| ~ScopedSaveState(); | |||
| private: | |||
| Graphics& context; | |||
| JUCE_DECLARE_NON_COPYABLE (ScopedSaveState); | |||
| }; | |||
| //============================================================================== | |||
| /** Begins rendering to an off-screen bitmap which will later be flattened onto the current | |||
| context with the given opacity. | |||
| @@ -58,7 +58,8 @@ void Drawable::draw (Graphics& g, float opacity, const AffineTransform& transfor | |||
| void Drawable::nonConstDraw (Graphics& g, float opacity, const AffineTransform& transform) | |||
| { | |||
| g.saveState(); | |||
| Graphics::ScopedSaveState ss (g); | |||
| const float oldOpacity = getAlpha(); | |||
| setAlpha (opacity); | |||
| g.addTransform (AffineTransform::translation ((float) -originRelativeToComponent.getX(), | |||
| @@ -70,7 +71,6 @@ void Drawable::nonConstDraw (Graphics& g, float opacity, const AffineTransform& | |||
| paintEntireComponent (g, false); | |||
| setAlpha (oldOpacity); | |||
| g.restoreState(); | |||
| } | |||
| void Drawable::drawAt (Graphics& g, float x, float y, float opacity) const | |||
| @@ -244,10 +244,12 @@ public: | |||
| const int rx = roundToInt (dx), ry = roundToInt (dy); | |||
| const int rw = roundToInt (dw), rh = roundToInt (dh); | |||
| g.saveState(); | |||
| g.excludeClipRegion (Rectangle<int> (rx, ry, rw, rh)); | |||
| g.fillAll (Colours::black); | |||
| g.restoreState(); | |||
| { | |||
| Graphics::ScopedSaveState ss (g); | |||
| g.excludeClipRegion (Rectangle<int> (rx, ry, rw, rh)); | |||
| g.fillAll (Colours::black); | |||
| } | |||
| g.drawImage (activeImage, rx, ry, rw, rh, 0, 0, width, height); | |||
| } | |||