Skip to content

Commit

Permalink
Rename Surge::GUI:toOSCaseForMenu (#6017)
Browse files Browse the repository at this point in the history
* Rename Surge::GUI:toOSCaseForMenu

Also document it.
  • Loading branch information
mkruselj authored Apr 5, 2022
1 parent 7074d54 commit 6c2b352
Show file tree
Hide file tree
Showing 13 changed files with 450 additions and 472 deletions.
500 changes: 243 additions & 257 deletions src/surge-xt/gui/SurgeGUIEditor.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/surge-xt/gui/SurgeGUIEditorKeyboardActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ inline std::string keyboardActionDescription(KeyboardActions a)
break;
};

return skipOSCase ? desc : Surge::GUI::toOSCaseForMenu(desc);
return skipOSCase ? desc : Surge::GUI::toOSCase(desc);
}

} // namespace GUI
Expand Down
193 changes: 90 additions & 103 deletions src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions src/surge-xt/gui/SurgeGUIUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,24 @@ namespace Surge
namespace GUI
{

std::string toOSCaseForMenu(const std::string &imenuName)
/*
* Used to convert letter case for menu entries
* Input string should be macOS style (Menu Entry is Like This)
* Output is string in Windows style (Menu entry is like this), or unmodified if we're on Mac
*/
std::string toOSCase(const std::string &imenuName)
{
#if WINDOWS
auto menuName = imenuName;

for (auto i = 1; i < menuName.length() - 1; ++i)
{
if (!(isupper(menuName[i]) && (isupper(menuName[i + 1]) || !isalpha(menuName[i + 1]))))
{
menuName[i] = std::tolower(menuName[i]);
}
}

return menuName;
#else
return imenuName;
Expand All @@ -45,9 +54,9 @@ bool isTouchMode(SurgeStorage *storage)
}

/*
* We kinda want to know if we are standalone here, but don't have reference to the processor
* but that's a constant for a process (you can't mix standalone and not) so make it a static
* and explicitly grab this symbol in the SGE startup path
* We want to know if we are standalone here, but we don't have a reference to the processor
* Since that is a constant for a process (you can't mix standalone and not), make it a static
* and explicitly grab this symbol in the SurgeGUIEditor startup path
*/
static bool isStandalone{false};
void setIsStandalone(bool b) { isStandalone = b; }
Expand All @@ -72,8 +81,10 @@ bool allowKeyboardEdits(SurgeStorage *storage)
return res;
}

