Browse Source

tags/2021-05-28
jules 18 years ago
parent
commit
e039eeda07
6 changed files with 67 additions and 5 deletions
  1. +1
    -1
      extras/audio plugins/demo/build/AudioUnit/JuceDemoAU.xcodeproj/project.pbxproj
  2. +1
    -1
      src/juce_appframework/gui/components/buttons/juce_Button.cpp
  3. +5
    -1
      src/juce_core/containers/juce_Array.h
  4. +2
    -0
      src/juce_core/containers/juce_ElementComparator.h
  5. +54
    -2
      src/juce_core/containers/juce_OwnedArray.h
  6. +4
    -0
      src/juce_core/containers/juce_SortedSet.h

+ 1
- 1
extras/audio plugins/demo/build/AudioUnit/JuceDemoAU.xcodeproj/project.pbxproj View File

@@ -80,7 +80,7 @@
84CFB0240909684B0053C22C /* CopyFiles */ = { 84CFB0240909684B0053C22C /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase; isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
dstPath = "/Users/jules/Library/Audio/Plug-Ins/Components";
dstPath = "~/Library/Audio/Plug-Ins/Components";
dstSubfolderSpec = 0; dstSubfolderSpec = 0;
files = ( files = (
84CFB029090968590053C22C /* DemoJuceAudioUnit.component in CopyFiles */, 84CFB029090968590053C22C /* DemoJuceAudioUnit.component in CopyFiles */,


+ 1
- 1
src/juce_appframework/gui/components/buttons/juce_Button.cpp View File

@@ -230,7 +230,7 @@ Button::ButtonState Button::updateState (const MouseEvent* const e) throw()
const bool over = reallyContains (mx, my, true); const bool over = reallyContains (mx, my, true);
const bool down = isMouseButtonDownAnywhere(); const bool down = isMouseButtonDownAnywhere();
if ((down && (over || triggerOnMouseDown)) || isKeyDown)
if ((down && (over || (triggerOnMouseDown && state == buttonDown))) || isKeyDown)
state = buttonDown; state = buttonDown;
else if (over) else if (over)
state = buttonOver; state = buttonOver;


+ 5
- 1
src/juce_core/containers/juce_Array.h View File

@@ -46,6 +46,10 @@
Note that when holding pointers to objects, the array doesn't take any ownership Note that when holding pointers to objects, the array doesn't take any ownership
of the objects - for doing this, see the OwnedArray class or the ReferenceCountedArray class. of the objects - for doing this, see the OwnedArray class or the ReferenceCountedArray class.
If you're using a class or struct as the element type, it must be
capable of being copied or moved with a straightforward memcpy, rather than
needing construction and destruction code.
For holding lists of strings, use the specialised class StringArray. For holding lists of strings, use the specialised class StringArray.
To make all the array's methods thread-safe, pass in "CriticalSection" as the templated To make all the array's methods thread-safe, pass in "CriticalSection" as the templated
@@ -672,7 +676,7 @@ public:
@param comparator the comparator to use to compare the elements - see the sort() @param comparator the comparator to use to compare the elements - see the sort()
method for details about the form this object should take method for details about the form this object should take
@param elementToLookFor the new element to insert to the array
@param elementToLookFor the element to search for
@returns the index of the element, or -1 if it's not found @returns the index of the element, or -1 if it's not found
@see addSorted, sort @see addSorted, sort
*/ */


+ 2
- 0
src/juce_core/containers/juce_ElementComparator.h View File

@@ -183,6 +183,8 @@ static void sortArray (ElementComparator& comparator,
if (--stackIndex < 0) if (--stackIndex < 0)
break; break;
jassert (stackIndex < numElementsInArray (fromStack));
firstElement = fromStack [stackIndex]; firstElement = fromStack [stackIndex];
lastElement = toStack [stackIndex]; lastElement = toStack [stackIndex];
} }


+ 54
- 2
src/juce_core/containers/juce_OwnedArray.h View File

@@ -380,7 +380,7 @@ public:
@param comparator the comparator to use to compare the elements - see the sort method @param comparator the comparator to use to compare the elements - see the sort method
for details about this object's structure for details about this object's structure
@param newObject the new object to insert to the array @param newObject the new object to insert to the array
@see add, sort
@see add, sort, indexOfSorted
*/ */
template <class ElementComparator> template <class ElementComparator>
void addSorted (ElementComparator& comparator, void addSorted (ElementComparator& comparator,
@@ -393,6 +393,58 @@ public:
lock.exit(); lock.exit();
} }
/** Finds the index of an object in the array, assuming that the array is sorted.
This will use a comparator to do a binary-chop to find the index of the given
element, if it exists. If the array isn't sorted, the behaviour of this
method will be unpredictable.
@param comparator the comparator to use to compare the elements - see the sort()
method for details about the form this object should take
@param objectToLookFor the object to search for
@returns the index of the element, or -1 if it's not found
@see addSorted, sort
*/
template <class ElementComparator>
int indexOfSorted (ElementComparator& comparator,
const ObjectClass* const objectToLookFor) const throw()
{
(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();
int start = 0;
int end = numUsed;
for (;;)
{
if (start >= end)
{
lock.exit();
return -1;
}
else if (comparator.compareElements (objectToLookFor, this->elements [start]) == 0)
{
lock.exit();
return start;
}
else
{
const int halfway = (start + end) >> 1;
if (halfway == start)
{
lock.exit();
return -1;
}
else if (comparator.compareElements (objectToLookFor, this->elements [halfway]) >= 0)
start = halfway;
else
end = halfway;
}
}
}
//============================================================================== //==============================================================================
/** Removes an object from the array. /** Removes an object from the array.
@@ -679,7 +731,7 @@ public:
be important in some cases. If it's false, a faster be important in some cases. If it's false, a faster
algorithm is used, but equivalent elements may be algorithm is used, but equivalent elements may be
rearranged. rearranged.
@see sortArray
@see sortArray, indexOfSorted
*/ */
template <class ElementComparator> template <class ElementComparator>
void sort (ElementComparator& comparator, void sort (ElementComparator& comparator,


+ 4
- 0
src/juce_core/containers/juce_SortedSet.h View File

@@ -54,6 +54,10 @@
to determine the order), and searching the set for known values is very fast to determine the order), and searching the set for known values is very fast
because it uses a binary-chop method. because it uses a binary-chop method.
Note that if you're using a class or struct as the element type, it must be
capable of being copied or moved with a straightforward memcpy, rather than
needing construction and destruction code.
To make all the set's methods thread-safe, pass in "CriticalSection" as the templated To make all the set's methods thread-safe, pass in "CriticalSection" as the templated
TypeOfCriticalSectionToUse parameter, instead of the default DummyCriticalSection. TypeOfCriticalSectionToUse parameter, instead of the default DummyCriticalSection.


Loading…
Cancel
Save