Browse Source

Introjucer: misc internal refactoring.

tags/2021-05-28
jules 13 years ago
parent
commit
c65c7dd4a4
13 changed files with 156 additions and 136 deletions
  1. +1
    -1
      extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp
  2. +111
    -105
      extras/Introjucer/Source/Application/jucer_Application.h
  3. +2
    -1
      extras/Introjucer/Source/Application/jucer_CommandIDs.h
  4. +2
    -2
      extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp
  5. +8
    -8
      extras/Introjucer/Source/Application/jucer_MainWindow.cpp
  6. +3
    -3
      extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp
  7. +1
    -1
      extras/Introjucer/Source/Project/jucer_ConfigPage.cpp
  8. +1
    -1
      extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp
  9. +2
    -2
      extras/Introjucer/Source/Project/jucer_Project.cpp
  10. +21
    -8
      extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp
  11. +1
    -1
      extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp
  12. +1
    -1
      extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h
  13. +2
    -2
      extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp

+ 1
- 1
extras/Introjucer/Source/Application/jucer_AppearanceSettings.cpp View File

@@ -209,7 +209,7 @@ struct AppearanceEditor
void closeButtonPressed()
{
JucerApplication::getApp()->appearanceEditorWindow = nullptr;
JucerApplication::getApp().appearanceEditorWindow = nullptr;
}
private:


+ 111
- 105
extras/Introjucer/Source/Application/jucer_Application.h View File

