Browse Source

Changes to relative coordinate classes. Fix for jucer include file.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
3cb4fb4034
10 changed files with 126 additions and 144 deletions
  1. +2
    -2
      extras/Jucer (experimental)/Source/Utility/jucer_MiscUtilities.cpp
  2. +1
    -1
      extras/Jucer (experimental)/Source/jucer_Headers.h
  3. +6
    -6
      extras/juce demo/Source/demos/DragAndDropDemo.cpp
  4. +27
    -27
      extras/juce demo/Source/demos/InterprocessCommsDemo.cpp
  5. +39
    -49
      juce_amalgamated.cpp
  6. +6
    -5
      juce_amalgamated.h
  7. +1
    -1
      src/core/juce_StandardHeader.h
  8. +13
    -19
      src/gui/graphics/drawables/juce_DrawableComposite.cpp
  9. +26
    -30
      src/gui/graphics/geometry/juce_RelativeCoordinate.cpp
  10. +5
    -4
      src/gui/graphics/geometry/juce_RelativeCoordinate.h

+ 2
- 2
extras/Jucer (experimental)/Source/Utility/jucer_MiscUtilities.cpp View File

@@ -337,8 +337,8 @@ const RelativeCoordinate RelativeRectangleLayoutManager::findNamedCoordinate (co
{ {
if (objectName == RelativeCoordinate::Strings::parent) if (objectName == RelativeCoordinate::Strings::parent)
{ {
if (edge == RelativeCoordinate::Strings::right) return RelativeCoordinate ((double) parent->getWidth(), true);
if (edge == RelativeCoordinate::Strings::bottom) return RelativeCoordinate ((double) parent->getHeight(), false);
if (edge == RelativeCoordinate::Strings::right) return RelativeCoordinate ((double) parent->getWidth());
if (edge == RelativeCoordinate::Strings::bottom) return RelativeCoordinate ((double) parent->getHeight());
} }
if (objectName.isNotEmpty() && edge.isNotEmpty()) if (objectName.isNotEmpty() && edge.isNotEmpty())


+ 1
- 1
extras/Jucer (experimental)/Source/jucer_Headers.h View File

@@ -32,7 +32,7 @@
//============================================================================== //==============================================================================
#include "../JuceLibraryCode/JuceHeader.h" #include "../JuceLibraryCode/JuceHeader.h"
#include "jucer_CommonHeaders.h"
#include "Application/jucer_CommonHeaders.h"
#endif // __JUCER_HEADERS_JUCEHEADER__ #endif // __JUCER_HEADERS_JUCEHEADER__

+ 6
- 6
extras/juce demo/Source/demos/DragAndDropDemo.cpp View File

@@ -34,7 +34,7 @@ class DragAndDropDemoSource : public ListBox,
public: public:
//============================================================================== //==============================================================================
DragAndDropDemoSource() DragAndDropDemoSource()
: ListBox (T("d+d source"), 0)
: ListBox ("d+d source", 0)
{ {
// tells the ListBox that this object supplies the info about // tells the ListBox that this object supplies the info about
// its rows. // its rows.
@@ -66,7 +66,7 @@ public:
g.setColour (Colours::black); g.setColour (Colours::black);
g.setFont (height * 0.7f); g.setFont (height * 0.7f);
g.drawText (T("Row Number ") + String (rowNumber + 1),
g.drawText ("Row Number " + String (rowNumber + 1),
5, 0, width, height, 5, 0, width, height,
Justification::centredLeft, true); Justification::centredLeft, true);
} }
@@ -79,7 +79,7 @@ public:
String desc; String desc;
for (int i = 0; i < selectedRows.size(); ++i) for (int i = 0; i < selectedRows.size(); ++i)
desc << (selectedRows [i] + 1) << T(" ");
desc << (selectedRows [i] + 1) << " ";
return desc.trim(); return desc.trim();
} }
@@ -121,7 +121,7 @@ public:
{ {
somethingIsBeingDraggedOver = false; somethingIsBeingDraggedOver = false;
message = T("Drag-and-drop some rows from the top-left box onto this component!");
message = "Drag-and-drop some rows from the top-left box onto this component!";
} }
~DragAndDropDemoTarget() ~DragAndDropDemoTarget()
@@ -172,7 +172,7 @@ public:
void itemDropped (const String& sourceDescription, Component* /*sourceComponent*/, int /*x*/, int /*y*/) void itemDropped (const String& sourceDescription, Component* /*sourceComponent*/, int /*x*/, int /*y*/)
{ {
message = T("last rows dropped: ") + sourceDescription;
message = "last rows dropped: " + sourceDescription;
somethingIsBeingDraggedOver = false; somethingIsBeingDraggedOver = false;
repaint(); repaint();
@@ -192,7 +192,7 @@ public:
//============================================================================== //==============================================================================
DragAndDropDemo() DragAndDropDemo()
{ {
setName (T("Drag-and-Drop"));
setName ("Drag-and-Drop");
source = new DragAndDropDemoSource(); source = new DragAndDropDemoSource();
addAndMakeVisible (source); addAndMakeVisible (source);


+ 27
- 27
extras/juce demo/Source/demos/InterprocessCommsDemo.cpp View File

@@ -37,56 +37,56 @@ public:
{ {
server = new DemoInterprocessConnectionServer (*this); server = new DemoInterprocessConnectionServer (*this);
setName (T("Interprocess Communication"));
setName ("Interprocess Communication");
// create all our UI bits and pieces.. // create all our UI bits and pieces..
addAndMakeVisible (modeSelector = new ComboBox (T("mode:")));
addAndMakeVisible (modeSelector = new ComboBox ("mode:"));
modeSelector->setBounds (100, 25, 200, 24); modeSelector->setBounds (100, 25, 200, 24);
(new Label (modeSelector->getName(), modeSelector->getName()))->attachToComponent (modeSelector, true); (new Label (modeSelector->getName(), modeSelector->getName()))->attachToComponent (modeSelector, true);
modeSelector->addItem (T("(Disconnected)"), 8);
modeSelector->addItem ("(Disconnected)", 8);
modeSelector->addSeparator(); modeSelector->addSeparator();
modeSelector->addItem (T("Named pipe (listening)"), 1);
modeSelector->addItem (T("Named pipe (connect to existing pipe)"), 5);
modeSelector->addItem ("Named pipe (listening)", 1);
modeSelector->addItem ("Named pipe (connect to existing pipe)", 5);
modeSelector->addSeparator(); modeSelector->addSeparator();
modeSelector->addItem (T("Socket (listening)"), 2);
modeSelector->addItem (T("Socket (connect to existing socket)"), 6);
modeSelector->addItem ("Socket (listening)", 2);
modeSelector->addItem ("Socket (connect to existing socket)", 6);
modeSelector->setSelectedId (8); modeSelector->setSelectedId (8);
modeSelector->addListener (this); modeSelector->addListener (this);
addAndMakeVisible (pipeName = new TextEditor (T("pipe name:")));
addAndMakeVisible (pipeName = new TextEditor ("pipe name:"));
pipeName->setBounds (100, 60, 130, 24); pipeName->setBounds (100, 60, 130, 24);
pipeName->setMultiLine (false); pipeName->setMultiLine (false);
pipeName->setText (T("juce demo pipe"));
pipeName->setText ("juce demo pipe");
(new Label (pipeName->getName(), pipeName->getName()))->attachToComponent (pipeName, true); (new Label (pipeName->getName(), pipeName->getName()))->attachToComponent (pipeName, true);
addAndMakeVisible (socketNumber = new TextEditor (T("socket port:")));
addAndMakeVisible (socketNumber = new TextEditor ("socket port:"));
socketNumber->setBounds (350, 60, 80, 24); socketNumber->setBounds (350, 60, 80, 24);
socketNumber->setMultiLine (false); socketNumber->setMultiLine (false);
socketNumber->setText (T("12345"));
socketNumber->setInputRestrictions (5, T("0123456789"));
socketNumber->setText ("12345");
socketNumber->setInputRestrictions (5, "0123456789");
(new Label (socketNumber->getName(), socketNumber->getName()))->attachToComponent (socketNumber, true); (new Label (socketNumber->getName(), socketNumber->getName()))->attachToComponent (socketNumber, true);
addAndMakeVisible (socketHost = new TextEditor (T("socket host:")));
addAndMakeVisible (socketHost = new TextEditor ("socket host:"));
socketHost->setBounds (530, 60, 130, 24); socketHost->setBounds (530, 60, 130, 24);
socketHost->setMultiLine (false); socketHost->setMultiLine (false);
socketHost->setText (T("localhost"));
socketHost->setText ("localhost");
socketNumber->setInputRestrictions (512); socketNumber->setInputRestrictions (512);
(new Label (socketHost->getName(), socketHost->getName()))->attachToComponent (socketHost, true); (new Label (socketHost->getName(), socketHost->getName()))->attachToComponent (socketHost, true);
addChildComponent (sendText = new TextEditor (T("sendtext")));
addChildComponent (sendText = new TextEditor ("sendtext"));
sendText->setBounds (30, 120, 200, 24); sendText->setBounds (30, 120, 200, 24);
sendText->setMultiLine (false); sendText->setMultiLine (false);
sendText->setReadOnly (false); sendText->setReadOnly (false);
sendText->setText (T("testing 1234"));
sendText->setText ("testing 1234");
addChildComponent (sendButton = new TextButton (T("send"), T("Fires off the message")));
addChildComponent (sendButton = new TextButton ("send", "Fires off the message"));
sendButton->setBounds (240, 120, 200, 24); sendButton->setBounds (240, 120, 200, 24);
sendButton->changeWidthToFitText(); sendButton->changeWidthToFitText();
sendButton->addButtonListener (this); sendButton->addButtonListener (this);
addChildComponent (incomingMessages = new TextEditor (T("messages")));
addChildComponent (incomingMessages = new TextEditor ("messages"));
incomingMessages->setReadOnly (true); incomingMessages->setReadOnly (true);
incomingMessages->setMultiLine (true); incomingMessages->setMultiLine (true);
incomingMessages->setBounds (30, 150, 500, 250); incomingMessages->setBounds (30, 150, 500, 250);
@@ -117,7 +117,7 @@ public:
if (! activeConnections[i]->sendMessage (messageData)) if (! activeConnections[i]->sendMessage (messageData))
{ {
// the write failed, so indicate that the connection has broken.. // the write failed, so indicate that the connection has broken..
appendMessage (T("send message failed!"));
appendMessage ("send message failed!");
} }
} }
} }
@@ -205,7 +205,7 @@ public:
openedOk = server->beginWaitingForSocket (socketNumber->getText().getIntValue()); openedOk = server->beginWaitingForSocket (socketNumber->getText().getIntValue());
if (openedOk) if (openedOk)
appendMessage (T("Waiting for another app to connect to this socket.."));
appendMessage ("Waiting for another app to connect to this socket..");
} }
else else
{ {
@@ -215,7 +215,7 @@ public:
if (openedOk) if (openedOk)
{ {
appendMessage (T("Waiting for another app to connect to this pipe.."));
appendMessage ("Waiting for another app to connect to this pipe..");
activeConnections.add (newConnection); activeConnections.add (newConnection);
} }
else else
@@ -230,15 +230,15 @@ public:
modeSelector->setSelectedId (8); modeSelector->setSelectedId (8);
AlertWindow::showMessageBox (AlertWindow::WarningIcon, AlertWindow::showMessageBox (AlertWindow::WarningIcon,
T("Interprocess Comms Demo"),
T("Failed to open the socket or pipe..."));
"Interprocess Comms Demo",
"Failed to open the socket or pipe...");
} }
} }
void appendMessage (const String& message) void appendMessage (const String& message)
{ {
incomingMessages->setCaretPosition (INT_MAX); incomingMessages->setCaretPosition (INT_MAX);
incomingMessages->insertTextAtCaret (message + T("\n"));
incomingMessages->insertTextAtCaret (message + "\n");
incomingMessages->setCaretPosition (INT_MAX); incomingMessages->setCaretPosition (INT_MAX);
} }
@@ -263,17 +263,17 @@ public:
void connectionMade() void connectionMade()
{ {
owner.appendMessage (T("Connection #") + String (ourNumber) + T(" - connection started"));
owner.appendMessage ("Connection #" + String (ourNumber) + " - connection started");
} }
void connectionLost() void connectionLost()
{ {
owner.appendMessage (T("Connection #") + String (ourNumber) + T(" - connection lost"));
owner.appendMessage ("Connection #" + String (ourNumber) + " - connection lost");
} }
void messageReceived (const MemoryBlock& message) void messageReceived (const MemoryBlock& message)
{ {
owner.appendMessage (T("Connection #") + String (ourNumber) + T(" - message received: ") + message.toString());
owner.appendMessage ("Connection #" + String (ourNumber) + " - message received: " + message.toString());
} }
}; };


