VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_graphics / native / juce_mac_CoreGraphicsHelpers.h
blob4ccee76af784d50743e254d620da86a06244542a
1 /*
2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
23 ==============================================================================
26 namespace juce
29 //==============================================================================
30 namespace
32 template <class RectType>
33 Rectangle<int> convertToRectInt (RectType r) noexcept
35 return { (int) r.origin.x,
36 (int) r.origin.y,
37 (int) r.size.width,
38 (int) r.size.height };
41 template <class RectType>
42 Rectangle<float> convertToRectFloat (RectType r) noexcept
44 return { (float) r.origin.x,
45 (float) r.origin.y,
46 (float) r.size.width,
47 (float) r.size.height };
50 template <class RectType>
51 CGRect convertToCGRect (RectType r) noexcept
53 return CGRectMake ((CGFloat) r.getX(), (CGFloat) r.getY(), (CGFloat) r.getWidth(), (CGFloat) r.getHeight());
56 template <class PointType>
57 Point<float> convertToPointFloat (PointType p) noexcept
59 return { (float) p.x, (float) p.y };
62 template <typename PointType>
63 CGPoint convertToCGPoint (PointType p) noexcept
65 return CGPointMake ((CGFloat) p.x, (CGFloat) p.y);
68 template <class PointType>
69 Point<int> roundToIntPoint (PointType p) noexcept
71 return { roundToInt (p.x), roundToInt (p.y) };
74 #if JUCE_MAC
75 inline CGFloat getMainScreenHeight() noexcept
77 if ([[NSScreen screens] count] == 0)
78 return 0.0f;
80 return [[[NSScreen screens] objectAtIndex: 0] frame].size.height;
83 inline NSRect flippedScreenRect (NSRect r) noexcept
85 r.origin.y = getMainScreenHeight() - (r.origin.y + r.size.height);
86 return r;
89 inline NSPoint flippedScreenPoint (NSPoint p) noexcept
91 p.y = getMainScreenHeight() - p.y;
92 return p;
94 #endif
97 CGImageRef juce_createCoreGraphicsImage (const Image&, CGColorSpaceRef);
98 CGContextRef juce_getImageContext (const Image&);
100 #if JUCE_IOS
101 Image juce_createImageFromUIImage (UIImage*);
102 #endif
104 #if JUCE_MAC
105 NSImage* imageToNSImage (const ScaledImage& image);
106 #endif
108 } // namespace juce