Browse Source

Fixed a compile problem in VSTs. Minor clean-ups.

tags/2021-05-28
jules 14 years ago
parent
commit
9b38f91226
11 changed files with 118 additions and 175 deletions
  1. +1
    -1
      extras/JuceDemo/Source/demos/OpenGLDemo.cpp
  2. +1
    -1
      modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp
  3. +1
    -1
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
  4. +30
    -12
      modules/juce_gui_basics/keyboard/juce_KeyPress.cpp
  5. +35
    -39
      modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp
  6. +5
    -0
      modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp
  7. +4
    -1
      modules/juce_gui_basics/keyboard/juce_ModifierKeys.h
  8. +23
    -82
      modules/juce_gui_basics/mouse/juce_MouseEvent.cpp
  9. +10
    -13
      modules/juce_gui_basics/mouse/juce_MouseEvent.h
  10. +3
    -7
      modules/juce_gui_basics/mouse/juce_SelectedItemSet.h
  11. +5
    -18
      modules/juce_gui_basics/widgets/juce_Label.cpp

+ 1
- 1
extras/JuceDemo/Source/demos/OpenGLDemo.cpp View File

@@ -172,7 +172,7 @@ private:
for (int i = 10; --i >= 0;) for (int i = 10; --i >= 0;)
{ {
Path pp; Path pp;
pp.addStar (Point<float> (r.nextFloat() * w, r.nextFloat() * h, r.nextFloat() * 8 + 3, 10.0f, 20.0f, 0.0f);
pp.addStar (Point<float> (r.nextFloat() * w, r.nextFloat() * h), r.nextFloat() * 8 + 3, 10.0f, 20.0f, 0.0f);
g.setColour (Colours::pink.withAlpha (0.4f)); g.setColour (Colours::pink.withAlpha (0.4f));
g.fillPath (pp); g.fillPath (pp);
} }


+ 1
- 1
modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp View File

@@ -617,7 +617,7 @@ protected:
{ {
//jassert (midiEventPosition >= 0 && midiEventPosition < (int) numSamples); //jassert (midiEventPosition >= 0 && midiEventPosition < (int) numSamples);
} }
#else
#elif JUCE_DEBUG || JUCE_LOG_ASSERTIONS
// if your plugin creates midi messages, you'll need to set // if your plugin creates midi messages, you'll need to set
// the JucePlugin_ProducesMidiOutput macro to 1 in your // the JucePlugin_ProducesMidiOutput macro to 1 in your
// JucePluginCharacteristics.h file // JucePluginCharacteristics.h file


+ 1
- 1
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -573,7 +573,7 @@ public:
} }
sendVstEventsToHost (outgoingEvents.events); sendVstEventsToHost (outgoingEvents.events);
#else
#elif JUCE_DEBUG
/* This assertion is caused when you've added some events to the /* This assertion is caused when you've added some events to the
midiMessages array in your processBlock() method, which usually means midiMessages array in your processBlock() method, which usually means
that you're trying to send them somewhere. But in this case they're that you're trying to send them somewhere. But in this case they're


+ 30
- 12
modules/juce_gui_basics/keyboard/juce_KeyPress.cpp View File

@@ -28,7 +28,6 @@ BEGIN_JUCE_NAMESPACE
//============================================================================== //==============================================================================
KeyPress::KeyPress() noexcept KeyPress::KeyPress() noexcept
: keyCode (0), : keyCode (0),
mods (0),
textCharacter (0) textCharacter (0)
{ {
} }
@@ -170,6 +169,29 @@ namespace KeyPressHelpers
return 0; return 0;
} }
#if JUCE_MAC
struct OSXSymbolReplacement
{
const char* text;
juce_wchar symbol;
};
const OSXSymbolReplacement osxSymbols[] =
{
{ "shift + ", 0x21e7 },
{ "command + ", 0x2318 },
{ "option + ", 0x2325 },
{ "ctrl + ", 0x2303 },
{ "return", 0x23ce },
{ "cursor left", 0x2190 },
{ "cursor right", 0x2192 },
{ "cursor up", 0x2191 },
{ "cursor down", 0x2193 },
{ "backspace", 0x232b },
{ "delete", 0x2326 }
};
#endif
} }
//============================================================================== //==============================================================================
@@ -273,17 +295,13 @@ String KeyPress::getTextDescription() const
String KeyPress::getTextDescriptionWithIcons() const String KeyPress::getTextDescriptionWithIcons() const
{ {
#if JUCE_MAC #if JUCE_MAC
return getTextDescription().replace ("shift + ", String::charToString (0x21e7))
.replace ("command + ", String::charToString (0x2318))
.replace ("option + ", String::charToString (0x2325))
.replace ("ctrl + ", String::charToString (0x2303))
.replace ("return", String::charToString (0x23ce))
.replace ("cursor left", String::charToString (0x2190))
.replace ("cursor right", String::charToString (0x2192))
.replace ("cursor up", String::charToString (0x2191))
.replace ("cursor down", String::charToString (0x2193))
.replace ("backspace", String::charToString (0x232b))
.replace ("delete", String::charToString (0x2326));
String s (getTextDescription());
for (int i = 0; i < numElementsInArray (KeyPressHelpers::osxSymbols); ++i)
s = s.replace (KeyPressHelpers::osxSymbols[i].text,
String::charToString (KeyPressHelpers::osxSymbols[i].symbol));
return s;
#else #else
return getTextDescription(); return getTextDescription();
#endif #endif


+ 35
- 39
modules/juce_gui_basics/keyboard/juce_KeyboardFocusTraverser.cpp View File

@@ -25,42 +25,30 @@
BEGIN_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE
//==============================================================================
KeyboardFocusTraverser::KeyboardFocusTraverser()
{
}
KeyboardFocusTraverser::~KeyboardFocusTraverser()
{
}
//==============================================================================
namespace KeyboardFocusHelpers namespace KeyboardFocusHelpers
{ {
// This will sort a set of components, so that they are ordered in terms of // This will sort a set of components, so that they are ordered in terms of
// left-to-right and then top-to-bottom. // left-to-right and then top-to-bottom.
class ScreenPositionComparator
struct ScreenPositionComparator
{ {
public:
ScreenPositionComparator() {}
static int compareElements (const Component* const first, const Component* const second) static int compareElements (const Component* const first, const Component* const second)
{ {
int explicitOrder1 = first->getExplicitFocusOrder();
if (explicitOrder1 <= 0)
explicitOrder1 = std::numeric_limits<int>::max() / 2;
int explicitOrder2 = second->getExplicitFocusOrder();
if (explicitOrder2 <= 0)
explicitOrder2 = std::numeric_limits<int>::max() / 2;
const int explicitOrder1 = getOrder (first);
const int explicitOrder2 = getOrder (second);
if (explicitOrder1 != explicitOrder2) if (explicitOrder1 != explicitOrder2)
return explicitOrder1 - explicitOrder2; return explicitOrder1 - explicitOrder2;
const int diff = first->getY() - second->getY();
const int yDiff = first->getY() - second->getY();
return (diff == 0) ? first->getX() - second->getX()
: diff;
return yDiff == 0 ? first->getX() - second->getX()
: yDiff;
}
static int getOrder (const Component* const c)
{
const int order = c->getExplicitFocusOrder();
return order > 0 ? order : (std::numeric_limits<int>::max() / 2);
} }
}; };
@@ -92,29 +80,31 @@ namespace KeyboardFocusHelpers
} }
} }
} }
}
namespace KeyboardFocusHelpers
{
Component* findFocusContainer (Component* c)
{
c = c->getParentComponent();
if (c != nullptr)
while (c->getParentComponent() != nullptr && ! c->isFocusContainer())
c = c->getParentComponent();
return c;
}
Component* getIncrementedComponent (Component* const current, const int delta) Component* getIncrementedComponent (Component* const current, const int delta)
{ {
Component* focusContainer = current->getParentComponent();
Component* focusContainer = findFocusContainer (current);
if (focusContainer != nullptr) if (focusContainer != nullptr)
{ {
while (focusContainer->getParentComponent() != nullptr && ! focusContainer->isFocusContainer())
focusContainer = focusContainer->getParentComponent();
Array <Component*> comps;
KeyboardFocusHelpers::findAllFocusableComponents (focusContainer, comps);
if (focusContainer != nullptr)
if (comps.size() > 0)
{ {
Array <Component*> comps;
KeyboardFocusHelpers::findAllFocusableComponents (focusContainer, comps);
if (comps.size() > 0)
{
const int index = comps.indexOf (current);
return comps [(index + comps.size() + delta) % comps.size()];
}
const int index = comps.indexOf (current);
return comps [(index + comps.size() + delta) % comps.size()];
} }
} }
@@ -122,13 +112,19 @@ namespace KeyboardFocusHelpers
} }
} }
//==============================================================================
KeyboardFocusTraverser::KeyboardFocusTraverser() {}
KeyboardFocusTraverser::~KeyboardFocusTraverser() {}
Component* KeyboardFocusTraverser::getNextComponent (Component* current) Component* KeyboardFocusTraverser::getNextComponent (Component* current)
{ {
jassert (current != nullptr);
return KeyboardFocusHelpers::getIncrementedComponent (current, 1); return KeyboardFocusHelpers::getIncrementedComponent (current, 1);
} }
Component* KeyboardFocusTraverser::getPreviousComponent (Component* current) Component* KeyboardFocusTraverser::getPreviousComponent (Component* current)
{ {
jassert (current != nullptr);
return KeyboardFocusHelpers::getIncrementedComponent (current, -1); return KeyboardFocusHelpers::getIncrementedComponent (current, -1);
} }


+ 5
- 0
modules/juce_gui_basics/keyboard/juce_ModifierKeys.cpp View File

@@ -26,6 +26,11 @@
BEGIN_JUCE_NAMESPACE BEGIN_JUCE_NAMESPACE
//============================================================================== //==============================================================================
ModifierKeys::ModifierKeys() noexcept
: flags (0)
{
}
ModifierKeys::ModifierKeys (const int flags_) noexcept ModifierKeys::ModifierKeys (const int flags_) noexcept
: flags (flags_) : flags (flags_)
{ {


+ 4
- 1
modules/juce_gui_basics/keyboard/juce_ModifierKeys.h View File

@@ -40,13 +40,16 @@ class JUCE_API ModifierKeys
{ {
public: public:
//============================================================================== //==============================================================================
/** Creates a ModifierKeys object with no flags set. */
ModifierKeys() noexcept;
/** Creates a ModifierKeys object from a raw set of flags. /** Creates a ModifierKeys object from a raw set of flags.
@param flags to represent the keys that are down @param flags to represent the keys that are down
@see shiftModifier, ctrlModifier, altModifier, leftButtonModifier, @see shiftModifier, ctrlModifier, altModifier, leftButtonModifier,
rightButtonModifier, commandModifier, popupMenuClickModifier rightButtonModifier, commandModifier, popupMenuClickModifier
*/ */
ModifierKeys (int flags = 0) noexcept;
ModifierKeys (int flags) noexcept;
/** Creates a copy of another object. */ /** Creates a copy of another object. */
ModifierKeys (const ModifierKeys& other) noexcept; ModifierKeys (const ModifierKeys& other) noexcept;