+ 39
- 49
juce_amalgamated.cpp View File

@@ -84392,10 +84392,10 @@ BEGIN_JUCE_NAMESPACE
DrawableComposite::DrawableComposite() DrawableComposite::DrawableComposite()
: bounds (Point<float>(), Point<float> (100.0f, 0.0f), Point<float> (0.0f, 100.0f)) : bounds (Point<float>(), Point<float> (100.0f, 0.0f), Point<float> (0.0f, 100.0f))
{ {
setContentArea (RelativeRectangle (RelativeCoordinate (0.0, true),
RelativeCoordinate (100.0, true),
RelativeCoordinate (0.0, false),
RelativeCoordinate (100.0, false)));
setContentArea (RelativeRectangle (RelativeCoordinate (0.0),
RelativeCoordinate (100.0),
RelativeCoordinate (0.0),
RelativeCoordinate (100.0)));
} }


DrawableComposite::DrawableComposite (const DrawableComposite& other) DrawableComposite::DrawableComposite (const DrawableComposite& other)
@@ -84504,10 +84504,10 @@ void DrawableComposite::resetContentAreaAndBoundingBoxToFitChildren()
{ {
const Rectangle<float> bounds (getUntransformedBounds (false)); const Rectangle<float> bounds (getUntransformedBounds (false));


setContentArea (RelativeRectangle (RelativeCoordinate (bounds.getX(), true),
RelativeCoordinate (bounds.getRight(), true),
RelativeCoordinate (bounds.getY(), false),
RelativeCoordinate (bounds.getBottom(), false)));
setContentArea (RelativeRectangle (RelativeCoordinate (bounds.getX()),
RelativeCoordinate (bounds.getRight()),
RelativeCoordinate (bounds.getY()),
RelativeCoordinate (bounds.getBottom())));
resetBoundingBoxToContentArea(); resetBoundingBoxToContentArea();
} }


