Browse Source

Added a Component::setBounds method to take an expression. Fix for deleting CoreAudio devices.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
3f97694143
14 changed files with 318 additions and 213 deletions
  1. +3
    -3
      extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.cpp
  2. +5
    -5
      extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp
  3. +173
    -128
      juce_amalgamated.cpp
  4. +8
    -1
      juce_amalgamated.h
  5. +1
    -1
      src/core/juce_StandardHeader.h
  6. +5
    -0
      src/gui/components/juce_Component.cpp
  7. +7
    -0
      src/gui/components/juce_Component.h
  8. +4
    -4
      src/gui/components/layout/juce_ResizableEdgeComponent.cpp
  9. +9
    -3
      src/native/android/juce_android_Fonts.cpp
  10. +34
    -6
      src/native/android/juce_android_GraphicsContext.cpp
  11. +10
    -5
      src/native/android/juce_android_NativeCode.cpp
  12. +1
    -0
      src/native/linux/juce_linux_Audio.cpp
  13. +2
    -0
      src/native/mac/juce_mac_CoreAudio.cpp
  14. +56
    -57
      src/native/mac/juce_mac_OpenGLComponent.mm

+ 3
- 3
extras/Jucer (experimental)/Source/Project/jucer_ProjectContentComponent.cpp View File

@@ -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();


+ 5
- 5
extras/Jucer (experimental)/Source/Project/jucer_ProjectInformationComponent.cpp View File

@@ -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);


+ 173
- 128
juce_amalgamated.cpp View File

@@ -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 <OpenGLPixelFormat>& /*results*/)
OwnedArray <OpenGLPixelFormat>& 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 <OpenGLPixelFormat>& /*results*/)
OwnedArray <OpenGLPixelFormat>& 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, "<init>", "(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<jobject> 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<int>& r, bool replaceExistingContents)
@@ -281766,24 +281783,36 @@ public:

void beginTransparencyLayer (float opacity)
{
// TODO xxx
Rectangle<int> 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:


+ 8
- 1
juce_amalgamated.h View File

@@ -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


+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -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.


+ 5
- 0
src/gui/components/juce_Component.cpp View File

@@ -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)
{


+ 7
- 0
src/gui/components/juce_Component.h View File

@@ -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


+ 4
- 4
src/gui/components/layout/juce_ResizableEdgeComponent.cpp View File

@@ -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;
}


+ 9
- 3
src/native/android/juce_android_Fonts.cpp View File

@@ -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<jobject> ignored (paint.callObjectMethod (android.setTypeface, typeface.get()));
const float standardSize = 256.0f;


+ 34
- 6
src/native/android/juce_android_GraphicsContext.cpp View File

@@ -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<int> 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:


+ 10
- 5
src/native/android/juce_android_NativeCode.cpp View File

@@ -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, "<init>", "(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);
}


+ 1
- 0
src/native/linux/juce_linux_Audio.cpp View File

@@ -698,6 +698,7 @@ public:
~ALSAAudioIODevice()
{
close();
}
const StringArray getOutputChannelNames() { return internal.channelNamesOut; }


+ 2
- 0
src/native/mac/juce_mac_CoreAudio.cpp View File

@@ -901,6 +901,8 @@ public:
~CoreAudioIODevice()
{
close();
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioObjectPropertySelectorWildcard;
pa.mScope = kAudioObjectPropertyScopeWildcard;


+ 56
- 57
src/native/mac/juce_mac_OpenGLComponent.mm View File

@@ -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 <OpenGLPixelFormat>& /*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 <OpenGLPixelFormat>& 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


Loading…
Cancel
Save