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.

115 lines
3.4KB

  1. diff --git a/modules/juce_audio_processors/juce_audio_processors.cpp b/modules/juce_audio_processors/juce_audio_processors.cpp
  2. index 20dee10..ca6dd27 100644
  3. --- a/modules/juce_audio_processors/juce_audio_processors.cpp
  4. +++ b/modules/juce_audio_processors/juce_audio_processors.cpp
  5. @@ -86,24 +86,9 @@ static inline bool arrayContainsPlugin (const OwnedArray<PluginDescription>& lis
  6. struct AutoResizingNSViewComponent : public ViewComponentBaseClass,
  7. private AsyncUpdater
  8. {
  9. - AutoResizingNSViewComponent() : recursive (false) {}
  10. -
  11. - void childBoundsChanged (Component*) override
  12. - {
  13. - if (recursive)
  14. - {
  15. - triggerAsyncUpdate();
  16. - }
  17. - else
  18. - {
  19. - recursive = true;
  20. - resizeToFitView();
  21. - recursive = true;
  22. - }
  23. - }
  24. -
  25. - void handleAsyncUpdate() override { resizeToFitView(); }
  26. -
  27. + AutoResizingNSViewComponent();
  28. + void childBoundsChanged (Component*) override;
  29. + void handleAsyncUpdate() override;
  30. bool recursive;
  31. };
  32. @@ -111,33 +96,61 @@ struct AutoResizingNSViewComponent : public ViewComponentBaseClass,
  33. struct AutoResizingNSViewComponentWithParent : public AutoResizingNSViewComponent,
  34. private Timer
  35. {
  36. - AutoResizingNSViewComponentWithParent()
  37. - {
  38. - JUCE_IOS_MAC_VIEW* v = [[JUCE_IOS_MAC_VIEW alloc] init];
  39. - setView (v);
  40. - [v release];
  41. + AutoResizingNSViewComponentWithParent();
  42. + JUCE_IOS_MAC_VIEW* getChildView() const;
  43. + void timerCallback() override;
  44. +};
  45. - startTimer (30);
  46. - }
  47. +//==============================================================================
  48. +AutoResizingNSViewComponent::AutoResizingNSViewComponent()
  49. + : recursive (false) {}
  50. - JUCE_IOS_MAC_VIEW* getChildView() const
  51. +void AutoResizingNSViewComponent::childBoundsChanged (Component*) override
  52. +{
  53. + if (recursive)
  54. {
  55. - if (JUCE_IOS_MAC_VIEW* parent = (JUCE_IOS_MAC_VIEW*) getView())
  56. - if ([[parent subviews] count] > 0)
  57. - return [[parent subviews] objectAtIndex: 0];
  58. -
  59. - return nil;
  60. + triggerAsyncUpdate();
  61. }
  62. + else
  63. + {
  64. + recursive = true;
  65. + resizeToFitView();
  66. + recursive = true;
  67. + }
  68. +}
  69. - void timerCallback() override
  70. +void AutoResizingNSViewComponent::handleAsyncUpdate() override
  71. +{
  72. + resizeToFitView();
  73. +}
  74. +
  75. +//==============================================================================
  76. +AutoResizingNSViewComponentWithParent::AutoResizingNSViewComponentWithParent()
  77. +{
  78. + JUCE_IOS_MAC_VIEW* v = [[JUCE_IOS_MAC_VIEW alloc] init];
  79. + setView (v);
  80. + [v release];
  81. +
  82. + startTimer (30);
  83. +}
  84. +
  85. +JUCE_IOS_MAC_VIEW* AutoResizingNSViewComponentWithParent::getChildView() const
  86. +{
  87. + if (JUCE_IOS_MAC_VIEW* parent = (JUCE_IOS_MAC_VIEW*) getView())
  88. + if ([[parent subviews] count] > 0)
  89. + return [[parent subviews] objectAtIndex: 0];
  90. +
  91. + return nil;
  92. +}
  93. +
  94. +void AutoResizingNSViewComponentWithParent::timerCallback() override
  95. +{
  96. + if (JUCE_IOS_MAC_VIEW* child = getChildView())
  97. {
  98. - if (JUCE_IOS_MAC_VIEW* child = getChildView())
  99. - {
  100. - stopTimer();
  101. - setView (child);
  102. - }
  103. + stopTimer();
  104. + setView (child);
  105. }
  106. -};
  107. +}
  108. #endif
  109. #if JUCE_CLANG