@@ -84601,16 +84601,10 @@ const RelativeCoordinate DrawableComposite::findNamedCoordinate (const String& o
{ {
if (objectName == RelativeCoordinate::Strings::parent) if (objectName == RelativeCoordinate::Strings::parent)
{ {
if (edge == RelativeCoordinate::Strings::right)
if (edge == RelativeCoordinate::Strings::right || edge == RelativeCoordinate::Strings::bottom)
{ {
jassertfalse; // a Drawable doesn't have a fixed right-hand edge - use a marker instead if you need a point of reference.
return RelativeCoordinate (100.0, true);
}

if (edge == RelativeCoordinate::Strings::bottom)
{
jassertfalse; // a Drawable doesn't have a fixed bottom edge - use a marker instead if you need a point of reference.
return RelativeCoordinate (100.0, false);
jassertfalse; // a Drawable doesn't have a fixed right-hand or bottom edge - use a marker instead if you need a point of reference.
return RelativeCoordinate (100.0);
} }
} }


@@ -84650,7 +84644,7 @@ const Rectangle<float> DrawableComposite::getUntransformedBounds (const bool inc
for (i = markersX.size(); --i >= 0;) for (i = markersX.size(); --i >= 0;)
{ {
const Marker* m = markersX.getUnchecked(i); const Marker* m = markersX.getUnchecked(i);
const float pos = (float) m->position.resolve (parent);
const float pos = (float) m->position.resolve (this);
minX = jmin (minX, pos); minX = jmin (minX, pos);
maxX = jmax (maxX, pos); maxX = jmax (maxX, pos);
} }
@@ -84676,7 +84670,7 @@ const Rectangle<float> DrawableComposite::getUntransformedBounds (const bool inc
for (i = markersY.size(); --i >= 0;) for (i = markersY.size(); --i >= 0;)
{ {
const Marker* m = markersY.getUnchecked(i); const Marker* m = markersY.getUnchecked(i);
const float pos = (float) m->position.resolve (parent);
const float pos = (float) m->position.resolve (this);
minY = jmin (minY, pos); minY = jmin (minY, pos);
maxY = jmax (maxY, pos); maxY = jmax (maxY, pos);
} }
@@ -92958,12 +92952,6 @@ namespace RelativeCoordinateHelpers
|| name == RelativeCoordinate::Strings::parentTop; || name == RelativeCoordinate::Strings::parentTop;
} }


static const String getOriginAnchorName (const bool isHorizontal) throw()
{
return isHorizontal ? RelativeCoordinate::Strings::parentLeft
: RelativeCoordinate::Strings::parentTop;
}

static const String getExtentAnchorName (const bool isHorizontal) throw() static const String getExtentAnchorName (const bool isHorizontal) throw()
{ {
return isHorizontal ? RelativeCoordinate::Strings::parentRight return isHorizontal ? RelativeCoordinate::Strings::parentRight
@@ -93082,9 +93070,6 @@ namespace RelativeCoordinateHelpers
{ {
anchor1 = readAnchorName (s, ++i); anchor1 = readAnchorName (s, ++i);


if (anchor1.isEmpty())
anchor1 = getOriginAnchorName (isHorizontal);

skipWhitespace (s, i); skipWhitespace (s, i);


if (s[i] == '-' && s[i + 1] == '>') if (s[i] == '-' && s[i + 1] == '>')
@@ -93095,19 +93080,19 @@ namespace RelativeCoordinateHelpers
else else
{ {
anchor2 = anchor1; anchor2 = anchor1;
anchor1 = getOriginAnchorName (isHorizontal);
anchor1 = String::empty;
} }
} }
else else
{ {
anchor1 = getOriginAnchorName (isHorizontal);
anchor1 = String::empty;
anchor2 = getExtentAnchorName (isHorizontal); anchor2 = getExtentAnchorName (isHorizontal);
} }


return RelativeCoordinate (value, anchor1, anchor2); return RelativeCoordinate (value, anchor1, anchor2);
} }


return RelativeCoordinate (value, isHorizontal);
return RelativeCoordinate (value);
} }
} }


