1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-16 00:34:19 +00:00

Set the default value of JUCE_MODAL_LOOPS_PERMITTED to 0

See BREAKING-CHANGES.txt for more details.
This commit is contained in:
Tom Poole 2021-06-30 13:00:21 +01:00
parent f1768843fb
commit fe4ba9071b
79 changed files with 3423 additions and 1332 deletions

View file

@ -98,7 +98,7 @@ static bool writeCodeDocToFile (const File& file, CodeDocument& doc)
return temp.overwriteTargetFileWithTemporary();
}
bool SourceCodeDocument::save()
bool SourceCodeDocument::saveSyncWithoutAsking()
{
if (writeCodeDocToFile (getFile(), getCodeDocument()))
{
@ -110,14 +110,28 @@ bool SourceCodeDocument::save()
return false;
}
bool SourceCodeDocument::saveAs()
void SourceCodeDocument::saveAsync (std::function<void (bool)> callback)
{
FileChooser fc (TRANS("Save As..."), getFile(), "*");
callback (saveSyncWithoutAsking());
}
if (! fc.browseForFileToSave (true))
return true;
void SourceCodeDocument::saveAsAsync (std::function<void (bool)> callback)
{
chooser = std::make_unique<FileChooser> (TRANS("Save As..."), getFile(), "*");
auto flags = FileBrowserComponent::saveMode
| FileBrowserComponent::canSelectFiles
| FileBrowserComponent::warnAboutOverwriting;
return writeCodeDocToFile (fc.getResult(), getCodeDocument());
chooser->launchAsync (flags, [this, callback] (const FileChooser& fc)
{
if (fc.getResult() == File{})
{
callback (true);
return;
}
callback (writeCodeDocToFile (fc.getResult(), getCodeDocument()));
});
}
void SourceCodeDocument::updateLastState (CodeEditorComponent& editor)
@ -642,18 +656,31 @@ void CppCodeEditorComponent::performPopupMenuAction (int menuItemID)
void CppCodeEditorComponent::insertComponentClass()
{
AlertWindow aw (TRANS ("Insert a new Component class"),
TRANS ("Please enter a name for the new class"),
AlertWindow::NoIcon, nullptr);
asyncAlertWindow = std::make_unique<AlertWindow> (TRANS ("Insert a new Component class"),
TRANS ("Please enter a name for the new class"),
AlertWindow::NoIcon,
nullptr);
const char* classNameField = "Class Name";
const String classNameField { "Class Name" };
aw.addTextEditor (classNameField, String(), String(), false);
aw.addButton (TRANS ("Insert Code"), 1, KeyPress (KeyPress::returnKey));
aw.addButton (TRANS ("Cancel"), 0, KeyPress (KeyPress::escapeKey));
asyncAlertWindow->addTextEditor (classNameField, String(), String(), false);
asyncAlertWindow->addButton (TRANS ("Insert Code"), 1, KeyPress (KeyPress::returnKey));
asyncAlertWindow->addButton (TRANS ("Cancel"), 0, KeyPress (KeyPress::escapeKey));
while (aw.runModalLoop() != 0)
SafePointer<CppCodeEditorComponent> parent { this };
asyncAlertWindow->enterModalState (true, ModalCallbackFunction::create ([parent, classNameField] (int result)
{
if (parent == nullptr)
return;
auto& aw = *(parent->asyncAlertWindow);
aw.exitModalState (result);
aw.setVisible (false);
if (result == 0)
return;
auto className = aw.getTextEditorContents (classNameField).trim();
if (className == build_tools::makeValidIdentifier (className, false, true, false))
@ -661,8 +688,10 @@ void CppCodeEditorComponent::insertComponentClass()
String code (BinaryData::jucer_InlineComponentTemplate_h);
code = code.replace ("%%component_class%%", className);
insertTextAtCaret (code);
break;
parent->insertTextAtCaret (code);
return;
}
}
parent->insertComponentClass();
}));
}