1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-03 03:30:06 +00:00

Misc fixes and tweaks for networking, pthreads, jucer project generation, drawables.

This commit is contained in:
Julian Storer 2010-06-09 20:11:43 +01:00
parent 1f21a94753
commit cc45ec88f5
16 changed files with 190 additions and 68 deletions

View file

@ -861,6 +861,10 @@ public:
Value v (wrapper.getFontValue (item.getUndoManager()));
props.add (FontNameValueSource::createProperty ("Font", v));
props.add (FontStyleValueSource::createProperty ("Font Style", v));
props.add (new SliderPropertyComponent (Value (new FontDimensionSource (item, true)), "Font Height", 1.0, 150.0, 0.1, 0.5));
props.add (new SliderPropertyComponent (Value (new FontDimensionSource (item, false)), "Font Scale", 0.05, 10.0, 0.01, 0.5));
props.add (new ResetButtonPropertyComponent (item, wrapper));
}
@ -888,7 +892,7 @@ public:
case 0: return wrapper.getBoundingBox().topLeft;
case 1: return wrapper.getBoundingBox().topRight;
case 2: return wrapper.getBoundingBox().bottomLeft;
case 3: return wrapper.getFontSizeAndScaleAnchor();
case 3: return wrapper.getFontSizeControlPoint();
default: jassertfalse; break;
}
@ -901,7 +905,7 @@ public:
if (cpNum == 3)
{
wrapper.setFontSizeAndScaleAnchor (newPoint, undoManager);
wrapper.setFontSizeControlPoint (newPoint, undoManager);
}
else
{
@ -981,17 +985,92 @@ public:
const AffineTransform t (bounds.resetToPerpendicular (&item));
RelativePoint fontPos (wrapper.getFontSizeAndScaleAnchor());
RelativePoint fontPos (wrapper.getFontSizeControlPoint());
fontPos.moveToAbsolute (fontPos.resolve (&item).transformedBy (t), &item);
wrapper.setBoundingBox (bounds, item.getUndoManager());
wrapper.setFontSizeAndScaleAnchor (fontPos, item.getUndoManager());
wrapper.setFontSizeControlPoint (fontPos, item.getUndoManager());
}
private:
DrawableTypeInstance item;
DrawableText::ValueTreeWrapper wrapper;
};
//==============================================================================
class FontDimensionSource : public Value::ValueSource,
public ValueTree::Listener
{
public:
FontDimensionSource (const DrawableTypeInstance& item_, bool isHeight_)
: item (item_), isHeight (isHeight_), reentrant (false)
{
item.getState().addListener (this);
}
~FontDimensionSource() {}
const var getValue() const
{
DrawableText::ValueTreeWrapper wrapper (item.getState());
const RelativeParallelogram bounds (wrapper.getBoundingBox());
RelativePoint fontPoint (wrapper.getFontSizeControlPoint());
Point<float> corners[3];
bounds.resolveThreePoints (corners, &item);
Point<float> sizeAndScale (RelativeParallelogram::getInternalCoordForPoint (corners, fontPoint.resolve (&item)));
if (isHeight)
return sizeAndScale.getY();
else
return sizeAndScale.getX() / sizeAndScale.getY();
}
void setValue (const var& newValue)
{
if (reentrant)
return;
DrawableText::ValueTreeWrapper wrapper (item.getState());
const RelativeParallelogram bounds (wrapper.getBoundingBox());
RelativePoint fontPoint (wrapper.getFontSizeControlPoint());
Point<float> corners[3];
bounds.resolveThreePoints (corners, &item);
Point<float> sizeAndScale (RelativeParallelogram::getInternalCoordForPoint (corners, fontPoint.resolve (&item)));
const Point<float> oldSize (sizeAndScale);
if (isHeight)
sizeAndScale.setXY ((oldSize.getX() / oldSize.getY()) * (float) newValue, (float) newValue);
else
sizeAndScale.setX (sizeAndScale.getY() * (float) newValue);
if (oldSize.getDistanceFrom (sizeAndScale) > 0.001f)
wrapper.setFontSizeControlPoint (RelativePoint (RelativeParallelogram::getPointForInternalCoord (corners, sizeAndScale)),
item.getUndoManager());
}
void valueTreePropertyChanged (ValueTree& tree, const Identifier& property)
{
reentrant = true;
sendChangeMessage (true);
reentrant = false;
}
void valueTreeChildrenChanged (ValueTree& tree) {}
void valueTreeParentChanged (ValueTree& tree) {}
protected:
mutable DrawableTypeInstance item;
bool isHeight, reentrant;
FontDimensionSource (const FontDimensionSource&);
const FontDimensionSource& operator= (const FontDimensionSource&);
};
};