@@ -93135,9 +93120,8 @@ RelativeCoordinate::RelativeCoordinate()
{ {
} }


RelativeCoordinate::RelativeCoordinate (const double absoluteDistanceFromOrigin, const bool horizontal_)
: anchor1 (RelativeCoordinateHelpers::getOriginAnchorName (horizontal_)),
value (absoluteDistanceFromOrigin)
RelativeCoordinate::RelativeCoordinate (const double absoluteDistanceFromOrigin)
: value (absoluteDistanceFromOrigin)
{ {
} }


@@ -93145,7 +93129,6 @@ RelativeCoordinate::RelativeCoordinate (const double absoluteDistance, const Str
: anchor1 (source.trim()), : anchor1 (source.trim()),
value (absoluteDistance) value (absoluteDistance)
{ {
jassert (anchor1.isNotEmpty());
} }


RelativeCoordinate::RelativeCoordinate (const double relativeProportion, const String& pos1, const String& pos2) RelativeCoordinate::RelativeCoordinate (const double relativeProportion, const String& pos1, const String& pos2)
@@ -93153,8 +93136,6 @@ RelativeCoordinate::RelativeCoordinate (const double relativeProportion, const S
anchor2 (pos2.trim()), anchor2 (pos2.trim()),
value (relativeProportion) value (relativeProportion)
{ {
jassert (anchor1.isNotEmpty());
jassert (anchor2.isNotEmpty());
} }


RelativeCoordinate::RelativeCoordinate (const String& s, const bool isHorizontal) RelativeCoordinate::RelativeCoordinate (const String& s, const bool isHorizontal)
@@ -93258,13 +93239,13 @@ void RelativeCoordinate::moveToAbsolute (double newPos, const NamedCoordinateFin
{} {}
} }


void RelativeCoordinate::toggleProportionality (const NamedCoordinateFinder* nameFinder, bool isHorizontal)
void RelativeCoordinate::toggleProportionality (const NamedCoordinateFinder* nameFinder,
const String& proportionalAnchor1, const String& proportionalAnchor2)
{ {
const double oldValue = resolve (nameFinder); const double oldValue = resolve (nameFinder);


anchor1 = RelativeCoordinateHelpers::getOriginAnchorName (isHorizontal);
anchor2 = isProportional() ? String::empty
: RelativeCoordinateHelpers::getExtentAnchorName (isHorizontal);
anchor1 = proportionalAnchor1;
anchor2 = isProportional() ? String::empty : proportionalAnchor2;


moveToAbsolute (oldValue, nameFinder); moveToAbsolute (oldValue, nameFinder);
} }
@@ -93297,7 +93278,7 @@ const String RelativeCoordinate::toString() const


if (isOrigin (anchor1)) if (isOrigin (anchor1))
{ {
if (anchor2 == "parent.right" || anchor2 == "parent.bottom")
if (anchor2 == Strings::parentRight || anchor2 == Strings::parentBottom)
return percent + "%"; return percent + "%";
else else
return percent + "% * " + anchor2; return percent + "% * " + anchor2;
@@ -93328,12 +93309,22 @@ void RelativeCoordinate::setEditableNumber (const double newValue)
value = isProportional() ? newValue / 100.0 : newValue; value = isProportional() ? newValue / 100.0 : newValue;
} }


const String RelativeCoordinate::getAnchorName1 (const String& returnValueIfOrigin) const
{
return RelativeCoordinateHelpers::isOrigin (anchor1) ? returnValueIfOrigin : anchor1;
}

const String RelativeCoordinate::getAnchorName2 (const String& returnValueIfOrigin) const
{
return RelativeCoordinateHelpers::isOrigin (anchor2) ? returnValueIfOrigin : anchor2;
}

void RelativeCoordinate::changeAnchor1 (const String& newAnchorName, const NamedCoordinateFinder* nameFinder) void RelativeCoordinate::changeAnchor1 (const String& newAnchorName, const NamedCoordinateFinder* nameFinder)
{ {
jassert (newAnchorName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_.")); jassert (newAnchorName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_."));


const double oldValue = resolve (nameFinder); const double oldValue = resolve (nameFinder);
anchor1 = newAnchorName;
anchor1 = RelativeCoordinateHelpers::isOrigin (newAnchorName) ? String::empty : newAnchorName;
moveToAbsolute (oldValue, nameFinder); moveToAbsolute (oldValue, nameFinder);
} }


