diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.cpp b/extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.cpp index c13b11ad10..99b6fbcbd0 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.cpp +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.cpp @@ -91,12 +91,12 @@ void ProjectContentComponent::setProject (Project* newProject) if (lastTreeWidth.getIntValue() < 150) lastTreeWidth = "250"; - projectTree->setBounds (RelativeRectangle ("0, 0, left + " + lastTreeWidth + ", parent.height")); + projectTree->setBounds ("0, 0, left + " + lastTreeWidth + ", parent.height"); addAndMakeVisible (resizerBar = new ResizableEdgeComponent (projectTree, &treeSizeConstrainer, ResizableEdgeComponent::rightEdge)); resizerBar->setComponentID ("resizer"); - resizerBar->setBounds (RelativeRectangle ("tree.right, 0, tree.right + 4, parent.height")); + resizerBar->setBounds ("tree.right, 0, tree.right + 4, parent.height"); project->addChangeListener (this); @@ -160,7 +160,7 @@ bool ProjectContentComponent::setEditorComponent (Component* editor, OpenDocumen contentView = editor; currentDocument = doc; addAndMakeVisible (editor); - editor->setBounds (RelativeRectangle ("resizer.right, 0, parent.right, parent.height")); + editor->setBounds ("resizer.right, 0, parent.right, parent.height"); updateMainWindowTitle(); commandManager->commandStatusChanged(); diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp b/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp index a32e94be02..2bd730f8fd 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp @@ -104,21 +104,21 @@ ProjectInformationComponent::ProjectInformationComponent (Project& project_) configTabBox (TabbedButtonBar::TabsAtTop) { addAndMakeVisible (&configTabBox); - configTabBox.setBounds (RelativeRectangle ("8, 0, this.left + parent.width - 16, this.top + parent.height - 36")); + configTabBox.setBounds ("8, 0, this.left + parent.width - 16, this.top + parent.height - 36"); addAndMakeVisible (&editConfigsButton); - editConfigsButton.setBounds (RelativeRectangle ("8, parent.height - 30, this.left + 192, this.top + 22")); + editConfigsButton.setBounds ("8, parent.height - 30, this.left + 192, this.top + 22"); editConfigsButton.setButtonText ("Add/Remove Configurations..."); editConfigsButton.addListener (this); addAndMakeVisible (&openProjectButton); - openProjectButton.setBounds (RelativeRectangle ("608, parent.height - 30, this.left + 208, this.top + 22")); + openProjectButton.setBounds ("608, parent.height - 30, this.left + 208, this.top + 22"); openProjectButton.setButtonText ("Open Project in "); openProjectButton.addListener (this); addAndMakeVisible (&editExportersButton); - editExportersButton.setBounds (RelativeRectangle ("208, parent.height - 30, this.left + 160, this.top + 22")); + editExportersButton.setBounds ("208, parent.height - 30, this.left + 160, this.top + 22"); editExportersButton.setButtonText ("Add/Remove Exporters..."); editExportersButton.addListener (this); addAndMakeVisible (&saveAndOpenButton); - saveAndOpenButton.setBounds (RelativeRectangle ("391, parent.height - 30, this.left + 208, this.top + 22")); + saveAndOpenButton.setBounds ("391, parent.height - 30, this.left + 208, this.top + 22"); saveAndOpenButton.setButtonText ("Save And Open in"); saveAndOpenButton.addListener (this); diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 19779450a8..2e2b255996 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -40551,6 +40551,11 @@ void Component::setBounds (const RelativeRectangle& newBounds) newBounds.applyToComponent (*this); } +void Component::setBounds (const String& newBoundsExpression) +{ + setBounds (RelativeRectangle (newBoundsExpression)); +} + void Component::setBoundsRelative (const float x, const float y, const float w, const float h) { @@ -63015,10 +63020,10 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) switch (edge) { - case leftEdge: bounds.setLeft (bounds.getX() + e.getDistanceFromDragStartX()); break; - case rightEdge: bounds.setWidth (bounds.getWidth() + e.getDistanceFromDragStartX()); break; - case topEdge: bounds.setTop (bounds.getY() + e.getDistanceFromDragStartY()); break; - case bottomEdge: bounds.setHeight (bounds.getHeight() + e.getDistanceFromDragStartY()); break; + case leftEdge: bounds.setLeft (jmin (bounds.getRight(), bounds.getX() + e.getDistanceFromDragStartX())); break; + case rightEdge: bounds.setWidth (jmax (0, bounds.getWidth() + e.getDistanceFromDragStartX())); break; + case topEdge: bounds.setTop (jmin (bounds.getBottom(), bounds.getY() + e.getDistanceFromDragStartY())); break; + case bottomEdge: bounds.setHeight (jmax (0, bounds.getHeight() + e.getDistanceFromDragStartY())); break; default: jassertfalse; break; } @@ -261088,6 +261093,7 @@ public: ~ALSAAudioIODevice() { + close(); } const StringArray getOutputChannelNames() { return internal.channelNamesOut; } @@ -268247,36 +268253,28 @@ public: : renderContext (0), pixelFormat (pixelFormat_) { - NSOpenGLPixelFormatAttribute attribs [64]; - int n = 0; - attribs[n++] = NSOpenGLPFADoubleBuffer; - attribs[n++] = NSOpenGLPFAAccelerated; - attribs[n++] = NSOpenGLPFAMPSafe; // NSOpenGLPFAAccelerated, NSOpenGLPFAMultiScreen, NSOpenGLPFASingleRenderer - attribs[n++] = NSOpenGLPFAColorSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) jmax (pixelFormat.redBits, - pixelFormat.greenBits, - pixelFormat.blueBits); - attribs[n++] = NSOpenGLPFAAlphaSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) pixelFormat.alphaBits; - attribs[n++] = NSOpenGLPFADepthSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) pixelFormat.depthBufferBits; - attribs[n++] = NSOpenGLPFAStencilSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) pixelFormat.stencilBufferBits; - attribs[n++] = NSOpenGLPFAAccumSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) jmax (pixelFormat.accumulationBufferRedBits, - pixelFormat.accumulationBufferGreenBits, - pixelFormat.accumulationBufferBlueBits, - pixelFormat.accumulationBufferAlphaBits); - - // xxx not sure how to do fullSceneAntiAliasingNumSamples.. - attribs[n++] = NSOpenGLPFASampleBuffers; - attribs[n++] = (NSOpenGLPixelFormatAttribute) 1; - attribs[n++] = NSOpenGLPFAClosestPolicy; - attribs[n++] = NSOpenGLPFANoRecovery; - attribs[n++] = (NSOpenGLPixelFormatAttribute) 0; - - NSOpenGLPixelFormat* format - = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; + NSOpenGLPixelFormatAttribute attribs[] = + { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAAccelerated, + NSOpenGLPFAMPSafe, + NSOpenGLPFAClosestPolicy, + NSOpenGLPFANoRecovery, + NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.redBits + + pixelFormat.greenBits + + pixelFormat.blueBits), + NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) pixelFormat.alphaBits, + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) pixelFormat.depthBufferBits, + NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute) pixelFormat.stencilBufferBits, + NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.accumulationBufferRedBits + + pixelFormat.accumulationBufferGreenBits + + pixelFormat.accumulationBufferBlueBits + + pixelFormat.accumulationBufferAlphaBits), + NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute) 1, + 0 + }; + + NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; view = [[ThreadSafeNSOpenGLView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f) pixelFormat: format]; @@ -268402,39 +268400,46 @@ void juce_glViewport (const int w, const int h) glViewport (0, 0, w, h); } +static int getPixelFormatAttribute (NSOpenGLPixelFormat* p, NSOpenGLPixelFormatAttribute att) +{ + GLint val = 0; + [p getValues: &val forAttribute: att forVirtualScreen: 0]; + return (int) val; +} + void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, - OwnedArray & /*results*/) + OwnedArray & results) { -/* GLint attribs [64]; - int n = 0; - attribs[n++] = AGL_RGBA; - attribs[n++] = AGL_DOUBLEBUFFER; - attribs[n++] = AGL_ACCELERATED; - attribs[n++] = AGL_NO_RECOVERY; - attribs[n++] = AGL_NONE; + NSOpenGLPixelFormatAttribute attributes[] = + { + NSOpenGLPFAWindow, + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAAccelerated, + NSOpenGLPFANoRecovery, + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) 16, + NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) 8, + NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) 24, + NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) 32, + 0 + }; - AGLPixelFormat p = aglChoosePixelFormat (0, 0, attribs); + NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes]; - while (p != 0) + if (format != nil) { OpenGLPixelFormat* const pf = new OpenGLPixelFormat(); - pf->redBits = getAGLAttribute (p, AGL_RED_SIZE); - pf->greenBits = getAGLAttribute (p, AGL_GREEN_SIZE); - pf->blueBits = getAGLAttribute (p, AGL_BLUE_SIZE); - pf->alphaBits = getAGLAttribute (p, AGL_ALPHA_SIZE); - pf->depthBufferBits = getAGLAttribute (p, AGL_DEPTH_SIZE); - pf->stencilBufferBits = getAGLAttribute (p, AGL_STENCIL_SIZE); - pf->accumulationBufferRedBits = getAGLAttribute (p, AGL_ACCUM_RED_SIZE); - pf->accumulationBufferGreenBits = getAGLAttribute (p, AGL_ACCUM_GREEN_SIZE); - pf->accumulationBufferBlueBits = getAGLAttribute (p, AGL_ACCUM_BLUE_SIZE); - pf->accumulationBufferAlphaBits = getAGLAttribute (p, AGL_ACCUM_ALPHA_SIZE); - - results.add (pf); - p = aglNextPixelFormat (p); - }*/ + pf->redBits = pf->greenBits = pf->blueBits = getPixelFormatAttribute (format, NSOpenGLPFAColorSize) / 3; + pf->alphaBits = getPixelFormatAttribute (format, NSOpenGLPFAAlphaSize); + pf->depthBufferBits = getPixelFormatAttribute (format, NSOpenGLPFADepthSize); + pf->stencilBufferBits = getPixelFormatAttribute (format, NSOpenGLPFAStencilSize); + pf->accumulationBufferRedBits = pf->accumulationBufferGreenBits + = pf->accumulationBufferBlueBits = pf->accumulationBufferAlphaBits + = getPixelFormatAttribute (format, NSOpenGLPFAAccumSize) / 4; - //jassertfalse // can't see how you do this in cocoa! + [format release]; + results.add (pf); + } } #else @@ -273950,36 +273955,28 @@ public: : renderContext (0), pixelFormat (pixelFormat_) { - NSOpenGLPixelFormatAttribute attribs [64]; - int n = 0; - attribs[n++] = NSOpenGLPFADoubleBuffer; - attribs[n++] = NSOpenGLPFAAccelerated; - attribs[n++] = NSOpenGLPFAMPSafe; // NSOpenGLPFAAccelerated, NSOpenGLPFAMultiScreen, NSOpenGLPFASingleRenderer - attribs[n++] = NSOpenGLPFAColorSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) jmax (pixelFormat.redBits, - pixelFormat.greenBits, - pixelFormat.blueBits); - attribs[n++] = NSOpenGLPFAAlphaSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) pixelFormat.alphaBits; - attribs[n++] = NSOpenGLPFADepthSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) pixelFormat.depthBufferBits; - attribs[n++] = NSOpenGLPFAStencilSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) pixelFormat.stencilBufferBits; - attribs[n++] = NSOpenGLPFAAccumSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) jmax (pixelFormat.accumulationBufferRedBits, - pixelFormat.accumulationBufferGreenBits, - pixelFormat.accumulationBufferBlueBits, - pixelFormat.accumulationBufferAlphaBits); - - // xxx not sure how to do fullSceneAntiAliasingNumSamples.. - attribs[n++] = NSOpenGLPFASampleBuffers; - attribs[n++] = (NSOpenGLPixelFormatAttribute) 1; - attribs[n++] = NSOpenGLPFAClosestPolicy; - attribs[n++] = NSOpenGLPFANoRecovery; - attribs[n++] = (NSOpenGLPixelFormatAttribute) 0; - - NSOpenGLPixelFormat* format - = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; + NSOpenGLPixelFormatAttribute attribs[] = + { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAAccelerated, + NSOpenGLPFAMPSafe, + NSOpenGLPFAClosestPolicy, + NSOpenGLPFANoRecovery, + NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.redBits + + pixelFormat.greenBits + + pixelFormat.blueBits), + NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) pixelFormat.alphaBits, + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) pixelFormat.depthBufferBits, + NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute) pixelFormat.stencilBufferBits, + NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.accumulationBufferRedBits + + pixelFormat.accumulationBufferGreenBits + + pixelFormat.accumulationBufferBlueBits + + pixelFormat.accumulationBufferAlphaBits), + NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute) 1, + 0 + }; + + NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; view = [[ThreadSafeNSOpenGLView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f) pixelFormat: format]; @@ -274105,39 +274102,46 @@ void juce_glViewport (const int w, const int h) glViewport (0, 0, w, h); } +static int getPixelFormatAttribute (NSOpenGLPixelFormat* p, NSOpenGLPixelFormatAttribute att) +{ + GLint val = 0; + [p getValues: &val forAttribute: att forVirtualScreen: 0]; + return (int) val; +} + void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, - OwnedArray & /*results*/) + OwnedArray & results) { -/* GLint attribs [64]; - int n = 0; - attribs[n++] = AGL_RGBA; - attribs[n++] = AGL_DOUBLEBUFFER; - attribs[n++] = AGL_ACCELERATED; - attribs[n++] = AGL_NO_RECOVERY; - attribs[n++] = AGL_NONE; + NSOpenGLPixelFormatAttribute attributes[] = + { + NSOpenGLPFAWindow, + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAAccelerated, + NSOpenGLPFANoRecovery, + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) 16, + NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) 8, + NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) 24, + NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) 32, + 0 + }; - AGLPixelFormat p = aglChoosePixelFormat (0, 0, attribs); + NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes]; - while (p != 0) + if (format != nil) { OpenGLPixelFormat* const pf = new OpenGLPixelFormat(); - pf->redBits = getAGLAttribute (p, AGL_RED_SIZE); - pf->greenBits = getAGLAttribute (p, AGL_GREEN_SIZE); - pf->blueBits = getAGLAttribute (p, AGL_BLUE_SIZE); - pf->alphaBits = getAGLAttribute (p, AGL_ALPHA_SIZE); - pf->depthBufferBits = getAGLAttribute (p, AGL_DEPTH_SIZE); - pf->stencilBufferBits = getAGLAttribute (p, AGL_STENCIL_SIZE); - pf->accumulationBufferRedBits = getAGLAttribute (p, AGL_ACCUM_RED_SIZE); - pf->accumulationBufferGreenBits = getAGLAttribute (p, AGL_ACCUM_GREEN_SIZE); - pf->accumulationBufferBlueBits = getAGLAttribute (p, AGL_ACCUM_BLUE_SIZE); - pf->accumulationBufferAlphaBits = getAGLAttribute (p, AGL_ACCUM_ALPHA_SIZE); - results.add (pf); - - p = aglNextPixelFormat (p); - }*/ + pf->redBits = pf->greenBits = pf->blueBits = getPixelFormatAttribute (format, NSOpenGLPFAColorSize) / 3; + pf->alphaBits = getPixelFormatAttribute (format, NSOpenGLPFAAlphaSize); + pf->depthBufferBits = getPixelFormatAttribute (format, NSOpenGLPFADepthSize); + pf->stencilBufferBits = getPixelFormatAttribute (format, NSOpenGLPFAStencilSize); + pf->accumulationBufferRedBits = pf->accumulationBufferGreenBits + = pf->accumulationBufferBlueBits = pf->accumulationBufferAlphaBits + = getPixelFormatAttribute (format, NSOpenGLPFAAccumSize) / 4; - //jassertfalse // can't see how you do this in cocoa! + [format release]; + results.add (pf); + } } #else @@ -277812,6 +277816,8 @@ public: ~CoreAudioIODevice() { + close(); + AudioObjectPropertyAddress pa; pa.mSelector = kAudioObjectPropertySelectorWildcard; pa.mScope = kAudioObjectPropertyScopeWildcard; @@ -279270,6 +279276,7 @@ BEGIN_JUCE_NAMESPACE METHOD (paintClass, descent, "descent", "()F") \ METHOD (paintClass, setTextSize, "setTextSize", "(F)V") \ METHOD (paintClass, getTextWidths, "getTextWidths", "(Ljava/lang/String;[F)I") \ + METHOD (paintClass, setTextScaleX, "setTextScaleX", "(F)V") \ \ METHOD (shaderClass, setLocalMatrix, "setLocalMatrix", "(Landroid/graphics/Matrix;)V") \ STATICFIELD (shaderTileModeClass, clampMode, "CLAMP", "Landroid/graphics/Shader$TileMode;") \ @@ -279292,6 +279299,7 @@ BEGIN_JUCE_NAMESPACE METHOD (matrixClass, setValues, "setValues", "([F)V") \ \ STATICMETHOD (typefaceClass, create, "create", "(Ljava/lang/String;I)Landroid/graphics/Typeface;") \ + STATICMETHOD (typefaceClass, createFromFile, "createFromFile", "(Ljava/lang/String;)Landroid/graphics/Typeface;") \ \ METHOD (rectClass, rectConstructor, "", "(IIII)V") \ FIELD (rectClass, rectLeft, "left", "I") \ @@ -279606,12 +279614,15 @@ public: String appFile, appDataDir; int screenWidth, screenHeight; - jobject createPaint() + jobject createPaint (Graphics::ResamplingQuality quality) { - const jint constructorFlags = 1 /*ANTI_ALIAS_FLAG*/ - | 2 /*FILTER_BITMAP_FLAG*/ - | 4 /*DITHER_FLAG*/ - | 128 /*SUBPIXEL_TEXT_FLAG*/; + jint constructorFlags = 1 /*ANTI_ALIAS_FLAG*/ + | 4 /*DITHER_FLAG*/ + | 128 /*SUBPIXEL_TEXT_FLAG*/; + + if (quality > Graphics::lowResamplingQuality) + constructorFlags |= 2; /*FILTER_BITMAP_FLAG*/ + return getEnv()->NewObject (paintClass, paintClassConstructor, constructorFlags); } @@ -281306,10 +281317,16 @@ public: if (font.isBold()) flags = 1; if (font.isItalic()) flags += 2; - typeface = GlobalRef (getEnv()->CallStaticObjectMethod (android.typefaceClass, android.create, - javaString (getName()).get(), flags)); + File fontFile (File ("/system/fonts").getChildFile (name).withFileExtension (".ttf")); + + if (fontFile.exists()) + typeface = GlobalRef (getEnv()->CallStaticObjectMethod (android.typefaceClass, android.createFromFile, + javaString (fontFile.getFullPathName()).get())); + else + typeface = GlobalRef (getEnv()->CallStaticObjectMethod (android.typefaceClass, android.create, + javaString (getName()).get(), flags)); - paint = GlobalRef (android.createPaint()); + paint = GlobalRef (android.createPaint (Graphics::highResamplingQuality)); const LocalRef ignored (paint.callObjectMethod (android.setTypeface, typeface.get())); const float standardSize = 256.0f; @@ -281619,7 +281636,7 @@ public: void setInterpolationQuality (Graphics::ResamplingQuality quality) { - // TODO xxx + currentState->setInterpolationQuality (quality); } void fillRect (const Rectangle& r, bool replaceExistingContents) @@ -281766,24 +281783,36 @@ public: void beginTransparencyLayer (float opacity) { - // TODO xxx + Rectangle clip (getClipBounds()); + + (void) canvas.callIntMethod (android.saveLayerAlpha, + (float) clip.getX(), + (float) clip.getY(), + (float) clip.getRight(), + (float) clip.getBottom(), + jlimit (0, 255, roundToInt (opacity * 255.0f)), + 31 /*ALL_SAVE_FLAG*/); + + stateStack.add (new SavedState (*currentState)); } void endTransparencyLayer() { - // TODO xxx + restoreState(); } class SavedState { public: SavedState() - : font (1.0f), fillNeedsUpdate (true), typefaceNeedsUpdate (true) + : font (1.0f), quality (Graphics::highResamplingQuality), + fillNeedsUpdate (true), typefaceNeedsUpdate (true) { } SavedState (const SavedState& other) - : fillType (other.fillType), font (other.font), fillNeedsUpdate (true), typefaceNeedsUpdate (true) + : fillType (other.fillType), font (other.font), quality (other.quality), + fillNeedsUpdate (true), typefaceNeedsUpdate (true) { } @@ -281799,6 +281828,16 @@ public: fillType.colour = fillType.colour.withAlpha (alpha); } + void setInterpolationQuality (Graphics::ResamplingQuality quality_) + { + if (quality != quality_) + { + quality = quality_; + fillNeedsUpdate = true; + paint.clear(); + } + } + jobject getPaint() { if (fillNeedsUpdate) @@ -281806,7 +281845,7 @@ public: JNIEnv* env = getEnv(); if (paint.get() == 0) - paint = GlobalRef (android.createPaint()); + paint = GlobalRef (android.createPaint (quality)); if (fillType.isColour()) { @@ -281890,6 +281929,11 @@ public: { paint.callObjectMethod (android.setTypeface, atf->typeface.get()); paint.callVoidMethod (android.setTextSize, font.getHeight()); + + const float hScale = font.getHorizontalScale(); + + if (hScale < 0.99f || hScale > 1.01f) + paint.callVoidMethod (android.setTextScaleX, hScale); } fillNeedsUpdate = true; @@ -281911,6 +281955,7 @@ public: Font font; GlobalRef paint; bool fillNeedsUpdate, typefaceNeedsUpdate; + Graphics::ResamplingQuality quality; }; private: diff --git a/juce_amalgamated.h b/juce_amalgamated.h index d0e8a9c7ed..c4d75be694 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 33 +#define JUCE_BUILDNUMBER 34 /** Current Juce version number. @@ -30134,6 +30134,13 @@ public: */ void setBounds (const RelativeRectangle& newBounds); + /** Sets the component's bounds with an expression. + The string is parsed as a RelativeRectangle expression - see the notes for + Component::setBounds (const RelativeRectangle&) for more information. This method is + basically just a shortcut for writing setBounds (RelativeRectangle ("...")) + */ + void setBounds (const String& newBoundsExpression); + /** Changes the component's position and size in terms of fractions of its parent's size. The values are factors of the parent's size, so for example diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index b54540011b..8e7e3e8595 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 33 +#define JUCE_BUILDNUMBER 34 /** Current Juce version number. diff --git a/src/gui/components/juce_Component.cpp b/src/gui/components/juce_Component.cpp index e6e17bf5b0..978f23ec7c 100644 --- a/src/gui/components/juce_Component.cpp +++ b/src/gui/components/juce_Component.cpp @@ -1095,6 +1095,11 @@ void Component::setBounds (const RelativeRectangle& newBounds) newBounds.applyToComponent (*this); } +void Component::setBounds (const String& newBoundsExpression) +{ + setBounds (RelativeRectangle (newBoundsExpression)); +} + void Component::setBoundsRelative (const float x, const float y, const float w, const float h) { diff --git a/src/gui/components/juce_Component.h b/src/gui/components/juce_Component.h index 68a9eb48c3..d25df01a3a 100644 --- a/src/gui/components/juce_Component.h +++ b/src/gui/components/juce_Component.h @@ -526,6 +526,13 @@ public: */ void setBounds (const RelativeRectangle& newBounds); + /** Sets the component's bounds with an expression. + The string is parsed as a RelativeRectangle expression - see the notes for + Component::setBounds (const RelativeRectangle&) for more information. This method is + basically just a shortcut for writing setBounds (RelativeRectangle ("...")) + */ + void setBounds (const String& newBoundsExpression); + /** Changes the component's position and size in terms of fractions of its parent's size. The values are factors of the parent's size, so for example diff --git a/src/gui/components/layout/juce_ResizableEdgeComponent.cpp b/src/gui/components/layout/juce_ResizableEdgeComponent.cpp index ecd651fa5c..a01a4d28fc 100644 --- a/src/gui/components/layout/juce_ResizableEdgeComponent.cpp +++ b/src/gui/components/layout/juce_ResizableEdgeComponent.cpp @@ -86,10 +86,10 @@ void ResizableEdgeComponent::mouseDrag (const MouseEvent& e) switch (edge) { - case leftEdge: bounds.setLeft (bounds.getX() + e.getDistanceFromDragStartX()); break; - case rightEdge: bounds.setWidth (bounds.getWidth() + e.getDistanceFromDragStartX()); break; - case topEdge: bounds.setTop (bounds.getY() + e.getDistanceFromDragStartY()); break; - case bottomEdge: bounds.setHeight (bounds.getHeight() + e.getDistanceFromDragStartY()); break; + case leftEdge: bounds.setLeft (jmin (bounds.getRight(), bounds.getX() + e.getDistanceFromDragStartX())); break; + case rightEdge: bounds.setWidth (jmax (0, bounds.getWidth() + e.getDistanceFromDragStartX())); break; + case topEdge: bounds.setTop (jmin (bounds.getBottom(), bounds.getY() + e.getDistanceFromDragStartY())); break; + case bottomEdge: bounds.setHeight (jmax (0, bounds.getHeight() + e.getDistanceFromDragStartY())); break; default: jassertfalse; break; } diff --git a/src/native/android/juce_android_Fonts.cpp b/src/native/android/juce_android_Fonts.cpp index f6a167ce7f..a4df71a456 100644 --- a/src/native/android/juce_android_Fonts.cpp +++ b/src/native/android/juce_android_Fonts.cpp @@ -63,10 +63,16 @@ public: if (font.isBold()) flags = 1; if (font.isItalic()) flags += 2; - typeface = GlobalRef (getEnv()->CallStaticObjectMethod (android.typefaceClass, android.create, - javaString (getName()).get(), flags)); + File fontFile (File ("/system/fonts").getChildFile (name).withFileExtension (".ttf")); - paint = GlobalRef (android.createPaint()); + if (fontFile.exists()) + typeface = GlobalRef (getEnv()->CallStaticObjectMethod (android.typefaceClass, android.createFromFile, + javaString (fontFile.getFullPathName()).get())); + else + typeface = GlobalRef (getEnv()->CallStaticObjectMethod (android.typefaceClass, android.create, + javaString (getName()).get(), flags)); + + paint = GlobalRef (android.createPaint (Graphics::highResamplingQuality)); const LocalRef ignored (paint.callObjectMethod (android.setTypeface, typeface.get())); const float standardSize = 256.0f; diff --git a/src/native/android/juce_android_GraphicsContext.cpp b/src/native/android/juce_android_GraphicsContext.cpp index 3cdf4cf18a..778a8c23f9 100644 --- a/src/native/android/juce_android_GraphicsContext.cpp +++ b/src/native/android/juce_android_GraphicsContext.cpp @@ -250,7 +250,7 @@ public: void setInterpolationQuality (Graphics::ResamplingQuality quality) { - // TODO xxx + currentState->setInterpolationQuality (quality); } //============================================================================== @@ -399,24 +399,36 @@ public: void beginTransparencyLayer (float opacity) { - // TODO xxx + Rectangle clip (getClipBounds()); + + (void) canvas.callIntMethod (android.saveLayerAlpha, + (float) clip.getX(), + (float) clip.getY(), + (float) clip.getRight(), + (float) clip.getBottom(), + jlimit (0, 255, roundToInt (opacity * 255.0f)), + 31 /*ALL_SAVE_FLAG*/); + + stateStack.add (new SavedState (*currentState)); } void endTransparencyLayer() { - // TODO xxx + restoreState(); } class SavedState { public: SavedState() - : font (1.0f), fillNeedsUpdate (true), typefaceNeedsUpdate (true) + : font (1.0f), quality (Graphics::highResamplingQuality), + fillNeedsUpdate (true), typefaceNeedsUpdate (true) { } SavedState (const SavedState& other) - : fillType (other.fillType), font (other.font), fillNeedsUpdate (true), typefaceNeedsUpdate (true) + : fillType (other.fillType), font (other.font), quality (other.quality), + fillNeedsUpdate (true), typefaceNeedsUpdate (true) { } @@ -432,6 +444,16 @@ public: fillType.colour = fillType.colour.withAlpha (alpha); } + void setInterpolationQuality (Graphics::ResamplingQuality quality_) + { + if (quality != quality_) + { + quality = quality_; + fillNeedsUpdate = true; + paint.clear(); + } + } + jobject getPaint() { if (fillNeedsUpdate) @@ -439,7 +461,7 @@ public: JNIEnv* env = getEnv(); if (paint.get() == 0) - paint = GlobalRef (android.createPaint()); + paint = GlobalRef (android.createPaint (quality)); if (fillType.isColour()) { @@ -523,6 +545,11 @@ public: { paint.callObjectMethod (android.setTypeface, atf->typeface.get()); paint.callVoidMethod (android.setTextSize, font.getHeight()); + + const float hScale = font.getHorizontalScale(); + + if (hScale < 0.99f || hScale > 1.01f) + paint.callVoidMethod (android.setTextScaleX, hScale); } fillNeedsUpdate = true; @@ -544,6 +571,7 @@ public: Font font; GlobalRef paint; bool fillNeedsUpdate, typefaceNeedsUpdate; + Graphics::ResamplingQuality quality; }; private: diff --git a/src/native/android/juce_android_NativeCode.cpp b/src/native/android/juce_android_NativeCode.cpp index a6dff0bb33..5c6a219435 100644 --- a/src/native/android/juce_android_NativeCode.cpp +++ b/src/native/android/juce_android_NativeCode.cpp @@ -172,6 +172,7 @@ BEGIN_JUCE_NAMESPACE METHOD (paintClass, descent, "descent", "()F") \ METHOD (paintClass, setTextSize, "setTextSize", "(F)V") \ METHOD (paintClass, getTextWidths, "getTextWidths", "(Ljava/lang/String;[F)I") \ + METHOD (paintClass, setTextScaleX, "setTextScaleX", "(F)V") \ \ METHOD (shaderClass, setLocalMatrix, "setLocalMatrix", "(Landroid/graphics/Matrix;)V") \ STATICFIELD (shaderTileModeClass, clampMode, "CLAMP", "Landroid/graphics/Shader$TileMode;") \ @@ -194,6 +195,7 @@ BEGIN_JUCE_NAMESPACE METHOD (matrixClass, setValues, "setValues", "([F)V") \ \ STATICMETHOD (typefaceClass, create, "create", "(Ljava/lang/String;I)Landroid/graphics/Typeface;") \ + STATICMETHOD (typefaceClass, createFromFile, "createFromFile", "(Ljava/lang/String;)Landroid/graphics/Typeface;") \ \ METHOD (rectClass, rectConstructor, "", "(IIII)V") \ FIELD (rectClass, rectLeft, "left", "I") \ @@ -519,12 +521,15 @@ public: String appFile, appDataDir; int screenWidth, screenHeight; - jobject createPaint() + jobject createPaint (Graphics::ResamplingQuality quality) { - const jint constructorFlags = 1 /*ANTI_ALIAS_FLAG*/ - | 2 /*FILTER_BITMAP_FLAG*/ - | 4 /*DITHER_FLAG*/ - | 128 /*SUBPIXEL_TEXT_FLAG*/; + jint constructorFlags = 1 /*ANTI_ALIAS_FLAG*/ + | 4 /*DITHER_FLAG*/ + | 128 /*SUBPIXEL_TEXT_FLAG*/; + + if (quality > Graphics::lowResamplingQuality) + constructorFlags |= 2; /*FILTER_BITMAP_FLAG*/ + return getEnv()->NewObject (paintClass, paintClassConstructor, constructorFlags); } diff --git a/src/native/linux/juce_linux_Audio.cpp b/src/native/linux/juce_linux_Audio.cpp index eb41de75b0..58fb6bdbd2 100644 --- a/src/native/linux/juce_linux_Audio.cpp +++ b/src/native/linux/juce_linux_Audio.cpp @@ -698,6 +698,7 @@ public: ~ALSAAudioIODevice() { + close(); } const StringArray getOutputChannelNames() { return internal.channelNamesOut; } diff --git a/src/native/mac/juce_mac_CoreAudio.cpp b/src/native/mac/juce_mac_CoreAudio.cpp index b981a520dc..c31036d7dc 100644 --- a/src/native/mac/juce_mac_CoreAudio.cpp +++ b/src/native/mac/juce_mac_CoreAudio.cpp @@ -901,6 +901,8 @@ public: ~CoreAudioIODevice() { + close(); + AudioObjectPropertyAddress pa; pa.mSelector = kAudioObjectPropertySelectorWildcard; pa.mScope = kAudioObjectPropertyScopeWildcard; diff --git a/src/native/mac/juce_mac_OpenGLComponent.mm b/src/native/mac/juce_mac_OpenGLComponent.mm index f5d9069f7a..fcabc0867a 100644 --- a/src/native/mac/juce_mac_OpenGLComponent.mm +++ b/src/native/mac/juce_mac_OpenGLComponent.mm @@ -137,36 +137,28 @@ public: : renderContext (0), pixelFormat (pixelFormat_) { - NSOpenGLPixelFormatAttribute attribs [64]; - int n = 0; - attribs[n++] = NSOpenGLPFADoubleBuffer; - attribs[n++] = NSOpenGLPFAAccelerated; - attribs[n++] = NSOpenGLPFAMPSafe; // NSOpenGLPFAAccelerated, NSOpenGLPFAMultiScreen, NSOpenGLPFASingleRenderer - attribs[n++] = NSOpenGLPFAColorSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) jmax (pixelFormat.redBits, - pixelFormat.greenBits, - pixelFormat.blueBits); - attribs[n++] = NSOpenGLPFAAlphaSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) pixelFormat.alphaBits; - attribs[n++] = NSOpenGLPFADepthSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) pixelFormat.depthBufferBits; - attribs[n++] = NSOpenGLPFAStencilSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) pixelFormat.stencilBufferBits; - attribs[n++] = NSOpenGLPFAAccumSize; - attribs[n++] = (NSOpenGLPixelFormatAttribute) jmax (pixelFormat.accumulationBufferRedBits, - pixelFormat.accumulationBufferGreenBits, - pixelFormat.accumulationBufferBlueBits, - pixelFormat.accumulationBufferAlphaBits); - - // xxx not sure how to do fullSceneAntiAliasingNumSamples.. - attribs[n++] = NSOpenGLPFASampleBuffers; - attribs[n++] = (NSOpenGLPixelFormatAttribute) 1; - attribs[n++] = NSOpenGLPFAClosestPolicy; - attribs[n++] = NSOpenGLPFANoRecovery; - attribs[n++] = (NSOpenGLPixelFormatAttribute) 0; - - NSOpenGLPixelFormat* format - = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; + NSOpenGLPixelFormatAttribute attribs[] = + { + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAAccelerated, + NSOpenGLPFAMPSafe, + NSOpenGLPFAClosestPolicy, + NSOpenGLPFANoRecovery, + NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.redBits + + pixelFormat.greenBits + + pixelFormat.blueBits), + NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) pixelFormat.alphaBits, + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) pixelFormat.depthBufferBits, + NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute) pixelFormat.stencilBufferBits, + NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) (pixelFormat.accumulationBufferRedBits + + pixelFormat.accumulationBufferGreenBits + + pixelFormat.accumulationBufferBlueBits + + pixelFormat.accumulationBufferAlphaBits), + NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute) 1, + 0 + }; + + NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attribs]; view = [[ThreadSafeNSOpenGLView alloc] initWithFrame: NSMakeRect (0, 0, 100.0f, 100.0f) pixelFormat: format]; @@ -295,39 +287,46 @@ void juce_glViewport (const int w, const int h) glViewport (0, 0, w, h); } -void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, - OwnedArray & /*results*/) +static int getPixelFormatAttribute (NSOpenGLPixelFormat* p, NSOpenGLPixelFormatAttribute att) { -/* GLint attribs [64]; - int n = 0; - attribs[n++] = AGL_RGBA; - attribs[n++] = AGL_DOUBLEBUFFER; - attribs[n++] = AGL_ACCELERATED; - attribs[n++] = AGL_NO_RECOVERY; - attribs[n++] = AGL_NONE; - - AGLPixelFormat p = aglChoosePixelFormat (0, 0, attribs); + GLint val = 0; + [p getValues: &val forAttribute: att forVirtualScreen: 0]; + return (int) val; +} - while (p != 0) +void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, + OwnedArray & results) +{ + NSOpenGLPixelFormatAttribute attributes[] = + { + NSOpenGLPFAWindow, + NSOpenGLPFADoubleBuffer, + NSOpenGLPFAAccelerated, + NSOpenGLPFANoRecovery, + NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) 16, + NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute) 8, + NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute) 24, + NSOpenGLPFAAccumSize, (NSOpenGLPixelFormatAttribute) 32, + 0 + }; + + NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes: attributes]; + + if (format != nil) { OpenGLPixelFormat* const pf = new OpenGLPixelFormat(); - pf->redBits = getAGLAttribute (p, AGL_RED_SIZE); - pf->greenBits = getAGLAttribute (p, AGL_GREEN_SIZE); - pf->blueBits = getAGLAttribute (p, AGL_BLUE_SIZE); - pf->alphaBits = getAGLAttribute (p, AGL_ALPHA_SIZE); - pf->depthBufferBits = getAGLAttribute (p, AGL_DEPTH_SIZE); - pf->stencilBufferBits = getAGLAttribute (p, AGL_STENCIL_SIZE); - pf->accumulationBufferRedBits = getAGLAttribute (p, AGL_ACCUM_RED_SIZE); - pf->accumulationBufferGreenBits = getAGLAttribute (p, AGL_ACCUM_GREEN_SIZE); - pf->accumulationBufferBlueBits = getAGLAttribute (p, AGL_ACCUM_BLUE_SIZE); - pf->accumulationBufferAlphaBits = getAGLAttribute (p, AGL_ACCUM_ALPHA_SIZE); - - results.add (pf); - p = aglNextPixelFormat (p); - }*/ + pf->redBits = pf->greenBits = pf->blueBits = getPixelFormatAttribute (format, NSOpenGLPFAColorSize) / 3; + pf->alphaBits = getPixelFormatAttribute (format, NSOpenGLPFAAlphaSize); + pf->depthBufferBits = getPixelFormatAttribute (format, NSOpenGLPFADepthSize); + pf->stencilBufferBits = getPixelFormatAttribute (format, NSOpenGLPFAStencilSize); + pf->accumulationBufferRedBits = pf->accumulationBufferGreenBits + = pf->accumulationBufferBlueBits = pf->accumulationBufferAlphaBits + = getPixelFormatAttribute (format, NSOpenGLPFAAccumSize) / 4; - //jassertfalse // can't see how you do this in cocoa! + [format release]; + results.add (pf); + } } #else