| @@ -257,7 +257,7 @@ AudioDemoRecordPage::AudioDemoRecordPage (AudioDeviceManager& deviceManager_) | |||
| recordButton->setButtonText (T("Record")); | |||
| recordButton->addButtonListener (this); | |||
| recordButton->setColour (TextButton::buttonColourId, Colour (0xffff5c5c)); | |||
| recordButton->setColour (TextButton::textColourId, Colours::black); | |||
| recordButton->setColour (TextButton::textColourOffId, Colours::black); | |||
| //[UserPreSize] | |||
| @@ -263,7 +263,7 @@ public: | |||
| ColourSelector colourSelector2; | |||
| colourSelector2.setName (T("text")); | |||
| colourSelector2.setCurrentColour (findColour (TextButton::textColourId)); | |||
| colourSelector2.setCurrentColour (findColour (TextButton::textColourOffId)); | |||
| colourSelector2.addChangeListener (this); | |||
| // and add the selectors as custom menu items to a PopupMenu, putting | |||
| @@ -285,7 +285,7 @@ public: | |||
| ColourSelector* cs = (ColourSelector*) source; | |||
| if (cs->getName() == T("text")) | |||
| setColour (TextButton::textColourId, cs->getCurrentColour()); | |||
| setColour (TextButton::textColourOffId, cs->getCurrentColour()); | |||
| else | |||
| setColour (TextButton::buttonColourId, cs->getCurrentColour()); | |||
| } | |||
| @@ -42,7 +42,8 @@ public: | |||
| { | |||
| registerColour (TextButton::buttonColourId, "background (normal)", "bgColOff"); | |||
| registerColour (TextButton::buttonOnColourId, "background (on)", "bgColOn"); | |||
| registerColour (TextButton::textColourId, "text colour", "textCol"); | |||
| registerColour (TextButton::textColourOnId, "text colour (normal)", "textCol"); | |||
| registerColour (TextButton::textColourOffId, "text colour (on)", "textColOn"); | |||
| } | |||
| //============================================================================== | |||
| @@ -32,24 +32,24 @@ BEGIN_JUCE_NAMESPACE | |||
| //============================================================================== | |||
| MidiBuffer::MidiBuffer() throw() | |||
| : ArrayAllocationBase <uint8> (32), | |||
| : data (32), | |||
| bytesUsed (0) | |||
| { | |||
| } | |||
| MidiBuffer::MidiBuffer (const MidiMessage& message) throw() | |||
| : ArrayAllocationBase <uint8> (32), | |||
| : data (32), | |||
| bytesUsed (0) | |||
| { | |||
| addEvent (message, 0); | |||
| } | |||
| MidiBuffer::MidiBuffer (const MidiBuffer& other) throw() | |||
| : ArrayAllocationBase <uint8> (32), | |||
| : data (32), | |||
| bytesUsed (other.bytesUsed) | |||
| { | |||
| ensureAllocatedSize (bytesUsed); | |||
| memcpy (elements, other.elements, bytesUsed); | |||
| data.ensureAllocatedSize (bytesUsed); | |||
| memcpy (data.elements, other.data.elements, bytesUsed); | |||
| } | |||
| const MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw() | |||
| @@ -57,10 +57,10 @@ const MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw() | |||
| if (this != &other) | |||
| { | |||
| bytesUsed = other.bytesUsed; | |||
| ensureAllocatedSize (bytesUsed); | |||
| data.ensureAllocatedSize (bytesUsed); | |||
| if (bytesUsed > 0) | |||
| memcpy (elements, other.elements, bytesUsed); | |||
| memcpy (data.elements, other.data.elements, bytesUsed); | |||
| } | |||
| return *this; | |||
| @@ -68,9 +68,9 @@ const MidiBuffer& MidiBuffer::operator= (const MidiBuffer& other) throw() | |||
| void MidiBuffer::swap (MidiBuffer& other) | |||
| { | |||
| swapVariables <uint8*> (this->elements, other.elements); | |||
| swapVariables <int> (this->numAllocated, other.numAllocated); | |||
| swapVariables <int> (this->bytesUsed, other.bytesUsed); | |||
| swapVariables <uint8*> (data.elements, other.data.elements); | |||
| swapVariables <int> (data.numAllocated, other.data.numAllocated); | |||
| swapVariables <int> (bytesUsed, other.bytesUsed); | |||
| } | |||
| MidiBuffer::~MidiBuffer() throw() | |||
| @@ -85,12 +85,12 @@ void MidiBuffer::clear() throw() | |||
| void MidiBuffer::clear (const int startSample, | |||
| const int numSamples) throw() | |||
| { | |||
| uint8* const start = findEventAfter (elements, startSample - 1); | |||
| uint8* const start = findEventAfter (data.elements, startSample - 1); | |||
| uint8* const end = findEventAfter (start, startSample + numSamples - 1); | |||
| if (end > start) | |||
| { | |||
| const size_t bytesToMove = (size_t) (bytesUsed - (end - elements)); | |||
| const size_t bytesToMove = (size_t) (bytesUsed - (end - data.elements)); | |||
| if (bytesToMove > 0) | |||
| memmove (start, end, bytesToMove); | |||
| @@ -144,10 +144,10 @@ void MidiBuffer::addEvent (const uint8* const newData, | |||
| if (numBytes > 0) | |||
| { | |||
| ensureAllocatedSize (bytesUsed + numBytes + 6); | |||
| data.ensureAllocatedSize (bytesUsed + numBytes + 6); | |||
| uint8* d = findEventAfter (elements, sampleNumber); | |||
| const size_t bytesToMove = (size_t) (bytesUsed - (d - elements)); | |||
| uint8* d = findEventAfter (data.elements, sampleNumber); | |||
| const size_t bytesToMove = (size_t) (bytesUsed - (d - data.elements)); | |||
| if (bytesToMove > 0) | |||
| memmove (d + numBytes + 6, | |||
| @@ -191,8 +191,8 @@ bool MidiBuffer::isEmpty() const throw() | |||
| int MidiBuffer::getNumEvents() const throw() | |||
| { | |||
| int n = 0; | |||
| const uint8* d = elements; | |||
| const uint8* const end = elements + bytesUsed; | |||
| const uint8* d = data.elements; | |||
| const uint8* const end = data.elements + bytesUsed; | |||
| while (d < end) | |||
| { | |||
| @@ -206,7 +206,7 @@ int MidiBuffer::getNumEvents() const throw() | |||
| int MidiBuffer::getFirstEventTime() const throw() | |||
| { | |||
| return (bytesUsed > 0) ? *(const int*) elements : 0; | |||
| return (bytesUsed > 0) ? *(const int*) data.elements : 0; | |||
| } | |||
| int MidiBuffer::getLastEventTime() const throw() | |||
| @@ -214,7 +214,7 @@ int MidiBuffer::getLastEventTime() const throw() | |||
| if (bytesUsed == 0) | |||
| return 0; | |||
| const uint8* d = elements; | |||
| const uint8* d = data.elements; | |||
| const uint8* const endData = d + bytesUsed; | |||
| for (;;) | |||
| @@ -230,7 +230,7 @@ int MidiBuffer::getLastEventTime() const throw() | |||
| uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const throw() | |||
| { | |||
| const uint8* const endData = elements + bytesUsed; | |||
| const uint8* const endData = data.elements + bytesUsed; | |||
| while (d < endData && *(int*) d <= samplePosition) | |||
| { | |||
| @@ -244,7 +244,7 @@ uint8* MidiBuffer::findEventAfter (uint8* d, const int samplePosition) const thr | |||
| //============================================================================== | |||
| MidiBuffer::Iterator::Iterator (const MidiBuffer& buffer_) throw() | |||
| : buffer (buffer_), | |||
| data (buffer_.elements) | |||
| data (buffer_.data.elements) | |||
| { | |||
| } | |||
| @@ -255,8 +255,8 @@ MidiBuffer::Iterator::~Iterator() throw() | |||
| //============================================================================== | |||
| void MidiBuffer::Iterator::setNextSamplePosition (const int samplePosition) throw() | |||
| { | |||
| data = buffer.elements; | |||
| const uint8* dataEnd = buffer.elements + buffer.bytesUsed; | |||
| data = buffer.data.elements; | |||
| const uint8* dataEnd = buffer.data.elements + buffer.bytesUsed; | |||
| while (data < dataEnd && *(int*) data < samplePosition) | |||
| { | |||
| @@ -269,7 +269,7 @@ bool MidiBuffer::Iterator::getNextEvent (const uint8* &midiData, | |||
| int& numBytes, | |||
| int& samplePosition) throw() | |||
| { | |||
| if (data >= buffer.elements + buffer.bytesUsed) | |||
| if (data >= buffer.data.elements + buffer.bytesUsed) | |||
| return false; | |||
| samplePosition = *(int*) data; | |||
| @@ -285,7 +285,7 @@ bool MidiBuffer::Iterator::getNextEvent (const uint8* &midiData, | |||
| bool MidiBuffer::Iterator::getNextEvent (MidiMessage& result, | |||
| int& samplePosition) throw() | |||
| { | |||
| if (data >= buffer.elements + buffer.bytesUsed) | |||
| if (data >= buffer.data.elements + buffer.bytesUsed) | |||
| return false; | |||
| samplePosition = *(int*) data; | |||
| @@ -39,7 +39,7 @@ | |||
| @see MidiMessage | |||
| */ | |||
| class JUCE_API MidiBuffer : private ArrayAllocationBase <uint8> | |||
| class JUCE_API MidiBuffer | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| @@ -226,6 +226,7 @@ public: | |||
| private: | |||
| friend class MidiBuffer::Iterator; | |||
| ArrayAllocationBase <uint8> data; | |||
| int bytesUsed; | |||
| uint8* findEventAfter (uint8* d, const int samplePosition) const throw(); | |||
| @@ -52,7 +52,7 @@ | |||
| @see OwnedArray, ReferenceCountedArray, StringArray, CriticalSection | |||
| */ | |||
| template <class ElementType, class TypeOfCriticalSectionToUse = DummyCriticalSection> | |||
| class Array : private ArrayAllocationBase <ElementType> | |||
| class Array | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| @@ -61,11 +61,9 @@ public: | |||
| @param granularity this is the size of increment by which the internal storage | |||
| used by the array will grow. Only change it from the default if you know the | |||
| array is going to be very big and needs to be able to grow efficiently. | |||
| @see ArrayAllocationBase | |||
| */ | |||
| Array (const int granularity_ = juceDefaultArrayGranularity) throw() | |||
| : ArrayAllocationBase <ElementType> (granularity_), | |||
| : data (granularity_), | |||
| numUsed (0) | |||
| { | |||
| } | |||
| @@ -74,12 +72,12 @@ public: | |||
| @param other the array to copy | |||
| */ | |||
| Array (const Array<ElementType, TypeOfCriticalSectionToUse>& other) throw() | |||
| : ArrayAllocationBase <ElementType> (other.granularity) | |||
| : data (other.data.granularity) | |||
| { | |||
| other.lockArray(); | |||
| numUsed = other.numUsed; | |||
| this->setAllocatedSize (other.numUsed); | |||
| memcpy (this->elements, other.elements, numUsed * sizeof (ElementType)); | |||
| data.setAllocatedSize (other.numUsed); | |||
| memcpy (data.elements, other.data.elements, numUsed * sizeof (ElementType)); | |||
| other.unlockArray(); | |||
| } | |||
| @@ -88,7 +86,7 @@ public: | |||
| @param values the array to copy from | |||
| */ | |||
| Array (const ElementType* values) throw() | |||
| : ArrayAllocationBase <ElementType> (juceDefaultArrayGranularity), | |||
| : data (juceDefaultArrayGranularity), | |||
| numUsed (0) | |||
| { | |||
| while (*values != 0) | |||
| @@ -101,11 +99,11 @@ public: | |||
| @param numValues the number of values in the array | |||
| */ | |||
| Array (const ElementType* values, int numValues) throw() | |||
| : ArrayAllocationBase <ElementType> (juceDefaultArrayGranularity), | |||
| : data (juceDefaultArrayGranularity), | |||
| numUsed (numValues) | |||
| { | |||
| this->setAllocatedSize (numValues); | |||
| memcpy (this->elements, values, numValues * sizeof (ElementType)); | |||
| data.setAllocatedSize (numValues); | |||
| memcpy (data.elements, values, numValues * sizeof (ElementType)); | |||
| } | |||
| /** Destructor. */ | |||
| @@ -123,10 +121,10 @@ public: | |||
| other.lockArray(); | |||
| lock.enter(); | |||
| this->granularity = other.granularity; | |||
| this->ensureAllocatedSize (other.size()); | |||
| data.granularity = other.data.granularity; | |||
| data.ensureAllocatedSize (other.size()); | |||
| numUsed = other.numUsed; | |||
| memcpy (this->elements, other.elements, this->numUsed * sizeof (ElementType)); | |||
| memcpy (data.elements, other.data.elements, numUsed * sizeof (ElementType)); | |||
| minimiseStorageOverheads(); | |||
| lock.exit(); | |||
| @@ -147,7 +145,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| if (this->numUsed != other.numUsed) | |||
| if (numUsed != other.numUsed) | |||
| { | |||
| lock.exit(); | |||
| return false; | |||
| @@ -155,7 +153,7 @@ public: | |||
| for (int i = numUsed; --i >= 0;) | |||
| { | |||
| if (this->elements [i] != other.elements [i]) | |||
| if (data.elements [i] != other.data.elements [i]) | |||
| { | |||
| lock.exit(); | |||
| return false; | |||
| @@ -188,7 +186,7 @@ public: | |||
| void clear() throw() | |||
| { | |||
| lock.enter(); | |||
| this->setAllocatedSize (0); | |||
| data.setAllocatedSize (0); | |||
| numUsed = 0; | |||
| lock.exit(); | |||
| } | |||
| @@ -226,7 +224,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| const ElementType result = (((unsigned int) index) < (unsigned int) numUsed) | |||
| ? this->elements [index] | |||
| ? data.elements [index] | |||
| : ElementType(); | |||
| lock.exit(); | |||
| @@ -246,7 +244,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| jassert (((unsigned int) index) < (unsigned int) numUsed); | |||
| const ElementType result = this->elements [index]; | |||
| const ElementType result = data.elements [index]; | |||
| lock.exit(); | |||
| return result; | |||
| @@ -265,7 +263,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| jassert (((unsigned int) index) < (unsigned int) numUsed); | |||
| ElementType& result = this->elements [index]; | |||
| ElementType& result = data.elements [index]; | |||
| lock.exit(); | |||
| return result; | |||
| } | |||
| @@ -277,7 +275,7 @@ public: | |||
| inline ElementType getFirst() const throw() | |||
| { | |||
| lock.enter(); | |||
| const ElementType result = (numUsed > 0) ? this->elements [0] | |||
| const ElementType result = (numUsed > 0) ? data.elements [0] | |||
| : ElementType(); | |||
| lock.exit(); | |||
| @@ -291,7 +289,7 @@ public: | |||
| inline ElementType getLast() const throw() | |||
| { | |||
| lock.enter(); | |||
| const ElementType result = (numUsed > 0) ? this->elements [numUsed - 1] | |||
| const ElementType result = (numUsed > 0) ? data.elements [numUsed - 1] | |||
| : ElementType(); | |||
| lock.exit(); | |||
| @@ -312,13 +310,13 @@ public: | |||
| int result = -1; | |||
| lock.enter(); | |||
| const ElementType* e = this->elements; | |||
| const ElementType* e = data.elements; | |||
| for (int i = numUsed; --i >= 0;) | |||
| { | |||
| if (elementToLookFor == *e) | |||
| { | |||
| result = (int) (e - this->elements); | |||
| result = (int) (e - data.elements); | |||
| break; | |||
| } | |||
| @@ -338,7 +336,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| const ElementType* e = this->elements; | |||
| const ElementType* e = data.elements; | |||
| int num = numUsed; | |||
| while (num >= 4) | |||
| @@ -381,8 +379,8 @@ public: | |||
| void add (const ElementType newElement) throw() | |||
| { | |||
| lock.enter(); | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| this->elements [numUsed++] = newElement; | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| data.elements [numUsed++] = newElement; | |||
| lock.exit(); | |||
| } | |||
| @@ -401,11 +399,11 @@ public: | |||
| void insert (int indexToInsertAt, const ElementType newElement) throw() | |||
| { | |||
| lock.enter(); | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| if (((unsigned int) indexToInsertAt) < (unsigned int) numUsed) | |||
| { | |||
| ElementType* const insertPos = this->elements + indexToInsertAt; | |||
| ElementType* const insertPos = data.elements + indexToInsertAt; | |||
| const int numberToMove = numUsed - indexToInsertAt; | |||
| if (numberToMove > 0) | |||
| @@ -416,7 +414,7 @@ public: | |||
| } | |||
| else | |||
| { | |||
| this->elements [numUsed++] = newElement; | |||
| data.elements [numUsed++] = newElement; | |||
| } | |||
| lock.exit(); | |||
| @@ -440,11 +438,11 @@ public: | |||
| if (numberOfTimesToInsertIt > 0) | |||
| { | |||
| lock.enter(); | |||
| this->ensureAllocatedSize (numUsed + numberOfTimesToInsertIt); | |||
| data.ensureAllocatedSize (numUsed + numberOfTimesToInsertIt); | |||
| if (((unsigned int) indexToInsertAt) < (unsigned int) numUsed) | |||
| { | |||
| ElementType* insertPos = this->elements + indexToInsertAt; | |||
| ElementType* insertPos = data.elements + indexToInsertAt; | |||
| const int numberToMove = numUsed - indexToInsertAt; | |||
| memmove (insertPos + numberOfTimesToInsertIt, insertPos, numberToMove * sizeof (ElementType)); | |||
| @@ -456,7 +454,7 @@ public: | |||
| else | |||
| { | |||
| while (--numberOfTimesToInsertIt >= 0) | |||
| this->elements [numUsed++] = newElement; | |||
| data.elements [numUsed++] = newElement; | |||
| } | |||
| lock.exit(); | |||
| @@ -482,11 +480,11 @@ public: | |||
| if (numberOfElements > 0) | |||
| { | |||
| lock.enter(); | |||
| this->ensureAllocatedSize (numUsed + numberOfElements); | |||
| data.ensureAllocatedSize (numUsed + numberOfElements); | |||
| if (((unsigned int) indexToInsertAt) < (unsigned int) numUsed) | |||
| { | |||
| ElementType* insertPos = this->elements + indexToInsertAt; | |||
| ElementType* insertPos = data.elements + indexToInsertAt; | |||
| const int numberToMove = numUsed - indexToInsertAt; | |||
| memmove (insertPos + numberOfElements, insertPos, numberToMove * sizeof (ElementType)); | |||
| @@ -498,7 +496,7 @@ public: | |||
| else | |||
| { | |||
| while (--numberOfElements >= 0) | |||
| this->elements [numUsed++] = *newElements++; | |||
| data.elements [numUsed++] = *newElements++; | |||
| } | |||
| lock.exit(); | |||
| @@ -543,12 +541,12 @@ public: | |||
| if (indexToChange < numUsed) | |||
| { | |||
| this->elements [indexToChange] = newValue; | |||
| data.elements [indexToChange] = newValue; | |||
| } | |||
| else | |||
| { | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| this->elements [numUsed++] = newValue; | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| data.elements [numUsed++] = newValue; | |||
| } | |||
| lock.exit(); | |||
| @@ -569,7 +567,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| jassert (((unsigned int) indexToChange) < (unsigned int) numUsed); | |||
| this->elements [indexToChange] = newValue; | |||
| data.elements [indexToChange] = newValue; | |||
| lock.exit(); | |||
| } | |||
| @@ -586,10 +584,10 @@ public: | |||
| if (numElementsToAdd > 0) | |||
| { | |||
| this->ensureAllocatedSize (numUsed + numElementsToAdd); | |||
| data.ensureAllocatedSize (numUsed + numElementsToAdd); | |||
| while (--numElementsToAdd >= 0) | |||
| this->elements [numUsed++] = *elementsToAdd++; | |||
| data.elements [numUsed++] = *elementsToAdd++; | |||
| } | |||
| lock.exit(); | |||
| @@ -605,9 +603,9 @@ public: | |||
| { | |||
| lock.enter(); | |||
| otherArray.lock.enter(); | |||
| swapVariables <int> (this->numUsed, otherArray.numUsed); | |||
| swapVariables <ElementType*> (this->elements, otherArray.elements); | |||
| swapVariables <int> (this->numAllocated, otherArray.numAllocated); | |||
| swapVariables <int> (numUsed, otherArray.numUsed); | |||
| swapVariables <ElementType*> (data.elements, otherArray.data.elements); | |||
| swapVariables <int> (data.numAllocated, otherArray.data.numAllocated); | |||
| otherArray.lock.exit(); | |||
| lock.exit(); | |||
| } | |||
| @@ -639,7 +637,7 @@ public: | |||
| if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) | |||
| numElementsToAdd = arrayToAddFrom.size() - startIndex; | |||
| this->addArray ((const ElementType*) (arrayToAddFrom.elements + startIndex), numElementsToAdd); | |||
| addArray ((const ElementType*) (arrayToAddFrom.data.elements + startIndex), numElementsToAdd); | |||
| lock.exit(); | |||
| arrayToAddFrom.unlockArray(); | |||
| @@ -661,7 +659,7 @@ public: | |||
| const ElementType newElement) throw() | |||
| { | |||
| lock.enter(); | |||
| insert (findInsertIndexInSortedArray (comparator, this->elements, newElement, 0, numUsed), newElement); | |||
| insert (findInsertIndexInSortedArray (comparator, data.elements, newElement, 0, numUsed), newElement); | |||
| lock.exit(); | |||
| } | |||
| @@ -695,7 +693,7 @@ public: | |||
| lock.exit(); | |||
| return -1; | |||
| } | |||
| else if (comparator.compareElements (elementToLookFor, this->elements [start]) == 0) | |||
| else if (comparator.compareElements (elementToLookFor, data.elements [start]) == 0) | |||
| { | |||
| lock.exit(); | |||
| return start; | |||
| @@ -709,7 +707,7 @@ public: | |||
| lock.exit(); | |||
| return -1; | |||
| } | |||
| else if (comparator.compareElements (elementToLookFor, this->elements [halfway]) >= 0) | |||
| else if (comparator.compareElements (elementToLookFor, data.elements [halfway]) >= 0) | |||
| start = halfway; | |||
| else | |||
| end = halfway; | |||
| @@ -736,14 +734,14 @@ public: | |||
| { | |||
| --numUsed; | |||
| ElementType* const e = this->elements + indexToRemove; | |||
| ElementType* const e = data.elements + indexToRemove; | |||
| ElementType const removed = *e; | |||
| const int numberToShift = numUsed - indexToRemove; | |||
| if (numberToShift > 0) | |||
| memmove (e, e + 1, numberToShift * sizeof (ElementType)); | |||
| if ((numUsed << 1) < this->numAllocated) | |||
| if ((numUsed << 1) < data.numAllocated) | |||
| minimiseStorageOverheads(); | |||
| lock.exit(); | |||
| @@ -767,13 +765,13 @@ public: | |||
| void removeValue (const ElementType valueToRemove) throw() | |||
| { | |||
| lock.enter(); | |||
| ElementType* e = this->elements; | |||
| ElementType* e = data.elements; | |||
| for (int i = numUsed; --i >= 0;) | |||
| { | |||
| if (valueToRemove == *e) | |||
| { | |||
| remove ((int) (e - this->elements)); | |||
| remove ((int) (e - data.elements)); | |||
| break; | |||
| } | |||
| @@ -805,7 +803,7 @@ public: | |||
| if (endIndex > startIndex) | |||
| { | |||
| const int rangeSize = endIndex - startIndex; | |||
| ElementType* e = this->elements + startIndex; | |||
| ElementType* e = data.elements + startIndex; | |||
| int numToShift = numUsed - endIndex; | |||
| numUsed -= rangeSize; | |||
| @@ -815,7 +813,7 @@ public: | |||
| ++e; | |||
| } | |||
| if ((numUsed << 1) < this->numAllocated) | |||
| if ((numUsed << 1) < data.numAllocated) | |||
| minimiseStorageOverheads(); | |||
| } | |||
| @@ -832,7 +830,7 @@ public: | |||
| lock.enter(); | |||
| numUsed = jmax (0, numUsed - howManyToRemove); | |||
| if ((numUsed << 1) < this->numAllocated) | |||
| if ((numUsed << 1) < data.numAllocated) | |||
| minimiseStorageOverheads(); | |||
| lock.exit(); | |||
| @@ -858,7 +856,7 @@ public: | |||
| if (otherArray.size() > 0) | |||
| { | |||
| for (int i = numUsed; --i >= 0;) | |||
| if (otherArray.contains (this->elements [i])) | |||
| if (otherArray.contains (data.elements [i])) | |||
| remove (i); | |||
| } | |||
| } | |||
| @@ -889,7 +887,7 @@ public: | |||
| else | |||
| { | |||
| for (int i = numUsed; --i >= 0;) | |||
| if (! otherArray.contains (this->elements [i])) | |||
| if (! otherArray.contains (data.elements [i])) | |||
| remove (i); | |||
| } | |||
| } | |||
| @@ -914,8 +912,8 @@ public: | |||
| if (((unsigned int) index1) < (unsigned int) numUsed | |||
| && ((unsigned int) index2) < (unsigned int) numUsed) | |||
| { | |||
| swapVariables (this->elements [index1], | |||
| this->elements [index2]); | |||
| swapVariables (data.elements [index1], | |||
| data.elements [index2]); | |||
| } | |||
| lock.exit(); | |||
| @@ -947,22 +945,22 @@ public: | |||
| if (((unsigned int) newIndex) >= (unsigned int) numUsed) | |||
| newIndex = numUsed - 1; | |||
| const ElementType value = this->elements [currentIndex]; | |||
| const ElementType value = data.elements [currentIndex]; | |||
| if (newIndex > currentIndex) | |||
| { | |||
| memmove (this->elements + currentIndex, | |||
| this->elements + currentIndex + 1, | |||
| memmove (data.elements + currentIndex, | |||
| data.elements + currentIndex + 1, | |||
| (newIndex - currentIndex) * sizeof (ElementType)); | |||
| } | |||
| else | |||
| { | |||
| memmove (this->elements + newIndex + 1, | |||
| this->elements + newIndex, | |||
| memmove (data.elements + newIndex + 1, | |||
| data.elements + newIndex, | |||
| (currentIndex - newIndex) * sizeof (ElementType)); | |||
| } | |||
| this->elements [newIndex] = value; | |||
| data.elements [newIndex] = value; | |||
| } | |||
| lock.exit(); | |||
| @@ -982,14 +980,14 @@ public: | |||
| if (numUsed == 0) | |||
| { | |||
| this->setAllocatedSize (0); | |||
| data.setAllocatedSize (0); | |||
| } | |||
| else | |||
| { | |||
| const int newAllocation = this->granularity * (numUsed / this->granularity + 1); | |||
| const int newAllocation = data.granularity * (numUsed / data.granularity + 1); | |||
| if (newAllocation < this->numAllocated) | |||
| this->setAllocatedSize (newAllocation); | |||
| if (newAllocation < data.numAllocated) | |||
| data.setAllocatedSize (newAllocation); | |||
| } | |||
| lock.exit(); | |||
| @@ -1003,7 +1001,7 @@ public: | |||
| */ | |||
| void ensureStorageAllocated (const int minNumElements) throw() | |||
| { | |||
| this->ensureAllocatedSize (minNumElements); | |||
| data.ensureAllocatedSize (minNumElements); | |||
| } | |||
| //============================================================================== | |||
| @@ -1040,7 +1038,7 @@ public: | |||
| (void) comparator; // if you pass in an object with a static compareElements() method, this | |||
| // avoids getting warning messages about the parameter being unused | |||
| lock.enter(); | |||
| sortArray (comparator, this->elements, 0, size() - 1, retainOrderOfEquivalentItems); | |||
| sortArray (comparator, data.elements, 0, size() - 1, retainOrderOfEquivalentItems); | |||
| lock.exit(); | |||
| } | |||
| @@ -1074,6 +1072,7 @@ public: | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| ArrayAllocationBase <ElementType> data; | |||
| int numUsed; | |||
| TypeOfCriticalSectionToUse lock; | |||
| }; | |||
| @@ -47,7 +47,7 @@ const int juceDefaultArrayGranularity = 8; | |||
| template <class ElementType> | |||
| class ArrayAllocationBase | |||
| { | |||
| protected: | |||
| public: | |||
| //============================================================================== | |||
| /** Creates an empty array. | |||
| @@ -53,7 +53,7 @@ | |||
| template <class ObjectClass, | |||
| class TypeOfCriticalSectionToUse = DummyCriticalSection> | |||
| class OwnedArray : private ArrayAllocationBase <ObjectClass*> | |||
| class OwnedArray | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| @@ -62,11 +62,9 @@ public: | |||
| @param granularity this is the size of increment by which the internal storage | |||
| used by the array will grow. Only change it from the default if you know the | |||
| array is going to be very big and needs to be able to grow efficiently. | |||
| @see ArrayAllocationBase | |||
| */ | |||
| OwnedArray (const int granularity_ = juceDefaultArrayGranularity) throw() | |||
| : ArrayAllocationBase <ObjectClass*> (granularity_), | |||
| : data (granularity_), | |||
| numUsed (0) | |||
| { | |||
| } | |||
| @@ -90,10 +88,10 @@ public: | |||
| if (deleteObjects) | |||
| { | |||
| while (numUsed > 0) | |||
| delete this->elements [--numUsed]; | |||
| delete data.elements [--numUsed]; | |||
| } | |||
| this->setAllocatedSize (0); | |||
| data.setAllocatedSize (0); | |||
| numUsed = 0; | |||
| lock.exit(); | |||
| } | |||
| @@ -119,7 +117,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| ObjectClass* const result = (((unsigned int) index) < (unsigned int) numUsed) | |||
| ? this->elements [index] | |||
| ? data.elements [index] | |||
| : (ObjectClass*) 0; | |||
| lock.exit(); | |||
| @@ -135,7 +133,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| jassert (((unsigned int) index) < (unsigned int) numUsed); | |||
| ObjectClass* const result = this->elements [index]; | |||
| ObjectClass* const result = data.elements [index]; | |||
| lock.exit(); | |||
| return result; | |||
| @@ -149,7 +147,7 @@ public: | |||
| inline ObjectClass* getFirst() const throw() | |||
| { | |||
| lock.enter(); | |||
| ObjectClass* const result = (numUsed > 0) ? this->elements [0] | |||
| ObjectClass* const result = (numUsed > 0) ? data.elements [0] | |||
| : (ObjectClass*) 0; | |||
| lock.exit(); | |||
| return result; | |||
| @@ -163,7 +161,7 @@ public: | |||
| inline ObjectClass* getLast() const throw() | |||
| { | |||
| lock.enter(); | |||
| ObjectClass* const result = (numUsed > 0) ? this->elements [numUsed - 1] | |||
| ObjectClass* const result = (numUsed > 0) ? data.elements [numUsed - 1] | |||
| : (ObjectClass*) 0; | |||
| lock.exit(); | |||
| @@ -181,13 +179,13 @@ public: | |||
| int result = -1; | |||
| lock.enter(); | |||
| ObjectClass* const* e = this->elements; | |||
| ObjectClass* const* e = data.elements; | |||
| for (int i = numUsed; --i >= 0;) | |||
| { | |||
| if (objectToLookFor == *e) | |||
| { | |||
| result = (int) (e - this->elements); | |||
| result = (int) (e - data.elements); | |||
| break; | |||
| } | |||
| @@ -207,7 +205,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| ObjectClass* const* e = this->elements; | |||
| ObjectClass* const* e = data.elements; | |||
| int i = numUsed; | |||
| while (i >= 4) | |||
| @@ -256,8 +254,8 @@ public: | |||
| void add (const ObjectClass* const newObject) throw() | |||
| { | |||
| lock.enter(); | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| this->elements [numUsed++] = const_cast <ObjectClass*> (newObject); | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| data.elements [numUsed++] = const_cast <ObjectClass*> (newObject); | |||
| lock.exit(); | |||
| } | |||
| @@ -288,9 +286,9 @@ public: | |||
| if (indexToInsertAt > numUsed) | |||
| indexToInsertAt = numUsed; | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| ObjectClass** const e = this->elements + indexToInsertAt; | |||
| ObjectClass** const e = data.elements + indexToInsertAt; | |||
| const int numToMove = numUsed - indexToInsertAt; | |||
| if (numToMove > 0) | |||
| @@ -350,18 +348,18 @@ public: | |||
| { | |||
| if (deleteOldElement) | |||
| { | |||
| toDelete = this->elements [indexToChange]; | |||
| toDelete = data.elements [indexToChange]; | |||
| if (toDelete == newObject) | |||
| toDelete = 0; | |||
| } | |||
| this->elements [indexToChange] = const_cast <ObjectClass*> (newObject); | |||
| data.elements [indexToChange] = const_cast <ObjectClass*> (newObject); | |||
| } | |||
| else | |||
| { | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| this->elements [numUsed++] = const_cast <ObjectClass*> (newObject); | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| data.elements [numUsed++] = const_cast <ObjectClass*> (newObject); | |||
| } | |||
| lock.exit(); | |||
| @@ -388,7 +386,7 @@ public: | |||
| (void) comparator; // if you pass in an object with a static compareElements() method, this | |||
| // avoids getting warning messages about the parameter being unused | |||
| lock.enter(); | |||
| insert (findInsertIndexInSortedArray (comparator, this->elements, newObject, 0, numUsed), newObject); | |||
| insert (findInsertIndexInSortedArray (comparator, data.elements, newObject, 0, numUsed), newObject); | |||
| lock.exit(); | |||
| } | |||
| @@ -422,7 +420,7 @@ public: | |||
| lock.exit(); | |||
| return -1; | |||
| } | |||
| else if (comparator.compareElements (objectToLookFor, this->elements [start]) == 0) | |||
| else if (comparator.compareElements (objectToLookFor, data.elements [start]) == 0) | |||
| { | |||
| lock.exit(); | |||
| return start; | |||
| @@ -436,7 +434,7 @@ public: | |||
| lock.exit(); | |||
| return -1; | |||
| } | |||
| else if (comparator.compareElements (objectToLookFor, this->elements [halfway]) >= 0) | |||
| else if (comparator.compareElements (objectToLookFor, data.elements [halfway]) >= 0) | |||
| start = halfway; | |||
| else | |||
| end = halfway; | |||
| @@ -463,7 +461,7 @@ public: | |||
| if (((unsigned int) indexToRemove) < (unsigned int) numUsed) | |||
| { | |||
| ObjectClass** const e = this->elements + indexToRemove; | |||
| ObjectClass** const e = data.elements + indexToRemove; | |||
| if (deleteObject) | |||
| toDelete = *e; | |||
| @@ -474,7 +472,7 @@ public: | |||
| if (numToShift > 0) | |||
| memmove (e, e + 1, numToShift * sizeof (ObjectClass*)); | |||
| if ((numUsed << 1) < this->numAllocated) | |||
| if ((numUsed << 1) < data.numAllocated) | |||
| minimiseStorageOverheads(); | |||
| } | |||
| @@ -495,13 +493,13 @@ public: | |||
| const bool deleteObject = true) | |||
| { | |||
| lock.enter(); | |||
| ObjectClass** e = this->elements; | |||
| ObjectClass** e = data.elements; | |||
| for (int i = numUsed; --i >= 0;) | |||
| { | |||
| if (objectToRemove == *e) | |||
| { | |||
| remove ((int) (e - this->elements), deleteObject); | |||
| remove ((int) (e - data.elements), deleteObject); | |||
| break; | |||
| } | |||
| @@ -538,13 +536,13 @@ public: | |||
| { | |||
| for (int i = startIndex; i < endIndex; ++i) | |||
| { | |||
| delete this->elements [i]; | |||
| this->elements [i] = 0; // (in case one of the destructors accesses this array and hits a dangling pointer) | |||
| delete data.elements [i]; | |||
| data.elements [i] = 0; // (in case one of the destructors accesses this array and hits a dangling pointer) | |||
| } | |||
| } | |||
| const int rangeSize = endIndex - startIndex; | |||
| ObjectClass** e = this->elements + startIndex; | |||
| ObjectClass** e = data.elements + startIndex; | |||
| int numToShift = numUsed - endIndex; | |||
| numUsed -= rangeSize; | |||
| @@ -554,7 +552,7 @@ public: | |||
| ++e; | |||
| } | |||
| if ((numUsed << 1) < this->numAllocated) | |||
| if ((numUsed << 1) < data.numAllocated) | |||
| minimiseStorageOverheads(); | |||
| } | |||
| @@ -598,8 +596,8 @@ public: | |||
| if (((unsigned int) index1) < (unsigned int) numUsed | |||
| && ((unsigned int) index2) < (unsigned int) numUsed) | |||
| { | |||
| swapVariables (this->elements [index1], | |||
| this->elements [index2]); | |||
| swapVariables (data.elements [index1], | |||
| data.elements [index2]); | |||
| } | |||
| lock.exit(); | |||
| @@ -630,22 +628,22 @@ public: | |||
| if (((unsigned int) newIndex) >= (unsigned int) numUsed) | |||
| newIndex = numUsed - 1; | |||
| ObjectClass* const value = this->elements [currentIndex]; | |||
| ObjectClass* const value = data.elements [currentIndex]; | |||
| if (newIndex > currentIndex) | |||
| { | |||
| memmove (this->elements + currentIndex, | |||
| this->elements + currentIndex + 1, | |||
| memmove (data.elements + currentIndex, | |||
| data.elements + currentIndex + 1, | |||
| (newIndex - currentIndex) * sizeof (ObjectClass*)); | |||
| } | |||
| else | |||
| { | |||
| memmove (this->elements + newIndex + 1, | |||
| this->elements + newIndex, | |||
| memmove (data.elements + newIndex + 1, | |||
| data.elements + newIndex, | |||
| (currentIndex - newIndex) * sizeof (ObjectClass*)); | |||
| } | |||
| this->elements [newIndex] = value; | |||
| data.elements [newIndex] = value; | |||
| } | |||
| lock.exit(); | |||
| @@ -662,9 +660,9 @@ public: | |||
| { | |||
| lock.enter(); | |||
| otherArray.lock.enter(); | |||
| swapVariables <int> (this->numUsed, otherArray.numUsed); | |||
| swapVariables <ObjectClass**> (this->elements, otherArray.elements); | |||
| swapVariables <int> (this->numAllocated, otherArray.numAllocated); | |||
| swapVariables <int> (numUsed, otherArray.numUsed); | |||
| swapVariables <ObjectClass**> (data.elements, otherArray.data.elements); | |||
| swapVariables <int> (data.numAllocated, otherArray.data.numAllocated); | |||
| otherArray.lock.exit(); | |||
| lock.exit(); | |||
| } | |||
| @@ -682,14 +680,14 @@ public: | |||
| if (numUsed == 0) | |||
| { | |||
| this->setAllocatedSize (0); | |||
| data.setAllocatedSize (0); | |||
| } | |||
| else | |||
| { | |||
| const int newAllocation = this->granularity * (numUsed / this->granularity + 1); | |||
| const int newAllocation = data.granularity * (numUsed / data.granularity + 1); | |||
| if (newAllocation < this->numAllocated) | |||
| this->setAllocatedSize (newAllocation); | |||
| if (newAllocation < data.numAllocated) | |||
| data.setAllocatedSize (newAllocation); | |||
| } | |||
| lock.exit(); | |||
| @@ -703,7 +701,7 @@ public: | |||
| */ | |||
| void ensureStorageAllocated (const int minNumElements) throw() | |||
| { | |||
| this->ensureAllocatedSize (minNumElements); | |||
| data.ensureAllocatedSize (minNumElements); | |||
| } | |||
| //============================================================================== | |||
| @@ -740,7 +738,7 @@ public: | |||
| // avoids getting warning messages about the parameter being unused | |||
| lock.enter(); | |||
| sortArray (comparator, this->elements, 0, size() - 1, retainOrderOfEquivalentItems); | |||
| sortArray (comparator, data.elements, 0, size() - 1, retainOrderOfEquivalentItems); | |||
| lock.exit(); | |||
| } | |||
| @@ -774,6 +772,7 @@ public: | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| ArrayAllocationBase <ObjectClass*> data; | |||
| int numUsed; | |||
| TypeOfCriticalSectionToUse lock; | |||
| @@ -46,7 +46,7 @@ | |||
| @see Array, OwnedArray, StringArray | |||
| */ | |||
| template <class ObjectClass, class TypeOfCriticalSectionToUse = DummyCriticalSection> | |||
| class ReferenceCountedArray : private ArrayAllocationBase <ObjectClass*> | |||
| class ReferenceCountedArray | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| @@ -56,26 +56,26 @@ public: | |||
| used by the array will grow. Only change it from the default if you know the | |||
| array is going to be very big and needs to be able to grow efficiently. | |||
| @see ReferenceCountedObject, ArrayAllocationBase, Array, OwnedArray | |||
| @see ReferenceCountedObject, Array, OwnedArray | |||
| */ | |||
| ReferenceCountedArray (const int granularity_ = juceDefaultArrayGranularity) throw() | |||
| : ArrayAllocationBase <ObjectClass*> (granularity_), | |||
| : data (granularity_), | |||
| numUsed (0) | |||
| { | |||
| } | |||
| /** Creates a copy of another array */ | |||
| ReferenceCountedArray (const ReferenceCountedArray<ObjectClass, TypeOfCriticalSectionToUse>& other) throw() | |||
| : ArrayAllocationBase <ObjectClass*> (other.granularity) | |||
| : data (other.data.granularity) | |||
| { | |||
| other.lockArray(); | |||
| numUsed = other.numUsed; | |||
| this->setAllocatedSize (numUsed); | |||
| memcpy (this->elements, other.elements, numUsed * sizeof (ObjectClass*)); | |||
| data.setAllocatedSize (numUsed); | |||
| memcpy (data.elements, other.data.elements, numUsed * sizeof (ObjectClass*)); | |||
| for (int i = numUsed; --i >= 0;) | |||
| if (this->elements[i] != 0) | |||
| this->elements[i]->incReferenceCount(); | |||
| if (data.elements[i] != 0) | |||
| data.elements[i]->incReferenceCount(); | |||
| other.unlockArray(); | |||
| } | |||
| @@ -93,15 +93,15 @@ public: | |||
| clear(); | |||
| this->granularity = other.granularity; | |||
| this->ensureAllocatedSize (other.numUsed); | |||
| data.granularity = other.granularity; | |||
| data.ensureAllocatedSize (other.numUsed); | |||
| numUsed = other.numUsed; | |||
| memcpy (this->elements, other.elements, numUsed * sizeof (ObjectClass*)); | |||
| memcpy (data.elements, other.data.elements, numUsed * sizeof (ObjectClass*)); | |||
| minimiseStorageOverheads(); | |||
| for (int i = numUsed; --i >= 0;) | |||
| if (this->elements[i] != 0) | |||
| this->elements[i]->incReferenceCount(); | |||
| if (data.elements[i] != 0) | |||
| data.elements[i]->incReferenceCount(); | |||
| lock.exit(); | |||
| other.unlockArray(); | |||
| @@ -129,11 +129,11 @@ public: | |||
| lock.enter(); | |||
| while (numUsed > 0) | |||
| if (this->elements [--numUsed] != 0) | |||
| this->elements [numUsed]->decReferenceCount(); | |||
| if (data.elements [--numUsed] != 0) | |||
| data.elements [numUsed]->decReferenceCount(); | |||
| jassert (numUsed == 0); | |||
| this->setAllocatedSize (0); | |||
| data.setAllocatedSize (0); | |||
| lock.exit(); | |||
| } | |||
| @@ -156,7 +156,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| const ReferenceCountedObjectPtr<ObjectClass> result ((((unsigned int) index) < (unsigned int) numUsed) | |||
| ? this->elements [index] | |||
| ? data.elements [index] | |||
| : (ObjectClass*) 0); | |||
| lock.exit(); | |||
| return result; | |||
| @@ -171,7 +171,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| jassert (((unsigned int) index) < (unsigned int) numUsed); | |||
| const ReferenceCountedObjectPtr<ObjectClass> result (this->elements [index]); | |||
| const ReferenceCountedObjectPtr<ObjectClass> result (data.elements [index]); | |||
| lock.exit(); | |||
| return result; | |||
| } | |||
| @@ -184,7 +184,7 @@ public: | |||
| inline const ReferenceCountedObjectPtr<ObjectClass> getFirst() const throw() | |||
| { | |||
| lock.enter(); | |||
| const ReferenceCountedObjectPtr<ObjectClass> result ((numUsed > 0) ? this->elements [0] | |||
| const ReferenceCountedObjectPtr<ObjectClass> result ((numUsed > 0) ? data.elements [0] | |||
| : (ObjectClass*) 0); | |||
| lock.exit(); | |||
| @@ -199,7 +199,7 @@ public: | |||
| inline const ReferenceCountedObjectPtr<ObjectClass> getLast() const throw() | |||
| { | |||
| lock.enter(); | |||
| const ReferenceCountedObjectPtr<ObjectClass> result ((numUsed > 0) ? this->elements [numUsed - 1] | |||
| const ReferenceCountedObjectPtr<ObjectClass> result ((numUsed > 0) ? data.elements [numUsed - 1] | |||
| : (ObjectClass*) 0); | |||
| lock.exit(); | |||
| @@ -217,13 +217,13 @@ public: | |||
| int result = -1; | |||
| lock.enter(); | |||
| ObjectClass** e = this->elements; | |||
| ObjectClass** e = data.elements; | |||
| for (int i = numUsed; --i >= 0;) | |||
| { | |||
| if (objectToLookFor == *e) | |||
| { | |||
| result = (int) (e - this->elements); | |||
| result = (int) (e - data.elements); | |||
| break; | |||
| } | |||
| @@ -242,7 +242,7 @@ public: | |||
| bool contains (const ObjectClass* const objectToLookFor) const throw() | |||
| { | |||
| lock.enter(); | |||
| ObjectClass** e = this->elements; | |||
| ObjectClass** e = data.elements; | |||
| for (int i = numUsed; --i >= 0;) | |||
| { | |||
| @@ -269,8 +269,8 @@ public: | |||
| void add (ObjectClass* const newObject) throw() | |||
| { | |||
| lock.enter(); | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| this->elements [numUsed++] = newObject; | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| data.elements [numUsed++] = newObject; | |||
| if (newObject != 0) | |||
| newObject->incReferenceCount(); | |||
| @@ -301,9 +301,9 @@ public: | |||
| if (indexToInsertAt > numUsed) | |||
| indexToInsertAt = numUsed; | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| ObjectClass** const e = this->elements + indexToInsertAt; | |||
| ObjectClass** const e = data.elements + indexToInsertAt; | |||
| const int numToMove = numUsed - indexToInsertAt; | |||
| if (numToMove > 0) | |||
| @@ -364,15 +364,15 @@ public: | |||
| if (indexToChange < numUsed) | |||
| { | |||
| if (this->elements [indexToChange] != 0) | |||
| this->elements [indexToChange]->decReferenceCount(); | |||
| if (data.elements [indexToChange] != 0) | |||
| data.elements [indexToChange]->decReferenceCount(); | |||
| this->elements [indexToChange] = newObject; | |||
| data.elements [indexToChange] = newObject; | |||
| } | |||
| else | |||
| { | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| this->elements [numUsed++] = newObject; | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| data.elements [numUsed++] = newObject; | |||
| } | |||
| lock.exit(); | |||
| @@ -406,7 +406,7 @@ public: | |||
| if (numElementsToAdd > 0) | |||
| { | |||
| this->ensureAllocatedSize (numUsed + numElementsToAdd); | |||
| data.ensureAllocatedSize (numUsed + numElementsToAdd); | |||
| while (--numElementsToAdd >= 0) | |||
| add (arrayToAddFrom.getUnchecked (startIndex++)); | |||
| @@ -432,7 +432,7 @@ public: | |||
| ObjectClass* newObject) throw() | |||
| { | |||
| lock.enter(); | |||
| insert (findInsertIndexInSortedArray (comparator, this->elements, newObject, 0, numUsed), newObject); | |||
| insert (findInsertIndexInSortedArray (comparator, data.elements, newObject, 0, numUsed), newObject); | |||
| lock.exit(); | |||
| } | |||
| @@ -446,9 +446,9 @@ public: | |||
| ObjectClass* newObject) throw() | |||
| { | |||
| lock.enter(); | |||
| const int index = findInsertIndexInSortedArray (comparator, this->elements, newObject, 0, numUsed); | |||
| const int index = findInsertIndexInSortedArray (comparator, data.elements, newObject, 0, numUsed); | |||
| if (index > 0 && comparator.compareElements (newObject, this->elements [index - 1]) == 0) | |||
| if (index > 0 && comparator.compareElements (newObject, data.elements [index - 1]) == 0) | |||
| set (index - 1, newObject); // replace an existing object that matches | |||
| else | |||
| insert (index, newObject); // no match, so insert the new one | |||
| @@ -476,7 +476,7 @@ public: | |||
| if (((unsigned int) indexToRemove) < (unsigned int) numUsed) | |||
| { | |||
| ObjectClass** const e = this->elements + indexToRemove; | |||
| ObjectClass** const e = data.elements + indexToRemove; | |||
| if (*e != 0) | |||
| (*e)->decReferenceCount(); | |||
| @@ -487,7 +487,7 @@ public: | |||
| if (numberToShift > 0) | |||
| memmove (e, e + 1, numberToShift * sizeof (ObjectClass*)); | |||
| if ((numUsed << 1) < this->numAllocated) | |||
| if ((numUsed << 1) < data.numAllocated) | |||
| minimiseStorageOverheads(); | |||
| } | |||
| @@ -537,15 +537,15 @@ public: | |||
| int i; | |||
| for (i = start; i < end; ++i) | |||
| { | |||
| if (this->elements[i] != 0) | |||
| if (data.elements[i] != 0) | |||
| { | |||
| this->elements[i]->decReferenceCount(); | |||
| this->elements[i] = 0; // (in case one of the destructors accesses this array and hits a dangling pointer) | |||
| data.elements[i]->decReferenceCount(); | |||
| data.elements[i] = 0; // (in case one of the destructors accesses this array and hits a dangling pointer) | |||
| } | |||
| } | |||
| const int rangeSize = end - start; | |||
| ObjectClass** e = this->elements + start; | |||
| ObjectClass** e = data.elements + start; | |||
| i = numUsed - end; | |||
| numUsed -= rangeSize; | |||
| @@ -555,7 +555,7 @@ public: | |||
| ++e; | |||
| } | |||
| if ((numUsed << 1) < this->numAllocated) | |||
| if ((numUsed << 1) < data.numAllocated) | |||
| minimiseStorageOverheads(); | |||
| } | |||
| @@ -596,8 +596,8 @@ public: | |||
| if (((unsigned int) index1) < (unsigned int) numUsed | |||
| && ((unsigned int) index2) < (unsigned int) numUsed) | |||
| { | |||
| swapVariables (this->elements [index1], | |||
| this->elements [index2]); | |||
| swapVariables (data.elements [index1], | |||
| data.elements [index2]); | |||
| } | |||
| lock.exit(); | |||
| @@ -628,22 +628,22 @@ public: | |||
| if (((unsigned int) newIndex) >= (unsigned int) numUsed) | |||
| newIndex = numUsed - 1; | |||
| ObjectClass* const value = this->elements [currentIndex]; | |||
| ObjectClass* const value = data.elements [currentIndex]; | |||
| if (newIndex > currentIndex) | |||
| { | |||
| memmove (this->elements + currentIndex, | |||
| this->elements + currentIndex + 1, | |||
| memmove (data.elements + currentIndex, | |||
| data.elements + currentIndex + 1, | |||
| (newIndex - currentIndex) * sizeof (ObjectClass*)); | |||
| } | |||
| else | |||
| { | |||
| memmove (this->elements + newIndex + 1, | |||
| this->elements + newIndex, | |||
| memmove (data.elements + newIndex + 1, | |||
| data.elements + newIndex, | |||
| (currentIndex - newIndex) * sizeof (ObjectClass*)); | |||
| } | |||
| this->elements [newIndex] = value; | |||
| data.elements [newIndex] = value; | |||
| } | |||
| lock.exit(); | |||
| @@ -666,7 +666,7 @@ public: | |||
| { | |||
| for (int i = numUsed; --i >= 0;) | |||
| { | |||
| if (this->elements [i] != other.elements [i]) | |||
| if (data.elements [i] != other.data.elements [i]) | |||
| { | |||
| result = false; | |||
| break; | |||
| @@ -724,7 +724,7 @@ public: | |||
| // avoids getting warning messages about the parameter being unused | |||
| lock.enter(); | |||
| sortArray (comparator, this->elements, 0, size() - 1, retainOrderOfEquivalentItems); | |||
| sortArray (comparator, data.elements, 0, size() - 1, retainOrderOfEquivalentItems); | |||
| lock.exit(); | |||
| } | |||
| @@ -741,14 +741,14 @@ public: | |||
| if (numUsed == 0) | |||
| { | |||
| this->setAllocatedSize (0); | |||
| data.setAllocatedSize (0); | |||
| } | |||
| else | |||
| { | |||
| const int newAllocation = this->granularity * (numUsed / this->granularity + 1); | |||
| const int newAllocation = data.granularity * (numUsed / data.granularity + 1); | |||
| if (newAllocation < this->numAllocated) | |||
| this->setAllocatedSize (newAllocation); | |||
| if (newAllocation < data.numAllocated) | |||
| data.setAllocatedSize (newAllocation); | |||
| } | |||
| lock.exit(); | |||
| @@ -784,6 +784,7 @@ public: | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| ArrayAllocationBase <ObjectClass*> data; | |||
| int numUsed; | |||
| TypeOfCriticalSectionToUse lock; | |||
| }; | |||
| @@ -58,7 +58,7 @@ | |||
| @see Array, OwnedArray, ReferenceCountedArray, StringArray, CriticalSection | |||
| */ | |||
| template <class ElementType, class TypeOfCriticalSectionToUse = DummyCriticalSection> | |||
| class SortedSet : private ArrayAllocationBase <ElementType> | |||
| class SortedSet | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| @@ -67,11 +67,9 @@ public: | |||
| @param granularity this is the size of increment by which the internal storage | |||
| used by the array will grow. Only change it from the default if you know the | |||
| array is going to be very big and needs to be able to grow efficiently. | |||
| @see ArrayAllocationBase | |||
| */ | |||
| SortedSet (const int granularity_ = juceDefaultArrayGranularity) throw() | |||
| : ArrayAllocationBase <ElementType> (granularity_), | |||
| : data (granularity_), | |||
| numUsed (0) | |||
| { | |||
| } | |||
| @@ -80,12 +78,12 @@ public: | |||
| @param other the set to copy | |||
| */ | |||
| SortedSet (const SortedSet<ElementType, TypeOfCriticalSectionToUse>& other) throw() | |||
| : ArrayAllocationBase <ElementType> (other.granularity) | |||
| : data (other.data.granularity) | |||
| { | |||
| other.lockSet(); | |||
| numUsed = other.numUsed; | |||
| setAllocatedSize (other.numUsed); | |||
| memcpy (this->elements, other.elements, numUsed * sizeof (ElementType)); | |||
| data.setAllocatedSize (other.numUsed); | |||
| memcpy (data.elements, other.data.elements, numUsed * sizeof (ElementType)); | |||
| other.unlockSet(); | |||
| } | |||
| @@ -104,10 +102,10 @@ public: | |||
| other.lockSet(); | |||
| lock.enter(); | |||
| this->granularity = other.granularity; | |||
| ensureAllocatedSize (other.size()); | |||
| data.granularity = other.data.granularity; | |||
| data.ensureAllocatedSize (other.size()); | |||
| numUsed = other.numUsed; | |||
| memcpy (this->elements, other.elements, numUsed * sizeof (ElementType)); | |||
| memcpy (data.elements, other.data.elements, numUsed * sizeof (ElementType)); | |||
| minimiseStorageOverheads(); | |||
| lock.exit(); | |||
| @@ -137,7 +135,7 @@ public: | |||
| for (int i = numUsed; --i >= 0;) | |||
| { | |||
| if (this->elements [i] != other.elements [i]) | |||
| if (data.elements [i] != other.data.elements [i]) | |||
| { | |||
| lock.exit(); | |||
| return false; | |||
| @@ -172,7 +170,7 @@ public: | |||
| void clear() throw() | |||
| { | |||
| lock.enter(); | |||
| this->setAllocatedSize (0); | |||
| data.setAllocatedSize (0); | |||
| numUsed = 0; | |||
| lock.exit(); | |||
| } | |||
| @@ -211,7 +209,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| const ElementType result = (((unsigned int) index) < (unsigned int) numUsed) | |||
| ? this->elements [index] | |||
| ? data.elements [index] | |||
| : (ElementType) 0; | |||
| lock.exit(); | |||
| @@ -230,7 +228,7 @@ public: | |||
| { | |||
| lock.enter(); | |||
| jassert (((unsigned int) index) < (unsigned int) numUsed); | |||
| const ElementType result = this->elements [index]; | |||
| const ElementType result = data.elements [index]; | |||
| lock.exit(); | |||
| return result; | |||
| @@ -243,7 +241,7 @@ public: | |||
| inline ElementType getFirst() const throw() | |||
| { | |||
| lock.enter(); | |||
| const ElementType result = (numUsed > 0) ? this->elements [0] | |||
| const ElementType result = (numUsed > 0) ? data.elements [0] | |||
| : (ElementType) 0; | |||
| lock.exit(); | |||
| @@ -257,7 +255,7 @@ public: | |||
| inline ElementType getLast() const throw() | |||
| { | |||
| lock.enter(); | |||
| const ElementType result = (numUsed > 0) ? this->elements [numUsed - 1] | |||
| const ElementType result = (numUsed > 0) ? data.elements [numUsed - 1] | |||
| : (ElementType) 0; | |||
| lock.exit(); | |||
| @@ -287,7 +285,7 @@ public: | |||
| lock.exit(); | |||
| return -1; | |||
| } | |||
| else if (elementToLookFor == this->elements [start]) | |||
| else if (elementToLookFor == data.elements [start]) | |||
| { | |||
| lock.exit(); | |||
| return start; | |||
| @@ -301,7 +299,7 @@ public: | |||
| lock.exit(); | |||
| return -1; | |||
| } | |||
| else if (elementToLookFor >= this->elements [halfway]) | |||
| else if (elementToLookFor >= data.elements [halfway]) | |||
| start = halfway; | |||
| else | |||
| end = halfway; | |||
| @@ -328,7 +326,7 @@ public: | |||
| lock.exit(); | |||
| return false; | |||
| } | |||
| else if (elementToLookFor == this->elements [start]) | |||
| else if (elementToLookFor == data.elements [start]) | |||
| { | |||
| lock.exit(); | |||
| return true; | |||
| @@ -342,7 +340,7 @@ public: | |||
| lock.exit(); | |||
| return false; | |||
| } | |||
| else if (elementToLookFor >= this->elements [halfway]) | |||
| else if (elementToLookFor >= data.elements [halfway]) | |||
| start = halfway; | |||
| else | |||
| end = halfway; | |||
| @@ -371,7 +369,7 @@ public: | |||
| insertInternal (start, newElement); | |||
| break; | |||
| } | |||
| else if (newElement == this->elements [start]) | |||
| else if (newElement == data.elements [start]) | |||
| { | |||
| break; | |||
| } | |||
| @@ -381,14 +379,14 @@ public: | |||
| if (halfway == start) | |||
| { | |||
| if (newElement >= this->elements [halfway]) | |||
| if (newElement >= data.elements [halfway]) | |||
| insertInternal (start + 1, newElement); | |||
| else | |||
| insertInternal (start, newElement); | |||
| break; | |||
| } | |||
| else if (newElement >= this->elements [halfway]) | |||
| else if (newElement >= data.elements [halfway]) | |||
| start = halfway; | |||
| else | |||
| end = halfway; | |||
| @@ -470,14 +468,14 @@ public: | |||
| { | |||
| --numUsed; | |||
| ElementType* const e = this->elements + indexToRemove; | |||
| ElementType* const e = data.elements + indexToRemove; | |||
| ElementType const removed = *e; | |||
| const int numberToShift = numUsed - indexToRemove; | |||
| if (numberToShift > 0) | |||
| memmove (e, e + 1, numberToShift * sizeof (ElementType)); | |||
| if ((numUsed << 1) < this->numAllocated) | |||
| if ((numUsed << 1) < data.numAllocated) | |||
| minimiseStorageOverheads(); | |||
| lock.exit(); | |||
| @@ -524,7 +522,7 @@ public: | |||
| if (otherSet.size() > 0) | |||
| { | |||
| for (int i = numUsed; --i >= 0;) | |||
| if (otherSet.contains (this->elements [i])) | |||
| if (otherSet.contains (data.elements [i])) | |||
| remove (i); | |||
| } | |||
| } | |||
| @@ -555,7 +553,7 @@ public: | |||
| else | |||
| { | |||
| for (int i = numUsed; --i >= 0;) | |||
| if (! otherSet.contains (this->elements [i])) | |||
| if (! otherSet.contains (data.elements [i])) | |||
| remove (i); | |||
| } | |||
| } | |||
| @@ -577,14 +575,14 @@ public: | |||
| if (numUsed == 0) | |||
| { | |||
| this->setAllocatedSize (0); | |||
| data.setAllocatedSize (0); | |||
| } | |||
| else | |||
| { | |||
| const int newAllocation = this->granularity * (numUsed / this->granularity + 1); | |||
| const int newAllocation = data.granularity * (numUsed / data.granularity + 1); | |||
| if (newAllocation < this->numAllocated) | |||
| this->setAllocatedSize (newAllocation); | |||
| if (newAllocation < data.numAllocated) | |||
| data.setAllocatedSize (newAllocation); | |||
| } | |||
| lock.exit(); | |||
| @@ -620,14 +618,15 @@ public: | |||
| juce_UseDebuggingNewOperator | |||
| private: | |||
| ArrayAllocationBase <ElementType> data; | |||
| int numUsed; | |||
| TypeOfCriticalSectionToUse lock; | |||
| void insertInternal (const int indexToInsertAt, const ElementType newElement) throw() | |||
| { | |||
| this->ensureAllocatedSize (numUsed + 1); | |||
| data.ensureAllocatedSize (numUsed + 1); | |||
| ElementType* const insertPos = this->elements + indexToInsertAt; | |||
| ElementType* const insertPos = data.elements + indexToInsertAt; | |||
| const int numberToMove = numUsed - indexToInsertAt; | |||
| if (numberToMove > 0) | |||
| @@ -90,8 +90,9 @@ class ValueTreeChildChangeAction : public UndoableAction | |||
| public: | |||
| ValueTreeChildChangeAction (const ValueTree::SharedObjectPtr& target_, const int childIndex_, | |||
| const ValueTree::SharedObjectPtr& newChild_) throw() | |||
| : target (target_), childIndex (childIndex_), | |||
| : target (target_), | |||
| child (newChild_ != 0 ? newChild_ : target_->children [childIndex_]), | |||
| childIndex (childIndex_), | |||
| isDeleting (newChild_ == 0) | |||
| { | |||
| jassert (child != 0); | |||
| @@ -71,7 +71,8 @@ public: | |||
| buttonOnColourId = 0x1000101, /**< The colour used to fill the button shape (when the button is toggled | |||
| 'on'). The look-and-feel class might re-interpret this to add | |||
| effects, etc. */ | |||
| textColourId = 0x1000102 /**< The colour to use for the button's text. */ | |||
| textColourOffId = 0x1000102, /**< The colour to use for the button's text when the button's toggle state is "off". */ | |||
| textColourOnId = 0x1000103 /**< The colour to use for the button's text.when the button's toggle state is "on". */ | |||
| }; | |||
| //============================================================================== | |||
| @@ -212,16 +212,16 @@ bool CodeDocument::Iterator::isEOF() const throw() | |||
| //============================================================================== | |||
| CodeDocument::Position::Position() throw() | |||
| : owner (0), line (0), indexInLine (0), | |||
| characterPos (0), positionMaintained (false) | |||
| : owner (0), characterPos (0), line (0), | |||
| indexInLine (0), positionMaintained (false) | |||
| { | |||
| } | |||
| CodeDocument::Position::Position (const CodeDocument* const ownerDocument, | |||
| const int line_, const int indexInLine_) throw() | |||
| : owner (const_cast <CodeDocument*> (ownerDocument)), | |||
| line (line_), indexInLine (indexInLine_), | |||
| characterPos (0), positionMaintained (false) | |||
| characterPos (0), line (line_), | |||
| indexInLine (indexInLine_), positionMaintained (false) | |||
| { | |||
| setLineAndIndex (line_, indexInLine_); | |||
| } | |||
| @@ -235,9 +235,8 @@ CodeDocument::Position::Position (const CodeDocument* const ownerDocument, | |||
| } | |||
| CodeDocument::Position::Position (const Position& other) throw() | |||
| : owner (other.owner), line (other.line), | |||
| indexInLine (other.indexInLine), characterPos (other.characterPos), | |||
| positionMaintained (false) | |||
| : owner (other.owner), characterPos (other.characterPos), line (other.line), | |||
| indexInLine (other.indexInLine), positionMaintained (false) | |||
| { | |||
| jassert (*this == other); | |||
| } | |||
| @@ -277,16 +277,16 @@ private: | |||
| CodeEditorComponent::CodeEditorComponent (CodeDocument& document_, | |||
| CodeTokeniser* const codeTokeniser_) | |||
| : document (document_), | |||
| codeTokeniser (codeTokeniser_), | |||
| firstLineOnScreen (0), | |||
| gutter (5), | |||
| spacesPerTab (4), | |||
| lineHeight (0), | |||
| firstLineOnScreen (0), | |||
| linesOnScreen (0), | |||
| columnsOnScreen (0), | |||
| scrollbarThickness (16), | |||
| useSpacesForTabs (false), | |||
| xOffset (0), | |||
| useSpacesForTabs (false) | |||
| codeTokeniser (codeTokeniser_) | |||
| { | |||
| caretPos = CodeDocument::Position (&document_, 0, 0); | |||
| caretPos.setPositionMaintained (true); | |||
| @@ -565,6 +565,14 @@ TreeViewItem* TreeView::getItemAt (int y) const throw() | |||
| return tc->findItemAt (y, pos); | |||
| } | |||
| TreeViewItem* TreeView::findItemFromIdentifierString (const String& identifierString) const | |||
| { | |||
| if (rootItem == 0) | |||
| return 0; | |||
| return rootItem->findItemFromIdentifierString (identifierString); | |||
| } | |||
| //============================================================================== | |||
| XmlElement* TreeView::getOpennessState (const bool alsoIncludeScrollPosition) const | |||
| { | |||
| @@ -1679,6 +1687,44 @@ TreeViewItem* TreeViewItem::getNextVisibleItem (const bool recurse) const throw( | |||
| return 0; | |||
| } | |||
| const String TreeViewItem::getItemIdentifierString() const | |||
| { | |||
| String s; | |||
| if (parentItem != 0) | |||
| s = parentItem->getItemIdentifierString(); | |||
| return s + T("/") + getUniqueName().replaceCharacter (T('/'), T('\\')); | |||
| } | |||
| TreeViewItem* TreeViewItem::findItemFromIdentifierString (const String& identifierString) | |||
| { | |||
| const String uid (getUniqueName()); | |||
| if (uid == identifierString) | |||
| return this; | |||
| if (identifierString.startsWith (uid + T("/"))) | |||
| { | |||
| const String remainingPath (identifierString.substring (uid.length() + 1)); | |||
| bool wasOpen = isOpen(); | |||
| setOpen (true); | |||
| for (int i = subItems.size(); --i >= 0;) | |||
| { | |||
| TreeViewItem* item = subItems.getUnchecked(i)->findItemFromIdentifierString (remainingPath); | |||
| if (item != 0) | |||
| return item; | |||
| } | |||
| setOpen (wasOpen); | |||
| } | |||
| return 0; | |||
| } | |||
| void TreeViewItem::restoreOpennessState (const XmlElement& e) throw() | |||
| { | |||
| if (e.hasTagName (T("CLOSED"))) | |||
| @@ -450,6 +450,15 @@ public: | |||
| /** Returns true if this item is the last of its parent's sub-itens. */ | |||
| bool isLastOfSiblings() const throw(); | |||
| /** Creates a string that can be used to uniquely retrieve this item in the tree. | |||
| The string that is returned can be passed to TreeView::findItemFromIdentifierString(). | |||
| The string takes the form of a path, constructed from the getUniqueName() of this | |||
| item and all its parents, so these must all be correctly implemented for it to work. | |||
| @see TreeView::findItemFromIdentifierString, getUniqueName | |||
| */ | |||
| const String getItemIdentifierString() const; | |||
| //============================================================================== | |||
| juce_UseDebuggingNewOperator | |||
| @@ -481,6 +490,7 @@ private: | |||
| int countSelectedItemsRecursively() const throw(); | |||
| TreeViewItem* getSelectedItemWithIndex (int index) throw(); | |||
| TreeViewItem* getNextVisibleItem (const bool recurse) const throw(); | |||
| TreeViewItem* findItemFromIdentifierString (const String& identifierString); | |||
| TreeViewItem (const TreeViewItem&); | |||
| const TreeViewItem& operator= (const TreeViewItem&); | |||
| @@ -654,6 +664,13 @@ public: | |||
| */ | |||
| void setIndentSize (const int newIndentSize); | |||
| /** Searches the tree for an item with the specified identifier. | |||
| The identifer string must have been created by calling TreeViewItem::getItemIdentifierString(). | |||
| If no such item exists, this will return false. If the item is found, all of its items | |||
| will be automatically opened. | |||
| */ | |||
| TreeViewItem* findItemFromIdentifierString (const String& identifierString) const; | |||
| //============================================================================== | |||
| /** Saves the current state of open/closed nodes so it can be restored later. | |||
| @@ -114,7 +114,8 @@ LookAndFeel::LookAndFeel() | |||
| { | |||
| TextButton::buttonColourId, textButtonColour, | |||
| TextButton::buttonOnColourId, 0xff4444ff, | |||
| TextButton::textColourId, 0xff000000, | |||
| TextButton::textColourOnId, 0xff000000, | |||
| TextButton::textColourOffId, 0xff000000, | |||
| ComboBox::buttonColourId, 0xffbbbbff, | |||
| ComboBox::outlineColourId, standardOutlineColour, | |||
| @@ -386,7 +387,8 @@ void LookAndFeel::drawButtonText (Graphics& g, TextButton& button, | |||
| { | |||
| Font font (getFontForTextButton (button)); | |||
| g.setFont (font); | |||
| g.setColour (button.findColour (TextButton::textColourId) | |||
| g.setColour (button.findColour (button.getToggleState() ? TextButton::textColourOnId | |||
| : TextButton::textColourOffId) | |||
| .withMultipliedAlpha (button.isEnabled() ? 1.0f : 0.5f)); | |||
| const int yIndent = jmin (4, button.proportionOfHeight (0.3f)); | |||
| @@ -48,7 +48,7 @@ static const int defaultGranularity = 32; | |||
| //============================================================================== | |||
| Path::Path() throw() | |||
| : ArrayAllocationBase <float> (defaultGranularity), | |||
| : data (defaultGranularity), | |||
| numElements (0), | |||
| pathXMin (0), | |||
| pathXMax (0), | |||
| @@ -63,7 +63,7 @@ Path::~Path() throw() | |||
| } | |||
| Path::Path (const Path& other) throw() | |||
| : ArrayAllocationBase <float> (defaultGranularity), | |||
| : data (defaultGranularity), | |||
| numElements (other.numElements), | |||
| pathXMin (other.pathXMin), | |||
| pathXMax (other.pathXMax), | |||
| @@ -73,8 +73,8 @@ Path::Path (const Path& other) throw() | |||
| { | |||
| if (numElements > 0) | |||
| { | |||
| setAllocatedSize (numElements); | |||
| memcpy (elements, other.elements, numElements * sizeof (float)); | |||
| data.setAllocatedSize (numElements); | |||
| memcpy (data.elements, other.data.elements, numElements * sizeof (float)); | |||
| } | |||
| } | |||
| @@ -82,7 +82,7 @@ const Path& Path::operator= (const Path& other) throw() | |||
| { | |||
| if (this != &other) | |||
| { | |||
| ensureAllocatedSize (other.numElements); | |||
| data.ensureAllocatedSize (other.numElements); | |||
| numElements = other.numElements; | |||
| pathXMin = other.pathXMin; | |||
| @@ -92,7 +92,7 @@ const Path& Path::operator= (const Path& other) throw() | |||
| useNonZeroWinding = other.useNonZeroWinding; | |||
| if (numElements > 0) | |||
| memcpy (elements, other.elements, numElements * sizeof (float)); | |||
| memcpy (data.elements, other.data.elements, numElements * sizeof (float)); | |||
| } | |||
| return *this; | |||
| @@ -109,14 +109,14 @@ void Path::clear() throw() | |||
| void Path::swapWithPath (Path& other) | |||
| { | |||
| swapVariables <int> (this->numAllocated, other.numAllocated); | |||
| swapVariables <float*> (this->elements, other.elements); | |||
| swapVariables <int> (this->numElements, other.numElements); | |||
| swapVariables <float> (this->pathXMin, other.pathXMin); | |||
| swapVariables <float> (this->pathXMax, other.pathXMax); | |||
| swapVariables <float> (this->pathYMin, other.pathYMin); | |||
| swapVariables <float> (this->pathYMax, other.pathYMax); | |||
| swapVariables <bool> (this->useNonZeroWinding, other.useNonZeroWinding); | |||
| swapVariables <int> (data.numAllocated, other.data.numAllocated); | |||
| swapVariables <float*> (data.elements, other.data.elements); | |||
| swapVariables <int> (numElements, other.numElements); | |||
| swapVariables <float> (pathXMin, other.pathXMin); | |||
| swapVariables <float> (pathXMax, other.pathXMax); | |||
| swapVariables <float> (pathYMin, other.pathYMin); | |||
| swapVariables <float> (pathYMax, other.pathYMax); | |||
| swapVariables <bool> (useNonZeroWinding, other.useNonZeroWinding); | |||
| } | |||
| //============================================================================== | |||
| @@ -138,7 +138,7 @@ bool Path::isEmpty() const throw() | |||
| while (i < numElements) | |||
| { | |||
| const float type = elements [i++]; | |||
| const float type = data.elements [i++]; | |||
| if (type == moveMarker) | |||
| { | |||
| @@ -210,11 +210,11 @@ void Path::startNewSubPath (const float x, | |||
| pathYMax = jmax (pathYMax, y); | |||
| } | |||
| ensureAllocatedSize (numElements + 3); | |||
| data.ensureAllocatedSize (numElements + 3); | |||
| elements [numElements++] = moveMarker; | |||
| elements [numElements++] = x; | |||
| elements [numElements++] = y; | |||
| data.elements [numElements++] = moveMarker; | |||
| data.elements [numElements++] = x; | |||
| data.elements [numElements++] = y; | |||
| } | |||
| void Path::lineTo (const float x, const float y) throw() | |||
| @@ -224,11 +224,11 @@ void Path::lineTo (const float x, const float y) throw() | |||
| if (numElements == 0) | |||
| startNewSubPath (0, 0); | |||
| ensureAllocatedSize (numElements + 3); | |||
| data.ensureAllocatedSize (numElements + 3); | |||
| elements [numElements++] = lineMarker; | |||
| elements [numElements++] = x; | |||
| elements [numElements++] = y; | |||
| data.elements [numElements++] = lineMarker; | |||
| data.elements [numElements++] = x; | |||
| data.elements [numElements++] = y; | |||
| pathXMin = jmin (pathXMin, x); | |||
| pathXMax = jmax (pathXMax, x); | |||
| @@ -245,13 +245,13 @@ void Path::quadraticTo (const float x1, const float y1, | |||
| if (numElements == 0) | |||
| startNewSubPath (0, 0); | |||
| ensureAllocatedSize (numElements + 5); | |||
| data.ensureAllocatedSize (numElements + 5); | |||
| elements [numElements++] = quadMarker; | |||
| elements [numElements++] = x1; | |||
| elements [numElements++] = y1; | |||
| elements [numElements++] = x2; | |||
| elements [numElements++] = y2; | |||
| data.elements [numElements++] = quadMarker; | |||
| data.elements [numElements++] = x1; | |||
| data.elements [numElements++] = y1; | |||
| data.elements [numElements++] = x2; | |||
| data.elements [numElements++] = y2; | |||
| pathXMin = jmin (pathXMin, x1, x2); | |||
| pathXMax = jmax (pathXMax, x1, x2); | |||
| @@ -270,15 +270,15 @@ void Path::cubicTo (const float x1, const float y1, | |||
| if (numElements == 0) | |||
| startNewSubPath (0, 0); | |||
| ensureAllocatedSize (numElements + 7); | |||
| data.ensureAllocatedSize (numElements + 7); | |||
| elements [numElements++] = cubicMarker; | |||
| elements [numElements++] = x1; | |||
| elements [numElements++] = y1; | |||
| elements [numElements++] = x2; | |||
| elements [numElements++] = y2; | |||
| elements [numElements++] = x3; | |||
| elements [numElements++] = y3; | |||
| data.elements [numElements++] = cubicMarker; | |||
| data.elements [numElements++] = x1; | |||
| data.elements [numElements++] = y1; | |||
| data.elements [numElements++] = x2; | |||
| data.elements [numElements++] = y2; | |||
| data.elements [numElements++] = x3; | |||
| data.elements [numElements++] = y3; | |||
| pathXMin = jmin (pathXMin, x1, x2, x3); | |||
| pathXMax = jmax (pathXMax, x1, x2, x3); | |||
| @@ -289,10 +289,10 @@ void Path::cubicTo (const float x1, const float y1, | |||
| void Path::closeSubPath() throw() | |||
| { | |||
| if (numElements > 0 | |||
| && elements [numElements - 1] != closeSubPathMarker) | |||
| && data.elements [numElements - 1] != closeSubPathMarker) | |||
| { | |||
| ensureAllocatedSize (numElements + 1); | |||
| elements [numElements++] = closeSubPathMarker; | |||
| data.ensureAllocatedSize (numElements + 1); | |||
| data.elements [numElements++] = closeSubPathMarker; | |||
| } | |||
| } | |||
| @@ -300,11 +300,11 @@ const Point Path::getCurrentPosition() const | |||
| { | |||
| int i = numElements - 1; | |||
| if (i > 0 && elements[i] == closeSubPathMarker) | |||
| if (i > 0 && data.elements[i] == closeSubPathMarker) | |||
| { | |||
| while (i >= 0) | |||
| { | |||
| if (elements[i] == moveMarker) | |||
| if (data.elements[i] == moveMarker) | |||
| { | |||
| i += 2; | |||
| break; | |||
| @@ -315,7 +315,7 @@ const Point Path::getCurrentPosition() const | |||
| } | |||
| if (i > 0) | |||
| return Point (elements [i - 1], elements [i]); | |||
| return Point (data.elements [i - 1], data.elements [i]); | |||
| return Point (0.0f, 0.0f); | |||
| } | |||
| @@ -331,7 +331,7 @@ void Path::addRectangle (const float x, const float y, | |||
| if (h < 0) | |||
| swapVariables (y1, y2); | |||
| ensureAllocatedSize (numElements + 13); | |||
| data.ensureAllocatedSize (numElements + 13); | |||
| if (numElements == 0) | |||
| { | |||
| @@ -348,19 +348,19 @@ void Path::addRectangle (const float x, const float y, | |||
| pathYMax = jmax (pathYMax, y2); | |||
| } | |||
| elements [numElements++] = moveMarker; | |||
| elements [numElements++] = x1; | |||
| elements [numElements++] = y2; | |||
| elements [numElements++] = lineMarker; | |||
| elements [numElements++] = x1; | |||
| elements [numElements++] = y1; | |||
| elements [numElements++] = lineMarker; | |||
| elements [numElements++] = x2; | |||
| elements [numElements++] = y1; | |||
| elements [numElements++] = lineMarker; | |||
| elements [numElements++] = x2; | |||
| elements [numElements++] = y2; | |||
| elements [numElements++] = closeSubPathMarker; | |||
| data.elements [numElements++] = moveMarker; | |||
| data.elements [numElements++] = x1; | |||
| data.elements [numElements++] = y2; | |||
| data.elements [numElements++] = lineMarker; | |||
| data.elements [numElements++] = x1; | |||
| data.elements [numElements++] = y1; | |||
| data.elements [numElements++] = lineMarker; | |||
| data.elements [numElements++] = x2; | |||
| data.elements [numElements++] = y1; | |||
| data.elements [numElements++] = lineMarker; | |||
| data.elements [numElements++] = x2; | |||
| data.elements [numElements++] = y2; | |||
| data.elements [numElements++] = closeSubPathMarker; | |||
| } | |||
| void Path::addRectangle (const Rectangle& rectangle) throw() | |||
| @@ -791,38 +791,38 @@ void Path::addPath (const Path& other) throw() | |||
| while (i < other.numElements) | |||
| { | |||
| const float type = other.elements [i++]; | |||
| const float type = other.data.elements [i++]; | |||
| if (type == moveMarker) | |||
| { | |||
| startNewSubPath (other.elements [i], | |||
| other.elements [i + 1]); | |||
| startNewSubPath (other.data.elements [i], | |||
| other.data.elements [i + 1]); | |||
| i += 2; | |||
| } | |||
| else if (type == lineMarker) | |||
| { | |||
| lineTo (other.elements [i], | |||
| other.elements [i + 1]); | |||
| lineTo (other.data.elements [i], | |||
| other.data.elements [i + 1]); | |||
| i += 2; | |||
| } | |||
| else if (type == quadMarker) | |||
| { | |||
| quadraticTo (other.elements [i], | |||
| other.elements [i + 1], | |||
| other.elements [i + 2], | |||
| other.elements [i + 3]); | |||
| quadraticTo (other.data.elements [i], | |||
| other.data.elements [i + 1], | |||
| other.data.elements [i + 2], | |||
| other.data.elements [i + 3]); | |||
| i += 4; | |||
| } | |||
| else if (type == cubicMarker) | |||
| { | |||
| cubicTo (other.elements [i], | |||
| other.elements [i + 1], | |||
| other.elements [i + 2], | |||
| other.elements [i + 3], | |||
| other.elements [i + 4], | |||
| other.elements [i + 5]); | |||
| cubicTo (other.data.elements [i], | |||
| other.data.elements [i + 1], | |||
| other.data.elements [i + 2], | |||
| other.data.elements [i + 3], | |||
| other.data.elements [i + 4], | |||
| other.data.elements [i + 5]); | |||
| i += 6; | |||
| } | |||
| @@ -845,7 +845,7 @@ void Path::addPath (const Path& other, | |||
| while (i < other.numElements) | |||
| { | |||
| const float type = other.elements [i++]; | |||
| const float type = other.data.elements [i++]; | |||
| if (type == closeSubPathMarker) | |||
| { | |||
| @@ -853,8 +853,8 @@ void Path::addPath (const Path& other, | |||
| } | |||
| else | |||
| { | |||
| float x = other.elements [i++]; | |||
| float y = other.elements [i++]; | |||
| float x = other.data.elements [i++]; | |||
| float y = other.data.elements [i++]; | |||
| transformToApply.transformPoint (x, y); | |||
| if (type == moveMarker) | |||
| @@ -867,18 +867,18 @@ void Path::addPath (const Path& other, | |||
| } | |||
| else if (type == quadMarker) | |||
| { | |||
| float x2 = other.elements [i++]; | |||
| float y2 = other.elements [i++]; | |||
| float x2 = other.data.elements [i++]; | |||
| float y2 = other.data.elements [i++]; | |||
| transformToApply.transformPoint (x2, y2); | |||
| quadraticTo (x, y, x2, y2); | |||
| } | |||
| else if (type == cubicMarker) | |||
| { | |||
| float x2 = other.elements [i++]; | |||
| float y2 = other.elements [i++]; | |||
| float x3 = other.elements [i++]; | |||
| float y3 = other.elements [i++]; | |||
| float x2 = other.data.elements [i++]; | |||
| float y2 = other.data.elements [i++]; | |||
| float x3 = other.data.elements [i++]; | |||
| float y3 = other.data.elements [i++]; | |||
| transformToApply.transformPoint (x2, y2); | |||
| transformToApply.transformPoint (x3, y3); | |||
| @@ -903,24 +903,24 @@ void Path::applyTransform (const AffineTransform& transform) throw() | |||
| while (i < numElements) | |||
| { | |||
| const float type = elements [i++]; | |||
| const float type = data.elements [i++]; | |||
| if (type == moveMarker) | |||
| { | |||
| transform.transformPoint (elements [i], | |||
| elements [i + 1]); | |||
| transform.transformPoint (data.elements [i], | |||
| data.elements [i + 1]); | |||
| if (setMaxMin) | |||
| { | |||
| pathXMin = jmin (pathXMin, elements [i]); | |||
| pathXMax = jmax (pathXMax, elements [i]); | |||
| pathYMin = jmin (pathYMin, elements [i + 1]); | |||
| pathYMax = jmax (pathYMax, elements [i + 1]); | |||
| pathXMin = jmin (pathXMin, data.elements [i]); | |||
| pathXMax = jmax (pathXMax, data.elements [i]); | |||
| pathYMin = jmin (pathYMin, data.elements [i + 1]); | |||
| pathYMax = jmax (pathYMax, data.elements [i + 1]); | |||
| } | |||
| else | |||
| { | |||
| pathXMin = pathXMax = elements [i]; | |||
| pathYMin = pathYMax = elements [i + 1]; | |||
| pathXMin = pathXMax = data.elements [i]; | |||
| pathYMin = pathYMax = data.elements [i + 1]; | |||
| setMaxMin = true; | |||
| } | |||
| @@ -928,46 +928,46 @@ void Path::applyTransform (const AffineTransform& transform) throw() | |||
| } | |||
| else if (type == lineMarker) | |||
| { | |||
| transform.transformPoint (elements [i], | |||
| elements [i + 1]); | |||
| transform.transformPoint (data.elements [i], | |||
| data.elements [i + 1]); | |||
| pathXMin = jmin (pathXMin, elements [i]); | |||
| pathXMax = jmax (pathXMax, elements [i]); | |||
| pathYMin = jmin (pathYMin, elements [i + 1]); | |||
| pathYMax = jmax (pathYMax, elements [i + 1]); | |||
| pathXMin = jmin (pathXMin, data.elements [i]); | |||
| pathXMax = jmax (pathXMax, data.elements [i]); | |||
| pathYMin = jmin (pathYMin, data.elements [i + 1]); | |||
| pathYMax = jmax (pathYMax, data.elements [i + 1]); | |||
| i += 2; | |||
| } | |||
| else if (type == quadMarker) | |||
| { | |||
| transform.transformPoint (elements [i], | |||
| elements [i + 1]); | |||
| transform.transformPoint (data.elements [i], | |||
| data.elements [i + 1]); | |||
| transform.transformPoint (elements [i + 2], | |||
| elements [i + 3]); | |||
| transform.transformPoint (data.elements [i + 2], | |||
| data.elements [i + 3]); | |||
| pathXMin = jmin (pathXMin, elements [i], elements [i + 2]); | |||
| pathXMax = jmax (pathXMax, elements [i], elements [i + 2]); | |||
| pathYMin = jmin (pathYMin, elements [i + 1], elements [i + 3]); | |||
| pathYMax = jmax (pathYMax, elements [i + 1], elements [i + 3]); | |||
| pathXMin = jmin (pathXMin, data.elements [i], data.elements [i + 2]); | |||
| pathXMax = jmax (pathXMax, data.elements [i], data.elements [i + 2]); | |||
| pathYMin = jmin (pathYMin, data.elements [i + 1], data.elements [i + 3]); | |||
| pathYMax = jmax (pathYMax, data.elements [i + 1], data.elements [i + 3]); | |||
| i += 4; | |||
| } | |||
| else if (type == cubicMarker) | |||
| { | |||
| transform.transformPoint (elements [i], | |||
| elements [i + 1]); | |||
| transform.transformPoint (data.elements [i], | |||
| data.elements [i + 1]); | |||
| transform.transformPoint (elements [i + 2], | |||
| elements [i + 3]); | |||
| transform.transformPoint (data.elements [i + 2], | |||
| data.elements [i + 3]); | |||
| transform.transformPoint (elements [i + 4], | |||
| elements [i + 5]); | |||
| transform.transformPoint (data.elements [i + 4], | |||
| data.elements [i + 5]); | |||
| pathXMin = jmin (pathXMin, elements [i], elements [i + 2], elements [i + 4]); | |||
| pathXMax = jmax (pathXMax, elements [i], elements [i + 2], elements [i + 4]); | |||
| pathYMin = jmin (pathYMin, elements [i + 1], elements [i + 3], elements [i + 5]); | |||
| pathYMax = jmax (pathYMax, elements [i + 1], elements [i + 3], elements [i + 5]); | |||
| pathXMin = jmin (pathXMin, data.elements [i], data.elements [i + 2], data.elements [i + 4]); | |||
| pathXMax = jmax (pathXMax, data.elements [i], data.elements [i + 2], data.elements [i + 4]); | |||
| pathYMin = jmin (pathYMin, data.elements [i + 1], data.elements [i + 3], data.elements [i + 5]); | |||
| pathYMax = jmax (pathYMax, data.elements [i + 1], data.elements [i + 3], data.elements [i + 5]); | |||
| i += 6; | |||
| } | |||
| @@ -1098,17 +1098,17 @@ const Path Path::createPathWithRoundedCorners (const float cornerRadius) const t | |||
| while (n < numElements) | |||
| { | |||
| const float type = elements [n++]; | |||
| const float type = data.elements [n++]; | |||
| if (type == moveMarker) | |||
| { | |||
| indexOfPathStart = p.numElements; | |||
| indexOfPathStartThis = n - 1; | |||
| const float x = elements [n++]; | |||
| const float y = elements [n++]; | |||
| const float x = data.elements [n++]; | |||
| const float y = data.elements [n++]; | |||
| p.startNewSubPath (x, y); | |||
| lastWasLine = false; | |||
| firstWasLine = (elements [n] == lineMarker); | |||
| firstWasLine = (data.elements [n] == lineMarker); | |||
| } | |||
| else if (type == lineMarker || type == closeSubPathMarker) | |||
| { | |||
| @@ -1116,28 +1116,28 @@ const Path Path::createPathWithRoundedCorners (const float cornerRadius) const t | |||
| if (type == lineMarker) | |||
| { | |||
| endX = elements [n++]; | |||
| endY = elements [n++]; | |||
| endX = data.elements [n++]; | |||
| endY = data.elements [n++]; | |||
| if (n > 8) | |||
| { | |||
| startX = elements [n - 8]; | |||
| startY = elements [n - 7]; | |||
| joinX = elements [n - 5]; | |||
| joinY = elements [n - 4]; | |||
| startX = data.elements [n - 8]; | |||
| startY = data.elements [n - 7]; | |||
| joinX = data.elements [n - 5]; | |||
| joinY = data.elements [n - 4]; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| endX = elements [indexOfPathStartThis + 1]; | |||
| endY = elements [indexOfPathStartThis + 2]; | |||
| endX = data.elements [indexOfPathStartThis + 1]; | |||
| endY = data.elements [indexOfPathStartThis + 2]; | |||
| if (n > 6) | |||
| { | |||
| startX = elements [n - 6]; | |||
| startY = elements [n - 5]; | |||
| joinX = elements [n - 3]; | |||
| joinY = elements [n - 2]; | |||
| startX = data.elements [n - 6]; | |||
| startY = data.elements [n - 5]; | |||
| joinX = data.elements [n - 3]; | |||
| joinY = data.elements [n - 2]; | |||
| } | |||
| } | |||
| @@ -1150,8 +1150,8 @@ const Path Path::createPathWithRoundedCorners (const float cornerRadius) const t | |||
| { | |||
| const double propNeeded = jmin (0.5, cornerRadius / len1); | |||
| p.elements [p.numElements - 2] = (float) (joinX - (joinX - startX) * propNeeded); | |||
| p.elements [p.numElements - 1] = (float) (joinY - (joinY - startY) * propNeeded); | |||
| p.data.elements [p.numElements - 2] = (float) (joinX - (joinX - startX) * propNeeded); | |||
| p.data.elements [p.numElements - 1] = (float) (joinY - (joinY - startY) * propNeeded); | |||
| } | |||
| const double len2 = juce_hypot (endX - joinX, | |||
| @@ -1178,12 +1178,12 @@ const Path Path::createPathWithRoundedCorners (const float cornerRadius) const t | |||
| { | |||
| if (firstWasLine) | |||
| { | |||
| startX = elements [n - 3]; | |||
| startY = elements [n - 2]; | |||
| startX = data.elements [n - 3]; | |||
| startY = data.elements [n - 2]; | |||
| joinX = endX; | |||
| joinY = endY; | |||
| endX = elements [indexOfPathStartThis + 4]; | |||
| endY = elements [indexOfPathStartThis + 5]; | |||
| endX = data.elements [indexOfPathStartThis + 4]; | |||
| endY = data.elements [indexOfPathStartThis + 5]; | |||
| const double len1 = juce_hypot (startX - joinX, | |||
| startY - joinY); | |||
| @@ -1192,8 +1192,8 @@ const Path Path::createPathWithRoundedCorners (const float cornerRadius) const t | |||
| { | |||
| const double propNeeded = jmin (0.5, cornerRadius / len1); | |||
| p.elements [p.numElements - 2] = (float) (joinX - (joinX - startX) * propNeeded); | |||
| p.elements [p.numElements - 1] = (float) (joinY - (joinY - startY) * propNeeded); | |||
| p.data.elements [p.numElements - 2] = (float) (joinX - (joinX - startX) * propNeeded); | |||
| p.data.elements [p.numElements - 1] = (float) (joinY - (joinY - startY) * propNeeded); | |||
| } | |||
| const double len2 = juce_hypot (endX - joinX, | |||
| @@ -1208,8 +1208,8 @@ const Path Path::createPathWithRoundedCorners (const float cornerRadius) const t | |||
| p.quadraticTo (joinX, joinY, endX, endY); | |||
| p.elements [indexOfPathStart + 1] = endX; | |||
| p.elements [indexOfPathStart + 2] = endY; | |||
| p.data.elements [indexOfPathStart + 1] = endX; | |||
| p.data.elements [indexOfPathStart + 2] = endY; | |||
| } | |||
| } | |||
| @@ -1219,21 +1219,21 @@ const Path Path::createPathWithRoundedCorners (const float cornerRadius) const t | |||
| else if (type == quadMarker) | |||
| { | |||
| lastWasLine = false; | |||
| const float x1 = elements [n++]; | |||
| const float y1 = elements [n++]; | |||
| const float x2 = elements [n++]; | |||
| const float y2 = elements [n++]; | |||
| const float x1 = data.elements [n++]; | |||
| const float y1 = data.elements [n++]; | |||
| const float x2 = data.elements [n++]; | |||
| const float y2 = data.elements [n++]; | |||
| p.quadraticTo (x1, y1, x2, y2); | |||
| } | |||
| else if (type == cubicMarker) | |||
| { | |||
| lastWasLine = false; | |||
| const float x1 = elements [n++]; | |||
| const float y1 = elements [n++]; | |||
| const float x2 = elements [n++]; | |||
| const float y2 = elements [n++]; | |||
| const float x3 = elements [n++]; | |||
| const float y3 = elements [n++]; | |||
| const float x1 = data.elements [n++]; | |||
| const float y1 = data.elements [n++]; | |||
| const float x2 = data.elements [n++]; | |||
| const float y2 = data.elements [n++]; | |||
| const float x3 = data.elements [n++]; | |||
| const float y3 = data.elements [n++]; | |||
| p.cubicTo (x1, y1, x2, y2, x3, y3); | |||
| } | |||
| } | |||
| @@ -1322,37 +1322,37 @@ void Path::writePathToStream (OutputStream& dest) const | |||
| int i = 0; | |||
| while (i < numElements) | |||
| { | |||
| const float type = elements [i++]; | |||
| const float type = data.elements [i++]; | |||
| if (type == moveMarker) | |||
| { | |||
| dest.writeByte ('m'); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| } | |||
| else if (type == lineMarker) | |||
| { | |||
| dest.writeByte ('l'); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| } | |||
| else if (type == quadMarker) | |||
| { | |||
| dest.writeByte ('q'); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| } | |||
| else if (type == cubicMarker) | |||
| { | |||
| dest.writeByte ('b'); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| dest.writeFloat (data.elements [i++]); | |||
| } | |||
| else if (type == closeSubPathMarker) | |||
| { | |||
| @@ -1375,7 +1375,7 @@ const String Path::toString() const | |||
| while (i < numElements) | |||
| { | |||
| const float marker = elements [i++]; | |||
| const float marker = data.elements [i++]; | |||
| tchar markerChar = 0; | |||
| int numCoords = 0; | |||
| @@ -1413,7 +1413,7 @@ const String Path::toString() const | |||
| while (--numCoords >= 0 && i < numElements) | |||
| { | |||
| String n (elements [i++], 3); | |||
| String n (data.elements [i++], 3); | |||
| while (n.endsWithChar (T('0'))) | |||
| n = n.dropLastCharacters (1); | |||
| @@ -1541,7 +1541,7 @@ Path::Iterator::~Iterator() | |||
| bool Path::Iterator::next() | |||
| { | |||
| const float* const elements = path.elements; | |||
| const float* const elements = path.data.elements; | |||
| if (index < path.numElements) | |||
| { | |||
| @@ -69,7 +69,7 @@ class Image; | |||
| @see PathFlatteningIterator, PathStrokeType, Graphics | |||
| */ | |||
| class JUCE_API Path : private ArrayAllocationBase <float> | |||
| class JUCE_API Path | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| @@ -632,6 +632,7 @@ public: | |||
| private: | |||
| friend class PathFlatteningIterator; | |||
| friend class Path::Iterator; | |||
| ArrayAllocationBase <float> data; | |||
| int numElements; | |||
| float pathXMin, pathXMax, pathYMin, pathYMax; | |||
| bool useNonZeroWinding; | |||
| @@ -44,7 +44,7 @@ PathFlatteningIterator::PathFlatteningIterator (const Path& path_, | |||
| subPathIndex (-1), | |||
| path (path_), | |||
| transform (transform_), | |||
| points (path_.elements), | |||
| points (path_.data.elements), | |||
| tolerence (tolerence_ * tolerence_), | |||
| subPathCloseX (0), | |||
| subPathCloseY (0), | |||
| @@ -464,10 +464,20 @@ public: | |||
| return true; | |||
| DWORD playCursor, writeCursor; | |||
| HRESULT hr = pOutputBuffer->GetCurrentPosition (&playCursor, &writeCursor); | |||
| if (hr != S_OK) | |||
| for (;;) | |||
| { | |||
| HRESULT hr = pOutputBuffer->GetCurrentPosition (&playCursor, &writeCursor); | |||
| if (hr == MAKE_HRESULT (1, 0x878, 150)) // DSERR_BUFFERLOST | |||
| { | |||
| pOutputBuffer->Restore(); | |||
| continue; | |||
| } | |||
| if (hr == S_OK) | |||
| break; | |||
| logError (hr); | |||
| jassertfalse | |||
| return true; | |||