// Returns 1 if the lines intersect, otherwise 0. In addition, if the lines
// intersect, the intersection point may be stored in the floats i_x and i_y.
/*
* Returns true if the two lines (p0-p1 and p2-p3) intersect.
* In addition, if the lines intersect, the intersection point may be stored to floats i_x and i_y.
*/
bool get_line_intersection(float p0_x, float p0_y, float p1_x, float p1_y, float p2_x, float p2_y,
float p3_x, float p3_y, float *i_x, float *i_y)
{
Expand Down Expand Up @@ -106,7 +117,7 @@ void openFileOrFolder(const std::string &f)

if (path.isDirectory())
{
// See this for why we branch out linux here
// See this for why we branch out Linux here
// https://forum.juce.com/t/linux-spaces-in-path-startasprocess-and-process-opendocument/47296
#if LINUX
if (vfork() == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/gui/SurgeGUIUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Surge
{
namespace GUI
{
std::string toOSCaseForMenu(const std::string &menuName);
std::string toOSCase(const std::string &menuName);

extern bool showCursor(SurgeStorage *storage);
extern bool allowKeyboardEdits(SurgeStorage *storage);
Expand Down
85 changes: 41 additions & 44 deletions src/surge-xt/gui/overlays/MSEGEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2346,15 +2346,15 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
{
if (tts <= ms->loop_end + 1 && tts != ms->loop_start)
{
contextMenu.addItem(Surge::GUI::toOSCaseForMenu("Set Loop Start"), [this, tts]() {
contextMenu.addItem(Surge::GUI::toOSCase("Set Loop Start"), [this, tts]() {
Surge::MSEG::setLoopStart(ms, tts);
modelChanged();
});
}

if (tts >= ms->loop_start - 1 && tts != ms->loop_end)
{
contextMenu.addItem(Surge::GUI::toOSCaseForMenu("Set Loop End"), [this, tts, t]() {
contextMenu.addItem(Surge::GUI::toOSCase("Set Loop End"), [this, tts, t]() {
auto along = t - ms->segmentStart[tts];

if (ms->segments[tts].duration == 0)
Expand Down Expand Up @@ -2400,45 +2400,45 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

actionsMenu.addSeparator();

actionsMenu.addItem(Surge::GUI::toOSCaseForMenu("Double Duration"), [this]() {
actionsMenu.addItem(Surge::GUI::toOSCase("Double Duration"), [this]() {
Surge::MSEG::scaleDurations(this->ms, 2.0, longestMSEG);
modelChanged();
zoomToFull();
});

actionsMenu.addItem(Surge::GUI::toOSCaseForMenu("Half Duration"), [this]() {
actionsMenu.addItem(Surge::GUI::toOSCase("Half Duration"), [this]() {
Surge::MSEG::scaleDurations(this->ms, 0.5, longestMSEG);
modelChanged();
zoomToFull();
});

actionsMenu.addSeparator();

actionsMenu.addItem(Surge::GUI::toOSCaseForMenu("Flip Vertically"), [this]() {
actionsMenu.addItem(Surge::GUI::toOSCase("Flip Vertically"), [this]() {
Surge::MSEG::scaleValues(this->ms, -1);
modelChanged();
});

actionsMenu.addItem(Surge::GUI::toOSCaseForMenu("Flip Horizontally"), [this]() {
actionsMenu.addItem(Surge::GUI::toOSCase("Flip Horizontally"), [this]() {
Surge::MSEG::mirrorMSEG(this->ms);
modelChanged();
});

actionsMenu.addSeparator();

actionsMenu.addItem(Surge::GUI::toOSCaseForMenu("Quantize Nodes to Snap Divisions"),
actionsMenu.addItem(Surge::GUI::toOSCase("Quantize Nodes to Snap Divisions"),
(ms->editMode != MSEGStorage::LFO), false, [this]() {
Surge::MSEG::setAllDurationsTo(this->ms, ms->hSnapDefault);
modelChanged();
});

actionsMenu.addItem(Surge::GUI::toOSCaseForMenu("Quantize Nodes to Whole Units"),
actionsMenu.addItem(Surge::GUI::toOSCase("Quantize Nodes to Whole Units"),
(ms->editMode != MSEGStorage::LFO), false, [this]() {
Surge::MSEG::setAllDurationsTo(this->ms, 1.0);
modelChanged();
});

actionsMenu.addItem(Surge::GUI::toOSCaseForMenu("Distribute Nodes Evenly"), [this]() {
actionsMenu.addItem(Surge::GUI::toOSCase("Distribute Nodes Evenly"), [this]() {
Surge::MSEG::setAllDurationsTo(this->ms,
ms->totalDuration / this->ms->n_activeSegments);
modelChanged();
Expand All @@ -2448,7 +2448,7 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

auto createMenu = juce::PopupMenu();

createMenu.addItem(Surge::GUI::toOSCaseForMenu("Minimal MSEG"), [this]() {
createMenu.addItem(Surge::GUI::toOSCase("Minimal MSEG"), [this]() {
Surge::MSEG::clearMSEG(this->ms);
this->zoomToFull();
if (controlregion)
Expand All @@ -2458,15 +2458,15 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

createMenu.addSeparator();

createMenu.addItem(Surge::GUI::toOSCaseForMenu("Default Voice MSEG"), [this]() {
createMenu.addItem(Surge::GUI::toOSCase("Default Voice MSEG"), [this]() {
Surge::MSEG::createInitVoiceMSEG(this->ms);
this->zoomToFull();
if (controlregion)
controlregion->rebuild();
modelChanged();
});

createMenu.addItem(Surge::GUI::toOSCaseForMenu("Default Scene MSEG"), [this]() {
createMenu.addItem(Surge::GUI::toOSCase("Default Scene MSEG"), [this]() {
Surge::MSEG::createInitSceneMSEG(this->ms);
this->zoomToFull();
if (controlregion)
Expand All @@ -2480,22 +2480,21 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

for (int i : stepCounts)
{
createMenu.addItem(
Surge::GUI::toOSCaseForMenu(std::to_string(i) + " Step Sequencer"),
[this, i]() {
Surge::MSEG::createStepseqMSEG(this->ms, i);
this->zoomToFull();
if (controlregion)
controlregion->rebuild();
modelChanged();
});
createMenu.addItem(Surge::GUI::toOSCase(std::to_string(i) + " Step Sequencer"),
[this, i]() {
Surge::MSEG::createStepseqMSEG(this->ms, i);
this->zoomToFull();
if (controlregion)
controlregion->rebuild();
modelChanged();
});
}

createMenu.addSeparator();

for (int i : stepCounts)
{
createMenu.addItem(Surge::GUI::toOSCaseForMenu(std::to_string(i) + " Lines Sine"),
createMenu.addItem(Surge::GUI::toOSCase(std::to_string(i) + " Lines Sine"),
[this, i] {
Surge::MSEG::createSinLineMSEG(this->ms, i);
this->zoomToFull();
Expand All @@ -2512,15 +2511,14 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
// we're fine with a max of 32 sawtooth plucks methinks - ED
if (i <= 32)
{
createMenu.addItem(
Surge::GUI::toOSCaseForMenu(std::to_string(i) + " Sawtooth Plucks"),
[this, i]() {
Surge::MSEG::createSawMSEG(this->ms, i, 0.5);
this->zoomToFull();
if (controlregion)
controlregion->rebuild();
modelChanged();
});
createMenu.addItem(Surge::GUI::toOSCase(std::to_string(i) + " Sawtooth Plucks"),
[this, i]() {
Surge::MSEG::createSawMSEG(this->ms, i, 0.5);
this->zoomToFull();
if (controlregion)
controlregion->rebuild();
modelChanged();
});
}
}

Expand All @@ -2530,14 +2528,14 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
{
auto triggerMenu = juce::PopupMenu();

triggerMenu.addItem(Surge::GUI::toOSCaseForMenu("Filter EG"), true,
triggerMenu.addItem(Surge::GUI::toOSCase("Filter EG"), true,
(ms->segments[tts].retriggerFEG), [this, tts]() {
this->ms->segments[tts].retriggerFEG =
!this->ms->segments[tts].retriggerFEG;
modelChanged();
});

triggerMenu.addItem(Surge::GUI::toOSCaseForMenu("Amp EG"), true,
triggerMenu.addItem(Surge::GUI::toOSCase("Amp EG"), true,
(ms->segments[tts].retriggerAEG), [this, tts]() {
this->ms->segments[tts].retriggerAEG =
!this->ms->segments[tts].retriggerAEG;
Expand All @@ -2546,13 +2544,13 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

triggerMenu.addSeparator();

triggerMenu.addItem(Surge::GUI::toOSCaseForMenu("Nothing"), [this, tts]() {
triggerMenu.addItem(Surge::GUI::toOSCase("Nothing"), [this, tts]() {
this->ms->segments[tts].retriggerFEG = false;
this->ms->segments[tts].retriggerAEG = false;
modelChanged();
});

triggerMenu.addItem(Surge::GUI::toOSCaseForMenu("All"), [this, tts]() {
triggerMenu.addItem(Surge::GUI::toOSCase("All"), [this, tts]() {
this->ms->segments[tts].retriggerFEG = true;
this->ms->segments[tts].retriggerAEG = true;
modelChanged();
Expand All @@ -2564,7 +2562,7 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp
auto settingsMenu = juce::PopupMenu();

settingsMenu.addItem(
Surge::GUI::toOSCaseForMenu("Link Start and End Nodes"), true,
Surge::GUI::toOSCase("Link Start and End Nodes"), true,
(ms->endpointMode == MSEGStorage::EndpointMode::LOCKED), [this]() {
if (this->ms->endpointMode == MSEGStorage::EndpointMode::LOCKED)
{
Expand All @@ -2580,14 +2578,14 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

settingsMenu.addSeparator();

settingsMenu.addItem(Surge::GUI::toOSCaseForMenu("Deform Applied to Segment"), true,
settingsMenu.addItem(Surge::GUI::toOSCase("Deform Applied to Segment"), true,
ms->segments[tts].useDeform, [this, tts]() {
this->ms->segments[tts].useDeform =
!this->ms->segments[tts].useDeform;
modelChanged();
});

settingsMenu.addItem(Surge::GUI::toOSCaseForMenu("Invert Deform Value"), true,
settingsMenu.addItem(Surge::GUI::toOSCase("Invert Deform Value"), true,
ms->segments[tts].invertDeform, [this, tts]() {
this->ms->segments[tts].invertDeform =
!this->ms->segments[tts].invertDeform;
Expand Down Expand Up @@ -2620,7 +2618,7 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

typeTo("Hold", MSEGStorage::segment::Type::HOLD);
typeTo("Linear", MSEGStorage::segment::Type::LINEAR);
typeTo(Surge::GUI::toOSCaseForMenu("S-Curve"), MSEGStorage::segment::Type::SCURVE);
typeTo(Surge::GUI::toOSCase("S-Curve"), MSEGStorage::segment::Type::SCURVE);
typeTo("Bezier", MSEGStorage::segment::Type::QUAD_BEZIER);

contextMenu.addSeparator();
Expand All @@ -2634,10 +2632,9 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp

typeTo("Bump", MSEGStorage::segment::Type::BUMP);
typeTo("Stairs", MSEGStorage::segment::Type::STAIRS);
typeTo(Surge::GUI::toOSCaseForMenu("Smooth Stairs"),
typeTo(Surge::GUI::toOSCase("Smooth Stairs"),
MSEGStorage::segment::Type::SMOOTH_STAIRS);
typeTo(Surge::GUI::toOSCaseForMenu("Brownian Bridge"),
MSEGStorage::segment::Type::BROWNIAN);
typeTo(Surge::GUI::toOSCase("Brownian Bridge"), MSEGStorage::segment::Type::BROWNIAN);

contextMenu.showMenuAsync(sge->popupMenuOptions());
}
Expand Down Expand Up @@ -2891,7 +2888,7 @@ int32_t MSEGControlRegion::controlModifierClicked(Surge::GUI::IComponentTagValue
options.push_back(std::make_pair("Off", 0));
options.push_back(std::make_pair("Loop", 0.5));
options.push_back(
std::make_pair(Surge::GUI::toOSCaseForMenu("Gate (Loop Until Release)").c_str(), 1.0));
std::make_pair(Surge::GUI::toOSCase("Gate (Loop Until Release)").c_str(), 1.0));
break;

case tag_edit_mode:
Expand Down Expand Up @@ -3037,7 +3034,7 @@ int32_t MSEGControlRegion::controlModifierClicked(Surge::GUI::IComponentTagValue
typeinEditor->grabFocus();
};

contextMenu.addItem(Surge::GUI::toOSCaseForMenu("Edit Value: ") + val, true, false,
contextMenu.addItem(Surge::GUI::toOSCase("Edit Value: ") + val, true, false,
showTypein);
}

Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/gui/overlays/ModulationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ void ModulationSideControls::valueChanged(GUI::IComponentTagValue *c)
{
men.addSeparator();

men.addItem(Surge::GUI::toOSCaseForMenu("Clear Filter"), [this]() {
men.addItem(Surge::GUI::toOSCase("Clear Filter"), [this]() {
editor->modContents->clearFilters();
filterL->setText("Filter By", juce::NotificationType::dontSendNotification);
filterW->setLabels({"-"});
Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/gui/overlays/PatchStoreDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ PatchStoreDialog::PatchStoreDialog()

auto stbTitle = "Store Tuning in Patch";

storeTuningLabel = makeL(Surge::GUI::toOSCaseForMenu(stbTitle));
storeTuningLabel = makeL(Surge::GUI::toOSCase(stbTitle));

storeTuningButton = std::make_unique<juce::ToggleButton>();
storeTuningButton->setButtonText("");
Expand Down
22 changes: 11 additions & 11 deletions src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,22 +2193,22 @@ void LFOAndStepDisplay::showLFODisplayPopupMenu(SurgeGUIEditor::OverlayTags tag)

std::string openname = (sge->isAnyOverlayPresent(tag)) ? "Close " : "Open ";

Surge::GUI::addMenuWithShortcut(
contextMenu, Surge::GUI::toOSCaseForMenu(openname + olname + "..."),
sge->showShortcutDescription("Alt+E", "⌥E"), [this, sge, tag]() {
if (sge)
{
sge->toggleOverlay(tag);
}
});
Surge::GUI::addMenuWithShortcut(contextMenu, Surge::GUI::toOSCase(openname + olname + "..."),
sge->showShortcutDescription("Alt+E", "⌥E"),
[this, sge, tag]() {
if (sge)
{
sge->toggleOverlay(tag);
}
});

if (isMSEG())
{
contextMenu.addSeparator();

bool isChecked = ms->loopMode == MSEGStorage::ONESHOT;

contextMenu.addItem(Surge::GUI::toOSCaseForMenu("No Looping"), true, isChecked,
contextMenu.addItem(Surge::GUI::toOSCase("No Looping"), true, isChecked,
[this, isChecked, sge]() {
if (isChecked)
{
Expand All @@ -2228,7 +2228,7 @@ void LFOAndStepDisplay::showLFODisplayPopupMenu(SurgeGUIEditor::OverlayTags tag)

isChecked = ms->loopMode == MSEGStorage::LOOP;

contextMenu.addItem(Surge::GUI::toOSCaseForMenu("Loop Always"), true, isChecked,
contextMenu.addItem(Surge::GUI::toOSCase("Loop Always"), true, isChecked,
[this, isChecked, sge]() {
if (isChecked)
{
Expand All @@ -2248,7 +2248,7 @@ void LFOAndStepDisplay::showLFODisplayPopupMenu(SurgeGUIEditor::OverlayTags tag)

isChecked = ms->loopMode == MSEGStorage::GATED_LOOP;

contextMenu.addItem(Surge::GUI::toOSCaseForMenu("Loop Until Release"), true, isChecked,
contextMenu.addItem(Surge::GUI::toOSCase("Loop Until Release"), true, isChecked,
[this, isChecked, sge]() {
if (isChecked)
{
Expand Down
Loading

0 comments on commit 6c2b352

Please sign in to comment.