1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

RTAS mac window position fix. Introjucer fixes for Windows.

This commit is contained in:
Julian Storer 2011-08-23 15:02:11 +01:00
parent 57a0fd5cef
commit d86d68446c
21 changed files with 112 additions and 61 deletions

View file

@ -66,20 +66,22 @@ void* attachSubWindow (void* hostWindowRef, Component* comp)
NSRect hostWindowScreenFrame = [[hostWindow screen] frame];
const int mainScreenHeight = [[[NSScreen screens] objectAtIndex: 0] frame].size.height;
#if WINDOWPOSITION_BODGE
{
Rect winBounds;
GetWindowBounds ((WindowRef) hostWindowRef, kWindowContentRgn, &winBounds);
NSRect w = [hostWindow frame];
w.origin.x = winBounds.left;
w.origin.y = hostWindowScreenFrame.size.height + hostWindowScreenFrame.origin.y - winBounds.bottom;
w.origin.y = mainScreenHeight - winBounds.bottom;
[hostWindow setFrame: w display: NO animate: NO];
}
#endif
NSPoint windowPos = [hostWindow convertBaseToScreen: f.origin];
windowPos.x = windowPos.x + jmax (0.0f, (oldWindowFrame.size.width - f.size.width) / 2.0f);
windowPos.y = hostWindowScreenFrame.size.height + hostWindowScreenFrame.origin.y - (windowPos.y + f.size.height);
windowPos.y = mainScreenHeight - (windowPos.y + f.size.height);
comp->setTopLeftPosition ((int) windowPos.x, (int) windowPos.y);

View file