@@ -93343,7 +93334,7 @@ void RelativeCoordinate::changeAnchor2 (const String& newAnchorName, const Named
jassert (newAnchorName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_.")); jassert (newAnchorName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_."));


const double oldValue = resolve (nameFinder); const double oldValue = resolve (nameFinder);
anchor2 = newAnchorName;
anchor2 = RelativeCoordinateHelpers::isOrigin (newAnchorName) ? String::empty : newAnchorName;
moveToAbsolute (oldValue, nameFinder); moveToAbsolute (oldValue, nameFinder);
} }


@@ -93374,17 +93365,16 @@ void RelativeCoordinate::renameAnchorIfUsed (const String& oldName, const String
} }


RelativePoint::RelativePoint() RelativePoint::RelativePoint()
: x (0, true), y (0, false)
{ {
} }


RelativePoint::RelativePoint (const Point<float>& absolutePoint) RelativePoint::RelativePoint (const Point<float>& absolutePoint)
: x (absolutePoint.getX(), true), y (absolutePoint.getY(), false)
: x (absolutePoint.getX()), y (absolutePoint.getY())
{ {
} }


RelativePoint::RelativePoint (const float x_, const float y_) RelativePoint::RelativePoint (const float x_, const float y_)
: x (x_, true), y (y_, false)
: x (x_), y (y_)
{ {
} }


@@ -93450,9 +93440,9 @@ RelativeRectangle::RelativeRectangle (const RelativeCoordinate& left_, const Rel
} }


RelativeRectangle::RelativeRectangle (const Rectangle<float>& rect, const String& componentName) RelativeRectangle::RelativeRectangle (const Rectangle<float>& rect, const String& componentName)
: left (rect.getX(), true),
: left (rect.getX()),
right (rect.getWidth(), componentName + "." + RelativeCoordinate::Strings::left), right (rect.getWidth(), componentName + "." + RelativeCoordinate::Strings::left),
top (rect.getY(), false),
top (rect.getY()),
bottom (rect.getHeight(), componentName + "." + RelativeCoordinate::Strings::top) bottom (rect.getHeight(), componentName + "." + RelativeCoordinate::Strings::top)
{ {
} }


+ 6
- 5
juce_amalgamated.h View File

@@ -64,7 +64,7 @@
*/ */
#define JUCE_MAJOR_VERSION 1 #define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 52 #define JUCE_MINOR_VERSION 52
#define JUCE_BUILDNUMBER 25
#define JUCE_BUILDNUMBER 26


/** Current Juce version number. /** Current Juce version number.


@@ -42641,7 +42641,7 @@ public:
@param absoluteDistanceFromOrigin the distance from the origin @param absoluteDistanceFromOrigin the distance from the origin
@param isHorizontal this must be true if this is an X coordinate, or false if it's on the Y axis. @param isHorizontal this must be true if this is an X coordinate, or false if it's on the Y axis.
*/ */
RelativeCoordinate (double absoluteDistanceFromOrigin, bool isHorizontal);
RelativeCoordinate (double absoluteDistanceFromOrigin);


/** Creates an absolute position relative to a named coordinate. /** Creates an absolute position relative to a named coordinate.


@@ -42755,7 +42755,8 @@ public:
Note that calling this will reset the names of any anchor points, and just make the Note that calling this will reset the names of any anchor points, and just make the
coordinate relative to the parent origin and parent size. coordinate relative to the parent origin and parent size.
*/ */
void toggleProportionality (const NamedCoordinateFinder* nameFinder, bool isHorizontal);
void toggleProportionality (const NamedCoordinateFinder* nameFinder,
const String& proportionalAnchor1, const String& proportionalAnchor2);


