Browse Source

Windows support

Signed-off-by: falkTX <falktx@falktx.com>
tags/v1.0
falkTX 3 years ago
parent
commit
84ffc02fe8
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 81 additions and 16 deletions
  1. +1
    -1
      carla
  2. +21
    -3
      plugins/Common/IldaeilPlugin.cpp
  3. +16
    -7
      plugins/Common/IldaeilUI.cpp
  4. +43
    -5
      plugins/Common/PluginHostWindow.cpp

+ 1
- 1
carla

@@ -1 +1 @@
Subproject commit 51028655d09c9a21fc51cadd7bc48210295aa791
Subproject commit 37b294bdd2a340a0a8a7e05523c95c46789f32a6

+ 21
- 3
plugins/Common/IldaeilPlugin.cpp View File

@@ -37,6 +37,9 @@ static bool host_is_offline(NativeHostHandle);
static const NativeTimeInfo* host_get_time_info(NativeHostHandle handle); static const NativeTimeInfo* host_get_time_info(NativeHostHandle handle);
static bool host_write_midi_event(NativeHostHandle handle, const NativeMidiEvent* event); static bool host_write_midi_event(NativeHostHandle handle, const NativeMidiEvent* event);
static void host_ui_parameter_changed(NativeHostHandle handle, uint32_t index, float value); static void host_ui_parameter_changed(NativeHostHandle handle, uint32_t index, float value);
static void host_ui_midi_program_changed(NativeHostHandle handle, uint8_t channel, uint32_t bank, uint32_t program);
static void host_ui_custom_data_changed(NativeHostHandle handle, const char* key, const char* value);
static void host_ui_closed(NativeHostHandle handle);
static const char* host_ui_open_file(NativeHostHandle handle, bool isDir, const char* title, const char* filter); static const char* host_ui_open_file(NativeHostHandle handle, bool isDir, const char* title, const char* filter);
static const char* host_ui_save_file(NativeHostHandle handle, bool isDir, const char* title, const char* filter); static const char* host_ui_save_file(NativeHostHandle handle, bool isDir, const char* title, const char* filter);
static intptr_t host_dispatcher(NativeHostHandle handle, NativeHostDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt); static intptr_t host_dispatcher(NativeHostHandle handle, NativeHostDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt);
@@ -102,9 +105,9 @@ public:
fCarlaHostDescriptor.get_time_info = host_get_time_info; fCarlaHostDescriptor.get_time_info = host_get_time_info;
fCarlaHostDescriptor.write_midi_event = host_write_midi_event; fCarlaHostDescriptor.write_midi_event = host_write_midi_event;
fCarlaHostDescriptor.ui_parameter_changed = host_ui_parameter_changed; fCarlaHostDescriptor.ui_parameter_changed = host_ui_parameter_changed;
fCarlaHostDescriptor.ui_midi_program_changed = nullptr;
fCarlaHostDescriptor.ui_custom_data_changed = nullptr;
fCarlaHostDescriptor.ui_closed = nullptr;
fCarlaHostDescriptor.ui_midi_program_changed = host_ui_midi_program_changed;
fCarlaHostDescriptor.ui_custom_data_changed = host_ui_custom_data_changed;
fCarlaHostDescriptor.ui_closed = host_ui_closed;
fCarlaHostDescriptor.ui_open_file = host_ui_open_file; fCarlaHostDescriptor.ui_open_file = host_ui_open_file;
fCarlaHostDescriptor.ui_save_file = host_ui_save_file; fCarlaHostDescriptor.ui_save_file = host_ui_save_file;
fCarlaHostDescriptor.dispatcher = host_dispatcher; fCarlaHostDescriptor.dispatcher = host_dispatcher;
@@ -484,6 +487,21 @@ static void host_ui_parameter_changed(const NativeHostHandle handle, const uint3
ildaeilParameterChangeForUI(static_cast<IldaeilPlugin*>(handle)->fUI, index, value); ildaeilParameterChangeForUI(static_cast<IldaeilPlugin*>(handle)->fUI, index, value);
} }
static void host_ui_midi_program_changed(NativeHostHandle handle, uint8_t channel, uint32_t bank, uint32_t program)
{
d_stdout("%s %p %u %u %u", __FUNCTION__, handle, channel, bank, program);
}
static void host_ui_custom_data_changed(NativeHostHandle handle, const char* key, const char* value)
{
d_stdout("%s %p %s %s", __FUNCTION__, handle, key, value);
}
static void host_ui_closed(NativeHostHandle handle)
{
d_stdout("%s %p", __FUNCTION__, handle);
}
static const char* host_ui_open_file(const NativeHostHandle handle, const bool isDir, const char* const title, const char* const filter) static const char* host_ui_open_file(const NativeHostHandle handle, const bool isDir, const char* const title, const char* const filter)
{ {
return ildaeilOpenFileForUI(static_cast<IldaeilPlugin*>(handle)->fUI, isDir, title, filter); return ildaeilOpenFileForUI(static_cast<IldaeilPlugin*>(handle)->fUI, isDir, title, filter);


+ 16
- 7
plugins/Common/IldaeilUI.cpp View File

@@ -170,6 +170,8 @@ class IldaeilUI : public UI,


String fPopupError; String fPopupError;


Size<uint> fNextSize;

public: public:
IldaeilUI() IldaeilUI()
: UI(kInitialWidth, kInitialHeight), : UI(kInitialWidth, kInitialHeight),
@@ -303,7 +305,7 @@ public:
updatePluginGenericUI(handle); updatePluginGenericUI(handle);
ImGuiStyle& style(ImGui::GetStyle()); ImGuiStyle& style(ImGui::GetStyle());
const double scaleFactor = getScaleFactor(); const double scaleFactor = getScaleFactor();
setSize(kGenericWidth * scaleFactor, (kGenericHeight + style.FramePadding.x) * scaleFactor);
fNextSize = Size<uint>(kGenericWidth * scaleFactor, (kGenericHeight + style.FramePadding.x) * scaleFactor);
} }


