|
@@ -296,7 +296,6 @@ public: |
|
|
|
|
|
|
|
|
if (isSharedWindow)
|
|
|
if (isSharedWindow)
|
|
|
{
|
|
|
{
|
|
|
r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height);
|
|
|
|
|
|
[view setFrame: r];
|
|
|
[view setFrame: r];
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
else
|
|
@@ -326,10 +325,6 @@ public: |
|
|
|
|
|
|
|
|
flipScreenRect (r);
|
|
|
flipScreenRect (r);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
r.origin.y = [[view superview] frame].size.height - r.origin.y - r.size.height;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return convertToRectInt (r);
|
|
|
return convertToRectInt (r);
|
|
|
}
|
|
|
}
|
|
@@ -437,7 +432,7 @@ public: |
|
|
if (NSWindow* const viewWindow = [view window])
|
|
|
if (NSWindow* const viewWindow = [view window])
|
|
|
{
|
|
|
{
|
|
|
NSRect windowFrame = [viewWindow frame];
|
|
|
NSRect windowFrame = [viewWindow frame];
|
|
|
NSPoint windowPoint = [view convertPoint: NSMakePoint (localPos.x, viewFrame.size.height - localPos.y) toView: nil];
|
|
|
|
|
|
|
|
|
NSPoint windowPoint = [view convertPoint: NSMakePoint (localPos.x, localPos.y) toView: nil];
|
|
|
NSPoint screenPoint = NSMakePoint (windowFrame.origin.x + windowPoint.x,
|
|
|
NSPoint screenPoint = NSMakePoint (windowFrame.origin.x + windowPoint.x,
|
|
|
windowFrame.origin.y + windowPoint.y);
|
|
|
windowFrame.origin.y + windowPoint.y);
|
|
|
|
|
|
|
|
@@ -448,7 +443,7 @@ public: |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
NSView* v = [view hitTest: NSMakePoint (viewFrame.origin.x + localPos.getX(),
|
|
|
NSView* v = [view hitTest: NSMakePoint (viewFrame.origin.x + localPos.getX(),
|
|
|
viewFrame.origin.y + viewFrame.size.height - localPos.getY())];
|
|
|
|
|
|
|
|
|
viewFrame.origin.y + localPos.getY())];
|
|
|
|
|
|
|
|
|
return trueIfInAChildWindow ? (v != nil)
|
|
|
return trueIfInAChildWindow ? (v != nil)
|
|
|
: (v == view);
|
|
|
: (v == view);
|
|
@@ -463,8 +458,8 @@ public: |
|
|
NSRect v = [view convertRect: [view frame] toView: nil];
|
|
|
NSRect v = [view convertRect: [view frame] toView: nil];
|
|
|
NSRect w = [window frame];
|
|
|
NSRect w = [window frame];
|
|
|
|
|
|
|
|
|
b.setTop ((int) (w.size.height - (v.origin.y + v.size.height)));
|
|
|
|
|
|
b.setBottom ((int) v.origin.y);
|
|
|
|
|
|
|
|
|
b.setTop ((int) v.origin.y);
|
|
|
|
|
|
b.setBottom ((int) (w.size.height - (v.origin.y + v.size.height)));
|
|
|
b.setLeft ((int) v.origin.x);
|
|
|
b.setLeft ((int) v.origin.x);
|
|
|
b.setRight ((int) (w.size.width - (v.origin.x + v.size.width)));
|
|
|
b.setRight ((int) (w.size.width - (v.origin.x + v.size.width)));
|
|
|
}
|
|
|
}
|
|
@@ -913,14 +908,14 @@ public: |
|
|
#if USE_COREGRAPHICS_RENDERING
|
|
|
#if USE_COREGRAPHICS_RENDERING
|
|
|
if (usingCoreGraphics)
|
|
|
if (usingCoreGraphics)
|
|
|
{
|
|
|
{
|
|
|
|
|
|
CGContextConcatCTM (cg, CGAffineTransformMake (1, 0, 0, -1, 0, getComponent().getHeight()));
|
|
|
CoreGraphicsContext context (cg, (float) [view frame].size.height);
|
|
|
CoreGraphicsContext context (cg, (float) [view frame].size.height);
|
|
|
invokePaint (context);
|
|
|
|
|
|
|
|
|
handlePaint (context);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
else
|
|
|
#endif
|
|
|
#endif
|
|
|
{
|
|
|
{
|
|
|
const Point<int> offset (-roundToInt (r.origin.x),
|
|
|
|
|
|
-roundToInt ([view frame].size.height - (r.origin.y + r.size.height)));
|
|
|
|
|
|
|
|
|
const Point<int> offset (-roundToInt (r.origin.x), -roundToInt (r.origin.y));
|
|
|
auto clipW = (int) (r.size.width + 0.5f);
|
|
|
auto clipW = (int) (r.size.width + 0.5f);
|
|
|
auto clipH = (int) (r.size.height + 0.5f);
|
|
|
auto clipH = (int) (r.size.height + 0.5f);
|
|
|
|
|
|
|
|
@@ -941,17 +936,18 @@ public: |
|
|
clip.scaleAll (intScale);
|
|
|
clip.scaleAll (intScale);
|
|
|
|
|
|
|
|
|
auto context = component.getLookAndFeel()
|
|
|
auto context = component.getLookAndFeel()
|
|
|
.createGraphicsContext (temp, offset * intScale, clip);
|
|
|
|
|
|
|
|
|
.createGraphicsContext (temp, offset * intScale, clip);
|
|
|
|
|
|
|
|
|
if (intScale != 1)
|
|
|
if (intScale != 1)
|
|
|
context->addTransform (AffineTransform::scale (displayScale));
|
|
|
context->addTransform (AffineTransform::scale (displayScale));
|
|
|
|
|
|
|
|
|
invokePaint (*context);
|
|
|
|
|
|
|
|
|
handlePaint (*context);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
detail::ColorSpacePtr colourSpace { CGColorSpaceCreateWithName (kCGColorSpaceSRGB) };
|
|
|
detail::ColorSpacePtr colourSpace { CGColorSpaceCreateWithName (kCGColorSpaceSRGB) };
|
|
|
CGImageRef image = juce_createCoreGraphicsImage (temp, colourSpace.get(), false);
|
|
|
CGImageRef image = juce_createCoreGraphicsImage (temp, colourSpace.get(), false);
|
|
|
CGContextDrawImage (cg, CGRectMake (r.origin.x, r.origin.y, clipW, clipH), image);
|
|
|
|
|
|
|
|
|
CGContextConcatCTM (cg, CGAffineTransformMake (1, 0, 0, -1, r.origin.x, r.origin.y + clipH));
|
|
|
|
|
|
CGContextDrawImage (cg, CGRectMake (0.0f, 0.0f, clipW, clipH), image);
|
|
|
CGImageRelease (image);
|
|
|
CGImageRelease (image);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -964,7 +960,7 @@ public: |
|
|
// a few when there's a lot of activity.
|
|
|
// a few when there's a lot of activity.
|
|
|
// As a work around for this, we use a RectangleList to do our own coalescing of regions before
|
|
|
// As a work around for this, we use a RectangleList to do our own coalescing of regions before
|
|
|
// asynchronously asking the OS to repaint them.
|
|
|
// asynchronously asking the OS to repaint them.
|
|
|
deferredRepaints.add ((float) area.getX(), (float) ([view frame].size.height - area.getBottom()),
|
|
|
|
|
|
|
|
|
deferredRepaints.add ((float) area.getX(), (float) area.getY(),
|
|
|
(float) area.getWidth(), (float) area.getHeight());
|
|
|
(float) area.getWidth(), (float) area.getHeight());
|
|
|
|
|
|
|
|
|
if (isTimerRunning())
|
|
|
if (isTimerRunning())
|
|
@@ -1008,11 +1004,6 @@ public: |
|
|
deferredRepaints.clear();
|
|
|
deferredRepaints.clear();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void invokePaint (LowLevelGraphicsContext& context)
|
|
|
|
|
|
{
|
|
|
|
|
|
handlePaint (context);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void performAnyPendingRepaintsNow() override
|
|
|
void performAnyPendingRepaintsNow() override
|
|
|
{
|
|
|
{
|
|
|
[view displayIfNeeded];
|
|
|
[view displayIfNeeded];
|
|
@@ -1320,7 +1311,7 @@ public: |
|
|
static Point<float> getMousePos (NSEvent* e, NSView* view)
|
|
|
static Point<float> getMousePos (NSEvent* e, NSView* view)
|
|
|
{
|
|
|
{
|
|
|
NSPoint p = [view convertPoint: [e locationInWindow] fromView: nil];
|
|
|
NSPoint p = [view convertPoint: [e locationInWindow] fromView: nil];
|
|
|
return { (float) p.x, (float) ([view frame].size.height - p.y) };
|
|
|
|
|
|
|
|
|
return { (float) p.x, (float) p.y };
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
static int getModifierForButtonNumber (const NSInteger num)
|
|
|
static int getModifierForButtonNumber (const NSInteger num)
|
|
@@ -1356,7 +1347,7 @@ public: |
|
|
|
|
|
|
|
|
NSPoint p = [view convertPoint: [sender draggingLocation] fromView: nil];
|
|
|
NSPoint p = [view convertPoint: [sender draggingLocation] fromView: nil];
|
|
|
ComponentPeer::DragInfo dragInfo;
|
|
|
ComponentPeer::DragInfo dragInfo;
|
|
|
dragInfo.position.setXY ((int) p.x, (int) ([view frame].size.height - p.y));
|
|
|
|
|
|
|
|
|
dragInfo.position.setXY ((int) p.x, (int) p.y);
|
|
|
|
|
|
|
|
|
if (contentType == NSPasteboardTypeString)
|
|
|
if (contentType == NSPasteboardTypeString)
|
|
|
dragInfo.text = nsStringToJuce ([pasteboard stringForType: NSPasteboardTypeString]);
|
|
|
dragInfo.text = nsStringToJuce ([pasteboard stringForType: NSPasteboardTypeString]);
|
|
@@ -1522,13 +1513,12 @@ private: |
|
|
[view getRectsBeingDrawn: &rects count: &numRects];
|
|
|
[view getRectsBeingDrawn: &rects count: &numRects];
|
|
|
|
|
|
|
|
|
const Rectangle<int> clipBounds (clipW, clipH);
|
|
|
const Rectangle<int> clipBounds (clipW, clipH);
|
|
|
auto viewH = [view frame].size.height;
|
|
|
|
|
|
|
|
|
|
|
|
clip.ensureStorageAllocated ((int) numRects);
|
|
|
clip.ensureStorageAllocated ((int) numRects);
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numRects; ++i)
|
|
|
for (int i = 0; i < numRects; ++i)
|
|
|
clip.addWithoutMerging (clipBounds.getIntersection (Rectangle<int> (roundToInt (rects[i].origin.x) + offset.x,
|
|
|
clip.addWithoutMerging (clipBounds.getIntersection (Rectangle<int> (roundToInt (rects[i].origin.x) + offset.x,
|
|
|
roundToInt (viewH - (rects[i].origin.y + rects[i].size.height)) + offset.y,
|
|
|
|
|
|
|
|
|
roundToInt (rects[i].origin.y) + offset.y,
|
|
|
roundToInt (rects[i].size.width),
|
|
|
roundToInt (rects[i].size.width),
|
|
|
roundToInt (rects[i].size.height))));
|
|
|
roundToInt (rects[i].size.height))));
|
|
|
}
|
|
|
}
|
|
@@ -1741,6 +1731,8 @@ struct JuceNSViewClass : public ObjCClass<NSView> |
|
|
addMethod (@selector (cut:), cut, "v@:@");
|
|
|
addMethod (@selector (cut:), cut, "v@:@");
|
|
|
addMethod (@selector (selectAll:), selectAll, "v@:@");
|
|
|
addMethod (@selector (selectAll:), selectAll, "v@:@");
|
|
|
|
|
|
|
|
|
|
|
|
addMethod (@selector (isFlipped), isFlipped, "c@:");
|
|
|
|
|
|
|
|
|
addMethod (NSViewComponentPeer::dismissModalsSelector, dismissModals, "v@:");
|
|
|
addMethod (NSViewComponentPeer::dismissModalsSelector, dismissModals, "v@:");
|
|
|
addMethod (NSViewComponentPeer::asyncMouseDownSelector, asyncMouseDown, "v@:@");
|
|
|
addMethod (NSViewComponentPeer::asyncMouseDownSelector, asyncMouseDown, "v@:@");
|
|
|
addMethod (NSViewComponentPeer::asyncMouseUpSelector, asyncMouseUp, "v@:@");
|
|
|
addMethod (NSViewComponentPeer::asyncMouseUpSelector, asyncMouseUp, "v@:@");
|
|
@@ -1816,6 +1808,8 @@ private: |
|
|
static void dismissModals (id self, SEL) { if (auto* p = getOwner (self)) p->dismissModals(); }
|
|
|
static void dismissModals (id self, SEL) { if (auto* p = getOwner (self)) p->dismissModals(); }
|
|
|
static void becomeKey (id self, SEL) { if (auto* p = getOwner (self)) p->becomeKey(); }
|
|
|
static void becomeKey (id self, SEL) { if (auto* p = getOwner (self)) p->becomeKey(); }
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL isFlipped (id, SEL) { return true; }
|
|
|
|
|
|
|
|
|
static void viewWillDraw (id self, SEL)
|
|
|
static void viewWillDraw (id self, SEL)
|
|
|
{
|
|
|
{
|
|
|
// Without setting contentsFormat macOS Big Sur will always set the invalid area
|
|
|
// Without setting contentsFormat macOS Big Sur will always set the invalid area
|
|
@@ -2099,6 +2093,7 @@ struct JuceNSWindowClass : public ObjCClass<NSWindow> |
|
|
addMethod (@selector (windowWillStartLiveResize:), windowWillStartLiveResize, "v@:@");
|
|
|
addMethod (@selector (windowWillStartLiveResize:), windowWillStartLiveResize, "v@:@");
|
|
|
addMethod (@selector (windowDidEndLiveResize:), windowDidEndLiveResize, "v@:@");
|
|
|
addMethod (@selector (windowDidEndLiveResize:), windowDidEndLiveResize, "v@:@");
|
|
|
addMethod (@selector (window:shouldPopUpDocumentPathMenu:), shouldPopUpPathMenu, "B@:@", @encode (NSMenu*));
|
|
|
addMethod (@selector (window:shouldPopUpDocumentPathMenu:), shouldPopUpPathMenu, "B@:@", @encode (NSMenu*));
|
|
|
|
|
|
addMethod (@selector (isFlipped), isFlipped, "c@:");
|
|
|
|
|
|
|
|
|
addMethod (@selector (window:shouldDragDocumentWithEvent:from:withPasteboard:),
|
|
|
addMethod (@selector (window:shouldDragDocumentWithEvent:from:withPasteboard:),
|
|
|
shouldAllowIconDrag, "B@:@", @encode (NSEvent*), @encode (NSPoint), @encode (NSPasteboard*));
|
|
|
shouldAllowIconDrag, "B@:@", @encode (NSEvent*), @encode (NSPoint), @encode (NSPasteboard*));
|
|
@@ -2115,6 +2110,8 @@ private: |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
//==============================================================================
|
|
|
|
|
|
static BOOL isFlipped (id, SEL) { return true; }
|
|
|
|
|
|
|
|
|
static BOOL canBecomeKeyWindow (id self, SEL)
|
|
|
static BOOL canBecomeKeyWindow (id self, SEL)
|
|
|
{
|
|
|
{
|
|
|
auto* owner = getOwner (self);
|
|
|
auto* owner = getOwner (self);
|
|
@@ -2186,7 +2183,6 @@ private: |
|
|
return proposedFrameSize;
|
|
|
return proposedFrameSize;
|
|
|
|
|
|
|
|
|
NSRect frameRect = [(NSWindow*) self frame];
|
|
|
NSRect frameRect = [(NSWindow*) self frame];
|
|
|
frameRect.origin.y -= proposedFrameSize.height - frameRect.size.height;
|
|
|
|
|
|
frameRect.size = proposedFrameSize;
|
|
|
frameRect.size = proposedFrameSize;
|
|
|
|
|
|
|
|
|
frameRect = owner->constrainRect (frameRect);
|
|
|
frameRect = owner->constrainRect (frameRect);
|
|
|