@@ -132,9 +132,11 @@ public:
openFile (commandLine.unquoted());
}
static JucerApplication* getApp()
static JucerApplication& getApp()
{
return dynamic_cast<JucerApplication*> (JUCEApplication::getInstance());
JucerApplication* const app = dynamic_cast<JucerApplication*> (JUCEApplication::getInstance());
jassert (app != nullptr);
return *app;
}
//==============================================================================
@@ -148,126 +150,131 @@ public:
StringArray getMenuBarNames()
{
const char* const names[] = { "File", "Edit", "View", "Window", "Tools", 0 };
return StringArray ((const char**) names);
return getApp().getMenuNames();
}
PopupMenu getMenuForIndex (int topLevelMenuIndex, const String& /*menuName*/)
PopupMenu getMenuForIndex (int /*topLevelMenuIndex*/, const String& menuName)
{
PopupMenu menu;
getApp().createMenu (menu, menuName);
return menu;
}
if (topLevelMenuIndex == 0) // "File" menu
void menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/)
{
if (menuItemID >= 100 && menuItemID < 200)
{
menu.addCommandItem (commandManager, CommandIDs::newProject);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::open);
PopupMenu recentFiles;
getAppSettings().recentFiles.createPopupMenuItems (recentFiles, 100, true, true);
menu.addSubMenu ("Open recent file", recentFiles);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::closeDocument);
menu.addCommandItem (commandManager, CommandIDs::saveDocument);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::closeProject);
menu.addCommandItem (commandManager, CommandIDs::saveProject);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::openInIDE);
menu.addCommandItem (commandManager, CommandIDs::saveAndOpenInIDE);
#if ! JUCE_MAC
menu.addSeparator();
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::quit);
#endif
// open a file from the "recent files" menu
getApp().openFile (getAppSettings().recentFiles.getFile (menuItemID - 100));
}
else if (topLevelMenuIndex == 1) // "Edit" menu
else if (menuItemID >= 300 && menuItemID < 400)
{
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::undo);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::redo);
menu.addSeparator();
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::cut);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::copy);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::paste);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::del);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::selectAll);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::deselectAll);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::toFront);
menu.addCommandItem (commandManager, CommandIDs::toBack);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::group);
menu.addCommandItem (commandManager, CommandIDs::ungroup);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::bringBackLostItems);
OpenDocumentManager::Document* doc = getApp().openDocumentManager.getOpenDocument (menuItemID - 300);
jassert (doc != nullptr);
getApp().mainWindowList.openDocument (doc);
}
else if (topLevelMenuIndex == 2) // "View" menu
{
menu.addCommandItem (commandManager, CommandIDs::showProjectSettings);
menu.addSeparator();
}
};
menu.addCommandItem (commandManager, CommandIDs::showAppearanceSettings);
menu.addSeparator();
virtual StringArray getMenuNames()
{
const char* const names[] = { "File", "Edit", "View", "Window", "Tools", nullptr };
return StringArray (names);
}
menu.addCommandItem (commandManager, CommandIDs::showGrid);
menu.addCommandItem (commandManager, CommandIDs::enableSnapToGrid);
virtual void 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 == "Window") createWindowMenu (menu);
else if (menuName == "Tools") createToolsMenu (menu);
else jassertfalse; // names have changed?
}
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::zoomIn);
menu.addCommandItem (commandManager, CommandIDs::zoomOut);
menu.addCommandItem (commandManager, CommandIDs::zoomNormal);
virtual void createFileMenu (PopupMenu& menu)
{
menu.addCommandItem (commandManager, CommandIDs::newProject);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::open);
PopupMenu recentFiles;
getAppSettings().recentFiles.createPopupMenuItems (recentFiles, 100, true, true);
menu.addSubMenu ("Open recent file", recentFiles);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::closeDocument);
menu.addCommandItem (commandManager, CommandIDs::saveDocument);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::closeProject);
menu.addCommandItem (commandManager, CommandIDs::saveProject);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::openInIDE);
menu.addCommandItem (commandManager, CommandIDs::saveAndOpenInIDE);
#if ! JUCE_MAC
menu.addSeparator();
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::quit);
#endif
}
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::useTabbedWindows);
}
else if (topLevelMenuIndex == 3) // "Window" menu
{
menu.addCommandItem (commandManager, CommandIDs::closeWindow);
menu.addSeparator();
virtual void createEditMenu (PopupMenu& menu)
{
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::undo);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::redo);
menu.addSeparator();
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::cut);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::copy);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::paste);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::del);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::selectAll);
menu.addCommandItem (commandManager, StandardApplicationCommandIDs::deselectAll);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::toFront);
menu.addCommandItem (commandManager, CommandIDs::toBack);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::group);
menu.addCommandItem (commandManager, CommandIDs::ungroup);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::bringBackLostItems);
}
menu.addCommandItem (commandManager, CommandIDs::goToPreviousDoc);
menu.addCommandItem (commandManager, CommandIDs::goToNextDoc);
menu.addSeparator();
virtual void createViewMenu (PopupMenu& menu)
{
menu.addCommandItem (commandManager, CommandIDs::showFilePanel);
menu.addCommandItem (commandManager, CommandIDs::showConfigPanel);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::showAppearanceSettings);
}
const int numDocs = jmin (50, getApp()->openDocumentManager.getNumOpenDocuments());
virtual void createWindowMenu (PopupMenu& menu)
{
menu.addCommandItem (commandManager, CommandIDs::closeWindow);
menu.addSeparator();
for (int i = 0; i < numDocs; ++i)
{
OpenDocumentManager::Document* doc = getApp()->openDocumentManager.getOpenDocument(i);
menu.addCommandItem (commandManager, CommandIDs::goToPreviousDoc);
menu.addCommandItem (commandManager, CommandIDs::goToNextDoc);
menu.addSeparator();
menu.addItem (300 + i, doc->getName());
}
const int numDocs = jmin (50, getApp().openDocumentManager.getNumOpenDocuments());
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::closeAllDocuments);
}
else if (topLevelMenuIndex == 4) // "Tools" menu
{
menu.addCommandItem (commandManager, CommandIDs::updateModules);
menu.addCommandItem (commandManager, CommandIDs::showUTF8Tool);
}
for (int i = 0; i < numDocs; ++i)
{
OpenDocumentManager::Document* doc = getApp().openDocumentManager.getOpenDocument(i);
return menu;
menu.addItem (300 + i, doc->getName());
}
void menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/)
{
if (menuItemID >= 100 && menuItemID < 200)
{
// open a file from the "recent files" menu
const File file (getAppSettings().recentFiles.getFile (menuItemID - 100));
getApp()->openFile (file);
}
else if (menuItemID >= 300 && menuItemID < 400)
{
OpenDocumentManager::Document* doc = getApp()->openDocumentManager.getOpenDocument (menuItemID - 300);
jassert (doc != nullptr);
menu.addSeparator();
menu.addCommandItem (commandManager, CommandIDs::closeAllDocuments);
}
getApp()->mainWindowList.openDocument (doc);
}
}
};
virtual void createToolsMenu (PopupMenu& menu)
{
menu.addCommandItem (commandManager, CommandIDs::updateModules);
menu.addCommandItem (commandManager, CommandIDs::showUTF8Tool);
}
//==============================================================================
void getAllCommands (Array <CommandID>& commands)
@@ -345,9 +352,7 @@ public:
case CommandIDs::showUTF8Tool: showUTF8ToolWindow(); break;
case CommandIDs::showAppearanceSettings: showAppearanceEditorWindow(); break;
case CommandIDs::updateModules: runModuleUpdate (String::empty); break;
default:
return JUCEApplication::perform (info);
default: return JUCEApplication::perform (info);
}
return true;
@@ -455,8 +460,9 @@ private:
stopTimer();
delete this;
if (getApp() != nullptr)
getApp()->systemRequestedQuit();
JUCEApplication* app = JUCEApplication::getInstance();
if (app != nullptr)
app->systemRequestedQuit();
}
JUCE_DECLARE_NON_COPYABLE (AsyncQuitRetrier);