repaint(); repaint();
@@ -433,9 +435,10 @@ public:
} }


protected: protected:
void pluginWindowResized(uint width, uint height) override
void pluginWindowResized(const uint width, const uint height) override
{ {
setSize(width, height + kButtonHeight * getScaleFactor() + ImGui::GetStyle().WindowPadding.y * 2);
fNextSize = Size<uint>(width,
height + kButtonHeight * getScaleFactor() + ImGui::GetStyle().WindowPadding.y * 2);
} }


void uiIdle() override void uiIdle() override
@@ -465,6 +468,13 @@ protected:
default: default:
break; break;
} }

if (fNextSize.isValid())
{
setSize(fNextSize);
fNextSize = Size<uint>();
return;
}
} }


void uiFileBrowserSelected(const char* const filename) override void uiFileBrowserSelected(const char* const filename) override
@@ -554,7 +564,6 @@ protected:
drawTopBar(); drawTopBar();
break; break;
} }

} }


void drawError(const bool open) void drawError(const bool open)
@@ -619,7 +628,7 @@ protected:
fDrawingState = kDrawingPluginList; fDrawingState = kDrawingPluginList;


const double scaleFactor = getScaleFactor(); const double scaleFactor = getScaleFactor();
setSize(kInitialWidth * scaleFactor, kInitialHeight * scaleFactor);
fNextSize = Size<uint>(kInitialWidth * scaleFactor, kInitialHeight * scaleFactor);
} }


ImGui::SameLine(); ImGui::SameLine();
@@ -666,8 +675,8 @@ protected:


const double scaleFactor = getScaleFactor(); const double scaleFactor = getScaleFactor();
const double padding = ImGui::GetStyle().WindowPadding.y * 2; const double padding = ImGui::GetStyle().WindowPadding.y * 2;
setSize(std::max(getWidth(), static_cast<uint>(kGenericWidth * scaleFactor + 0.5)),
(kGenericHeight + kButtonHeight) * scaleFactor + padding);
fNextSize = Size<uint>(std::max(getWidth(), static_cast<uint>(kGenericWidth * scaleFactor + 0.5)),
(kGenericHeight + kButtonHeight) * scaleFactor + padding);
} }
} }
} }


