Browse Source

Improvements to ComponentMovementWatcher to check visibility. TopLevelWindow activation fix. Changed MidiMessage default constructor to an empty sysex.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
e05f6a2b95
22 changed files with 318 additions and 343 deletions
  1. +0
    -8
      extras/Jucer (experimental)/Source/Application/jucer_FilePreviewComponent.cpp
  2. +0
    -4
      extras/Jucer (experimental)/Source/Application/jucer_FilePreviewComponent.h
  3. +144
    -162
      juce_amalgamated.cpp
  4. +16
    -4
      juce_amalgamated.h
  5. +13
    -24
      src/audio/midi/juce_MidiMessage.cpp
  6. +1
    -1
      src/audio/midi/juce_MidiMessage.h
  7. +6
    -14
      src/audio/plugins/formats/juce_VSTPluginFormat.cpp
  8. +1
    -1
      src/core/juce_StandardHeader.h
  9. +1
    -1
      src/gui/components/juce_Component.cpp
  10. +2
    -1
      src/gui/components/juce_Component.h
  11. +14
    -17
      src/gui/components/juce_ModalComponentManager.cpp
  12. +43
    -19
      src/gui/components/layout/juce_ComponentMovementWatcher.cpp
  13. +9
    -2
      src/gui/components/layout/juce_ComponentMovementWatcher.h
  14. +2
    -2
      src/gui/components/layout/juce_Viewport.cpp
  15. +5
    -14
      src/gui/components/special/juce_OpenGLComponent.cpp
  16. +10
    -0
      src/gui/components/windows/juce_TopLevelWindow.cpp
  17. +2
    -0
      src/gui/components/windows/juce_TopLevelWindow.h
  18. +1
    -1
      src/native/mac/juce_mac_CarbonViewWrapperComponent.h
  19. +17
    -17
      src/native/mac/juce_mac_NSViewComponent.mm
  20. +2
    -4
      src/native/mac/juce_mac_OpenGLComponent.mm
  21. +11
    -18
      src/native/windows/juce_win32_ActiveXComponent.cpp
  22. +18
    -29
      src/native/windows/juce_win32_WebBrowserComponent.cpp

+ 0
- 8
extras/Jucer (experimental)/Source/Application/jucer_FilePreviewComponent.cpp View File

@@ -34,10 +34,6 @@ ItemPreviewComponent::ItemPreviewComponent (const File& file_)
tryToLoadImage();
}
ItemPreviewComponent::~ItemPreviewComponent()
{
}
void ItemPreviewComponent::tryToLoadImage()
{
facts.clear();
@@ -79,7 +75,3 @@ void ItemPreviewComponent::paint (Graphics& g)
g.drawMultiLineText (facts.joinIntoString ("\n"),
10, 15, getWidth() - 16);
}
void ItemPreviewComponent::resized()
{
}

+ 0
- 4
extras/Jucer (experimental)/Source/Application/jucer_FilePreviewComponent.h View File

@@ -34,13 +34,9 @@ class ItemPreviewComponent : public Component
{
public:
//==============================================================================
// This will delete the stream
ItemPreviewComponent (const File& file);
~ItemPreviewComponent();
void paint (Graphics& g);
void resized();
private:
StringArray facts;


+ 144
- 162
juce_amalgamated.cpp View File

@@ -1127,7 +1127,7 @@ public:
createWindow();
}

void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
if (isShowing())
createWindow();
@@ -28580,9 +28580,7 @@ int MidiMessage::readVariableLengthVal (const uint8* data, int& numBytesUsed) th
int MidiMessage::getMessageLengthFromFirstByte (const uint8 firstByte) throw()
{
// this method only works for valid starting bytes of a short midi message
jassert (firstByte >= 0x80
&& firstByte != 0xf0
&& firstByte != 0xf7);
jassert (firstByte >= 0x80 && firstByte != 0xf0 && firstByte != 0xf7);

static const char messageLengths[] =
{
@@ -28602,9 +28600,10 @@ int MidiMessage::getMessageLengthFromFirstByte (const uint8 firstByte) throw()
MidiMessage::MidiMessage() throw()
: timeStamp (0),
data (static_cast<uint8*> (preallocatedData.asBytes)),
size (1)
size (2)
{
data[0] = 0xfe;
data[0] = 0xf0;
data[1] = 0xf7;
}

MidiMessage::MidiMessage (const void* const d, const int dataSize, const double t)
@@ -29040,8 +29039,7 @@ const MidiMessage MidiMessage::allNotesOff (const int channel) throw()

bool MidiMessage::isAllNotesOff() const throw()
{
return (data[0] & 0xf0) == 0xb0
&& data[1] == 123;
return (data[0] & 0xf0) == 0xb0 && data[1] == 123;
}

const MidiMessage MidiMessage::allSoundOff (const int channel) throw()
@@ -29051,8 +29049,7 @@ const MidiMessage MidiMessage::allSoundOff (const int channel) throw()

bool MidiMessage::isAllSoundOff() const throw()
{
return (data[0] & 0xf0) == 0xb0
&& data[1] == 120;
return (data[0] & 0xf0) == 0xb0 && data[1] == 120;
}

const MidiMessage MidiMessage::allControllersOff (const int channel) throw()
@@ -29096,12 +29093,12 @@ const MidiMessage MidiMessage::createSysExMessage (const uint8* sysexData, const

const uint8* MidiMessage::getSysExData() const throw()
{
return (isSysEx()) ? getRawData() + 1 : 0;
return isSysEx() ? getRawData() + 1 : 0;
}

int MidiMessage::getSysExDataSize() const throw()
{
return (isSysEx()) ? size - 2 : 0;
return isSysEx() ? size - 2 : 0;
}

bool MidiMessage::isMetaEvent() const throw()
@@ -29116,10 +29113,7 @@ bool MidiMessage::isActiveSense() const throw()

int MidiMessage::getMetaEventType() const throw()
{
if (*data != 0xff)
return -1;
else
return data[1];
return *data != 0xff ? -1 : data[1];
}

int MidiMessage::getMetaEventLength() const throw()
@@ -29165,21 +29159,17 @@ const String MidiMessage::getTextFromTextMetaEvent() const

bool MidiMessage::isTrackNameEvent() const throw()
{
return (data[1] == 3)
&& (*data == 0xff);
return (data[1] == 3) && (*data == 0xff);
}

bool MidiMessage::isTempoMetaEvent() const throw()
{
return (data[1] == 81)
&& (*data == 0xff);
return (data[1] == 81) && (*data == 0xff);
}

bool MidiMessage::isMidiChannelMetaEvent() const throw()
{
return (data[1] == 0x20)
&& (*data == 0xff)
&& (data[2] == 1);
return (data[1] == 0x20) && (*data == 0xff) && (data[2] == 1);
}

int MidiMessage::getMidiChannelMetaEventChannel() const throw()
@@ -29242,8 +29232,7 @@ const MidiMessage MidiMessage::tempoMetaEvent (int microsecondsPerQuarterNote) t

bool MidiMessage::isTimeSignatureMetaEvent() const throw()
{
return (data[1] == 0x58)
&& (*data == (uint8) 0xff);
return (data[1] == 0x58) && (*data == (uint8) 0xff);
}

void MidiMessage::getTimeSignatureInfo (int& numerator, int& denominator) const throw()
@@ -33884,7 +33873,6 @@ public:
#endif
plugin (plugin_),
isOpen (false),
wasShowing (false),
recursiveResize (false),
pluginWantsKeys (false),
pluginRefusesToResize (false),
@@ -33948,19 +33936,12 @@ public:
}
}

void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
const bool isShowingNow = isShowing();

if (wasShowing != isShowingNow)
{
wasShowing = isShowingNow;

if (isShowingNow)
openPluginWindow();
else
closePluginWindow();
}
if (isShowing())
openPluginWindow();
else
closePluginWindow();

componentMovedOrResized (true, true);
}
@@ -34095,7 +34076,7 @@ public:

