diff --git a/test/plugin_ui.h b/test/plugin_ui.h index 39fd4e6..209dbe2 100644 --- a/test/plugin_ui.h +++ b/test/plugin_ui.h @@ -20,6 +20,7 @@ #if defined(_WIN32) || defined(__CYGWIN__) #elif defined(__APPLE__) +# include "ui_apple.h" #else # include #endif @@ -59,6 +60,7 @@ static plugin_ui *plugin_ui_create(char has_parent, void *parent, plugin_ui_call return NULL; #if defined(_WIN32) || defined(__CYGWIN__) #elif defined(__APPLE__) + instance->widget = (void *)ui_create(has_parent, parent, WIDTH, HEIGHT); #else instance->display = XOpenDisplay(NULL); if (instance->display == NULL) { @@ -82,8 +84,12 @@ static plugin_ui *plugin_ui_create(char has_parent, void *parent, plugin_ui_call } static void plugin_ui_free(plugin_ui *instance) { +#if defined(_WIN32) || defined(__CYGWIN__) +#elif defined(__APPLE__) +#else XDestroyWindow(instance->display, (Window)instance->widget); XCloseDisplay(instance->display); +#endif free(instance); } diff --git a/test/run.sh b/test/run.sh index db3861f..4b88f47 100755 --- a/test/run.sh +++ b/test/run.sh @@ -6,12 +6,12 @@ $dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/api $dir/../ $dir/../tibia $dir/product.json,$dir/company.json,$dir/vst3.json $dir/../templates/vst3 $dir/../out/vst3 $dir/../tibia $dir/product.json,$dir/company.json,$dir/vst3.json $dir/../templates/vst3-make $dir/../out/vst3 -cp $dir/plugin.h $dir/plugin_ui.h $dir/../out/vst3/src +cp $dir/plugin.h $dir/plugin_ui.h $dir/ui_apple.h $dir/ui_apple.m $dir/../out/vst3/src cp $dir/vars-pre.mk $dir/../out/vst3 $dir/../tibia $dir/product.json,$dir/company.json,$dir/lv2.json $dir/../templates/lv2 $dir/../out/lv2 $dir/../tibia $dir/product.json,$dir/company.json,$dir/lv2.json $dir/../templates/lv2-make $dir/../out/lv2 -cp $dir/plugin.h $dir/plugin_ui.h $dir/../out/lv2/src +cp $dir/plugin.h $dir/plugin_ui.h $dir/ui_apple.h $dir/ui_apple.m $dir/../out/lv2/src cp $dir/vars-pre.mk $dir/../out/lv2 $dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/web $dir/../out/web diff --git a/test/ui_apple.h b/test/ui_apple.h new file mode 100644 index 0000000..1383071 --- /dev/null +++ b/test/ui_apple.h @@ -0,0 +1,21 @@ +/* + * Tibia + * + * Copyright (C) 2025 Orastron Srl unipersonale + * + * Tibia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * Tibia is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tibia. If not, see . + * + * File author: Stefano D'Angelo + */ + +void *ui_create(char has_parent, void *parent, int width, int height); diff --git a/test/ui_apple.m b/test/ui_apple.m new file mode 100644 index 0000000..95ab87b --- /dev/null +++ b/test/ui_apple.m @@ -0,0 +1,32 @@ +/* + * Tibia + * + * Copyright (C) 2025 Orastron Srl unipersonale + * + * Tibia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * Tibia is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tibia. If not, see . + * + * File author: Stefano D'Angelo + */ + +#import + +void *ui_create(char has_parent, void *parent, int width, int height) { + NSView *v = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, width, height)]; +/* WRONG + if (has_parent) { + NSView *p = (NSView *)parent; + [p addSubview:v positioned:NSWindowAbove relativeTo:nil]; + } +*/ + return (void *)v; +} diff --git a/test/vars-pre.mk b/test/vars-pre.mk index 70e0143..bd4e887 100644 --- a/test/vars-pre.mk +++ b/test/vars-pre.mk @@ -6,13 +6,31 @@ ifeq ($(TEMPLATE), cmd) endif ifeq ($(TEMPLATE), lv2) - CFLAGS_EXTRA := $(shell pkg-config --cflags x11) - LDFLAGS_EXTRA := $(shell pkg-config --libs x11) -Wl,-rpath,$(shell pkg-config --variable=libdir x11) + ifeq ($(OS), Windows_NT) + else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + M_SRCS_EXTRA := $(PLUGIN_DIR)/ui_apple.m + LDFLAGS_EXTRA := -framework Cocoa -framework WebKit + else + CFLAGS_EXTRA := $(shell pkg-config --cflags x11) + LDFLAGS_EXTRA := $(shell pkg-config --libs x11) -Wl,-rpath,$(shell pkg-config --variable=libdir x11) + endif + endif endif ifeq ($(TEMPLATE), vst3) - CFLAGS_EXTRA := $(shell pkg-config --cflags x11) - LDFLAGS_EXTRA := $(shell pkg-config --libs x11) -Wl,-rpath,$(shell pkg-config --variable=libdir x11) + ifeq ($(OS), Windows_NT) + else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + M_SRCS_EXTRA := $(PLUGIN_DIR)/ui_apple.m + LDFLAGS_EXTRA := -framework Cocoa -framework WebKit + else + CFLAGS_EXTRA := $(shell pkg-config --cflags x11) + LDFLAGS_EXTRA := $(shell pkg-config --libs x11) -Wl,-rpath,$(shell pkg-config --variable=libdir x11) + endif + endif endif ifeq ($(TEMPLATE), daisy-seed)