Browse Source

Fixes for AU hosting and Button Value reference handling. Minor clean-ups.

tags/2021-05-28
Julian Storer 13 years ago
parent
commit
638a93d639
10 changed files with 58 additions and 64 deletions
  1. +2
    -0
      modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm
  2. +0
    -1
      modules/juce_core/network/juce_NamedPipe.cpp
  3. +0
    -3
      modules/juce_core/network/juce_NamedPipe.h
  4. +2
    -2
      modules/juce_gui_basics/buttons/juce_Button.cpp
  5. +6
    -4
      modules/juce_gui_basics/native/juce_mac_Windowing.mm
  6. +0
    -6
      modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h
  7. +0
    -1
      modules/juce_gui_extra/embedding/juce_UIViewComponent.h
  8. +11
    -11
      modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h
  9. +9
    -5
      modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm
  10. +28
    -31
      modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp

+ 2
- 0
modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm View File

@@ -1031,6 +1031,8 @@ public:
{ {
const bool wasValid = isValid(); const bool wasValid = isValid();
wrapper.setVisible (false);
removeChildComponent (&wrapper);
wrapper.setView (nil); wrapper.setView (nil);
if (wasValid) if (wasValid)


+ 0
- 1
modules/juce_core/network/juce_NamedPipe.cpp View File

@@ -25,7 +25,6 @@
BEGIN_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE
//==============================================================================
bool NamedPipe::openExisting (const String& pipeName) bool NamedPipe::openExisting (const String& pipeName)
{ {
currentPipeName = pipeName; currentPipeName = pipeName;


+ 0
- 3
modules/juce_core/network/juce_NamedPipe.h View File

@@ -26,8 +26,6 @@
#ifndef __JUCE_NAMEDPIPE_JUCEHEADER__ #ifndef __JUCE_NAMEDPIPE_JUCEHEADER__
#define __JUCE_NAMEDPIPE_JUCEHEADER__ #define __JUCE_NAMEDPIPE_JUCEHEADER__
#include "../threads/juce_CriticalSection.h"
//============================================================================== //==============================================================================
/** /**
@@ -102,7 +100,6 @@ private:
class Pimpl; class Pimpl;
ScopedPointer<Pimpl> pimpl; ScopedPointer<Pimpl> pimpl;
String currentPipeName; String currentPipeName;
CriticalSection lock;
bool openInternal (const String& pipeName, const bool createPipe); bool openInternal (const String& pipeName, const bool createPipe);


+ 2
- 2
modules/juce_gui_basics/buttons/juce_Button.cpp View File

@@ -132,8 +132,8 @@ void Button::setToggleState (const bool shouldBeOn,
{ {
if (shouldBeOn != lastToggleState) if (shouldBeOn != lastToggleState)
{ {
if (isOn != shouldBeOn) // this test means that if the value is void rather than explicitly set to
isOn = shouldBeOn; // false, it won't be changed unless the required value is true.
if (getToggleState() != shouldBeOn) // this test means that if the value is void rather than explicitly set to
isOn = shouldBeOn; // false, it won't be changed unless the required value is true.
lastToggleState = shouldBeOn; lastToggleState = shouldBeOn;
repaint(); repaint();


+ 6
- 4
modules/juce_gui_basics/native/juce_mac_Windowing.mm View File

@@ -346,11 +346,13 @@ Image juce_createIconForFile (const File& file)
//============================================================================== //==============================================================================
void SystemClipboard::copyTextToClipboard (const String& text) void SystemClipboard::copyTextToClipboard (const String& text)
{ {
[[NSPasteboard generalPasteboard] declareTypes: [NSArray arrayWithObject: NSStringPboardType]
owner: nil];
NSPasteboard* pb = [NSPasteboard generalPasteboard];
[[NSPasteboard generalPasteboard] setString: juceStringToNS (text)
forType: NSStringPboardType];
[pb declareTypes: [NSArray arrayWithObject: NSStringPboardType]
owner: nil];
[pb setString: juceStringToNS (text)
forType: NSStringPboardType];
} }
String SystemClipboard::getTextFromClipboard() String SystemClipboard::getTextFromClipboard()


+ 0
- 6
modules/juce_gui_extra/embedding/juce_ActiveXControlComponent.h View File

@@ -108,19 +108,13 @@ public:
//============================================================================== //==============================================================================
/** @internal */ /** @internal */
void paint (Graphics& g); void paint (Graphics& g);
/** @internal */
void* originalWndProc;
private: private:
class Pimpl; class Pimpl;
friend class Pimpl;
friend class ScopedPointer <Pimpl>; friend class ScopedPointer <Pimpl>;
ScopedPointer <Pimpl> control; ScopedPointer <Pimpl> control;
bool mouseEventsAllowed; bool mouseEventsAllowed;
void setControlBounds (const Rectangle<int>& bounds) const;
void setControlVisible (bool b) const;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ActiveXControlComponent); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ActiveXControlComponent);
}; };