private:
VSTPluginInstance& plugin;
bool isOpen, wasShowing, recursiveResize;
bool isOpen, recursiveResize;
bool pluginWantsKeys, pluginRefusesToResize, alreadyInside;

#if JUCE_WINDOWS
@@ -41064,7 +41045,7 @@ void Component::enterModalState (const bool shouldTakeKeyboardFocus, ModalCompon

void Component::exitModalState (const int returnValue)
{
if (isCurrentlyModal())
if (flags.currentlyModalFlag)
{
if (MessageManager::getInstance()->isThisTheMessageThread())
{
@@ -42884,40 +42865,36 @@ END_JUCE_NAMESPACE
/*** Start of inlined file: juce_ModalComponentManager.cpp ***/
BEGIN_JUCE_NAMESPACE

class ModalComponentManager::ModalItem : public ComponentListener
class ModalComponentManager::ModalItem : public ComponentMovementWatcher
{
public:
ModalItem (Component* const comp, Callback* const callback)
: component (comp), returnValue (0), isActive (true), isDeleted (false)
: ComponentMovementWatcher (comp),
component (comp), returnValue (0), isActive (true)
{
jassert (comp != 0);

if (callback != 0)
callbacks.add (callback);

jassert (comp != 0);
component->addComponentListener (this);
}

~ModalItem()
{
if (! isDeleted)
component->removeComponentListener (this);
}
void componentMovedOrResized (bool, bool) {}

void componentBeingDeleted (Component&)
void componentPeerChanged()
{
isDeleted = true;
cancel();
if (! component->isShowing())
cancel();
}

void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
if (! component->isShowing())
cancel();
}

void componentParentHierarchyChanged (Component&)
void componentBeingDeleted (Component& comp)
{
if (! component->isShowing())
if (component == &comp || comp.isParentOf (component))
cancel();
}

@@ -42933,7 +42910,7 @@ public:
Component* component;
OwnedArray<Callback> callbacks;
int returnValue;
bool isActive, isDeleted;
bool isActive;

private:
JUCE_DECLARE_NON_COPYABLE (ModalItem);
@@ -61892,7 +61869,8 @@ BEGIN_JUCE_NAMESPACE
ComponentMovementWatcher::ComponentMovementWatcher (Component* const component_)
: component (component_),
lastPeer (0),
reentrant (false)
reentrant (false),
wasShowing (component_->isShowing())
{
jassert (component != 0); // can't use this with a null pointer..

@@ -61903,17 +61881,15 @@ ComponentMovementWatcher::ComponentMovementWatcher (Component* const component_)

ComponentMovementWatcher::~ComponentMovementWatcher()
{
component->removeComponentListener (this);
if (component != 0)
component->removeComponentListener (this);

unregister();
}

void ComponentMovementWatcher::componentParentHierarchyChanged (Component&)
{
// agh! don't delete the target component without deleting this object first!
jassert (component != 0);

if (! reentrant)
if (component != 0 && ! reentrant)
{
reentrant = true;

@@ -61932,30 +61908,55 @@ void ComponentMovementWatcher::componentParentHierarchyChanged (Component&)
unregister();
registerWithParentComps();

reentrant = false;

componentMovedOrResized (*component, true, true);

if (component != 0)
componentVisibilityChanged (*component);

reentrant = false;
}
}

void ComponentMovementWatcher::componentMovedOrResized (Component&, bool wasMoved, bool wasResized)
{
// agh! don't delete the target component without deleting this object first!
jassert (component != 0);

if (wasMoved)
if (component != 0)
{
const Point<int> pos (component->getTopLevelComponent()->getLocalPoint (component, Point<int>()));
if (wasMoved)
{
const Point<int> pos (component->getTopLevelComponent()->getLocalPoint (component, Point<int>()));

wasMoved = lastBounds.getPosition() != pos;
lastBounds.setPosition (pos);
}

wasMoved = lastBounds.getPosition() != pos;
lastBounds.setPosition (pos);
wasResized = (lastBounds.getWidth() != component->getWidth() || lastBounds.getHeight() != component->getHeight());
lastBounds.setSize (component->getWidth(), component->getHeight());

if (wasMoved || wasResized)
componentMovedOrResized (wasMoved, wasResized);
}
}

wasResized = (lastBounds.getWidth() != component->getWidth() || lastBounds.getHeight() != component->getHeight());
lastBounds.setSize (component->getWidth(), component->getHeight());
void ComponentMovementWatcher::componentBeingDeleted (Component& comp)
{
registeredParentComps.removeValue (&comp);

if (wasMoved || wasResized)
componentMovedOrResized (wasMoved, wasResized);
if (component == &comp)
unregister();
}

void ComponentMovementWatcher::componentVisibilityChanged (Component&)
{
if (component != 0)
{
const bool isShowingNow = component->isShowing();

if (wasShowing != isShowingNow)
{
wasShowing = isShowingNow;
componentVisibilityChanged();
}
}
}

void ComponentMovementWatcher::registerWithParentComps()
@@ -64649,7 +64650,7 @@ void Viewport::updateVisibleArea()
horizontalScrollBar.setSingleStepSize (singleStepX);
horizontalScrollBar.cancelPendingUpdate();
}
else
else if (canShowHBar)
{
visibleOrigin.setX (0);
}
@@ -64662,7 +64663,7 @@ void Viewport::updateVisibleArea()
verticalScrollBar.setSingleStepSize (singleStepY);
verticalScrollBar.cancelPendingUpdate();
}
else
else if (canShowVBar)
{
visibleOrigin.setY (0);
}
@@ -75632,8 +75633,7 @@ public:

OpenGLComponentWatcher (OpenGLComponent* const owner_)
: ComponentMovementWatcher (owner_),
owner (owner_),
wasShowing (false)
owner (owner_)
{
}

@@ -75648,25 +75648,17 @@ public:
owner->deleteContext();
}

void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
const bool isShowingNow = owner->isShowing();

if (wasShowing != isShowingNow)
if (! owner->isShowing())
{
wasShowing = isShowingNow;

if (! isShowingNow)
{
const ScopedLock sl (owner->getContextLock());
owner->deleteContext();
}
const ScopedLock sl (owner->getContextLock());
owner->deleteContext();
}
}

private:
OpenGLComponent* const owner;
bool wasShowing;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLComponentWatcher);
};
@@ -78819,6 +78811,16 @@ void TopLevelWindow::activeWindowStatusChanged()
{
}