+ 23
- 82
modules/juce_gui_basics/mouse/juce_MouseEvent.cpp View File

@@ -45,8 +45,8 @@ MouseEvent::MouseEvent (MouseInputSource& source_,
source (source_), source (source_),
mouseDownPos (mouseDownPos_), mouseDownPos (mouseDownPos_),
mouseDownTime (mouseDownTime_), mouseDownTime (mouseDownTime_),
numberOfClicks (numberOfClicks_),
wasMovedSinceMouseDown (mouseWasDragged)
numberOfClicks ((uint8) numberOfClicks_),
wasMovedSinceMouseDown ((uint8) (mouseWasDragged ? 1 : 0))
{ {
} }
@@ -57,64 +57,25 @@ MouseEvent::~MouseEvent() noexcept
//============================================================================== //==============================================================================
MouseEvent MouseEvent::getEventRelativeTo (Component* const otherComponent) const noexcept MouseEvent MouseEvent::getEventRelativeTo (Component* const otherComponent) const noexcept
{ {
if (otherComponent == nullptr)
{
jassertfalse;
return *this;
}
jassert (otherComponent != nullptr);
return MouseEvent (source, otherComponent->getLocalPoint (eventComponent, getPosition()), return MouseEvent (source, otherComponent->getLocalPoint (eventComponent, getPosition()),
mods, otherComponent, originalComponent, eventTime, mods, otherComponent, originalComponent, eventTime,
otherComponent->getLocalPoint (eventComponent, mouseDownPos), otherComponent->getLocalPoint (eventComponent, mouseDownPos),
mouseDownTime, numberOfClicks, wasMovedSinceMouseDown);
mouseDownTime, numberOfClicks, wasMovedSinceMouseDown != 0);
} }
MouseEvent MouseEvent::withNewPosition (const Point<int>& newPosition) const noexcept MouseEvent MouseEvent::withNewPosition (const Point<int>& newPosition) const noexcept
{ {
return MouseEvent (source, newPosition, mods, eventComponent, originalComponent, return MouseEvent (source, newPosition, mods, eventComponent, originalComponent,
eventTime, mouseDownPos, mouseDownTime, eventTime, mouseDownPos, mouseDownTime,
numberOfClicks, wasMovedSinceMouseDown);
numberOfClicks, wasMovedSinceMouseDown != 0);
} }
//============================================================================== //==============================================================================
bool MouseEvent::mouseWasClicked() const noexcept bool MouseEvent::mouseWasClicked() const noexcept
{ {
return ! wasMovedSinceMouseDown;
}
int MouseEvent::getMouseDownX() const noexcept
{
return mouseDownPos.getX();
}
int MouseEvent::getMouseDownY() const noexcept
{
return mouseDownPos.getY();
}
const Point<int> MouseEvent::getMouseDownPosition() const noexcept
{
return mouseDownPos;
}
int MouseEvent::getDistanceFromDragStartX() const noexcept
{
return x - mouseDownPos.getX();
}
int MouseEvent::getDistanceFromDragStartY() const noexcept
{
return y - mouseDownPos.getY();
}
int MouseEvent::getDistanceFromDragStart() const noexcept
{
return mouseDownPos.getDistanceFrom (getPosition());
}
const Point<int> MouseEvent::getOffsetFromDragStart() const noexcept
{
return getPosition() - mouseDownPos;
return wasMovedSinceMouseDown == 0;
} }
int MouseEvent::getLengthOfMousePress() const noexcept int MouseEvent::getLengthOfMousePress() const noexcept
@@ -126,52 +87,32 @@ int MouseEvent::getLengthOfMousePress() const noexcept
} }
//============================================================================== //==============================================================================
const Point<int> MouseEvent::getPosition() const noexcept
{
return Point<int> (x, y);
}
Point<int> MouseEvent::getPosition() const noexcept { return Point<int> (x, y); }
Point<int> MouseEvent::getScreenPosition() const { return eventComponent->localPointToGlobal (getPosition()); }
int MouseEvent::getScreenX() const
{
return getScreenPosition().getX();
}
Point<int> MouseEvent::getMouseDownPosition() const noexcept { return mouseDownPos; }
Point<int> MouseEvent::getMouseDownScreenPosition() const { return eventComponent->localPointToGlobal (mouseDownPos); }
int MouseEvent::getScreenY() const
{
return getScreenPosition().getY();
}
Point<int> MouseEvent::getOffsetFromDragStart() const noexcept { return getPosition() - mouseDownPos; }
int MouseEvent::getDistanceFromDragStart() const noexcept { return mouseDownPos.getDistanceFrom (getPosition()); }
const Point<int> MouseEvent::getScreenPosition() const
{
return eventComponent->localPointToGlobal (Point<int> (x, y));
}
int MouseEvent::getMouseDownX() const noexcept { return mouseDownPos.getX(); }
int MouseEvent::getMouseDownY() const noexcept { return mouseDownPos.getY(); }
int MouseEvent::getMouseDownScreenX() const
{
return getMouseDownScreenPosition().getX();
}
int MouseEvent::getDistanceFromDragStartX() const noexcept { return x - mouseDownPos.getX(); }
int MouseEvent::getDistanceFromDragStartY() const noexcept { return y - mouseDownPos.getY(); }
int MouseEvent::getMouseDownScreenY() const
{
return getMouseDownScreenPosition().getY();
}
int MouseEvent::getScreenX() const { return getScreenPosition().getX(); }
int MouseEvent::getScreenY() const { return getScreenPosition().getY(); }
const Point<int> MouseEvent::getMouseDownScreenPosition() const
{
return eventComponent->localPointToGlobal (mouseDownPos);
}
int MouseEvent::getMouseDownScreenX() const { return getMouseDownScreenPosition().getX(); }
int MouseEvent::getMouseDownScreenY() const { return getMouseDownScreenPosition().getY(); }
//============================================================================== //==============================================================================
int MouseEvent::doubleClickTimeOutMs = 400;
static int doubleClickTimeOutMs = 400;
void MouseEvent::setDoubleClickTimeout (const int newTime) noexcept
{
doubleClickTimeOutMs = newTime;
}
int MouseEvent::getDoubleClickTimeout() noexcept { return doubleClickTimeOutMs; }
void MouseEvent::setDoubleClickTimeout (const int newTime) noexcept { doubleClickTimeOutMs = newTime; }
int MouseEvent::getDoubleClickTimeout() noexcept
{
return doubleClickTimeOutMs;
}
END_JUCE_NAMESPACE END_JUCE_NAMESPACE