+ 2
- 1
extras/Introjucer/Source/Application/jucer_CommandIDs.h View File

@@ -37,10 +37,11 @@ namespace CommandIDs
static const int saveProject = 0x200060;
static const int openInIDE = 0x200072;
static const int saveAndOpenInIDE = 0x200073;
static const int showProjectSettings = 0x200074;
static const int updateModules = 0x200075;
static const int showUTF8Tool = 0x200076;
static const int showAppearanceSettings = 0x200077;
static const int showConfigPanel = 0x200074;
static const int showFilePanel = 0x200078;
static const int saveAll = 0x200080;


+ 2
- 2
extras/Introjucer/Source/Application/jucer_DocumentEditorComponent.cpp View File

@@ -32,12 +32,12 @@
DocumentEditorComponent::DocumentEditorComponent (OpenDocumentManager::Document* document_)
: document (document_)
{
JucerApplication::getApp()->openDocumentManager.addListener (this);
JucerApplication::getApp().openDocumentManager.addListener (this);
}
DocumentEditorComponent::~DocumentEditorComponent()
{
JucerApplication::getApp()->openDocumentManager.removeListener (this);
JucerApplication::getApp().openDocumentManager.removeListener (this);
}
void DocumentEditorComponent::documentAboutToClose (OpenDocumentManager::Document* closingDoc)


+ 8
- 8
extras/Introjucer/Source/Application/jucer_MainWindow.cpp View File

