| @@ -90,7 +90,7 @@ StandaloneFilterWindow::StandaloneFilterWindow (const String& title, | |||
| const int y = globalSettings->getIntValue (T("windowY"), -100); | |||
| if (x != -100 && y != -100) | |||
| setBoundsConstrained (x, y, getWidth(), getHeight()); | |||
| setBoundsConstrained (Rectangle<int> (x, y, getWidth(), getHeight())); | |||
| else | |||
| centreWithSize (getWidth(), getHeight()); | |||
| } | |||
| @@ -336,7 +336,7 @@ void PaintElement::resizeEnd() | |||
| { | |||
| } | |||
| void PaintElement::checkBounds (int& x, int& y, int& w, int& h, | |||
| void PaintElement::checkBounds (Rectangle<int>& bounds, | |||
| const Rectangle<int>& previousBounds, | |||
| const Rectangle<int>& limits, | |||
| const bool isStretchingTop, | |||
| @@ -349,7 +349,7 @@ void PaintElement::checkBounds (int& x, int& y, int& w, int& h, | |||
| else | |||
| setFixedAspectRatio (0.0); | |||
| ComponentBoundsConstrainer::checkBounds (x, y, w, h, previousBounds, limits, isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight); | |||
| ComponentBoundsConstrainer::checkBounds (bounds, previousBounds, limits, isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight); | |||
| JucerDocument* document = getDocument(); | |||
| @@ -358,6 +358,11 @@ void PaintElement::checkBounds (int& x, int& y, int& w, int& h, | |||
| jassert (getParentComponent() != 0); | |||
| const Rectangle<int> area (((PaintRoutineEditor*) getParentComponent())->getComponentArea()); | |||
| int x = bounds.getX(); | |||
| int y = bounds.getY(); | |||
| int w = bounds.getWidth(); | |||
| int h = bounds.getHeight(); | |||
| x += borderThickness - area.getX(); | |||
| y += borderThickness - area.getY(); | |||
| w -= borderThickness * 2; | |||
| @@ -382,19 +387,20 @@ void PaintElement::checkBounds (int& x, int& y, int& w, int& h, | |||
| h = (bottom - y) + borderThickness * 2; | |||
| x -= borderThickness - area.getX(); | |||
| y -= borderThickness - area.getY(); | |||
| bounds = Rectangle<int> (x, y, w, h); | |||
| } | |||
| } | |||
| void PaintElement::applyBoundsToComponent (Component* component, int x, int y, int w, int h) | |||
| void PaintElement::applyBoundsToComponent (Component* component, const Rectangle<int>& bounds) | |||
| { | |||
| if (getBounds() != Rectangle<int> (x, y, w, h)) | |||
| if (getBounds() != bounds) | |||
| { | |||
| getDocument()->getUndoManager().undoCurrentTransactionOnly(); | |||
| jassert (dynamic_cast <PaintRoutineEditor*> (getParentComponent()) != 0); | |||
| setCurrentBounds (Rectangle<int> (x, y, w, h) | |||
| .expanded (-borderThickness, -borderThickness), | |||
| setCurrentBounds (bounds.expanded (-borderThickness, -borderThickness), | |||
| ((PaintRoutineEditor*) getParentComponent())->getComponentArea(), | |||
| true); | |||
| } | |||
| @@ -102,7 +102,7 @@ protected: | |||
| void resizeStart(); | |||
| void resizeEnd(); | |||
| void checkBounds (int& x, int& y, int& w, int& h, | |||
| void checkBounds (Rectangle<int>& bounds, | |||
| const Rectangle<int>& previousBounds, | |||
| const Rectangle<int>& limits, | |||
| const bool isStretchingTop, | |||
| @@ -110,7 +110,7 @@ protected: | |||
| const bool isStretchingBottom, | |||
| const bool isStretchingRight); | |||
| void applyBoundsToComponent (Component* component, int x, int y, int w, int h); | |||
| void applyBoundsToComponent (Component* component, const Rectangle<int>& bounds); | |||
| const Rectangle<int> getCurrentAbsoluteBounds() const; | |||
| void getCurrentAbsoluteBoundsDouble (double& x, double& y, double& w, double& h) const; | |||
| @@ -179,7 +179,7 @@ void ComponentOverlayComponent::resizeEnd() | |||
| layout.getDocument()->getUndoManager().beginNewTransaction(); | |||
| } | |||
| void ComponentOverlayComponent::checkBounds (int& x, int& y, int& w, int& h, | |||
| void ComponentOverlayComponent::checkBounds (Rectangle<int>& bounds, | |||
| const Rectangle<int>& previousBounds, | |||
| const Rectangle<int>& limits, | |||
| const bool isStretchingTop, | |||
| @@ -192,7 +192,7 @@ void ComponentOverlayComponent::checkBounds (int& x, int& y, int& w, int& h, | |||
| else | |||
| setFixedAspectRatio (0.0); | |||
| ComponentBoundsConstrainer::checkBounds (x, y, w, h, previousBounds, limits, isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight); | |||
| ComponentBoundsConstrainer::checkBounds (bounds, previousBounds, limits, isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight); | |||
| if (layout.getDocument()->isSnapActive (true)) | |||
| { | |||
| @@ -204,6 +204,11 @@ void ComponentOverlayComponent::checkBounds (int& x, int& y, int& w, int& h, | |||
| const int dx = parent->getX(); | |||
| const int dy = parent->getY(); | |||
| int x = bounds.getX(); | |||
| int y = bounds.getY(); | |||
| int w = bounds.getWidth(); | |||
| int h = bounds.getHeight(); | |||
| x += borderThickness - dx; | |||
| y += borderThickness - dy; | |||
| w -= borderThickness * 2; | |||
| @@ -228,27 +233,29 @@ void ComponentOverlayComponent::checkBounds (int& x, int& y, int& w, int& h, | |||
| h = (bottom - y) + borderThickness * 2; | |||
| x -= borderThickness - dx; | |||
| y -= borderThickness - dy; | |||
| bounds = Rectangle<int> (x, y, w, h); | |||
| } | |||
| } | |||
| } | |||
| void ComponentOverlayComponent::applyBoundsToComponent (Component* component, int x, int y, int w, int h) | |||
| void ComponentOverlayComponent::applyBoundsToComponent (Component* component, const Rectangle<int>& bounds) | |||
| { | |||
| if (component->getBounds() != Rectangle<int> (x, y, w, h)) | |||
| if (component->getBounds() != bounds) | |||
| { | |||
| layout.getDocument()->getUndoManager().undoCurrentTransactionOnly(); | |||
| component->setBounds (x, y, w, h); | |||
| component->setBounds (bounds); | |||
| Component* const parent = target->getParentComponent(); | |||
| jassert (parent != 0); | |||
| if (parent != 0) | |||
| { | |||
| target->setBounds (x + borderThickness - parent->getX(), | |||
| y + borderThickness - parent->getY(), | |||
| w - borderThickness * 2, | |||
| h - borderThickness * 2); | |||
| target->setBounds (bounds.getX() + borderThickness - parent->getX(), | |||
| bounds.getY() + borderThickness - parent->getY(), | |||
| bounds.getWidth() - borderThickness * 2, | |||
| bounds.getHeight() - borderThickness * 2); | |||
| } | |||
| layout.updateStoredComponentPosition (target, true); | |||
| @@ -64,7 +64,7 @@ public: | |||
| void updateBoundsToMatchTarget(); | |||
| void checkBounds (int& x, int& y, int& w, int& h, | |||
| void checkBounds (Rectangle<int>& bounds, | |||
| const Rectangle<int>& previousBounds, | |||
| const Rectangle<int>& limits, | |||
| const bool isStretchingTop, | |||
| @@ -72,7 +72,7 @@ public: | |||
| const bool isStretchingBottom, | |||
| const bool isStretchingRight); | |||
| void applyBoundsToComponent (Component* component, int x, int y, int w, int h); | |||
| void applyBoundsToComponent (Component* component, const Rectangle<int>& bounds); | |||
| //============================================================================== | |||
| Component* const target; | |||
| @@ -60780,7 +60780,7 @@ double ComponentBoundsConstrainer::getFixedAspectRatio() const throw() | |||
| } | |||
| void ComponentBoundsConstrainer::setBoundsForComponent (Component* const component, | |||
| int x, int y, int w, int h, | |||
| const Rectangle<int>& targetBounds, | |||
| const bool isStretchingTop, | |||
| const bool isStretchingLeft, | |||
| const bool isStretchingBottom, | |||
| @@ -60788,57 +60788,47 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* const compone | |||
| { | |||
| jassert (component != 0); | |||
| Rectangle<int> limits; | |||
| Component* const p = component->getParentComponent(); | |||
| Rectangle<int> limits, bounds (targetBounds); | |||
| BorderSize border; | |||
| if (p == 0) | |||
| limits = Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(); | |||
| else | |||
| limits.setSize (p->getWidth(), p->getHeight()); | |||
| Component* const parent = component->getParentComponent(); | |||
| if (component->isOnDesktop()) | |||
| if (parent == 0) | |||
| { | |||
| ComponentPeer* const peer = component->getPeer(); | |||
| const BorderSize border (peer->getFrameSize()); | |||
| x -= border.getLeft(); | |||
| y -= border.getTop(); | |||
| w += border.getLeftAndRight(); | |||
| h += border.getTopAndBottom(); | |||
| checkBounds (x, y, w, h, | |||
| border.addedTo (component->getBounds()), limits, | |||
| isStretchingTop, isStretchingLeft, | |||
| isStretchingBottom, isStretchingRight); | |||
| ComponentPeer* peer = component->getPeer(); | |||
| if (peer != 0) | |||
| border = peer->getFrameSize(); | |||
| x += border.getLeft(); | |||
| y += border.getTop(); | |||
| w -= border.getLeftAndRight(); | |||
| h -= border.getTopAndBottom(); | |||
| limits = Desktop::getInstance().getMonitorAreaContaining (bounds.getCentreX(), | |||
| bounds.getCentreY()); | |||
| } | |||
| else | |||
| { | |||
| checkBounds (x, y, w, h, | |||
| component->getBounds(), limits, | |||
| isStretchingTop, isStretchingLeft, | |||
| isStretchingBottom, isStretchingRight); | |||
| limits.setSize (parent->getWidth(), parent->getHeight()); | |||
| } | |||
| applyBoundsToComponent (component, x, y, w, h); | |||
| border.addTo (bounds); | |||
| checkBounds (bounds, | |||
| border.addedTo (component->getBounds()), limits, | |||
| isStretchingTop, isStretchingLeft, | |||
| isStretchingBottom, isStretchingRight); | |||
| border.subtractFrom (bounds); | |||
| applyBoundsToComponent (component, bounds); | |||
| } | |||
| void ComponentBoundsConstrainer::checkComponentBounds (Component* component) | |||
| { | |||
| setBoundsForComponent (component, | |||
| component->getX(), component->getY(), | |||
| component->getWidth(), component->getHeight(), | |||
| setBoundsForComponent (component, component->getBounds(), | |||
| false, false, false, false); | |||
| } | |||
| void ComponentBoundsConstrainer::applyBoundsToComponent (Component* component, | |||
| int x, int y, int w, int h) | |||
| const Rectangle<int>& bounds) | |||
| { | |||
| component->setBounds (x, y, w, h); | |||
| component->setBounds (bounds); | |||
| } | |||
| void ComponentBoundsConstrainer::resizeStart() | |||
| @@ -60849,7 +60839,7 @@ void ComponentBoundsConstrainer::resizeEnd() | |||
| { | |||
| } | |||
| void ComponentBoundsConstrainer::checkBounds (int& x, int& y, int& w, int& h, | |||
| void ComponentBoundsConstrainer::checkBounds (Rectangle<int>& bounds, | |||
| const Rectangle<int>& old, | |||
| const Rectangle<int>& limits, | |||
| const bool isStretchingTop, | |||
| @@ -60857,6 +60847,11 @@ void ComponentBoundsConstrainer::checkBounds (int& x, int& y, int& w, int& h, | |||
| const bool isStretchingBottom, | |||
| const bool isStretchingRight) | |||
| { | |||
| int x = bounds.getX(); | |||
| int y = bounds.getY(); | |||
| int w = bounds.getWidth(); | |||
| int h = bounds.getHeight(); | |||
| // constrain the size if it's being stretched.. | |||
| if (isStretchingLeft) | |||
| { | |||
| @@ -60997,7 +60992,7 @@ void ComponentBoundsConstrainer::checkBounds (int& x, int& y, int& w, int& h, | |||
| } | |||
| jassert (w >= 0 && h >= 0); | |||
| bounds = Rectangle<int> (x, y, w, h); | |||
| } | |||
| END_JUCE_NAMESPACE | |||
| @@ -61775,7 +61770,7 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) | |||
| if (constrainer != 0) | |||
| constrainer->setBoundsForComponent (component, | |||
| x, y, w, h, | |||
| Rectangle<int> (x, y, w, h), | |||
| (mouseZone & zoneT) != 0, | |||
| (mouseZone & zoneL) != 0, | |||
| (mouseZone & zoneB) != 0, | |||
| @@ -61945,7 +61940,7 @@ void ResizableCornerComponent::mouseDrag (const MouseEvent& e) | |||
| int h = originalH + e.getDistanceFromDragStartY(); | |||
| if (constrainer != 0) | |||
| constrainer->setBoundsForComponent (component, x, y, w, h, | |||
| constrainer->setBoundsForComponent (component, Rectangle<int> (x, y, w, h), | |||
| false, false, true, true); | |||
| else | |||
| component->setBounds (x, y, w, h); | |||
| @@ -69884,7 +69879,7 @@ void ComponentDragger::dragComponent (Component* const componentToDrag, const Mo | |||
| y += e.getDistanceFromDragStartY(); | |||
| if (constrainer != 0) | |||
| constrainer->setBoundsForComponent (componentToDrag, x, y, w, h, | |||
| constrainer->setBoundsForComponent (componentToDrag, Rectangle<int> (x, y, w, h), | |||
| false, false, false, false); | |||
| else | |||
| componentToDrag->setBounds (x, y, w, h); | |||
| @@ -77538,7 +77533,7 @@ void ResizableWindow::setResizeLimits (const int newMinimumWidth, | |||
| defaultConstrainer.setSizeLimits (newMinimumWidth, newMinimumHeight, | |||
| newMaximumWidth, newMaximumHeight); | |||
| setBoundsConstrained (getX(), getY(), getWidth(), getHeight()); | |||
| setBoundsConstrained (getBounds()); | |||
| } | |||
| void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer) | |||
| @@ -77561,12 +77556,12 @@ void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer | |||
| } | |||
| } | |||
| void ResizableWindow::setBoundsConstrained (int x, int y, int w, int h) | |||
| void ResizableWindow::setBoundsConstrained (const Rectangle<int>& bounds) | |||
| { | |||
| if (constrainer != 0) | |||
| constrainer->setBoundsForComponent (this, x, y, w, h, false, false, false, false); | |||
| constrainer->setBoundsForComponent (this, bounds, false, false, false, false); | |||
| else | |||
| setBounds (x, y, w, h); | |||
| setBounds (bounds); | |||
| } | |||
| void ResizableWindow::paint (Graphics& g) | |||
| @@ -77721,18 +77716,7 @@ void ResizableWindow::parentSizeChanged() | |||
| const String ResizableWindow::getWindowStateAsString() | |||
| { | |||
| updateLastPos(); | |||
| String s; | |||
| if (isFullScreen()) | |||
| s << "fs "; | |||
| s << lastNonFullScreenPos.getX() << T(' ') | |||
| << lastNonFullScreenPos.getY() << T(' ') | |||
| << lastNonFullScreenPos.getWidth() << T(' ') | |||
| << lastNonFullScreenPos.getHeight(); | |||
| return s; | |||
| return (isFullScreen() ? "fs " : "") + lastNonFullScreenPos.toString(); | |||
| } | |||
| bool ResizableWindow::restoreWindowStateFromString (const String& s) | |||
| @@ -77743,47 +77727,46 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s) | |||
| tokens.trim(); | |||
| const bool fs = tokens[0].startsWithIgnoreCase (T("fs")); | |||
| const int n = fs ? 1 : 0; | |||
| const int firstCoord = fs ? 1 : 0; | |||
| if (tokens.size() != 4 + n) | |||
| if (tokens.size() != firstCoord + 4) | |||
| return false; | |||
| Rectangle<int> r (tokens[n].getIntValue(), | |||
| tokens[n + 1].getIntValue(), | |||
| tokens[n + 2].getIntValue(), | |||
| tokens[n + 3].getIntValue()); | |||
| Rectangle<int> newPos (tokens[firstCoord].getIntValue(), | |||
| tokens[firstCoord + 1].getIntValue(), | |||
| tokens[firstCoord + 2].getIntValue(), | |||
| tokens[firstCoord + 3].getIntValue()); | |||
| if (r.isEmpty()) | |||
| if (newPos.isEmpty()) | |||
| return false; | |||
| const Rectangle<int> screen (Desktop::getInstance().getMonitorAreaContaining (r.getX(), r.getY())); | |||
| const Rectangle<int> screen (Desktop::getInstance().getMonitorAreaContaining (newPos.getCentreX(), | |||
| newPos.getCentreY())); | |||
| if (! screen.contains (r)) | |||
| ComponentPeer* const peer = isOnDesktop() ? getPeer() : 0; | |||
| if (peer != 0) | |||
| peer->getFrameSize().addTo (newPos); | |||
| if (! screen.contains (newPos)) | |||
| { | |||
| r.setSize (jmin (r.getWidth(), screen.getWidth()), | |||
| jmin (r.getHeight(), screen.getHeight())); | |||
| newPos.setSize (jmin (newPos.getWidth(), screen.getWidth()), | |||
| jmin (newPos.getHeight(), screen.getHeight())); | |||
| r.setPosition (jlimit (screen.getX(), screen.getRight() - r.getWidth(), r.getX()), | |||
| jlimit (screen.getY(), screen.getBottom() - r.getHeight(), r.getY())); | |||
| newPos.setPosition (jlimit (screen.getX(), screen.getRight() - newPos.getWidth(), newPos.getX()), | |||
| jlimit (screen.getY(), screen.getBottom() - newPos.getHeight(), newPos.getY())); | |||
| } | |||
| lastNonFullScreenPos = r; | |||
| if (isOnDesktop()) | |||
| if (peer != 0) | |||
| { | |||
| ComponentPeer* const peer = getPeer(); | |||
| if (peer != 0) | |||
| peer->setNonFullScreenBounds (r); | |||
| peer->getFrameSize().subtractFrom (newPos); | |||
| peer->setNonFullScreenBounds (newPos); | |||
| } | |||
| lastNonFullScreenPos = newPos; | |||
| setFullScreen (fs); | |||
| if (! fs) | |||
| setBoundsConstrained (r.getX(), | |||
| r.getY(), | |||
| r.getWidth(), | |||
| r.getHeight()); | |||
| setBoundsConstrained (newPos); | |||
| return true; | |||
| } | |||
| @@ -216197,13 +216180,18 @@ private: | |||
| component->getWidth() + windowBorder.getLeftAndRight(), | |||
| component->getHeight() + windowBorder.getTopAndBottom()); | |||
| constrainer->checkBounds (wp->x, wp->y, wp->cx, wp->cy, | |||
| current, | |||
| Rectangle<int> pos (wp->x, wp->y, wp->cx, wp->cy); | |||
| constrainer->checkBounds (pos, current, | |||
| Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), | |||
| wp->y != current.getY() && wp->y + wp->cy == current.getBottom(), | |||
| wp->x != current.getX() && wp->x + wp->cx == current.getRight(), | |||
| wp->y == current.getY() && wp->y + wp->cy != current.getBottom(), | |||
| wp->x == current.getX() && wp->x + wp->cx != current.getRight()); | |||
| pos.getY() != current.getY() && pos.getBottom() == current.getBottom(), | |||
| pos.getX() != current.getX() && pos.getRight() == current.getRight(), | |||
| pos.getY() == current.getY() && pos.getBottom() != current.getBottom(), | |||
| pos.getX() == current.getX() && pos.getRight() != current.getRight()); | |||
| wp->x = pos.getX(); | |||
| wp->y = pos.getY(); | |||
| wp->cx = pos.getWidth(); | |||
| wp->cy = pos.getHeight(); | |||
| } | |||
| } | |||
| } | |||
| @@ -241267,26 +241255,23 @@ CGRect UIViewComponentPeer::constrainRect (CGRect r) | |||
| r.origin.y = [[UIScreen mainScreen] bounds].size.height - r.origin.y - r.size.height; | |||
| int x = (int) r.origin.x; | |||
| int y = (int) r.origin.y; | |||
| int w = (int) r.size.width; | |||
| int h = (int) r.size.height; | |||
| Rectangle<int> pos ((int) r.origin.x, (int) r.origin.y, | |||
| (int) r.size.width, (int) r.size.height); | |||
| Rectangle<int> original ((int) current.origin.x, (int) current.origin.y, | |||
| (int) current.size.width, (int) current.size.height); | |||
| constrainer->checkBounds (x, y, w, h, | |||
| original, | |||
| constrainer->checkBounds (pos, original, | |||
| Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), | |||
| y != original.getY() && y + h == original.getBottom(), | |||
| x != original.getX() && x + w == original.getRight(), | |||
| y == original.getY() && y + h != original.getBottom(), | |||
| x == original.getX() && x + w != original.getRight()); | |||
| pos.getY() != original.getY() && pos.getBottom() == original.getBottom(), | |||
| pos.getX() != original.getX() && pos.getRight() == original.getRight(), | |||
| pos.getY() == original.getY() && pos.getBottom() != original.getBottom(), | |||
| pos.getX() == original.getX() && pos.getRight() != original.getRight()); | |||
| r.origin.x = x; | |||
| r.origin.y = [[UIScreen mainScreen] bounds].size.height - r.size.height - y; | |||
| r.size.width = w; | |||
| r.size.height = h; | |||
| r.origin.x = pos.getX(); | |||
| r.origin.y = [[UIScreen mainScreen] bounds].size.height - r.size.height - pos.getY(); | |||
| r.size.width = pos.getWidth(); | |||
| r.size.height = pos.getHeight(); | |||
| } | |||
| return r; | |||
| @@ -246061,26 +246046,23 @@ NSRect NSViewComponentPeer::constrainRect (NSRect r) | |||
| r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.origin.y - r.size.height; | |||
| int x = (int) r.origin.x; | |||
| int y = (int) r.origin.y; | |||
| int w = (int) r.size.width; | |||
| int h = (int) r.size.height; | |||
| Rectangle<int> pos ((int) r.origin.x, (int) r.origin.y, | |||
| (int) r.size.width, (int) r.size.height); | |||
| Rectangle<int> original ((int) current.origin.x, (int) current.origin.y, | |||
| (int) current.size.width, (int) current.size.height); | |||
| constrainer->checkBounds (x, y, w, h, | |||
| original, | |||
| constrainer->checkBounds (pos, original, | |||
| Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), | |||
| y != original.getY() && y + h == original.getBottom(), | |||
| x != original.getX() && x + w == original.getRight(), | |||
| y == original.getY() && y + h != original.getBottom(), | |||
| x == original.getX() && x + w != original.getRight()); | |||
| r.origin.x = x; | |||
| r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.size.height - y; | |||
| r.size.width = w; | |||
| r.size.height = h; | |||
| pos.getY() != original.getY() && pos.getBottom() == original.getBottom(), | |||
| pos.getX() != original.getX() && pos.getRight() == original.getRight(), | |||
| pos.getY() == original.getY() && pos.getBottom() != original.getBottom(), | |||
| pos.getX() == original.getX() && pos.getRight() != original.getRight()); | |||
| r.origin.x = pos.getX(); | |||
| r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.size.height - pos.getY(); | |||
| r.size.width = pos.getWidth(); | |||
| r.size.height = pos.getHeight(); | |||
| } | |||
| return r; | |||
| @@ -22637,7 +22637,7 @@ public: | |||
| double getFixedAspectRatio() const throw(); | |||
| virtual void checkBounds (int& x, int& y, int& w, int& h, | |||
| virtual void checkBounds (Rectangle<int>& bounds, | |||
| const Rectangle<int>& previousBounds, | |||
| const Rectangle<int>& limits, | |||
| const bool isStretchingTop, | |||
| @@ -22650,7 +22650,7 @@ public: | |||
| virtual void resizeEnd(); | |||
| void setBoundsForComponent (Component* const component, | |||
| int x, int y, int w, int h, | |||
| const Rectangle<int>& bounds, | |||
| const bool isStretchingTop, | |||
| const bool isStretchingLeft, | |||
| const bool isStretchingBottom, | |||
| @@ -22659,7 +22659,7 @@ public: | |||
| void checkComponentBounds (Component* component); | |||
| virtual void applyBoundsToComponent (Component* component, | |||
| int x, int y, int w, int h); | |||
| const Rectangle<int>& bounds); | |||
| juce_UseDebuggingNewOperator | |||
| @@ -22811,7 +22811,7 @@ public: | |||
| void setConstrainer (ComponentBoundsConstrainer* newConstrainer); | |||
| void setBoundsConstrained (int x, int y, int width, int height); | |||
| void setBoundsConstrained (const Rectangle<int>& bounds); | |||
| bool isFullScreen() const; | |||
| @@ -134,7 +134,7 @@ double ComponentBoundsConstrainer::getFixedAspectRatio() const throw() | |||
| } | |||
| void ComponentBoundsConstrainer::setBoundsForComponent (Component* const component, | |||
| int x, int y, int w, int h, | |||
| const Rectangle<int>& targetBounds, | |||
| const bool isStretchingTop, | |||
| const bool isStretchingLeft, | |||
| const bool isStretchingBottom, | |||
| @@ -142,57 +142,47 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* const compone | |||
| { | |||
| jassert (component != 0); | |||
| Rectangle<int> limits; | |||
| Component* const p = component->getParentComponent(); | |||
| Rectangle<int> limits, bounds (targetBounds); | |||
| BorderSize border; | |||
| if (p == 0) | |||
| limits = Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(); | |||
| else | |||
| limits.setSize (p->getWidth(), p->getHeight()); | |||
| Component* const parent = component->getParentComponent(); | |||
| if (component->isOnDesktop()) | |||
| if (parent == 0) | |||
| { | |||
| ComponentPeer* const peer = component->getPeer(); | |||
| const BorderSize border (peer->getFrameSize()); | |||
| x -= border.getLeft(); | |||
| y -= border.getTop(); | |||
| w += border.getLeftAndRight(); | |||
| h += border.getTopAndBottom(); | |||
| checkBounds (x, y, w, h, | |||
| border.addedTo (component->getBounds()), limits, | |||
| isStretchingTop, isStretchingLeft, | |||
| isStretchingBottom, isStretchingRight); | |||
| x += border.getLeft(); | |||
| y += border.getTop(); | |||
| w -= border.getLeftAndRight(); | |||
| h -= border.getTopAndBottom(); | |||
| ComponentPeer* peer = component->getPeer(); | |||
| if (peer != 0) | |||
| border = peer->getFrameSize(); | |||
| limits = Desktop::getInstance().getMonitorAreaContaining (bounds.getCentreX(), | |||
| bounds.getCentreY()); | |||
| } | |||
| else | |||
| { | |||
| checkBounds (x, y, w, h, | |||
| component->getBounds(), limits, | |||
| isStretchingTop, isStretchingLeft, | |||
| isStretchingBottom, isStretchingRight); | |||
| limits.setSize (parent->getWidth(), parent->getHeight()); | |||
| } | |||
| applyBoundsToComponent (component, x, y, w, h); | |||
| border.addTo (bounds); | |||
| checkBounds (bounds, | |||
| border.addedTo (component->getBounds()), limits, | |||
| isStretchingTop, isStretchingLeft, | |||
| isStretchingBottom, isStretchingRight); | |||
| border.subtractFrom (bounds); | |||
| applyBoundsToComponent (component, bounds); | |||
| } | |||
| void ComponentBoundsConstrainer::checkComponentBounds (Component* component) | |||
| { | |||
| setBoundsForComponent (component, | |||
| component->getX(), component->getY(), | |||
| component->getWidth(), component->getHeight(), | |||
| setBoundsForComponent (component, component->getBounds(), | |||
| false, false, false, false); | |||
| } | |||
| void ComponentBoundsConstrainer::applyBoundsToComponent (Component* component, | |||
| int x, int y, int w, int h) | |||
| const Rectangle<int>& bounds) | |||
| { | |||
| component->setBounds (x, y, w, h); | |||
| component->setBounds (bounds); | |||
| } | |||
| //============================================================================== | |||
| @@ -205,7 +195,7 @@ void ComponentBoundsConstrainer::resizeEnd() | |||
| } | |||
| //============================================================================== | |||
| void ComponentBoundsConstrainer::checkBounds (int& x, int& y, int& w, int& h, | |||
| void ComponentBoundsConstrainer::checkBounds (Rectangle<int>& bounds, | |||
| const Rectangle<int>& old, | |||
| const Rectangle<int>& limits, | |||
| const bool isStretchingTop, | |||
| @@ -213,6 +203,11 @@ void ComponentBoundsConstrainer::checkBounds (int& x, int& y, int& w, int& h, | |||
| const bool isStretchingBottom, | |||
| const bool isStretchingRight) | |||
| { | |||
| int x = bounds.getX(); | |||
| int y = bounds.getY(); | |||
| int w = bounds.getWidth(); | |||
| int h = bounds.getHeight(); | |||
| // constrain the size if it's being stretched.. | |||
| if (isStretchingLeft) | |||
| { | |||
| @@ -353,7 +348,7 @@ void ComponentBoundsConstrainer::checkBounds (int& x, int& y, int& w, int& h, | |||
| } | |||
| jassert (w >= 0 && h >= 0); | |||
| bounds = Rectangle<int> (x, y, w, h); | |||
| } | |||
| @@ -133,18 +133,15 @@ public: | |||
| /** This callback changes the given co-ordinates to impose whatever the current | |||
| constraints are set to be. | |||
| @param x the x position that should be examined and adjusted | |||
| @param y the y position that should be examined and adjusted | |||
| @param w the width that should be examined and adjusted | |||
| @param h the height that should be examined and adjusted | |||
| @param previousBounds the component's current size | |||
| @param limits the region in which the component can be positioned | |||
| @param bounds the target position that should be examined and adjusted | |||
| @param previousBounds the component's current size | |||
| @param limits the region in which the component can be positioned | |||
| @param isStretchingTop whether the top edge of the component is being resized | |||
| @param isStretchingLeft whether the left edge of the component is being resized | |||
| @param isStretchingBottom whether the bottom edge of the component is being resized | |||
| @param isStretchingRight whether the right edge of the component is being resized | |||
| */ | |||
| virtual void checkBounds (int& x, int& y, int& w, int& h, | |||
| virtual void checkBounds (Rectangle<int>& bounds, | |||
| const Rectangle<int>& previousBounds, | |||
| const Rectangle<int>& limits, | |||
| const bool isStretchingTop, | |||
| @@ -160,7 +157,7 @@ public: | |||
| /** Checks the given bounds, and then sets the component to the corrected size. */ | |||
| void setBoundsForComponent (Component* const component, | |||
| int x, int y, int w, int h, | |||
| const Rectangle<int>& bounds, | |||
| const bool isStretchingTop, | |||
| const bool isStretchingLeft, | |||
| const bool isStretchingBottom, | |||
| @@ -178,7 +175,7 @@ public: | |||
| extremely cunning purposes. | |||
| */ | |||
| virtual void applyBoundsToComponent (Component* component, | |||
| int x, int y, int w, int h); | |||
| const Rectangle<int>& bounds); | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| @@ -124,7 +124,7 @@ void ResizableBorderComponent::mouseDrag (const MouseEvent& e) | |||
| if (constrainer != 0) | |||
| constrainer->setBoundsForComponent (component, | |||
| x, y, w, h, | |||
| Rectangle<int> (x, y, w, h), | |||
| (mouseZone & zoneT) != 0, | |||
| (mouseZone & zoneL) != 0, | |||
| (mouseZone & zoneB) != 0, | |||
| @@ -88,7 +88,7 @@ void ResizableCornerComponent::mouseDrag (const MouseEvent& e) | |||
| int h = originalH + e.getDistanceFromDragStartY(); | |||
| if (constrainer != 0) | |||
| constrainer->setBoundsForComponent (component, x, y, w, h, | |||
| constrainer->setBoundsForComponent (component, Rectangle<int> (x, y, w, h), | |||
| false, false, true, true); | |||
| else | |||
| component->setBounds (x, y, w, h); | |||
| @@ -78,7 +78,7 @@ void ComponentDragger::dragComponent (Component* const componentToDrag, const Mo | |||
| y += e.getDistanceFromDragStartY(); | |||
| if (constrainer != 0) | |||
| constrainer->setBoundsForComponent (componentToDrag, x, y, w, h, | |||
| constrainer->setBoundsForComponent (componentToDrag, Rectangle<int> (x, y, w, h), | |||
| false, false, false, false); | |||
| else | |||
| componentToDrag->setBounds (x, y, w, h); | |||
| @@ -265,7 +265,7 @@ void ResizableWindow::setResizeLimits (const int newMinimumWidth, | |||
| defaultConstrainer.setSizeLimits (newMinimumWidth, newMinimumHeight, | |||
| newMaximumWidth, newMaximumHeight); | |||
| setBoundsConstrained (getX(), getY(), getWidth(), getHeight()); | |||
| setBoundsConstrained (getBounds()); | |||
| } | |||
| void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer) | |||
| @@ -288,12 +288,12 @@ void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer | |||
| } | |||
| } | |||
| void ResizableWindow::setBoundsConstrained (int x, int y, int w, int h) | |||
| void ResizableWindow::setBoundsConstrained (const Rectangle<int>& bounds) | |||
| { | |||
| if (constrainer != 0) | |||
| constrainer->setBoundsForComponent (this, x, y, w, h, false, false, false, false); | |||
| constrainer->setBoundsForComponent (this, bounds, false, false, false, false); | |||
| else | |||
| setBounds (x, y, w, h); | |||
| setBounds (bounds); | |||
| } | |||
| //============================================================================== | |||
| @@ -451,18 +451,7 @@ void ResizableWindow::parentSizeChanged() | |||
| const String ResizableWindow::getWindowStateAsString() | |||
| { | |||
| updateLastPos(); | |||
| String s; | |||
| if (isFullScreen()) | |||
| s << "fs "; | |||
| s << lastNonFullScreenPos.getX() << T(' ') | |||
| << lastNonFullScreenPos.getY() << T(' ') | |||
| << lastNonFullScreenPos.getWidth() << T(' ') | |||
| << lastNonFullScreenPos.getHeight(); | |||
| return s; | |||
| return (isFullScreen() ? "fs " : "") + lastNonFullScreenPos.toString(); | |||
| } | |||
| bool ResizableWindow::restoreWindowStateFromString (const String& s) | |||
| @@ -473,47 +462,46 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s) | |||
| tokens.trim(); | |||
| const bool fs = tokens[0].startsWithIgnoreCase (T("fs")); | |||
| const int n = fs ? 1 : 0; | |||
| const int firstCoord = fs ? 1 : 0; | |||
| if (tokens.size() != 4 + n) | |||
| if (tokens.size() != firstCoord + 4) | |||
| return false; | |||
| Rectangle<int> r (tokens[n].getIntValue(), | |||
| tokens[n + 1].getIntValue(), | |||
| tokens[n + 2].getIntValue(), | |||
| tokens[n + 3].getIntValue()); | |||
| Rectangle<int> newPos (tokens[firstCoord].getIntValue(), | |||
| tokens[firstCoord + 1].getIntValue(), | |||
| tokens[firstCoord + 2].getIntValue(), | |||
| tokens[firstCoord + 3].getIntValue()); | |||
| if (r.isEmpty()) | |||
| if (newPos.isEmpty()) | |||
| return false; | |||
| const Rectangle<int> screen (Desktop::getInstance().getMonitorAreaContaining (r.getX(), r.getY())); | |||
| const Rectangle<int> screen (Desktop::getInstance().getMonitorAreaContaining (newPos.getCentreX(), | |||
| newPos.getCentreY())); | |||
| ComponentPeer* const peer = isOnDesktop() ? getPeer() : 0; | |||
| if (peer != 0) | |||
| peer->getFrameSize().addTo (newPos); | |||
| if (! screen.contains (r)) | |||
| if (! screen.contains (newPos)) | |||
| { | |||
| r.setSize (jmin (r.getWidth(), screen.getWidth()), | |||
| jmin (r.getHeight(), screen.getHeight())); | |||
| newPos.setSize (jmin (newPos.getWidth(), screen.getWidth()), | |||
| jmin (newPos.getHeight(), screen.getHeight())); | |||
| r.setPosition (jlimit (screen.getX(), screen.getRight() - r.getWidth(), r.getX()), | |||
| jlimit (screen.getY(), screen.getBottom() - r.getHeight(), r.getY())); | |||
| newPos.setPosition (jlimit (screen.getX(), screen.getRight() - newPos.getWidth(), newPos.getX()), | |||
| jlimit (screen.getY(), screen.getBottom() - newPos.getHeight(), newPos.getY())); | |||
| } | |||
| lastNonFullScreenPos = r; | |||
| if (isOnDesktop()) | |||
| if (peer != 0) | |||
| { | |||
| ComponentPeer* const peer = getPeer(); | |||
| if (peer != 0) | |||
| peer->setNonFullScreenBounds (r); | |||
| peer->getFrameSize().subtractFrom (newPos); | |||
| peer->setNonFullScreenBounds (newPos); | |||
| } | |||
| lastNonFullScreenPos = newPos; | |||
| setFullScreen (fs); | |||
| if (! fs) | |||
| setBoundsConstrained (r.getX(), | |||
| r.getY(), | |||
| r.getWidth(), | |||
| r.getHeight()); | |||
| setBoundsConstrained (newPos); | |||
| return true; | |||
| } | |||
| @@ -168,7 +168,7 @@ public: | |||
| @see setConstrainer | |||
| */ | |||
| void setBoundsConstrained (int x, int y, int width, int height); | |||
| void setBoundsConstrained (const Rectangle<int>& bounds); | |||
| //============================================================================== | |||
| @@ -528,26 +528,23 @@ CGRect UIViewComponentPeer::constrainRect (CGRect r) | |||
| r.origin.y = [[UIScreen mainScreen] bounds].size.height - r.origin.y - r.size.height; | |||
| int x = (int) r.origin.x; | |||
| int y = (int) r.origin.y; | |||
| int w = (int) r.size.width; | |||
| int h = (int) r.size.height; | |||
| Rectangle<int> pos ((int) r.origin.x, (int) r.origin.y, | |||
| (int) r.size.width, (int) r.size.height); | |||
| Rectangle<int> original ((int) current.origin.x, (int) current.origin.y, | |||
| (int) current.size.width, (int) current.size.height); | |||
| constrainer->checkBounds (x, y, w, h, | |||
| original, | |||
| constrainer->checkBounds (pos, original, | |||
| Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), | |||
| y != original.getY() && y + h == original.getBottom(), | |||
| x != original.getX() && x + w == original.getRight(), | |||
| y == original.getY() && y + h != original.getBottom(), | |||
| x == original.getX() && x + w != original.getRight()); | |||
| r.origin.x = x; | |||
| r.origin.y = [[UIScreen mainScreen] bounds].size.height - r.size.height - y; | |||
| r.size.width = w; | |||
| r.size.height = h; | |||
| pos.getY() != original.getY() && pos.getBottom() == original.getBottom(), | |||
| pos.getX() != original.getX() && pos.getRight() == original.getRight(), | |||
| pos.getY() == original.getY() && pos.getBottom() != original.getBottom(), | |||
| pos.getX() == original.getX() && pos.getRight() != original.getRight()); | |||
| r.origin.x = pos.getX(); | |||
| r.origin.y = [[UIScreen mainScreen] bounds].size.height - r.size.height - pos.getY(); | |||
| r.size.width = pos.getWidth(); | |||
| r.size.height = pos.getHeight(); | |||
| } | |||
| return r; | |||
| @@ -897,26 +897,23 @@ NSRect NSViewComponentPeer::constrainRect (NSRect r) | |||
| r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.origin.y - r.size.height; | |||
| int x = (int) r.origin.x; | |||
| int y = (int) r.origin.y; | |||
| int w = (int) r.size.width; | |||
| int h = (int) r.size.height; | |||
| Rectangle<int> pos ((int) r.origin.x, (int) r.origin.y, | |||
| (int) r.size.width, (int) r.size.height); | |||
| Rectangle<int> original ((int) current.origin.x, (int) current.origin.y, | |||
| (int) current.size.width, (int) current.size.height); | |||
| constrainer->checkBounds (x, y, w, h, | |||
| original, | |||
| constrainer->checkBounds (pos, original, | |||
| Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), | |||
| y != original.getY() && y + h == original.getBottom(), | |||
| x != original.getX() && x + w == original.getRight(), | |||
| y == original.getY() && y + h != original.getBottom(), | |||
| x == original.getX() && x + w != original.getRight()); | |||
| r.origin.x = x; | |||
| r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.size.height - y; | |||
| r.size.width = w; | |||
| r.size.height = h; | |||
| pos.getY() != original.getY() && pos.getBottom() == original.getBottom(), | |||
| pos.getX() != original.getX() && pos.getRight() == original.getRight(), | |||
| pos.getY() == original.getY() && pos.getBottom() != original.getBottom(), | |||
| pos.getX() == original.getX() && pos.getRight() != original.getRight()); | |||
| r.origin.x = pos.getX(); | |||
| r.origin.y = [[[NSScreen screens] objectAtIndex: 0] frame].size.height - r.size.height - pos.getY(); | |||
| r.size.width = pos.getWidth(); | |||
| r.size.height = pos.getHeight(); | |||
| } | |||
| return r; | |||
| @@ -1902,13 +1902,18 @@ private: | |||
| component->getWidth() + windowBorder.getLeftAndRight(), | |||
| component->getHeight() + windowBorder.getTopAndBottom()); | |||
| constrainer->checkBounds (wp->x, wp->y, wp->cx, wp->cy, | |||
| current, | |||
| Rectangle<int> pos (wp->x, wp->y, wp->cx, wp->cy); | |||
| constrainer->checkBounds (pos, current, | |||
| Desktop::getInstance().getAllMonitorDisplayAreas().getBounds(), | |||
| wp->y != current.getY() && wp->y + wp->cy == current.getBottom(), | |||
| wp->x != current.getX() && wp->x + wp->cx == current.getRight(), | |||
| wp->y == current.getY() && wp->y + wp->cy != current.getBottom(), | |||
| wp->x == current.getX() && wp->x + wp->cx != current.getRight()); | |||
| pos.getY() != current.getY() && pos.getBottom() == current.getBottom(), | |||
| pos.getX() != current.getX() && pos.getRight() == current.getRight(), | |||
| pos.getY() == current.getY() && pos.getBottom() != current.getBottom(), | |||
| pos.getX() == current.getX() && pos.getRight() != current.getRight()); | |||
| wp->x = pos.getX(); | |||
| wp->y = pos.getY(); | |||
| wp->cx = pos.getWidth(); | |||
| wp->cy = pos.getHeight(); | |||
| } | |||
| } | |||
| } | |||