@ -225,7 +225,7 @@ public:
@param index the index of the element being requested (0 is the first element in the array)
@see getUnchecked, getFirst, getLast
*/
const ElementType operator[] (const int index) const
ElementType operator[] (const int index) const
{
const ScopedLockType lock (getLock());
return isPositiveAndBelow (index, numUsed) ? data.elements [index]
@ -241,7 +241,7 @@ public:
@param index the index of the element being requested (0 is the first element in the array)
@see operator[], getFirst, getLast
*/
inline const ElementType getUnchecked (const int index) const
inline ElementType getUnchecked (const int index) const
{
const ScopedLockType lock (getLock());
jassert (isPositiveAndBelow (index, numUsed));
@ -1022,7 +1022,7 @@ private:
ArrayAllocationBase <ElementType, TypeOfCriticalSectionToUse> data;
int numUsed;
inline void deleteAllElements()
inline void deleteAllElements() noexcept
{
for (int i = 0; i < numUsed; ++i)
data.elements[i].~ElementType();

View file

@ -402,7 +402,7 @@ public:
/** Returns the current item's key.
This should only be called when a call to next() has just returned true.
*/
const KeyType getKey() const
KeyType getKey() const
{
return entry != nullptr ? entry->key : KeyType();
}
@ -410,7 +410,7 @@ public:
/** Returns the current item's value.
This should only be called when a call to next() has just returned true.
*/
const ValueType getValue() const
ValueType getValue() const
{
return entry != nullptr ? entry->value : ValueType();
}

View file

@ -55,6 +55,11 @@ NamedValueSet::NamedValue::NamedValue (NamedValue&& other) noexcept
{
}
inline NamedValueSet::NamedValue::NamedValue (const Identifier& name_, var&& value_)
: name (name_), value (static_cast <var&&> (value_))
{
}
NamedValueSet::NamedValue& NamedValueSet::NamedValue::operator= (NamedValue&& other) noexcept
{
nextListItem = static_cast <LinkedListPointer<NamedValue>&&> (other.nextListItem);
@ -160,6 +165,32 @@ var* NamedValueSet::getVarPointer (const Identifier& name) const noexcept
return nullptr;
}
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
bool NamedValueSet::set (const Identifier& name, var&& newValue)
{
LinkedListPointer<NamedValue>* i = &values;
while (i->get() != nullptr)
{
NamedValue* const v = i->get();
if (v->name == name)
{
if (v->value.equalsWithSameType (newValue))
return false;
v->value = static_cast <var&&> (newValue);
return true;
}
i = &(v->nextListItem);
}
i->insertNext (new NamedValue (name, static_cast <var&&> (newValue)));
return true;
}
#endif
bool NamedValueSet::set (const Identifier& name, const var& newValue)
{
LinkedListPointer<NamedValue>* i = &values;

View file

@ -84,6 +84,14 @@ public:
*/
bool set (const Identifier& name, const var& newValue);
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
/** Changes or adds a named value.
@returns true if a value was changed or added; false if the
value was already set the the value passed-in.
*/
bool set (const Identifier& name, var&& newValue);
#endif
/** Returns true if the set contains an item with the specified name. */
bool contains (const Identifier& name) const;
@ -135,6 +143,7 @@ private:
NamedValue& operator= (const NamedValue&);
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
NamedValue (NamedValue&&) noexcept;
NamedValue (const Identifier& name, var&& value);
NamedValue& operator= (NamedValue&&) noexcept;
#endif
bool operator== (const NamedValue& other) const noexcept;

View file

@ -128,7 +128,7 @@ public:
@see getUnchecked
*/
inline const ObjectClassPtr operator[] (const int index) const noexcept
inline ObjectClassPtr operator[] (const int index) const noexcept
{
const ScopedLockType lock (getLock());
return isPositiveAndBelow (index, numUsed) ? data.elements [index]
@ -140,7 +140,7 @@ public:
This is a faster and less safe version of operator[] which doesn't check the index passed in, so
it can be used when you're sure the index if always going to be legal.
*/
inline const ObjectClassPtr getUnchecked (const int index) const noexcept
inline ObjectClassPtr getUnchecked (const int index) const noexcept
{
const ScopedLockType lock (getLock());
jassert (isPositiveAndBelow (index, numUsed));
@ -152,7 +152,7 @@ public:
This will return a null pointer if the array's empty.
@see getLast
*/
inline const ObjectClassPtr getFirst() const noexcept
inline ObjectClassPtr getFirst() const noexcept
{
const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [0]
@ -164,7 +164,7 @@ public:
This will return a null pointer if the array's empty.
@see getFirst
*/
inline const ObjectClassPtr getLast() const noexcept
inline ObjectClassPtr getLast() const noexcept
{
const ScopedLockType lock (getLock());
return numUsed > 0 ? data.elements [numUsed - 1]
@ -466,7 +466,7 @@ public:
@param indexToRemove the index of the element to remove
@see remove, removeObject, removeRange
*/
const ObjectClassPtr removeAndReturn (const int indexToRemove)
ObjectClassPtr removeAndReturn (const int indexToRemove)
{
ObjectClassPtr removedItem;
const ScopedLockType lock (getLock());

View file

@ -146,7 +146,7 @@ public:
/** Returns the range between the lowest and highest values in the set.
@see getRange
*/
const Range<Type> getTotalRange() const
Range<Type> getTotalRange() const
{
if (values.size() > 0)
{

View file

@ -399,17 +399,17 @@ void var::swapWith (var& other) noexcept
std::swap (value, other.value);
}
const var& var::operator= (const var& v) { type->cleanUp (value); type = v.type; type->createCopy (value, v.value); return *this; }
const var& var::operator= (const int v) { type->cleanUp (value); type = &VariantType_Int::instance; value.intValue = v; return *this; }
const var& var::operator= (const int64 v) { type->cleanUp (value); type = &VariantType_Int64::instance; value.int64Value = v; return *this; }
const var& var::operator= (const bool v) { type->cleanUp (value); type = &VariantType_Bool::instance; value.boolValue = v; return *this; }
const var& var::operator= (const double v) { type->cleanUp (value); type = &VariantType_Double::instance; value.doubleValue = v; return *this; }
const var& var::operator= (const char* const v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
const var& var::operator= (const wchar_t* const v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
const var& var::operator= (const String& v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
const var& var::operator= (const Array<var>& v) { var v2 (v); swapWith (v2); return *this; }
const var& var::operator= (ReferenceCountedObject* v) { var v2 (v); swapWith (v2); return *this; }
const var& var::operator= (MethodFunction v) { var v2 (v); swapWith (v2); return *this; }
var& var::operator= (const var& v) { type->cleanUp (value); type = v.type; type->createCopy (value, v.value); return *this; }
var& var::operator= (const int v) { type->cleanUp (value); type = &VariantType_Int::instance; value.intValue = v; return *this; }
var& var::operator= (const int64 v) { type->cleanUp (value); type = &VariantType_Int64::instance; value.int64Value = v; return *this; }
var& var::operator= (const bool v) { type->cleanUp (value); type = &VariantType_Bool::instance; value.boolValue = v; return *this; }
var& var::operator= (const double v) { type->cleanUp (value); type = &VariantType_Double::instance; value.doubleValue = v; return *this; }
var& var::operator= (const char* const v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
var& var::operator= (const wchar_t* const v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
var& var::operator= (const String& v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
var& var::operator= (const Array<var>& v) { var v2 (v); swapWith (v2); return *this; }
var& var::operator= (ReferenceCountedObject* v) { var v2 (v); swapWith (v2); return *this; }
var& var::operator= (MethodFunction v) { var v2 (v); swapWith (v2); return *this; }
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
var::var (var&& other) noexcept
@ -424,6 +424,19 @@ var& var::operator= (var&& other) noexcept
swapWith (other);
return *this;
}
var::var (String&& value_) : type (&VariantType_String::instance)
{
new (value.stringValue) String (static_cast<String&&> (value_));
}
var& var::operator= (String&& v)
{
type->cleanUp (value);
type = &VariantType_String::instance;
new (value.stringValue) String (static_cast<String&&> (v));
return *this;
}
#endif
//==============================================================================

View file

@ -78,21 +78,23 @@ public:
var (ReferenceCountedObject* object);
var (MethodFunction method) noexcept;
const var& operator= (const var& valueToCopy);
const var& operator= (int value);
const var& operator= (int64 value);
const var& operator= (bool value);
const var& operator= (double value);
const var& operator= (const char* value);
const var& operator= (const wchar_t* value);
const var& operator= (const String& value);
const var& operator= (const Array<var>& value);
const var& operator= (ReferenceCountedObject* object);
const var& operator= (MethodFunction method);
var& operator= (const var& valueToCopy);
var& operator= (int value);
var& operator= (int64 value);
var& operator= (bool value);
var& operator= (double value);
var& operator= (const char* value);
var& operator= (const wchar_t* value);
var& operator= (const String& value);
var& operator= (const Array<var>& value);
var& operator= (ReferenceCountedObject* object);
var& operator= (MethodFunction method);
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
var (var&& other) noexcept;
var (String&& value);
var& operator= (var&& other) noexcept;
var& operator= (String&& value);
#endif
void swapWith (var& other) noexcept;

View file

@ -256,15 +256,7 @@ public:
#if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectPtr&& other)
{
if (this != &other)
{
if (referencedObject != nullptr)
referencedObject->decReferenceCount();
referencedObject = other.referencedObject;
other.referencedObject = nullptr;
}
std::swap (referencedObject, other.referencedObject);
return *this;
}
#endif

View file

@ -53,17 +53,13 @@ public:
//==============================================================================
/** Compares two arrays.
Comparisons are case-sensitive.
@returns true only if the other array contains exactly the same strings with the same keys
*/
bool operator== (const StringPairArray& other) const;
/** Compares two arrays.
Comparisons are case-sensitive.
@returns false if the other array contains exactly the same strings with the same keys
*/
bool operator!= (const StringPairArray& other) const;

View file

@ -51,7 +51,8 @@ void Value::ValueSource::sendChangeMessage (const bool synchronous)
}
else
{
triggerAsyncUpdate();
if (valuesWithListeners.size() > 0)
triggerAsyncUpdate();
}
}

View file

@ -142,8 +142,7 @@ bool MessageManager::postMessageToSystemQueue (Message* message)
return PostMessage (juce_messageWindowHandle, WindowsMessageHelpers::specialId, 0, (LPARAM) message) != 0;
}
void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback,
void* userData)
void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, void* userData)
{
if (MessageManager::getInstance()->isThisTheMessageThread())
{