void TopLevelWindow::visibilityChanged()
{
if (isShowing()
&& (getPeer()->getStyleFlags() & (ComponentPeer::windowIsTemporary
| ComponentPeer::windowIgnoresKeyPresses)) == 0)
{
toFront (true);
}
}

void TopLevelWindow::parentHierarchyChanged()
{
setDropShadowEnabled (useDropShadow);
@@ -245117,19 +245119,11 @@ namespace ActiveXHelpers

class ActiveXControlComponent::Pimpl : public ComponentMovementWatcher
{
ActiveXControlComponent& owner;
bool wasShowing;

public:
HWND controlHWND;
IStorage* storage;
IOleClientSite* clientSite;
IOleObject* control;

Pimpl (HWND hwnd, ActiveXControlComponent& owner_)
: ComponentMovementWatcher (&owner_),
owner (owner_),
wasShowing (owner_.isShowing()),
controlHWND (0),
storage (new ActiveXHelpers::JuceIStorage()),
clientSite (new ActiveXHelpers::JuceIOleClientSite (hwnd)),
@@ -245162,19 +245156,12 @@ public:

void componentPeerChanged()
{
const bool isShowingNow = owner.isShowing();

if (wasShowing != isShowingNow)
{
wasShowing = isShowingNow;
owner.setControlVisible (isShowingNow);
}

componentMovedOrResized (true, true);
}

void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
owner.setControlVisible (owner.isShowing());
componentPeerChanged();
}

@@ -245223,6 +245210,15 @@ public:

return DefWindowProc (hwnd, message, wParam, lParam);
}

private:
ActiveXControlComponent& owner;

public:
HWND controlHWND;
IStorage* storage;
IOleClientSite* clientSite;
IOleObject* control;
};

ActiveXControlComponent::ActiveXControlComponent()
@@ -245837,7 +245833,7 @@ public:
WebBrowserComponent* const owner = dynamic_cast <WebBrowserComponent*> (getParentComponent());
jassert (owner != 0);

EventHandler* handler = new EventHandler (owner);
EventHandler* handler = new EventHandler (*owner);
connectionPoint->Advise (handler, &adviseCookie);
handler->Release();
}
@@ -245913,8 +245909,8 @@ private:
public ComponentMovementWatcher
{
public:
EventHandler (WebBrowserComponent* const owner_)
: ComponentMovementWatcher (owner_),
EventHandler (WebBrowserComponent& owner_)
: ComponentMovementWatcher (&owner_),
owner (owner_)
{
}
@@ -245926,43 +245922,32 @@ private:
HRESULT __stdcall Invoke (DISPID dispIdMember, REFIID /*riid*/, LCID /*lcid*/, WORD /*wFlags*/, DISPPARAMS* pDispParams,
VARIANT* /*pVarResult*/, EXCEPINFO* /*pExcepInfo*/, UINT* /*puArgErr*/)
{
switch (dispIdMember)
if (dispIdMember == DISPID_BEFORENAVIGATE2)
{
case DISPID_BEFORENAVIGATE2:
{
VARIANT* const vurl = pDispParams->rgvarg[5].pvarVal;
VARIANT* const vurl = pDispParams->rgvarg[5].pvarVal;
String url;

String url;

if ((vurl->vt & VT_BYREF) != 0)
url = *vurl->pbstrVal;
else
url = vurl->bstrVal;

*pDispParams->rgvarg->pboolVal
= owner->pageAboutToLoad (url) ? VARIANT_FALSE
: VARIANT_TRUE;
if ((vurl->vt & VT_BYREF) != 0)
url = *vurl->pbstrVal;
else
url = vurl->bstrVal;

return S_OK;
}
*pDispParams->rgvarg->pboolVal
= owner.pageAboutToLoad (url) ? VARIANT_FALSE
: VARIANT_TRUE;

default:
break;
return S_OK;
}

return E_NOTIMPL;
}

void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) {}
void componentPeerChanged() {}

