mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Some internal modernisation in windowing classes
This commit is contained in:
parent
9527e077b1
commit
c42719c2eb
11 changed files with 173 additions and 227 deletions
|
|
@ -32,14 +32,8 @@ class TopLevelWindowManager : private Timer,
|
|||
private DeletedAtShutdown
|
||||
{
|
||||
public:
|
||||
TopLevelWindowManager() : currentActive (nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
~TopLevelWindowManager()
|
||||
{
|
||||
clearSingletonInstance();
|
||||
}
|
||||
TopLevelWindowManager() {}
|
||||
~TopLevelWindowManager() { clearSingletonInstance(); }
|
||||
|
||||
juce_DeclareSingleton_SingleThreaded_Minimal (TopLevelWindowManager)
|
||||
|
||||
|
|
@ -52,14 +46,14 @@ public:
|
|||
{
|
||||
startTimer (jmin (1731, getTimerInterval() * 2));
|
||||
|
||||
TopLevelWindow* newActive = findCurrentlyActiveWindow();
|
||||
auto* newActive = findCurrentlyActiveWindow();
|
||||
|
||||
if (newActive != currentActive)
|
||||
{
|
||||
currentActive = newActive;
|
||||
|
||||
for (int i = windows.size(); --i >= 0;)
|
||||
if (TopLevelWindow* tlw = windows[i])
|
||||
if (auto* tlw = windows[i])
|
||||
tlw->setWindowActive (isWindowActive (tlw));
|
||||
|
||||
Desktop::getInstance().triggerFocusCallback();
|
||||
|
|
@ -83,14 +77,14 @@ public:
|
|||
|
||||
windows.removeFirstMatchingValue (w);
|
||||
|
||||
if (windows.size() == 0)
|
||||
if (windows.isEmpty())
|
||||
deleteInstance();
|
||||
}
|
||||
|
||||
Array<TopLevelWindow*> windows;
|
||||
|
||||
private:
|
||||
TopLevelWindow* currentActive;
|
||||
TopLevelWindow* currentActive = nullptr;
|
||||
|
||||
void timerCallback() override
|
||||
{
|
||||
|
|
@ -109,8 +103,8 @@ private:
|
|||
{
|
||||
if (Process::isForegroundProcess())
|
||||
{
|
||||
Component* const focusedComp = Component::getCurrentlyFocusedComponent();
|
||||
TopLevelWindow* w = dynamic_cast<TopLevelWindow*> (focusedComp);
|
||||
auto* focusedComp = Component::getCurrentlyFocusedComponent();
|
||||
auto* w = dynamic_cast<TopLevelWindow*> (focusedComp);
|
||||
|
||||
if (w == nullptr && focusedComp != nullptr)
|
||||
w = focusedComp->findParentComponentOfClass<TopLevelWindow>();
|
||||
|
|
@ -133,16 +127,13 @@ juce_ImplementSingleton_SingleThreaded (TopLevelWindowManager)
|
|||
void juce_checkCurrentlyFocusedTopLevelWindow();
|
||||
void juce_checkCurrentlyFocusedTopLevelWindow()
|
||||
{
|
||||
if (TopLevelWindowManager* const wm = TopLevelWindowManager::getInstanceWithoutCreating())
|
||||
if (auto* wm = TopLevelWindowManager::getInstanceWithoutCreating())
|
||||
wm->checkFocusAsync();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
TopLevelWindow::TopLevelWindow (const String& name, const bool shouldAddToDesktop)
|
||||
: Component (name),
|
||||
useDropShadow (true),
|
||||
useNativeTitleBar (false),
|
||||
isCurrentlyActive (false)
|
||||
: Component (name)
|
||||
{
|
||||
setOpaque (true);
|
||||
|
||||
|
|
@ -165,7 +156,7 @@ TopLevelWindow::~TopLevelWindow()
|
|||
//==============================================================================
|
||||
void TopLevelWindow::focusOfChildComponentChanged (FocusChangeType)
|
||||
{
|
||||
TopLevelWindowManager* const wm = TopLevelWindowManager::getInstance();
|
||||
auto* wm = TopLevelWindowManager::getInstance();
|
||||
|
||||
if (hasKeyboardFocus (true))
|
||||
wm->checkFocus();
|
||||
|
|
@ -194,7 +185,7 @@ bool TopLevelWindow::isUsingNativeTitleBar() const noexcept
|
|||
void TopLevelWindow::visibilityChanged()
|
||||
{
|
||||
if (isShowing())
|
||||
if (ComponentPeer* p = getPeer())
|
||||
if (auto* p = getPeer())
|
||||
if ((p->getStyleFlags() & (ComponentPeer::windowIsTemporary
|
||||
| ComponentPeer::windowIgnoresKeyPresses)) == 0)
|
||||
toFront (true);
|
||||
|
|
@ -302,10 +293,10 @@ void TopLevelWindow::centreAroundComponent (Component* c, const int width, const
|
|||
}
|
||||
else
|
||||
{
|
||||
Point<int> targetCentre (c->localPointToGlobal (c->getLocalBounds().getCentre()));
|
||||
Rectangle<int> parentArea (c->getParentMonitorArea());
|
||||
auto targetCentre = c->localPointToGlobal (c->getLocalBounds().getCentre());
|
||||
auto parentArea = c->getParentMonitorArea();
|
||||
|
||||
if (Component* const parent = getParentComponent())
|
||||
if (auto* parent = getParentComponent())
|
||||
{
|
||||
targetCentre = parent->getLocalPoint (nullptr, targetCentre);
|
||||
parentArea = parent->getLocalBounds();
|
||||
|
|
@ -336,13 +327,13 @@ TopLevelWindow* TopLevelWindow::getActiveTopLevelWindow() noexcept
|
|||
|
||||
for (int i = TopLevelWindow::getNumTopLevelWindows(); --i >= 0;)
|
||||
{
|
||||
TopLevelWindow* const tlw = TopLevelWindow::getTopLevelWindow (i);
|
||||
auto* tlw = TopLevelWindow::getTopLevelWindow (i);
|
||||
|
||||
if (tlw->isActiveWindow())
|
||||
{
|
||||
int numTWLParents = 0;
|
||||
|
||||
for (const Component* c = tlw->getParentComponent(); c != nullptr; c = c->getParentComponent())
|
||||
for (auto* c = tlw->getParentComponent(); c != nullptr; c = c->getParentComponent())
|
||||
if (dynamic_cast<const TopLevelWindow*> (c) != nullptr)
|
||||
++numTWLParents;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue