@@ -365,7 +365,7 @@ public: | |||
void updateSampleRates() | |||
{ | |||
// find a list of sample rates.. | |||
const int possibleSampleRates[] = { 44100, 48000, 88200, 96000, 176400, 192000 }; | |||
const int possibleSampleRates[] = { 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 }; | |||
Array<double> newRates; | |||
if (asioObject != nullptr) | |||
@@ -1449,6 +1449,8 @@ public: | |||
~VST3PluginWindow() | |||
{ | |||
warnOnFailure (view->removed()); | |||
warnOnFailure (view->setFrame (nullptr)); | |||
getAudioProcessor()->editorBeingDeleted (this); | |||
#if JUCE_MAC | |||
@@ -259,15 +259,15 @@ struct PluginSorter | |||
switch (method) | |||
{ | |||
case KnownPluginList::sortByCategory: diff = first->category.compareLexicographically (second->category); break; | |||
case KnownPluginList::sortByManufacturer: diff = first->manufacturerName.compareLexicographically (second->manufacturerName); break; | |||
case KnownPluginList::sortByCategory: diff = first->category.compareNatural (second->category); break; | |||
case KnownPluginList::sortByManufacturer: diff = first->manufacturerName.compareNatural (second->manufacturerName); break; | |||
case KnownPluginList::sortByFormat: diff = first->pluginFormatName.compare (second->pluginFormatName); break; | |||
case KnownPluginList::sortByFileSystemLocation: diff = lastPathPart (first->fileOrIdentifier).compare (lastPathPart (second->fileOrIdentifier)); break; | |||
default: break; | |||
} | |||
if (diff == 0) | |||
diff = first->name.compareLexicographically (second->name); | |||
diff = first->name.compareNatural (second->name); | |||
return diff * direction; | |||
} | |||
@@ -364,6 +364,11 @@ inline int roundToInt (const FloatType value) noexcept | |||
#endif | |||
} | |||
inline int roundToInt (int value) noexcept | |||
{ | |||
return value; | |||
} | |||
#if JUCE_MSVC | |||
#ifndef __INTEL_COMPILER | |||
#pragma float_control (pop) | |||
@@ -271,26 +271,33 @@ public: | |||
JNIEnv* attach() noexcept | |||
{ | |||
if (JNIEnv* env = attachToCurrentThread()) | |||
if (android.activity != nullptr) | |||
{ | |||
SpinLock::ScopedLockType sl (addRemoveLock); | |||
return addEnv (env); | |||
if (JNIEnv* env = attachToCurrentThread()) | |||
{ | |||
SpinLock::ScopedLockType sl (addRemoveLock); | |||
return addEnv (env); | |||
} | |||
jassertfalse; | |||
} | |||
jassertfalse; | |||
return nullptr; | |||
} | |||
void detach() noexcept | |||
{ | |||
jvm->DetachCurrentThread(); | |||
if (android.activity != nullptr) | |||
{ | |||
jvm->DetachCurrentThread(); | |||
const pthread_t thisThread = pthread_self(); | |||
const pthread_t thisThread = pthread_self(); | |||
SpinLock::ScopedLockType sl (addRemoveLock); | |||
for (int i = 0; i < maxThreads; ++i) | |||
if (threads[i] == thisThread) | |||
threads[i] = 0; | |||
SpinLock::ScopedLockType sl (addRemoveLock); | |||
for (int i = 0; i < maxThreads; ++i) | |||
if (threads[i] == thisThread) | |||
threads[i] = 0; | |||
} | |||
} | |||
JNIEnv* getOrAttach() noexcept | |||
@@ -1035,7 +1035,7 @@ public: | |||
Array<char*> argv; | |||
for (int i = 0; i < arguments.size(); ++i) | |||
if (arguments[i].isNotEmpty()) | |||
argv.add (arguments[i].toUTF8().getAddress()); | |||
argv.add (const_cast<char*> (arguments[i].toUTF8().getAddress())); | |||
argv.add (nullptr); | |||
@@ -36,7 +36,7 @@ | |||
*/ | |||
#define JUCE_MAJOR_VERSION 3 | |||
#define JUCE_MINOR_VERSION 0 | |||
#define JUCE_BUILDNUMBER 5 | |||
#define JUCE_BUILDNUMBER 6 | |||
/** Current Juce version number. | |||
@@ -221,8 +221,8 @@ private: | |||
static inline StringHolder* bufferFromText (const CharPointerType text) noexcept | |||
{ | |||
// (Can't use offsetof() here because of warnings about this not being a POD) | |||
return reinterpret_cast <StringHolder*> (reinterpret_cast <char*> (text.getAddress()) | |||
- (reinterpret_cast <size_t> (reinterpret_cast <StringHolder*> (1)->text) - 1)); | |||
return reinterpret_cast<StringHolder*> (reinterpret_cast<char*> (text.getAddress()) | |||
- (reinterpret_cast<size_t> (reinterpret_cast<StringHolder*> (1)->text) - 1)); | |||
} | |||
void compileTimeChecks() | |||
@@ -618,19 +618,98 @@ int String::compare (const char* const other) const noexcept { return text | |||
int String::compare (const wchar_t* const other) const noexcept { return text.compare (castToCharPointer_wchar_t (other)); } | |||
int String::compareIgnoreCase (const String& other) const noexcept { return (text == other.text) ? 0 : text.compareIgnoreCase (other.text); } | |||
int String::compareLexicographically (const String& other) const noexcept | |||
static int stringCompareRight (String::CharPointerType s1, String::CharPointerType s2) noexcept | |||
{ | |||
CharPointerType s1 (text); | |||
for (int bias = 0;;) | |||
{ | |||
const juce_wchar c1 = s1.getAndAdvance(); | |||
const bool isDigit1 = CharacterFunctions::isDigit (c1); | |||
const juce_wchar c2 = s2.getAndAdvance(); | |||
const bool isDigit2 = CharacterFunctions::isDigit (c2); | |||
if (! (isDigit1 || isDigit2)) return bias; | |||
if (! isDigit1) return -1; | |||
if (! isDigit2) return 1; | |||
if (c1 != c2 && bias == 0) | |||
bias = c1 < c2 ? -1 : 1; | |||
jassert (c1 != 0 && c2 != 0); | |||
} | |||
} | |||
while (! (s1.isEmpty() || s1.isLetterOrDigit())) | |||
++s1; | |||
static int stringCompareLeft (String::CharPointerType s1, String::CharPointerType s2) noexcept | |||
{ | |||
for (;;) | |||
{ | |||
const juce_wchar c1 = s1.getAndAdvance(); | |||
const bool isDigit1 = CharacterFunctions::isDigit (c1); | |||
const juce_wchar c2 = s2.getAndAdvance(); | |||
const bool isDigit2 = CharacterFunctions::isDigit (c2); | |||
if (! (isDigit1 || isDigit2)) return 0; | |||
if (! isDigit1) return -1; | |||
if (! isDigit2) return 1; | |||
if (c1 < c2) return -1; | |||
if (c1 > c2) return 1; | |||
} | |||
} | |||
static int naturalStringCompare (String::CharPointerType s1, String::CharPointerType s2) noexcept | |||
{ | |||
bool firstLoop = true; | |||
for (;;) | |||
{ | |||
const bool hasSpace1 = s1.isWhitespace(); | |||
const bool hasSpace2 = s2.isWhitespace(); | |||
CharPointerType s2 (other.text); | |||
if ((! firstLoop) && (hasSpace1 ^ hasSpace2)) | |||
return hasSpace2 ? 1 : -1; | |||
while (! (s2.isEmpty() || s2.isLetterOrDigit())) | |||
++s2; | |||
firstLoop = false; | |||
return s1.compareIgnoreCase (s2); | |||
if (hasSpace1) s1 = s1.findEndOfWhitespace(); | |||
if (hasSpace2) s2 = s2.findEndOfWhitespace(); | |||
if (s1.isDigit() && s2.isDigit()) | |||
{ | |||
const int result = (*s1 == '0' || *s2 == '0') ? stringCompareLeft (s1, s2) | |||
: stringCompareRight (s1, s2); | |||
if (result != 0) | |||
return result; | |||
} | |||
const juce_wchar c1 = s1.getAndAdvance(); | |||
const juce_wchar c2 = s2.getAndAdvance(); | |||
if (c1 == c2 || CharacterFunctions::toUpperCase (c1) | |||
== CharacterFunctions::toUpperCase (c2)) | |||
{ | |||
if (c1 == 0) | |||
return 0; | |||
} | |||
else | |||
{ | |||
const bool isAlphaNum1 = CharacterFunctions::isLetterOrDigit (c1); | |||
const bool isAlphaNum2 = CharacterFunctions::isLetterOrDigit (c2); | |||
if (isAlphaNum2 && ! isAlphaNum1) return -1; | |||
if (isAlphaNum1 && ! isAlphaNum2) return 1; | |||
return c1 < c2 ? -1 : 1; | |||
} | |||
jassert (c1 != 0 && c2 != 0); | |||
} | |||
} | |||
int String::compareNatural (StringRef other) const noexcept | |||
{ | |||
return naturalStringCompare (getCharPointer(), other.text); | |||
} | |||
//============================================================================== | |||
@@ -1760,13 +1839,13 @@ String String::formatted (const String pf, ... ) | |||
va_start (args, pf); | |||
#if JUCE_WINDOWS | |||
HeapBlock <wchar_t> temp (bufferSize); | |||
HeapBlock<wchar_t> temp (bufferSize); | |||
const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, pf.toWideCharPointer(), args); | |||
#elif JUCE_ANDROID | |||
HeapBlock <char> temp (bufferSize); | |||
HeapBlock<char> temp (bufferSize); | |||
const int num = (int) vsnprintf (temp.getData(), bufferSize - 1, pf.toUTF8(), args); | |||
#else | |||
HeapBlock <wchar_t> temp (bufferSize); | |||
HeapBlock<wchar_t> temp (bufferSize); | |||
const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toWideCharPointer(), args); | |||
#endif | |||
@@ -1921,12 +2000,12 @@ struct StringEncodingConverter | |||
{ | |||
static CharPointerType_Dest convert (const String& s) | |||
{ | |||
String& source = const_cast <String&> (s); | |||
String& source = const_cast<String&> (s); | |||
typedef typename CharPointerType_Dest::CharType DestChar; | |||
if (source.isEmpty()) | |||
return CharPointerType_Dest (reinterpret_cast <const DestChar*> (&emptyChar)); | |||
return CharPointerType_Dest (reinterpret_cast<const DestChar*> (&emptyChar)); | |||
CharPointerType_Src text (source.getCharPointer()); | |||
const size_t extraBytesNeeded = CharPointerType_Dest::getBytesRequiredFor (text) + sizeof (typename CharPointerType_Dest::CharType); | |||
@@ -1936,7 +2015,7 @@ struct StringEncodingConverter | |||
text = source.getCharPointer(); | |||
void* const newSpace = addBytesToPointer (text.getAddress(), (int) endOffset); | |||
const CharPointerType_Dest extraSpace (static_cast <DestChar*> (newSpace)); | |||
const CharPointerType_Dest extraSpace (static_cast<DestChar*> (newSpace)); | |||
#if JUCE_DEBUG // (This just avoids spurious warnings from valgrind about the uninitialised bytes at the end of the buffer..) | |||
const size_t bytesToClear = (size_t) jmin ((int) extraBytesNeeded, 4); | |||
@@ -346,15 +346,15 @@ public: | |||
*/ | |||
int compareIgnoreCase (const String& other) const noexcept; | |||
/** Lexicographic comparison with another string. | |||
/** Compares two strings, taking into account textual characteristics like numbers and spaces. | |||
The comparison used here is case-insensitive and ignores leading non-alphanumeric | |||
characters, making it good for sorting human-readable strings. | |||
This comparison is case-insensitive and can detect words and embedded numbers in the | |||
strings, making it good for sorting human-readable lists of things like filenames. | |||
@returns 0 if the two strings are identical; negative if this string comes before | |||
the other one alphabetically, or positive if it comes after it. | |||
*/ | |||
int compareLexicographically (const String& other) const noexcept; | |||
int compareNatural (StringRef other) const noexcept; | |||
/** Tests whether the string begins with another string. | |||
If the parameter is an empty string, this will always return true. | |||
@@ -199,6 +199,11 @@ int StringArray::indexOf (StringRef stringToLookFor, const bool ignoreCase, int | |||
return -1; | |||
} | |||
void StringArray::move (const int currentIndex, const int newIndex) noexcept | |||
{ | |||
strings.move (currentIndex, newIndex); | |||
} | |||
//============================================================================== | |||
void StringArray::remove (const int index) | |||
{ | |||
@@ -255,12 +260,17 @@ void StringArray::trim() | |||
//============================================================================== | |||
struct InternalStringArrayComparator_CaseSensitive | |||
{ | |||
static int compareElements (String& first, String& second) { return first.compare (second); } | |||
static int compareElements (String& s1, String& s2) noexcept { return s1.compare (s2); } | |||
}; | |||
struct InternalStringArrayComparator_CaseInsensitive | |||
{ | |||
static int compareElements (String& first, String& second) { return first.compareIgnoreCase (second); } | |||
static int compareElements (String& s1, String& s2) noexcept { return s1.compareIgnoreCase (s2); } | |||
}; | |||
struct InternalStringArrayComparator_Natural | |||
{ | |||
static int compareElements (String& s1, String& s2) noexcept { return s1.compareNatural (s2); } | |||
}; | |||
void StringArray::sort (const bool ignoreCase) | |||
@@ -277,12 +287,12 @@ void StringArray::sort (const bool ignoreCase) | |||
} | |||
} | |||
void StringArray::move (const int currentIndex, int newIndex) noexcept | |||
void StringArray::sortNatural() | |||
{ | |||
strings.move (currentIndex, newIndex); | |||
InternalStringArrayComparator_Natural comp; | |||
strings.sort (comp); | |||
} | |||
//============================================================================== | |||
String StringArray::joinIntoString (StringRef separator, int start, int numberToJoin) const | |||
{ | |||
@@ -134,18 +134,12 @@ public: | |||
/** Returns a pointer to the first String in the array. | |||
This method is provided for compatibility with standard C++ iteration mechanisms. | |||
*/ | |||
inline String* begin() const noexcept | |||
{ | |||
return strings.begin(); | |||
} | |||
inline String* begin() const noexcept { return strings.begin(); } | |||
/** Returns a pointer to the String which follows the last element in the array. | |||
This method is provided for compatibility with standard C++ iteration mechanisms. | |||
*/ | |||
inline String* end() const noexcept | |||
{ | |||
return strings.end(); | |||
} | |||
inline String* end() const noexcept { return strings.end(); } | |||
/** Searches for a string in the array. | |||
@@ -387,11 +381,16 @@ public: | |||
//============================================================================== | |||
/** Sorts the array into alphabetical order. | |||
@param ignoreCase if true, the comparisons used will be case-sensitive. | |||
*/ | |||
void sort (bool ignoreCase); | |||
/** Sorts the array using extra language-aware rules to do a better job of comparing | |||
words containing spaces and numbers. | |||
@see String::compareNatural() | |||
*/ | |||
void sortNatural(); | |||
//============================================================================== | |||
/** Increases the array's internal storage to hold a minimum number of elements. | |||
@@ -121,6 +121,16 @@ String StringPool::getPooledString (String::CharPointerType start, String::CharP | |||
return addPooledString (strings, StartEndString (start, end)); | |||
} | |||
String StringPool::getPooledString (StringRef newString) | |||
{ | |||
if (newString.isEmpty()) | |||
return String(); | |||
const ScopedLock sl (lock); | |||
garbageCollectIfNeeded(); | |||
return addPooledString (strings, newString.text); | |||
} | |||
String StringPool::getPooledString (const String& newString) | |||
{ | |||
if (newString.isEmpty()) | |||
@@ -62,6 +62,11 @@ public: | |||
*/ | |||
String getPooledString (const char* original); | |||
/** Returns a pointer to a shared copy of the string that is passed in. | |||
The pool will always return the same String object when asked for a string that matches it. | |||
*/ | |||
String getPooledString (StringRef original); | |||
/** Returns a pointer to a copy of the string that is passed in. | |||
The pool will always return the same String object when asked for a string that matches it. | |||
*/ | |||
@@ -72,7 +72,7 @@ XmlElement::XmlElement (const char* tag) | |||
} | |||
XmlElement::XmlElement (StringRef tag) | |||
: tagName (StringPool::getGlobalPool().getPooledString (tag.text.getAddress())) | |||
: tagName (StringPool::getGlobalPool().getPooledString (tag)) | |||
{ | |||
sanityCheckTagName (tagName); | |||
} | |||
@@ -789,6 +789,11 @@ void ValueTree::copyPropertiesFrom (const ValueTree& source, UndoManager* const | |||
object->copyPropertiesFrom (*(source.object), undoManager); | |||
} | |||
int ValueTree::getReferenceCount() const noexcept | |||
{ | |||
return object != nullptr ? object->getReferenceCount() : 0; | |||
} | |||
//============================================================================== | |||
class ValueTreePropertyValueSource : public Value::ValueSource, | |||
private ValueTree::Listener | |||
@@ -950,6 +955,9 @@ XmlElement* ValueTree::createXml() const | |||
ValueTree ValueTree::fromXml (const XmlElement& xml) | |||
{ | |||
// ValueTrees don't have any equivalent to XML text elements! | |||
jassert (! xml.isTextElement()); | |||
ValueTree v (xml.getTagName()); | |||
v.object->properties.setFromXmlAttributes (xml); | |||
@@ -490,6 +490,11 @@ public: | |||
*/ | |||
static const ValueTree invalid; | |||
/** Returns the total number of references to the shared underlying data structure that this | |||
ValueTree is using. | |||
*/ | |||
int getReferenceCount() const noexcept; | |||
private: | |||
//============================================================================== | |||
JUCE_PUBLIC_IN_DLL_BUILD (class SharedObject) | |||
@@ -213,6 +213,9 @@ public: | |||
/** Casts this point to a Point<double> object. */ | |||
Point<double> toDouble() const noexcept { return Point<double> (static_cast<double> (x), static_cast<double> (y)); } | |||
/** Casts this point to a Point<int> object using roundToInt() to convert the values. */ | |||
Point<int> roundToInt() const noexcept { return Point<int> (juce::roundToInt (x), juce::roundToInt (y)); } | |||
/** Returns the point as a string in the form "x, y". */ | |||
String toString() const { return String (x) + ", " + String (y); } | |||
@@ -363,9 +363,8 @@ public: | |||
virtual void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour, | |||
bool isMouseOverButton, bool isButtonDown) = 0; | |||
virtual Font getTextButtonFont (TextButton&) = 0; | |||
virtual void changeTextButtonWidthToFitText (TextButton&, int newHeight) = 0; | |||
virtual Font getTextButtonFont (TextButton&, int buttonHeight) = 0; | |||
virtual int getTextButtonWidthToFitText (TextButton&, int buttonHeight) = 0; | |||
/** Draws the text for a TextButton. */ | |||
virtual void drawButtonText (Graphics&, TextButton&, bool isMouseOverButton, bool isButtonDown) = 0; | |||
@@ -379,6 +378,13 @@ public: | |||
bool ticked, bool isEnabled, bool isMouseOverButton, bool isButtonDown) = 0; | |||
virtual void drawDrawableButton (Graphics&, DrawableButton&, bool isMouseOverButton, bool isButtonDown) = 0; | |||
private: | |||
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE | |||
// These method have been deprecated: see their replacements above. | |||
virtual int getTextButtonFont (TextButton&) { return 0; } | |||
virtual int changeTextButtonWidthToFitText (TextButton&, int) { return 0; } | |||
#endif | |||
}; | |||
protected: | |||
@@ -80,6 +80,31 @@ void DrawableButton::setEdgeIndent (const int numPixelsIndent) | |||
resized(); | |||
} | |||
Rectangle<float> DrawableButton::getImageBounds() const | |||
{ | |||
Rectangle<int> r (getLocalBounds()); | |||
if (style != ImageStretched) | |||
{ | |||
int indentX = jmin (edgeIndent, proportionOfWidth (0.3f)); | |||
int indentY = jmin (edgeIndent, proportionOfHeight (0.3f)); | |||
if (style == ImageOnButtonBackground) | |||
{ | |||
indentX = jmax (getWidth() / 4, indentX); | |||
indentY = jmax (getHeight() / 4, indentY); | |||
} | |||
else if (style == ImageAboveTextLabel) | |||
{ | |||
r = r.withTrimmedBottom (jmin (16, proportionOfHeight (0.25f))); | |||
} | |||
r = r.reduced (indentX, indentY); | |||
} | |||
return r.toFloat(); | |||
} | |||
void DrawableButton::resized() | |||
{ | |||
Button::resized(); | |||
@@ -87,36 +112,11 @@ void DrawableButton::resized() | |||
if (currentImage != nullptr) | |||
{ | |||
if (style == ImageRaw) | |||
{ | |||
currentImage->setOriginWithOriginalSize (Point<float>()); | |||
} | |||
else if (style == ImageStretched) | |||
{ | |||
currentImage->setTransformToFit (getLocalBounds().toFloat(), RectanglePlacement::stretchToFit); | |||
} | |||
else | |||
{ | |||
Rectangle<int> imageSpace; | |||
const int indentX = jmin (edgeIndent, proportionOfWidth (0.3f)); | |||
const int indentY = jmin (edgeIndent, proportionOfHeight (0.3f)); | |||
if (style == ImageOnButtonBackground) | |||
{ | |||
imageSpace = getLocalBounds().reduced (jmax (getWidth() / 4, indentX), | |||
jmax (getHeight() / 4, indentY)); | |||
} | |||
else | |||
{ | |||
const int textH = (style == ImageAboveTextLabel) ? jmin (16, proportionOfHeight (0.25f)) : 0; | |||
imageSpace.setBounds (indentX, indentY, | |||
getWidth() - indentX * 2, | |||
getHeight() - indentY * 2 - textH); | |||
} | |||
currentImage->setTransformToFit (imageSpace.toFloat(), RectanglePlacement::centred); | |||
} | |||
currentImage->setTransformToFit (getImageBounds(), | |||
style == ImageStretched ? RectanglePlacement::stretchToFit | |||
: RectanglePlacement::centred); | |||
} | |||
} | |||
@@ -152,7 +152,7 @@ void DrawableButton::buttonStateChanged() | |||
{ | |||
currentImage->setInterceptsMouseClicks (false, false); | |||
addAndMakeVisible (currentImage); | |||
DrawableButton::resized(); | |||
resized(); | |||
} | |||
} | |||
@@ -132,6 +132,9 @@ public: | |||
/** Returns the image that the button will use when the mouse is held down on it. */ | |||
Drawable* getDownImage() const noexcept; | |||
/** Can be overridden to specify a custom position for the image within the button. */ | |||
virtual Rectangle<float> getImageBounds() const; | |||
//============================================================================== | |||
/** A set of colour IDs to use to change the colour of various aspects of the link. | |||
@@ -173,8 +176,8 @@ public: | |||
private: | |||
//============================================================================== | |||
ButtonStyle style; | |||
ScopedPointer <Drawable> normalImage, overImage, downImage, disabledImage, | |||
normalImageOn, overImageOn, downImageOn, disabledImageOn; | |||
ScopedPointer<Drawable> normalImage, overImage, downImage, disabledImage, | |||
normalImageOn, overImageOn, downImageOn, disabledImageOn; | |||
Drawable* currentImage; | |||
int edgeIndent; | |||
@@ -1,7 +1,6 @@ | |||
/* | |||
============================================================================== | |||
This file is part of the JUCE library. | |||
file is part of the JUCE library. | |||
Copyright (c) 2013 - Raw Material Software Ltd. | |||
Permission is granted to use this software under the terms of either: | |||
@@ -26,8 +25,11 @@ TextButton::TextButton() : Button (String()) | |||
{ | |||
} | |||
TextButton::TextButton (const String& name, const String& toolTip) | |||
: Button (name) | |||
TextButton::TextButton (const String& name) : Button (name) | |||
{ | |||
} | |||
TextButton::TextButton (const String& name, const String& toolTip) : Button (name) | |||
{ | |||
setTooltip (toolTip); | |||
} | |||
@@ -52,12 +54,17 @@ void TextButton::colourChanged() | |||
repaint(); | |||
} | |||
Font TextButton::getFont() | |||
void TextButton::changeWidthToFitText() | |||
{ | |||
return Font (jmin (15.0f, getHeight() * 0.6f)); | |||
changeWidthToFitText (getHeight()); | |||
} | |||
void TextButton::changeWidthToFitText (const int newHeight) | |||
{ | |||
getLookAndFeel().changeTextButtonWidthToFitText (*this, newHeight); | |||
setSize (getBestWidthForHeight (newHeight), newHeight); | |||
} | |||
int TextButton::getBestWidthForHeight (int buttonHeight) | |||
{ | |||
return getLookAndFeel().getTextButtonWidthToFitText (*this, buttonHeight); | |||
} |
@@ -40,15 +40,20 @@ public: | |||
/** Creates a TextButton. */ | |||
TextButton(); | |||
/** Creates a TextButton. | |||
@param buttonName the text to put in the button (the component's name is also | |||
initially set to this string, but these can be changed later | |||
using the setName() and setButtonText() methods) | |||
*/ | |||
explicit TextButton (const String& buttonName); | |||
/** Creates a TextButton. | |||
@param buttonName the text to put in the button (the component's name is also | |||
initially set to this string, but these can be changed later | |||
using the setName() and setButtonText() methods) | |||
@param toolTip an optional string to use as a toolip | |||
@see Button | |||
*/ | |||
explicit TextButton (const String& buttonName, | |||
const String& toolTip = String::empty); | |||
TextButton (const String& buttonName, const String& toolTip); | |||
/** Destructor. */ | |||
~TextButton(); | |||
@@ -74,17 +79,20 @@ public: | |||
}; | |||
//============================================================================== | |||
/** Resizes the button to fit neatly around its current text. | |||
If newHeight is >= 0, the button's height will be changed to this | |||
value. If it's less than zero, its height will be unaffected. | |||
/** Changes this button's width to fit neatly around its current text, without | |||
changing its height. | |||
*/ | |||
void changeWidthToFitText (int newHeight = -1); | |||
void changeWidthToFitText(); | |||
/** This can be overridden to use different fonts than the default one. | |||
Note that you'll need to set the font's size appropriately, too. | |||
/** Resizes the button's width to fit neatly around its current text, and gives it | |||
the specified height. | |||
*/ | |||
virtual Font getFont(); | |||
void changeWidthToFitText (int newHeight); | |||
/** Returns the width that the LookAndFeel suggests would be best for this button if it | |||
had the given height. | |||
*/ | |||
int getBestWidthForHeight (int buttonHeight); | |||
//============================================================================== | |||
/** @internal */ | |||
@@ -93,6 +101,11 @@ public: | |||
void colourChanged() override; | |||
private: | |||
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE | |||
// Note that this method has been removed - instead, see LookAndFeel::getTextButtonWidthToFitText() | |||
virtual int getFont() { return 0; } | |||
#endif | |||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton) | |||
}; | |||
@@ -22,12 +22,6 @@ | |||
============================================================================== | |||
*/ | |||
#define CHECK_MESSAGE_MANAGER_IS_LOCKED \ | |||
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); | |||
#define CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN \ | |||
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager() || getPeer() == nullptr); | |||
Component* Component::currentlyFocusedComponent = nullptr; | |||
@@ -245,6 +239,15 @@ struct ScalingHelpers | |||
{ | |||
return scaledScreenPosToUnscaled (comp.getDesktopScaleFactor(), pos); | |||
} | |||
static Point<int> addPosition (Point<int> p, const Component& c) noexcept { return p + c.getPosition(); } | |||
static Rectangle<int> addPosition (Rectangle<int> p, const Component& c) noexcept { return p + c.getPosition(); } | |||
static Point<float> addPosition (Point<float> p, const Component& c) noexcept { return p + c.getPosition().toFloat(); } | |||
static Rectangle<float> addPosition (Rectangle<float> p, const Component& c) noexcept { return p + c.getPosition().toFloat(); } | |||
static Point<int> subtractPosition (Point<int> p, const Component& c) noexcept { return p - c.getPosition(); } | |||
static Rectangle<int> subtractPosition (Rectangle<int> p, const Component& c) noexcept { return p - c.getPosition(); } | |||
static Point<float> subtractPosition (Point<float> p, const Component& c) noexcept { return p - c.getPosition().toFloat(); } | |||
static Rectangle<float> subtractPosition (Rectangle<float> p, const Component& c) noexcept { return p - c.getPosition().toFloat(); } | |||
}; | |||
//============================================================================== | |||
@@ -327,7 +330,7 @@ struct Component::ComponentHelpers | |||
} | |||
else | |||
{ | |||
pointInParentSpace -= comp.getPosition(); | |||
pointInParentSpace = ScalingHelpers::subtractPosition (pointInParentSpace, comp); | |||
} | |||
return pointInParentSpace; | |||
@@ -346,7 +349,7 @@ struct Component::ComponentHelpers | |||
} | |||
else | |||
{ | |||
pointInLocalSpace += comp.getPosition(); | |||
pointInLocalSpace = ScalingHelpers::addPosition (pointInLocalSpace, comp); | |||
} | |||
if (comp.affineTransform != nullptr) | |||
@@ -524,7 +527,7 @@ void Component::setName (const String& name) | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
if (componentName != name) | |||
{ | |||
@@ -550,7 +553,7 @@ void Component::setVisible (bool shouldBeVisible) | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
const WeakReference<Component> safePointer (this); | |||
flags.visibleFlag = shouldBeVisible; | |||
@@ -632,7 +635,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
if (isOpaque()) | |||
styleWanted &= ~ComponentPeer::windowIsSemiTransparent; | |||
@@ -732,7 +735,7 @@ void Component::removeFromDesktop() | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
if (flags.hasHeavyweightPeerFlag) | |||
{ | |||
@@ -910,7 +913,7 @@ void Component::toFront (const bool setAsForeground) | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
if (flags.hasHeavyweightPeerFlag) | |||
{ | |||
@@ -1092,6 +1095,11 @@ Point<int> Component::getLocalPoint (const Component* source, Point<int> point) | |||
return ComponentHelpers::convertCoordinate (this, source, point); | |||
} | |||
Point<float> Component::getLocalPoint (const Component* source, Point<float> point) const | |||
{ | |||
return ComponentHelpers::convertCoordinate (this, source, point); | |||
} | |||
Rectangle<int> Component::getLocalArea (const Component* source, const Rectangle<int>& area) const | |||
{ | |||
return ComponentHelpers::convertCoordinate (this, source, area); | |||
@@ -1102,6 +1110,11 @@ Point<int> Component::localPointToGlobal (Point<int> point) const | |||
return ComponentHelpers::convertCoordinate (nullptr, this, point); | |||
} | |||
Point<float> Component::localPointToGlobal (Point<float> point) const | |||
{ | |||
return ComponentHelpers::convertCoordinate (nullptr, this, point); | |||
} | |||
Rectangle<int> Component::localAreaToGlobal (const Rectangle<int>& area) const | |||
{ | |||
return ComponentHelpers::convertCoordinate (nullptr, this, area); | |||
@@ -1130,7 +1143,7 @@ void Component::setBounds (const int x, const int y, int w, int h) | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
if (w < 0) w = 0; | |||
if (h < 0) h = 0; | |||
@@ -1463,7 +1476,7 @@ void Component::addChildComponent (Component& child, int zOrder) | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
if (child.parentComponent != this) | |||
{ | |||
@@ -1539,7 +1552,7 @@ Component* Component::removeChildComponent (const int index, bool sendParentEven | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN | |||
Component* const child = childComponentList [index]; | |||
@@ -1730,7 +1743,7 @@ void Component::enterModalState (const bool shouldTakeKeyboardFocus, | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
// Check for an attempt to make a component modal when it already is! | |||
// This can cause nasty problems.. | |||
@@ -1917,7 +1930,7 @@ void Component::internalRepaintUnchecked (const Rectangle<int>& area, const bool | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
if (ComponentPeer* const peer = getPeer()) | |||
{ | |||
@@ -2306,7 +2319,7 @@ void Component::addComponentListener (ComponentListener* const newListener) | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
#if JUCE_DEBUG || JUCE_LOG_ASSERTIONS | |||
if (getParentComponent() != nullptr) | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED; | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED; | |||
#endif | |||
componentListeners.add (newListener); | |||
@@ -2369,7 +2382,7 @@ void Component::addMouseListener (MouseListener* const newListener, | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
// If you register a component as a mouselistener for itself, it'll receive all the events | |||
// twice - once via the direct callback that all components get anyway, and then again as a listener! | |||
@@ -2385,14 +2398,14 @@ void Component::removeMouseListener (MouseListener* const listenerToRemove) | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
if (mouseListeners != nullptr) | |||
mouseListeners->removeListener (listenerToRemove); | |||
} | |||
//============================================================================== | |||
void Component::internalMouseEnter (MouseInputSource source, Point<int> relativePos, Time time) | |||
void Component::internalMouseEnter (MouseInputSource source, Point<float> relativePos, Time time) | |||
{ | |||
if (isCurrentlyBlockedByAnotherModalComponent()) | |||
{ | |||
@@ -2418,7 +2431,7 @@ void Component::internalMouseEnter (MouseInputSource source, Point<int> relative | |||
MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseEnter, me); | |||
} | |||
void Component::internalMouseExit (MouseInputSource source, Point<int> relativePos, Time time) | |||
void Component::internalMouseExit (MouseInputSource source, Point<float> relativePos, Time time) | |||
{ | |||
if (flags.repaintOnMouseActivityFlag) | |||
repaint(); | |||
@@ -2438,7 +2451,7 @@ void Component::internalMouseExit (MouseInputSource source, Point<int> relativeP | |||
MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseExit, me); | |||
} | |||
void Component::internalMouseDown (MouseInputSource source, Point<int> relativePos, Time time) | |||
void Component::internalMouseDown (MouseInputSource source, Point<float> relativePos, Time time) | |||
{ | |||
Desktop& desktop = Desktop::getInstance(); | |||
BailOutChecker checker (this); | |||
@@ -2502,7 +2515,7 @@ void Component::internalMouseDown (MouseInputSource source, Point<int> relativeP | |||
MouseListenerList::sendMouseEvent (*this, checker, &MouseListener::mouseDown, me); | |||
} | |||
void Component::internalMouseUp (MouseInputSource source, Point<int> relativePos, | |||
void Component::internalMouseUp (MouseInputSource source, Point<float> relativePos, | |||
Time time, const ModifierKeys oldModifiers) | |||
{ | |||
if (flags.mouseDownWasBlocked && isCurrentlyBlockedByAnotherModalComponent()) | |||
@@ -2545,7 +2558,7 @@ void Component::internalMouseUp (MouseInputSource source, Point<int> relativePos | |||
} | |||
} | |||
void Component::internalMouseDrag (MouseInputSource source, Point<int> relativePos, Time time) | |||
void Component::internalMouseDrag (MouseInputSource source, Point<float> relativePos, Time time) | |||
{ | |||
if (! isCurrentlyBlockedByAnotherModalComponent()) | |||
{ | |||
@@ -2568,7 +2581,7 @@ void Component::internalMouseDrag (MouseInputSource source, Point<int> relativeP | |||
} | |||
} | |||
void Component::internalMouseMove (MouseInputSource source, Point<int> relativePos, Time time) | |||
void Component::internalMouseMove (MouseInputSource source, Point<float> relativePos, Time time) | |||
{ | |||
Desktop& desktop = Desktop::getInstance(); | |||
@@ -2594,7 +2607,7 @@ void Component::internalMouseMove (MouseInputSource source, Point<int> relativeP | |||
} | |||
} | |||
void Component::internalMouseWheel (MouseInputSource source, Point<int> relativePos, | |||
void Component::internalMouseWheel (MouseInputSource source, Point<float> relativePos, | |||
Time time, const MouseWheelDetails& wheel) | |||
{ | |||
Desktop& desktop = Desktop::getInstance(); | |||
@@ -2622,7 +2635,7 @@ void Component::internalMouseWheel (MouseInputSource source, Point<int> relative | |||
} | |||
} | |||
void Component::internalMagnifyGesture (MouseInputSource source, Point<int> relativePos, | |||
void Component::internalMagnifyGesture (MouseInputSource source, Point<float> relativePos, | |||
Time time, float amount) | |||
{ | |||
if (! isCurrentlyBlockedByAnotherModalComponent()) | |||
@@ -2850,7 +2863,7 @@ void Component::grabKeyboardFocus() | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
grabFocusInternal (focusChangedDirectly, true); | |||
} | |||
@@ -2859,7 +2872,7 @@ void Component::moveKeyboardFocusToSibling (const bool moveToNext) | |||
{ | |||
// if component methods are being called from threads other than the message | |||
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. | |||
CHECK_MESSAGE_MANAGER_IS_LOCKED | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
if (parentComponent != nullptr) | |||
{ | |||
@@ -2972,7 +2985,7 @@ bool Component::isMouseOver (const bool includeChildren) const | |||
Component* const c = mi->getComponentUnderMouse(); | |||
if ((c == this || (includeChildren && isParentOf (c))) | |||
&& c->reallyContains (c->getLocalPoint (nullptr, mi->getScreenPosition()), false) | |||
&& c->reallyContains (c->getLocalPoint (nullptr, mi->getScreenPosition()).roundToInt(), false) | |||
&& (mi->isMouse() || mi->isDragging())) | |||
return true; | |||
} | |||
@@ -355,6 +355,15 @@ public: | |||
Point<int> getLocalPoint (const Component* sourceComponent, | |||
Point<int> pointRelativeToSourceComponent) const; | |||
/** Converts a point to be relative to this component's coordinate space. | |||
This takes a point relative to a different component, and returns its position relative to this | |||
component. If the sourceComponent parameter is null, the source point is assumed to be a global | |||
screen coordinate. | |||
*/ | |||
Point<float> getLocalPoint (const Component* sourceComponent, | |||
Point<float> pointRelativeToSourceComponent) const; | |||
/** Converts a rectangle to be relative to this component's coordinate space. | |||
This takes a rectangle that is relative to a different component, and returns its position relative | |||
@@ -373,6 +382,11 @@ public: | |||
*/ | |||
Point<int> localPointToGlobal (Point<int> localPoint) const; | |||
/** Converts a point relative to this component's top-left into a screen coordinate. | |||
@see getLocalPoint, localAreaToGlobal | |||
*/ | |||
Point<float> localPointToGlobal (Point<float> localPoint) const; | |||
/** Converts a rectangle from this component's coordinate space to a screen coordinate. | |||
If you've used setTransform() to apply one or more transforms to components, then the source rectangle | |||
@@ -2306,18 +2320,18 @@ private: | |||
uint8 componentTransparency; | |||
//============================================================================== | |||
void internalMouseEnter (MouseInputSource, Point<int>, Time); | |||
void internalMouseExit (MouseInputSource, Point<int>, Time); | |||
void internalMouseDown (MouseInputSource, Point<int>, Time); | |||
void internalMouseUp (MouseInputSource, Point<int>, Time, const ModifierKeys oldModifiers); | |||
void internalMouseDrag (MouseInputSource, Point<int>, Time); | |||
void internalMouseMove (MouseInputSource, Point<int>, Time); | |||
void internalMouseWheel (MouseInputSource, Point<int>, Time, const MouseWheelDetails&); | |||
void internalMagnifyGesture (MouseInputSource, Point<int>, Time, float); | |||
void internalMouseEnter (MouseInputSource, Point<float>, Time); | |||
void internalMouseExit (MouseInputSource, Point<float>, Time); | |||
void internalMouseDown (MouseInputSource, Point<float>, Time); | |||
void internalMouseUp (MouseInputSource, Point<float>, Time, const ModifierKeys oldModifiers); | |||
void internalMouseDrag (MouseInputSource, Point<float>, Time); | |||
void internalMouseMove (MouseInputSource, Point<float>, Time); | |||
void internalMouseWheel (MouseInputSource, Point<float>, Time, const MouseWheelDetails&); | |||
void internalMagnifyGesture (MouseInputSource, Point<float>, Time, float); | |||
void internalBroughtToFront(); | |||
void internalFocusGain (const FocusChangeType, const WeakReference<Component>&); | |||
void internalFocusGain (const FocusChangeType); | |||
void internalFocusLoss (const FocusChangeType); | |||
void internalFocusGain (FocusChangeType, const WeakReference<Component>&); | |||
void internalFocusGain (FocusChangeType); | |||
void internalFocusLoss (FocusChangeType); | |||
void internalChildFocusChange (FocusChangeType, const WeakReference<Component>&); | |||
void internalModalInputAttempt(); | |||
void internalModifierKeysChanged(); | |||
@@ -68,6 +68,8 @@ Component* Desktop::getComponent (const int index) const noexcept | |||
Component* Desktop::findComponentAt (Point<int> screenPosition) const | |||
{ | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
for (int i = desktopComponents.size(); --i >= 0;) | |||
{ | |||
Component* const c = desktopComponents.getUnchecked(i); | |||
@@ -100,6 +102,7 @@ LookAndFeel& Desktop::getDefaultLookAndFeel() noexcept | |||
void Desktop::setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel) | |||
{ | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
currentLookAndFeel = newDefaultLookAndFeel; | |||
for (int i = getNumComponents(); --i >= 0;) | |||
@@ -145,18 +148,23 @@ void Desktop::componentBroughtToFront (Component* const c) | |||
//============================================================================== | |||
Point<int> Desktop::getMousePosition() | |||
{ | |||
return getMousePositionFloat().roundToInt(); | |||
} | |||
Point<float> Desktop::getMousePositionFloat() | |||
{ | |||
return getInstance().getMainMouseSource().getScreenPosition(); | |||
} | |||
void Desktop::setMousePosition (Point<int> newPosition) | |||
{ | |||
getInstance().getMainMouseSource().setScreenPosition (newPosition); | |||
getInstance().getMainMouseSource().setScreenPosition (newPosition.toFloat()); | |||
} | |||
Point<int> Desktop::getLastMouseDownPosition() | |||
{ | |||
return getInstance().getMainMouseSource().getLastMouseDownPosition(); | |||
return getInstance().getMainMouseSource().getLastMouseDownPosition().roundToInt(); | |||
} | |||
int Desktop::getMouseButtonClickCounter() const noexcept { return mouseClickCounter; } | |||
@@ -194,10 +202,10 @@ void Desktop::resetTimer() | |||
else | |||
startTimer (100); | |||
lastFakeMouseMove = getMousePosition(); | |||
lastFakeMouseMove = getMousePositionFloat(); | |||
} | |||
ListenerList <MouseListener>& Desktop::getMouseListeners() | |||
ListenerList<MouseListener>& Desktop::getMouseListeners() | |||
{ | |||
resetTimer(); | |||
return mouseListeners; | |||
@@ -205,19 +213,21 @@ ListenerList <MouseListener>& Desktop::getMouseListeners() | |||
void Desktop::addGlobalMouseListener (MouseListener* const listener) | |||
{ | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
mouseListeners.add (listener); | |||
resetTimer(); | |||
} | |||
void Desktop::removeGlobalMouseListener (MouseListener* const listener) | |||
{ | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
mouseListeners.remove (listener); | |||
resetTimer(); | |||
} | |||
void Desktop::timerCallback() | |||
{ | |||
if (lastFakeMouseMove != getMousePosition()) | |||
if (lastFakeMouseMove != getMousePositionFloat()) | |||
sendMouseMove(); | |||
} | |||
@@ -227,12 +237,12 @@ void Desktop::sendMouseMove() | |||
{ | |||
startTimer (20); | |||
lastFakeMouseMove = getMousePosition(); | |||
lastFakeMouseMove = getMousePositionFloat(); | |||
if (Component* const target = findComponentAt (lastFakeMouseMove)) | |||
if (Component* const target = findComponentAt (lastFakeMouseMove.roundToInt())) | |||
{ | |||
Component::BailOutChecker checker (target); | |||
const Point<int> pos (target->getLocalPoint (nullptr, lastFakeMouseMove)); | |||
const Point<float> pos (target->getLocalPoint (nullptr, lastFakeMouseMove)); | |||
const Time now (Time::getCurrentTime()); | |||
const MouseEvent me (getMainMouseSource(), pos, ModifierKeys::getCurrentModifiers(), | |||
@@ -253,12 +263,14 @@ Desktop::Displays::~Displays() {} | |||
const Desktop::Displays::Display& Desktop::Displays::getMainDisplay() const noexcept | |||
{ | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
jassert (displays.getReference(0).isMain); | |||
return displays.getReference(0); | |||
} | |||
const Desktop::Displays::Display& Desktop::Displays::getDisplayContaining (Point<int> position) const noexcept | |||
{ | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
const Display* best = &displays.getReference(0); | |||
double bestDistance = 1.0e10; | |||
@@ -286,6 +298,7 @@ const Desktop::Displays::Display& Desktop::Displays::getDisplayContaining (Point | |||
RectangleList<int> Desktop::Displays::getRectangleList (bool userAreasOnly) const | |||
{ | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
RectangleList<int> rl; | |||
for (int i = 0; i < displays.size(); ++i) | |||
@@ -329,6 +342,7 @@ void Desktop::Displays::refresh() | |||
oldDisplays.swapWith (displays); | |||
init (Desktop::getInstance()); | |||
jassert (displays.size() > 0); | |||
if (oldDisplays != displays) | |||
{ | |||
@@ -391,6 +405,8 @@ bool Desktop::isOrientationEnabled (const DisplayOrientation orientation) const | |||
void Desktop::setGlobalScaleFactor (float newScaleFactor) noexcept | |||
{ | |||
ASSERT_MESSAGE_MANAGER_IS_LOCKED | |||
if (masterScaleFactor != newScaleFactor) | |||
{ | |||
masterScaleFactor = newScaleFactor; | |||
@@ -414,7 +414,7 @@ private: | |||
ScopedPointer<Displays> displays; | |||
Point<int> lastFakeMouseMove; | |||
Point<float> lastFakeMouseMove; | |||
void sendMouseMove(); | |||
int mouseClickCounter, mouseWheelCounter; | |||
@@ -441,11 +441,13 @@ private: | |||
void removeDesktopComponent (Component*); | |||
void componentBroughtToFront (Component*); | |||
void setKioskComponent (Component*, bool enableOrDisable, bool allowMenusAndBars); | |||
void setKioskComponent (Component*, bool shouldBeEnabled, bool allowMenusAndBars); | |||
void triggerFocusCallback(); | |||
void handleAsyncUpdate() override; | |||
static Point<float> getMousePositionFloat(); | |||
static double getDefaultMasterScale(); | |||
Desktop(); | |||
@@ -54,7 +54,7 @@ public: | |||
DrawableComposite* const drawable = new DrawableComposite(); | |||
drawable->setName (xml->getStringAttribute ("id")); | |||
setDrawableID (*drawable, xml); | |||
SVGState newState (*this); | |||
@@ -363,6 +363,13 @@ private: | |||
AffineTransform transform; | |||
String cssStyleText; | |||
static void setDrawableID (Drawable& d, const XmlPath& xml) | |||
{ | |||
String compID (xml->getStringAttribute ("id")); | |||
d.setName (compID); | |||
d.setComponentID (compID); | |||
} | |||
//============================================================================== | |||
void parseSubElements (const XmlPath& xml, DrawableComposite& parentDrawable) | |||
{ | |||
@@ -402,7 +409,7 @@ private: | |||
{ | |||
DrawableComposite* const drawable = new DrawableComposite(); | |||
drawable->setName (xml->getStringAttribute ("id")); | |||
setDrawableID (*drawable, xml); | |||
if (xml->hasAttribute ("transform")) | |||
{ | |||
@@ -547,7 +554,7 @@ private: | |||
} | |||
DrawablePath* dp = new DrawablePath(); | |||
dp->setName (xml->getStringAttribute ("id")); | |||
setDrawableID (*dp, xml); | |||
dp->setFill (Colours::transparentBlack); | |||
path.applyTransform (transform); | |||
@@ -222,7 +222,7 @@ struct FileInfoComparator | |||
return first->isDirectory ? -1 : 1; | |||
#endif | |||
return first->filename.compareIgnoreCase (second->filename); | |||
return first->filename.compareNatural (second->filename); | |||
} | |||
}; | |||
@@ -135,6 +135,12 @@ | |||
namespace juce | |||
{ | |||
#define ASSERT_MESSAGE_MANAGER_IS_LOCKED \ | |||
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager()); | |||
#define ASSERT_MESSAGE_MANAGER_IS_LOCKED_OR_OFFSCREEN \ | |||
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager() || getPeer() == nullptr); | |||
extern bool juce_areThereAnyAlwaysOnTopWindows(); | |||
#include "components/juce_Component.cpp" | |||
@@ -238,24 +238,19 @@ void LookAndFeel_V2::drawButtonBackground (Graphics& g, | |||
button.isConnectedOnBottom()); | |||
} | |||
Font LookAndFeel_V2::getTextButtonFont (TextButton& button) | |||
Font LookAndFeel_V2::getTextButtonFont (TextButton&, int buttonHeight) | |||
{ | |||
return button.getFont(); | |||
return Font (jmin (15.0f, buttonHeight * 0.6f)); | |||
} | |||
void LookAndFeel_V2::changeTextButtonWidthToFitText (TextButton& b, int newHeight) | |||
int LookAndFeel_V2::getTextButtonWidthToFitText (TextButton& b, int buttonHeight) | |||
{ | |||
if (newHeight >= 0) | |||
b.setSize (jmax (1, b.getWidth()), newHeight); | |||
else | |||
newHeight = b.getHeight(); | |||
b.setSize (getTextButtonFont (b).getStringWidth (b.getButtonText()) + newHeight, newHeight); | |||
return getTextButtonFont (b, buttonHeight).getStringWidth (b.getButtonText()) + buttonHeight; | |||
} | |||
void LookAndFeel_V2::drawButtonText (Graphics& g, TextButton& button, bool /*isMouseOverButton*/, bool /*isButtonDown*/) | |||
{ | |||
Font font (getTextButtonFont (button)); | |||
Font font (getTextButtonFont (button, button.getHeight())); | |||
g.setFont (font); | |||
g.setColour (button.findColour (button.getToggleState() ? TextButton::textColourOnId | |||
: TextButton::textColourOffId) | |||
@@ -39,16 +39,14 @@ public: | |||
~LookAndFeel_V2(); | |||
//============================================================================== | |||
void drawButtonBackground (Graphics&, Button& button, const Colour& backgroundColour, | |||
void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour, | |||
bool isMouseOverButton, bool isButtonDown) override; | |||
Font getTextButtonFont (TextButton&, int buttonHeight) override; | |||
Font getTextButtonFont (TextButton&) override; | |||
void drawButtonText (Graphics&, TextButton&, bool isMouseOverButton, bool isButtonDown) override; | |||
int getTextButtonWidthToFitText (TextButton&, int buttonHeight) override; | |||
void drawButtonText (Graphics&, TextButton& button, | |||
bool isMouseOverButton, bool isButtonDown) override; | |||
void changeTextButtonWidthToFitText (TextButton&, int newHeight) override; | |||
void drawToggleButton (Graphics&, ToggleButton& button, bool isMouseOverButton, bool isButtonDown) override; | |||
void drawToggleButton (Graphics&, ToggleButton&, bool isMouseOverButton, bool isButtonDown) override; | |||
void changeToggleButtonWidthToFitText (ToggleButton&) override; | |||
@@ -78,17 +76,17 @@ public: | |||
//============================================================================== | |||
bool areScrollbarButtonsVisible() override; | |||
void drawScrollbarButton (Graphics& g, ScrollBar&, int width, int height, int buttonDirection, | |||
void drawScrollbarButton (Graphics&, ScrollBar&, int width, int height, int buttonDirection, | |||
bool isScrollbarVertical, bool isMouseOverButton, bool isButtonDown) override; | |||
void drawScrollbar (Graphics& g, ScrollBar&, int x, int y, int width, int height, | |||
void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, | |||
bool isScrollbarVertical, int thumbStartPosition, int thumbSize, | |||
bool isMouseOver, bool isMouseDown) override; | |||
ImageEffectFilter* getScrollbarEffect() override; | |||
int getMinimumScrollbarThumbSize (ScrollBar&) override; | |||
int getDefaultScrollbarWidth() override; | |||
int getScrollbarButtonSize (ScrollBar& scrollbar) override; | |||
int getScrollbarButtonSize (ScrollBar&) override; | |||
//============================================================================== | |||
Path getTickShape (float height) override; | |||
@@ -199,7 +197,7 @@ public: | |||
//============================================================================== | |||
Button* createFilenameComponentBrowseButton (const String& text) override; | |||
void layoutFilenameComponent (FilenameComponent& filenameComp, ComboBox* filenameBox, Button* browseButton) override; | |||
void layoutFilenameComponent (FilenameComponent&, ComboBox* filenameBox, Button* browseButton) override; | |||
//============================================================================== | |||
void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area, | |||
@@ -250,8 +248,8 @@ public: | |||
void drawTabbedButtonBarBackground (TabbedButtonBar&, Graphics&) override; | |||
void drawTabAreaBehindFrontButton (TabbedButtonBar&, Graphics&, int w, int h) override; | |||
void createTabButtonShape (TabBarButton&, Path& path, bool isMouseOver, bool isMouseDown) override; | |||
void fillTabButtonShape (TabBarButton&, Graphics&, const Path& path, bool isMouseOver, bool isMouseDown) override; | |||
void createTabButtonShape (TabBarButton&, Path&, bool isMouseOver, bool isMouseDown) override; | |||
void fillTabButtonShape (TabBarButton&, Graphics&, const Path&, bool isMouseOver, bool isMouseDown) override; | |||
Button* createTabBarExtrasButton() override; | |||
@@ -291,7 +289,7 @@ public: | |||
//============================================================================== | |||
void drawLevelMeter (Graphics&, int width, int height, float level) override; | |||
void drawKeymapChangeButton (Graphics&, int width, int height, Button& button, const String& keyDescription) override; | |||
void drawKeymapChangeButton (Graphics&, int width, int height, Button&, const String& keyDescription) override; | |||
//============================================================================== | |||
/** Draws a 3D raised (or indented) bevel using two colours. | |||
@@ -318,15 +316,15 @@ public: | |||
/** Utility function to draw a shiny, glassy circle (for round LED-type buttons). */ | |||
static void drawGlassSphere (Graphics&, float x, float y, float diameter, | |||
const Colour& colour, float outlineThickness) noexcept; | |||
const Colour&, float outlineThickness) noexcept; | |||
static void drawGlassPointer (Graphics&, float x, float y, float diameter, | |||
const Colour& colour, float outlineThickness, int direction) noexcept; | |||
const Colour&, float outlineThickness, int direction) noexcept; | |||
/** Utility function to draw a shiny, glassy oblong (for text buttons). */ | |||
static void drawGlassLozenge (Graphics&, | |||
float x, float y, float width, float height, | |||
const Colour& colour, float outlineThickness, float cornerSize, | |||
const Colour&, float outlineThickness, float cornerSize, | |||
bool flatOnLeft, bool flatOnRight, bool flatOnTop, bool flatOnBottom) noexcept; | |||
private: | |||
@@ -335,7 +333,7 @@ private: | |||
void drawShinyButtonShape (Graphics&, | |||
float x, float y, float w, float h, float maxCornerSize, | |||
const Colour& baseColour, float strokeWidth, | |||
const Colour&, float strokeWidth, | |||
bool flatOnLeft, bool flatOnRight, bool flatOnTop, bool flatOnBottom) noexcept; | |||
class GlassWindowButton; | |||
@@ -980,12 +980,12 @@ public: | |||
void timerCallback() override | |||
{ | |||
if (window.windowIsStillValid()) | |||
handleMousePosition (source.getScreenPosition()); | |||
handleMousePosition (source.getScreenPosition().roundToInt()); | |||
} | |||
bool isOver() const | |||
{ | |||
return window.reallyContains (window.getLocalPoint (nullptr, source.getScreenPosition()), true); | |||
return window.reallyContains (window.getLocalPoint (nullptr, source.getScreenPosition()).roundToInt(), true); | |||
} | |||
MenuWindow& window; | |||
@@ -49,7 +49,7 @@ void ComponentDragger::dragComponent (Component* const componentToDrag, const Mo | |||
// so their coordinates become wrong after the first one moves the window, so in that case, we'll use | |||
// the current mouse position instead of the one that the event contains... | |||
if (componentToDrag->isOnDesktop()) | |||
bounds += componentToDrag->getLocalPoint (nullptr, e.source.getScreenPosition()) - mouseDownWithinTarget; | |||
bounds += componentToDrag->getLocalPoint (nullptr, e.source.getScreenPosition()).roundToInt() - mouseDownWithinTarget; | |||
else | |||
bounds += e.getEventRelativeTo (componentToDrag).getPosition() - mouseDownWithinTarget; | |||
@@ -212,7 +212,7 @@ private: | |||
DragAndDropTarget* getCurrentlyOver() const noexcept | |||
{ | |||
return dynamic_cast <DragAndDropTarget*> (currentlyOverComp.get()); | |||
return dynamic_cast<DragAndDropTarget*> (currentlyOverComp.get()); | |||
} | |||
DragAndDropTarget* findTarget (Point<int> screenPos, Point<int>& relativePos, | |||
@@ -231,7 +231,7 @@ private: | |||
while (hit != nullptr) | |||
{ | |||
if (DragAndDropTarget* const ddt = dynamic_cast <DragAndDropTarget*> (hit)) | |||
if (DragAndDropTarget* const ddt = dynamic_cast<DragAndDropTarget*> (hit)) | |||
{ | |||
if (ddt->isInterestedInDragSource (details)) | |||
{ | |||
@@ -353,7 +353,7 @@ void DragAndDropContainer::startDragging (const var& sourceDescription, | |||
return; | |||
} | |||
const Point<int> lastMouseDown (draggingSource->getLastMouseDownPosition()); | |||
const Point<int> lastMouseDown (draggingSource->getLastMouseDownPosition().roundToInt()); | |||
Point<int> imageOffset; | |||
if (dragImage.isNull()) | |||
@@ -383,7 +383,7 @@ void DragAndDropContainer::startDragging (const var& sourceDescription, | |||
{ | |||
const float alpha = (distance > hi) ? 0 | |||
: (hi - distance) / (float) (hi - lo) | |||
+ random.nextFloat() * 0.008f; | |||
+ random.nextFloat() * 0.008f; | |||
dragImage.multiplyAlphaAt (x, y, alpha); | |||
} | |||
@@ -414,7 +414,7 @@ void DragAndDropContainer::startDragging (const var& sourceDescription, | |||
} | |||
else | |||
{ | |||
if (Component* const thisComp = dynamic_cast <Component*> (this)) | |||
if (Component* const thisComp = dynamic_cast<Component*> (this)) | |||
{ | |||
thisComp->addChildComponent (dragImageComponent); | |||
} | |||
@@ -425,8 +425,7 @@ void DragAndDropContainer::startDragging (const var& sourceDescription, | |||
} | |||
} | |||
static_cast <DragImageComponent*> (dragImageComponent.get())->updateLocation (false, lastMouseDown); | |||
dragImageComponent->setVisible (true); | |||
static_cast<DragImageComponent*> (dragImageComponent.get())->updateLocation (false, lastMouseDown); | |||
dragImageComponent->enterModalState(); | |||
#if JUCE_WINDOWS | |||
@@ -23,17 +23,18 @@ | |||
*/ | |||
MouseEvent::MouseEvent (MouseInputSource inputSource, | |||
Point<int> position, | |||
Point<float> pos, | |||
ModifierKeys modKeys, | |||
Component* const eventComp, | |||
Component* const originator, | |||
Time time, | |||
Point<int> downPos, | |||
Point<float> downPos, | |||
Time downTime, | |||
const int numClicks, | |||
const bool mouseWasDragged) noexcept | |||
: x (position.x), | |||
y (position.y), | |||
: position (pos), | |||
x (roundToInt (pos.x)), | |||
y (roundToInt (pos.y)), | |||
mods (modKeys), | |||
eventComponent (eventComp), | |||
originalComponent (originator), | |||
@@ -55,19 +56,26 @@ MouseEvent MouseEvent::getEventRelativeTo (Component* const otherComponent) cons | |||
{ | |||
jassert (otherComponent != nullptr); | |||
return MouseEvent (source, otherComponent->getLocalPoint (eventComponent, getPosition()), | |||
return MouseEvent (source, otherComponent->getLocalPoint (eventComponent, position), | |||
mods, otherComponent, originalComponent, eventTime, | |||
otherComponent->getLocalPoint (eventComponent, mouseDownPos), | |||
mouseDownTime, numberOfClicks, wasMovedSinceMouseDown != 0); | |||
} | |||
MouseEvent MouseEvent::withNewPosition (Point<int> newPosition) const noexcept | |||
MouseEvent MouseEvent::withNewPosition (Point<float> newPosition) const noexcept | |||
{ | |||
return MouseEvent (source, newPosition, mods, eventComponent, originalComponent, | |||
eventTime, mouseDownPos, mouseDownTime, | |||
numberOfClicks, wasMovedSinceMouseDown != 0); | |||
} | |||
MouseEvent MouseEvent::withNewPosition (Point<int> newPosition) const noexcept | |||
{ | |||
return MouseEvent (source, newPosition.toFloat(), mods, eventComponent, originalComponent, | |||
eventTime, mouseDownPos, mouseDownTime, | |||
numberOfClicks, wasMovedSinceMouseDown != 0); | |||
} | |||
//============================================================================== | |||
bool MouseEvent::mouseWasClicked() const noexcept | |||
{ | |||
@@ -86,17 +94,17 @@ int MouseEvent::getLengthOfMousePress() const noexcept | |||
Point<int> MouseEvent::getPosition() const noexcept { return Point<int> (x, y); } | |||
Point<int> MouseEvent::getScreenPosition() const { return eventComponent->localPointToGlobal (getPosition()); } | |||
Point<int> MouseEvent::getMouseDownPosition() const noexcept { return mouseDownPos; } | |||
Point<int> MouseEvent::getMouseDownScreenPosition() const { return eventComponent->localPointToGlobal (mouseDownPos); } | |||
Point<int> MouseEvent::getMouseDownPosition() const noexcept { return mouseDownPos.roundToInt(); } | |||
Point<int> MouseEvent::getMouseDownScreenPosition() const { return eventComponent->localPointToGlobal (mouseDownPos).roundToInt(); } | |||
Point<int> MouseEvent::getOffsetFromDragStart() const noexcept { return getPosition() - mouseDownPos; } | |||
int MouseEvent::getDistanceFromDragStart() const noexcept { return mouseDownPos.getDistanceFrom (getPosition()); } | |||
Point<int> MouseEvent::getOffsetFromDragStart() const noexcept { return (position - mouseDownPos).roundToInt(); } | |||
int MouseEvent::getDistanceFromDragStart() const noexcept { return roundToInt (mouseDownPos.getDistanceFrom (position)); } | |||
int MouseEvent::getMouseDownX() const noexcept { return mouseDownPos.x; } | |||
int MouseEvent::getMouseDownY() const noexcept { return mouseDownPos.y; } | |||
int MouseEvent::getMouseDownX() const noexcept { return roundToInt (mouseDownPos.x); } | |||
int MouseEvent::getMouseDownY() const noexcept { return roundToInt (mouseDownPos.y); } | |||
int MouseEvent::getDistanceFromDragStartX() const noexcept { return x - mouseDownPos.x; } | |||
int MouseEvent::getDistanceFromDragStartY() const noexcept { return y - mouseDownPos.y; } | |||
int MouseEvent::getDistanceFromDragStartX() const noexcept { return getOffsetFromDragStart().x; } | |||
int MouseEvent::getDistanceFromDragStartY() const noexcept { return getOffsetFromDragStart().y; } | |||
int MouseEvent::getScreenX() const { return getScreenPosition().x; } | |||
int MouseEvent::getScreenY() const { return getScreenPosition().y; } | |||
@@ -57,12 +57,12 @@ public: | |||
@param mouseWasDragged whether the mouse has been dragged significantly since the previous mouse-down | |||
*/ | |||
MouseEvent (MouseInputSource source, | |||
Point<int> position, | |||
Point<float> position, | |||
ModifierKeys modifiers, | |||
Component* eventComponent, | |||
Component* originator, | |||
Time eventTime, | |||
Point<int> mouseDownPos, | |||
Point<float> mouseDownPos, | |||
Time mouseDownTime, | |||
int numberOfClicks, | |||
bool mouseWasDragged) noexcept; | |||
@@ -71,10 +71,22 @@ public: | |||
~MouseEvent() noexcept; | |||
//============================================================================== | |||
/** The position of the mouse when the event occurred. | |||
This value is relative to the top-left of the component to which the | |||
event applies (as indicated by the MouseEvent::eventComponent field). | |||
This is a more accurate floating-point version of the position returned by | |||
getPosition() and the integer x and y member variables. | |||
*/ | |||
const Point<float> position; | |||
/** The x-position of the mouse when the event occurred. | |||
This value is relative to the top-left of the component to which the | |||
event applies (as indicated by the MouseEvent::eventComponent field). | |||
For a floating-point coordinate, see MouseEvent::position | |||
*/ | |||
const int x; | |||
@@ -82,6 +94,8 @@ public: | |||
This value is relative to the top-left of the component to which the | |||
event applies (as indicated by the MouseEvent::eventComponent field). | |||
For a floating-point coordinate, see MouseEvent::position | |||
*/ | |||
const int y; | |||
@@ -130,25 +144,19 @@ public: | |||
//============================================================================== | |||
/** Returns the x coordinate of the last place that a mouse was pressed. | |||
The coordinate is relative to the component specified in MouseEvent::component. | |||
@see getDistanceFromDragStart, getDistanceFromDragStartX, mouseWasClicked | |||
*/ | |||
int getMouseDownX() const noexcept; | |||
/** Returns the y coordinate of the last place that a mouse was pressed. | |||
The coordinate is relative to the component specified in MouseEvent::component. | |||
@see getDistanceFromDragStart, getDistanceFromDragStartX, mouseWasClicked | |||
*/ | |||
int getMouseDownY() const noexcept; | |||
/** Returns the coordinates of the last place that a mouse was pressed. | |||
The coordinates are relative to the component specified in MouseEvent::component. | |||
@see getDistanceFromDragStart, getDistanceFromDragStartX, mouseWasClicked | |||
*/ | |||
Point<int> getMouseDownPosition() const noexcept; | |||
@@ -221,6 +229,8 @@ public: | |||
This position is relative to the top-left of the component to which the | |||
event applies (as indicated by the MouseEvent::eventComponent field). | |||
For a floating-point position, see MouseEvent::position | |||
*/ | |||
Point<int> getPosition() const noexcept; | |||
@@ -269,6 +279,12 @@ public: | |||
*/ | |||
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 | |||
replaced with these new values. | |||
*/ | |||
MouseEvent withNewPosition (Point<float> newPosition) 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 | |||
replaced with these new values. | |||
@@ -297,7 +313,7 @@ public: | |||
private: | |||
//============================================================================== | |||
const Point<int> mouseDownPos; | |||
const Point<float> mouseDownPos; | |||
const uint8 numberOfClicks, wasMovedSinceMouseDown; | |||
MouseEvent& operator= (const MouseEvent&); | |||
@@ -58,7 +58,7 @@ public: | |||
return lastPeer; | |||
} | |||
static Point<int> screenPosToLocalPos (Component& comp, Point<int> pos) | |||
static Point<float> screenPosToLocalPos (Component& comp, Point<float> pos) | |||
{ | |||
if (ComponentPeer* const peer = comp.getPeer()) | |||
{ | |||
@@ -70,23 +70,25 @@ public: | |||
return comp.getLocalPoint (nullptr, ScalingHelpers::unscaledScreenPosToScaled (comp, pos)); | |||
} | |||
Component* findComponentAt (Point<int> screenPos) | |||
Component* findComponentAt (Point<float> screenPos) | |||
{ | |||
if (ComponentPeer* const peer = getPeer()) | |||
{ | |||
Point<int> relativePos (ScalingHelpers::unscaledScreenPosToScaled (peer->getComponent(), | |||
peer->globalToLocal (screenPos))); | |||
Point<float> relativePos (ScalingHelpers::unscaledScreenPosToScaled (peer->getComponent(), | |||
peer->globalToLocal (screenPos))); | |||
Component& comp = peer->getComponent(); | |||
const Point<int> pos (relativePos.roundToInt()); | |||
// (the contains() call is needed to test for overlapping desktop windows) | |||
if (comp.contains (relativePos)) | |||
return comp.getComponentAt (relativePos); | |||
if (comp.contains (pos)) | |||
return comp.getComponentAt (pos); | |||
} | |||
return nullptr; | |||
} | |||
Point<int> getScreenPosition() const | |||
Point<float> getScreenPosition() const | |||
{ | |||
// This needs to return the live position if possible, but it mustn't update the lastScreenPos | |||
// value, because that can cause continuity problems. | |||
@@ -95,7 +97,7 @@ public: | |||
: lastScreenPos)); | |||
} | |||
void setScreenPosition (Point<int> p) | |||
void setScreenPosition (Point<float> p) | |||
{ | |||
MouseInputSource::setRawMousePosition (ScalingHelpers::scaledScreenPosToUnscaled (p)); | |||
} | |||
@@ -109,49 +111,49 @@ public: | |||
#define JUCE_MOUSE_EVENT_DBG(desc) | |||
#endif | |||
void sendMouseEnter (Component& comp, Point<int> screenPos, Time time) | |||
void sendMouseEnter (Component& comp, Point<float> screenPos, Time time) | |||
{ | |||
JUCE_MOUSE_EVENT_DBG ("enter") | |||
comp.internalMouseEnter (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time); | |||
} | |||
void sendMouseExit (Component& comp, Point<int> screenPos, Time time) | |||
void sendMouseExit (Component& comp, Point<float> screenPos, Time time) | |||
{ | |||
JUCE_MOUSE_EVENT_DBG ("exit") | |||
comp.internalMouseExit (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time); | |||
} | |||
void sendMouseMove (Component& comp, Point<int> screenPos, Time time) | |||
void sendMouseMove (Component& comp, Point<float> screenPos, Time time) | |||
{ | |||
JUCE_MOUSE_EVENT_DBG ("move") | |||
comp.internalMouseMove (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time); | |||
} | |||
void sendMouseDown (Component& comp, Point<int> screenPos, Time time) | |||
void sendMouseDown (Component& comp, Point<float> screenPos, Time time) | |||
{ | |||
JUCE_MOUSE_EVENT_DBG ("down") | |||
comp.internalMouseDown (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time); | |||
} | |||
void sendMouseDrag (Component& comp, Point<int> screenPos, Time time) | |||
void sendMouseDrag (Component& comp, Point<float> screenPos, Time time) | |||
{ | |||
JUCE_MOUSE_EVENT_DBG ("drag") | |||
comp.internalMouseDrag (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time); | |||
} | |||
void sendMouseUp (Component& comp, Point<int> screenPos, Time time, const ModifierKeys oldMods) | |||
void sendMouseUp (Component& comp, Point<float> screenPos, Time time, const ModifierKeys oldMods) | |||
{ | |||
JUCE_MOUSE_EVENT_DBG ("up") | |||
comp.internalMouseUp (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, oldMods); | |||
} | |||
void sendMouseWheel (Component& comp, Point<int> screenPos, Time time, const MouseWheelDetails& wheel) | |||
void sendMouseWheel (Component& comp, Point<float> screenPos, Time time, const MouseWheelDetails& wheel) | |||
{ | |||
JUCE_MOUSE_EVENT_DBG ("wheel") | |||
comp.internalMouseWheel (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, wheel); | |||
} | |||
void sendMagnifyGesture (Component& comp, Point<int> screenPos, Time time, const float amount) | |||
void sendMagnifyGesture (Component& comp, Point<float> screenPos, Time time, const float amount) | |||
{ | |||
JUCE_MOUSE_EVENT_DBG ("magnify") | |||
comp.internalMagnifyGesture (MouseInputSource (this), screenPosToLocalPos (comp, screenPos), time, amount); | |||
@@ -159,7 +161,7 @@ public: | |||
//============================================================================== | |||
// (returns true if the button change caused a modal event loop) | |||
bool setButtons (Point<int> screenPos, Time time, const ModifierKeys newButtonState) | |||
bool setButtons (Point<float> screenPos, Time time, const ModifierKeys newButtonState) | |||
{ | |||
if (buttonState == newButtonState) | |||
return false; | |||
@@ -209,7 +211,7 @@ public: | |||
return lastCounter != mouseEventCounter; | |||
} | |||
void setComponentUnderMouse (Component* const newComponent, Point<int> screenPos, Time time) | |||
void setComponentUnderMouse (Component* const newComponent, Point<float> screenPos, Time time) | |||
{ | |||
Component* current = getComponentUnderMouse(); | |||
@@ -242,7 +244,7 @@ public: | |||
} | |||
} | |||
void setPeer (ComponentPeer& newPeer, Point<int> screenPos, Time time) | |||
void setPeer (ComponentPeer& newPeer, Point<float> screenPos, Time time) | |||
{ | |||
ModifierKeys::updateCurrentModifiers(); | |||
@@ -254,7 +256,7 @@ public: | |||
} | |||
} | |||
void setScreenPos (Point<int> newScreenPos, Time time, const bool forceUpdate) | |||
void setScreenPos (Point<float> newScreenPos, Time time, const bool forceUpdate) | |||
{ | |||
if (! isDragging()) | |||
setComponentUnderMouse (findComponentAt (newScreenPos), newScreenPos, time); | |||
@@ -285,11 +287,11 @@ public: | |||
} | |||
//============================================================================== | |||
void handleEvent (ComponentPeer& newPeer, Point<int> positionWithinPeer, Time time, const ModifierKeys newMods) | |||
void handleEvent (ComponentPeer& newPeer, Point<float> positionWithinPeer, Time time, const ModifierKeys newMods) | |||
{ | |||
lastTime = time; | |||
++mouseEventCounter; | |||
const Point<int> screenPos (newPeer.localToGlobal (positionWithinPeer)); | |||
const Point<float> screenPos (newPeer.localToGlobal (positionWithinPeer)); | |||
if (isDragging() && newMods.isAnyMouseButtonDown()) | |||
{ | |||
@@ -311,8 +313,8 @@ public: | |||
} | |||
} | |||
Component* getTargetForGesture (ComponentPeer& peer, Point<int> positionWithinPeer, | |||
Time time, Point<int>& screenPos) | |||
Component* getTargetForGesture (ComponentPeer& peer, Point<float> positionWithinPeer, | |||
Time time, Point<float>& screenPos) | |||
{ | |||
lastTime = time; | |||
++mouseEventCounter; | |||
@@ -325,27 +327,27 @@ public: | |||
return isDragging() ? nullptr : getComponentUnderMouse(); | |||
} | |||
void handleWheel (ComponentPeer& peer, Point<int> positionWithinPeer, | |||
void handleWheel (ComponentPeer& peer, Point<float> positionWithinPeer, | |||
Time time, const MouseWheelDetails& wheel) | |||
{ | |||
Desktop::getInstance().incrementMouseWheelCounter(); | |||
Point<int> screenPos; | |||
Point<float> screenPos; | |||
if (Component* current = getTargetForGesture (peer, positionWithinPeer, time, screenPos)) | |||
sendMouseWheel (*current, screenPos, time, wheel); | |||
} | |||
void handleMagnifyGesture (ComponentPeer& peer, Point<int> positionWithinPeer, | |||
void handleMagnifyGesture (ComponentPeer& peer, Point<float> positionWithinPeer, | |||
Time time, const float scaleFactor) | |||
{ | |||
Point<int> screenPos; | |||
Point<float> screenPos; | |||
if (Component* current = getTargetForGesture (peer, positionWithinPeer, time, screenPos)) | |||
sendMagnifyGesture (*current, screenPos, time, scaleFactor); | |||
} | |||
//============================================================================== | |||
Time getLastMouseDownTime() const noexcept { return mouseDowns[0].time; } | |||
Point<int> getLastMouseDownPosition() const noexcept { return ScalingHelpers::unscaledScreenPosToScaled (mouseDowns[0].position); } | |||
Point<float> getLastMouseDownPosition() const noexcept { return ScalingHelpers::unscaledScreenPosToScaled (mouseDowns[0].position); } | |||
int getNumberOfMultipleClicks() const noexcept | |||
{ | |||
@@ -397,12 +399,11 @@ public: | |||
{ | |||
// when released, return the mouse to within the component's bounds | |||
if (Component* current = getComponentUnderMouse()) | |||
Desktop::setMousePosition (current->getScreenBounds() | |||
.getConstrainedPoint (lastScreenPos)); | |||
setScreenPosition (current->getScreenBounds().toFloat().getConstrainedPoint (lastScreenPos)); | |||
} | |||
isUnboundedMouseModeOn = enable; | |||
unboundedMouseOffset = Point<int>(); | |||
unboundedMouseOffset = Point<float>(); | |||
revealCursor (true); | |||
} | |||
@@ -410,20 +411,20 @@ public: | |||
void handleUnboundedDrag (Component* current) | |||
{ | |||
const Rectangle<int> screenArea (current->getParentMonitorArea().expanded (-2, -2)); | |||
const Rectangle<float> screenArea (current->getParentMonitorArea().expanded (-2, -2).toFloat()); | |||
if (! screenArea.contains (lastScreenPos)) | |||
{ | |||
const Point<int> componentCentre (current->getScreenBounds().getCentre()); | |||
const Point<float> componentCentre (current->getScreenBounds().toFloat().getCentre()); | |||
unboundedMouseOffset += (lastScreenPos - componentCentre); | |||
Desktop::setMousePosition (componentCentre); | |||
setScreenPosition (componentCentre); | |||
} | |||
else if (isCursorVisibleUntilOffscreen | |||
&& (! unboundedMouseOffset.isOrigin()) | |||
&& screenArea.contains (lastScreenPos + unboundedMouseOffset)) | |||
{ | |||
Desktop::setMousePosition (lastScreenPos + unboundedMouseOffset); | |||
unboundedMouseOffset = Point<int>(); | |||
setScreenPosition (lastScreenPos + unboundedMouseOffset); | |||
unboundedMouseOffset = Point<float>(); | |||
} | |||
} | |||
@@ -461,10 +462,10 @@ public: | |||
//============================================================================== | |||
const int index; | |||
const bool isMouseDevice; | |||
Point<int> lastScreenPos; | |||
Point<float> lastScreenPos; | |||
ModifierKeys buttonState; | |||
Point<int> unboundedMouseOffset; | |||
Point<float> unboundedMouseOffset; | |||
bool isUnboundedMouseModeOn, isCursorVisibleUntilOffscreen; | |||
private: | |||
@@ -478,7 +479,7 @@ private: | |||
{ | |||
RecentMouseDown() noexcept : peerID (0) {} | |||
Point<int> position; | |||
Point<float> position; | |||
Time time; | |||
ModifierKeys buttons; | |||
uint32 peerID; | |||
@@ -497,7 +498,7 @@ private: | |||
Time lastTime; | |||
bool mouseMovedSignificantlySincePressed; | |||
void registerMouseDown (Point<int> screenPos, Time time, | |||
void registerMouseDown (Point<float> screenPos, Time time, | |||
Component& component, const ModifierKeys modifiers) noexcept | |||
{ | |||
for (int i = numElementsInArray (mouseDowns); --i > 0;) | |||
@@ -515,7 +516,7 @@ private: | |||
mouseMovedSignificantlySincePressed = false; | |||
} | |||
void registerMouseDrag (Point<int> screenPos) noexcept | |||
void registerMouseDrag (Point<float> screenPos) noexcept | |||
{ | |||
mouseMovedSignificantlySincePressed = mouseMovedSignificantlySincePressed | |||
|| mouseDowns[0].position.getDistanceFrom (screenPos) >= 4; | |||
@@ -535,47 +536,44 @@ MouseInputSource& MouseInputSource::operator= (const MouseInputSource& other) no | |||
return *this; | |||
} | |||
bool MouseInputSource::isMouse() const { return pimpl->isMouseDevice; } | |||
bool MouseInputSource::isTouch() const { return ! isMouse(); } | |||
bool MouseInputSource::canHover() const { return isMouse(); } | |||
bool MouseInputSource::hasMouseWheel() const { return isMouse(); } | |||
int MouseInputSource::getIndex() const { return pimpl->index; } | |||
bool MouseInputSource::isDragging() const { return pimpl->isDragging(); } | |||
Point<int> MouseInputSource::getScreenPosition() const { return pimpl->getScreenPosition(); } | |||
ModifierKeys MouseInputSource::getCurrentModifiers() const { return pimpl->getCurrentModifiers(); } | |||
Component* MouseInputSource::getComponentUnderMouse() const { return pimpl->getComponentUnderMouse(); } | |||
void MouseInputSource::triggerFakeMove() const { pimpl->triggerFakeMove(); } | |||
int MouseInputSource::getNumberOfMultipleClicks() const noexcept { return pimpl->getNumberOfMultipleClicks(); } | |||
Time MouseInputSource::getLastMouseDownTime() const noexcept { return pimpl->getLastMouseDownTime(); } | |||
Point<int> MouseInputSource::getLastMouseDownPosition() const noexcept { return pimpl->getLastMouseDownPosition(); } | |||
bool MouseInputSource::isMouse() const { return pimpl->isMouseDevice; } | |||
bool MouseInputSource::isTouch() const { return ! isMouse(); } | |||
bool MouseInputSource::canHover() const { return isMouse(); } | |||
bool MouseInputSource::hasMouseWheel() const { return isMouse(); } | |||
int MouseInputSource::getIndex() const { return pimpl->index; } | |||
bool MouseInputSource::isDragging() const { return pimpl->isDragging(); } | |||
Point<float> MouseInputSource::getScreenPosition() const { return pimpl->getScreenPosition(); } | |||
ModifierKeys MouseInputSource::getCurrentModifiers() const { return pimpl->getCurrentModifiers(); } | |||
Component* MouseInputSource::getComponentUnderMouse() const { return pimpl->getComponentUnderMouse(); } | |||
void MouseInputSource::triggerFakeMove() const { pimpl->triggerFakeMove(); } | |||
int MouseInputSource::getNumberOfMultipleClicks() const noexcept { return pimpl->getNumberOfMultipleClicks(); } | |||
Time MouseInputSource::getLastMouseDownTime() const noexcept { return pimpl->getLastMouseDownTime(); } | |||
Point<float> MouseInputSource::getLastMouseDownPosition() const noexcept { return pimpl->getLastMouseDownPosition(); } | |||
bool MouseInputSource::hasMouseMovedSignificantlySincePressed() const noexcept { return pimpl->hasMouseMovedSignificantlySincePressed(); } | |||
bool MouseInputSource::canDoUnboundedMovement() const noexcept { return isMouse(); } | |||
bool MouseInputSource::canDoUnboundedMovement() const noexcept { return isMouse(); } | |||
void MouseInputSource::enableUnboundedMouseMovement (bool isEnabled, bool keepCursorVisibleUntilOffscreen) const | |||
{ pimpl->enableUnboundedMouseMovement (isEnabled, keepCursorVisibleUntilOffscreen); } | |||
bool MouseInputSource::isUnboundedMouseMovementEnabled() const { return pimpl->isUnboundedMouseModeOn; } | |||
bool MouseInputSource::hasMouseCursor() const noexcept { return isMouse(); } | |||
void MouseInputSource::showMouseCursor (const MouseCursor& cursor) { pimpl->showMouseCursor (cursor, false); } | |||
void MouseInputSource::hideCursor() { pimpl->hideCursor(); } | |||
void MouseInputSource::revealCursor() { pimpl->revealCursor (false); } | |||
void MouseInputSource::forceMouseCursorUpdate() { pimpl->revealCursor (true); } | |||
void MouseInputSource::setScreenPosition (Point<int> p) { pimpl->setScreenPosition (p); } | |||
void MouseInputSource::handleEvent (ComponentPeer& peer, Point<int> positionWithinPeer, | |||
const int64 time, const ModifierKeys mods) | |||
{ pimpl->enableUnboundedMouseMovement (isEnabled, keepCursorVisibleUntilOffscreen); } | |||
bool MouseInputSource::isUnboundedMouseMovementEnabled() const { return pimpl->isUnboundedMouseModeOn; } | |||
bool MouseInputSource::hasMouseCursor() const noexcept { return isMouse(); } | |||
void MouseInputSource::showMouseCursor (const MouseCursor& cursor) { pimpl->showMouseCursor (cursor, false); } | |||
void MouseInputSource::hideCursor() { pimpl->hideCursor(); } | |||
void MouseInputSource::revealCursor() { pimpl->revealCursor (false); } | |||
void MouseInputSource::forceMouseCursorUpdate() { pimpl->revealCursor (true); } | |||
void MouseInputSource::setScreenPosition (Point<float> p) { pimpl->setScreenPosition (p); } | |||
void MouseInputSource::handleEvent (ComponentPeer& peer, Point<float> pos, int64 time, ModifierKeys mods) | |||
{ | |||
pimpl->handleEvent (peer, positionWithinPeer, Time (time), mods.withOnlyMouseButtons()); | |||
pimpl->handleEvent (peer, pos, Time (time), mods.withOnlyMouseButtons()); | |||
} | |||
void MouseInputSource::handleWheel (ComponentPeer& peer, Point<int> positionWithinPeer, | |||
const int64 time, const MouseWheelDetails& wheel) | |||
void MouseInputSource::handleWheel (ComponentPeer& peer, Point<float> pos, int64 time, const MouseWheelDetails& wheel) | |||
{ | |||
pimpl->handleWheel (peer, positionWithinPeer, Time (time), wheel); | |||
pimpl->handleWheel (peer, pos, Time (time), wheel); | |||
} | |||
void MouseInputSource::handleMagnifyGesture (ComponentPeer& peer, Point<int> positionWithinPeer, | |||
const int64 time, const float scaleFactor) | |||
void MouseInputSource::handleMagnifyGesture (ComponentPeer& peer, Point<float> pos, int64 time, float scaleFactor) | |||
{ | |||
pimpl->handleMagnifyGesture (peer, positionWithinPeer, Time (time), scaleFactor); | |||
pimpl->handleMagnifyGesture (peer, pos, Time (time), scaleFactor); | |||
} | |||
//============================================================================== | |||
@@ -88,7 +88,7 @@ public: | |||
bool isDragging() const; | |||
/** Returns the last-known screen position of this source. */ | |||
Point<int> getScreenPosition() const; | |||
Point<float> getScreenPosition() const; | |||
/** Returns a set of modifiers that indicate which buttons are currently | |||
held down on this device. | |||
@@ -114,7 +114,7 @@ public: | |||
Time getLastMouseDownTime() const noexcept; | |||
/** Returns the screen position at which the last mouse-down occurred. */ | |||
Point<int> getLastMouseDownPosition() const noexcept; | |||
Point<float> getLastMouseDownPosition() const noexcept; | |||
/** Returns true if this mouse is currently down, and if it has been dragged more | |||
than a couple of pixels from the place it was pressed. | |||
@@ -162,7 +162,7 @@ public: | |||
bool isUnboundedMouseMovementEnabled() const; | |||
/** Attempts to set this mouse pointer's screen position. */ | |||
void setScreenPosition (Point<int> newPosition); | |||
void setScreenPosition (Point<float> newPosition); | |||
private: | |||
//============================================================================== | |||
@@ -174,12 +174,12 @@ private: | |||
struct SourceList; | |||
explicit MouseInputSource (MouseInputSourceInternal*) noexcept; | |||
void handleEvent (ComponentPeer&, Point<int>, int64 time, const ModifierKeys); | |||
void handleWheel (ComponentPeer&, Point<int>, int64 time, const MouseWheelDetails&); | |||
void handleMagnifyGesture (ComponentPeer&, Point<int>, int64 time, float scaleFactor); | |||
void handleEvent (ComponentPeer&, Point<float>, int64 time, ModifierKeys); | |||
void handleWheel (ComponentPeer&, Point<float>, int64 time, const MouseWheelDetails&); | |||
void handleMagnifyGesture (ComponentPeer&, Point<float>, int64 time, float scaleFactor); | |||
static Point<int> getCurrentRawMousePosition(); | |||
static void setRawMousePosition (Point<int>); | |||
static Point<float> getCurrentRawMousePosition(); | |||
static void setRawMousePosition (Point<float>); | |||
JUCE_LEAK_DETECTOR (MouseInputSource) | |||
}; | |||
@@ -234,14 +234,14 @@ public: | |||
view.callIntMethod (ComponentPeerView.getTop)); | |||
} | |||
Point<int> localToGlobal (Point<int> relativePosition) override | |||
Point<float> localToGlobal (Point<float> relativePosition) override | |||
{ | |||
return relativePosition + getScreenPosition(); | |||
return relativePosition + getScreenPosition().toFloat(); | |||
} | |||
Point<int> globalToLocal (Point<int> screenPosition) override | |||
Point<float> globalToLocal (Point<float> screenPosition) override | |||
{ | |||
return screenPosition - getScreenPosition(); | |||
return screenPosition - getScreenPosition().toFloat(); | |||
} | |||
void setMinimised (bool shouldBeMinimised) override | |||
@@ -320,7 +320,7 @@ public: | |||
lastMousePos = pos; | |||
// this forces a mouse-enter/up event, in case for some reason we didn't get a mouse-up before. | |||
handleMouseEvent (index, pos.toInt(), currentModifiers.withoutMouseButtons(), time); | |||
handleMouseEvent (index, pos, currentModifiers.withoutMouseButtons(), time); | |||
if (isValidPeer (this)) | |||
handleMouseDragCallback (index, pos, time); | |||
@@ -333,8 +333,8 @@ public: | |||
jassert (index < 64); | |||
touchesDown = (touchesDown | (1 << (index & 63))); | |||
currentModifiers = currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::leftButtonModifier); | |||
handleMouseEvent (index, pos.toInt(), currentModifiers.withoutMouseButtons() | |||
.withFlags (ModifierKeys::leftButtonModifier), time); | |||
handleMouseEvent (index, pos, currentModifiers.withoutMouseButtons() | |||
.withFlags (ModifierKeys::leftButtonModifier), time); | |||
} | |||
void handleMouseUpCallback (int index, Point<float> pos, int64 time) | |||
@@ -347,7 +347,7 @@ public: | |||
if (touchesDown == 0) | |||
currentModifiers = currentModifiers.withoutMouseButtons(); | |||
handleMouseEvent (index, pos.toInt(), currentModifiers.withoutMouseButtons(), time); | |||
handleMouseEvent (index, pos, currentModifiers.withoutMouseButtons(), time); | |||
} | |||
void handleKeyDownCallback (int k, int kc) | |||
@@ -611,12 +611,12 @@ bool MouseInputSource::SourceList::addSource() | |||
return true; | |||
} | |||
Point<int> MouseInputSource::getCurrentRawMousePosition() | |||
Point<float> MouseInputSource::getCurrentRawMousePosition() | |||
{ | |||
return AndroidComponentPeer::lastMousePos.toInt(); | |||
return AndroidComponentPeer::lastMousePos; | |||
} | |||
void MouseInputSource::setRawMousePosition (Point<int>) | |||
void MouseInputSource::setRawMousePosition (Point<float>) | |||
{ | |||
// not needed | |||
} | |||
@@ -145,8 +145,8 @@ public: | |||
Rectangle<int> getBounds() const override { return getBounds (! isSharedWindow); } | |||
Rectangle<int> getBounds (bool global) const; | |||
Point<int> localToGlobal (Point<int> relativePosition) override; | |||
Point<int> globalToLocal (Point<int> screenPosition) override; | |||
Point<float> localToGlobal (Point<float> relativePosition) override; | |||
Point<float> globalToLocal (Point<float> screenPosition) override; | |||
void setAlpha (float newAlpha) override; | |||
void setMinimised (bool) override {} | |||
bool isMinimised() const override { return false; } | |||
@@ -477,7 +477,7 @@ void ModifierKeys::updateCurrentModifiers() noexcept | |||
currentModifiers = UIViewComponentPeer::currentModifiers; | |||
} | |||
Point<int> juce_lastMousePos; | |||
Point<float> juce_lastMousePos; | |||
//============================================================================== | |||
UIViewComponentPeer::UIViewComponentPeer (Component& comp, const int windowStyleFlags, UIView* viewToAttachTo) | |||
@@ -603,14 +603,14 @@ Rectangle<int> UIViewComponentPeer::getBounds (const bool global) const | |||
return convertToRectInt (r); | |||
} | |||
Point<int> UIViewComponentPeer::localToGlobal (Point<int> relativePosition) | |||
Point<float> UIViewComponentPeer::localToGlobal (Point<float> relativePosition) | |||
{ | |||
return relativePosition + getBounds (true).getPosition(); | |||
return relativePosition + getBounds (true).getPosition().toFloat(); | |||
} | |||
Point<int> UIViewComponentPeer::globalToLocal (Point<int> screenPosition) | |||
Point<float> UIViewComponentPeer::globalToLocal (Point<float> screenPosition) | |||
{ | |||
return screenPosition - getBounds (true).getPosition(); | |||
return screenPosition - getBounds (true).getPosition().toFloat(); | |||
} | |||
void UIViewComponentPeer::setAlpha (float newAlpha) | |||
@@ -737,8 +737,8 @@ void UIViewComponentPeer::handleTouches (UIEvent* event, const bool isDown, cons | |||
continue; | |||
CGPoint p = [touch locationInView: view]; | |||
const Point<int> pos ((int) p.x, (int) p.y); | |||
juce_lastMousePos = pos + getBounds (true).getPosition(); | |||
const Point<float> pos (p.x, p.y); | |||
juce_lastMousePos = pos + getBounds (true).getPosition().toFloat(); | |||
const int64 time = getMouseTime (event); | |||
const int touchIndex = currentTouches.getIndexOfTouch (touch); | |||
@@ -782,7 +782,7 @@ void UIViewComponentPeer::handleTouches (UIEvent* event, const bool isDown, cons | |||
if (isUp || isCancel) | |||
{ | |||
handleMouseEvent (touchIndex, Point<int> (-1, -1), modsToSend, time); | |||
handleMouseEvent (touchIndex, Point<float> (-1.0f, -1.0f), modsToSend, time); | |||
if (! isValidPeer (this)) | |||
return; | |||
} | |||
@@ -312,12 +312,12 @@ bool Desktop::canUseSemiTransparentWindows() noexcept | |||
return true; | |||
} | |||
Point<int> MouseInputSource::getCurrentRawMousePosition() | |||
Point<float> MouseInputSource::getCurrentRawMousePosition() | |||
{ | |||
return juce_lastMousePos; | |||
} | |||
void MouseInputSource::setRawMousePosition (Point<int>) | |||
void MouseInputSource::setRawMousePosition (Point<float>) | |||
{ | |||
} | |||
@@ -971,14 +971,14 @@ public: | |||
Rectangle<int> getBounds() const override { return bounds; } | |||
Point<int> localToGlobal (Point<int> relativePosition) override | |||
Point<float> localToGlobal (Point<float> relativePosition) override | |||
{ | |||
return relativePosition + bounds.getPosition(); | |||
return relativePosition + bounds.getPosition().toFloat(); | |||
} | |||
Point<int> globalToLocal (Point<int> screenPosition) override | |||
Point<float> globalToLocal (Point<float> screenPosition) override | |||
{ | |||
return screenPosition - bounds.getPosition(); | |||
return screenPosition - bounds.getPosition().toFloat(); | |||
} | |||
void setAlpha (float /* newAlpha */) override | |||
@@ -1491,9 +1491,9 @@ public: | |||
} | |||
template <typename EventType> | |||
static Point<int> getMousePos (const EventType& e) noexcept | |||
static Point<float> getMousePos (const EventType& e) noexcept | |||
{ | |||
return Point<int> (e.x, e.y); | |||
return Point<float> ((float) e.x, (float) e.y); | |||
} | |||
void handleWheelEvent (const XButtonPressedEvent& buttonPressEvent, const float amount) | |||
@@ -3123,7 +3123,7 @@ bool Desktop::canUseSemiTransparentWindows() noexcept | |||
&& (matchedDepth == desiredDepth); | |||
} | |||
Point<int> MouseInputSource::getCurrentRawMousePosition() | |||
Point<float> MouseInputSource::getCurrentRawMousePosition() | |||
{ | |||
Window root, child; | |||
int x, y, winx, winy; | |||
@@ -3140,14 +3140,14 @@ Point<int> MouseInputSource::getCurrentRawMousePosition() | |||
x = y = -1; | |||
} | |||
return Point<int> (x, y); | |||
return Point<float> ((float) x, (float) y); | |||
} | |||
void MouseInputSource::setRawMousePosition (Point<int> newPosition) | |||
void MouseInputSource::setRawMousePosition (Point<float> newPosition) | |||
{ | |||
ScopedXLock xlock; | |||
Window root = RootWindow (display, DefaultScreen (display)); | |||
XWarpPointer (display, None, root, 0, 0, 0, 0, newPosition.getX(), newPosition.getY()); | |||
XWarpPointer (display, None, root, 0, 0, 0, 0, roundToInt (newPosition.getX()), roundToInt (newPosition.getY())); | |||
} | |||
double Desktop::getDefaultMasterScale() | |||
@@ -295,14 +295,14 @@ public: | |||
return getBounds (! isSharedWindow); | |||
} | |||
Point<int> localToGlobal (Point<int> relativePosition) override | |||
Point<float> localToGlobal (Point<float> relativePosition) override | |||
{ | |||
return relativePosition + getBounds (true).getPosition(); | |||
return relativePosition + getBounds (true).getPosition().toFloat(); | |||
} | |||
Point<int> globalToLocal (Point<int> screenPosition) override | |||
Point<float> globalToLocal (Point<float> screenPosition) override | |||
{ | |||
return screenPosition - getBounds (true).getPosition(); | |||
return screenPosition - getBounds (true).getPosition().toFloat(); | |||
} | |||
void setAlpha (float newAlpha) override | |||
@@ -559,7 +559,7 @@ public: | |||
belowWindowWithWindowNumber: 0] != [window windowNumber]) | |||
{ | |||
// moved into another window which overlaps this one, so trigger an exit | |||
handleMouseEvent (0, Point<int> (-1, -1), currentModifiers, getMouseTime (ev)); | |||
handleMouseEvent (0, Point<float> (-1.0f, -1.0f), currentModifiers, getMouseTime (ev)); | |||
} | |||
else | |||
#endif | |||
@@ -936,7 +936,7 @@ public: | |||
MouseInputSource mouse = desktop.getMainMouseSource(); | |||
if (mouse.getComponentUnderMouse() == nullptr | |||
&& desktop.findComponentAt (mouse.getScreenPosition()) == nullptr) | |||
&& desktop.findComponentAt (mouse.getScreenPosition().roundToInt()) == nullptr) | |||
{ | |||
[[NSCursor arrowCursor] set]; | |||
} | |||
@@ -1010,10 +1010,10 @@ public: | |||
+ (int64) ([e timestamp] * 1000.0); | |||
} | |||
static Point<int> getMousePos (NSEvent* e, NSView* view) | |||
static Point<float> getMousePos (NSEvent* e, NSView* view) | |||
{ | |||
NSPoint p = [view convertPoint: [e locationInWindow] fromView: nil]; | |||
return Point<int> ((int) p.x, (int) ([view frame].size.height - p.y)); | |||
return Point<float> (p.x, [view frame].size.height - p.y); | |||
} | |||
static int getModifierForButtonNumber (const NSInteger num) | |||
@@ -1136,7 +1136,9 @@ public: | |||
bool isFocused() const override | |||
{ | |||
return this == currentlyFocusedPeer; | |||
return (isSharedWindow || ! JUCEApplication::isStandaloneApp()) | |||
? this == currentlyFocusedPeer | |||
: [window isKeyWindow]; | |||
} | |||
void grabFocus() override | |||
@@ -1686,21 +1688,22 @@ private: | |||
}; | |||
//============================================================================== | |||
struct JuceNSWindowClass : public ObjCClass <NSWindow> | |||
struct JuceNSWindowClass : public ObjCClass<NSWindow> | |||
{ | |||
JuceNSWindowClass() : ObjCClass <NSWindow> ("JUCEWindow_") | |||
JuceNSWindowClass() : ObjCClass<NSWindow> ("JUCEWindow_") | |||
{ | |||
addIvar<NSViewComponentPeer*> ("owner"); | |||
addMethod (@selector (canBecomeKeyWindow), canBecomeKeyWindow, "c@:"); | |||
addMethod (@selector (becomeKeyWindow), becomeKeyWindow, "v@:"); | |||
addMethod (@selector (windowShouldClose:), windowShouldClose, "c@:@"); | |||
addMethod (@selector (constrainFrameRect:toScreen:), constrainFrameRect, @encode (NSRect), "@:", @encode (NSRect), "@"); | |||
addMethod (@selector (windowWillResize:toSize:), windowWillResize, @encode (NSSize), "@:@", @encode (NSSize)); | |||
addMethod (@selector (zoom:), zoom, "v@:@"); | |||
addMethod (@selector (windowWillMove:), windowWillMove, "v@:@"); | |||
addMethod (@selector (canBecomeKeyWindow), canBecomeKeyWindow, "c@:"); | |||
addMethod (@selector (becomeKeyWindow), becomeKeyWindow, "v@:"); | |||
addMethod (@selector (windowShouldClose:), windowShouldClose, "c@:@"); | |||
addMethod (@selector (constrainFrameRect:toScreen:), constrainFrameRect, @encode (NSRect), "@:", @encode (NSRect), "@"); | |||
addMethod (@selector (windowWillResize:toSize:), windowWillResize, @encode (NSSize), "@:@", @encode (NSSize)); | |||
addMethod (@selector (windowDidExitFullScreen:), windowDidExitFullScreen, "v@:@"); | |||
addMethod (@selector (zoom:), zoom, "v@:@"); | |||
addMethod (@selector (windowWillMove:), windowWillMove, "v@:@"); | |||
addMethod (@selector (windowWillStartLiveResize:), windowWillStartLiveResize, "v@:@"); | |||
addMethod (@selector (windowDidEndLiveResize:), windowDidEndLiveResize, "v@:@"); | |||
addMethod (@selector (windowDidEndLiveResize:), windowDidEndLiveResize, "v@:@"); | |||
#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 | |||
addProtocol (@protocol (NSWindowDelegate)); | |||
@@ -1766,6 +1769,11 @@ private: | |||
return frameRect.size; | |||
} | |||
static void windowDidExitFullScreen (id, SEL, NSNotification*) | |||
{ | |||
[NSApp setPresentationOptions: NSApplicationPresentationDefault]; | |||
} | |||
static void zoom (id self, SEL, id sender) | |||
{ | |||
if (NSViewComponentPeer* const owner = getOwner (self)) | |||
@@ -1864,7 +1872,7 @@ bool MouseInputSource::SourceList::addSource() | |||
} | |||
//============================================================================== | |||
void Desktop::setKioskComponent (Component* kioskComp, bool enableOrDisable, bool allowMenusAndBars) | |||
void Desktop::setKioskComponent (Component* kioskComp, bool shouldBeEnabled, bool allowMenusAndBars) | |||
{ | |||
#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 | |||
@@ -1875,13 +1883,15 @@ void Desktop::setKioskComponent (Component* kioskComp, bool enableOrDisable, boo | |||
if (peer->hasNativeTitleBar() | |||
&& [peer->window respondsToSelector: @selector (toggleFullScreen:)]) | |||
{ | |||
[peer->window performSelector: @selector (toggleFullScreen:) | |||
withObject: [NSNumber numberWithBool: (BOOL) enableOrDisable]]; | |||
if (shouldBeEnabled && ! allowMenusAndBars) | |||
[NSApp setPresentationOptions: NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar]; | |||
[peer->window performSelector: @selector (toggleFullScreen:) withObject: nil]; | |||
} | |||
else | |||
#endif | |||
{ | |||
if (enableOrDisable) | |||
if (shouldBeEnabled) | |||
{ | |||
if (peer->hasNativeTitleBar()) | |||
[peer->window setStyleMask: NSBorderlessWindowMask]; | |||
@@ -1903,9 +1913,7 @@ void Desktop::setKioskComponent (Component* kioskComp, bool enableOrDisable, boo | |||
} | |||
} | |||
#elif JUCE_SUPPORT_CARBON | |||
(void) kioskComp; (void) enableOrDisable; (void) allowMenusAndBars; | |||
if (enableOrDisable) | |||
if (shouldBeEnabled) | |||
{ | |||
SetSystemUIMode (kUIModeAllSuppressed, allowMenusAndBars ? kUIOptionAutoShowMenuBar : 0); | |||
kioskComp->setBounds (Desktop::getInstance().getDisplays().getMainDisplay().totalArea); | |||
@@ -1915,7 +1923,7 @@ void Desktop::setKioskComponent (Component* kioskComp, bool enableOrDisable, boo | |||
SetSystemUIMode (kUIModeNormal, 0); | |||
} | |||
#else | |||
(void) kioskComp; (void) enableOrDisable; (void) allowMenusAndBars; | |||
(void) kioskComp; (void) shouldBeEnabled; (void) allowMenusAndBars; | |||
// If you're targeting OSes earlier than 10.6 and want to use this feature, | |||
// you'll need to enable JUCE_SUPPORT_CARBON. | |||
@@ -209,16 +209,16 @@ bool Desktop::canUseSemiTransparentWindows() noexcept | |||
return true; | |||
} | |||
Point<int> MouseInputSource::getCurrentRawMousePosition() | |||
Point<float> MouseInputSource::getCurrentRawMousePosition() | |||
{ | |||
JUCE_AUTORELEASEPOOL | |||
{ | |||
const NSPoint p ([NSEvent mouseLocation]); | |||
return Point<int> (roundToInt (p.x), roundToInt (getMainScreenHeight() - p.y)); | |||
return Point<float> (p.x, getMainScreenHeight() - p.y); | |||
} | |||
} | |||
void MouseInputSource::setRawMousePosition (Point<int> newPosition) | |||
void MouseInputSource::setRawMousePosition (Point<float> newPosition) | |||
{ | |||
// this rubbish needs to be done around the warp call, to avoid causing a | |||
// bizarre glitch.. | |||
@@ -354,6 +354,30 @@ static Rectangle<int> convertDisplayRect (NSRect r, CGFloat mainScreenBottom) | |||
return convertToRectInt (r); | |||
} | |||
static Desktop::Displays::Display getDisplayFromScreen (NSScreen* s, CGFloat& mainScreenBottom, const float masterScale) | |||
{ | |||
Desktop::Displays::Display d; | |||
d.isMain = (mainScreenBottom == 0); | |||
if (d.isMain) | |||
mainScreenBottom = [s frame].size.height; | |||
d.userArea = convertDisplayRect ([s visibleFrame], mainScreenBottom) / masterScale; | |||
d.totalArea = convertDisplayRect ([s frame], mainScreenBottom) / masterScale; | |||
d.scale = masterScale; | |||
#if defined (MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) | |||
if ([s respondsToSelector: @selector (backingScaleFactor)]) | |||
d.scale *= s.backingScaleFactor; | |||
#endif | |||
NSSize dpi = [[[s deviceDescription] objectForKey: NSDeviceResolution] sizeValue]; | |||
d.dpi = (dpi.width + dpi.height) / 2.0; | |||
return d; | |||
} | |||
void Desktop::Displays::findDisplays (const float masterScale) | |||
{ | |||
JUCE_AUTORELEASEPOOL | |||
@@ -363,30 +387,7 @@ void Desktop::Displays::findDisplays (const float masterScale) | |||
CGFloat mainScreenBottom = 0; | |||
for (NSScreen* s in [NSScreen screens]) | |||
{ | |||
Display d; | |||
d.isMain = false; | |||
if (mainScreenBottom == 0) | |||
{ | |||
mainScreenBottom = [s frame].size.height; | |||
d.isMain = true; | |||
} | |||
d.userArea = convertDisplayRect ([s visibleFrame], mainScreenBottom) / masterScale; | |||
d.totalArea = convertDisplayRect ([s frame], mainScreenBottom) / masterScale; | |||
d.scale = masterScale; | |||
#if defined (MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) | |||
if ([s respondsToSelector: @selector (backingScaleFactor)]) | |||
d.scale *= s.backingScaleFactor; | |||
#endif | |||
NSSize dpi = [[[s deviceDescription] objectForKey: NSDeviceResolution] sizeValue]; | |||
d.dpi = (dpi.width + dpi.height) / 2.0; | |||
displays.add (d); | |||
} | |||
displays.add (getDisplayFromScreen (s, mainScreenBottom, masterScale)); | |||
} | |||
} | |||
@@ -704,8 +704,8 @@ public: | |||
r.top + windowBorder.getTop()); | |||
} | |||
Point<int> localToGlobal (Point<int> relativePosition) override { return relativePosition + getScreenPosition(); } | |||
Point<int> globalToLocal (Point<int> screenPosition) override { return screenPosition - getScreenPosition(); } | |||
Point<float> localToGlobal (Point<float> relativePosition) override { return relativePosition + getScreenPosition().toFloat(); } | |||
Point<float> globalToLocal (Point<float> screenPosition) override { return screenPosition - getScreenPosition().toFloat(); } | |||
void setAlpha (float newAlpha) override | |||
{ | |||
@@ -993,7 +993,7 @@ public: | |||
if (ownerInfo == nullptr) | |||
return S_FALSE; | |||
ownerInfo->dragInfo.position = ownerInfo->getMousePos (mousePos); | |||
ownerInfo->dragInfo.position = ownerInfo->getMousePos (mousePos).roundToInt(); | |||
const bool wasWanted = ownerInfo->owner.handleDragMove (ownerInfo->dragInfo); | |||
*pdwEffect = wasWanted ? (DWORD) DROPEFFECT_COPY : (DWORD) DROPEFFECT_NONE; | |||
return S_OK; | |||
@@ -1004,7 +1004,7 @@ public: | |||
HRESULT hr = updateFileList (pDataObject); | |||
if (SUCCEEDED (hr)) | |||
{ | |||
ownerInfo->dragInfo.position = ownerInfo->getMousePos (mousePos); | |||
ownerInfo->dragInfo.position = ownerInfo->getMousePos (mousePos).roundToInt(); | |||
const bool wasWanted = ownerInfo->owner.handleDragDrop (ownerInfo->dragInfo); | |||
*pdwEffect = wasWanted ? (DWORD) DROPEFFECT_COPY : (DWORD) DROPEFFECT_NONE; | |||
hr = S_OK; | |||
@@ -1018,9 +1018,10 @@ public: | |||
{ | |||
OwnerInfo (HWNDComponentPeer& p) : owner (p) {} | |||
Point<int> getMousePos (const POINTL& mousePos) const | |||
Point<float> getMousePos (const POINTL& mousePos) const | |||
{ | |||
return owner.globalToLocal (Point<int> (mousePos.x, mousePos.y)); | |||
return owner.globalToLocal (Point<float> (static_cast<float> (mousePos.x), | |||
static_cast<float> (mousePos.y))); | |||
} | |||
template <typename CharType> | |||
@@ -1648,7 +1649,7 @@ private: | |||
} | |||
//============================================================================== | |||
void doMouseEvent (Point<int> position) | |||
void doMouseEvent (Point<float> position) | |||
{ | |||
handleMouseEvent (0, position, currentModifiers, getMouseEventTime()); | |||
} | |||
@@ -1699,7 +1700,7 @@ private: | |||
return 1000 / 60; // Throttling the incoming mouse-events seems to still be needed in XP.. | |||
} | |||
void doMouseMove (Point<int> position) | |||
void doMouseMove (Point<float> position) | |||
{ | |||
if (! isMouseOver) | |||
{ | |||
@@ -1720,7 +1721,7 @@ private: | |||
} | |||
else if (! isDragging) | |||
{ | |||
if (! contains (position, false)) | |||
if (! contains (position.roundToInt(), false)) | |||
return; | |||
} | |||
@@ -1735,7 +1736,7 @@ private: | |||
} | |||
} | |||
void doMouseDown (Point<int> position, const WPARAM wParam) | |||
void doMouseDown (Point<float> position, const WPARAM wParam) | |||
{ | |||
if (GetCapture() != hwnd) | |||
SetCapture (hwnd); | |||
@@ -1748,7 +1749,7 @@ private: | |||
doMouseEvent (position); | |||
} | |||
void doMouseUp (Point<int> position, const WPARAM wParam) | |||
void doMouseUp (Point<float> position, const WPARAM wParam) | |||
{ | |||
updateModifiersFromWParam (wParam); | |||
const bool wasDragging = isDragging; | |||
@@ -1784,9 +1785,9 @@ private: | |||
doMouseEvent (getCurrentMousePos()); | |||
} | |||
ComponentPeer* findPeerUnderMouse (Point<int>& localPos) | |||
ComponentPeer* findPeerUnderMouse (Point<float>& localPos) | |||
{ | |||
const Point<int> globalPos (getCurrentMousePosGlobal()); | |||
const Point<int> globalPos (getCurrentMousePosGlobal().roundToInt()); | |||
// Because Windows stupidly sends all wheel events to the window with the keyboard | |||
// focus, we have to redirect them here according to the mouse pos.. | |||
@@ -1796,7 +1797,7 @@ private: | |||
if (peer == nullptr) | |||
peer = this; | |||
localPos = peer->globalToLocal (globalPos); | |||
localPos = peer->globalToLocal (globalPos.toFloat()); | |||
return peer; | |||
} | |||
@@ -1811,7 +1812,7 @@ private: | |||
wheel.isReversed = false; | |||
wheel.isSmooth = false; | |||
Point<int> localPos; | |||
Point<float> localPos; | |||
if (ComponentPeer* const peer = findPeerUnderMouse (localPos)) | |||
peer->handleMouseWheel (0, localPos, getMouseEventTime(), wheel); | |||
} | |||
@@ -1825,7 +1826,7 @@ private: | |||
if (getGestureInfo != nullptr && getGestureInfo ((HGESTUREINFO) lParam, &gi)) | |||
{ | |||
updateKeyModifiers(); | |||
Point<int> localPos; | |||
Point<float> localPos; | |||
if (ComponentPeer* const peer = findPeerUnderMouse (localPos)) | |||
{ | |||
@@ -1883,8 +1884,8 @@ private: | |||
bool isCancel = false; | |||
const int touchIndex = currentTouches.getIndexOfTouch (touch.dwID); | |||
const int64 time = getMouseEventTime(); | |||
const Point<int> pos (globalToLocal (Point<int> ((int) TOUCH_COORD_TO_PIXEL (touch.x), | |||
(int) TOUCH_COORD_TO_PIXEL (touch.y)))); | |||
const Point<float> pos (globalToLocal (Point<float> (static_cast<float> (TOUCH_COORD_TO_PIXEL (touch.x)), | |||
static_cast<float> (TOUCH_COORD_TO_PIXEL (touch.y))))); | |||
ModifierKeys modsToSend (currentModifiers); | |||
if (isDown) | |||
@@ -1895,7 +1896,7 @@ private: | |||
if (! isPrimary) | |||
{ | |||
// this forces a mouse-enter/up event, in case for some reason we didn't get a mouse-up before. | |||
handleMouseEvent (touchIndex, pos, modsToSend.withoutMouseButtons(), time); | |||
handleMouseEvent (touchIndex, pos.toFloat(), modsToSend.withoutMouseButtons(), time); | |||
if (! isValidPeer (this)) // (in case this component was deleted by the event) | |||
return false; | |||
} | |||
@@ -1921,14 +1922,14 @@ private: | |||
if (! isPrimary) | |||
{ | |||
handleMouseEvent (touchIndex, pos, modsToSend, time); | |||
handleMouseEvent (touchIndex, pos.toFloat(), modsToSend, time); | |||
if (! isValidPeer (this)) // (in case this component was deleted by the event) | |||
return false; | |||
} | |||
if ((isUp || isCancel) && ! isPrimary) | |||
{ | |||
handleMouseEvent (touchIndex, Point<int> (-10, -10), currentModifiers, time); | |||
handleMouseEvent (touchIndex, Point<float> (-10.0f, -10.0f), currentModifiers, time); | |||
if (! isValidPeer (this)) | |||
return false; | |||
} | |||
@@ -2326,17 +2327,18 @@ private: | |||
return MessageManager::getInstance()->callFunctionOnMessageThread (callback, userData); | |||
} | |||
static Point<int> getPointFromLParam (LPARAM lParam) noexcept | |||
static Point<float> getPointFromLParam (LPARAM lParam) noexcept | |||
{ | |||
return Point<int> (GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam)); | |||
return Point<float> (static_cast<float> (GET_X_LPARAM (lParam)), | |||
static_cast<float> (GET_Y_LPARAM (lParam))); | |||
} | |||
static Point<int> getCurrentMousePosGlobal() noexcept | |||
static Point<float> getCurrentMousePosGlobal() noexcept | |||
{ | |||
return getPointFromLParam (GetMessagePos()); | |||
} | |||
Point<int> getCurrentMousePos() noexcept | |||
Point<float> getCurrentMousePos() noexcept | |||
{ | |||
return globalToLocal (getCurrentMousePosGlobal()); | |||
} | |||
@@ -2417,8 +2419,8 @@ private: | |||
case WM_WINDOWPOSCHANGED: | |||
{ | |||
const Point<int> pos (getCurrentMousePos()); | |||
if (contains (pos, false)) | |||
const Point<float> pos (getCurrentMousePos()); | |||
if (contains (pos.roundToInt(), false)) | |||
doMouseEvent (pos); | |||
} | |||
@@ -3131,16 +3133,17 @@ bool MouseInputSource::SourceList::addSource() | |||
return false; | |||
} | |||
Point<int> MouseInputSource::getCurrentRawMousePosition() | |||
Point<float> MouseInputSource::getCurrentRawMousePosition() | |||
{ | |||
POINT mousePos; | |||
GetCursorPos (&mousePos); | |||
return Point<int> (mousePos.x, mousePos.y); | |||
return Point<float> ((float) mousePos.x, (float) mousePos.y); | |||
} | |||
void MouseInputSource::setRawMousePosition (Point<int> newPosition) | |||
void MouseInputSource::setRawMousePosition (Point<float> newPosition) | |||
{ | |||
SetCursorPos (newPosition.x, newPosition.y); | |||
SetCursorPos (roundToInt (newPosition.x), | |||
roundToInt (newPosition.y)); | |||
} | |||
//============================================================================== | |||
@@ -94,7 +94,7 @@ public: | |||
@param newItemId an associated ID number that can be set or retrieved - see | |||
getSelectedId() and setSelectedId(). Note that this value can not | |||
be 0! | |||
@see setItemEnabled, addSeparator, addSectionHeading, removeItem, getNumItems, getItemText, getItemId | |||
@see setItemEnabled, addSeparator, addSectionHeading, getNumItems, getItemText, getItemId | |||
*/ | |||
void addItem (const String& newItemText, int newItemId); | |||
@@ -142,7 +142,7 @@ public: | |||
If this call causes the content to be cleared, and a change-message | |||
will be broadcast according to the notification parameter. | |||
@see addItem, removeItem, getNumItems | |||
@see addItem, getNumItems | |||
*/ | |||
void clear (NotificationType notification = sendNotificationAsync); | |||
@@ -257,8 +257,11 @@ public: | |||
*/ | |||
void showEditor(); | |||
/** Pops up the combo box's list. */ | |||
void showPopup(); | |||
/** Pops up the combo box's list. | |||
This is virtual so that you can override it with your own custom popup | |||
mechanism if you need some really unusual behaviour. | |||
*/ | |||
virtual void showPopup(); | |||
//============================================================================== | |||
/** | |||
@@ -809,7 +809,7 @@ void ListBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whee | |||
void ListBox::mouseUp (const MouseEvent& e) | |||
{ | |||
if (e.mouseWasClicked() && model != nullptr) | |||
model->backgroundClicked(); | |||
model->backgroundClicked (e); | |||
} | |||
//============================================================================== | |||
@@ -947,7 +947,7 @@ Component* ListBoxModel::refreshComponentForRow (int, bool, Component* existingC | |||
void ListBoxModel::listBoxItemClicked (int, const MouseEvent&) {} | |||
void ListBoxModel::listBoxItemDoubleClicked (int, const MouseEvent&) {} | |||
void ListBoxModel::backgroundClicked() {} | |||
void ListBoxModel::backgroundClicked (const MouseEvent&) {} | |||
void ListBoxModel::selectedRowsChanged (int) {} | |||
void ListBoxModel::deleteKeyPressed (int) {} | |||
void ListBoxModel::returnKeyPressed (int) {} | |||
@@ -84,18 +84,18 @@ public: | |||
/** This can be overridden to react to the user clicking on a row. | |||
@see listBoxItemDoubleClicked | |||
*/ | |||
virtual void listBoxItemClicked (int row, const MouseEvent& e); | |||
virtual void listBoxItemClicked (int row, const MouseEvent&); | |||
/** This can be overridden to react to the user double-clicking on a row. | |||
@see listBoxItemClicked | |||
*/ | |||
virtual void listBoxItemDoubleClicked (int row, const MouseEvent& e); | |||
virtual void listBoxItemDoubleClicked (int row, const MouseEvent&); | |||
/** This can be overridden to react to the user clicking on a part of the list where | |||
there are no rows. | |||
@see listBoxItemClicked | |||
*/ | |||
virtual void backgroundClicked(); | |||
virtual void backgroundClicked (const MouseEvent&); | |||
/** Override this to be informed when rows are selected or deselected. | |||
@@ -152,6 +152,12 @@ public: | |||
/** You can override this to return a custom mouse cursor for each row. */ | |||
virtual MouseCursor getMouseCursorForRow (int row); | |||
private: | |||
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE | |||
// This method's signature has changed to take a MouseEvent parameter - please update your code! | |||
JUCE_DEPRECATED_WITH_BODY (virtual int backgroundClicked(), { return 0; }) | |||
#endif | |||
}; | |||
@@ -745,12 +745,12 @@ public: | |||
|| ((style == LinearHorizontal || style == LinearVertical || style == LinearBar || style == LinearBarVertical) | |||
&& ! snapsToMousePos)) | |||
{ | |||
const int mouseDiff = (style == RotaryHorizontalDrag | |||
|| style == LinearHorizontal | |||
|| style == LinearBar | |||
|| (style == IncDecButtons && incDecDragDirectionIsHorizontal())) | |||
? e.x - mouseDragStartPos.x | |||
: mouseDragStartPos.y - e.y; | |||
const float mouseDiff = (style == RotaryHorizontalDrag | |||
|| style == LinearHorizontal | |||
|| style == LinearBar | |||
|| (style == IncDecButtons && incDecDragDirectionIsHorizontal())) | |||
? e.position.x - mouseDragStartPos.x | |||
: mouseDragStartPos.y - e.position.y; | |||
newPos = owner.valueToProportionOfLength (valueOnMouseDown) | |||
+ mouseDiff * (1.0 / pixelsForFullDragExtent); | |||
@@ -763,7 +763,8 @@ public: | |||
} | |||
else if (style == RotaryHorizontalVerticalDrag) | |||
{ | |||
const int mouseDiff = (e.x - mouseDragStartPos.x) + (mouseDragStartPos.y - e.y); | |||
const float mouseDiff = (e.position.x - mouseDragStartPos.x) | |||
+ (mouseDragStartPos.y - e.position.y); | |||
newPos = owner.valueToProportionOfLength (valueOnMouseDown) | |||
+ mouseDiff * (1.0 / pixelsForFullDragExtent); | |||
@@ -779,13 +780,13 @@ public: | |||
void handleVelocityDrag (const MouseEvent& e) | |||
{ | |||
const int mouseDiff = style == RotaryHorizontalVerticalDrag | |||
? (e.x - mousePosWhenLastDragged.x) + (mousePosWhenLastDragged.y - e.y) | |||
: (isHorizontal() | |||
|| style == RotaryHorizontalDrag | |||
|| (style == IncDecButtons && incDecDragDirectionIsHorizontal())) | |||
? e.x - mousePosWhenLastDragged.x | |||
: e.y - mousePosWhenLastDragged.y; | |||
const float mouseDiff = style == RotaryHorizontalVerticalDrag | |||
? (e.x - mousePosWhenLastDragged.x) + (mousePosWhenLastDragged.y - e.y) | |||
: (isHorizontal() | |||
|| style == RotaryHorizontalDrag | |||
|| (style == IncDecButtons && incDecDragDirectionIsHorizontal())) | |||
? e.position.x - mousePosWhenLastDragged.x | |||
: e.position.y - mousePosWhenLastDragged.y; | |||
const double maxSpeed = jmax (200, sliderRegionSize); | |||
double speed = jlimit (0.0, maxSpeed, (double) abs (mouseDiff)); | |||
@@ -816,7 +817,7 @@ public: | |||
{ | |||
incDecDragged = false; | |||
useDragEvents = false; | |||
mouseDragStartPos = mousePosWhenLastDragged = e.getPosition(); | |||
mouseDragStartPos = mousePosWhenLastDragged = e.position; | |||
currentDrag = nullptr; | |||
if (owner.isEnabled()) | |||
@@ -887,7 +888,7 @@ public: | |||
return; | |||
incDecDragged = true; | |||
mouseDragStartPos = e.getPosition(); | |||
mouseDragStartPos = e.position; | |||
} | |||
if (isAbsoluteDragMode (e.mods) || (maximum - minimum) / sliderRegionSize < interval) | |||
@@ -930,7 +931,7 @@ public: | |||
minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue(); | |||
} | |||
mousePosWhenLastDragged = e.getPosition(); | |||
mousePosWhenLastDragged = e.position; | |||
} | |||
} | |||
@@ -1036,29 +1037,29 @@ public: | |||
const double pos = sliderBeingDragged == 2 ? getMaxValue() | |||
: (sliderBeingDragged == 1 ? getMinValue() | |||
: (double) currentValue.getValue()); | |||
Point<int> mousePos; | |||
Point<float> mousePos; | |||
if (isRotary()) | |||
{ | |||
mousePos = mi->getLastMouseDownPosition(); | |||
const int delta = roundToInt (pixelsForFullDragExtent * (owner.valueToProportionOfLength (valueOnMouseDown) | |||
- owner.valueToProportionOfLength (pos))); | |||
const float delta = (float) (pixelsForFullDragExtent * (owner.valueToProportionOfLength (valueOnMouseDown) | |||
- owner.valueToProportionOfLength (pos))); | |||
if (style == RotaryHorizontalDrag) mousePos += Point<int> (-delta, 0); | |||
else if (style == RotaryVerticalDrag) mousePos += Point<int> (0, delta); | |||
else mousePos += Point<int> (delta / -2, delta / 2); | |||
if (style == RotaryHorizontalDrag) mousePos += Point<float> (-delta, 0.0f); | |||
else if (style == RotaryVerticalDrag) mousePos += Point<float> (0.0f, delta); | |||
else mousePos += Point<float> (delta / -2.0f, delta / 2.0f); | |||
mousePos = owner.getScreenBounds().reduced (4).getConstrainedPoint (mousePos); | |||
mousePos = owner.getScreenBounds().reduced (4).toFloat().getConstrainedPoint (mousePos); | |||
mouseDragStartPos = mousePosWhenLastDragged = owner.getLocalPoint (nullptr, mousePos); | |||
valueOnMouseDown = valueWhenLastDragged; | |||
} | |||
else | |||
{ | |||
const int pixelPos = (int) getLinearSliderPos (pos); | |||
const float pixelPos = (float) getLinearSliderPos (pos); | |||
mousePos = owner.localPointToGlobal (Point<int> (isHorizontal() ? pixelPos : (owner.getWidth() / 2), | |||
isVertical() ? pixelPos : (owner.getHeight() / 2))); | |||
mousePos = owner.localPointToGlobal (Point<float> (isHorizontal() ? pixelPos : (owner.getWidth() / 2.0f), | |||
isVertical() ? pixelPos : (owner.getHeight() / 2.0f))); | |||
} | |||
mi->setScreenPosition (mousePos); | |||
@@ -1231,7 +1232,7 @@ public: | |||
double velocityModeSensitivity, velocityModeOffset, minMaxDiff; | |||
int velocityModeThreshold; | |||
float rotaryStart, rotaryEnd; | |||
Point<int> mouseDragStartPos, mousePosWhenLastDragged; | |||
Point<float> mouseDragStartPos, mousePosWhenLastDragged; | |||
int sliderRegionStart, sliderRegionSize; | |||
int sliderBeingDragged; | |||
int pixelsForFullDragExtent; | |||
@@ -398,10 +398,10 @@ void TableListBox::returnKeyPressed (int row) | |||
model->returnKeyPressed (row); | |||
} | |||
void TableListBox::backgroundClicked() | |||
void TableListBox::backgroundClicked (const MouseEvent& e) | |||
{ | |||
if (model != nullptr) | |||
model->backgroundClicked(); | |||
model->backgroundClicked (e); | |||
} | |||
void TableListBox::listWasScrolled() | |||
@@ -457,7 +457,7 @@ void TableListBox::updateColumnComponents() const | |||
//============================================================================== | |||
void TableListBoxModel::cellClicked (int, int, const MouseEvent&) {} | |||
void TableListBoxModel::cellDoubleClicked (int, int, const MouseEvent&) {} | |||
void TableListBoxModel::backgroundClicked() {} | |||
void TableListBoxModel::backgroundClicked (const MouseEvent&) {} | |||
void TableListBoxModel::sortOrderChanged (int, const bool) {} | |||
int TableListBoxModel::getColumnAutoSizeWidth (int) { return 0; } | |||
void TableListBoxModel::selectedRowsChanged (int) {} | |||
@@ -103,21 +103,21 @@ public: | |||
The mouse event's coordinates will be relative to the entire table row. | |||
@see cellDoubleClicked, backgroundClicked | |||
*/ | |||
virtual void cellClicked (int rowNumber, int columnId, const MouseEvent& e); | |||
virtual void cellClicked (int rowNumber, int columnId, const MouseEvent&); | |||
/** This callback is made when the user clicks on one of the cells in the table. | |||
The mouse event's coordinates will be relative to the entire table row. | |||
@see cellClicked, backgroundClicked | |||
*/ | |||
virtual void cellDoubleClicked (int rowNumber, int columnId, const MouseEvent& e); | |||
virtual void cellDoubleClicked (int rowNumber, int columnId, const MouseEvent&); | |||
/** This can be overridden to react to the user double-clicking on a part of the list where | |||
there are no rows. | |||
@see cellClicked | |||
*/ | |||
virtual void backgroundClicked(); | |||
virtual void backgroundClicked (const MouseEvent&); | |||
//============================================================================== | |||
/** This callback is made when the table's sort order is changed. | |||
@@ -182,6 +182,12 @@ public: | |||
@see getDragSourceCustomData, DragAndDropContainer::startDragging | |||
*/ | |||
virtual var getDragSourceDescription (const SparseSet<int>& currentlySelectedRows); | |||
private: | |||
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE | |||
// This method's signature has changed to take a MouseEvent parameter - please update your code! | |||
JUCE_DEPRECATED_WITH_BODY (virtual int backgroundClicked(), { return 0; }) | |||
#endif | |||
}; | |||
@@ -303,7 +309,7 @@ public: | |||
/** @internal */ | |||
void returnKeyPressed (int currentSelectedRow) override; | |||
/** @internal */ | |||
void backgroundClicked() override; | |||
void backgroundClicked (const MouseEvent&) override; | |||
/** @internal */ | |||
void listWasScrolled() override; | |||
/** @internal */ | |||
@@ -67,7 +67,7 @@ public: | |||
selectBasedOnModifiers (item, e.mods); | |||
if (e.x >= pos.getX()) | |||
item->itemClicked (e.withNewPosition (e.getPosition() - pos.getPosition())); | |||
item->itemClicked (e.withNewPosition (e.position - pos.getPosition().toFloat())); | |||
} | |||
} | |||
} | |||
@@ -92,7 +92,7 @@ public: | |||
Rectangle<int> pos; | |||
if (TreeViewItem* const item = findItemAt (e.y, pos)) | |||
if (e.x >= pos.getX() || ! owner.openCloseButtonsVisible) | |||
item->itemDoubleClicked (e.withNewPosition (e.getPosition() - pos.getPosition())); | |||
item->itemDoubleClicked (e.withNewPosition (e.position - pos.getPosition().toFloat())); | |||
} | |||
} | |||
@@ -85,25 +85,22 @@ bool ComponentPeer::isKioskMode() const | |||
} | |||
//============================================================================== | |||
void ComponentPeer::handleMouseEvent (const int touchIndex, const Point<int> positionWithinPeer, | |||
const ModifierKeys newMods, const int64 time) | |||
void ComponentPeer::handleMouseEvent (int touchIndex, Point<float> pos, ModifierKeys newMods, int64 time) | |||
{ | |||
if (MouseInputSource* mouse = Desktop::getInstance().mouseSources->getOrCreateMouseInputSource (touchIndex)) | |||
MouseInputSource (*mouse).handleEvent (*this, positionWithinPeer, time, newMods); | |||
MouseInputSource (*mouse).handleEvent (*this, pos, time, newMods); | |||
} | |||
void ComponentPeer::handleMouseWheel (const int touchIndex, const Point<int> positionWithinPeer, | |||
const int64 time, const MouseWheelDetails& wheel) | |||
void ComponentPeer::handleMouseWheel (int touchIndex, Point<float> pos, int64 time, const MouseWheelDetails& wheel) | |||
{ | |||
if (MouseInputSource* mouse = Desktop::getInstance().mouseSources->getOrCreateMouseInputSource (touchIndex)) | |||
MouseInputSource (*mouse).handleWheel (*this, positionWithinPeer, time, wheel); | |||
MouseInputSource (*mouse).handleWheel (*this, pos, time, wheel); | |||
} | |||
void ComponentPeer::handleMagnifyGesture (const int touchIndex, const Point<int> positionWithinPeer, | |||
const int64 time, const float scaleFactor) | |||
void ComponentPeer::handleMagnifyGesture (int touchIndex, Point<float> pos, int64 time, float scaleFactor) | |||
{ | |||
if (MouseInputSource* mouse = Desktop::getInstance().mouseSources->getOrCreateMouseInputSource (touchIndex)) | |||
MouseInputSource (*mouse).handleMagnifyGesture (*this, positionWithinPeer, time, scaleFactor); | |||
MouseInputSource (*mouse).handleMagnifyGesture (*this, pos, time, scaleFactor); | |||
} | |||
//============================================================================== | |||
@@ -402,6 +399,9 @@ const Rectangle<int>& ComponentPeer::getNonFullScreenBounds() const noexcept | |||
return lastNonFullscreenBounds; | |||
} | |||
Point<int> ComponentPeer::localToGlobal (Point<int> p) { return localToGlobal (p.toFloat()).roundToInt(); } | |||
Point<int> ComponentPeer::globalToLocal (Point<int> p) { return globalToLocal (p.toFloat()).roundToInt(); } | |||
Rectangle<int> ComponentPeer::localToGlobal (const Rectangle<int>& relativePosition) | |||
{ | |||
return relativePosition.withPosition (localToGlobal (relativePosition.getPosition())); | |||
@@ -148,13 +148,19 @@ public: | |||
virtual Rectangle<int> getBounds() const = 0; | |||
/** Converts a position relative to the top-left of this component to screen coordinates. */ | |||
virtual Point<int> localToGlobal (Point<int> relativePosition) = 0; | |||
virtual Point<float> localToGlobal (Point<float> relativePosition) = 0; | |||
/** Converts a rectangle relative to the top-left of this component to screen coordinates. */ | |||
virtual Rectangle<int> localToGlobal (const Rectangle<int>& relativePosition); | |||
/** Converts a screen coordinate to a position relative to the top-left of this component. */ | |||
virtual Point<float> globalToLocal (Point<float> screenPosition) = 0; | |||
/** Converts a position relative to the top-left of this component to screen coordinates. */ | |||
Point<int> localToGlobal (Point<int> relativePosition); | |||
/** Converts a screen coordinate to a position relative to the top-left of this component. */ | |||
virtual Point<int> globalToLocal (Point<int> screenPosition) = 0; | |||
Point<int> globalToLocal (Point<int> screenPosition); | |||
/** Converts a rectangle relative to the top-left of this component to screen coordinates. */ | |||
virtual Rectangle<int> localToGlobal (const Rectangle<int>& relativePosition); | |||
/** Converts a screen area to a position relative to the top-left of this component. */ | |||
virtual Rectangle<int> globalToLocal (const Rectangle<int>& screenPosition); | |||
@@ -300,9 +306,9 @@ public: | |||
virtual void setAlpha (float newAlpha) = 0; | |||
//============================================================================== | |||
void handleMouseEvent (int touchIndex, const Point<int> positionWithinPeer, const ModifierKeys newMods, int64 time); | |||
void handleMouseWheel (int touchIndex, const Point<int> positionWithinPeer, int64 time, const MouseWheelDetails&); | |||
void handleMagnifyGesture (int touchIndex, const Point<int> positionWithinPeer, int64 time, float scaleFactor); | |||
void handleMouseEvent (int touchIndex, Point<float> positionWithinPeer, ModifierKeys newMods, int64 time); | |||
void handleMouseWheel (int touchIndex, Point<float> positionWithinPeer, int64 time, const MouseWheelDetails&); | |||
void handleMagnifyGesture (int touchIndex, Point<float> positionWithinPeer, int64 time, float scaleFactor); | |||
void handleUserClosingWindow(); | |||
@@ -138,7 +138,7 @@ void TooltipWindow::timerCallback() | |||
mouseClicks = clickCount; | |||
mouseWheelMoves = wheelCount; | |||
const Point<int> mousePos (mouseSource.getScreenPosition()); | |||
const Point<float> mousePos (mouseSource.getScreenPosition()); | |||
const bool mouseMovedQuickly = mousePos.getDistanceFrom (lastMousePos) > 12; | |||
lastMousePos = mousePos; | |||
@@ -159,7 +159,7 @@ void TooltipWindow::timerCallback() | |||
} | |||
else if (tipChanged) | |||
{ | |||
displayTip (mousePos, newTip); | |||
displayTip (mousePos.roundToInt(), newTip); | |||
} | |||
} | |||
else | |||
@@ -170,7 +170,7 @@ void TooltipWindow::timerCallback() | |||
&& newTip != tipShowing | |||
&& now > lastCompChangeTime + (unsigned int) millisecondsBeforeTipAppears) | |||
{ | |||
displayTip (mousePos, newTip); | |||
displayTip (mousePos.roundToInt(), newTip); | |||
} | |||
} | |||
} |
@@ -111,7 +111,7 @@ public: | |||
private: | |||
//============================================================================== | |||
int millisecondsBeforeTipAppears; | |||
Point<int> lastMousePos; | |||
Point<float> lastMousePos; | |||
int mouseClicks, mouseWheelMoves; | |||
unsigned int lastCompChangeTime, lastHideTime; | |||
Component* lastComponentUnderMouse; | |||
@@ -99,21 +99,21 @@ public: | |||
if (isLeft || isRight) // Only mouse up is sent by the OS, so simulate a down/up | |||
{ | |||
owner.mouseDown (MouseEvent (mouseSource, Point<int>(), | |||
owner.mouseDown (MouseEvent (mouseSource, Point<float>(), | |||
eventMods.withFlags (isLeft ? ModifierKeys::leftButtonModifier | |||
: ModifierKeys::rightButtonModifier), | |||
&owner, &owner, now, | |||
Point<int>(), now, 1, false)); | |||
Point<float>(), now, 1, false)); | |||
owner.mouseUp (MouseEvent (mouseSource, Point<int>(), eventMods.withoutMouseButtons(), | |||
owner.mouseUp (MouseEvent (mouseSource, Point<float>(), eventMods.withoutMouseButtons(), | |||
&owner, &owner, now, | |||
Point<int>(), now, 1, false)); | |||
Point<float>(), now, 1, false)); | |||
} | |||
else if (type == NSMouseMoved) | |||
{ | |||
owner.mouseMove (MouseEvent (mouseSource, Point<int>(), eventMods, | |||
owner.mouseMove (MouseEvent (mouseSource, Point<float>(), eventMods, | |||
&owner, &owner, now, | |||
Point<int>(), now, 1, false)); | |||
Point<float>(), now, 1, false)); | |||
} | |||
} | |||
} | |||
@@ -187,7 +187,7 @@ namespace ActiveXHelpers | |||
case WM_MBUTTONUP: | |||
case WM_RBUTTONUP: | |||
peer->handleMouseEvent (0, Point<int> (GET_X_LPARAM (lParam) + activeXRect.left - peerRect.left, | |||
GET_Y_LPARAM (lParam) + activeXRect.top - peerRect.top), | |||
GET_Y_LPARAM (lParam) + activeXRect.top - peerRect.top).toFloat(), | |||
ModifierKeys::getCurrentModifiersRealtime(), | |||
getMouseEventTime()); | |||
break; | |||
@@ -111,8 +111,8 @@ public: | |||
const Time eventTime (getMouseEventTime()); | |||
const MouseEvent e (Desktop::getInstance().getMainMouseSource(), | |||
Point<int>(), eventMods, &owner, &owner, eventTime, | |||
Point<int>(), eventTime, 1, false); | |||
Point<float>(), eventMods, &owner, &owner, eventTime, | |||
Point<float>(), eventTime, 1, false); | |||
if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN) | |||
{ | |||