From aff5fea6b473a7d086f8f36d27891273c9ae2076 Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 22 Jan 2012 10:04:19 +0000 Subject: [PATCH] Minor introjucer clean-ups. --- .../jucer_DocumentEditorComponent.cpp | 4 ++-- .../Application/jucer_OpenDocumentManager.cpp | 18 ++++++++++-------- .../Application/jucer_OpenDocumentManager.h | 2 ++ .../Source/Utility/jucer_JucerTreeViewBase.cpp | 4 ++-- .../Source/Utility/jucer_JucerTreeViewBase.h | 2 +- .../Source/Utility/jucer_ValueSourceHelpers.h | 7 +++---- .../native/juce_win32_WASAPI.cpp | 18 ++++++++++++++---- modules/juce_core/maths/juce_BigInteger.cpp | 8 ++++---- .../contexts/juce_GraphicsContext.cpp | 7 ++----- .../juce_graphics/geometry/juce_EdgeTable.cpp | 2 -- .../native/juce_mac_FileChooser.mm | 2 +- 11 files changed, 41 insertions(+), 33 deletions(-) diff --git a/extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp b/extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp index 835728442a..21631c6bb1 100644 --- a/extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp +++ b/extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp @@ -91,6 +91,7 @@ void DocumentEditorComponent::getCommandInfo (const CommandID commandID, Applica result.setInfo ("Save" + name + " As...", "Saves the current document to a different filename", CommandCategories::general, 0); + result.setActive (document != nullptr && document->canSaveAs()); result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier | ModifierKeys::shiftModifier, 0)); break; @@ -119,8 +120,7 @@ bool DocumentEditorComponent::perform (const InvocationInfo& info) return true; case CommandIDs::saveDocumentAs: - jassertfalse //xxxx - //document.save(); + document->saveAs(); return true; case CommandIDs::closeDocument: diff --git a/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp b/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp index 728942ff87..dd2dbc137b 100644 --- a/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp +++ b/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp @@ -40,16 +40,11 @@ public: reloadFromFile(); } - ~SourceCodeDocument() - { - } - //============================================================================== class Type : public OpenDocumentManager::DocumentType { public: Type() {} - ~Type() {} bool canOpenFile (const File& file) { return SourceCodeEditor::isTextFile (file); } Document* openFile (Project*, const File& file) { return new SourceCodeDocument (file); } @@ -60,6 +55,7 @@ public: bool isForFile (const File& file) const { return modDetector.getFile() == file; } bool isForNode (const ValueTree& node) const { return false; } bool refersToProject (Project& project) const { return false; } + bool canSaveAs() const { return true; } String getName() const { return modDetector.getFile().getFileName(); } String getType() const { return modDetector.getFile().getFileExtension() + " file"; } bool needsSaving() const { return codeDoc != nullptr && codeDoc->hasChangedSinceSavePoint(); } @@ -92,6 +88,12 @@ public: return true; } + bool saveAs() + { + jassertfalse; //xxx todo + return false; + } + Component* createEditor() { CodeTokeniser* tokeniser = nullptr; @@ -120,8 +122,6 @@ public: reloadFromFile(); } - ~UnknownDocument() {} - //============================================================================== class Type : public OpenDocumentManager::DocumentType { @@ -129,7 +129,7 @@ public: Type() {} ~Type() {} - bool canOpenFile (const File& file) { return true; } + bool canOpenFile (const File&) { return true; } Document* openFile (Project* project, const File& file) { return new UnknownDocument (project, file); } }; @@ -140,6 +140,8 @@ public: bool refersToProject (Project& p) const { return project == &p; } bool needsSaving() const { return false; } bool save() { return true; } + bool canSaveAs() const { return false; } + bool saveAs() { return false; } bool hasFileBeenModifiedExternally() { return fileModificationTime != file.getLastModificationTime(); } void reloadFromFile() { fileModificationTime = file.getLastModificationTime(); } String getName() const { return file.getFileName(); } diff --git a/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.h b/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.h index caf4edb0ff..ab5763024b 100644 --- a/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.h +++ b/extras/Introjucer/Source/Application/jucer_OpenDocumentManager.h @@ -56,6 +56,8 @@ public: virtual String getType() const = 0; virtual bool needsSaving() const = 0; virtual bool save() = 0; + virtual bool canSaveAs() const = 0; + virtual bool saveAs() = 0; virtual bool hasFileBeenModifiedExternally() = 0; virtual void reloadFromFile() = 0; virtual Component* createEditor() = 0; diff --git a/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.cpp b/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.cpp index bef8ccf3d0..b9ad81932f 100644 --- a/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.cpp +++ b/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.cpp @@ -37,7 +37,7 @@ JucerTreeViewBase::~JucerTreeViewBase() { } -const Font JucerTreeViewBase::getFont() const +Font JucerTreeViewBase::getFont() const { return Font (getItemHeight() * 0.6f); } @@ -109,7 +109,7 @@ Component* JucerTreeViewBase::createItemComponent() createLeftEdgeComponents (components); numLeftHandComps = components.size(); - return numLeftHandComps == 0 ? 0 : new TreeLeftHandButtonHolderComponent (components); + return numLeftHandComps == 0 ? nullptr : new TreeLeftHandButtonHolderComponent (components); } //============================================================================== diff --git a/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h b/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h index cb5f8e5310..80228acb27 100644 --- a/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h +++ b/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h @@ -70,7 +70,7 @@ public: //============================================================================== private: int numLeftHandComps; - const Font getFont() const; + Font getFont() const; int getTextX() const; }; diff --git a/extras/Introjucer/Source/Utility/jucer_ValueSourceHelpers.h b/extras/Introjucer/Source/Utility/jucer_ValueSourceHelpers.h index 9735512455..eccc70d10b 100644 --- a/extras/Introjucer/Source/Utility/jucer_ValueSourceHelpers.h +++ b/extras/Introjucer/Source/Utility/jucer_ValueSourceHelpers.h @@ -46,13 +46,12 @@ public: void setValue (const var& newValue) { - const Type newVal = (Type) newValue; + const Type newVal = static_cast (newValue); - if (newVal != (Type) getValue()) // this test is important, because if a property is missing, it won't - sourceValue = newVal; // create it (causing an unwanted undo action) when a control sets it to 0 + if (newVal != static_cast (getValue())) // this test is important, because if a property is missing, it won't + sourceValue = newVal; // create it (causing an unwanted undo action) when a control sets it to 0 } - //============================================================================== protected: Value sourceValue; diff --git a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp index d8592555b9..951f304420 100644 --- a/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp +++ b/modules/juce_audio_devices/native/juce_win32_WASAPI.cpp @@ -747,15 +747,25 @@ public: if (inputDevice != nullptr && inputDevice->client != nullptr) { latencyIn = (int) (inputDevice->latencySamples + inputDevice->actualBufferSize + inputDevice->minBufferSize); - HRESULT hr = inputDevice->client->Start(); - logFailure (hr); //xxx handle this + + if (! check (inputDevice->client->Start())) + { + close(); + lastError = "Couldn't start the input device!"; + return lastError; + } } if (outputDevice != nullptr && outputDevice->client != nullptr) { latencyOut = (int) (outputDevice->latencySamples + outputDevice->actualBufferSize + outputDevice->minBufferSize); - HRESULT hr = outputDevice->client->Start(); - logFailure (hr); //xxx handle this + + if (! check (outputDevice->client->Start())) + { + close(); + lastError = "Couldn't start the output device!"; + return lastError; + } } isOpen_ = true; diff --git a/modules/juce_core/maths/juce_BigInteger.cpp b/modules/juce_core/maths/juce_BigInteger.cpp index e270823398..6fff69962f 100644 --- a/modules/juce_core/maths/juce_BigInteger.cpp +++ b/modules/juce_core/maths/juce_BigInteger.cpp @@ -812,11 +812,11 @@ BigInteger BigInteger::findGreatestCommonDivisor (BigInteger n) const if (abs (m.getHighestBit() - n.getHighestBit()) <= 16) return simpleGCD (&m, &n); - BigInteger temp1 (m), temp2; - temp1.divideBy (n, temp2); + BigInteger temp2; + m.divideBy (n, temp2); - m = n; - n = temp2; + m.swapWith (n); + n.swapWith (temp2); } return m; diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp index 3521465994..6c26edf236 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp @@ -432,13 +432,10 @@ void Graphics::drawBevel (const int x, const int y, const int width, const int h { context->saveState(); - const float oldOpacity = 1.0f;//xxx state->colour.getFloatAlpha(); - const float ramp = oldOpacity / bevelThickness; - for (int i = bevelThickness; --i >= 0;) { - const float op = useGradient ? ramp * (sharpEdgeOnOutside ? bevelThickness - i : i) - : oldOpacity; + const float op = useGradient ? (sharpEdgeOnOutside ? bevelThickness - i : i) / bevelThickness + : 1.0f; context->setFill (topLeftColour.withMultipliedAlpha (op)); context->fillRect (Rectangle (x + i, y + i, width - i * 2, 1), false); diff --git a/modules/juce_graphics/geometry/juce_EdgeTable.cpp b/modules/juce_graphics/geometry/juce_EdgeTable.cpp index 40713cc773..bf4a8e17c3 100644 --- a/modules/juce_graphics/geometry/juce_EdgeTable.cpp +++ b/modules/juce_graphics/geometry/juce_EdgeTable.cpp @@ -629,8 +629,6 @@ void EdgeTable::excludeRectangle (const Rectangle& r) const int top = clipped.getY() - bounds.getY(); const int bottom = clipped.getBottom() - bounds.getY(); - //XXX optimise here by shortening the table if it fills top or bottom - const int rectLine[] = { 4, std::numeric_limits::min(), 255, clipped.getX() << 8, 0, clipped.getRight() << 8, 255, diff --git a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm index 935c39d77c..c26d393a7c 100644 --- a/modules/juce_gui_basics/native/juce_mac_FileChooser.mm +++ b/modules/juce_gui_basics/native/juce_mac_FileChooser.mm @@ -241,7 +241,7 @@ void FileChooser::showPlatformDialog (Array& results, { JUCE_AUTORELEASEPOOL - jassertfalse; //xxx to do + jassertfalse; //there's no such thing in iOS } #endif