/** Returns a value that can be edited to set this coordinate's position. /** Returns a value that can be edited to set this coordinate's position.
The meaning of this number depends on the coordinate's mode. If the coordinate is The meaning of this number depends on the coordinate's mode. If the coordinate is
@@ -42775,12 +42776,12 @@ public:


/** Returns the name of the first anchor point from which this coordinate is relative. /** Returns the name of the first anchor point from which this coordinate is relative.
*/ */
const String getAnchorName1() const { return anchor1; }
const String getAnchorName1 (const String& returnValueIfOrigin) const;


/** Returns the name of the second anchor point from which this coordinate is relative. /** Returns the name of the second anchor point from which this coordinate is relative.
The second anchor is only valid if the coordinate is in proportional mode. The second anchor is only valid if the coordinate is in proportional mode.
*/ */
const String getAnchorName2() const { return anchor2; }
const String getAnchorName2 (const String& returnValueIfOrigin) const;


/** Returns the first anchor point as a coordinate. */ /** Returns the first anchor point as a coordinate. */
const RelativeCoordinate getAnchorCoordinate1() const; const RelativeCoordinate getAnchorCoordinate1() const;


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

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


+ 13
- 19
src/gui/graphics/drawables/juce_DrawableComposite.cpp View File

@@ -38,10 +38,10 @@ BEGIN_JUCE_NAMESPACE
DrawableComposite::DrawableComposite() DrawableComposite::DrawableComposite()
: bounds (Point<float>(), Point<float> (100.0f, 0.0f), Point<float> (0.0f, 100.0f)) : bounds (Point<float>(), Point<float> (100.0f, 0.0f), Point<float> (0.0f, 100.0f))
{ {
setContentArea (RelativeRectangle (RelativeCoordinate (0.0, true),
RelativeCoordinate (100.0, true),
RelativeCoordinate (0.0, false),
RelativeCoordinate (100.0, false)));
setContentArea (RelativeRectangle (RelativeCoordinate (0.0),
RelativeCoordinate (100.0),
RelativeCoordinate (0.0),
RelativeCoordinate (100.0)));
} }
DrawableComposite::DrawableComposite (const DrawableComposite& other) DrawableComposite::DrawableComposite (const DrawableComposite& other)
@@ -153,10 +153,10 @@ void DrawableComposite::resetContentAreaAndBoundingBoxToFitChildren()
{ {
const Rectangle<float> bounds (getUntransformedBounds (false)); const Rectangle<float> bounds (getUntransformedBounds (false));
setContentArea (RelativeRectangle (RelativeCoordinate (bounds.getX(), true),
RelativeCoordinate (bounds.getRight(), true),
RelativeCoordinate (bounds.getY(), false),
RelativeCoordinate (bounds.getBottom(), false)));
setContentArea (RelativeRectangle (RelativeCoordinate (bounds.getX()),
RelativeCoordinate (bounds.getRight()),
RelativeCoordinate (bounds.getY()),
RelativeCoordinate (bounds.getBottom())));
resetBoundingBoxToContentArea(); resetBoundingBoxToContentArea();
} }
@@ -251,16 +251,10 @@ const RelativeCoordinate DrawableComposite::findNamedCoordinate (const String& o
{ {
if (objectName == RelativeCoordinate::Strings::parent) if (objectName == RelativeCoordinate::Strings::parent)
{ {
if (edge == RelativeCoordinate::Strings::right)
if (edge == RelativeCoordinate::Strings::right || edge == RelativeCoordinate::Strings::bottom)
{ {
jassertfalse; // a Drawable doesn't have a fixed right-hand edge - use a marker instead if you need a point of reference.
return RelativeCoordinate (100.0, true);
}
if (edge == RelativeCoordinate::Strings::bottom)
{
jassertfalse; // a Drawable doesn't have a fixed bottom edge - use a marker instead if you need a point of reference.
return RelativeCoordinate (100.0, false);
jassertfalse; // a Drawable doesn't have a fixed right-hand or bottom edge - use a marker instead if you need a point of reference.
return RelativeCoordinate (100.0);
} }
} }
@@ -300,7 +294,7 @@ const Rectangle<float> DrawableComposite::getUntransformedBounds (const bool inc
for (i = markersX.size(); --i >= 0;) for (i = markersX.size(); --i >= 0;)
{ {
const Marker* m = markersX.getUnchecked(i); const Marker* m = markersX.getUnchecked(i);
const float pos = (float) m->position.resolve (parent);
const float pos = (float) m->position.resolve (this);
minX = jmin (minX, pos); minX = jmin (minX, pos);
maxX = jmax (maxX, pos); maxX = jmax (maxX, pos);
} }
@@ -326,7 +320,7 @@ const Rectangle<float> DrawableComposite::getUntransformedBounds (const bool inc
for (i = markersY.size(); --i >= 0;) for (i = markersY.size(); --i >= 0;)
{ {
const Marker* m = markersY.getUnchecked(i); const Marker* m = markersY.getUnchecked(i);
const float pos = (float) m->position.resolve (parent);
const float pos = (float) m->position.resolve (this);
minY = jmin (minY, pos); minY = jmin (minY, pos);
maxY = jmax (maxY, pos); maxY = jmax (maxY, pos);
} }


+ 26
- 30
src/gui/graphics/geometry/juce_RelativeCoordinate.cpp View File

@@ -42,12 +42,6 @@ namespace RelativeCoordinateHelpers
|| name == RelativeCoordinate::Strings::parentTop; || name == RelativeCoordinate::Strings::parentTop;
} }
static const String getOriginAnchorName (const bool isHorizontal) throw()
{
return isHorizontal ? RelativeCoordinate::Strings::parentLeft
: RelativeCoordinate::Strings::parentTop;
}
static const String getExtentAnchorName (const bool isHorizontal) throw() static const String getExtentAnchorName (const bool isHorizontal) throw()
{ {
return isHorizontal ? RelativeCoordinate::Strings::parentRight return isHorizontal ? RelativeCoordinate::Strings::parentRight
@@ -168,9 +162,6 @@ namespace RelativeCoordinateHelpers
{ {
anchor1 = readAnchorName (s, ++i); anchor1 = readAnchorName (s, ++i);
if (anchor1.isEmpty())
anchor1 = getOriginAnchorName (isHorizontal);
skipWhitespace (s, i); skipWhitespace (s, i);
if (s[i] == '-' && s[i + 1] == '>') if (s[i] == '-' && s[i + 1] == '>')
@@ -181,19 +172,19 @@ namespace RelativeCoordinateHelpers
else else
{ {
anchor2 = anchor1; anchor2 = anchor1;
anchor1 = getOriginAnchorName (isHorizontal);
anchor1 = String::empty;
} }
} }
else else
{ {
anchor1 = getOriginAnchorName (isHorizontal);
anchor1 = String::empty;
anchor2 = getExtentAnchorName (isHorizontal); anchor2 = getExtentAnchorName (isHorizontal);
} }
return RelativeCoordinate (value, anchor1, anchor2); return RelativeCoordinate (value, anchor1, anchor2);
} }
return RelativeCoordinate (value, isHorizontal);
return RelativeCoordinate (value);
} }
} }
@@ -223,9 +214,8 @@ RelativeCoordinate::RelativeCoordinate()
{ {
} }
RelativeCoordinate::RelativeCoordinate (const double absoluteDistanceFromOrigin, const bool horizontal_)
: anchor1 (RelativeCoordinateHelpers::getOriginAnchorName (horizontal_)),
value (absoluteDistanceFromOrigin)
RelativeCoordinate::RelativeCoordinate (const double absoluteDistanceFromOrigin)
: value (absoluteDistanceFromOrigin)
{ {
} }
@@ -233,7 +223,6 @@ RelativeCoordinate::RelativeCoordinate (const double absoluteDistance, const Str
: anchor1 (source.trim()), : anchor1 (source.trim()),
value (absoluteDistance) value (absoluteDistance)
{ {
jassert (anchor1.isNotEmpty());
} }
RelativeCoordinate::RelativeCoordinate (const double relativeProportion, const String& pos1, const String& pos2) RelativeCoordinate::RelativeCoordinate (const double relativeProportion, const String& pos1, const String& pos2)
@@ -241,8 +230,6 @@ RelativeCoordinate::RelativeCoordinate (const double relativeProportion, const S
anchor2 (pos2.trim()), anchor2 (pos2.trim()),
value (relativeProportion) value (relativeProportion)
{ {
jassert (anchor1.isNotEmpty());
jassert (anchor2.isNotEmpty());
} }
RelativeCoordinate::RelativeCoordinate (const String& s, const bool isHorizontal) RelativeCoordinate::RelativeCoordinate (const String& s, const bool isHorizontal)
@@ -347,13 +334,13 @@ void RelativeCoordinate::moveToAbsolute (double newPos, const NamedCoordinateFin
{} {}
} }
void RelativeCoordinate::toggleProportionality (const NamedCoordinateFinder* nameFinder, bool isHorizontal)
void RelativeCoordinate::toggleProportionality (const NamedCoordinateFinder* nameFinder,
const String& proportionalAnchor1, const String& proportionalAnchor2)
{ {
const double oldValue = resolve (nameFinder); const double oldValue = resolve (nameFinder);
anchor1 = RelativeCoordinateHelpers::getOriginAnchorName (isHorizontal);
anchor2 = isProportional() ? String::empty
: RelativeCoordinateHelpers::getExtentAnchorName (isHorizontal);
anchor1 = proportionalAnchor1;
anchor2 = isProportional() ? String::empty : proportionalAnchor2;
moveToAbsolute (oldValue, nameFinder); moveToAbsolute (oldValue, nameFinder);
} }
@@ -387,7 +374,7 @@ const String RelativeCoordinate::toString() const
if (isOrigin (anchor1)) if (isOrigin (anchor1))
{ {
if (anchor2 == "parent.right" || anchor2 == "parent.bottom")
if (anchor2 == Strings::parentRight || anchor2 == Strings::parentBottom)
return percent + "%"; return percent + "%";
else else
return percent + "% * " + anchor2; return percent + "% * " + anchor2;
@@ -420,12 +407,22 @@ void RelativeCoordinate::setEditableNumber (const double newValue)
} }
//============================================================================== //==============================================================================
const String RelativeCoordinate::getAnchorName1 (const String& returnValueIfOrigin) const
{
return RelativeCoordinateHelpers::isOrigin (anchor1) ? returnValueIfOrigin : anchor1;
}
const String RelativeCoordinate::getAnchorName2 (const String& returnValueIfOrigin) const
{
return RelativeCoordinateHelpers::isOrigin (anchor2) ? returnValueIfOrigin : anchor2;
}
void RelativeCoordinate::changeAnchor1 (const String& newAnchorName, const NamedCoordinateFinder* nameFinder) void RelativeCoordinate::changeAnchor1 (const String& newAnchorName, const NamedCoordinateFinder* nameFinder)
{ {
jassert (newAnchorName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_.")); jassert (newAnchorName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_."));
const double oldValue = resolve (nameFinder); const double oldValue = resolve (nameFinder);
anchor1 = newAnchorName;
anchor1 = RelativeCoordinateHelpers::isOrigin (newAnchorName) ? String::empty : newAnchorName;
moveToAbsolute (oldValue, nameFinder); moveToAbsolute (oldValue, nameFinder);
} }
@@ -435,7 +432,7 @@ void RelativeCoordinate::changeAnchor2 (const String& newAnchorName, const Named
jassert (newAnchorName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_.")); jassert (newAnchorName.toLowerCase().containsOnly ("abcdefghijklmnopqrstuvwxyz0123456789_."));
const double oldValue = resolve (nameFinder); const double oldValue = resolve (nameFinder);
anchor2 = newAnchorName;
anchor2 = RelativeCoordinateHelpers::isOrigin (newAnchorName) ? String::empty : newAnchorName;
moveToAbsolute (oldValue, nameFinder); moveToAbsolute (oldValue, nameFinder);
} }
@@ -467,17 +464,16 @@ void RelativeCoordinate::renameAnchorIfUsed (const String& oldName, const String
//============================================================================== //==============================================================================
RelativePoint::RelativePoint() RelativePoint::RelativePoint()
: x (0, true), y (0, false)
{ {
} }
RelativePoint::RelativePoint (const Point<float>& absolutePoint) RelativePoint::RelativePoint (const Point<float>& absolutePoint)
: x (absolutePoint.getX(), true), y (absolutePoint.getY(), false)
: x (absolutePoint.getX()), y (absolutePoint.getY())
{ {
} }
RelativePoint::RelativePoint (const float x_, const float y_) RelativePoint::RelativePoint (const float x_, const float y_)
: x (x_, true), y (y_, false)
: x (x_), y (y_)
{ {
} }
@@ -545,9 +541,9 @@ RelativeRectangle::RelativeRectangle (const RelativeCoordinate& left_, const Rel
} }
RelativeRectangle::RelativeRectangle (const Rectangle<float>& rect, const String& componentName) RelativeRectangle::RelativeRectangle (const Rectangle<float>& rect, const String& componentName)
: left (rect.getX(), true),
: left (rect.getX()),
right (rect.getWidth(), componentName + "." + RelativeCoordinate::Strings::left), right (rect.getWidth(), componentName + "." + RelativeCoordinate::Strings::left),
top (rect.getY(), false),
top (rect.getY()),
bottom (rect.getHeight(), componentName + "." + RelativeCoordinate::Strings::top) bottom (rect.getHeight(), componentName + "." + RelativeCoordinate::Strings::top)
{ {
} }


