|
|
|
@@ -329,7 +329,8 @@ ApplicationCommandManager& ProjucerApplication::getCommandManager() |
|
|
|
enum
|
|
|
|
{
|
|
|
|
recentProjectsBaseID = 100,
|
|
|
|
activeDocumentsBaseID = 300,
|
|
|
|
openWindowsBaseID = 300,
|
|
|
|
activeDocumentsBaseID = 400,
|
|
|
|
colourSchemeBaseID = 1000,
|
|
|
|
codeEditorColourSchemeBaseID = 2000,
|
|
|
|
};
|
|
|
|
@@ -341,18 +342,19 @@ MenuBarModel* ProjucerApplication::getMenuModel() |
|
|
|
|
|
|
|
StringArray ProjucerApplication::getMenuNames()
|
|
|
|
{
|
|
|
|
return { "File", "Edit", "View", "Build", "Window", "GUI Editor", "Tools", "Help" };
|
|
|
|
return { "File", "Edit", "View", "Build", "Window", "Document", "GUI Editor", "Tools", "Help" };
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjucerApplication::createMenu (PopupMenu& menu, const String& menuName)
|
|
|
|
{
|
|
|
|
if (menuName == "File") createFileMenu (menu);
|
|
|
|
else if (menuName == "Edit") createEditMenu (menu);
|
|
|
|
else if (menuName == "View") createViewMenu (menu);
|
|
|
|
else if (menuName == "Build") createBuildMenu (menu);
|
|
|
|
else if (menuName == "Window") createWindowMenu (menu);
|
|
|
|
else if (menuName == "Tools") createToolsMenu (menu);
|
|
|
|
else if (menuName == "Help") createHelpMenu (menu);
|
|
|
|
if (menuName == "File") createFileMenu (menu);
|
|
|
|
else if (menuName == "Edit") createEditMenu (menu);
|
|
|
|
else if (menuName == "View") createViewMenu (menu);
|
|
|
|
else if (menuName == "Build") createBuildMenu (menu);
|
|
|
|
else if (menuName == "Window") createWindowMenu (menu);
|
|
|
|
else if (menuName == "Document") createDocumentMenu (menu);
|
|
|
|
else if (menuName == "Tools") createToolsMenu (menu);
|
|
|
|
else if (menuName == "Help") createHelpMenu (menu);
|
|
|
|
else if (menuName == "GUI Editor") createGUIEditorMenu (menu);
|
|
|
|
else jassertfalse; // names have changed?
|
|
|
|
}
|
|
|
|
@@ -363,9 +365,19 @@ void ProjucerApplication::createFileMenu (PopupMenu& menu) |
|
|
|
menu.addSeparator();
|
|
|
|
menu.addCommandItem (commandManager, CommandIDs::open);
|
|
|
|
|
|
|
|
PopupMenu recentFiles;
|
|
|
|
settings->recentFiles.createPopupMenuItems (recentFiles, recentProjectsBaseID, true, true);
|
|
|
|
menu.addSubMenu ("Open Recent", recentFiles);
|
|
|
|
{
|
|
|
|
PopupMenu recentFiles;
|
|
|
|
|
|
|
|
settings->recentFiles.createPopupMenuItems (recentFiles, recentProjectsBaseID, true, true);
|
|
|
|
|
|
|
|
if (recentFiles.getNumItems() > 0)
|
|
|
|
{
|
|
|
|
recentFiles.addSeparator();
|
|
|
|
recentFiles.addCommandItem (commandManager, CommandIDs::clearRecentFiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.addSubMenu ("Open Recent", recentFiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.addSeparator();
|
|
|
|
menu.addCommandItem (commandManager, CommandIDs::closeDocument);
|
|
|
|
@@ -485,12 +497,28 @@ void ProjucerApplication::createWindowMenu (PopupMenu& menu) |
|
|
|
menu.addCommandItem (commandManager, CommandIDs::closeWindow);
|
|
|
|
menu.addSeparator();
|
|
|
|
|
|
|
|
int counter = 0;
|
|
|
|
for (auto* window : mainWindowList.windows)
|
|
|
|
{
|
|
|
|
if (window != nullptr)
|
|
|
|
{
|
|
|
|
if (auto* project = window->getProject())
|
|
|
|
menu.addItem (openWindowsBaseID + counter++, project->getProjectNameString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.addSeparator();
|
|
|
|
menu.addCommandItem (commandManager, CommandIDs::closeAllWindows);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjucerApplication::createDocumentMenu (PopupMenu& menu)
|
|
|
|
{
|
|
|
|
menu.addCommandItem (commandManager, CommandIDs::goToPreviousDoc);
|
|
|
|
menu.addCommandItem (commandManager, CommandIDs::goToNextDoc);
|
|
|
|
menu.addCommandItem (commandManager, CommandIDs::goToCounterpart);
|
|
|
|
menu.addSeparator();
|
|
|
|
|
|
|
|
const int numDocs = jmin (50, openDocumentManager.getNumOpenDocuments());
|
|
|
|
auto numDocs = jmin (50, openDocumentManager.getNumOpenDocuments());
|
|
|
|
|
|
|
|
for (int i = 0; i < numDocs; ++i)
|
|
|
|
{
|
|
|
|
@@ -533,9 +561,14 @@ void ProjucerApplication::handleMainMenuCommand (int menuItemID) |
|
|
|
// open a file from the "recent files" menu
|
|
|
|
openFile (settings->recentFiles.getFile (menuItemID - recentProjectsBaseID));
|
|
|
|
}
|
|
|
|
else if (menuItemID >= openWindowsBaseID && menuItemID < (openWindowsBaseID + 100))
|
|
|
|
{
|
|
|
|
if (auto* window = mainWindowList.windows.getUnchecked (menuItemID - openWindowsBaseID))
|
|
|
|
window->toFront (true);
|
|
|
|
}
|
|
|
|
else if (menuItemID >= activeDocumentsBaseID && menuItemID < (activeDocumentsBaseID + 200))
|
|
|
|
{
|
|
|
|
if (OpenDocumentManager::Document* doc = openDocumentManager.getOpenDocument (menuItemID - activeDocumentsBaseID))
|
|
|
|
if (auto* doc = openDocumentManager.getOpenDocument (menuItemID - activeDocumentsBaseID))
|
|
|
|
mainWindowList.openDocument (doc, true);
|
|
|
|
else
|
|
|
|
jassertfalse;
|
|
|
|
@@ -566,7 +599,9 @@ void ProjucerApplication::getAllCommands (Array <CommandID>& commands) |
|
|
|
|
|
|
|
const CommandID ids[] = { CommandIDs::newProject,
|
|
|
|
CommandIDs::open,
|
|
|
|
CommandIDs::closeAllWindows,
|
|
|
|
CommandIDs::closeAllDocuments,
|
|
|
|
CommandIDs::clearRecentFiles,
|
|
|
|
CommandIDs::saveAll,
|
|
|
|
CommandIDs::showGlobalPathsWindow,
|
|
|
|
CommandIDs::showUTF8Tool,
|
|
|
|
@@ -602,11 +637,21 @@ void ProjucerApplication::getCommandInfo (CommandID commandID, ApplicationComman |
|
|
|
CommandCategories::general, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CommandIDs::closeAllWindows:
|
|
|
|
result.setInfo ("Close All Windows", "Closes all open windows", CommandCategories::general, 0);
|
|
|
|
result.setActive (mainWindowList.windows.size() > 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CommandIDs::closeAllDocuments:
|
|
|
|
result.setInfo ("Close All Documents", "Closes all open documents", CommandCategories::general, 0);
|
|
|
|
result.setActive (openDocumentManager.getNumOpenDocuments() > 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CommandIDs::clearRecentFiles:
|
|
|
|
result.setInfo ("Clear Recent Files", "Clears all recent files from the menu", CommandCategories::general, 0);
|
|
|
|
result.setActive (settings->recentFiles.getNumFiles() > 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CommandIDs::saveAll:
|
|
|
|
result.setInfo ("Save All", "Saves all open documents", CommandCategories::general, 0);
|
|
|
|
result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier | ModifierKeys::altModifier, 0));
|
|
|
|
@@ -676,7 +721,9 @@ bool ProjucerApplication::perform (const InvocationInfo& info) |
|
|
|
case CommandIDs::newProject: createNewProject(); break;
|
|
|
|
case CommandIDs::open: askUserToOpenFile(); break;
|
|
|
|
case CommandIDs::saveAll: openDocumentManager.saveAll(); break;
|
|
|
|
case CommandIDs::closeAllWindows: closeAllMainWindowsAndQuitIfNeeded(); break;
|
|
|
|
case CommandIDs::closeAllDocuments: closeAllDocuments (true); break;
|
|
|
|
case CommandIDs::clearRecentFiles: clearRecentFiles(); break;
|
|
|
|
case CommandIDs::showUTF8Tool: showUTF8ToolWindow(); break;
|
|
|
|
case CommandIDs::showSVGPathTool: showSVGPathDataToolWindow(); break;
|
|
|
|
case CommandIDs::showGlobalPathsWindow: showPathsWindow(); break;
|
|
|
|
@@ -729,6 +776,25 @@ bool ProjucerApplication::closeAllMainWindows() |
|
|
|
return server != nullptr || mainWindowList.askAllWindowsToClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjucerApplication::closeAllMainWindowsAndQuitIfNeeded()
|
|
|
|
{
|
|
|
|
if (closeAllMainWindows())
|
|
|
|
{
|
|
|
|
#if ! JUCE_MAC
|
|
|
|
if (mainWindowList.windows.size() == 0)
|
|
|
|
systemRequestedQuit();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjucerApplication::clearRecentFiles()
|
|
|
|
{
|
|
|
|
settings->recentFiles.clear();
|
|
|
|
settings->recentFiles.clearRecentFilesNatively();
|
|
|
|
settings->flush();
|
|
|
|
menuModel->menuItemsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
void ProjucerApplication::showUTF8ToolWindow()
|
|
|
|
{
|
|
|
|
|