Browse Source

Added a CharacterFunctions method. Some refactoring in introjucer.

tags/2021-05-28
jules 13 years ago
parent
commit
100301ed17
4 changed files with 79 additions and 68 deletions
  1. +1
    -6
      extras/Introjucer/Source/Project/jucer_ConfigPage.cpp
  2. +0
    -57
      extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp
  3. +58
    -1
      extras/Introjucer/Source/Utility/jucer_JucerTreeViewBase.h
  4. +20
    -4
      modules/juce_core/text/juce_CharacterFunctions.h

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

@@ -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()


+ 0
- 57
extras/Introjucer/Source/Project/jucer_ProjectContentComponent.cpp View File

@@ -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<XmlElement> treeOpenness (StoredSettings::getInstance()->getProps()
.getXmlValue (opennessStateKey));
if (treeOpenness != nullptr)
tree.restoreOpennessState (*treeOpenness, true);
}
void saveOpenness()
{
const ScopedPointer<XmlElement> 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<JucerTreeViewBase> rootItem;
private:
String opennessStateKey;
};
//==============================================================================
class FileTreeTab : public TreePanelBase
{


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

@@ -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<XmlElement> treeOpenness (StoredSettings::getInstance()->getProps()
.getXmlValue (opennessStateKey));
if (treeOpenness != nullptr)
tree.restoreOpennessState (*treeOpenness, true);
}
void saveOpenness()
{
const ScopedPointer<XmlElement> 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<JucerTreeViewBase> rootItem;
private:
String opennessStateKey;
};
#endif // __JUCER_JUCERTREEVIEWBASE_JUCEHEADER__
#endif

+ 20
- 4
modules/juce_core/text/juce_CharacterFunctions.h View File

@@ -447,23 +447,39 @@ public:
Returns -1 if the substring is not found.
*/
template <typename CharPointerType1, typename CharPointerType2>
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 <typename CharPointerType1, typename CharPointerType2>
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.


Loading…
Cancel
Save