+ 10
- 13
modules/juce_gui_basics/mouse/juce_MouseEvent.h View File

@@ -124,12 +124,10 @@ public:
*/ */
Component* const originalComponent; Component* const originalComponent;
/** The time that this mouse-event occurred.
*/
/** The time that this mouse-event occurred. */
const Time eventTime; const Time eventTime;
/** The source device that generated this event.
*/
/** The source device that generated this event. */
MouseInputSource& source; MouseInputSource& source;
//============================================================================== //==============================================================================
@@ -155,7 +153,7 @@ public:
@see getDistanceFromDragStart, getDistanceFromDragStartX, mouseWasClicked @see getDistanceFromDragStart, getDistanceFromDragStartX, mouseWasClicked
*/ */
const Point<int> getMouseDownPosition() const noexcept;
Point<int> getMouseDownPosition() const noexcept;
/** Returns the straight-line distance between where the mouse is now and where it /** Returns the straight-line distance between where the mouse is now and where it
was the last time the button was pressed. was the last time the button was pressed.
@@ -186,7 +184,7 @@ public:
@see getDistanceFromDragStart @see getDistanceFromDragStart
*/ */
const Point<int> getOffsetFromDragStart() const noexcept;
Point<int> getOffsetFromDragStart() const noexcept;
/** Returns true if the mouse has just been clicked. /** Returns true if the mouse has just been clicked.
@@ -226,7 +224,7 @@ public:
This position is relative to the top-left of the component to which the This position is relative to the top-left of the component to which the
event applies (as indicated by the MouseEvent::eventComponent field). event applies (as indicated by the MouseEvent::eventComponent field).
*/ */
const Point<int> getPosition() const noexcept;
Point<int> getPosition() const noexcept;
/** Returns the mouse x position of this event, in global screen co-ordinates. /** Returns the mouse x position of this event, in global screen co-ordinates.
@@ -250,7 +248,7 @@ public:
@see getMouseDownScreenPosition @see getMouseDownScreenPosition
*/ */
const Point<int> getScreenPosition() const;
Point<int> getScreenPosition() const;
/** Returns the x co-ordinate at which the mouse button was last pressed. /** Returns the x co-ordinate at which the mouse button was last pressed.
@@ -274,15 +272,16 @@ public:
@see getScreenPosition @see getScreenPosition
*/ */
const Point<int> getMouseDownScreenPosition() const;
Point<int> getMouseDownScreenPosition() const;
//============================================================================== //==============================================================================
/** Creates a version of this event that is relative to a different component. /** Creates a version of this event that is relative to a different component.
The x and y positions of the event that is returned will have been The x and y positions of the event that is returned will have been
adjusted to be relative to the new component. adjusted to be relative to the new component.
The component pointer that is passed-in must not be null.
*/ */
MouseEvent getEventRelativeTo (Component* otherComponent) const noexcept;
MouseEvent getEventRelativeTo (Component* newComponent) const noexcept;
/** Creates a copy of this event with a different position. /** Creates a copy of this event with a different position.
All other members of the event object are the same, but the x and y are All other members of the event object are the same, but the x and y are
@@ -314,9 +313,7 @@ private:
//============================================================================== //==============================================================================
const Point<int> mouseDownPos; const Point<int> mouseDownPos;
const Time mouseDownTime; const Time mouseDownTime;
const int numberOfClicks;
const bool wasMovedSinceMouseDown;
static int doubleClickTimeOutMs;
const uint8 numberOfClicks, wasMovedSinceMouseDown;
MouseEvent& operator= (const MouseEvent&); MouseEvent& operator= (const MouseEvent&);
}; };


+ 3
- 7
modules/juce_gui_basics/mouse/juce_SelectedItemSet.h View File

@@ -190,14 +190,10 @@ public:
const ModifierKeys& modifiers) const ModifierKeys& modifiers)
{ {
if (isSelected (item)) if (isSelected (item))
{
return ! modifiers.isPopupMenu(); return ! modifiers.isPopupMenu();
}
else
{
addToSelectionBasedOnModifiers (item, modifiers);
return false;
}
addToSelectionBasedOnModifiers (item, modifiers);
return false;
} }
/** Selects or deselects items that can also be dragged, based on a mouse-up event. /** Selects or deselects items that can also be dragged, based on a mouse-up event.


+ 5
- 18
modules/juce_gui_basics/widgets/juce_Label.cpp View File

@@ -144,8 +144,7 @@ Component* Label::getAttachedComponent() const
return static_cast<Component*> (ownerComponent); return static_cast<Component*> (ownerComponent);
} }
void Label::attachToComponent (Component* owner,
const bool onLeft)
void Label::attachToComponent (Component* owner, const bool onLeft)
{ {
if (ownerComponent != nullptr) if (ownerComponent != nullptr)
ownerComponent->removeComponentListener (this); ownerComponent->removeComponentListener (this);
@@ -193,13 +192,10 @@ void Label::componentVisibilityChanged (Component& component)
} }
//============================================================================== //==============================================================================
void Label::textWasEdited()
{
}
void Label::textWasChanged()
{
}
void Label::textWasEdited() {}
void Label::textWasChanged() {}
void Label::editorShown (TextEditor*) {}
void Label::editorAboutToBeHidden (TextEditor*) {}
void Label::showEditor() void Label::showEditor()
{ {
@@ -210,7 +206,6 @@ void Label::showEditor()
editor->addListener (this); editor->addListener (this);
editor->grabKeyboardFocus(); editor->grabKeyboardFocus();
editor->setHighlightedRegion (Range<int> (0, textValue.toString().length())); editor->setHighlightedRegion (Range<int> (0, textValue.toString().length()));
editor->addListener (this);
resized(); resized();
repaint(); repaint();
@@ -222,14 +217,6 @@ void Label::showEditor()
} }
} }
void Label::editorShown (TextEditor*)
{
}
void Label::editorAboutToBeHidden (TextEditor*)
{
}
bool Label::updateFromTextEditorContents (TextEditor& ed) bool Label::updateFromTextEditorContents (TextEditor& ed)
{ {
const String newText (ed.getText()); const String newText (ed.getText());


Loading…
Cancel
Save