View file

@ -148,7 +148,6 @@ private:
}
const File getProjectBundle() const { return getTargetFolder().getChildFile (project.getProjectFilenameRoot()).withFileExtension (".xcodeproj"); }
const RelativePath getJuceLibFile() const { return getJucePathFromTargetFolder().getChildFile ("bin/libjucedebug.a"); }
bool hasPList() const { return ! (project.isLibrary() || project.isCommandLineApp()); }
const String getAudioPluginBundleExtension() const { return "component"; }
@ -359,7 +358,11 @@ private:
}
if (project.getJuceLinkageMode() == Project::useLinkedJuce)
getLinkerFlagsForStaticLibrary (getJuceLibFile(), flags, librarySearchPaths);
{
RelativePath juceLib (getJucePathFromTargetFolder().getChildFile (config.isDebug().getValue() ? "bin/libjucedebug.a"
: "bin/libjuce.a"));
getLinkerFlagsForStaticLibrary (juceLib, flags, librarySearchPaths);
}
flags.add (getExtraLinkerFlags().toString());
flags.removeEmptyStrings (true);

View file

@ -189,7 +189,7 @@ public:
}
setBoundsInTargetSpace (r);
label.update (getParentComponent(), coord.toString(), resizableBorderColour.withAlpha (0.9f), getX(), getY(), type != left, type != top);
label.update (getParentComponent(), coord.toString(), Colours::darkgrey, getX(), getY(), type != left, type != top);
}
private:

View file

