Browse Source

DemoRunner: Use Display::safeAreaInsets to position demo content

tags/2021-05-28
ed 4 years ago
parent
commit
78a09bdfc6
1 changed files with 12 additions and 5 deletions
  1. +12
    -5
      examples/DemoRunner/Source/UI/MainComponent.cpp

+ 12
- 5
examples/DemoRunner/Source/UI/MainComponent.cpp View File

@@ -313,14 +313,21 @@ void MainComponent::paint (Graphics& g)
void MainComponent::resized()
{
auto bounds = getLocalBounds();
auto safeBounds = [this]
{
auto bounds = getLocalBounds();
if (auto* display = Desktop::getInstance().getDisplays().getDisplayForRect (getScreenBounds()))
return display->safeAreaInsets.subtractedFrom (bounds);
showDemosButton.setBounds (0, 0, 150, contentComponent->getTabBarDepth());
return bounds;
}();
showDemosButton.setBounds (safeBounds.getX(), safeBounds.getY(), 150, contentComponent->getTabBarDepth());
if (isShowingHeavyweightDemo)
{
bounds.removeFromLeft (sidePanelWidth);
safeBounds.removeFromLeft (sidePanelWidth);
contentComponent->setTabBarIndent (jmax (0, 150 - sidePanelWidth));
}
else
@@ -328,7 +335,7 @@ void MainComponent::resized()
contentComponent->setTabBarIndent (150);
}
contentComponent->setBounds (bounds);
contentComponent->setBounds (safeBounds);
}
void MainComponent::homeButtonClicked()


Loading…
Cancel
Save