void componentVisibilityChanged (Component&)
{
owner->visibilityChanged();
}
void componentMovedOrResized (bool, bool ) {}
void componentPeerChanged() {}
void componentVisibilityChanged() { owner.visibilityChanged(); }

private:
WebBrowserComponent* const owner;
WebBrowserComponent& owner;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EventHandler);
};
@@ -268154,14 +268139,12 @@ BEGIN_JUCE_NAMESPACE
class WindowedGLContext : public OpenGLContext
{
public:
WindowedGLContext (Component* const component,
WindowedGLContext (Component& component,
const OpenGLPixelFormat& pixelFormat_,
NSOpenGLContext* sharedContext)
: renderContext (0),
pixelFormat (pixelFormat_)
{
jassert (component != 0);

NSOpenGLPixelFormatAttribute attribs [64];
int n = 0;
attribs[n++] = NSOpenGLPFADoubleBuffer;
@@ -268300,7 +268283,7 @@ private:

OpenGLContext* OpenGLComponent::createContext()
{
ScopedPointer<WindowedGLContext> c (new WindowedGLContext (this, preferredPixelFormat,
ScopedPointer<WindowedGLContext> c (new WindowedGLContext (*this, preferredPixelFormat,
contextToShareListsWith != 0 ? (NSOpenGLContext*) contextToShareListsWith->getRawContext() : 0));

return (c->renderContext != 0) ? c.release() : 0;
@@ -273310,23 +273293,17 @@ void MouseCursor::showInWindow (ComponentPeer*) const {}

class NSViewComponentInternal : public ComponentMovementWatcher
{
Component* const owner;
NSViewComponentPeer* currentPeer;
bool wasShowing;

public:
NSView* const view;

NSViewComponentInternal (NSView* const view_, Component* const owner_)
: ComponentMovementWatcher (owner_),
NSViewComponentInternal (NSView* const view_, Component& owner_)
: ComponentMovementWatcher (&owner_),
owner (owner_),
currentPeer (0),
wasShowing (false),
view (view_)
{
[view_ retain];

if (owner_->isShowing())
if (owner.isShowing())
componentPeerChanged();
}

@@ -273350,13 +273327,13 @@ public:

void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/)
{
Component* const topComp = owner->getTopLevelComponent();
Component* const topComp = owner.getTopLevelComponent();

if (topComp->getPeer() != 0)
{
const Point<int> pos (topComp->getLocalPoint (owner, Point<int>()));
const Point<int> pos (topComp->getLocalPoint (&owner, Point<int>()));

NSRect r = NSMakeRect ((float) pos.getX(), (float) pos.getY(), (float) owner->getWidth(), (float) owner->getHeight());
NSRect r = NSMakeRect ((float) pos.getX(), (float) pos.getY(), (float) owner.getWidth(), (float) owner.getHeight());
r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height);

[view setFrame: r];
@@ -273365,7 +273342,7 @@ public:

void componentPeerChanged()
{
NSViewComponentPeer* const peer = dynamic_cast <NSViewComponentPeer*> (owner->getPeer());
NSViewComponentPeer* const peer = dynamic_cast <NSViewComponentPeer*> (owner.getPeer());

if (currentPeer != peer)
{
@@ -273382,10 +273359,10 @@ public:
}
}

[view setHidden: ! owner->isShowing()];
[view setHidden: ! owner.isShowing()];
}

void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
componentPeerChanged();
}
@@ -273396,6 +273373,13 @@ public:
return Rectangle<int> (0, 0, (int) r.size.width, (int) r.size.height);
}

private:
Component& owner;
NSViewComponentPeer* currentPeer;

public:
NSView* const view;

private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NSViewComponentInternal);
};
@@ -273413,7 +273397,7 @@ void NSViewComponent::setView (void* view)
if (view != getView())
{
if (view != 0)
info = new NSViewComponentInternal ((NSView*) view, this);
info = new NSViewComponentInternal ((NSView*) view, *this);
else
info = 0;
}
@@ -273782,14 +273766,12 @@ BEGIN_JUCE_NAMESPACE
class WindowedGLContext : public OpenGLContext
{
public:
WindowedGLContext (Component* const component,
WindowedGLContext (Component& component,
const OpenGLPixelFormat& pixelFormat_,
NSOpenGLContext* sharedContext)
: renderContext (0),
pixelFormat (pixelFormat_)
{
jassert (component != 0);

NSOpenGLPixelFormatAttribute attribs [64];
int n = 0;
attribs[n++] = NSOpenGLPFADoubleBuffer;
@@ -273928,7 +273910,7 @@ private:

OpenGLContext* OpenGLComponent::createContext()
{
ScopedPointer<WindowedGLContext> c (new WindowedGLContext (this, preferredPixelFormat,
ScopedPointer<WindowedGLContext> c (new WindowedGLContext (*this, preferredPixelFormat,
contextToShareListsWith != 0 ? (NSOpenGLContext*) contextToShareListsWith->getRawContext() : 0));

return (c->renderContext != 0) ? c.release() : 0;


+ 16
- 4
juce_amalgamated.h View File

@@ -73,7 +73,7 @@ namespace JuceDummyNamespace {}
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 10
#define JUCE_BUILDNUMBER 11

/** Current Juce version number.

@@ -27916,7 +27916,8 @@ public:
the graphics context that gets passed to the component's paint() callback.
If you enable this mode, you'll need to make sure your paint method doesn't call anything like
Graphics::fillAll(), and doesn't draw beyond the component's bounds, because that'll produce
artifacts.
artifacts. Your component also can't have any child components that may be placed beyond its
bounds.
*/
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) throw();

@@ -35475,7 +35476,7 @@ public:

/** Creates an active-sense message.
Since the MidiMessage has to contain a valid message, this default constructor
just initialises it with a simple one-byte active-sense message.
just initialises it with an empty sysex message.
*/
MidiMessage() throw();

@@ -51903,6 +51904,8 @@ protected:
virtual int getDesktopWindowStyleFlags() const;
/** @internal */
void recreateDesktopWindow();
/** @internal */
void visibilityChanged();

private:
friend class TopLevelWindowManager;
@@ -54066,17 +54069,26 @@ public:
/** This callback happens when the component's top-level peer is changed. */
virtual void componentPeerChanged() = 0;

/** This callback happens when the component's visibility state changes, possibly due to
one of its parents being made visible or invisible.
*/
virtual void componentVisibilityChanged() = 0;

/** @internal */
void componentParentHierarchyChanged (Component& component);
/** @internal */
void componentMovedOrResized (Component& component, bool wasMoved, bool wasResized);
/** @internal */
void componentBeingDeleted (Component& component);
/** @internal */
void componentVisibilityChanged (Component& component);

private:

WeakReference<Component> component;
ComponentPeer* lastPeer;
Array <Component*> registeredParentComps;
bool reentrant;
bool reentrant, wasShowing;
Rectangle<int> lastBounds;

void unregister();


+ 13
- 24
src/audio/midi/juce_MidiMessage.cpp View File

@@ -55,9 +55,7 @@ int MidiMessage::readVariableLengthVal (const uint8* data, int& numBytesUsed) th
int MidiMessage::getMessageLengthFromFirstByte (const uint8 firstByte) throw()
{
// this method only works for valid starting bytes of a short midi message
jassert (firstByte >= 0x80
&& firstByte != 0xf0
&& firstByte != 0xf7);
jassert (firstByte >= 0x80 && firstByte != 0xf0 && firstByte != 0xf7);
static const char messageLengths[] =
{
@@ -78,9 +76,10 @@ int MidiMessage::getMessageLengthFromFirstByte (const uint8 firstByte) throw()
MidiMessage::MidiMessage() throw()
: timeStamp (0),
data (static_cast<uint8*> (preallocatedData.asBytes)),
size (1)
size (2)
{
data[0] = 0xfe;
data[0] = 0xf0;
data[1] = 0xf7;
}
MidiMessage::MidiMessage (const void* const d, const int dataSize, const double t)
@@ -516,8 +515,7 @@ const MidiMessage MidiMessage::allNotesOff (const int channel) throw()
bool MidiMessage::isAllNotesOff() const throw()
{
return (data[0] & 0xf0) == 0xb0
&& data[1] == 123;
return (data[0] & 0xf0) == 0xb0 && data[1] == 123;
}
const MidiMessage MidiMessage::allSoundOff (const int channel) throw()
@@ -527,8 +525,7 @@ const MidiMessage MidiMessage::allSoundOff (const int channel) throw()
bool MidiMessage::isAllSoundOff() const throw()
{
return (data[0] & 0xf0) == 0xb0
&& data[1] == 120;
return (data[0] & 0xf0) == 0xb0 && data[1] == 120;
}
const MidiMessage MidiMessage::allControllersOff (const int channel) throw()
@@ -573,12 +570,12 @@ const MidiMessage MidiMessage::createSysExMessage (const uint8* sysexData, const
const uint8* MidiMessage::getSysExData() const throw()
{
return (isSysEx()) ? getRawData() + 1 : 0;
return isSysEx() ? getRawData() + 1 : 0;
}
int MidiMessage::getSysExDataSize() const throw()
{
return (isSysEx()) ? size - 2 : 0;
return isSysEx() ? size - 2 : 0;
}
bool MidiMessage::isMetaEvent() const throw()
@@ -594,10 +591,7 @@ bool MidiMessage::isActiveSense() const throw()
//==============================================================================
int MidiMessage::getMetaEventType() const throw()
{
if (*data != 0xff)
return -1;
else
return data[1];
return *data != 0xff ? -1 : data[1];
}
int MidiMessage::getMetaEventLength() const throw()
@@ -643,21 +637,17 @@ const String MidiMessage::getTextFromTextMetaEvent() const
bool MidiMessage::isTrackNameEvent() const throw()
{
return (data[1] == 3)
&& (*data == 0xff);
return (data[1] == 3) && (*data == 0xff);
}
bool MidiMessage::isTempoMetaEvent() const throw()
{
return (data[1] == 81)
&& (*data == 0xff);
return (data[1] == 81) && (*data == 0xff);
}
bool MidiMessage::isMidiChannelMetaEvent() const throw()
{
return (data[1] == 0x20)
&& (*data == 0xff)
&& (data[2] == 1);
return (data[1] == 0x20) && (*data == 0xff) && (data[2] == 1);
}
int MidiMessage::getMidiChannelMetaEventChannel() const throw()
@@ -720,8 +710,7 @@ const MidiMessage MidiMessage::tempoMetaEvent (int microsecondsPerQuarterNote) t
bool MidiMessage::isTimeSignatureMetaEvent() const throw()
{
return (data[1] == 0x58)
&& (*data == (uint8) 0xff);
return (data[1] == 0x58) && (*data == (uint8) 0xff);
}
void MidiMessage::getTimeSignatureInfo (int& numerator, int& denominator) const throw()


+ 1
- 1
src/audio/midi/juce_MidiMessage.h View File

@@ -92,7 +92,7 @@ public:
/** Creates an active-sense message.
Since the MidiMessage has to contain a valid message, this default constructor
just initialises it with a simple one-byte active-sense message.
just initialises it with an empty sysex message.
*/
MidiMessage() throw();


+ 6
- 14
src/audio/plugins/formats/juce_VSTPluginFormat.cpp View File

@@ -1151,7 +1151,6 @@ public:
#endif
plugin (plugin_),
isOpen (false),
wasShowing (false),
recursiveResize (false),
pluginWantsKeys (false),
pluginRefusesToResize (false),
@@ -1216,19 +1215,12 @@ public:
}
}
void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
const bool isShowingNow = isShowing();
if (wasShowing != isShowingNow)
{
wasShowing = isShowingNow;
if (isShowingNow)
openPluginWindow();
else
closePluginWindow();
}
if (isShowing())
openPluginWindow();
else
closePluginWindow();
componentMovedOrResized (true, true);
}
@@ -1368,7 +1360,7 @@ public:
//==============================================================================
private:
VSTPluginInstance& plugin;
bool isOpen, wasShowing, recursiveResize;
bool isOpen, recursiveResize;
bool pluginWantsKeys, pluginRefusesToResize, alreadyInside;
#if JUCE_WINDOWS


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

@@ -33,7 +33,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 53
#define JUCE_BUILDNUMBER 10
#define JUCE_BUILDNUMBER 11
/** Current Juce version number.


+ 1
- 1
src/gui/components/juce_Component.cpp View File

@@ -1563,7 +1563,7 @@ void Component::enterModalState (const bool shouldTakeKeyboardFocus, ModalCompon
void Component::exitModalState (const int returnValue)
{
if (isCurrentlyModal())
if (flags.currentlyModalFlag)
{
if (MessageManager::getInstance()->isThisTheMessageThread())
{


+ 2
- 1
src/gui/components/juce_Component.h View File

@@ -1046,7 +1046,8 @@ public:
the graphics context that gets passed to the component's paint() callback.
If you enable this mode, you'll need to make sure your paint method doesn't call anything like
Graphics::fillAll(), and doesn't draw beyond the component's bounds, because that'll produce
artifacts.
artifacts. Your component also can't have any child components that may be placed beyond its
bounds.
*/
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) throw();


+ 14
- 17
src/gui/components/juce_ModalComponentManager.cpp View File

@@ -32,43 +32,40 @@ BEGIN_JUCE_NAMESPACE
#include "windows/juce_ComponentPeer.h"
#include "../../events/juce_MessageManager.h"
#include "../../application/juce_Application.h"
#include "layout/juce_ComponentMovementWatcher.h"
//==============================================================================
class ModalComponentManager::ModalItem : public ComponentListener
class ModalComponentManager::ModalItem : public ComponentMovementWatcher
{
public:
ModalItem (Component* const comp, Callback* const callback)
: component (comp), returnValue (0), isActive (true), isDeleted (false)
: ComponentMovementWatcher (comp),
component (comp), returnValue (0), isActive (true)
{
jassert (comp != 0);
if (callback != 0)
callbacks.add (callback);
jassert (comp != 0);
component->addComponentListener (this);
}
~ModalItem()
{
if (! isDeleted)
component->removeComponentListener (this);
}
void componentMovedOrResized (bool, bool) {}
void componentBeingDeleted (Component&)
void componentPeerChanged()
{
isDeleted = true;
cancel();
if (! component->isShowing())
cancel();
}
void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
if (! component->isShowing())
cancel();
}
void componentParentHierarchyChanged (Component&)
void componentBeingDeleted (Component& comp)
{
if (! component->isShowing())
if (component == &comp || comp.isParentOf (component))
cancel();
}
@@ -84,7 +81,7 @@ public:
Component* component;
OwnedArray<Callback> callbacks;
int returnValue;
bool isActive, isDeleted;
bool isActive;
private:
JUCE_DECLARE_NON_COPYABLE (ModalItem);


+ 43
- 19
src/gui/components/layout/juce_ComponentMovementWatcher.cpp View File

@@ -34,7 +34,8 @@ BEGIN_JUCE_NAMESPACE
ComponentMovementWatcher::ComponentMovementWatcher (Component* const component_)
: component (component_),
lastPeer (0),
reentrant (false)
reentrant (false),
wasShowing (component_->isShowing())
{
jassert (component != 0); // can't use this with a null pointer..
@@ -45,7 +46,8 @@ ComponentMovementWatcher::ComponentMovementWatcher (Component* const component_)
ComponentMovementWatcher::~ComponentMovementWatcher()
{
component->removeComponentListener (this);
if (component != 0)
component->removeComponentListener (this);
unregister();
}
@@ -53,10 +55,7 @@ ComponentMovementWatcher::~ComponentMovementWatcher()
//==============================================================================
void ComponentMovementWatcher::componentParentHierarchyChanged (Component&)
{
// agh! don't delete the target component without deleting this object first!
jassert (component != 0);
if (! reentrant)
if (component != 0 && ! reentrant)
{
reentrant = true;
@@ -75,30 +74,55 @@ void ComponentMovementWatcher::componentParentHierarchyChanged (Component&)
unregister();
registerWithParentComps();
reentrant = false;
componentMovedOrResized (*component, true, true);
if (component != 0)
componentVisibilityChanged (*component);
reentrant = false;
}
}
void ComponentMovementWatcher::componentMovedOrResized (Component&, bool wasMoved, bool wasResized)
{
// agh! don't delete the target component without deleting this object first!
jassert (component != 0);
if (wasMoved)
if (component != 0)
{
const Point<int> pos (component->getTopLevelComponent()->getLocalPoint (component, Point<int>()));
if (wasMoved)
{
const Point<int> pos (component->getTopLevelComponent()->getLocalPoint (component, Point<int>()));
wasMoved = lastBounds.getPosition() != pos;
lastBounds.setPosition (pos);
}
wasResized = (lastBounds.getWidth() != component->getWidth() || lastBounds.getHeight() != component->getHeight());
lastBounds.setSize (component->getWidth(), component->getHeight());
wasMoved = lastBounds.getPosition() != pos;
lastBounds.setPosition (pos);
if (wasMoved || wasResized)
componentMovedOrResized (wasMoved, wasResized);
}
}
void ComponentMovementWatcher::componentBeingDeleted (Component& comp)
{
registeredParentComps.removeValue (&comp);
wasResized = (lastBounds.getWidth() != component->getWidth() || lastBounds.getHeight() != component->getHeight());
lastBounds.setSize (component->getWidth(), component->getHeight());
if (component == &comp)
unregister();
}
if (wasMoved || wasResized)
componentMovedOrResized (wasMoved, wasResized);
void ComponentMovementWatcher::componentVisibilityChanged (Component&)
{
if (component != 0)
{
const bool isShowingNow = component->isShowing();
if (wasShowing != isShowingNow)
{
wasShowing = isShowingNow;
componentVisibilityChanged();
}
}
}
void ComponentMovementWatcher::registerWithParentComps()


+ 9
- 2
src/gui/components/layout/juce_ComponentMovementWatcher.h View File

@@ -62,20 +62,27 @@ public:
/** This callback happens when the component's top-level peer is changed. */
virtual void componentPeerChanged() = 0;
/** This callback happens when the component's visibility state changes, possibly due to
one of its parents being made visible or invisible.
*/
virtual void componentVisibilityChanged() = 0;
//==============================================================================
/** @internal */
void componentParentHierarchyChanged (Component& component);
/** @internal */
void componentMovedOrResized (Component& component, bool wasMoved, bool wasResized);
/** @internal */
void componentBeingDeleted (Component& component);
/** @internal */
void componentVisibilityChanged (Component& component);
private:
//==============================================================================
WeakReference<Component> component;
ComponentPeer* lastPeer;
Array <Component*> registeredParentComps;
bool reentrant;
bool reentrant, wasShowing;
Rectangle<int> lastBounds;
void unregister();


+ 2
- 2
src/gui/components/layout/juce_Viewport.cpp View File

@@ -222,7 +222,7 @@ void Viewport::updateVisibleArea()
horizontalScrollBar.setSingleStepSize (singleStepX);
horizontalScrollBar.cancelPendingUpdate();
}
else
else if (canShowHBar)
{
visibleOrigin.setX (0);
}
@@ -235,7 +235,7 @@ void Viewport::updateVisibleArea()
verticalScrollBar.setSingleStepSize (singleStepY);
verticalScrollBar.cancelPendingUpdate();
}
else
else if (canShowVBar)
{
visibleOrigin.setY (0);
}


+ 5
- 14
src/gui/components/special/juce_OpenGLComponent.cpp View File

@@ -138,8 +138,7 @@ public:
//==============================================================================
OpenGLComponentWatcher (OpenGLComponent* const owner_)
: ComponentMovementWatcher (owner_),
owner (owner_),
wasShowing (false)
owner (owner_)
{
}
@@ -155,26 +154,18 @@ public:
owner->deleteContext();
}
void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
const bool isShowingNow = owner->isShowing();
if (wasShowing != isShowingNow)
if (! owner->isShowing())
{
wasShowing = isShowingNow;
if (! isShowingNow)
{
const ScopedLock sl (owner->getContextLock());
owner->deleteContext();
}
const ScopedLock sl (owner->getContextLock());
owner->deleteContext();
}
}
//==============================================================================
private:
OpenGLComponent* const owner;
bool wasShowing;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLComponentWatcher);
};


+ 10
- 0
src/gui/components/windows/juce_TopLevelWindow.cpp View File

@@ -187,6 +187,16 @@ void TopLevelWindow::activeWindowStatusChanged()
{
}
void TopLevelWindow::visibilityChanged()
{
if (isShowing()
&& (getPeer()->getStyleFlags() & (ComponentPeer::windowIsTemporary
| ComponentPeer::windowIgnoresKeyPresses)) == 0)
{
toFront (true);
}
}
void TopLevelWindow::parentHierarchyChanged()
{
setDropShadowEnabled (useDropShadow);


+ 2
- 0
src/gui/components/windows/juce_TopLevelWindow.h View File

@@ -151,6 +151,8 @@ protected:
virtual int getDesktopWindowStyleFlags() const;
/** @internal */
void recreateDesktopWindow();
/** @internal */
void visibilityChanged();
private:
friend class TopLevelWindowManager;


+ 1
- 1
src/native/mac/juce_mac_CarbonViewWrapperComponent.h View File

@@ -204,7 +204,7 @@ public:
createWindow();
}
void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
if (isShowing())
createWindow();


+ 17
- 17
src/native/mac/juce_mac_NSViewComponent.mm View File

@@ -30,24 +30,17 @@
//==============================================================================
class NSViewComponentInternal : public ComponentMovementWatcher
{
Component* const owner;
NSViewComponentPeer* currentPeer;
bool wasShowing;
public:
NSView* const view;
//==============================================================================
NSViewComponentInternal (NSView* const view_, Component* const owner_)
: ComponentMovementWatcher (owner_),
NSViewComponentInternal (NSView* const view_, Component& owner_)
: ComponentMovementWatcher (&owner_),
owner (owner_),
currentPeer (0),
wasShowing (false),
view (view_)
{
[view_ retain];
if (owner_->isShowing())
if (owner.isShowing())
componentPeerChanged();
}
@@ -72,13 +65,13 @@ public:
void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/)
{
Component* const topComp = owner->getTopLevelComponent();
Component* const topComp = owner.getTopLevelComponent();
if (topComp->getPeer() != 0)
{
const Point<int> pos (topComp->getLocalPoint (owner, Point<int>()));
const Point<int> pos (topComp->getLocalPoint (&owner, Point<int>()));
NSRect r = NSMakeRect ((float) pos.getX(), (float) pos.getY(), (float) owner->getWidth(), (float) owner->getHeight());
NSRect r = NSMakeRect ((float) pos.getX(), (float) pos.getY(), (float) owner.getWidth(), (float) owner.getHeight());
r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height);
[view setFrame: r];
@@ -87,7 +80,7 @@ public:
void componentPeerChanged()
{
NSViewComponentPeer* const peer = dynamic_cast <NSViewComponentPeer*> (owner->getPeer());
NSViewComponentPeer* const peer = dynamic_cast <NSViewComponentPeer*> (owner.getPeer());
if (currentPeer != peer)
{
@@ -104,10 +97,10 @@ public:
}
}
[view setHidden: ! owner->isShowing()];
[view setHidden: ! owner.isShowing()];
}
void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
componentPeerChanged();
}
@@ -118,6 +111,13 @@ public:
return Rectangle<int> (0, 0, (int) r.size.width, (int) r.size.height);
}
private:
Component& owner;
NSViewComponentPeer* currentPeer;
public:
NSView* const view;
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NSViewComponentInternal);
};
@@ -136,7 +136,7 @@ void NSViewComponent::setView (void* view)
if (view != getView())
{
if (view != 0)
info = new NSViewComponentInternal ((NSView*) view, this);
info = new NSViewComponentInternal ((NSView*) view, *this);
else
info = 0;
}


