Skip to content

Commit

Permalink
Add keybinding for fullscreen (default to F11), standalone only (#7366)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkruselj authored Dec 6, 2023
1 parent 5b68ef7 commit 60366dc
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 33 deletions.
102 changes: 74 additions & 28 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3916,42 +3916,50 @@ juce::PopupMenu SurgeGUIEditor::makeZoomMenu(const juce::Point<int> &where, bool
},
zoomStatus);
});
}

if (Surge::GUI::getIsStandalone())
{
juce::Component *comp = frame.get();

if (Surge::GUI::getIsStandalone())
while (comp)
{
juce::Component *comp = frame.get();
while (comp)
auto *cdw = dynamic_cast<juce::ResizableWindow *>(comp);

if (cdw)
{
auto *cdw = dynamic_cast<juce::ResizableWindow *>(comp);
if (cdw)
zoomSubMenu.addSeparator();

if (cdw->isFullScreen())
{
zoomSubMenu.addSeparator();
if (cdw->isFullScreen())
{
zoomSubMenu.addItem("Exit Full Screen",
[this, w = juce::Component::SafePointer(cdw)]() {
if (w)
{
w->setFullScreen(false);
}
});
}
else
{
zoomSubMenu.addItem("Enter Full Screen",
[w = juce::Component::SafePointer(cdw)]() {
if (w)
{
w->setFullScreen(true);
}
});
}
comp = nullptr;
Surge::GUI::addMenuWithShortcut(
zoomSubMenu, Surge::GUI::toOSCase("Exit Fullscreen Mode"),
showShortcutDescription("F11"),
[this, w = juce::Component::SafePointer(cdw)]() {
if (w)
{
w->setFullScreen(false);
}
});
}
else
{
comp = comp->getParentComponent();
Surge::GUI::addMenuWithShortcut(
zoomSubMenu, Surge::GUI::toOSCase("Enter Fullscreen Mode"),
showShortcutDescription("F11"),
[this, w = juce::Component::SafePointer(cdw)]() {
if (w)
{
w->setFullScreen(true);
}
});
}

comp = nullptr;
}
else
{
comp = comp->getParentComponent();
}
}
}
Expand Down Expand Up @@ -7423,6 +7431,11 @@ void SurgeGUIEditor::setupKeymapManager()
keyMapManager->addBinding(Surge::GUI::ZOOM_MINUS_10, {keymap_t::Modifiers::NONE, '-'});
keyMapManager->addBinding(Surge::GUI::ZOOM_MINUS_25, {keymap_t::Modifiers::SHIFT, '-'});

if (Surge::GUI::getIsStandalone())
{
keyMapManager->addBinding(Surge::GUI::ZOOM_FULLSCREEN, {juce::KeyPress::F11Key});
}

keyMapManager->addBinding(Surge::GUI::FOCUS_NEXT_CONTROL_GROUP,
{keymap_t::Modifiers::ALT, (int)'.'});
keyMapManager->addBinding(Surge::GUI::FOCUS_PRIOR_CONTROL_GROUP,
Expand Down Expand Up @@ -7651,10 +7664,43 @@ bool SurgeGUIEditor::keyPressed(const juce::KeyPress &key, juce::Component *orig
? -1
: 1;
auto jog = zl * di;

resizeWindow(getZoomFactor() + jog);

return true;
}
case Surge::GUI::ZOOM_FULLSCREEN:
{
if (Surge::GUI::getIsStandalone())
{
juce::Component *comp = frame.get();

while (comp)
{
auto *cdw = dynamic_cast<juce::ResizableWindow *>(comp);

if (cdw)
{
auto w = juce::Component::SafePointer(cdw);

if (w)
{
w->setFullScreen(!cdw->isFullScreen());
}

comp = nullptr;
}
else
{
comp = comp->getParentComponent();
}
}

return true;
}

return false;
}
case Surge::GUI::FOCUS_NEXT_CONTROL_GROUP:
case Surge::GUI::FOCUS_PRIOR_CONTROL_GROUP:
{
Expand Down
16 changes: 11 additions & 5 deletions src/surge-xt/gui/SurgeGUIEditorKeyboardActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ enum KeyboardActions
ZOOM_PLUS_25,
ZOOM_MINUS_10,
ZOOM_MINUS_25,
ZOOM_FULLSCREEN,

FOCUS_NEXT_CONTROL_GROUP,
FOCUS_PRIOR_CONTROL_GROUP,
Expand Down Expand Up @@ -169,6 +170,8 @@ inline std::string keyboardActionName(KeyboardActions a)
return "ZOOM_MINUS_10";
case ZOOM_MINUS_25:
return "ZOOM_MINUS_25";
case ZOOM_FULLSCREEN:
return "ZOOM_FULLSCREEN";

case REFRESH_SKIN:
return "REFRESH_SKIN";
Expand Down Expand Up @@ -303,19 +306,22 @@ inline std::string keyboardActionDescription(KeyboardActions a)
break;

case ZOOM_TO_DEFAULT:
desc = "Zoom to Default";
desc = Surge::GUI::toOSCase("Zoom: ") + Surge::GUI::toOSCase("Default");
break;
case ZOOM_PLUS_10:
desc = "Zoom +10%";
desc = "Zoom: +10%";
break;
case ZOOM_PLUS_25:
desc = "Zoom +25%";
desc = "Zoom: +25%";
break;
case ZOOM_MINUS_10:
desc = "Zoom -10%";
desc = "Zoom: -10%";
break;
case ZOOM_MINUS_25:
desc = "Zoom -25%";
desc = "Zoom: -25%";
break;
case ZOOM_FULLSCREEN:
desc = Surge::GUI::toOSCase("Zoom: ") + Surge::GUI::toOSCase("Toggle Fullscreen");
break;

case REFRESH_SKIN:
Expand Down

0 comments on commit 60366dc

Please sign in to comment.