1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-17 00:44:19 +00:00

Fix for menu bar problem on OSX.

This commit is contained in:
jules 2012-09-21 11:37:22 +01:00
parent 08dd8f62c7
commit 7141fe39dc
5 changed files with 33 additions and 45 deletions

View file

@ -127,7 +127,7 @@ public:
{
while (numSamples > 0)
{
const int numAvailable = reservoirStart + samplesInReservoir - startSampleInFile;
const int numAvailable = (int) (reservoirStart + samplesInReservoir - startSampleInFile);
if (startSampleInFile >= reservoirStart && numAvailable > 0)
{

View file

@ -26,10 +26,7 @@
class AsyncUpdater::AsyncUpdaterMessage : public CallbackMessage
{
public:
AsyncUpdaterMessage (AsyncUpdater& owner_)
: owner (owner_)
{
}
AsyncUpdaterMessage (AsyncUpdater& au) : owner (au) {}
void messageCallback()
{

View file

@ -45,7 +45,6 @@ public:
AsyncUpdater();
/** Destructor.
If there are any pending callbacks when the object is deleted, these are lost.
*/
virtual ~AsyncUpdater();

View file

@ -171,8 +171,7 @@ public:
void resized()
{
Component* const child = getChildComponent (0);
if (child != nullptr)
if (Component* const child = getChildComponent (0))
child->setBounds (getLocalBounds().reduced (2, 0));
}
@ -479,10 +478,9 @@ public:
return;
}
Window* currentlyModalWindow = dynamic_cast <Window*> (Component::getCurrentlyModalComponent());
if (currentlyModalWindow != nullptr && ! treeContains (currentlyModalWindow))
return;
if (Window* currentlyModalWindow = dynamic_cast <Window*> (Component::getCurrentlyModalComponent()))
if (! treeContains (currentlyModalWindow))
return;
startTimer (PopupMenuSettings::timerInterval); // do this in case it was called from a mouse
// move rather than a real timer callback
@ -1257,8 +1255,8 @@ public:
void resized()
{
if (getChildComponent(0) != nullptr)
getChildComponent(0)->setBounds (getLocalBounds());
if (Component* const child = getChildComponent(0))
child->setBounds (getLocalBounds());
}
private:
@ -1536,16 +1534,12 @@ int PopupMenu::showAt (Component* componentToAttachTo,
bool JUCE_CALLTYPE PopupMenu::dismissAllActiveMenus()
{
Array<Window*>& windows = Window::getActiveWindows();
const Array<Window*>& windows = Window::getActiveWindows();
const int numWindows = windows.size();
for (int i = numWindows; --i >= 0;)
{
Window* const pmw = windows[i];
if (pmw != nullptr)
for (int i = numWindows; --i >= 0;)
if (Window* const pmw = windows[i])
pmw->dismissMenu (nullptr);
}
return numWindows > 0;
}
@ -1566,10 +1560,10 @@ bool PopupMenu::containsCommandItem (const int commandID) const
{
for (int i = items.size(); --i >= 0;)
{
const Item* const mi = items.getUnchecked (i);
const Item& mi = *items.getUnchecked (i);
if ((mi->itemID == commandID && mi->commandManager != nullptr)
|| (mi->subMenu != nullptr && mi->subMenu->containsCommandItem (commandID)))
if ((mi.itemID == commandID && mi.commandManager != nullptr)
|| (mi.subMenu != nullptr && mi.subMenu->containsCommandItem (commandID)))
{
return true;
}
@ -1582,14 +1576,14 @@ bool PopupMenu::containsAnyActiveItems() const noexcept
{
for (int i = items.size(); --i >= 0;)
{
const Item* const mi = items.getUnchecked (i);
const Item& mi = *items.getUnchecked (i);
if (mi->subMenu != nullptr)
if (mi.subMenu != nullptr)
{
if (mi->subMenu->containsAnyActiveItems())
if (mi.subMenu->containsAnyActiveItems())
return true;
}
else if (mi->isActive)
else if (mi.isActive)
{
return true;
}
@ -1622,13 +1616,9 @@ void PopupMenu::CustomComponent::setHighlighted (bool shouldBeHighlighted)
void PopupMenu::CustomComponent::triggerMenuItem()
{
PopupMenu::ItemComponent* const mic = dynamic_cast <PopupMenu::ItemComponent*> (getParentComponent());
if (mic != nullptr)
if (PopupMenu::ItemComponent* const mic = dynamic_cast <PopupMenu::ItemComponent*> (getParentComponent()))
{
PopupMenu::Window* const pmw = dynamic_cast <PopupMenu::Window*> (mic->getParentComponent());
if (pmw != nullptr)
if (PopupMenu::Window* const pmw = dynamic_cast <PopupMenu::Window*> (mic->getParentComponent()))
{
pmw->dismissMenu (&mic->itemInfo);
}

View file

@ -58,7 +58,6 @@ public:
#else
usingCoreGraphics (false),
#endif
recursiveToFrontCall (false),
isZooming (false),
textWasInserted (false),
notificationCenter (nil)
@ -370,10 +369,8 @@ public:
NSView* v = [view hitTest: NSMakePoint (frameRect.origin.x + position.getX(),
frameRect.origin.y + frameRect.size.height - position.getY())];
if (trueIfInAChildWindow)
return v != nil;
return v == view;
return trueIfInAChildWindow ? (v != nil)
: (v == view);
}
BorderSize<int> getFrameSize() const
@ -427,18 +424,20 @@ public:
if (window != nil && component.isVisible())
{
++insideToFrontCall;
if (makeActiveWindow)
[window makeKeyAndOrderFront: nil];
else
[window orderFront: nil];
if (! recursiveToFrontCall)
if (insideToFrontCall <= 1)
{
recursiveToFrontCall = true;
Desktop::getInstance().getMainMouseSource().forceMouseCursorUpdate();
handleBroughtToFront();
recursiveToFrontCall = false;
}
--insideToFrontCall;
}
}
@ -783,6 +782,7 @@ public:
Component* const modal = Component::getCurrentlyModalComponent();
if (modal != nullptr
&& insideToFrontCall == 0
&& (! getComponent().isParentOf (modal))
&& getComponent().isCurrentlyBlockedByAnotherModalComponent())
{
@ -1133,13 +1133,14 @@ public:
NSWindow* window;
NSView* view;
bool isSharedWindow, fullScreen, insideDrawRect;
bool usingCoreGraphics, recursiveToFrontCall, isZooming, textWasInserted;
bool usingCoreGraphics, isZooming, textWasInserted;
String stringBeingComposed;
NSNotificationCenter* notificationCenter;
static ModifierKeys currentModifiers;
static ComponentPeer* currentlyFocusedPeer;
static Array<int> keysCurrentlyDown;
static int insideToFrontCall;
private:
static NSView* createViewInstance();
@ -1260,8 +1261,7 @@ private:
if (! [NSApp isActive])
[NSApp activateIgnoringOtherApps: YES];
Component* const modal = Component::getCurrentlyModalComponent();
if (modal != nullptr)
if (Component* const modal = Component::getCurrentlyModalComponent())
modal->inputAttemptWhenModal();
}
@ -1271,6 +1271,8 @@ private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NSViewComponentPeer);
};
int NSViewComponentPeer::insideToFrontCall = 0;
//==============================================================================
struct JuceNSViewClass : public ObjCClass <NSView>
{