Collection of DPF-based plugins for packaging
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.

54 lines
1.9KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. // A few utils declared in DistrhoUI.cpp but defined here because they use Obj-C
  17. #include "src/DistrhoPluginChecks.h"
  18. #include "src/DistrhoDefines.h"
  19. #if DISTRHO_UI_FILE_BROWSER || DISTRHO_PLUGIN_HAS_EXTERNAL_UI
  20. # import <Cocoa/Cocoa.h>
  21. #endif
  22. #if DISTRHO_UI_FILE_BROWSER
  23. # define DISTRHO_FILE_BROWSER_DIALOG_HPP_INCLUDED
  24. # define FILE_BROWSER_DIALOG_NAMESPACE DISTRHO_NAMESPACE
  25. # define FILE_BROWSER_DIALOG_DISTRHO_NAMESPACE
  26. START_NAMESPACE_DISTRHO
  27. # include "extra/FileBrowserDialogImpl.hpp"
  28. END_NAMESPACE_DISTRHO
  29. # include "extra/FileBrowserDialogImpl.cpp"
  30. #endif
  31. #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI
  32. # include <algorithm>
  33. # include <cmath>
  34. START_NAMESPACE_DISTRHO
  35. double getDesktopScaleFactor(const uintptr_t parentWindowHandle)
  36. {
  37. // allow custom scale for testing
  38. if (const char* const scale = getenv("DPF_SCALE_FACTOR"))
  39. return std::max(1.0, std::atof(scale));
  40. if (NSView* const parentView = (NSView*)parentWindowHandle)
  41. if (NSWindow* const parentWindow = [parentView window])
  42. return [parentWindow screen].backingScaleFactor;
  43. return [NSScreen mainScreen].backingScaleFactor;
  44. }
  45. END_NAMESPACE_DISTRHO
  46. #endif