@ -220,7 +220,7 @@ const String PropertyPanelWithTooltips::findTip (Component* c)
FloatingLabelComponent::FloatingLabelComponent()
: font (10.0f)
{
setInterceptsMouseClicks (false ,false);
setInterceptsMouseClicks (false, false);
}
void FloatingLabelComponent::remove()
@ -243,7 +243,7 @@ void FloatingLabelComponent::update (Component* parent, const String& text, cons
glyphs.justifyGlyphs (0, std::numeric_limits<int>::max(), 0, 0, 1000, 1000, Justification::topLeft);
r = glyphs.getBoundingBox (0, std::numeric_limits<int>::max(), false)
.getSmallestIntegerContainer().expanded (2, 2);
.getSmallestIntegerContainer().expanded (1, 1);
}
else
{
@ -259,10 +259,7 @@ void FloatingLabelComponent::paint (Graphics& g)
{
g.setFont (font);
g.setColour (Colours::white.withAlpha (0.5f));
for (int y = -1; y <= 1; ++y)
for (int x = -1; x <= 1; ++x)
glyphs.draw (g, AffineTransform::translation (1.0f + x, 1.0f + y));
g.fillRoundedRectangle (0, 0, (float) getWidth(), (float) getHeight(), 3);
g.setColour (colour);
glyphs.draw (g, AffineTransform::translation (1.0f, 1.0f));

View file

@ -8280,12 +8280,15 @@ private:
}
data << "--\r\n";
data.flush();
}
else
{
data << getMangledParameters (url.getParameters())
<< url.getPostData();
data.flush();
// just a short text attachment, so use simple url encoding..
headers = "Content-Type: application/x-www-form-urlencoded\r\nContent-length: "
+ String ((unsigned int) postData.getSize())
@ -51921,8 +51924,7 @@ class TextEditorViewport : public Viewport
{
public:
TextEditorViewport (TextEditor* const owner_)
: owner (owner_),
lastWordWrapWidth (0)
: owner (owner_), lastWordWrapWidth (0), rentrant (false)
{
}
@ -51932,18 +51934,26 @@ public:
void visibleAreaChanged (int, int, int, int)
{
const float wordWrapWidth = owner->getWordWrapWidth();
if (wordWrapWidth != lastWordWrapWidth)
if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars
// appear and disappear, causing the wrap width to change.
{
lastWordWrapWidth = wordWrapWidth;
owner->updateTextHolderSize();
const float wordWrapWidth = owner->getWordWrapWidth();
if (wordWrapWidth != lastWordWrapWidth)
{
lastWordWrapWidth = wordWrapWidth;
rentrant = true;
owner->updateTextHolderSize();
rentrant = false;
}
}
}
private:
TextEditor* const owner;
float lastWordWrapWidth;
bool rentrant;
TextEditorViewport (const TextEditorViewport&);
TextEditorViewport& operator= (const TextEditorViewport&);
@ -85569,7 +85579,7 @@ void DrawableText::setFont (const Font& newFont, bool applySizeAndScale)
Point<float> corners[3];
bounds.resolveThreePoints (corners, parent);
setFontSizeControlPoint (RelativePoint (bounds.getPointForInternalCoord (corners,
setFontSizeControlPoint (RelativePoint (RelativeParallelogram::getPointForInternalCoord (corners,
Point<float> (font.getHorizontalScale() * font.getHeight(), font.getHeight()))));
}
}
@ -85716,12 +85726,12 @@ void DrawableText::ValueTreeWrapper::setBoundingBox (const RelativeParallelogram
state.setProperty (bottomLeft, newBounds.bottomLeft.toString(), undoManager);
}
const RelativePoint DrawableText::ValueTreeWrapper::getFontSizeAndScaleAnchor() const
const RelativePoint DrawableText::ValueTreeWrapper::getFontSizeControlPoint() const
{
return state [fontSizeAnchor].toString();
}
void DrawableText::ValueTreeWrapper::setFontSizeAndScaleAnchor (const RelativePoint& p, UndoManager* undoManager)
void DrawableText::ValueTreeWrapper::setFontSizeControlPoint (const RelativePoint& p, UndoManager* undoManager)
{
state.setProperty (fontSizeAnchor, p.toString(), undoManager);
}
@ -85732,7 +85742,7 @@ const Rectangle<float> DrawableText::refreshFromValueTree (const ValueTree& tree
setName (v.getID());
const RelativeParallelogram newBounds (v.getBoundingBox());
const RelativePoint newFontPoint (v.getFontSizeAndScaleAnchor());
const RelativePoint newFontPoint (v.getFontSizeControlPoint());
const Colour newColour (v.getColour());
const Justification newJustification (v.getJustification());
const String newText (v.getText());
@ -85768,7 +85778,7 @@ const ValueTree DrawableText::createValueTree (ImageProvider*) const
v.setJustification (justification, 0);
v.setColour (colour, 0);
v.setBoundingBox (bounds, 0);
v.setFontSizeAndScaleAnchor (fontSizeControlPoint, 0);
v.setFontSizeControlPoint (fontSizeControlPoint, 0);
return tree;
}
@ -237916,7 +237926,7 @@ void* juce_openInternetFile (const String& url,
{
const TCHAR* mimeTypes[] = { _T("*/*"), 0 };
DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE;
DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES;
if (url.startsWithIgnoreCase ("https:"))
flags |= INTERNET_FLAG_SECURE; // (this flag only seems necessary if the OS is running IE6 -
@ -237961,7 +237971,9 @@ void* juce_openInternetFile (const String& url,
result->connection = connection;
result->request = request;
HttpEndRequest (request, 0, 0, 0);
if (! HttpEndRequest (request, 0, 0, 0))
break;
return result;
}
@ -238043,11 +238055,11 @@ void juce_getInternetFileHeaders (void* handle, StringPairArray& headers)
for (int i = 0; i < headersArray.size(); ++i)
{
const String& header = headersArray[i];
const String key (header.upToFirstOccurrenceOf (": ", false, false));
const String value (header.fromFirstOccurrenceOf (": ", false, false));
const String key (header.upToFirstOccurrenceOf ("; ", false, false));
const String value (header.fromFirstOccurrenceOf ("; ", false, false));
const String previousValue (headers [key]);
headers.set (key, previousValue.isEmpty() ? value : (previousValue + ";" + value));
headers.set (key, previousValue.isEmpty() ? value : (previousValue + "," + value));
}
break;
@ -252387,7 +252399,11 @@ public:
manualReset (manualReset_)
{
pthread_cond_init (&condition, 0);
pthread_mutex_init (&mutex, 0);
pthread_mutexattr_t atts;
pthread_mutexattr_init (&atts);
pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT);
pthread_mutex_init (&mutex, &atts);
}
~WaitableEventImpl()
@ -253858,10 +253874,10 @@ void juce_getInternetFileHeaders (void* handle, StringPairArray& headers)
for (int i = 0; i < s->headerLines.size(); ++i)
{
const String& headersEntry = s->headerLines[i];
const String key (headersEntry.upToFirstOccurrenceOf (": ", false, false));
const String value (headersEntry.fromFirstOccurrenceOf (": ", false, false));
const String key (headersEntry.upToFirstOccurrenceOf ("; ", false, false));
const String value (headersEntry.fromFirstOccurrenceOf ("; ", false, false));
const String previousValue (headers [key]);
headers.set (key, previousValue.isEmpty() ? value : (previousValue + ";" + value));
headers.set (key, previousValue.isEmpty() ? value : (previousValue + "," + value));
}
}
}
@ -254730,11 +254746,10 @@ namespace LinuxErrorHandling
static int ioErrorHandler (Display* display)
{
DBG ("ERROR: connection to X server broken.. terminating.");
errorOccurred = true;
if (JUCEApplication::getInstance() != 0)
Process::terminate();
MessageManager::getInstance()->stopDispatchLoop();
return 0;
}
@ -261723,8 +261738,12 @@ public:
- (void) createConnection
{
NSInteger oldRetainCount = [self retainCount];
connection = [[NSURLConnection alloc] initWithRequest: request
delegate: [self retain]];
delegate: self];
if (oldRetainCount == [self retainCount])
[self retain]; // newer SDK should already retain this, but there were problems in older versions..
if (connection == nil)
runLoopThread->signalThreadShouldExit();
@ -262282,7 +262301,11 @@ public:
manualReset (manualReset_)
{
pthread_cond_init (&condition, 0);
pthread_mutex_init (&mutex, 0);
pthread_mutexattr_t atts;
pthread_mutexattr_init (&atts);
pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT);
pthread_mutex_init (&mutex, &atts);
}
~WaitableEventImpl()

View file

@ -64,7 +64,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 52
#define JUCE_BUILDNUMBER 14
#define JUCE_BUILDNUMBER 15
/** Current Juce version number.
@ -59161,8 +59161,8 @@ public:
const RelativeParallelogram getBoundingBox() const;
void setBoundingBox (const RelativeParallelogram& newBounds, UndoManager* undoManager);
const RelativePoint getFontSizeAndScaleAnchor() const;
void setFontSizeAndScaleAnchor (const RelativePoint& p, UndoManager* undoManager);
const RelativePoint getFontSizeControlPoint() const;
void setFontSizeControlPoint (const RelativePoint& p, UndoManager* undoManager);
static const Identifier text, colour, font, justification, topLeft, topRight, bottomLeft, fontSizeAnchor;
};

View file

@ -33,7 +33,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 52
#define JUCE_BUILDNUMBER 14
#define JUCE_BUILDNUMBER 15
/** Current Juce version number.

View file

@ -919,8 +919,7 @@ class TextEditorViewport : public Viewport
{
public:
TextEditorViewport (TextEditor* const owner_)
: owner (owner_),
lastWordWrapWidth (0)
: owner (owner_), lastWordWrapWidth (0), rentrant (false)
{
}
@ -930,18 +929,26 @@ public:
void visibleAreaChanged (int, int, int, int)
{
const float wordWrapWidth = owner->getWordWrapWidth();
if (wordWrapWidth != lastWordWrapWidth)
if (! rentrant) // it's rare, but possible to get into a feedback loop as the viewport's scrollbars
// appear and disappear, causing the wrap width to change.
{
lastWordWrapWidth = wordWrapWidth;
owner->updateTextHolderSize();
const float wordWrapWidth = owner->getWordWrapWidth();
if (wordWrapWidth != lastWordWrapWidth)
{
lastWordWrapWidth = wordWrapWidth;
rentrant = true;
owner->updateTextHolderSize();
rentrant = false;
}
}
}
private:
TextEditor* const owner;
float lastWordWrapWidth;
bool rentrant;
TextEditorViewport (const TextEditorViewport&);
TextEditorViewport& operator= (const TextEditorViewport&);

View file

@ -73,7 +73,7 @@ void DrawableText::setFont (const Font& newFont, bool applySizeAndScale)
Point<float> corners[3];
bounds.resolveThreePoints (corners, parent);
setFontSizeControlPoint (RelativePoint (bounds.getPointForInternalCoord (corners,
setFontSizeControlPoint (RelativePoint (RelativeParallelogram::getPointForInternalCoord (corners,
Point<float> (font.getHorizontalScale() * font.getHeight(), font.getHeight()))));
}
}
@ -223,23 +223,24 @@ void DrawableText::ValueTreeWrapper::setBoundingBox (const RelativeParallelogram
state.setProperty (bottomLeft, newBounds.bottomLeft.toString(), undoManager);
}
const RelativePoint DrawableText::ValueTreeWrapper::getFontSizeAndScaleAnchor() const
const RelativePoint DrawableText::ValueTreeWrapper::getFontSizeControlPoint() const
{
return state [fontSizeAnchor].toString();
}
void DrawableText::ValueTreeWrapper::setFontSizeAndScaleAnchor (const RelativePoint& p, UndoManager* undoManager)
void DrawableText::ValueTreeWrapper::setFontSizeControlPoint (const RelativePoint& p, UndoManager* undoManager)
{
state.setProperty (fontSizeAnchor, p.toString(), undoManager);
}
//==============================================================================
const Rectangle<float> DrawableText::refreshFromValueTree (const ValueTree& tree, ImageProvider*)
{
ValueTreeWrapper v (tree);
setName (v.getID());
const RelativeParallelogram newBounds (v.getBoundingBox());
const RelativePoint newFontPoint (v.getFontSizeAndScaleAnchor());
const RelativePoint newFontPoint (v.getFontSizeControlPoint());
const Colour newColour (v.getColour());
const Justification newJustification (v.getJustification());
const String newText (v.getText());
@ -275,7 +276,7 @@ const ValueTree DrawableText::createValueTree (ImageProvider*) const
v.setJustification (justification, 0);
v.setColour (colour, 0);
v.setBoundingBox (bounds, 0);
v.setFontSizeAndScaleAnchor (fontSizeControlPoint, 0);
v.setFontSizeControlPoint (fontSizeControlPoint, 0);
return tree;
}

View file

@ -129,8 +129,8 @@ public:
const RelativeParallelogram getBoundingBox() const;
void setBoundingBox (const RelativeParallelogram& newBounds, UndoManager* undoManager);
const RelativePoint getFontSizeAndScaleAnchor() const;
void setFontSizeAndScaleAnchor (const RelativePoint& p, UndoManager* undoManager);
const RelativePoint getFontSizeControlPoint() const;
void setFontSizeControlPoint (const RelativePoint& p, UndoManager* undoManager);
static const Identifier text, colour, font, justification, topLeft, topRight, bottomLeft, fontSizeAnchor;
};

View file

@ -403,12 +403,15 @@ private:
}
data << "--\r\n";
data.flush();
}
else
{
data << getMangledParameters (url.getParameters())
<< url.getPostData();
data.flush();
// just a short text attachment, so use simple url encoding..
headers = "Content-Type: application/x-www-form-urlencoded\r\nContent-length: "
+ String ((unsigned int) postData.getSize())

View file

@ -70,7 +70,11 @@ public:
manualReset (manualReset_)
{
pthread_cond_init (&condition, 0);
pthread_mutex_init (&mutex, 0);
pthread_mutexattr_t atts;
pthread_mutexattr_init (&atts);
pthread_mutexattr_setprotocol (&atts, PTHREAD_PRIO_INHERIT);
pthread_mutex_init (&mutex, &atts);
}
~WaitableEventImpl()

View file

@ -254,11 +254,10 @@ namespace LinuxErrorHandling
static int ioErrorHandler (Display* display)
{
DBG ("ERROR: connection to X server broken.. terminating.");
errorOccurred = true;
if (JUCEApplication::getInstance() != 0)
Process::terminate();
MessageManager::getInstance()->stopDispatchLoop();
return 0;
}

View file

@ -463,10 +463,10 @@ void juce_getInternetFileHeaders (void* handle, StringPairArray& headers)
for (int i = 0; i < s->headerLines.size(); ++i)
{
const String& headersEntry = s->headerLines[i];
const String key (headersEntry.upToFirstOccurrenceOf (": ", false, false));
const String value (headersEntry.fromFirstOccurrenceOf (": ", false, false));
const String key (headersEntry.upToFirstOccurrenceOf ("; ", false, false));
const String value (headersEntry.fromFirstOccurrenceOf ("; ", false, false));
const String previousValue (headers [key]);
headers.set (key, previousValue.isEmpty() ? value : (previousValue + ";" + value));
headers.set (key, previousValue.isEmpty() ? value : (previousValue + "," + value));
}
}
}

View file

@ -232,8 +232,12 @@ public:
- (void) createConnection
{
NSInteger oldRetainCount = [self retainCount];
connection = [[NSURLConnection alloc] initWithRequest: request
delegate: [self retain]];
delegate: self];
if (oldRetainCount == [self retainCount])
[self retain]; // newer SDK should already retain this, but there were problems in older versions..
if (connection == nil)
runLoopThread->signalThreadShouldExit();

View file

@ -169,7 +169,7 @@ void* juce_openInternetFile (const String& url,
{
const TCHAR* mimeTypes[] = { _T("*/*"), 0 };
DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE;
DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES;
if (url.startsWithIgnoreCase ("https:"))
flags |= INTERNET_FLAG_SECURE; // (this flag only seems necessary if the OS is running IE6 -
@ -214,7 +214,9 @@ void* juce_openInternetFile (const String& url,
result->connection = connection;
result->request = request;
HttpEndRequest (request, 0, 0, 0);
if (! HttpEndRequest (request, 0, 0, 0))
break;
return result;
}
@ -296,11 +298,11 @@ void juce_getInternetFileHeaders (void* handle, StringPairArray& headers)
for (int i = 0; i < headersArray.size(); ++i)
{
const String& header = headersArray[i];
const String key (header.upToFirstOccurrenceOf (": ", false, false));
const String value (header.fromFirstOccurrenceOf (": ", false, false));
const String key (header.upToFirstOccurrenceOf ("; ", false, false));
const String value (header.fromFirstOccurrenceOf ("; ", false, false));
const String previousValue (headers [key]);
headers.set (key, previousValue.isEmpty() ? value : (previousValue + ";" + value));
headers.set (key, previousValue.isEmpty() ? value : (previousValue + "," + value));
}
break;