| @@ -172,7 +172,7 @@ private: | |||
| for (int i = 10; --i >= 0;) | |||
| { | |||
| 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.fillPath (pp); | |||
| } | |||
| @@ -617,7 +617,7 @@ protected: | |||
| { | |||
| //jassert (midiEventPosition >= 0 && midiEventPosition < (int) numSamples); | |||
| } | |||
| #else | |||
| #elif JUCE_DEBUG || JUCE_LOG_ASSERTIONS | |||
| // if your plugin creates midi messages, you'll need to set | |||
| // the JucePlugin_ProducesMidiOutput macro to 1 in your | |||
| // JucePluginCharacteristics.h file | |||
| @@ -573,7 +573,7 @@ public: | |||
| } | |||
| sendVstEventsToHost (outgoingEvents.events); | |||
| #else | |||
| #elif JUCE_DEBUG | |||
| /* This assertion is caused when you've added some events to the | |||
| midiMessages array in your processBlock() method, which usually means | |||
| that you're trying to send them somewhere. But in this case they're | |||
| @@ -28,7 +28,6 @@ BEGIN_JUCE_NAMESPACE | |||
| //============================================================================== | |||
| KeyPress::KeyPress() noexcept | |||
| : keyCode (0), | |||
| mods (0), | |||
| textCharacter (0) | |||
| { | |||
| } | |||
| @@ -170,6 +169,29 @@ namespace KeyPressHelpers | |||
| 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 | |||
| { | |||
| #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 | |||
| return getTextDescription(); | |||
| #endif | |||
| @@ -25,42 +25,30 @@ | |||
| BEGIN_JUCE_NAMESPACE | |||
| //============================================================================== | |||
| KeyboardFocusTraverser::KeyboardFocusTraverser() | |||
| { | |||
| } | |||
| KeyboardFocusTraverser::~KeyboardFocusTraverser() | |||
| { | |||
| } | |||
| //============================================================================== | |||
| namespace KeyboardFocusHelpers | |||
| { | |||
| // This will sort a set of components, so that they are ordered in terms of | |||
| // 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) | |||
| { | |||
| 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) | |||
| 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* focusContainer = current->getParentComponent(); | |||
| Component* focusContainer = findFocusContainer (current); | |||
| 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) | |||
| { | |||
| jassert (current != nullptr); | |||
| return KeyboardFocusHelpers::getIncrementedComponent (current, 1); | |||
| } | |||
| Component* KeyboardFocusTraverser::getPreviousComponent (Component* current) | |||
| { | |||
| jassert (current != nullptr); | |||
| return KeyboardFocusHelpers::getIncrementedComponent (current, -1); | |||
| } | |||
| @@ -26,6 +26,11 @@ | |||
| BEGIN_JUCE_NAMESPACE | |||
| //============================================================================== | |||
| ModifierKeys::ModifierKeys() noexcept | |||
| : flags (0) | |||
| { | |||
| } | |||
| ModifierKeys::ModifierKeys (const int flags_) noexcept | |||
| : flags (flags_) | |||
| { | |||
| @@ -40,13 +40,16 @@ class JUCE_API ModifierKeys | |||
| { | |||
| public: | |||
| //============================================================================== | |||
| /** Creates a ModifierKeys object with no flags set. */ | |||
| ModifierKeys() noexcept; | |||
| /** Creates a ModifierKeys object from a raw set of flags. | |||
| @param flags to represent the keys that are down | |||
| @see shiftModifier, ctrlModifier, altModifier, leftButtonModifier, | |||
| rightButtonModifier, commandModifier, popupMenuClickModifier | |||
| */ | |||
| ModifierKeys (int flags = 0) noexcept; | |||
| ModifierKeys (int flags) noexcept; | |||
| /** Creates a copy of another object. */ | |||
| ModifierKeys (const ModifierKeys& other) noexcept; | |||
| @@ -45,8 +45,8 @@ MouseEvent::MouseEvent (MouseInputSource& source_, | |||
| source (source_), | |||
| mouseDownPos (mouseDownPos_), | |||
| 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 | |||
| { | |||
| if (otherComponent == nullptr) | |||
| { | |||
| jassertfalse; | |||
| return *this; | |||
| } | |||
| jassert (otherComponent != nullptr); | |||
| return MouseEvent (source, otherComponent->getLocalPoint (eventComponent, getPosition()), | |||
| mods, otherComponent, originalComponent, eventTime, | |||
| otherComponent->getLocalPoint (eventComponent, mouseDownPos), | |||
| mouseDownTime, numberOfClicks, wasMovedSinceMouseDown); | |||
| mouseDownTime, numberOfClicks, wasMovedSinceMouseDown != 0); | |||
| } | |||
| MouseEvent MouseEvent::withNewPosition (const Point<int>& newPosition) const noexcept | |||
| { | |||
| return MouseEvent (source, newPosition, mods, eventComponent, originalComponent, | |||
| eventTime, mouseDownPos, mouseDownTime, | |||
| numberOfClicks, wasMovedSinceMouseDown); | |||
| numberOfClicks, wasMovedSinceMouseDown != 0); | |||
| } | |||
| //============================================================================== | |||
| 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 | |||
| @@ -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 | |||
| @@ -124,12 +124,10 @@ public: | |||
| */ | |||
| Component* const originalComponent; | |||
| /** The time that this mouse-event occurred. | |||
| */ | |||
| /** The time that this mouse-event occurred. */ | |||
| const Time eventTime; | |||
| /** The source device that generated this event. | |||
| */ | |||
| /** The source device that generated this event. */ | |||
| MouseInputSource& source; | |||
| //============================================================================== | |||
| @@ -155,7 +153,7 @@ public: | |||
| @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 | |||
| was the last time the button was pressed. | |||
| @@ -186,7 +184,7 @@ public: | |||
| @see getDistanceFromDragStart | |||
| */ | |||
| const Point<int> getOffsetFromDragStart() const noexcept; | |||
| Point<int> getOffsetFromDragStart() const noexcept; | |||
| /** 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 | |||
| 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. | |||
| @@ -250,7 +248,7 @@ public: | |||
| @see getMouseDownScreenPosition | |||
| */ | |||
| const Point<int> getScreenPosition() const; | |||
| Point<int> getScreenPosition() const; | |||
| /** Returns the x co-ordinate at which the mouse button was last pressed. | |||
| @@ -274,15 +272,16 @@ public: | |||
| @see getScreenPosition | |||
| */ | |||
| const Point<int> getMouseDownScreenPosition() const; | |||
| Point<int> getMouseDownScreenPosition() const; | |||
| //============================================================================== | |||
| /** 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 | |||
| 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. | |||
| 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 Time mouseDownTime; | |||
| const int numberOfClicks; | |||
| const bool wasMovedSinceMouseDown; | |||
| static int doubleClickTimeOutMs; | |||
| const uint8 numberOfClicks, wasMovedSinceMouseDown; | |||
| MouseEvent& operator= (const MouseEvent&); | |||
| }; | |||
| @@ -190,14 +190,10 @@ public: | |||
| const ModifierKeys& modifiers) | |||
| { | |||
| if (isSelected (item)) | |||
| { | |||
| 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. | |||
| @@ -144,8 +144,7 @@ Component* Label::getAttachedComponent() const | |||
| return static_cast<Component*> (ownerComponent); | |||
| } | |||
| void Label::attachToComponent (Component* owner, | |||
| const bool onLeft) | |||
| void Label::attachToComponent (Component* owner, const bool onLeft) | |||
| { | |||
| if (ownerComponent != nullptr) | |||
| 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() | |||
| { | |||
| @@ -210,7 +206,6 @@ void Label::showEditor() | |||
| editor->addListener (this); | |||
| editor->grabKeyboardFocus(); | |||
| editor->setHighlightedRegion (Range<int> (0, textValue.toString().length())); | |||
| editor->addListener (this); | |||
| resized(); | |||
| repaint(); | |||
| @@ -222,14 +217,6 @@ void Label::showEditor() | |||
| } | |||
| } | |||
| void Label::editorShown (TextEditor*) | |||
| { | |||
| } | |||
| void Label::editorAboutToBeHidden (TextEditor*) | |||
| { | |||
| } | |||
| bool Label::updateFromTextEditorContents (TextEditor& ed) | |||
| { | |||
| const String newText (ed.getText()); | |||