Skip to content

Commit

Permalink
ComponentPeer: Add isShowing() member, which more closely matches exp…
Browse files Browse the repository at this point in the history
…ected behaviour of Component::isShowing
  • Loading branch information
reuk committed Sep 18, 2024
1 parent 68d0ea9 commit 555b667
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ class UnityPeer final : public ComponentPeer,
//==============================================================================
void setMinimised (bool) override {}
bool isMinimised() const override { return false; }
bool isShowing() const override { return true; }
void setFullScreen (bool) override {}
bool isFullScreen() const override { return false; }
bool setAlwaysOnTop (bool) override { return false; }
Expand Down
2 changes: 1 addition & 1 deletion modules/juce_gui_basics/components/juce_Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ bool Component::isShowing() const
return parentComponent->isShowing();

if (auto* peer = getPeer())
return ! peer->isMinimised();
return peer->isShowing();

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ bool isMinimised() const override
return [window isMiniaturized];
}

bool isShowing() const override
{
return [window isVisible] && ! isMinimised();
}

NSWindowCollectionBehavior getCollectionBehavior (bool forceFullScreen) const
{
if (forceFullScreen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ void setViewController (UIViewController* newController) override
void setAlpha (float newAlpha) override;
void setMinimised (bool) override {}
bool isMinimised() const override { return false; }
bool isShowing() const override { return true; }
void setFullScreen (bool shouldBeFullScreen) override;
bool isFullScreen() const override { return fullScreen; }
bool contains (Point<int> localPos, bool trueIfInAChildWindow) const override;
Expand Down
5 changes: 5 additions & 0 deletions modules/juce_gui_basics/native/juce_Windowing_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,11 @@ class AndroidComponentPeer final : public ComponentPeer,
return false;
}

bool isShowing() const override
{
return true;
}

void setFullScreen (bool shouldBeFullScreen) override
{
if (shouldNavBarsBeHidden (shouldBeFullScreen))
Expand Down
5 changes: 5 additions & 0 deletions modules/juce_gui_basics/native/juce_Windowing_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ class LinuxComponentPeer final : public ComponentPeer,
return XWindowSystem::getInstance()->isMinimised (windowH);
}

bool isShowing() const override
{
return XWindowSystem::getInstance()->isMinimised (windowH);
}

void setFullScreen (bool shouldBeFullScreen) override
{
auto r = lastNonFullscreenBounds; // (get a copy of this before de-minimising)
Expand Down
5 changes: 5 additions & 0 deletions modules/juce_gui_basics/native/juce_Windowing_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,11 @@ class HWNDComponentPeer final : public ComponentPeer
return wp.showCmd == SW_SHOWMINIMIZED;
}

bool isShowing() const override
{
return IsWindowVisible (hwnd) && ! isMinimised();
}

void setFullScreen (bool shouldBeFullScreen) override
{
const ScopedValueSetter<bool> scope (shouldIgnoreModalDismiss, true);
Expand Down
3 changes: 3 additions & 0 deletions modules/juce_gui_basics/windows/juce_ComponentPeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ class JUCE_API ComponentPeer : private FocusChangeListener
/** True if the window is currently minimised. */
virtual bool isMinimised() const = 0;

/** True if the window is being displayed on-screen. */
virtual bool isShowing() const = 0;

/** Enable/disable fullscreen mode for the window. */
virtual void setFullScreen (bool shouldBeFullScreen) = 0;

Expand Down

0 comments on commit 555b667

Please sign in to comment.