Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1401 lines
46KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #include "juce_mac_CGMetalLayerRenderer.h"
  19. #if TARGET_OS_SIMULATOR && JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS
  20. #warning JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS uses parts of the Metal API that are currently unsupported in the simulator - falling back to JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS=0
  21. #undef JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS
  22. #endif
  23. #if defined (__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
  24. #define JUCE_HAS_IOS_POINTER_SUPPORT 1
  25. #else
  26. #define JUCE_HAS_IOS_POINTER_SUPPORT 0
  27. #endif
  28. namespace juce
  29. {
  30. class UIViewComponentPeer;
  31. static UIInterfaceOrientation getWindowOrientation()
  32. {
  33. UIApplication* sharedApplication = [UIApplication sharedApplication];
  34. #if defined (__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
  35. if (@available (iOS 13.0, *))
  36. {
  37. for (UIScene* scene in [sharedApplication connectedScenes])
  38. if ([scene isKindOfClass: [UIWindowScene class]])
  39. return [(UIWindowScene*) scene interfaceOrientation];
  40. }
  41. #endif
  42. JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations")
  43. return [sharedApplication statusBarOrientation];
  44. JUCE_END_IGNORE_WARNINGS_GCC_LIKE
  45. }
  46. namespace Orientations
  47. {
  48. static Desktop::DisplayOrientation convertToJuce (UIInterfaceOrientation orientation)
  49. {
  50. switch (orientation)
  51. {
  52. case UIInterfaceOrientationPortrait: return Desktop::upright;
  53. case UIInterfaceOrientationPortraitUpsideDown: return Desktop::upsideDown;
  54. case UIInterfaceOrientationLandscapeLeft: return Desktop::rotatedClockwise;
  55. case UIInterfaceOrientationLandscapeRight: return Desktop::rotatedAntiClockwise;
  56. case UIInterfaceOrientationUnknown:
  57. default: jassertfalse; // unknown orientation!
  58. }
  59. return Desktop::upright;
  60. }
  61. static UIInterfaceOrientation convertFromJuce (Desktop::DisplayOrientation orientation)
  62. {
  63. switch (orientation)
  64. {
  65. case Desktop::upright: return UIInterfaceOrientationPortrait;
  66. case Desktop::upsideDown: return UIInterfaceOrientationPortraitUpsideDown;
  67. case Desktop::rotatedClockwise: return UIInterfaceOrientationLandscapeLeft;
  68. case Desktop::rotatedAntiClockwise: return UIInterfaceOrientationLandscapeRight;
  69. case Desktop::allOrientations:
  70. default: jassertfalse; // unknown orientation!
  71. }
  72. return UIInterfaceOrientationPortrait;
  73. }
  74. static NSUInteger getSupportedOrientations()
  75. {
  76. NSUInteger allowed = 0;
  77. auto& d = Desktop::getInstance();
  78. if (d.isOrientationEnabled (Desktop::upright)) allowed |= UIInterfaceOrientationMaskPortrait;
  79. if (d.isOrientationEnabled (Desktop::upsideDown)) allowed |= UIInterfaceOrientationMaskPortraitUpsideDown;
  80. if (d.isOrientationEnabled (Desktop::rotatedClockwise)) allowed |= UIInterfaceOrientationMaskLandscapeLeft;
  81. if (d.isOrientationEnabled (Desktop::rotatedAntiClockwise)) allowed |= UIInterfaceOrientationMaskLandscapeRight;
  82. return allowed;
  83. }
  84. }
  85. enum class MouseEventFlags
  86. {
  87. none,
  88. down,
  89. up,
  90. upAndCancel,
  91. };
  92. //==============================================================================
  93. } // namespace juce
  94. using namespace juce;
  95. struct CADisplayLinkDeleter
  96. {
  97. void operator() (CADisplayLink* displayLink) const noexcept
  98. {
  99. [displayLink invalidate];
  100. [displayLink release];
  101. }
  102. };
  103. @interface JuceUIView : UIView <UITextViewDelegate>
  104. {
  105. @public
  106. UIViewComponentPeer* owner;
  107. UITextView* hiddenTextView;
  108. std::unique_ptr<CADisplayLink, CADisplayLinkDeleter> displayLink;
  109. }
  110. - (JuceUIView*) initWithOwner: (UIViewComponentPeer*) owner withFrame: (CGRect) frame;
  111. - (void) dealloc;
  112. + (Class) layerClass;
  113. - (void) displayLinkCallback: (CADisplayLink*) dl;
  114. - (void) drawRect: (CGRect) r;
  115. - (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event;
  116. - (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event;
  117. - (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event;
  118. - (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event;
  119. #if JUCE_HAS_IOS_POINTER_SUPPORT
  120. - (void) onHover: (UIHoverGestureRecognizer*) gesture API_AVAILABLE (ios (13.0));
  121. - (void) onScroll: (UIPanGestureRecognizer*) gesture;
  122. #endif
  123. - (BOOL) becomeFirstResponder;
  124. - (BOOL) resignFirstResponder;
  125. - (BOOL) canBecomeFirstResponder;
  126. - (BOOL) textView: (UITextView*) textView shouldChangeTextInRange: (NSRange) range replacementText: (NSString*) text;
  127. - (void) traitCollectionDidChange: (UITraitCollection*) previousTraitCollection;
  128. - (BOOL) isAccessibilityElement;
  129. - (CGRect) accessibilityFrame;
  130. - (NSArray*) accessibilityElements;
  131. @end
  132. //==============================================================================
  133. @interface JuceUIViewController : UIViewController
  134. {
  135. }
  136. - (JuceUIViewController*) init;
  137. - (NSUInteger) supportedInterfaceOrientations;
  138. - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation;
  139. - (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation duration: (NSTimeInterval) duration;
  140. - (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation;
  141. - (void) viewWillTransitionToSize: (CGSize) size withTransitionCoordinator: (id<UIViewControllerTransitionCoordinator>) coordinator;
  142. - (BOOL) prefersStatusBarHidden;
  143. - (UIStatusBarStyle) preferredStatusBarStyle;
  144. - (void) viewDidLoad;
  145. - (void) viewWillAppear: (BOOL) animated;
  146. - (void) viewDidAppear: (BOOL) animated;
  147. - (void) viewWillLayoutSubviews;
  148. - (void) viewDidLayoutSubviews;
  149. @end
  150. //==============================================================================
  151. @interface JuceUIWindow : UIWindow
  152. {
  153. @private
  154. UIViewComponentPeer* owner;
  155. }
  156. - (void) setOwner: (UIViewComponentPeer*) owner;
  157. - (void) becomeKeyWindow;
  158. @end
  159. //==============================================================================
  160. //==============================================================================
  161. namespace juce
  162. {
  163. struct UIViewPeerControllerReceiver
  164. {
  165. virtual ~UIViewPeerControllerReceiver() = default;
  166. virtual void setViewController (UIViewController*) = 0;
  167. };
  168. class UIViewComponentPeer : public ComponentPeer,
  169. private FocusChangeListener,
  170. private UIViewPeerControllerReceiver
  171. {
  172. public:
  173. UIViewComponentPeer (Component&, int windowStyleFlags, UIView* viewToAttachTo);
  174. ~UIViewComponentPeer() override;
  175. //==============================================================================
  176. void* getNativeHandle() const override { return view; }
  177. void setVisible (bool shouldBeVisible) override;
  178. void setTitle (const String& title) override;
  179. void setBounds (const Rectangle<int>&, bool isNowFullScreen) override;
  180. void setViewController (UIViewController* newController) override
  181. {
  182. jassert (controller == nullptr);
  183. controller = [newController retain];
  184. }
  185. Rectangle<int> getBounds() const override { return getBounds (! isSharedWindow); }
  186. Rectangle<int> getBounds (bool global) const;
  187. Point<float> localToGlobal (Point<float> relativePosition) override;
  188. Point<float> globalToLocal (Point<float> screenPosition) override;
  189. using ComponentPeer::localToGlobal;
  190. using ComponentPeer::globalToLocal;
  191. void setAlpha (float newAlpha) override;
  192. void setMinimised (bool) override {}
  193. bool isMinimised() const override { return false; }
  194. void setFullScreen (bool shouldBeFullScreen) override;
  195. bool isFullScreen() const override { return fullScreen; }
  196. bool contains (Point<int> localPos, bool trueIfInAChildWindow) const override;
  197. OptionalBorderSize getFrameSizeIfPresent() const override { return {}; }
  198. BorderSize<int> getFrameSize() const override { return BorderSize<int>(); }
  199. bool setAlwaysOnTop (bool alwaysOnTop) override;
  200. void toFront (bool makeActiveWindow) override;
  201. void toBehind (ComponentPeer* other) override;
  202. void setIcon (const Image& newIcon) override;
  203. StringArray getAvailableRenderingEngines() override { return StringArray ("CoreGraphics Renderer"); }
  204. void displayLinkCallback();
  205. void drawRect (CGRect);
  206. void drawRectWithContext (CGContextRef, CGRect);
  207. bool canBecomeKeyWindow();
  208. //==============================================================================
  209. void viewFocusGain();
  210. void viewFocusLoss();
  211. bool isFocused() const override;
  212. void grabFocus() override;
  213. void textInputRequired (Point<int>, TextInputTarget&) override;
  214. BOOL textViewReplaceCharacters (Range<int>, const String&);
  215. void updateHiddenTextContent (TextInputTarget*);
  216. void globalFocusChanged (Component*) override;
  217. void updateScreenBounds();
  218. void handleTouches (UIEvent*, MouseEventFlags);
  219. #if JUCE_HAS_IOS_POINTER_SUPPORT
  220. API_AVAILABLE (ios (13.0)) void onHover (UIHoverGestureRecognizer*);
  221. void onScroll (UIPanGestureRecognizer*);
  222. #endif
  223. //==============================================================================
  224. void repaint (const Rectangle<int>& area) override;
  225. void performAnyPendingRepaintsNow() override;
  226. //==============================================================================
  227. UIWindow* window = nil;
  228. JuceUIView* view = nil;
  229. UIViewController* controller = nil;
  230. const bool isSharedWindow, isAppex;
  231. bool fullScreen = false, insideDrawRect = false;
  232. static int64 getMouseTime (NSTimeInterval timestamp) noexcept
  233. {
  234. return (Time::currentTimeMillis() - Time::getMillisecondCounter())
  235. + (int64) (timestamp * 1000.0);
  236. }
  237. static int64 getMouseTime (UIEvent* e) noexcept
  238. {
  239. return getMouseTime ([e timestamp]);
  240. }
  241. static NSString* getDarkModeNotificationName()
  242. {
  243. return @"ViewDarkModeChanged";
  244. }
  245. static MultiTouchMapper<UITouch*> currentTouches;
  246. private:
  247. void appStyleChanged() override
  248. {
  249. [controller setNeedsStatusBarAppearanceUpdate];
  250. }
  251. //==============================================================================
  252. class AsyncRepaintMessage : public CallbackMessage
  253. {
  254. public:
  255. UIViewComponentPeer* const peer;
  256. const Rectangle<int> rect;
  257. AsyncRepaintMessage (UIViewComponentPeer* const p, const Rectangle<int>& r)
  258. : peer (p), rect (r)
  259. {
  260. }
  261. void messageCallback() override
  262. {
  263. if (ComponentPeer::isValidPeer (peer))
  264. peer->repaint (rect);
  265. }
  266. };
  267. std::unique_ptr<CoreGraphicsMetalLayerRenderer> metalRenderer;
  268. RectangleList<float> deferredRepaints;
  269. //==============================================================================
  270. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UIViewComponentPeer)
  271. };
  272. static UIViewComponentPeer* getViewPeer (JuceUIViewController* c)
  273. {
  274. if (JuceUIView* juceView = (JuceUIView*) [c view])
  275. return juceView->owner;
  276. jassertfalse;
  277. return nullptr;
  278. }
  279. static void sendScreenBoundsUpdate (JuceUIViewController* c)
  280. {
  281. if (auto* peer = getViewPeer (c))
  282. peer->updateScreenBounds();
  283. }
  284. static bool isKioskModeView (JuceUIViewController* c)
  285. {
  286. if (auto* peer = getViewPeer (c))
  287. return Desktop::getInstance().getKioskModeComponent() == &(peer->getComponent());
  288. return false;
  289. }
  290. MultiTouchMapper<UITouch*> UIViewComponentPeer::currentTouches;
  291. } // namespace juce
  292. //==============================================================================
  293. //==============================================================================
  294. @implementation JuceUIViewController
  295. - (JuceUIViewController*) init
  296. {
  297. self = [super init];
  298. return self;
  299. }
  300. - (NSUInteger) supportedInterfaceOrientations
  301. {
  302. return Orientations::getSupportedOrientations();
  303. }
  304. - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
  305. {
  306. return Desktop::getInstance().isOrientationEnabled (Orientations::convertToJuce (interfaceOrientation));
  307. }
  308. - (void) willRotateToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation
  309. duration: (NSTimeInterval) duration
  310. {
  311. ignoreUnused (toInterfaceOrientation, duration);
  312. [UIView setAnimationsEnabled: NO]; // disable this because it goes the wrong way and looks like crap.
  313. }
  314. - (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation
  315. {
  316. ignoreUnused (fromInterfaceOrientation);
  317. sendScreenBoundsUpdate (self);
  318. [UIView setAnimationsEnabled: YES];
  319. }
  320. - (void) viewWillTransitionToSize: (CGSize) size withTransitionCoordinator: (id<UIViewControllerTransitionCoordinator>) coordinator
  321. {
  322. [super viewWillTransitionToSize: size withTransitionCoordinator: coordinator];
  323. [coordinator animateAlongsideTransition: nil completion: ^void (id<UIViewControllerTransitionCoordinatorContext>)
  324. {
  325. sendScreenBoundsUpdate (self);
  326. }];
  327. }
  328. - (BOOL) prefersStatusBarHidden
  329. {
  330. if (isKioskModeView (self))
  331. return true;
  332. return [[[NSBundle mainBundle] objectForInfoDictionaryKey: @"UIStatusBarHidden"] boolValue];
  333. }
  334. #if defined (__IPHONE_11_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
  335. - (BOOL) prefersHomeIndicatorAutoHidden
  336. {
  337. return isKioskModeView (self);
  338. }
  339. #endif
  340. - (UIStatusBarStyle) preferredStatusBarStyle
  341. {
  342. #if defined (__IPHONE_13_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0
  343. if (@available (iOS 13.0, *))
  344. {
  345. if (auto* peer = getViewPeer (self))
  346. {
  347. switch (peer->getAppStyle())
  348. {
  349. case ComponentPeer::Style::automatic:
  350. return UIStatusBarStyleDefault;
  351. case ComponentPeer::Style::light:
  352. return UIStatusBarStyleDarkContent;
  353. case ComponentPeer::Style::dark:
  354. return UIStatusBarStyleLightContent;
  355. }
  356. }
  357. }
  358. #endif
  359. return UIStatusBarStyleDefault;
  360. }
  361. - (void) viewDidLoad
  362. {
  363. sendScreenBoundsUpdate (self);
  364. [super viewDidLoad];
  365. }
  366. - (void) viewWillAppear: (BOOL) animated
  367. {
  368. sendScreenBoundsUpdate (self);
  369. [super viewWillAppear:animated];
  370. }
  371. - (void) viewDidAppear: (BOOL) animated
  372. {
  373. sendScreenBoundsUpdate (self);
  374. [super viewDidAppear:animated];
  375. }
  376. - (void) viewWillLayoutSubviews
  377. {
  378. sendScreenBoundsUpdate (self);
  379. }
  380. - (void) viewDidLayoutSubviews
  381. {
  382. sendScreenBoundsUpdate (self);
  383. }
  384. @end
  385. @implementation JuceUIView
  386. - (JuceUIView*) initWithOwner: (UIViewComponentPeer*) peer
  387. withFrame: (CGRect) frame
  388. {
  389. [super initWithFrame: frame];
  390. owner = peer;
  391. displayLink.reset ([CADisplayLink displayLinkWithTarget: self
  392. selector: @selector (displayLinkCallback:)]);
  393. [displayLink.get() addToRunLoop: [NSRunLoop mainRunLoop]
  394. forMode: NSDefaultRunLoopMode];
  395. hiddenTextView = [[UITextView alloc] initWithFrame: CGRectZero];
  396. [self addSubview: hiddenTextView];
  397. hiddenTextView.delegate = self;
  398. hiddenTextView.autocapitalizationType = UITextAutocapitalizationTypeNone;
  399. hiddenTextView.autocorrectionType = UITextAutocorrectionTypeNo;
  400. hiddenTextView.inputAssistantItem.leadingBarButtonGroups = @[];
  401. hiddenTextView.inputAssistantItem.trailingBarButtonGroups = @[];
  402. #if JUCE_HAS_IOS_POINTER_SUPPORT
  403. if (@available (iOS 13.4, *))
  404. {
  405. auto hoverRecognizer = [[[UIHoverGestureRecognizer alloc] initWithTarget: self action: @selector (onHover:)] autorelease];
  406. [hoverRecognizer setCancelsTouchesInView: NO];
  407. [hoverRecognizer setRequiresExclusiveTouchType: YES];
  408. [self addGestureRecognizer: hoverRecognizer];
  409. auto panRecognizer = [[[UIPanGestureRecognizer alloc] initWithTarget: self action: @selector (onScroll:)] autorelease];
  410. [panRecognizer setCancelsTouchesInView: NO];
  411. [panRecognizer setRequiresExclusiveTouchType: YES];
  412. [panRecognizer setAllowedScrollTypesMask: UIScrollTypeMaskAll];
  413. [panRecognizer setMaximumNumberOfTouches: 0];
  414. [self addGestureRecognizer: panRecognizer];
  415. }
  416. #endif
  417. return self;
  418. }
  419. - (void) dealloc
  420. {
  421. [hiddenTextView removeFromSuperview];
  422. [hiddenTextView release];
  423. displayLink = nullptr;
  424. [super dealloc];
  425. }
  426. //==============================================================================
  427. + (Class) layerClass
  428. {
  429. #if JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS
  430. if (@available (iOS 12, *))
  431. return [CAMetalLayer class];
  432. #endif
  433. return [CALayer class];
  434. }
  435. - (void) displayLinkCallback: (CADisplayLink*) dl
  436. {
  437. if (owner != nullptr)
  438. owner->displayLinkCallback();
  439. }
  440. //==============================================================================
  441. - (void) drawRect: (CGRect) r
  442. {
  443. if (owner != nullptr)
  444. owner->drawRect (r);
  445. }
  446. //==============================================================================
  447. - (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event
  448. {
  449. ignoreUnused (touches);
  450. if (owner != nullptr)
  451. owner->handleTouches (event, MouseEventFlags::down);
  452. }
  453. - (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event
  454. {
  455. ignoreUnused (touches);
  456. if (owner != nullptr)
  457. owner->handleTouches (event, MouseEventFlags::none);
  458. }
  459. - (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event
  460. {
  461. ignoreUnused (touches);
  462. if (owner != nullptr)
  463. owner->handleTouches (event, MouseEventFlags::up);
  464. }
  465. - (void) touchesCancelled: (NSSet*) touches withEvent: (UIEvent*) event
  466. {
  467. if (owner != nullptr)
  468. owner->handleTouches (event, MouseEventFlags::upAndCancel);
  469. [self touchesEnded: touches withEvent: event];
  470. }
  471. #if JUCE_HAS_IOS_POINTER_SUPPORT
  472. - (void) onHover: (UIHoverGestureRecognizer*) gesture
  473. {
  474. if (owner != nullptr)
  475. owner->onHover (gesture);
  476. }
  477. - (void) onScroll: (UIPanGestureRecognizer*) gesture
  478. {
  479. if (owner != nullptr)
  480. owner->onScroll (gesture);
  481. }
  482. #endif
  483. //==============================================================================
  484. - (BOOL) becomeFirstResponder
  485. {
  486. if (owner != nullptr)
  487. owner->viewFocusGain();
  488. return true;
  489. }
  490. - (BOOL) resignFirstResponder
  491. {
  492. if (owner != nullptr)
  493. owner->viewFocusLoss();
  494. return [super resignFirstResponder];
  495. }
  496. - (BOOL) canBecomeFirstResponder
  497. {
  498. return owner != nullptr && owner->canBecomeKeyWindow();
  499. }
  500. - (BOOL) textView: (UITextView*) textView shouldChangeTextInRange: (NSRange) range replacementText: (NSString*) text
  501. {
  502. ignoreUnused (textView);
  503. return owner->textViewReplaceCharacters (Range<int> ((int) range.location, (int) (range.location + range.length)),
  504. nsStringToJuce (text));
  505. }
  506. - (void) traitCollectionDidChange: (UITraitCollection*) previousTraitCollection
  507. {
  508. [super traitCollectionDidChange: previousTraitCollection];
  509. #if defined (__IPHONE_12_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_12_0
  510. if (@available (iOS 12.0, *))
  511. {
  512. const auto wasDarkModeActive = ([previousTraitCollection userInterfaceStyle] == UIUserInterfaceStyleDark);
  513. if (wasDarkModeActive != Desktop::getInstance().isDarkModeActive())
  514. [[NSNotificationCenter defaultCenter] postNotificationName: UIViewComponentPeer::getDarkModeNotificationName()
  515. object: nil];
  516. }
  517. #endif
  518. }
  519. - (BOOL) isAccessibilityElement
  520. {
  521. return NO;
  522. }
  523. - (CGRect) accessibilityFrame
  524. {
  525. if (owner != nullptr)
  526. if (auto* handler = owner->getComponent().getAccessibilityHandler())
  527. return convertToCGRect (handler->getComponent().getScreenBounds());
  528. return CGRectZero;
  529. }
  530. - (NSArray*) accessibilityElements
  531. {
  532. if (owner != nullptr)
  533. if (auto* handler = owner->getComponent().getAccessibilityHandler())
  534. return getContainerAccessibilityElements (*handler);
  535. return nil;
  536. }
  537. @end
  538. //==============================================================================
  539. @implementation JuceUIWindow
  540. - (void) setOwner: (UIViewComponentPeer*) peer
  541. {
  542. owner = peer;
  543. }
  544. - (void) becomeKeyWindow
  545. {
  546. [super becomeKeyWindow];
  547. if (owner != nullptr)
  548. owner->grabFocus();
  549. }
  550. @end
  551. //==============================================================================
  552. //==============================================================================
  553. namespace juce
  554. {
  555. bool KeyPress::isKeyCurrentlyDown (int)
  556. {
  557. return false;
  558. }
  559. Point<float> juce_lastMousePos;
  560. //==============================================================================
  561. UIViewComponentPeer::UIViewComponentPeer (Component& comp, int windowStyleFlags, UIView* viewToAttachTo)
  562. : ComponentPeer (comp, windowStyleFlags),
  563. isSharedWindow (viewToAttachTo != nil),
  564. isAppex (SystemStats::isRunningInAppExtensionSandbox())
  565. {
  566. CGRect r = convertToCGRect (component.getBounds());
  567. view = [[JuceUIView alloc] initWithOwner: this withFrame: r];
  568. view.multipleTouchEnabled = YES;
  569. view.hidden = true;
  570. view.opaque = component.isOpaque();
  571. view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0];
  572. #if JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS
  573. if (@available (iOS 12, *))
  574. metalRenderer = std::make_unique<CoreGraphicsMetalLayerRenderer> ((CAMetalLayer*) view.layer, comp);
  575. #endif
  576. if ((windowStyleFlags & ComponentPeer::windowRequiresSynchronousCoreGraphicsRendering) == 0)
  577. [[view layer] setDrawsAsynchronously: YES];
  578. if (isSharedWindow)
  579. {
  580. window = [viewToAttachTo window];
  581. [viewToAttachTo addSubview: view];
  582. }
  583. else
  584. {
  585. r = convertToCGRect (component.getBounds());
  586. r.origin.y = [UIScreen mainScreen].bounds.size.height - (r.origin.y + r.size.height);
  587. window = [[JuceUIWindow alloc] initWithFrame: r];
  588. [((JuceUIWindow*) window) setOwner: this];
  589. controller = [[JuceUIViewController alloc] init];
  590. controller.view = view;
  591. window.rootViewController = controller;
  592. window.hidden = true;
  593. window.opaque = component.isOpaque();
  594. window.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0];
  595. if (component.isAlwaysOnTop())
  596. window.windowLevel = UIWindowLevelAlert;
  597. view.frame = CGRectMake (0, 0, r.size.width, r.size.height);
  598. }
  599. setTitle (component.getName());
  600. setVisible (component.isVisible());
  601. Desktop::getInstance().addFocusChangeListener (this);
  602. }
  603. static UIViewComponentPeer* currentlyFocusedPeer = nullptr;
  604. UIViewComponentPeer::~UIViewComponentPeer()
  605. {
  606. if (currentlyFocusedPeer == this)
  607. currentlyFocusedPeer = nullptr;
  608. currentTouches.deleteAllTouchesForPeer (this);
  609. Desktop::getInstance().removeFocusChangeListener (this);
  610. view->owner = nullptr;
  611. [view removeFromSuperview];
  612. [view release];
  613. [controller release];
  614. if (! isSharedWindow)
  615. {
  616. [((JuceUIWindow*) window) setOwner: nil];
  617. #if defined (__IPHONE_13_0)
  618. if (@available (iOS 13.0, *))
  619. window.windowScene = nil;
  620. #endif
  621. [window release];
  622. }
  623. }
  624. //==============================================================================
  625. void UIViewComponentPeer::setVisible (bool shouldBeVisible)
  626. {
  627. if (! isSharedWindow)
  628. window.hidden = ! shouldBeVisible;
  629. view.hidden = ! shouldBeVisible;
  630. }
  631. void UIViewComponentPeer::setTitle (const String&)
  632. {
  633. // xxx is this possible?
  634. }
  635. void UIViewComponentPeer::setBounds (const Rectangle<int>& newBounds, const bool isNowFullScreen)
  636. {
  637. fullScreen = isNowFullScreen;
  638. if (isSharedWindow)
  639. {
  640. CGRect r = convertToCGRect (newBounds);
  641. if (view.frame.size.width != r.size.width || view.frame.size.height != r.size.height)
  642. [view setNeedsDisplay];
  643. view.frame = r;
  644. }
  645. else
  646. {
  647. window.frame = convertToCGRect (newBounds);
  648. view.frame = CGRectMake (0, 0, (CGFloat) newBounds.getWidth(), (CGFloat) newBounds.getHeight());
  649. handleMovedOrResized();
  650. }
  651. }
  652. Rectangle<int> UIViewComponentPeer::getBounds (const bool global) const
  653. {
  654. auto r = view.frame;
  655. if (global)
  656. {
  657. if (view.window != nil)
  658. {
  659. r = [view convertRect: r toView: view.window];
  660. r = [view.window convertRect: r toWindow: nil];
  661. }
  662. else if (window != nil)
  663. {
  664. r.origin.x += window.frame.origin.x;
  665. r.origin.y += window.frame.origin.y;
  666. }
  667. }
  668. return convertToRectInt (r);
  669. }
  670. Point<float> UIViewComponentPeer::localToGlobal (Point<float> relativePosition)
  671. {
  672. return relativePosition + getBounds (true).getPosition().toFloat();
  673. }
  674. Point<float> UIViewComponentPeer::globalToLocal (Point<float> screenPosition)
  675. {
  676. return screenPosition - getBounds (true).getPosition().toFloat();
  677. }
  678. void UIViewComponentPeer::setAlpha (float newAlpha)
  679. {
  680. [view.window setAlpha: (CGFloat) newAlpha];
  681. }
  682. void UIViewComponentPeer::setFullScreen (bool shouldBeFullScreen)
  683. {
  684. if (! isSharedWindow)
  685. {
  686. auto r = shouldBeFullScreen ? Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea
  687. : lastNonFullscreenBounds;
  688. if ((! shouldBeFullScreen) && r.isEmpty())
  689. r = getBounds();
  690. // (can't call the component's setBounds method because that'll reset our fullscreen flag)
  691. if (! r.isEmpty())
  692. setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, r), shouldBeFullScreen);
  693. component.repaint();
  694. }
  695. }
  696. void UIViewComponentPeer::updateScreenBounds()
  697. {
  698. auto& desktop = Desktop::getInstance();
  699. auto oldArea = component.getBounds();
  700. auto oldDesktop = desktop.getDisplays().getPrimaryDisplay()->userArea;
  701. forceDisplayUpdate();
  702. if (fullScreen)
  703. {
  704. fullScreen = false;
  705. setFullScreen (true);
  706. }
  707. else if (! isSharedWindow)
  708. {
  709. auto newDesktop = desktop.getDisplays().getPrimaryDisplay()->userArea;
  710. if (newDesktop != oldDesktop)
  711. {
  712. // this will re-centre the window, but leave its size unchanged
  713. auto centreRelX = oldArea.getCentreX() / (float) oldDesktop.getWidth();
  714. auto centreRelY = oldArea.getCentreY() / (float) oldDesktop.getHeight();
  715. auto x = ((int) (newDesktop.getWidth() * centreRelX)) - (oldArea.getWidth() / 2);
  716. auto y = ((int) (newDesktop.getHeight() * centreRelY)) - (oldArea.getHeight() / 2);
  717. component.setBounds (oldArea.withPosition (x, y));
  718. }
  719. }
  720. [view setNeedsDisplay];
  721. }
  722. bool UIViewComponentPeer::contains (Point<int> localPos, bool trueIfInAChildWindow) const
  723. {
  724. if (! ScalingHelpers::scaledScreenPosToUnscaled (component, component.getLocalBounds()).contains (localPos))
  725. return false;
  726. UIView* v = [view hitTest: convertToCGPoint (localPos)
  727. withEvent: nil];
  728. if (trueIfInAChildWindow)
  729. return v != nil;
  730. return v == view;
  731. }
  732. bool UIViewComponentPeer::setAlwaysOnTop (bool alwaysOnTop)
  733. {
  734. if (! isSharedWindow)
  735. window.windowLevel = alwaysOnTop ? UIWindowLevelAlert : UIWindowLevelNormal;
  736. return true;
  737. }
  738. void UIViewComponentPeer::toFront (bool makeActiveWindow)
  739. {
  740. if (isSharedWindow)
  741. [[view superview] bringSubviewToFront: view];
  742. if (makeActiveWindow && window != nil && component.isVisible())
  743. [window makeKeyAndVisible];
  744. }
  745. void UIViewComponentPeer::toBehind (ComponentPeer* other)
  746. {
  747. if (auto* otherPeer = dynamic_cast<UIViewComponentPeer*> (other))
  748. {
  749. if (isSharedWindow)
  750. [[view superview] insertSubview: view belowSubview: otherPeer->view];
  751. }
  752. else
  753. {
  754. jassertfalse; // wrong type of window?
  755. }
  756. }
  757. void UIViewComponentPeer::setIcon (const Image& /*newIcon*/)
  758. {
  759. // to do..
  760. }
  761. //==============================================================================
  762. static float getMaximumTouchForce (UITouch* touch) noexcept
  763. {
  764. if ([touch respondsToSelector: @selector (maximumPossibleForce)])
  765. return (float) touch.maximumPossibleForce;
  766. return 0.0f;
  767. }
  768. static float getTouchForce (UITouch* touch) noexcept
  769. {
  770. if ([touch respondsToSelector: @selector (force)])
  771. return (float) touch.force;
  772. return 0.0f;
  773. }
  774. void UIViewComponentPeer::handleTouches (UIEvent* event, MouseEventFlags mouseEventFlags)
  775. {
  776. NSArray* touches = [[event touchesForView: view] allObjects];
  777. for (unsigned int i = 0; i < [touches count]; ++i)
  778. {
  779. UITouch* touch = [touches objectAtIndex: i];
  780. auto maximumForce = getMaximumTouchForce (touch);
  781. if ([touch phase] == UITouchPhaseStationary && maximumForce <= 0)
  782. continue;
  783. auto pos = convertToPointFloat ([touch locationInView: view]);
  784. juce_lastMousePos = pos + getBounds (true).getPosition().toFloat();
  785. auto time = getMouseTime (event);
  786. auto touchIndex = currentTouches.getIndexOfTouch (this, touch);
  787. auto modsToSend = ModifierKeys::currentModifiers;
  788. auto isUp = [] (MouseEventFlags m)
  789. {
  790. return m == MouseEventFlags::up || m == MouseEventFlags::upAndCancel;
  791. };
  792. if (mouseEventFlags == MouseEventFlags::down)
  793. {
  794. if ([touch phase] != UITouchPhaseBegan)
  795. continue;
  796. ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::leftButtonModifier);
  797. modsToSend = ModifierKeys::currentModifiers;
  798. // this forces a mouse-enter/up event, in case for some reason we didn't get a mouse-up before.
  799. handleMouseEvent (MouseInputSource::InputSourceType::touch, pos, modsToSend.withoutMouseButtons(),
  800. MouseInputSource::defaultPressure, MouseInputSource::defaultOrientation, time, {}, touchIndex);
  801. if (! isValidPeer (this)) // (in case this component was deleted by the event)
  802. return;
  803. }
  804. else if (isUp (mouseEventFlags))
  805. {
  806. if (! ([touch phase] == UITouchPhaseEnded || [touch phase] == UITouchPhaseCancelled))
  807. continue;
  808. modsToSend = modsToSend.withoutMouseButtons();
  809. currentTouches.clearTouch (touchIndex);
  810. if (! currentTouches.areAnyTouchesActive())
  811. mouseEventFlags = MouseEventFlags::upAndCancel;
  812. }
  813. if (mouseEventFlags == MouseEventFlags::upAndCancel)
  814. {
  815. currentTouches.clearTouch (touchIndex);
  816. modsToSend = ModifierKeys::currentModifiers = ModifierKeys::currentModifiers.withoutMouseButtons();
  817. }
  818. // NB: some devices return 0 or 1.0 if pressure is unknown, so we'll clip our value to a believable range:
  819. auto pressure = maximumForce > 0 ? jlimit (0.0001f, 0.9999f, getTouchForce (touch) / maximumForce)
  820. : MouseInputSource::defaultPressure;
  821. handleMouseEvent (MouseInputSource::InputSourceType::touch,
  822. pos, modsToSend, pressure, MouseInputSource::defaultOrientation, time, { }, touchIndex);
  823. if (! isValidPeer (this)) // (in case this component was deleted by the event)
  824. return;
  825. if (isUp (mouseEventFlags))
  826. {
  827. handleMouseEvent (MouseInputSource::InputSourceType::touch, MouseInputSource::offscreenMousePos, modsToSend,
  828. MouseInputSource::defaultPressure, MouseInputSource::defaultOrientation, time, {}, touchIndex);
  829. if (! isValidPeer (this))
  830. return;
  831. }
  832. }
  833. }
  834. #if JUCE_HAS_IOS_POINTER_SUPPORT
  835. void UIViewComponentPeer::onHover (UIHoverGestureRecognizer* gesture)
  836. {
  837. auto pos = convertToPointFloat ([gesture locationInView: view]);
  838. juce_lastMousePos = pos + getBounds (true).getPosition().toFloat();
  839. handleMouseEvent (MouseInputSource::InputSourceType::touch,
  840. pos,
  841. ModifierKeys::currentModifiers,
  842. MouseInputSource::defaultPressure, MouseInputSource::defaultOrientation,
  843. UIViewComponentPeer::getMouseTime ([[NSProcessInfo processInfo] systemUptime]),
  844. {});
  845. }
  846. void UIViewComponentPeer::onScroll (UIPanGestureRecognizer* gesture)
  847. {
  848. const auto offset = [gesture translationInView: view];
  849. const auto scale = 0.5f / 256.0f;
  850. MouseWheelDetails details;
  851. details.deltaX = scale * (float) offset.x;
  852. details.deltaY = scale * (float) offset.y;
  853. details.isReversed = false;
  854. details.isSmooth = true;
  855. details.isInertial = false;
  856. handleMouseWheel (MouseInputSource::InputSourceType::touch,
  857. convertToPointFloat ([gesture locationInView: view]),
  858. UIViewComponentPeer::getMouseTime ([[NSProcessInfo processInfo] systemUptime]),
  859. details);
  860. }
  861. #endif
  862. //==============================================================================
  863. void UIViewComponentPeer::viewFocusGain()
  864. {
  865. if (currentlyFocusedPeer != this)
  866. {
  867. if (ComponentPeer::isValidPeer (currentlyFocusedPeer))
  868. currentlyFocusedPeer->handleFocusLoss();
  869. currentlyFocusedPeer = this;
  870. handleFocusGain();
  871. }
  872. }
  873. void UIViewComponentPeer::viewFocusLoss()
  874. {
  875. if (currentlyFocusedPeer == this)
  876. {
  877. currentlyFocusedPeer = nullptr;
  878. handleFocusLoss();
  879. }
  880. }
  881. bool UIViewComponentPeer::isFocused() const
  882. {
  883. if (isAppex)
  884. return true;
  885. return isSharedWindow ? this == currentlyFocusedPeer
  886. : (window != nil && [window isKeyWindow]);
  887. }
  888. void UIViewComponentPeer::grabFocus()
  889. {
  890. if (window != nil)
  891. {
  892. [window makeKeyWindow];
  893. viewFocusGain();
  894. }
  895. }
  896. void UIViewComponentPeer::textInputRequired (Point<int>, TextInputTarget&)
  897. {
  898. }
  899. static UIKeyboardType getUIKeyboardType (TextInputTarget::VirtualKeyboardType type) noexcept
  900. {
  901. switch (type)
  902. {
  903. case TextInputTarget::textKeyboard: return UIKeyboardTypeAlphabet;
  904. case TextInputTarget::numericKeyboard: return UIKeyboardTypeNumbersAndPunctuation;
  905. case TextInputTarget::decimalKeyboard: return UIKeyboardTypeNumbersAndPunctuation;
  906. case TextInputTarget::urlKeyboard: return UIKeyboardTypeURL;
  907. case TextInputTarget::emailAddressKeyboard: return UIKeyboardTypeEmailAddress;
  908. case TextInputTarget::phoneNumberKeyboard: return UIKeyboardTypePhonePad;
  909. default: jassertfalse; break;
  910. }
  911. return UIKeyboardTypeDefault;
  912. }
  913. void UIViewComponentPeer::updateHiddenTextContent (TextInputTarget* target)
  914. {
  915. view->hiddenTextView.keyboardType = getUIKeyboardType (target->getKeyboardType());
  916. view->hiddenTextView.text = juceStringToNS (target->getTextInRange (Range<int> (0, target->getHighlightedRegion().getStart())));
  917. view->hiddenTextView.selectedRange = NSMakeRange ((NSUInteger) target->getHighlightedRegion().getStart(), 0);
  918. }
  919. BOOL UIViewComponentPeer::textViewReplaceCharacters (Range<int> range, const String& text)
  920. {
  921. if (auto* target = findCurrentTextInputTarget())
  922. {
  923. auto currentSelection = target->getHighlightedRegion();
  924. if (range.getLength() == 1 && text.isEmpty()) // (detect backspace)
  925. if (currentSelection.isEmpty())
  926. target->setHighlightedRegion (currentSelection.withStart (currentSelection.getStart() - 1));
  927. WeakReference<Component> deletionChecker (dynamic_cast<Component*> (target));
  928. if (text == "\r" || text == "\n" || text == "\r\n")
  929. handleKeyPress (KeyPress::returnKey, text[0]);
  930. else
  931. target->insertTextAtCaret (text);
  932. if (deletionChecker != nullptr)
  933. updateHiddenTextContent (target);
  934. }
  935. return NO;
  936. }
  937. void UIViewComponentPeer::globalFocusChanged (Component*)
  938. {
  939. if (auto* target = findCurrentTextInputTarget())
  940. {
  941. if (auto* comp = dynamic_cast<Component*> (target))
  942. {
  943. auto pos = component.getLocalPoint (comp, Point<int>());
  944. view->hiddenTextView.frame = CGRectMake (pos.x, pos.y, 0, 0);
  945. updateHiddenTextContent (target);
  946. [view->hiddenTextView becomeFirstResponder];
  947. }
  948. }
  949. else
  950. {
  951. [view->hiddenTextView resignFirstResponder];
  952. }
  953. }
  954. //==============================================================================
  955. void UIViewComponentPeer::displayLinkCallback()
  956. {
  957. if (deferredRepaints.isEmpty())
  958. return;
  959. auto dispatchRectangles = [this] ()
  960. {
  961. // We shouldn't need this preprocessor guard, but when running in the simulator
  962. // CAMetalLayer is flagged as requiring iOS 13
  963. #if JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS
  964. if (metalRenderer != nullptr)
  965. {
  966. if (@available (iOS 12, *))
  967. {
  968. return metalRenderer->drawRectangleList ((CAMetalLayer*) view.layer,
  969. (float) view.contentScaleFactor,
  970. view.frame,
  971. component,
  972. [this] (CGContextRef ctx, CGRect r) { drawRectWithContext (ctx, r); },
  973. deferredRepaints);
  974. }
  975. // The creation of metalRenderer should already be guarded with @available (iOS 12, *).
  976. jassertfalse;
  977. return false;
  978. }
  979. #endif
  980. for (const auto& r : deferredRepaints)
  981. [view setNeedsDisplayInRect: convertToCGRect (r)];
  982. return true;
  983. };
  984. if (dispatchRectangles())
  985. deferredRepaints.clear();
  986. }
  987. //==============================================================================
  988. void UIViewComponentPeer::drawRect (CGRect r)
  989. {
  990. if (r.size.width < 1.0f || r.size.height < 1.0f)
  991. return;
  992. drawRectWithContext (UIGraphicsGetCurrentContext(), r);
  993. }
  994. void UIViewComponentPeer::drawRectWithContext (CGContextRef cg, CGRect)
  995. {
  996. if (! component.isOpaque())
  997. CGContextClearRect (cg, CGContextGetClipBoundingBox (cg));
  998. CGContextConcatCTM (cg, CGAffineTransformMake (1, 0, 0, -1, 0, getComponent().getHeight()));
  999. CoreGraphicsContext g (cg, getComponent().getHeight());
  1000. insideDrawRect = true;
  1001. handlePaint (g);
  1002. insideDrawRect = false;
  1003. }
  1004. bool UIViewComponentPeer::canBecomeKeyWindow()
  1005. {
  1006. return (getStyleFlags() & juce::ComponentPeer::windowIgnoresKeyPresses) == 0;
  1007. }
  1008. //==============================================================================
  1009. void Desktop::setKioskComponent (Component* kioskModeComp, bool enableOrDisable, bool /*allowMenusAndBars*/)
  1010. {
  1011. displays->refresh();
  1012. if (auto* peer = kioskModeComp->getPeer())
  1013. {
  1014. if (auto* uiViewPeer = dynamic_cast<UIViewComponentPeer*> (peer))
  1015. [uiViewPeer->controller setNeedsStatusBarAppearanceUpdate];
  1016. peer->setFullScreen (enableOrDisable);
  1017. }
  1018. }
  1019. void Desktop::allowedOrientationsChanged()
  1020. {
  1021. // if the current orientation isn't allowed anymore then switch orientations
  1022. if (! isOrientationEnabled (getCurrentOrientation()))
  1023. {
  1024. auto newOrientation = [this]
  1025. {
  1026. for (auto orientation : { upright, upsideDown, rotatedClockwise, rotatedAntiClockwise })
  1027. if (isOrientationEnabled (orientation))
  1028. return orientation;
  1029. // you need to support at least one orientation
  1030. jassertfalse;
  1031. return upright;
  1032. }();
  1033. NSNumber* value = [NSNumber numberWithInt: (int) Orientations::convertFromJuce (newOrientation)];
  1034. [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
  1035. [value release];
  1036. }
  1037. }
  1038. //==============================================================================
  1039. void UIViewComponentPeer::repaint (const Rectangle<int>& area)
  1040. {
  1041. if (insideDrawRect || ! MessageManager::getInstance()->isThisTheMessageThread())
  1042. {
  1043. (new AsyncRepaintMessage (this, area))->post();
  1044. return;
  1045. }
  1046. deferredRepaints.add (area.toFloat());
  1047. }
  1048. void UIViewComponentPeer::performAnyPendingRepaintsNow()
  1049. {
  1050. }
  1051. ComponentPeer* Component::createNewPeer (int styleFlags, void* windowToAttachTo)
  1052. {
  1053. return new UIViewComponentPeer (*this, styleFlags, (UIView*) windowToAttachTo);
  1054. }
  1055. //==============================================================================
  1056. const int KeyPress::spaceKey = ' ';
  1057. const int KeyPress::returnKey = 0x0d;
  1058. const int KeyPress::escapeKey = 0x1b;
  1059. const int KeyPress::backspaceKey = 0x7f;
  1060. const int KeyPress::leftKey = 0x1000;
  1061. const int KeyPress::rightKey = 0x1001;
  1062. const int KeyPress::upKey = 0x1002;
  1063. const int KeyPress::downKey = 0x1003;
  1064. const int KeyPress::pageUpKey = 0x1004;
  1065. const int KeyPress::pageDownKey = 0x1005;
  1066. const int KeyPress::endKey = 0x1006;
  1067. const int KeyPress::homeKey = 0x1007;
  1068. const int KeyPress::deleteKey = 0x1008;
  1069. const int KeyPress::insertKey = -1;
  1070. const int KeyPress::tabKey = 9;
  1071. const int KeyPress::F1Key = 0x2001;
  1072. const int KeyPress::F2Key = 0x2002;
  1073. const int KeyPress::F3Key = 0x2003;
  1074. const int KeyPress::F4Key = 0x2004;
  1075. const int KeyPress::F5Key = 0x2005;
  1076. const int KeyPress::F6Key = 0x2006;
  1077. const int KeyPress::F7Key = 0x2007;
  1078. const int KeyPress::F8Key = 0x2008;
  1079. const int KeyPress::F9Key = 0x2009;
  1080. const int KeyPress::F10Key = 0x200a;
  1081. const int KeyPress::F11Key = 0x200b;
  1082. const int KeyPress::F12Key = 0x200c;
  1083. const int KeyPress::F13Key = 0x200d;
  1084. const int KeyPress::F14Key = 0x200e;
  1085. const int KeyPress::F15Key = 0x200f;
  1086. const int KeyPress::F16Key = 0x2010;
  1087. const int KeyPress::F17Key = 0x2011;
  1088. const int KeyPress::F18Key = 0x2012;
  1089. const int KeyPress::F19Key = 0x2013;
  1090. const int KeyPress::F20Key = 0x2014;
  1091. const int KeyPress::F21Key = 0x2015;
  1092. const int KeyPress::F22Key = 0x2016;
  1093. const int KeyPress::F23Key = 0x2017;
  1094. const int KeyPress::F24Key = 0x2018;
  1095. const int KeyPress::F25Key = 0x2019;
  1096. const int KeyPress::F26Key = 0x201a;
  1097. const int KeyPress::F27Key = 0x201b;
  1098. const int KeyPress::F28Key = 0x201c;
  1099. const int KeyPress::F29Key = 0x201d;
  1100. const int KeyPress::F30Key = 0x201e;
  1101. const int KeyPress::F31Key = 0x201f;
  1102. const int KeyPress::F32Key = 0x2020;
  1103. const int KeyPress::F33Key = 0x2021;
  1104. const int KeyPress::F34Key = 0x2022;
  1105. const int KeyPress::F35Key = 0x2023;
  1106. const int KeyPress::numberPad0 = 0x30020;
  1107. const int KeyPress::numberPad1 = 0x30021;
  1108. const int KeyPress::numberPad2 = 0x30022;
  1109. const int KeyPress::numberPad3 = 0x30023;
  1110. const int KeyPress::numberPad4 = 0x30024;
  1111. const int KeyPress::numberPad5 = 0x30025;
  1112. const int KeyPress::numberPad6 = 0x30026;
  1113. const int KeyPress::numberPad7 = 0x30027;
  1114. const int KeyPress::numberPad8 = 0x30028;
  1115. const int KeyPress::numberPad9 = 0x30029;
  1116. const int KeyPress::numberPadAdd = 0x3002a;
  1117. const int KeyPress::numberPadSubtract = 0x3002b;
  1118. const int KeyPress::numberPadMultiply = 0x3002c;
  1119. const int KeyPress::numberPadDivide = 0x3002d;
  1120. const int KeyPress::numberPadSeparator = 0x3002e;
  1121. const int KeyPress::numberPadDecimalPoint = 0x3002f;
  1122. const int KeyPress::numberPadEquals = 0x30030;
  1123. const int KeyPress::numberPadDelete = 0x30031;
  1124. const int KeyPress::playKey = 0x30000;
  1125. const int KeyPress::stopKey = 0x30001;
  1126. const int KeyPress::fastForwardKey = 0x30002;
  1127. const int KeyPress::rewindKey = 0x30003;
  1128. } // namespace juce