|
26 | 26 | #include "DistrhoPluginProM.hpp" |
27 | 27 | #include "DistrhoUIProM.hpp" |
28 | 28 |
|
29 | | -#ifndef DISTRHO_OS_WINDOWS |
30 | | -# include <dlfcn.h> |
31 | | -#endif |
32 | | - |
33 | | -#ifdef DISTRHO_OS_WINDOWS |
34 | | -static HINSTANCE hInstance = nullptr; |
35 | | - |
36 | | -DISTRHO_PLUGIN_EXPORT |
37 | | -BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID) |
38 | | -{ |
39 | | - if (reason == DLL_PROCESS_ATTACH) |
40 | | - hInstance = hInst; |
41 | | - return 1; |
42 | | -} |
43 | | -#endif |
| 29 | +#include "DistrhoPluginUtils.hpp" |
44 | 30 |
|
45 | 31 | START_NAMESPACE_DISTRHO |
46 | 32 |
|
47 | 33 | // ----------------------------------------------------------------------- |
48 | 34 |
|
49 | | -static String getCurrentExecutableDataDir() |
50 | | -{ |
51 | | - static String datadir; |
52 | | - |
53 | | - if (datadir.isNotEmpty()) |
54 | | - return datadir; |
55 | | - |
56 | | -#ifdef DISTRHO_OS_WINDOWS |
57 | | - CHAR filename[MAX_PATH + 256]; |
58 | | - filename[0] = '\0'; |
59 | | - GetModuleFileName(hInstance, filename, sizeof(filename)); |
60 | | - |
61 | | - datadir = String(filename); |
62 | | - datadir.truncate(datadir.rfind('\\')); |
63 | | -#else |
64 | | - Dl_info info; |
65 | | - dladdr((void*)getCurrentExecutableDataDir, &info); |
66 | | - |
67 | | - datadir = String(info.dli_fname); |
68 | | - datadir.truncate(datadir.rfind('/')); |
69 | | - |
70 | | -# ifdef DISTRHO_OS_MAC |
71 | | - if (datadir.endsWith("/MacOS")) |
72 | | - { |
73 | | - datadir.truncate(datadir.rfind('/')); |
74 | | - datadir += "/Resources"; |
75 | | - } |
76 | | - else |
77 | | -# endif |
78 | | - if (datadir.endsWith("/x86_64-linux")) |
79 | | - { |
80 | | - datadir.truncate(datadir.rfind('/')); |
81 | | - datadir += "/Resources"; |
82 | | - } |
83 | | - else |
84 | | -#endif |
85 | | - { |
86 | | - datadir += "/resources"; |
87 | | - } |
88 | | - |
89 | | - return datadir; |
90 | | -} |
91 | | - |
92 | | -// ----------------------------------------------------------------------- |
93 | | - |
94 | 35 | DistrhoUIProM::DistrhoUIProM() |
95 | 36 | : UI(512, 512), |
96 | | - fPM(nullptr), |
97 | | - fResizeHandle(this) |
| 37 | + fPM(nullptr) |
| 38 | +#ifndef DGL_USE_OPENGL3 |
| 39 | + , fResizeHandle(this) |
| 40 | +#endif |
98 | 41 | { |
99 | | - // const double scaleFactor = getScaleFactor(); |
100 | | - // if (d_isNotZero(scaleFactor)) |
101 | | - // setSize(512*scaleFactor, 512*scaleFactor) |
102 | | - setGeometryConstraints(256, 256, true); |
| 42 | + const double scaleFactor = getScaleFactor(); |
| 43 | + |
| 44 | + if (d_isNotZero(scaleFactor)) |
| 45 | + setSize(512*scaleFactor, 512*scaleFactor); |
| 46 | + |
| 47 | + setGeometryConstraints(256*scaleFactor, 256*scaleFactor, true); |
103 | 48 |
|
104 | 49 | // no need to show resize handle if window is user-resizable |
| 50 | +#ifndef DGL_USE_OPENGL3 |
105 | 51 | // if (isResizable()) |
106 | 52 | // fResizeHandle.hide(); |
| 53 | +#endif |
107 | 54 | } |
108 | 55 |
|
109 | 56 | DistrhoUIProM::~DistrhoUIProM() |
@@ -154,19 +101,27 @@ void DistrhoUIProM::uiReshape(uint width, uint height) |
154 | 101 | #ifdef PROJECTM_DATA_DIR |
155 | 102 | fPM = new projectM(PROJECTM_DATA_DIR "/config.inp"); |
156 | 103 | #else |
157 | | - const String datadir(getCurrentExecutableDataDir()); |
158 | | - d_stdout("ProM datadir: '%s'", datadir.buffer()); |
159 | | - |
160 | | - projectM::Settings settings; |
161 | | - settings.presetURL = datadir + DISTRHO_OS_SEP_STR "presets"; |
162 | | - settings.titleFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "Vera.ttf"; |
163 | | - settings.menuFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "VeraMono.ttf"; |
164 | | - settings.datadir = datadir; |
165 | | - fPM = new projectM(settings); |
| 104 | + if (const char* const bundlePath = getBundlePath()) |
| 105 | + { |
| 106 | + const String datadir(getResourcePath(bundlePath)); |
| 107 | + d_stdout("ProM datadir: '%s'", datadir.buffer()); |
| 108 | + |
| 109 | + projectM::Settings settings; |
| 110 | + settings.presetURL = datadir + DISTRHO_OS_SEP_STR "presets"; |
| 111 | + settings.titleFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "Vera.ttf"; |
| 112 | + settings.menuFontURL = datadir + DISTRHO_OS_SEP_STR "fonts" DISTRHO_OS_SEP_STR "VeraMono.ttf"; |
| 113 | + settings.datadir = datadir; |
| 114 | + fPM = new projectM(settings); |
| 115 | + } |
| 116 | + else |
| 117 | + { |
| 118 | + d_stderr2("ProM: failed to find bundle path, UI will be empty"); |
| 119 | + } |
166 | 120 | #endif |
167 | 121 | } |
168 | 122 |
|
169 | | - fPM->projectM_resetGL(width, height); |
| 123 | + if (fPM != nullptr) |
| 124 | + fPM->projectM_resetGL(width, height); |
170 | 125 | } |
171 | 126 |
|
172 | 127 | // ----------------------------------------------------------------------- |
|
0 commit comments