+ 5
- 4
src/gui/graphics/geometry/juce_RelativeCoordinate.h View File

@@ -64,7 +64,7 @@ public:
@param absoluteDistanceFromOrigin the distance from the origin @param absoluteDistanceFromOrigin the distance from the origin
@param isHorizontal this must be true if this is an X coordinate, or false if it's on the Y axis. @param isHorizontal this must be true if this is an X coordinate, or false if it's on the Y axis.
*/ */
RelativeCoordinate (double absoluteDistanceFromOrigin, bool isHorizontal);
RelativeCoordinate (double absoluteDistanceFromOrigin);
/** Creates an absolute position relative to a named coordinate. /** Creates an absolute position relative to a named coordinate.
@@ -182,7 +182,8 @@ public:
Note that calling this will reset the names of any anchor points, and just make the Note that calling this will reset the names of any anchor points, and just make the
coordinate relative to the parent origin and parent size. coordinate relative to the parent origin and parent size.
*/ */
void toggleProportionality (const NamedCoordinateFinder* nameFinder, bool isHorizontal);
void toggleProportionality (const NamedCoordinateFinder* nameFinder,
const String& proportionalAnchor1, const String& proportionalAnchor2);
/** Returns a value that can be edited to set this coordinate's position. /** Returns a value that can be edited to set this coordinate's position.
The meaning of this number depends on the coordinate's mode. If the coordinate is The meaning of this number depends on the coordinate's mode. If the coordinate is
@@ -203,12 +204,12 @@ public:
//============================================================================== //==============================================================================
/** Returns the name of the first anchor point from which this coordinate is relative. /** Returns the name of the first anchor point from which this coordinate is relative.
*/ */
const String getAnchorName1() const { return anchor1; }
const String getAnchorName1 (const String& returnValueIfOrigin) const;
/** Returns the name of the second anchor point from which this coordinate is relative. /** Returns the name of the second anchor point from which this coordinate is relative.
The second anchor is only valid if the coordinate is in proportional mode. The second anchor is only valid if the coordinate is in proportional mode.
*/ */
const String getAnchorName2() const { return anchor2; }
const String getAnchorName2 (const String& returnValueIfOrigin) const;
/** Returns the first anchor point as a coordinate. */ /** Returns the first anchor point as a coordinate. */
const RelativeCoordinate getAnchorCoordinate1() const; const RelativeCoordinate getAnchorCoordinate1() const;


Loading…
Cancel
Save