mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
misc cleanups.
This commit is contained in:
parent
05f32e3de6
commit
89d5e19fca
7 changed files with 44 additions and 97 deletions
|
|
@ -345,20 +345,15 @@ var::var (const var& valueToCopy) : type (valueToCopy.type)
|
|||
type->createCopy (value, valueToCopy.value);
|
||||
}
|
||||
|
||||
var::var (const int value_) noexcept : type (&VariantType_Int::instance) { value.intValue = value_; }
|
||||
var::var (const int64 value_) noexcept : type (&VariantType_Int64::instance) { value.int64Value = value_; }
|
||||
var::var (const bool value_) noexcept : type (&VariantType_Bool::instance) { value.boolValue = value_; }
|
||||
var::var (const double value_) noexcept : type (&VariantType_Double::instance) { value.doubleValue = value_; }
|
||||
var::var (MethodFunction method_) noexcept : type (&VariantType_Method::instance) { value.methodValue = method_; }
|
||||
|
||||
var::var (const String& value_) : type (&VariantType_String::instance) { new (value.stringValue) String (value_); }
|
||||
var::var (const char* const value_) : type (&VariantType_String::instance) { new (value.stringValue) String (value_); }
|
||||
var::var (const wchar_t* const value_) : type (&VariantType_String::instance) { new (value.stringValue) String (value_); }
|
||||
|
||||
var::var (const Array<var>& value_) : type (&VariantType_Array::instance)
|
||||
{
|
||||
value.arrayValue = new Array<var> (value_);
|
||||
}
|
||||
var::var (const int v) noexcept : type (&VariantType_Int::instance) { value.intValue = v; }
|
||||
var::var (const int64 v) noexcept : type (&VariantType_Int64::instance) { value.int64Value = v; }
|
||||
var::var (const bool v) noexcept : type (&VariantType_Bool::instance) { value.boolValue = v; }
|
||||
var::var (const double v) noexcept : type (&VariantType_Double::instance) { value.doubleValue = v; }
|
||||
var::var (MethodFunction m) noexcept : type (&VariantType_Method::instance) { value.methodValue = m; }
|
||||
var::var (const Array<var>& v) : type (&VariantType_Array::instance) { value.arrayValue = new Array<var> (v); }
|
||||
var::var (const String& v) : type (&VariantType_String::instance) { new (value.stringValue) String (v); }
|
||||
var::var (const char* const v) : type (&VariantType_String::instance) { new (value.stringValue) String (v); }
|
||||
var::var (const wchar_t* const v) : type (&VariantType_String::instance) { new (value.stringValue) String (v); }
|
||||
|
||||
var::var (ReferenceCountedObject* const object) : type (&VariantType_Object::instance)
|
||||
{
|
||||
|
|
@ -423,9 +418,9 @@ var& var::operator= (var&& other) noexcept
|
|||
return *this;
|
||||
}
|
||||
|
||||
var::var (String&& value_) : type (&VariantType_String::instance)
|
||||
var::var (String&& v) : type (&VariantType_String::instance)
|
||||
{
|
||||
new (value.stringValue) String (static_cast<String&&> (value_));
|
||||
new (value.stringValue) String (static_cast<String&&> (v));
|
||||
}
|
||||
|
||||
var& var::operator= (String&& v)
|
||||
|
|
|
|||
|
|
@ -24,10 +24,8 @@
|
|||
*/
|
||||
|
||||
ComponentBoundsConstrainer::ComponentBoundsConstrainer() noexcept
|
||||
: minW (0),
|
||||
maxW (0x3fffffff),
|
||||
minH (0),
|
||||
maxH (0x3fffffff),
|
||||
: minW (0), maxW (0x3fffffff),
|
||||
minH (0), maxH (0x3fffffff),
|
||||
minOffTop (0),
|
||||
minOffLeft (0),
|
||||
minOffBottom (0),
|
||||
|
|
@ -41,25 +39,10 @@ ComponentBoundsConstrainer::~ComponentBoundsConstrainer()
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void ComponentBoundsConstrainer::setMinimumWidth (const int minimumWidth) noexcept
|
||||
{
|
||||
minW = minimumWidth;
|
||||
}
|
||||
|
||||
void ComponentBoundsConstrainer::setMaximumWidth (const int maximumWidth) noexcept
|
||||
{
|
||||
maxW = maximumWidth;
|
||||
}
|
||||
|
||||
void ComponentBoundsConstrainer::setMinimumHeight (const int minimumHeight) noexcept
|
||||
{
|
||||
minH = minimumHeight;
|
||||
}
|
||||
|
||||
void ComponentBoundsConstrainer::setMaximumHeight (const int maximumHeight) noexcept
|
||||
{
|
||||
maxH = maximumHeight;
|
||||
}
|
||||
void ComponentBoundsConstrainer::setMinimumWidth (const int minimumWidth) noexcept { minW = minimumWidth; }
|
||||
void ComponentBoundsConstrainer::setMaximumWidth (const int maximumWidth) noexcept { maxW = maximumWidth; }
|
||||
void ComponentBoundsConstrainer::setMinimumHeight (const int minimumHeight) noexcept { minH = minimumHeight; }
|
||||
void ComponentBoundsConstrainer::setMaximumHeight (const int maximumHeight) noexcept { maxH = maximumHeight; }
|
||||
|
||||
void ComponentBoundsConstrainer::setMinimumSize (const int minimumWidth, const int minimumHeight) noexcept
|
||||
{
|
||||
|
|
@ -70,11 +53,8 @@ void ComponentBoundsConstrainer::setMinimumSize (const int minimumWidth, const i
|
|||
minW = minimumWidth;
|
||||
minH = minimumHeight;
|
||||
|
||||
if (minW > maxW)
|
||||
maxW = minW;
|
||||
|
||||
if (minH > maxH)
|
||||
maxH = minH;
|
||||
if (minW > maxW) maxW = minW;
|
||||
if (minH > maxH) maxH = minH;
|
||||
}
|
||||
|
||||
void ComponentBoundsConstrainer::setMaximumSize (const int maximumWidth, const int maximumHeight) noexcept
|
||||
|
|
@ -108,10 +88,10 @@ void ComponentBoundsConstrainer::setMinimumOnscreenAmounts (const int minimumWhe
|
|||
const int minimumWhenOffTheBottom,
|
||||
const int minimumWhenOffTheRight) noexcept
|
||||
{
|
||||
minOffTop = minimumWhenOffTheTop;
|
||||
minOffLeft = minimumWhenOffTheLeft;
|
||||
minOffTop = minimumWhenOffTheTop;
|
||||
minOffLeft = minimumWhenOffTheLeft;
|
||||
minOffBottom = minimumWhenOffTheBottom;
|
||||
minOffRight = minimumWhenOffTheRight;
|
||||
minOffRight = minimumWhenOffTheRight;
|
||||
}
|
||||
|
||||
void ComponentBoundsConstrainer::setFixedAspectRatio (const double widthOverHeight) noexcept
|
||||
|
|
@ -136,19 +116,16 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* const compone
|
|||
Rectangle<int> limits, bounds (targetBounds);
|
||||
BorderSize<int> border;
|
||||
|
||||
Component* const parent = component->getParentComponent();
|
||||
|
||||
if (parent == nullptr)
|
||||
if (Component* const parent = component->getParentComponent())
|
||||
{
|
||||
ComponentPeer* peer = component->getPeer();
|
||||
if (peer != nullptr)
|
||||
border = peer->getFrameSize();
|
||||
|
||||
limits = Desktop::getInstance().getDisplays().getDisplayContaining (bounds.getCentre()).userArea;
|
||||
limits.setSize (parent->getWidth(), parent->getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
limits.setSize (parent->getWidth(), parent->getHeight());
|
||||
if (ComponentPeer* const peer = component->getPeer())
|
||||
border = peer->getFrameSize();
|
||||
|
||||
limits = Desktop::getInstance().getDisplays().getDisplayContaining (bounds.getCentre()).userArea;
|
||||
}
|
||||
|
||||
border.addTo (bounds);
|
||||
|
|
@ -172,9 +149,7 @@ void ComponentBoundsConstrainer::checkComponentBounds (Component* component)
|
|||
void ComponentBoundsConstrainer::applyBoundsToComponent (Component* component,
|
||||
const Rectangle<int>& bounds)
|
||||
{
|
||||
Component::Positioner* const positioner = component->getPositioner();
|
||||
|
||||
if (positioner != nullptr)
|
||||
if (Component::Positioner* const positioner = component->getPositioner())
|
||||
positioner->applyNewBounds (bounds);
|
||||
else
|
||||
component->setBounds (bounds);
|
||||
|
|
|
|||
|
|
@ -396,8 +396,7 @@ void DragAndDropContainer::startDragging (const var& sourceDescription,
|
|||
#if JUCE_WINDOWS
|
||||
// Under heavy load, the layered window's paint callback can often be lost by the OS,
|
||||
// so forcing a repaint at least once makes sure that the window becomes visible..
|
||||
ComponentPeer* const peer = dragImageComponent->getPeer();
|
||||
if (peer != nullptr)
|
||||
if (ComponentPeer* const peer = dragImageComponent->getPeer())
|
||||
peer->performAnyPendingRepaintsNow();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,9 +60,7 @@ public:
|
|||
|
||||
Component* findComponentAt (const Point<int>& screenPos)
|
||||
{
|
||||
ComponentPeer* const peer = getPeer();
|
||||
|
||||
if (peer != nullptr)
|
||||
if (ComponentPeer* const peer = getPeer())
|
||||
{
|
||||
Component& comp = peer->getComponent();
|
||||
const Point<int> relativePos (comp.getLocalPoint (nullptr, screenPos));
|
||||
|
|
@ -148,9 +146,7 @@ public:
|
|||
|
||||
if (buttonState.isAnyMouseButtonDown())
|
||||
{
|
||||
Component* const current = getComponentUnderMouse();
|
||||
|
||||
if (current != nullptr)
|
||||
if (Component* const current = getComponentUnderMouse())
|
||||
{
|
||||
const ModifierKeys oldMods (getCurrentModifiers());
|
||||
buttonState = newButtonState; // must change this before calling sendMouseUp, in case it runs a modal loop
|
||||
|
|
@ -167,9 +163,7 @@ public:
|
|||
{
|
||||
Desktop::getInstance().incrementMouseClickCounter();
|
||||
|
||||
Component* const current = getComponentUnderMouse();
|
||||
|
||||
if (current != nullptr)
|
||||
if (Component* const current = getComponentUnderMouse())
|
||||
{
|
||||
registerMouseDown (screenPos, time, current, buttonState);
|
||||
sendMouseDown (current, screenPos, time);
|
||||
|
|
@ -232,11 +226,9 @@ public:
|
|||
if (newScreenPos != lastScreenPos || forceUpdate)
|
||||
{
|
||||
cancelPendingUpdate();
|
||||
|
||||
lastScreenPos = newScreenPos;
|
||||
Component* const current = getComponentUnderMouse();
|
||||
|
||||
if (current != nullptr)
|
||||
if (Component* const current = getComponentUnderMouse())
|
||||
{
|
||||
if (isDragging())
|
||||
{
|
||||
|
|
@ -272,8 +264,7 @@ public:
|
|||
{
|
||||
setPeer (newPeer, screenPos, time);
|
||||
|
||||
ComponentPeer* peer = getPeer();
|
||||
if (peer != nullptr)
|
||||
if (ComponentPeer* peer = getPeer())
|
||||
{
|
||||
if (setButtons (screenPos, time, newMods))
|
||||
return; // some modal events have been dispatched, so the current event is now out-of-date
|
||||
|
|
@ -300,8 +291,7 @@ public:
|
|||
|
||||
if (! isDragging())
|
||||
{
|
||||
Component* current = getComponentUnderMouse();
|
||||
if (current != nullptr)
|
||||
if (Component* current = getComponentUnderMouse())
|
||||
sendMouseWheel (current, screenPos, time, wheel);
|
||||
}
|
||||
}
|
||||
|
|
@ -359,8 +349,7 @@ public:
|
|||
if ((! enable) && ((! isCursorVisibleUntilOffscreen) || ! unboundedMouseOffset.isOrigin()))
|
||||
{
|
||||
// when released, return the mouse to within the component's bounds
|
||||
Component* current = getComponentUnderMouse();
|
||||
if (current != nullptr)
|
||||
if (Component* current = getComponentUnderMouse())
|
||||
Desktop::setMousePosition (current->getScreenBounds()
|
||||
.getConstrainedPoint (lastScreenPos));
|
||||
}
|
||||
|
|
@ -416,8 +405,7 @@ public:
|
|||
{
|
||||
MouseCursor mc (MouseCursor::NormalCursor);
|
||||
|
||||
Component* current = getComponentUnderMouse();
|
||||
if (current != nullptr)
|
||||
if (Component* current = getComponentUnderMouse())
|
||||
mc = current->getLookAndFeel().getMouseCursorFor (*current);
|
||||
|
||||
showMouseCursor (mc, forcedUpdate);
|
||||
|
|
|
|||
|
|
@ -965,9 +965,7 @@ void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDis
|
|||
|
||||
displays.refresh();
|
||||
|
||||
ComponentPeer* const peer = kioskModeComponent->getPeer();
|
||||
|
||||
if (peer != nullptr)
|
||||
if (ComponentPeer* const peer = kioskModeComponent->getPeer())
|
||||
peer->setFullScreen (enableOrDisable);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -343,8 +343,7 @@ void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer
|
|||
|
||||
setResizable (shouldBeResizable, useBottomRightCornerResizer);
|
||||
|
||||
ComponentPeer* const peer = getPeer();
|
||||
if (peer != nullptr)
|
||||
if (ComponentPeer* const peer = getPeer())
|
||||
peer->setConstrainer (newConstrainer);
|
||||
}
|
||||
}
|
||||
|
|
@ -393,8 +392,7 @@ void ResizableWindow::lookAndFeelChanged()
|
|||
{
|
||||
Component::addToDesktop (getDesktopWindowStyleFlags());
|
||||
|
||||
ComponentPeer* const peer = getPeer();
|
||||
if (peer != nullptr)
|
||||
if (ComponentPeer* const peer = getPeer())
|
||||
peer->setConstrainer (constrainer);
|
||||
}
|
||||
}
|
||||
|
|
@ -438,9 +436,7 @@ void ResizableWindow::setFullScreen (const bool shouldBeFullScreen)
|
|||
|
||||
if (isOnDesktop())
|
||||
{
|
||||
ComponentPeer* const peer = getPeer();
|
||||
|
||||
if (peer != nullptr)
|
||||
if (ComponentPeer* const peer = getPeer())
|
||||
{
|
||||
// keep a copy of this intact in case the real one gets messed-up while we're un-maximising
|
||||
const Rectangle<int> lastPos (lastNonFullScreenPos);
|
||||
|
|
@ -478,9 +474,7 @@ void ResizableWindow::setMinimised (const bool shouldMinimise)
|
|||
{
|
||||
if (shouldMinimise != isMinimised())
|
||||
{
|
||||
ComponentPeer* const peer = getPeer();
|
||||
|
||||
if (peer != nullptr)
|
||||
if (ComponentPeer* const peer = getPeer())
|
||||
{
|
||||
updateLastPos();
|
||||
peer->setMinimised (shouldMinimise);
|
||||
|
|
|
|||
|
|
@ -283,9 +283,7 @@ public:
|
|||
case WM_RBUTTONDBLCLK:
|
||||
if (ax->isShowing())
|
||||
{
|
||||
ComponentPeer* const peer = ax->getPeer();
|
||||
|
||||
if (peer != nullptr)
|
||||
if (ComponentPeer* const peer = ax->getPeer())
|
||||
{
|
||||
ActiveXHelpers::offerActiveXMouseEventToPeer (peer, hwnd, message, lParam);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue