EditorWidget-osx.mm 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*****************************************************************************
  2. Copyright (C) 2016-2017 by Colin Edwards.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. *****************************************************************************/
  14. #import "../headers/EditorWidget.h"
  15. #import <Cocoa/Cocoa.h>
  16. #include <QLayout>
  17. #include <QWindow>
  18. #import "../headers/VSTPlugin.h"
  19. void EditorWidget::buildEffectContainer(AEffect *effect)
  20. {
  21. NSView *view =
  22. [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300)];
  23. cocoaViewContainer =
  24. QWidget::createWindowContainer(QWindow::fromWinId(WId(view)));
  25. cocoaViewContainer->move(0, 0);
  26. cocoaViewContainer->resize(300, 300);
  27. cocoaViewContainer->show();
  28. QGridLayout *hblParams = new QGridLayout();
  29. hblParams->setContentsMargins(0, 0, 0, 0);
  30. hblParams->setSpacing(0);
  31. hblParams->addWidget(cocoaViewContainer);
  32. VstRect *vstRect = nullptr;
  33. effect->dispatcher(effect, effEditGetRect, 0, 0, &vstRect, 0);
  34. if (vstRect) {
  35. NSRect frame = NSMakeRect(vstRect->left, vstRect->top,
  36. vstRect->right, vstRect->bottom);
  37. [view setFrame:frame];
  38. cocoaViewContainer->resize(vstRect->right - vstRect->left,
  39. vstRect->bottom - vstRect->top);
  40. setFixedSize(vstRect->right - vstRect->left,
  41. vstRect->bottom - vstRect->top);
  42. }
  43. effect->dispatcher(effect, effEditOpen, 0, 0, view, 0);
  44. setLayout(hblParams);
  45. }
  46. void EditorWidget::handleResizeRequest(int width, int height)
  47. {
  48. setFixedSize(width, height);
  49. }