+ 2
- 4
src/native/mac/juce_mac_OpenGLComponent.mm View File

@@ -119,14 +119,12 @@ BEGIN_JUCE_NAMESPACE
class WindowedGLContext : public OpenGLContext
{
public:
WindowedGLContext (Component* const component,
WindowedGLContext (Component& component,
const OpenGLPixelFormat& pixelFormat_,
NSOpenGLContext* sharedContext)
: renderContext (0),
pixelFormat (pixelFormat_)
{
jassert (component != 0);
NSOpenGLPixelFormatAttribute attribs [64];
int n = 0;
attribs[n++] = NSOpenGLPFADoubleBuffer;
@@ -268,7 +266,7 @@ private:
//==============================================================================
OpenGLContext* OpenGLComponent::createContext()
{
ScopedPointer<WindowedGLContext> c (new WindowedGLContext (this, preferredPixelFormat,
ScopedPointer<WindowedGLContext> c (new WindowedGLContext (*this, preferredPixelFormat,
contextToShareListsWith != 0 ? (NSOpenGLContext*) contextToShareListsWith->getRawContext() : 0));
return (c->renderContext != 0) ? c.release() : 0;


+ 11
- 18
src/native/windows/juce_win32_ActiveXComponent.cpp View File

@@ -208,20 +208,11 @@ namespace ActiveXHelpers
//==============================================================================
class ActiveXControlComponent::Pimpl : public ComponentMovementWatcher
{
ActiveXControlComponent& owner;
bool wasShowing;
public:
HWND controlHWND;
IStorage* storage;
IOleClientSite* clientSite;
IOleObject* control;
//==============================================================================
Pimpl (HWND hwnd, ActiveXControlComponent& owner_)
: ComponentMovementWatcher (&owner_),
owner (owner_),
wasShowing (owner_.isShowing()),
controlHWND (0),
storage (new ActiveXHelpers::JuceIStorage()),
clientSite (new ActiveXHelpers::JuceIOleClientSite (hwnd)),
@@ -255,19 +246,12 @@ public:
void componentPeerChanged()
{
const bool isShowingNow = owner.isShowing();
if (wasShowing != isShowingNow)
{
wasShowing = isShowingNow;
owner.setControlVisible (isShowingNow);
}
componentMovedOrResized (true, true);
}
void componentVisibilityChanged (Component&)
void componentVisibilityChanged()
{
owner.setControlVisible (owner.isShowing());
componentPeerChanged();
}
@@ -316,6 +300,15 @@ public:
return DefWindowProc (hwnd, message, wParam, lParam);
}
private:
ActiveXControlComponent& owner;
public:
HWND controlHWND;
IStorage* storage;
IOleClientSite* clientSite;
IOleObject* control;
};
ActiveXControlComponent::ActiveXControlComponent()


+ 18
- 29
src/native/windows/juce_win32_WebBrowserComponent.cpp View File

@@ -66,7 +66,7 @@ public:
WebBrowserComponent* const owner = dynamic_cast <WebBrowserComponent*> (getParentComponent());
jassert (owner != 0);
EventHandler* handler = new EventHandler (owner);
EventHandler* handler = new EventHandler (*owner);
connectionPoint->Advise (handler, &adviseCookie);
handler->Release();
}
@@ -144,8 +144,8 @@ private:
public ComponentMovementWatcher
{
public:
EventHandler (WebBrowserComponent* const owner_)
: ComponentMovementWatcher (owner_),
EventHandler (WebBrowserComponent& owner_)
: ComponentMovementWatcher (&owner_),
owner (owner_)
{
}
@@ -158,44 +158,33 @@ private:
HRESULT __stdcall Invoke (DISPID dispIdMember, REFIID /*riid*/, LCID /*lcid*/, WORD /*wFlags*/, DISPPARAMS* pDispParams,
VARIANT* /*pVarResult*/, EXCEPINFO* /*pExcepInfo*/, UINT* /*puArgErr*/)
{
switch (dispIdMember)
if (dispIdMember == DISPID_BEFORENAVIGATE2)
{
case DISPID_BEFORENAVIGATE2:
{
VARIANT* const vurl = pDispParams->rgvarg[5].pvarVal;
String url;
VARIANT* const vurl = pDispParams->rgvarg[5].pvarVal;
String url;
if ((vurl->vt & VT_BYREF) != 0)
url = *vurl->pbstrVal;
else
url = vurl->bstrVal;
if ((vurl->vt & VT_BYREF) != 0)
url = *vurl->pbstrVal;
else
url = vurl->bstrVal;
*pDispParams->rgvarg->pboolVal
= owner->pageAboutToLoad (url) ? VARIANT_FALSE
: VARIANT_TRUE;
return S_OK;
}
*pDispParams->rgvarg->pboolVal
= owner.pageAboutToLoad (url) ? VARIANT_FALSE
: VARIANT_TRUE;
default:
break;
return S_OK;
}
return E_NOTIMPL;
}
void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) {}
void componentPeerChanged() {}
void componentVisibilityChanged (Component&)
{
owner->visibilityChanged();
}
void componentMovedOrResized (bool, bool ) {}
void componentPeerChanged() {}
void componentVisibilityChanged() { owner.visibilityChanged(); }
//==============================================================================
private:
WebBrowserComponent* const owner;
WebBrowserComponent& owner;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EventHandler);
};


Loading…
Cancel
Save