+ 43
- 5
plugins/Common/PluginHostWindow.cpp View File

@@ -21,6 +21,8 @@
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
# import <Cocoa/Cocoa.h> # import <Cocoa/Cocoa.h>
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#else #else
# define ILDAEIL_X11 # define ILDAEIL_X11
# include <X11/Xlib.h> # include <X11/Xlib.h>
@@ -67,11 +69,12 @@ struct PluginHostWindow::PrivateData
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
IldaeilPluginView* view; IldaeilPluginView* view;
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
::HWND pluginWindow;
#else #else
::Display* display; ::Display* display;
::Window pluginWindow; ::Window pluginWindow;
uint xOffset, yOffset;
#endif #endif
uint xOffset, yOffset;


bool lookingForChildren; bool lookingForChildren;


@@ -83,12 +86,13 @@ struct PluginHostWindow::PrivateData
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
view(nullptr), view(nullptr),
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
pluginWindow(nullptr),
#else #else
display(nullptr), display(nullptr),
pluginWindow(0), pluginWindow(0),
#endif
xOffset(0), xOffset(0),
yOffset(0), yOffset(0),
#endif
lookingForChildren(false) lookingForChildren(false)
{ {
#if defined(DISTRHO_OS_HAIKU) #if defined(DISTRHO_OS_HAIKU)
@@ -128,7 +132,8 @@ struct PluginHostWindow::PrivateData
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
return view; return view;
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
return nullptr;
pluginWindow = nullptr;
return (void*)parentWindowId;
#else #else
pluginWindow = 0; pluginWindow = 0;
return (void*)parentWindowId; return (void*)parentWindowId;
@@ -143,6 +148,11 @@ struct PluginHostWindow::PrivateData
[view setHidden:YES]; [view setHidden:YES];
[NSOpenGLContext clearCurrentContext]; [NSOpenGLContext clearCurrentContext];
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
if (pluginWindow != nullptr)
{
ShowWindow(pluginWindow, SW_HIDE);
pluginWindow = nullptr;
}
#else #else
pluginWindow = 0; pluginWindow = 0;
#endif #endif
@@ -175,6 +185,31 @@ struct PluginHostWindow::PrivateData
break; break;
} }
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
if (pluginWindow == nullptr)
pluginWindow = FindWindowExA((::HWND)parentWindowId, nullptr, nullptr, nullptr);

if (pluginWindow != nullptr)
{
int width = 0;
int height = 0;

RECT rect;
if (GetWindowRect(pluginWindow, &rect))
{
width = rect.right - rect.left;
height = rect.bottom - rect.top;
}

d_stdout("child window bounds %u %u | offset %u %u", width, height, xOffset, yOffset);

if (width > 1 && height > 1)
{
lookingForChildren = false;
SetWindowPos(pluginWindow, 0, xOffset, yOffset, 0, 0,
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER);
pluginWindowCallbacks->pluginWindowResized(width, height);
}
}
#else #else
if (pluginWindow == 0) if (pluginWindow == 0)
{ {
@@ -260,13 +295,16 @@ struct PluginHostWindow::PrivateData
[view setFrame:NSMakeRect(x / scaleFactor, y / scaleFactor, width / scaleFactor, height / scaleFactor)]; [view setFrame:NSMakeRect(x / scaleFactor, y / scaleFactor, width / scaleFactor, height / scaleFactor)];
} }
#elif defined(DISTRHO_OS_WINDOWS) #elif defined(DISTRHO_OS_WINDOWS)
// unused
(void)width;
(void)height;
#else #else
xOffset = x;
yOffset = y;
// unused // unused
(void)width; (void)width;
(void)height; (void)height;
#endif #endif
xOffset = x;
yOffset = y;
} }
}; };




Loading…
Cancel
Save