+ 0
- 1
modules/juce_gui_extra/embedding/juce_UIViewComponent.h View File

@@ -84,5 +84,4 @@ private:
}; };
#endif #endif
#endif // __JUCE_UIVIEWCOMPONENT_JUCEHEADER__ #endif // __JUCE_UIVIEWCOMPONENT_JUCEHEADER__

+ 11
- 11
modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h View File

@@ -75,9 +75,9 @@ public:
if (wrapperWindow == 0) if (wrapperWindow == 0)
{ {
Rect r; Rect r;
r.left = getScreenX();
r.top = getScreenY();
r.right = r.left + getWidth();
r.left = getScreenX();
r.top = getScreenY();
r.right = r.left + getWidth();
r.bottom = r.top + getHeight(); r.bottom = r.top + getHeight();
CreateNewWindow (kDocumentWindowClass, CreateNewWindow (kDocumentWindowClass,
@@ -101,10 +101,10 @@ public:
{ kEventClassWindow, kEventWindowGetClickActivation }, { kEventClassWindow, kEventWindowGetClickActivation },
{ kEventClassWindow, kEventWindowHandleDeactivate }, { kEventClassWindow, kEventWindowHandleDeactivate },
{ kEventClassWindow, kEventWindowBoundsChanging }, { kEventClassWindow, kEventWindowBoundsChanging },
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseMoved },
{ kEventClassMouse, kEventMouseDragged },
{ kEventClassMouse, kEventMouseUp},
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseMoved },
{ kEventClassMouse, kEventMouseDragged },
{ kEventClassMouse, kEventMouseUp},
{ kEventClassWindow, kEventWindowDrawContent }, { kEventClassWindow, kEventWindowDrawContent },
{ kEventClassWindow, kEventWindowShown }, { kEventClassWindow, kEventWindowShown },
{ kEventClassWindow, kEventWindowHidden } { kEventClassWindow, kEventWindowHidden }
@@ -179,7 +179,7 @@ public:
HIRect r; HIRect r;
r.origin.x = 0; r.origin.x = 0;
r.origin.y = 0; r.origin.y = 0;
r.size.width = (float) getWidth();
r.size.width = (float) getWidth();
r.size.height = (float) getHeight(); r.size.height = (float) getHeight();
HIViewSetFrame (embeddedView, &r); HIViewSetFrame (embeddedView, &r);
} }
@@ -187,9 +187,9 @@ public:
if (wrapperWindow != 0) if (wrapperWindow != 0)
{ {
Rect wr; Rect wr;
wr.left = getScreenX();
wr.top = getScreenY();
wr.right = wr.left + getWidth();
wr.left = getScreenX();
wr.top = getScreenY();
wr.right = wr.left + getWidth();
wr.bottom = wr.top + getHeight(); wr.bottom = wr.top + getHeight();
SetWindowBounds (wrapperWindow, kWindowContentRgn, &wr); SetWindowBounds (wrapperWindow, kWindowContentRgn, &wr);


+ 9
- 5
modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm View File

@@ -40,7 +40,7 @@ public:
~Pimpl() ~Pimpl()
{ {
[view removeFromSuperview];
removeFromParent();
[view release]; [view release];
} }
@@ -77,10 +77,7 @@ public:
if (currentPeer != peer) if (currentPeer != peer)
{ {
if ([view superview] != nil)
[view removeFromSuperview]; // Must be careful not to call this unless it's required - e.g. some Apple AU views
// override the call and use it as a sign that they're being deleted, which breaks everything..
removeFromParent();
currentPeer = peer; currentPeer = peer;
if (peer != nullptr) if (peer != nullptr)
@@ -111,6 +108,13 @@ private:
Component& owner; Component& owner;
ComponentPeer* currentPeer; ComponentPeer* currentPeer;
void removeFromParent()
{
if ([view superview] != nil)
[view removeFromSuperview]; // Must be careful not to call this unless it's required - e.g. some Apple AU views
// override the call and use it as a sign that they're being deleted, which breaks everything..
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl);
}; };


+ 28
- 31
modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp View File

@@ -205,14 +205,14 @@ namespace ActiveXHelpers
class ActiveXControlComponent::Pimpl : public ComponentMovementWatcher class ActiveXControlComponent::Pimpl : public ComponentMovementWatcher
{ {
public: public:
//==============================================================================
Pimpl (HWND hwnd, ActiveXControlComponent& owner_) Pimpl (HWND hwnd, ActiveXControlComponent& owner_)
: ComponentMovementWatcher (&owner_), : ComponentMovementWatcher (&owner_),
owner (owner_), owner (owner_),
controlHWND (0), controlHWND (0),
storage (new ActiveXHelpers::JuceIStorage()), storage (new ActiveXHelpers::JuceIStorage()),
clientSite (new ActiveXHelpers::JuceIOleClientSite (hwnd)), clientSite (new ActiveXHelpers::JuceIOleClientSite (hwnd)),
control (nullptr)
control (nullptr),
originalWndProc (0)
{ {
} }
@@ -228,16 +228,25 @@ public:
storage->Release(); storage->Release();
} }
void setControlBounds (const Rectangle<int>& bounds) const
{
if (controlHWND != 0)
MoveWindow (controlHWND, bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), TRUE);
}
void setControlVisible (bool shouldBeVisible) const
{
if (controlHWND != 0)
ShowWindow (controlHWND, shouldBeVisible ? SW_SHOWNA : SW_HIDE);
}
//============================================================================== //==============================================================================
void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/)
{ {
Component* const topComp = owner.getTopLevelComponent(); Component* const topComp = owner.getTopLevelComponent();
if (topComp->getPeer() != nullptr) if (topComp->getPeer() != nullptr)
{
const Point<int> pos (topComp->getLocalPoint (&owner, Point<int>()));
owner.setControlBounds (Rectangle<int> (pos.getX(), pos.getY(), owner.getWidth(), owner.getHeight()));
}
setControlBounds (topComp->getLocalArea (&owner, owner.getLocalBounds()));
} }
void componentPeerChanged() void componentPeerChanged()
@@ -247,7 +256,7 @@ public:
void componentVisibilityChanged() void componentVisibilityChanged()
{ {
owner.setControlVisible (owner.isShowing());
setControlVisible (owner.isShowing());
componentPeerChanged(); componentPeerChanged();
} }
@@ -290,7 +299,7 @@ public:
break; break;
} }
return CallWindowProc ((WNDPROC) ax->originalWndProc, hwnd, message, wParam, lParam);
return CallWindowProc (ax->control->originalWndProc, hwnd, message, wParam, lParam);
} }
} }
@@ -305,12 +314,13 @@ public:
IStorage* storage; IStorage* storage;
IOleClientSite* clientSite; IOleClientSite* clientSite;
IOleObject* control; IOleObject* control;
WNDPROC originalWndProc;
}; };
//============================================================================== //==============================================================================
ActiveXControlComponent::ActiveXControlComponent() ActiveXControlComponent::ActiveXControlComponent()
: originalWndProc (0),
mouseEventsAllowed (true)
: mouseEventsAllowed (true)
{ {
ActiveXHelpers::activeXComps.add (this); ActiveXHelpers::activeXComps.add (this);
} }
@@ -337,7 +347,7 @@ bool ActiveXControlComponent::createControl (const void* controlIID)
if (peer != nullptr) if (peer != nullptr)
{ {
const Point<int> pos (getTopLevelComponent()->getLocalPoint (this, Point<int>()));
const Rectangle<int> bounds (getTopLevelComponent()->getLocalArea (this, getLocalBounds()));
HWND hwnd = (HWND) peer->getNativeHandle(); HWND hwnd = (HWND) peer->getNativeHandle();
ScopedPointer<Pimpl> newControl (new Pimpl (hwnd, *this)); ScopedPointer<Pimpl> newControl (new Pimpl (hwnd, *this));
@@ -352,21 +362,21 @@ bool ActiveXControlComponent::createControl (const void* controlIID)
if (OleSetContainedObject (newControl->control, TRUE) == S_OK) if (OleSetContainedObject (newControl->control, TRUE) == S_OK)
{ {
RECT rect; RECT rect;
rect.left = pos.getX();
rect.top = pos.getY();
rect.right = pos.getX() + getWidth();
rect.bottom = pos.getY() + getHeight();
rect.left = bounds.getX();
rect.top = bounds.getY();
rect.right = bounds.getRight();
rect.bottom = bounds.getBottom();
if (newControl->control->DoVerb (OLEIVERB_SHOW, 0, newControl->clientSite, 0, hwnd, &rect) == S_OK) if (newControl->control->DoVerb (OLEIVERB_SHOW, 0, newControl->clientSite, 0, hwnd, &rect) == S_OK)
{ {
control = newControl; control = newControl;
setControlBounds (Rectangle<int> (pos.getX(), pos.getY(), getWidth(), getHeight()));
control->controlHWND = ActiveXHelpers::getHWND (this); control->controlHWND = ActiveXHelpers::getHWND (this);
if (control->controlHWND != 0) if (control->controlHWND != 0)
{ {
originalWndProc = (void*) (pointer_sized_int) GetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC);
control->setControlBounds (bounds);
control->originalWndProc = (void*) (pointer_sized_int) GetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC);
SetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC, (LONG_PTR) Pimpl::activeXHookWndProc); SetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC, (LONG_PTR) Pimpl::activeXHookWndProc);
} }
@@ -382,7 +392,6 @@ bool ActiveXControlComponent::createControl (const void* controlIID)
void ActiveXControlComponent::deleteControl() void ActiveXControlComponent::deleteControl()
{ {
control = nullptr; control = nullptr;
originalWndProc = 0;
} }
void* ActiveXControlComponent::queryInterface (const void* iid) const void* ActiveXControlComponent::queryInterface (const void* iid) const
@@ -396,18 +405,6 @@ void* ActiveXControlComponent::queryInterface (const void* iid) const
return nullptr; return nullptr;
} }
void ActiveXControlComponent::setControlBounds (const Rectangle<int>& newBounds) const
{
if (control->controlHWND != 0)
MoveWindow (control->controlHWND, newBounds.getX(), newBounds.getY(), newBounds.getWidth(), newBounds.getHeight(), TRUE);
}
void ActiveXControlComponent::setControlVisible (const bool shouldBeVisible) const
{
if (control->controlHWND != 0)
ShowWindow (control->controlHWND, shouldBeVisible ? SW_SHOWNA : SW_HIDE);
}
void ActiveXControlComponent::setMouseEventsAllowed (const bool eventsCanReachControl) void ActiveXControlComponent::setMouseEventsAllowed (const bool eventsCanReachControl)
{ {
mouseEventsAllowed = eventsCanReachControl; mouseEventsAllowed = eventsCanReachControl;


Loading…
Cancel
Save