diff --git a/extras/Introjucer/Source/Project/jucer_ConfigPage.cpp b/extras/Introjucer/Source/Project/jucer_ConfigPage.cpp index 4a98bc7a03..06e68f6164 100644 --- a/extras/Introjucer/Source/Project/jucer_ConfigPage.cpp +++ b/extras/Introjucer/Source/Project/jucer_ConfigPage.cpp @@ -67,7 +67,6 @@ namespace ProjectSettingsTreeClasses configTree.addListener (this); } - bool isRoot() const { return false; } bool isMissing() { return false; } bool canBeSelected() const { return true; } bool mightContainSubItems() { return false; } @@ -169,7 +168,6 @@ namespace ProjectSettingsTreeClasses jassert (exporter != nullptr); } - bool isRoot() const { return false; } bool canBeSelected() const { return true; } bool mightContainSubItems() { return exporter->getNumConfigurations() > 0; } String getUniqueName() const { return project.getProjectUID() + "_exporter_" + String (exporterIndex); } @@ -292,7 +290,6 @@ namespace ProjectSettingsTreeClasses public: ModulesItem (Project& project_) : project (project_) {} - bool isRoot() const { return false; } bool canBeSelected() const { return true; } bool mightContainSubItems() { return false; } String getUniqueName() const { return project.getProjectUID() + "_modules"; } @@ -348,7 +345,6 @@ namespace ProjectSettingsTreeClasses exportersTree.addListener (this); } - bool isRoot() const { return true; } String getRenamingName() const { return getDisplayName(); } String getDisplayName() const { return project.getTitle(); } void setName (const String&) {} @@ -362,12 +358,11 @@ namespace ProjectSettingsTreeClasses void addSubItems() { addSubItem (new ModulesItem (project)); + JucerApplication::getApp()->addExtraConfigItems (project, *this); int i = 0; for (Project::ExporterIterator exporter (project); exporter.next(); ++i) addSubItem (new ExporterItem (project, exporter.exporter.release(), i)); - - JucerApplication::getApp()->addExtraConfigItems (project, *this); } void showPopupMenu() diff --git a/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp b/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp index d154133c3f..559c768098 100644 --- a/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp @@ -31,63 +31,6 @@ #include "../Project Saving/jucer_ProjectExporter.h" -//============================================================================== -class TreePanelBase : public Component -{ -public: - TreePanelBase (const String& opennessStateKey_) - : opennessStateKey (opennessStateKey_) - { - addAndMakeVisible (&tree); - tree.setRootItemVisible (true); - tree.setDefaultOpenness (true); - tree.setColour (TreeView::backgroundColourId, Colours::transparentBlack); - tree.setIndentSize (14); - } - - ~TreePanelBase() - { - tree.setRootItem (nullptr); - } - - void setRoot (JucerTreeViewBase* root) - { - rootItem = root; - tree.setRootItem (root); - tree.getRootItem()->setOpen (true); - - const ScopedPointer treeOpenness (StoredSettings::getInstance()->getProps() - .getXmlValue (opennessStateKey)); - if (treeOpenness != nullptr) - tree.restoreOpennessState (*treeOpenness, true); - } - - void saveOpenness() - { - const ScopedPointer opennessState (tree.getOpennessState (true)); - - if (opennessState != nullptr) - StoredSettings::getInstance()->getProps().setValue (opennessStateKey, opennessState); - } - - void deleteSelectedItems() - { - if (rootItem != nullptr) - rootItem->deleteAllSelectedItems(); - } - - void resized() - { - tree.setBounds (getLocalBounds()); - } - - TreeView tree; - ScopedPointer rootItem; - -private: - String opennessStateKey; -}; - //============================================================================== class FileTreeTab : public TreePanelBase { diff --git a/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h b/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h index b1139cf7a4..7df0b9ba3d 100644 --- a/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h +++ b/extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h @@ -100,5 +100,62 @@ private: void invokeShowDocument(); }; +//============================================================================== +class TreePanelBase : public Component +{ +public: + TreePanelBase (const String& opennessStateKey_) + : opennessStateKey (opennessStateKey_) + { + addAndMakeVisible (&tree); + tree.setRootItemVisible (true); + tree.setDefaultOpenness (true); + tree.setColour (TreeView::backgroundColourId, Colours::transparentBlack); + tree.setIndentSize (14); + } + + ~TreePanelBase() + { + tree.setRootItem (nullptr); + } + + void setRoot (JucerTreeViewBase* root) + { + rootItem = root; + tree.setRootItem (root); + tree.getRootItem()->setOpen (true); + + const ScopedPointer treeOpenness (StoredSettings::getInstance()->getProps() + .getXmlValue (opennessStateKey)); + if (treeOpenness != nullptr) + tree.restoreOpennessState (*treeOpenness, true); + } + + void saveOpenness() + { + const ScopedPointer opennessState (tree.getOpennessState (true)); + + if (opennessState != nullptr) + StoredSettings::getInstance()->getProps().setValue (opennessStateKey, opennessState); + } + + void deleteSelectedItems() + { + if (rootItem != nullptr) + rootItem->deleteAllSelectedItems(); + } + + void resized() + { + tree.setBounds (getLocalBounds()); + } + + TreeView tree; + ScopedPointer rootItem; + +private: + String opennessStateKey; +}; + -#endif // __JUCER_JUCERTREEVIEWBASE_JUCEHEADER__ +#endif diff --git a/modules/juce_core/text/juce_CharacterFunctions.h b/modules/juce_core/text/juce_CharacterFunctions.h index b5e25c0fe1..35299971dc 100644 --- a/modules/juce_core/text/juce_CharacterFunctions.h +++ b/modules/juce_core/text/juce_CharacterFunctions.h @@ -447,23 +447,39 @@ public: Returns -1 if the substring is not found. */ template - static int indexOf (CharPointerType1 haystack, const CharPointerType2& needle) noexcept + static int indexOf (CharPointerType1 textToSearch, const CharPointerType2& substringToLookFor) noexcept { int index = 0; - const int needleLength = (int) needle.length(); + const int substringLength = (int) substringToLookFor.length(); for (;;) { - if (haystack.compareUpTo (needle, needleLength) == 0) + if (textToSearch.compareUpTo (substringToLookFor, substringLength) == 0) return index; - if (haystack.getAndAdvance() == 0) + if (textToSearch.getAndAdvance() == 0) return -1; ++index; } } + /** Returns a pointer to the first occurrence of a substring in a string. + If the substring is not found, this will return a pointer to the string's + null terminator. + */ + template + static CharPointerType1 find (CharPointerType1 textToSearch, const CharPointerType2& substringToLookFor) noexcept + { + const int substringLength = (int) substringToLookFor.length(); + + while (textToSearch.compareUpTo (substringToLookFor, substringLength) != 0 + && ! textToSearch.isEmpty()) + ++textToSearch; + + return textToSearch; + } + /** Finds the character index of a given substring in another string, using a case-independent match. Returns -1 if the substring is not found.