- Library code update

- project update (added Eigen)

git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@94 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-12-20 20:59:48 +00:00
parent 1b4d8e9f54
commit dc5560392f
312 changed files with 6349 additions and 4195 deletions
@@ -22,12 +22,6 @@
==============================================================================
*/
#define CHECK_MESSAGE_MANAGER_IS_LOCKED \
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager());
#define CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN \
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager() || getPeer() == nullptr);
Component* Component::currentlyFocusedComponent = nullptr;
@@ -147,7 +141,7 @@ public:
}
private:
Array <MouseListener*> listeners;
Array<MouseListener*> listeners;
int numDeepMouseListeners;
class BailOutChecker2
@@ -245,6 +239,15 @@ struct ScalingHelpers
{
return scaledScreenPosToUnscaled (comp.getDesktopScaleFactor(), pos);
}
static Point<int> addPosition (Point<int> p, const Component& c) noexcept { return p + c.getPosition(); }
static Rectangle<int> addPosition (Rectangle<int> p, const Component& c) noexcept { return p + c.getPosition(); }
static Point<float> addPosition (Point<float> p, const Component& c) noexcept { return p + c.getPosition().toFloat(); }
static Rectangle<float> addPosition (Rectangle<float> p, const Component& c) noexcept { return p + c.getPosition().toFloat(); }
static Point<int> subtractPosition (Point<int> p, const Component& c) noexcept { return p - c.getPosition(); }
static Rectangle<int> subtractPosition (Rectangle<int> p, const Component& c) noexcept { return p - c.getPosition(); }
static Point<float> subtractPosition (Point<float> p, const Component& c) noexcept { return p - c.getPosition().toFloat(); }
static Rectangle<float> subtractPosition (Rectangle<float> p, const Component& c) noexcept { return p - c.getPosition().toFloat(); }
};
//==============================================================================
@@ -253,7 +256,7 @@ struct Component::ComponentHelpers
#if JUCE_MODAL_LOOPS_PERMITTED
static void* runModalLoopCallback (void* userData)
{
return (void*) (pointer_sized_int) static_cast <Component*> (userData)->runModalLoop();
return (void*) (pointer_sized_int) static_cast<Component*> (userData)->runModalLoop();
}
#endif
@@ -327,7 +330,7 @@ struct Component::ComponentHelpers
}
else
{
pointInParentSpace -= comp.getPosition();
pointInParentSpace = ScalingHelpers::subtractPosition (pointInParentSpace, comp);
}
return pointInParentSpace;
@@ -346,7 +349,7 @@ struct Component::ComponentHelpers
}
else
{
pointInLocalSpace += comp.getPosition();
pointInLocalSpace = ScalingHelpers::addPosition (pointInLocalSpace, comp);
}
if (comp.affineTransform != nullptr)
@@ -396,16 +399,6 @@ struct Component::ComponentHelpers
return convertFromDistantParentSpace (topLevelComp, *target, p);
}
static Rectangle<int> getUnclippedArea (const Component& comp)
{
Rectangle<int> r (comp.getLocalBounds());
if (Component* const p = comp.getParentComponent())
r = r.getIntersection (convertFromParentSpace (comp, getUnclippedArea (*p)));
return r;
}
static bool clipObscuredRegions (const Component& comp, Graphics& g, const Rectangle<int>& clipRect, Point<int> delta)
{
bool nothingChanged = true;
@@ -438,35 +431,6 @@ struct Component::ComponentHelpers
return nothingChanged;
}
static void subtractObscuredRegions (const Component& comp, RectangleList<int>& result,
Point<int> delta, const Rectangle<int>& clipRect,
const Component* const compToAvoid)
{
for (int i = comp.childComponentList.size(); --i >= 0;)
{
const Component* const c = comp.childComponentList.getUnchecked(i);
if (c != compToAvoid && c->isVisible())
{
if (c->isOpaque() && c->componentTransparency == 0)
{
Rectangle<int> childBounds (c->bounds.getIntersection (clipRect));
childBounds.translate (delta.x, delta.y);
result.subtract (childBounds);
}
else
{
Rectangle<int> newClip (clipRect.getIntersection (c->bounds));
newClip.translate (-c->getX(), -c->getY());
subtractObscuredRegions (*c, result, c->getPosition() + delta,
newClip, compToAvoid);
}
}
}
}
static Rectangle<int> getParentOrMainMonitorBounds (const Component& comp)
{
if (Component* p = comp.getParentComponent())
@@ -477,7 +441,7 @@ struct Component::ComponentHelpers
};
//==============================================================================
Component::Component()
Component::Component() noexcept
: parentComponent (nullptr),
lookAndFeel (nullptr),
effect (nullptr),
@@ -486,7 +450,7 @@ Component::Component()
{
}
Component::Component (const String& name)
Component::Component (const String& name) noexcept
: componentName (name),
parentComponent (nullptr),
lookAndFeel (nullptr),
@@ -524,7 +488,7 @@ void Component::setName (const String& name)
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
if (componentName != name)
{
@@ -550,7 +514,7 @@ void Component::setVisible (bool shouldBeVisible)
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
const WeakReference<Component> safePointer (this);
flags.visibleFlag = shouldBeVisible;
@@ -617,7 +581,6 @@ bool Component::isShowing() const
return false;
}
//==============================================================================
void* Component::getWindowHandle() const
{
@@ -632,7 +595,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo)
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED
ASSERT_MESSAGE_MANAGER_IS_LOCKED
if (isOpaque())
styleWanted &= ~ComponentPeer::windowIsSemiTransparent;
@@ -659,7 +622,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo)
bool wasFullscreen = false;
bool wasMinimised = false;
ComponentBoundsConstrainer* currentConstainer = nullptr;
ComponentBoundsConstrainer* currentConstrainer = nullptr;
Rectangle<int> oldNonFullScreenBounds;
int oldRenderingEngine = -1;
@@ -669,7 +632,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo)
wasFullscreen = peer->isFullScreen();
wasMinimised = peer->isMinimised();
currentConstainer = peer->getConstrainer();
currentConstrainer = peer->getConstrainer();
oldNonFullScreenBounds = peer->getNonFullScreenBounds();
oldRenderingEngine = peer->getCurrentRenderingEngine();
@@ -720,7 +683,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo)
peer->setAlwaysOnTop (true);
#endif
peer->setConstrainer (currentConstainer);
peer->setConstrainer (currentConstrainer);
repaint();
internalHierarchyChanged();
@@ -732,7 +695,7 @@ void Component::removeFromDesktop()
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
if (flags.hasHeavyweightPeerFlag)
{
@@ -877,7 +840,7 @@ void Component::setBufferedToImage (const bool shouldBeBuffered)
// so by calling setBufferedToImage, you'll be deleting the custom one - this is almost certainly
// not what you wanted to happen... If you really do know what you're doing here, and want to
// avoid this assertion, just call setCachedComponentImage (nullptr) before setBufferedToImage().
jassert (cachedImage == nullptr || dynamic_cast <StandardCachedComponentImage*> (cachedImage.get()) != nullptr);
jassert (cachedImage == nullptr || dynamic_cast<StandardCachedComponentImage*> (cachedImage.get()) != nullptr);
if (shouldBeBuffered)
{
@@ -910,7 +873,7 @@ void Component::toFront (const bool setAsForeground)
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
if (flags.hasHeavyweightPeerFlag)
{
@@ -1092,6 +1055,11 @@ Point<int> Component::getLocalPoint (const Component* source, Point<int> point)
return ComponentHelpers::convertCoordinate (this, source, point);
}
Point<float> Component::getLocalPoint (const Component* source, Point<float> point) const
{
return ComponentHelpers::convertCoordinate (this, source, point);
}
Rectangle<int> Component::getLocalArea (const Component* source, const Rectangle<int>& area) const
{
return ComponentHelpers::convertCoordinate (this, source, area);
@@ -1102,6 +1070,11 @@ Point<int> Component::localPointToGlobal (Point<int> point) const
return ComponentHelpers::convertCoordinate (nullptr, this, point);
}
Point<float> Component::localPointToGlobal (Point<float> point) const
{
return ComponentHelpers::convertCoordinate (nullptr, this, point);
}
Rectangle<int> Component::localAreaToGlobal (const Rectangle<int>& area) const
{
return ComponentHelpers::convertCoordinate (nullptr, this, area);
@@ -1130,7 +1103,7 @@ void Component::setBounds (const int x, const int y, int w, int h)
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
if (w < 0) w = 0;
if (h < 0) h = 0;
@@ -1169,11 +1142,25 @@ void Component::setBounds (const int x, const int y, int w, int h)
cachedImage->invalidateAll();
}
flags.isMoveCallbackPending = wasMoved;
flags.isResizeCallbackPending = wasResized;
if (flags.hasHeavyweightPeerFlag)
if (ComponentPeer* const peer = getPeer())
peer->updateBounds();
sendMovedResizedMessages (wasMoved, wasResized);
sendMovedResizedMessagesIfPending();
}
}
void Component::sendMovedResizedMessagesIfPending()
{
if (flags.isMoveCallbackPending || flags.isResizeCallbackPending)
{
sendMovedResizedMessages (flags.isMoveCallbackPending, flags.isResizeCallbackPending);
flags.isMoveCallbackPending = false;
flags.isResizeCallbackPending = false;
}
}
@@ -1463,7 +1450,7 @@ void Component::addChildComponent (Component& child, int zOrder)
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
if (child.parentComponent != this)
{
@@ -1539,7 +1526,7 @@ Component* Component::removeChildComponent (const int index, bool sendParentEven
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN
Component* const child = childComponentList [index];
@@ -1616,7 +1603,7 @@ Component* Component::getChildComponent (const int index) const noexcept
int Component::getIndexOfChildComponent (const Component* const child) const noexcept
{
return childComponentList.indexOf (const_cast <Component*> (child));
return childComponentList.indexOf (const_cast<Component*> (child));
}
Component* Component::findChildWithID (StringRef targetID) const noexcept
@@ -1638,7 +1625,7 @@ Component* Component::getTopLevelComponent() const noexcept
while (comp->parentComponent != nullptr)
comp = comp->parentComponent;
return const_cast <Component*> (comp);
return const_cast<Component*> (comp);
}
bool Component::isParentOf (const Component* possibleChild) const noexcept
@@ -1730,7 +1717,7 @@ void Component::enterModalState (const bool shouldTakeKeyboardFocus,
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED
ASSERT_MESSAGE_MANAGER_IS_LOCKED
// Check for an attempt to make a component modal when it already is!
// This can cause nasty problems..
@@ -1917,7 +1904,7 @@ void Component::internalRepaintUnchecked (const Rectangle<int>& area, const bool
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED
ASSERT_MESSAGE_MANAGER_IS_LOCKED
if (ComponentPeer* const peer = getPeer())
{
@@ -2034,6 +2021,14 @@ void Component::paintComponentAndChildren (Graphics& g)
void Component::paintEntireComponent (Graphics& g, const bool ignoreAlphaLevel)
{
// If sizing a top-level-window and the OS paint message is delivered synchronously
// before resized() is called, then we'll invoke the callback here, to make sure
// the components inside have had a chance to sort their sizes out..
#if JUCE_DEBUG
if (! flags.isInsidePaintCall) // (avoids an assertion in plugins hosted in WaveLab)
#endif
sendMovedResizedMessagesIfPending();
#if JUCE_DEBUG
flags.isInsidePaintCall = true;
#endif
@@ -2170,7 +2165,7 @@ void Component::sendLookAndFeelChange()
Colour Component::findColour (const int colourId, const bool inheritFromParent) const
{
if (const var* const v = properties.getVarPointer (ComponentHelpers::getColourPropertyId (colourId)))
return Colour ((uint32) static_cast <int> (*v));
return Colour ((uint32) static_cast<int> (*v));
if (inheritFromParent && parentComponent != nullptr
&& (lookAndFeel == nullptr || ! lookAndFeel->isColourSpecified (colourId)))
@@ -2249,28 +2244,6 @@ Rectangle<int> Component::getBoundsInParent() const noexcept
: bounds.transformedBy (*affineTransform);
}
void Component::getVisibleArea (RectangleList<int>& result, const bool includeSiblings) const
{
result.clear();
const Rectangle<int> unclipped (ComponentHelpers::getUnclippedArea (*this));
if (! unclipped.isEmpty())
{
result.add (unclipped);
if (includeSiblings)
{
const Component* const c = getTopLevelComponent();
ComponentHelpers::subtractObscuredRegions (*c, result, getLocalPoint (c, Point<int>()),
c->getLocalBounds(), this);
}
ComponentHelpers::subtractObscuredRegions (*this, result, Point<int>(), unclipped, nullptr);
result.consolidate();
}
}
//==============================================================================
void Component::mouseEnter (const MouseEvent&) {}
void Component::mouseExit (const MouseEvent&) {}
@@ -2306,7 +2279,7 @@ void Component::addComponentListener (ComponentListener* const newListener)
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
#if JUCE_DEBUG || JUCE_LOG_ASSERTIONS
if (getParentComponent() != nullptr)
CHECK_MESSAGE_MANAGER_IS_LOCKED;
ASSERT_MESSAGE_MANAGER_IS_LOCKED;
#endif
componentListeners.add (newListener);
@@ -2369,7 +2342,7 @@ void Component::addMouseListener (MouseListener* const newListener,
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED
ASSERT_MESSAGE_MANAGER_IS_LOCKED
// If you register a component as a mouselistener for itself, it'll receive all the events
// twice - once via the direct callback that all components get anyway, and then again as a listener!
@@ -2385,14 +2358,14 @@ void Component::removeMouseListener (MouseListener* const listenerToRemove)
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED
ASSERT_MESSAGE_MANAGER_IS_LOCKED
if (mouseListeners != nullptr)
mouseListeners->removeListener (listenerToRemove);
}
//==============================================================================
void Component::internalMouseEnter (MouseInputSource source, Point<int> relativePos, Time time)
void Component::internalMouseEnter (MouseInputSource source, Point<float> relativePos, Time time)
{
if (isCurrentlyBlockedByAnotherModalComponent())
{
@@ -2418,7 +2391,7 @@ void Component::internalMouseEnter (MouseInputSource source, Point<int> relative
MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseEnter, me);
}
void Component::internalMouseExit (MouseInputSource source, Point<int> relativePos, Time time)
void Component::internalMouseExit (MouseInputSource source, Point<float> relativePos, Time time)
{
if (flags.repaintOnMouseActivityFlag)
repaint();
@@ -2438,7 +2411,7 @@ void Component::internalMouseExit (MouseInputSource source, Point<int> relativeP
MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseExit, me);
}
void Component::internalMouseDown (MouseInputSource source, Point<int> relativePos, Time time)
void Component::internalMouseDown (MouseInputSource source, Point<float> relativePos, Time time)
{
Desktop& desktop = Desktop::getInstance();
BailOutChecker checker (this);
@@ -2502,7 +2475,7 @@ void Component::internalMouseDown (MouseInputSource source, Point<int> relativeP
MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDown, me);
}
void Component::internalMouseUp (MouseInputSource source, Point<int> relativePos,
void Component::internalMouseUp (MouseInputSource source, Point<float> relativePos,
Time time, const ModifierKeys oldModifiers)
{
if (flags.mouseDownWasBlocked && isCurrentlyBlockedByAnotherModalComponent())
@@ -2545,7 +2518,7 @@ void Component::internalMouseUp (MouseInputSource source, Point<int> relativePos
}
}
void Component::internalMouseDrag (MouseInputSource source, Point<int> relativePos, Time time)
void Component::internalMouseDrag (MouseInputSource source, Point<float> relativePos, Time time)
{
if (! isCurrentlyBlockedByAnotherModalComponent())
{
@@ -2568,7 +2541,7 @@ void Component::internalMouseDrag (MouseInputSource source, Point<int> relativeP
}
}
void Component::internalMouseMove (MouseInputSource source, Point<int> relativePos, Time time)
void Component::internalMouseMove (MouseInputSource source, Point<float> relativePos, Time time)
{
Desktop& desktop = Desktop::getInstance();
@@ -2594,7 +2567,7 @@ void Component::internalMouseMove (MouseInputSource source, Point<int> relativeP
}
}
void Component::internalMouseWheel (MouseInputSource source, Point<int> relativePos,
void Component::internalMouseWheel (MouseInputSource source, Point<float> relativePos,
Time time, const MouseWheelDetails& wheel)
{
Desktop& desktop = Desktop::getInstance();
@@ -2622,7 +2595,7 @@ void Component::internalMouseWheel (MouseInputSource source, Point<int> relative
}
}
void Component::internalMagnifyGesture (MouseInputSource source, Point<int> relativePos,
void Component::internalMagnifyGesture (MouseInputSource source, Point<float> relativePos,
Time time, float amount)
{
if (! isCurrentlyBlockedByAnotherModalComponent())
@@ -2821,7 +2794,7 @@ void Component::grabFocusInternal (const FocusChangeType cause, const bool canTr
else
{
// find the default child component..
ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser());
ScopedPointer<KeyboardFocusTraverser> traverser (createFocusTraverser());
if (traverser != nullptr)
{
@@ -2850,7 +2823,7 @@ void Component::grabKeyboardFocus()
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED
ASSERT_MESSAGE_MANAGER_IS_LOCKED
grabFocusInternal (focusChangedDirectly, true);
}
@@ -2859,11 +2832,11 @@ void Component::moveKeyboardFocusToSibling (const bool moveToNext)
{
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
CHECK_MESSAGE_MANAGER_IS_LOCKED
ASSERT_MESSAGE_MANAGER_IS_LOCKED
if (parentComponent != nullptr)
{
ScopedPointer <KeyboardFocusTraverser> traverser (createFocusTraverser());
ScopedPointer<KeyboardFocusTraverser> traverser (createFocusTraverser());
if (traverser != nullptr)
{
@@ -2972,7 +2945,7 @@ bool Component::isMouseOver (const bool includeChildren) const
Component* const c = mi->getComponentUnderMouse();
if ((c == this || (includeChildren && isParentOf (c)))
&& c->reallyContains (c->getLocalPoint (nullptr, mi->getScreenPosition()), false)
&& c->reallyContains (c->getLocalPoint (nullptr, mi->getScreenPosition()).roundToInt(), false)
&& (mi->isMouse() || mi->isDragging()))
return true;
}
@@ -3017,7 +2990,7 @@ Point<int> Component::getMouseXYRelative() const
void Component::addKeyListener (KeyListener* const newListener)
{
if (keyListeners == nullptr)
keyListeners = new Array <KeyListener*>();
keyListeners = new Array<KeyListener*>();
keyListeners->addIfNotAlreadyThere (newListener);
}
@@ -46,7 +46,7 @@ public:
subclass of Component or use one of the other types of component from
the library.
*/
Component();
Component() noexcept;
/** Destructor.
@@ -66,7 +66,7 @@ public:
/** Creates a component, setting its name at the same time.
@see getName, setName
*/
explicit Component (const String& componentName);
explicit Component (const String& componentName) noexcept;
/** Returns the name of this component.
@see setName
@@ -315,16 +315,6 @@ public:
*/
Rectangle<int> getBoundsInParent() const noexcept;
/** Returns the region of this component that's not obscured by other, opaque components.
The RectangleList that is returned represents the area of this component
which isn't covered by opaque child components.
If includeSiblings is true, it will also take into account any siblings
that may be overlapping the component.
*/
void getVisibleArea (RectangleList<int>& result, bool includeSiblings) const;
//==============================================================================
/** Returns this component's x coordinate relative the screen's top-left origin.
@see getX, localPointToGlobal
@@ -355,6 +345,15 @@ public:
Point<int> getLocalPoint (const Component* sourceComponent,
Point<int> pointRelativeToSourceComponent) const;
/** Converts a point to be relative to this component's coordinate space.
This takes a point relative to a different component, and returns its position relative to this
component. If the sourceComponent parameter is null, the source point is assumed to be a global
screen coordinate.
*/
Point<float> getLocalPoint (const Component* sourceComponent,
Point<float> pointRelativeToSourceComponent) const;
/** Converts a rectangle to be relative to this component's coordinate space.
This takes a rectangle that is relative to a different component, and returns its position relative
@@ -373,6 +372,11 @@ public:
*/
Point<int> localPointToGlobal (Point<int> localPoint) const;
/** Converts a point relative to this component's top-left into a screen coordinate.
@see getLocalPoint, localAreaToGlobal
*/
Point<float> localPointToGlobal (Point<float> localPoint) const;
/** Converts a rectangle from this component's coordinate space to a screen coordinate.
If you've used setTransform() to apply one or more transforms to components, then the source rectangle
@@ -793,7 +797,7 @@ public:
TargetClass* findParentComponentOfClass() const
{
for (Component* p = parentComponent; p != nullptr; p = p->parentComponent)
if (TargetClass* const target = dynamic_cast <TargetClass*> (p))
if (TargetClass* const target = dynamic_cast<TargetClass*> (p))
return target;
return nullptr;
@@ -1152,7 +1156,7 @@ public:
By default, components are considered transparent, unless this is used to
make it otherwise.
@see isOpaque, getVisibleArea
@see isOpaque
*/
void setOpaque (bool shouldBeOpaque);
@@ -1743,11 +1747,14 @@ public:
*/
virtual void focusLost (FocusChangeType cause);
/** Called to indicate that one of this component's children has been focused or unfocused.
/** Called to indicate a change in whether or not this component is the parent of the
currently-focused component.
Essentially this means that the return value of a call to hasKeyboardFocus (true) has
Essentially this is called when the return value of a call to hasKeyboardFocus (true) has
changed. It happens when focus moves from one of this component's children (at any depth)
to a component that isn't contained in this one, (or vice-versa).
Note that this method does NOT get called to when focus simply moves from one of its
child components to another.
@see focusGained, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus
*/
@@ -1782,9 +1789,7 @@ public:
bool isMouseButtonDown() const;
/** True if the mouse is over this component, or if it's being dragged in this component.
This is a handy equivalent to (isMouseOver() || isMouseButtonDown()).
@see isMouseOver, isMouseButtonDown, isMouseButtonDownAnywhere
*/
bool isMouseOverOrDragging() const;
@@ -2122,31 +2127,31 @@ public:
SafePointer() noexcept {}
/** Creates a SafePointer that points at the given component. */
SafePointer (ComponentType* const component) : weakRef (component) {}
SafePointer (ComponentType* component) : weakRef (component) {}
/** Creates a copy of another SafePointer. */
SafePointer (const SafePointer& other) noexcept : weakRef (other.weakRef) {}
SafePointer (const SafePointer& other) noexcept : weakRef (other.weakRef) {}
/** Copies another pointer to this one. */
SafePointer& operator= (const SafePointer& other) { weakRef = other.weakRef; return *this; }
SafePointer& operator= (const SafePointer& other) { weakRef = other.weakRef; return *this; }
/** Copies another pointer to this one. */
SafePointer& operator= (ComponentType* const newComponent) { weakRef = newComponent; return *this; }
SafePointer& operator= (ComponentType* newComponent) { weakRef = newComponent; return *this; }
/** Returns the component that this pointer refers to, or null if the component no longer exists. */
ComponentType* getComponent() const noexcept { return dynamic_cast <ComponentType*> (weakRef.get()); }
ComponentType* getComponent() const noexcept { return dynamic_cast<ComponentType*> (weakRef.get()); }
/** Returns the component that this pointer refers to, or null if the component no longer exists. */
operator ComponentType*() const noexcept { return getComponent(); }
operator ComponentType*() const noexcept { return getComponent(); }
/** Returns the component that this pointer refers to, or null if the component no longer exists. */
ComponentType* operator->() noexcept { return getComponent(); }
ComponentType* operator->() noexcept { return getComponent(); }
/** Returns the component that this pointer refers to, or null if the component no longer exists. */
const ComponentType* operator->() const noexcept { return getComponent(); }
const ComponentType* operator->() const noexcept { return getComponent(); }
/** If the component is valid, this deletes it and sets this pointer to null. */
void deleteAndZero() { delete getComponent(); }
void deleteAndZero() { delete getComponent(); }
bool operator== (ComponentType* component) const noexcept { return weakRef == component; }
bool operator!= (ComponentType* component) const noexcept { return weakRef != component; }
@@ -2254,20 +2259,20 @@ private:
String componentName, componentID;
Component* parentComponent;
Rectangle<int> bounds;
ScopedPointer <Positioner> positioner;
ScopedPointer <AffineTransform> affineTransform;
Array <Component*> childComponentList;
ScopedPointer<Positioner> positioner;
ScopedPointer<AffineTransform> affineTransform;
Array<Component*> childComponentList;
LookAndFeel* lookAndFeel;
MouseCursor cursor;
ImageEffectFilter* effect;
ScopedPointer <CachedComponentImage> cachedImage;
ScopedPointer<CachedComponentImage> cachedImage;
class MouseListenerList;
friend class MouseListenerList;
friend struct ContainerDeletePolicy<MouseListenerList>;
ScopedPointer <MouseListenerList> mouseListeners;
ScopedPointer <Array <KeyListener*> > keyListeners;
ListenerList <ComponentListener> componentListeners;
ScopedPointer<MouseListenerList> mouseListeners;
ScopedPointer<Array<KeyListener*> > keyListeners;
ListenerList<ComponentListener> componentListeners;
NamedValueSet properties;
friend class WeakReference<Component>;
@@ -2292,9 +2297,11 @@ private:
bool childCompFocusedFlag : 1;
bool dontClipGraphicsFlag : 1;
bool mouseDownWasBlocked : 1;
#if JUCE_DEBUG
bool isMoveCallbackPending : 1;
bool isResizeCallbackPending : 1;
#if JUCE_DEBUG
bool isInsidePaintCall : 1;
#endif
#endif
};
union
@@ -2306,18 +2313,18 @@ private:
uint8 componentTransparency;
//==============================================================================
void internalMouseEnter (MouseInputSource, Point<int>, Time);
void internalMouseExit (MouseInputSource, Point<int>, Time);
void internalMouseDown (MouseInputSource, Point<int>, Time);
void internalMouseUp (MouseInputSource, Point<int>, Time, const ModifierKeys oldModifiers);
void internalMouseDrag (MouseInputSource, Point<int>, Time);
void internalMouseMove (MouseInputSource, Point<int>, Time);
void internalMouseWheel (MouseInputSource, Point<int>, Time, const MouseWheelDetails&);
void internalMagnifyGesture (MouseInputSource, Point<int>, Time, float);
void internalMouseEnter (MouseInputSource, Point<float>, Time);
void internalMouseExit (MouseInputSource, Point<float>, Time);
void internalMouseDown (MouseInputSource, Point<float>, Time);
void internalMouseUp (MouseInputSource, Point<float>, Time, const ModifierKeys oldModifiers);
void internalMouseDrag (MouseInputSource, Point<float>, Time);
void internalMouseMove (MouseInputSource, Point<float>, Time);
void internalMouseWheel (MouseInputSource, Point<float>, Time, const MouseWheelDetails&);
void internalMagnifyGesture (MouseInputSource, Point<float>, Time, float);
void internalBroughtToFront();
void internalFocusGain (const FocusChangeType, const WeakReference<Component>&);
void internalFocusGain (const FocusChangeType);
void internalFocusLoss (const FocusChangeType);
void internalFocusGain (FocusChangeType, const WeakReference<Component>&);
void internalFocusGain (FocusChangeType);
void internalFocusLoss (FocusChangeType);
void internalChildFocusChange (FocusChangeType, const WeakReference<Component>&);
void internalModalInputAttempt();
void internalModifierKeysChanged();
@@ -2330,6 +2337,7 @@ private:
void paintComponentAndChildren (Graphics&);
void paintWithinParentContext (Graphics&);
void sendMovedResizedMessages (bool wasMoved, bool wasResized);
void sendMovedResizedMessagesIfPending();
void repaintParent();
void sendFakeMouseMove() const;
void takeKeyboardFocus (const FocusChangeType);
@@ -68,6 +68,8 @@ Component* Desktop::getComponent (const int index) const noexcept
Component* Desktop::findComponentAt (Point<int> screenPosition) const
{
ASSERT_MESSAGE_MANAGER_IS_LOCKED
for (int i = desktopComponents.size(); --i >= 0;)
{
Component* const c = desktopComponents.getUnchecked(i);
@@ -100,6 +102,7 @@ LookAndFeel& Desktop::getDefaultLookAndFeel() noexcept
void Desktop::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel)
{
ASSERT_MESSAGE_MANAGER_IS_LOCKED
currentLookAndFeel = newDefaultLookAndFeel;
for (int i = getNumComponents(); --i >= 0;)
@@ -145,18 +148,23 @@ void Desktop::componentBroughtToFront (Component* const c)
//==============================================================================
Point<int> Desktop::getMousePosition()
{
return getMousePositionFloat().roundToInt();
}
Point<float> Desktop::getMousePositionFloat()
{
return getInstance().getMainMouseSource().getScreenPosition();
}
void Desktop::setMousePosition (Point<int> newPosition)
{
getInstance().getMainMouseSource().setScreenPosition (newPosition);
getInstance().getMainMouseSource().setScreenPosition (newPosition.toFloat());
}
Point<int> Desktop::getLastMouseDownPosition()
{
return getInstance().getMainMouseSource().getLastMouseDownPosition();
return getInstance().getMainMouseSource().getLastMouseDownPosition().roundToInt();
}
int Desktop::getMouseButtonClickCounter() const noexcept { return mouseClickCounter; }
@@ -194,10 +202,10 @@ void Desktop::resetTimer()
else
startTimer (100);
lastFakeMouseMove = getMousePosition();
lastFakeMouseMove = getMousePositionFloat();
}
ListenerList <MouseListener>& Desktop::getMouseListeners()
ListenerList<MouseListener>& Desktop::getMouseListeners()
{
resetTimer();
return mouseListeners;
@@ -205,19 +213,21 @@ ListenerList <MouseListener>& Desktop::getMouseListeners()
void Desktop::addGlobalMouseListener (MouseListener* const listener)
{
ASSERT_MESSAGE_MANAGER_IS_LOCKED
mouseListeners.add (listener);
resetTimer();
}
void Desktop::removeGlobalMouseListener (MouseListener* const listener)
{
ASSERT_MESSAGE_MANAGER_IS_LOCKED
mouseListeners.remove (listener);
resetTimer();
}
void Desktop::timerCallback()
{
if (lastFakeMouseMove != getMousePosition())
if (lastFakeMouseMove != getMousePositionFloat())
sendMouseMove();
}
@@ -227,12 +237,12 @@ void Desktop::sendMouseMove()
{
startTimer (20);
lastFakeMouseMove = getMousePosition();
lastFakeMouseMove = getMousePositionFloat();
if (Component* const target = findComponentAt (lastFakeMouseMove))
if (Component* const target = findComponentAt (lastFakeMouseMove.roundToInt()))
{
Component::BailOutChecker checker (target);
const Point<int> pos (target->getLocalPoint (nullptr, lastFakeMouseMove));
const Point<float> pos (target->getLocalPoint (nullptr, lastFakeMouseMove));
const Time now (Time::getCurrentTime());
const MouseEvent me (getMainMouseSource(), pos, ModifierKeys::getCurrentModifiers(),
@@ -253,12 +263,14 @@ Desktop::Displays::~Displays() {}
const Desktop::Displays::Display& Desktop::Displays::getMainDisplay() const noexcept
{
ASSERT_MESSAGE_MANAGER_IS_LOCKED
jassert (displays.getReference(0).isMain);
return displays.getReference(0);
}
const Desktop::Displays::Display& Desktop::Displays::getDisplayContaining (Point<int> position) const noexcept
{
ASSERT_MESSAGE_MANAGER_IS_LOCKED
const Display* best = &displays.getReference(0);
double bestDistance = 1.0e10;
@@ -286,6 +298,7 @@ const Desktop::Displays::Display& Desktop::Displays::getDisplayContaining (Point
RectangleList<int> Desktop::Displays::getRectangleList (bool userAreasOnly) const
{
ASSERT_MESSAGE_MANAGER_IS_LOCKED
RectangleList<int> rl;
for (int i = 0; i < displays.size(); ++i)
@@ -329,6 +342,7 @@ void Desktop::Displays::refresh()
oldDisplays.swapWith (displays);
init (Desktop::getInstance());
jassert (displays.size() > 0);
if (oldDisplays != displays)
{
@@ -391,6 +405,8 @@ bool Desktop::isOrientationEnabled (const DisplayOrientation orientation) const
void Desktop::setGlobalScaleFactor (float newScaleFactor) noexcept
{
ASSERT_MESSAGE_MANAGER_IS_LOCKED
if (masterScaleFactor != newScaleFactor)
{
masterScaleFactor = newScaleFactor;
@@ -414,7 +414,7 @@ private:
ScopedPointer<Displays> displays;
Point<int> lastFakeMouseMove;
Point<float> lastFakeMouseMove;
void sendMouseMove();
int mouseClickCounter, mouseWheelCounter;
@@ -441,11 +441,13 @@ private:
void removeDesktopComponent (Component*);
void componentBroughtToFront (Component*);
void setKioskComponent (Component*, bool enableOrDisable, bool allowMenusAndBars);
void setKioskComponent (Component*, bool shouldBeEnabled, bool allowMenusAndBars);
void triggerFocusCallback();
void handleAsyncUpdate() override;
static Point<float> getMousePositionFloat();
static double getDefaultMasterScale();
Desktop();
@@ -234,6 +234,17 @@ void ModalComponentManager::bringModalComponentsToFront (bool topOneShouldGrabFo
}
}
bool ModalComponentManager::cancelAllModalComponents()
{
const int numModal = getNumModalComponents();
for (int i = numModal; --i >= 0;)
if (Component* const c = getModalComponent(i))
c->exitModalState (0);
return numModal > 0;
}
#if JUCE_MODAL_LOOPS_PERMITTED
class ModalComponentManager::ReturnValueRetriever : public ModalComponentManager::Callback
{
@@ -107,6 +107,11 @@ public:
/** Brings any modal components to the front. */
void bringModalComponentsToFront (bool topOneShouldGrabFocus = true);
/** Calls exitModalState (0) on any components that are currently modal.
@returns true if any components were modal; false if nothing needed cancelling
*/
bool cancelAllModalComponents();
#if JUCE_MODAL_LOOPS_PERMITTED
/** Runs the event loop until the currently topmost modal component is dismissed, and
returns the exit code for that component.