@@ -35,7 +35,7 @@ ScopedPointer<ApplicationCommandManager> commandManager;
//==============================================================================
MainWindow::MainWindow()
: DocumentWindow (JucerApplication::getApp()->getApplicationName(),
: DocumentWindow (JucerApplication::getApp().getApplicationName(),
Colour::greyLevel (0.6f),
DocumentWindow::allButtons,
false)
@@ -44,7 +44,7 @@ MainWindow::MainWindow()
createProjectContentCompIfNeeded();
#if ! JUCE_MAC
setMenuBar (JucerApplication::getApp()->menuModel);
setMenuBar (JucerApplication::getApp().menuModel);
#endif
setResizable (true, false);
@@ -93,7 +93,7 @@ void MainWindow::createProjectContentCompIfNeeded()
if (getProjectContentComponent() == nullptr)
{
clearContentComponent();
setContentOwned (JucerApplication::getApp()->createProjectContentComponent(), false);
setContentOwned (JucerApplication::getApp().createProjectContentComponent(), false);
jassert (getProjectContentComponent() != nullptr);
}
}
@@ -115,7 +115,7 @@ ProjectContentComponent* MainWindow::getProjectContentComponent() const
void MainWindow::closeButtonPressed()
{
JucerApplication::getApp()->mainWindowList.closeWindow (this);
JucerApplication::getApp().mainWindowList.closeWindow (this);
}
bool MainWindow::closeProject (Project* project)
@@ -136,7 +136,7 @@ bool MainWindow::closeProject (Project* project)
pcc->hideEditor();
}
if (! JucerApplication::getApp()->openDocumentManager.closeAllDocumentsUsingProject (*project, true))
if (! JucerApplication::getApp().openDocumentManager.closeAllDocumentsUsingProject (*project, true))
return false;
FileBasedDocument::SaveResult r = project->saveIfNeededAndUserAgrees();
@@ -179,7 +179,7 @@ void MainWindow::restoreWindowPosition()
bool MainWindow::canOpenFile (const File& file) const
{
return file.hasFileExtension (Project::projectFileExtension)
|| JucerApplication::getApp()->openDocumentManager.canOpenFile (file);
|| JucerApplication::getApp().openDocumentManager.canOpenFile (file);
}
bool MainWindow::openFile (const File& file)
@@ -232,12 +232,12 @@ void MainWindow::activeWindowStatusChanged()
if (getProjectContentComponent() != nullptr)
getProjectContentComponent()->updateMissingFileStatuses();
JucerApplication::getApp()->openDocumentManager.reloadModifiedFiles();
JucerApplication::getApp().openDocumentManager.reloadModifiedFiles();
}
void MainWindow::updateTitle (const String& documentName)
{
String name (JucerApplication::getApp()->getApplicationName());
String name (JucerApplication::getApp().getApplicationName());
if (currentProject != nullptr)
name = currentProject->getDocumentTitle() + " - " + name;


+ 3
- 3
extras/Introjucer/Source/Application/jucer_OpenDocumentManager.cpp View File

@@ -304,12 +304,12 @@ void OpenDocumentManager::fileHasBeenRenamed (const File& oldFile, const File& n
//==============================================================================
RecentDocumentList::RecentDocumentList()
{
JucerApplication::getApp()->openDocumentManager.addListener (this);
JucerApplication::getApp().openDocumentManager.addListener (this);
}
RecentDocumentList::~RecentDocumentList()
{
JucerApplication::getApp()->openDocumentManager.removeListener (this);
JucerApplication::getApp().openDocumentManager.removeListener (this);
}
void RecentDocumentList::clear()
@@ -378,7 +378,7 @@ static void restoreDocList (Project& project, Array <OpenDocumentManager::Docume
{
if (xml != nullptr)
{
OpenDocumentManager& odm = JucerApplication::getApp()->openDocumentManager;
OpenDocumentManager& odm = JucerApplication::getApp().openDocumentManager;
forEachXmlChildElementWithTagName (*xml, e, "DOC")
{


+ 1
- 1
extras/Introjucer/Source/Project/jucer_ConfigPage.cpp View File

@@ -358,7 +358,7 @@ namespace ProjectSettingsTreeClasses
void addSubItems()
{
addSubItem (new ModulesItem (project));
JucerApplication::getApp()->addExtraConfigItems (project, *this);
JucerApplication::getApp().addExtraConfigItems (project, *this);
int i = 0;
for (Project::ExporterIterator exporter (project); exporter.next(); ++i)


+ 1
- 1
extras/Introjucer/Source/Project/jucer_NewProjectWizard.cpp View File

@@ -495,7 +495,7 @@ public:
MainWindow* mw = dynamic_cast<MainWindow*> (getTopLevelComponent());
jassert (mw != nullptr);
JucerApplication::getApp()->mainWindowList.closeWindow (mw);
JucerApplication::getApp().mainWindowList.closeWindow (mw);
}
}


+ 2
- 2
extras/Introjucer/Source/Project/jucer_Project.cpp View File

@@ -66,7 +66,7 @@ Project::Project (const File& file_)
Project::~Project()
{
projectRoot.removeListener (this);
JucerApplication::getApp()->openDocumentManager.closeAllDocumentsUsingProject (*this, false);
JucerApplication::getApp().openDocumentManager.closeAllDocumentsUsingProject (*this, false);
}
//==============================================================================
@@ -537,7 +537,7 @@ bool Project::Item::renameFile (const File& newFile)
|| (newFile.exists() && ! oldFile.exists()))
{
setFile (newFile);
JucerApplication::getApp()->openDocumentManager.fileHasBeenRenamed (oldFile, newFile);
JucerApplication::getApp().openDocumentManager.fileHasBeenRenamed (oldFile, newFile);
return true;
}


+ 21
- 8
extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp View File

@@ -259,7 +259,7 @@ void ProjectContentComponent::updateMissingFileStatuses()
bool ProjectContentComponent::showEditorForFile (const File& f)
{
return getCurrentFile() == f
|| showDocument (JucerApplication::getApp()->openDocumentManager.openFile (project, f));
|| showDocument (JucerApplication::getApp().openDocumentManager.openFile (project, f));
}
File ProjectContentComponent::getCurrentFile() const
@@ -375,7 +375,8 @@ void ProjectContentComponent::getAllCommands (Array <CommandID>& commands)
CommandIDs::closeProject,
CommandIDs::openInIDE,
CommandIDs::saveAndOpenInIDE,
CommandIDs::showProjectSettings,
CommandIDs::showFilePanel,
CommandIDs::showConfigPanel,
CommandIDs::goToPreviousDoc,
CommandIDs::goToNextDoc,
StandardApplicationCommandIDs::del };
@@ -472,16 +473,24 @@ void ProjectContentComponent::getCommandInfo (const CommandID commandID, Applica
result.defaultKeypresses.add (KeyPress ('l', ModifierKeys::commandModifier, 0));
break;
case CommandIDs::showProjectSettings:
result.setInfo ("Show Project Build Settings",
case CommandIDs::showFilePanel:
result.setInfo ("Show File Panel",
"Shows the tree of files for this project",
CommandCategories::general, 0);
result.setActive (project != nullptr);
result.defaultKeypresses.add (KeyPress ('p', ModifierKeys::commandModifier, 0));
break;
case CommandIDs::showConfigPanel:
result.setInfo ("Show Config Panel",
"Shows the build options for the project",
CommandCategories::general, 0);
result.setActive (project != nullptr);
result.defaultKeypresses.add (KeyPress ('i', ModifierKeys::commandModifier | ModifierKeys::shiftModifier, 0));
result.defaultKeypresses.add (KeyPress ('i', ModifierKeys::commandModifier, 0));
break;
case StandardApplicationCommandIDs::del:
result.setInfo ("Delete", String::empty, CommandCategories::general, 0);
result.setInfo ("Delete Selected File", String::empty, CommandCategories::general, 0);
result.defaultKeypresses.add (KeyPress (KeyPress::deleteKey, 0, 0));
result.defaultKeypresses.add (KeyPress (KeyPress::backspaceKey, 0, 0));
result.setActive (dynamic_cast<TreePanelBase*> (treeViewTabs.getCurrentContentComponent()) != nullptr);
@@ -530,7 +539,7 @@ bool ProjectContentComponent::perform (const InvocationInfo& info)
case CommandIDs::closeDocument:
if (currentDocument != nullptr)
JucerApplication::getApp()->openDocumentManager.closeDocument (currentDocument, true);
JucerApplication::getApp().openDocumentManager.closeDocument (currentDocument, true);
break;
case CommandIDs::goToPreviousDoc:
@@ -567,7 +576,11 @@ bool ProjectContentComponent::perform (const InvocationInfo& info)
}
break;
case CommandIDs::showProjectSettings:
case CommandIDs::showFilePanel:
treeViewTabs.setCurrentTabIndex (0);
break;
case CommandIDs::showConfigPanel:
treeViewTabs.setCurrentTabIndex (1);
break;


+ 1
- 1
extras/Introjucer/Source/Project/jucer_ProjectTreeViewBase.cpp View File

@@ -220,7 +220,7 @@ void ProjectTreeViewBase::deleteAllSelectedItems()
if (treeRootItem != nullptr)
{
OpenDocumentManager& om = JucerApplication::getApp()->openDocumentManager;
OpenDocumentManager& om = JucerApplication::getApp().openDocumentManager;
for (int i = filesToTrash.size(); --i >= 0;)
{


+ 1
- 1
extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h View File

@@ -191,7 +191,7 @@ public:
void resized()
{
item.textX = item.getIconSize() + 8;
item.textX = (int) item.getIconSize() + 8;
}
JucerTreeViewBase& item;


+ 2
- 2
extras/Introjucer/Source/Utility/jucer_StoredSettings.cpp View File

@@ -30,7 +30,7 @@
//==============================================================================
StoredSettings& getAppSettings()
{
return JucerApplication::getApp()->settings;
return JucerApplication::getApp().settings;
}
PropertiesFile& getAppProperties()
@@ -211,7 +211,7 @@ File StoredSettings::getSchemesFolder()
//==============================================================================
const Icons& getIcons()
{
return JucerApplication::getApp()->icons;
return JucerApplication::getApp().icons;
}
Icons::Icons()


Loading…
Cancel
Save