mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-04 03:40:07 +00:00
Changes and additions to provide alternatives to modal-loop functionality (Android can't run modal loops). New class ModalCallbackFunction providing quick objects for making callbacks to static functions. Changes to remove modal loops from most of the internal library classes. Added new methods to PopupMenu to provide easier async callbacks, and also a cleaner way of specifying options when showing a menu. Fix for PNG decoding of corrupted image files.
This commit is contained in:
parent
d4818c2ac2
commit
2d10b0b43d
47 changed files with 2906 additions and 1606 deletions
|
|
@ -172,27 +172,6 @@ void MenuBarComponent::updateItemUnderMouse (int x, int y)
|
|||
setItemUnderMouse (getItemAt (x, y));
|
||||
}
|
||||
|
||||
class MenuBarComponent::AsyncCallback : public ModalComponentManager::Callback
|
||||
{
|
||||
public:
|
||||
AsyncCallback (MenuBarComponent* const bar_, const int topLevelIndex_)
|
||||
: bar (bar_), topLevelIndex (topLevelIndex_)
|
||||
{
|
||||
}
|
||||
|
||||
void modalStateFinished (int returnValue)
|
||||
{
|
||||
if (bar != 0)
|
||||
bar->menuDismissed (topLevelIndex, returnValue);
|
||||
}
|
||||
|
||||
private:
|
||||
Component::SafePointer<MenuBarComponent> bar;
|
||||
const int topLevelIndex;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (AsyncCallback);
|
||||
};
|
||||
|
||||
void MenuBarComponent::showMenu (int index)
|
||||
{
|
||||
if (index != currentPopupIndex)
|
||||
|
|
@ -213,13 +192,20 @@ void MenuBarComponent::showMenu (int index)
|
|||
|
||||
const Rectangle<int> itemPos (xPositions [index], 0, xPositions [index + 1] - xPositions [index], getHeight());
|
||||
|
||||
m.showMenu (localAreaToGlobal (itemPos),
|
||||
0, itemPos.getWidth(), 0, 0, this,
|
||||
new AsyncCallback (this, index));
|
||||
m.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
|
||||
.withTargetScreenArea (localAreaToGlobal (itemPos))
|
||||
.withMinimumWidth (itemPos.getWidth()),
|
||||
ModalCallbackFunction::forComponent (menuBarMenuDismissedCallback, this, index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MenuBarComponent::menuBarMenuDismissedCallback (int result, MenuBarComponent* bar, int topLevelIndex)
|
||||
{
|
||||
if (bar != 0)
|
||||
bar->menuDismissed (topLevelIndex, result);
|
||||
}
|
||||
|
||||
void MenuBarComponent::menuDismissed (int topLevelIndex, int itemId)
|
||||
{
|
||||
topLevelIndexClicked = topLevelIndex;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue