Browse Source

Merge branch 'develop'

pull/201/head
falkTX 5 years ago
parent
commit
07d5018f60
45 changed files with 1165 additions and 155 deletions
  1. +1
    -0
      .travis/install.sh
  2. +9
    -3
      .travis/script-linux.sh
  3. +1
    -1
      .travis/script-win32.sh
  4. +1
    -1
      .travis/script-win64.sh
  5. +56
    -7
      Makefile.base.mk
  6. +24
    -17
      Makefile.plugins.mk
  7. +1
    -0
      README.md
  8. +9
    -0
      dgl/ImageWidgets.hpp
  9. +13
    -13
      dgl/Makefile
  10. +9
    -0
      dgl/src/ImageWidgets.cpp
  11. +175
    -74
      dgl/src/Window.cpp
  12. +441
    -0
      dgl/src/pugl/pugl_haiku.cpp
  13. +0
    -2
      dgl/src/pugl/pugl_win.cpp
  14. +2
    -0
      distrho/DistrhoPlugin.hpp
  15. +6
    -1
      distrho/src/DistrhoDefines.h
  16. +7
    -2
      distrho/src/DistrhoPluginChecks.h
  17. +41
    -10
      distrho/src/DistrhoPluginLV2.cpp
  18. +10
    -2
      distrho/src/DistrhoPluginLV2export.cpp
  19. +9
    -6
      distrho/src/DistrhoPluginVST.cpp
  20. +5
    -2
      distrho/src/DistrhoUIDSSI.cpp
  21. +10
    -1
      distrho/src/DistrhoUIInternal.hpp
  22. +8
    -0
      examples/CairoUI/DemoWidgetBanner.cpp
  23. +10
    -0
      examples/CairoUI/DemoWidgetBanner.hpp
  24. +8
    -0
      examples/CairoUI/DemoWidgetClickable.cpp
  25. +10
    -0
      examples/CairoUI/DemoWidgetClickable.hpp
  26. +1
    -1
      examples/CairoUI/Makefile
  27. +3
    -0
      examples/ExternalUI/Makefile
  28. +4
    -0
      examples/Info/DistrhoPluginInfo.h
  29. +42
    -0
      examples/Info/modgui.ttl
  30. BIN
      examples/Info/modgui/box.png
  31. +73
    -0
      examples/Info/modgui/icon-info.html
  32. BIN
      examples/Info/modgui/screenshot-info.png
  33. +57
    -0
      examples/Info/modgui/script-info.js
  34. +88
    -0
      examples/Info/modgui/stylesheet-info.css
  35. BIN
      examples/Info/modgui/thumbnail-tinygain.png
  36. +4
    -0
      examples/Info/modgui/tilesf1.LICENSE
  37. BIN
      examples/Info/modgui/tilesf1.jpg
  38. +1
    -1
      examples/Latency/Makefile
  39. +1
    -1
      examples/Meters/ExampleUIMeters.cpp
  40. +1
    -1
      examples/Meters/Makefile
  41. +1
    -1
      examples/Parameters/ExampleUIParameters.cpp
  42. +1
    -1
      examples/Parameters/Makefile
  43. +5
    -0
      examples/States/ExampleUIStates.cpp
  44. +1
    -1
      examples/States/Makefile
  45. +16
    -6
      utils/lv2-ttl-generator/GNUmakefile

+ 1
- 0
.travis/install.sh View File

@@ -5,6 +5,7 @@ set -e
sudo apt-get install -y \ sudo apt-get install -y \
g++ \ g++ \
pkg-config \ pkg-config \
libcairo2-dev \
libjack-jackd2-dev \ libjack-jackd2-dev \
liblo-dev \ liblo-dev \
libgl1-mesa-dev \ libgl1-mesa-dev \


+ 9
- 3
.travis/script-linux.sh View File

@@ -7,8 +7,14 @@ _FLAGS="-Werror"
export CFLAGS="${_FLAGS}" export CFLAGS="${_FLAGS}"
export CXXFLAGS="${_FLAGS}" export CXXFLAGS="${_FLAGS}"


# Start clean
echo "==============> Normal build"
make clean >/dev/null make clean >/dev/null

# Build now
make make

echo "==============> No namespace build"
make clean >/dev/null
make CXXFLAGS="${_FLAGS} -DDONT_SET_USING_DISTRHO_NAMESPACE -DDONT_SET_USING_DGL_NAMESPACE"

echo "==============> Custom namespace build"
make clean >/dev/null
make CXXFLAGS="${_FLAGS} -DDISTRHO_NAMESPACE=WubbWubb -DDGL_NAMESPACE=DabDab"

+ 1
- 1
.travis/script-win32.sh View File

@@ -17,4 +17,4 @@ export CROSS_COMPILING=true
make clean >/dev/null make clean >/dev/null


# Build now # Build now
make
make HAVE_CAIRO=false HAVE_JACK=false

+ 1
- 1
.travis/script-win64.sh View File

@@ -17,4 +17,4 @@ export CROSS_COMPILING=true
make clean >/dev/null make clean >/dev/null


# Build now # Build now
make
make HAVE_CAIRO=false HAVE_JACK=false

+ 56
- 7
Makefile.base.mk View File

@@ -11,6 +11,8 @@ CXX ?= g++
# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Auto-detect OS if not defined # Auto-detect OS if not defined


TARGET_MACHINE := $(shell $(CC) -dumpmachine)

ifneq ($(BSD),true) ifneq ($(BSD),true)
ifneq ($(HAIKU),true) ifneq ($(HAIKU),true)
ifneq ($(HURD),true) ifneq ($(HURD),true)
@@ -18,7 +20,6 @@ ifneq ($(LINUX),true)
ifneq ($(MACOS),true) ifneq ($(MACOS),true)
ifneq ($(WINDOWS),true) ifneq ($(WINDOWS),true)


TARGET_MACHINE := $(shell $(CC) -dumpmachine)
ifneq (,$(findstring bsd,$(TARGET_MACHINE))) ifneq (,$(findstring bsd,$(TARGET_MACHINE)))
BSD=true BSD=true
endif endif
@@ -45,6 +46,28 @@ endif
endif endif
endif endif


# ---------------------------------------------------------------------------------------------------------------------
# Auto-detect the processor

TARGET_PROCESSOR := $(firstword $(subst -, ,$(TARGET_MACHINE)))

ifneq (,$(filter i%86,$(TARGET_PROCESSOR)))
CPU_I386=true
CPU_I386_OR_X86_64=true
endif
ifneq (,$(filter x86_64,$(TARGET_PROCESSOR)))
CPU_X86_64=true
CPU_I386_OR_X86_64=true
endif
ifneq (,$(filter arm%,$(TARGET_PROCESSOR)))
CPU_ARM=true
CPU_ARM_OR_AARCH64=true
endif
ifneq (,$(filter aarch64%,$(TARGET_PROCESSOR)))
CPU_AARCH64=true
CPU_ARM_OR_AARCH64=true
endif

# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Set PKG_CONFIG (can be overridden by environment variable) # Set PKG_CONFIG (can be overridden by environment variable)


@@ -106,7 +129,15 @@ endif
# Set build and link flags # Set build and link flags


BASE_FLAGS = -Wall -Wextra -pipe -MD -MP BASE_FLAGS = -Wall -Wextra -pipe -MD -MP
BASE_OPTS = -O3 -ffast-math -mtune=generic -msse -msse2 -fdata-sections -ffunction-sections
BASE_OPTS = -O3 -ffast-math -mtune=generic -fdata-sections -ffunction-sections

ifeq ($(CPU_I386_OR_X86_64),true)
BASE_OPTS += -msse -msse2
endif

ifeq ($(CPU_ARM),true)
BASE_OPTS += -mfpu=neon-vfpv4 -mfloat-abi=hard
endif


ifeq ($(MACOS),true) ifeq ($(MACOS),true)
# MacOS linker flags # MacOS linker flags
@@ -208,18 +239,22 @@ HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true)
# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Set Generic DGL stuff # Set Generic DGL stuff


ifeq ($(HAIKU),true)
DGL_SYSTEM_LIBS += -lbe
endif

ifeq ($(MACOS),true) ifeq ($(MACOS),true)
DGL_SYSTEM_LIBS += -framework Cocoa
DGL_SYSTEM_LIBS += -framework Cocoa
endif endif


ifeq ($(WINDOWS),true) ifeq ($(WINDOWS),true)
DGL_SYSTEM_LIBS += -lgdi32 -lcomdlg32
DGL_SYSTEM_LIBS += -lgdi32 -lcomdlg32
endif endif


ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true) ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_X11),true) ifeq ($(HAVE_X11),true)
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11)
DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11)
DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
endif endif
endif endif


@@ -244,6 +279,11 @@ ifeq ($(HAVE_OPENGL),true)


DGL_FLAGS += -DHAVE_OPENGL DGL_FLAGS += -DHAVE_OPENGL


ifeq ($(HAIKU),true)
OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl)
OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl)
endif

ifeq ($(MACOS),true) ifeq ($(MACOS),true)
OPENGL_LIBS = -framework OpenGL OPENGL_LIBS = -framework OpenGL
endif endif
@@ -252,7 +292,7 @@ ifeq ($(WINDOWS),true)
OPENGL_LIBS = -lopengl32 OPENGL_LIBS = -lopengl32
endif endif


ifneq ($(MACOS_OR_WINDOWS),true)
ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl x11) OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl x11)
OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11) OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11)
endif endif
@@ -291,3 +331,12 @@ SHARED = -shared
endif endif


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Handle the verbosity switch

ifeq ($(VERBOSE),true)
SILENT =
else
SILENT = @
endif

# ---------------------------------------------------------------------------------------------------------------------

+ 24
- 17
Makefile.plugins.mk View File

@@ -70,8 +70,9 @@ UI_TYPE = opengl
endif endif


ifeq ($(UI_TYPE),cairo) ifeq ($(UI_TYPE),cairo)
DGL_FLAGS += -DDGL_CAIRO
ifeq ($(HAVE_CAIRO),true) ifeq ($(HAVE_CAIRO),true)
DGL_FLAGS += $(CAIRO_FLAGS) -DDGL_CAIRO
DGL_FLAGS += $(CAIRO_FLAGS)
DGL_LIBS += $(CAIRO_LIBS) DGL_LIBS += $(CAIRO_LIBS)
DGL_LIB = $(DPF_PATH)/build/libdgl-cairo.a DGL_LIB = $(DPF_PATH)/build/libdgl-cairo.a
HAVE_DGL = true HAVE_DGL = true
@@ -81,8 +82,9 @@ endif
endif endif


ifeq ($(UI_TYPE),opengl) ifeq ($(UI_TYPE),opengl)
DGL_FLAGS += -DDGL_OPENGL
ifeq ($(HAVE_OPENGL),true) ifeq ($(HAVE_OPENGL),true)
DGL_FLAGS += $(OPENGL_FLAGS) -DDGL_OPENGL
DGL_FLAGS += $(OPENGL_FLAGS)
DGL_LIBS += $(OPENGL_LIBS) DGL_LIBS += $(OPENGL_LIBS)
DGL_LIB = $(DPF_PATH)/build/libdgl-opengl.a DGL_LIB = $(DPF_PATH)/build/libdgl-opengl.a
HAVE_DGL = true HAVE_DGL = true
@@ -91,6 +93,11 @@ HAVE_DGL = false
endif endif
endif endif


ifeq ($(UI_TYPE),external)
DGL_FLAGS += -DDGL_EXTERNAL
HAVE_DGL = true
endif

DGL_LIBS += $(DGL_SYSTEM_LIBS) DGL_LIBS += $(DGL_SYSTEM_LIBS)


ifneq ($(HAVE_DGL),true) ifneq ($(HAVE_DGL),true)
@@ -114,17 +121,17 @@ all:
$(BUILD_DIR)/%.c.o: %.c $(BUILD_DIR)/%.c.o: %.c
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<" @echo "Compiling $<"
@$(CC) $< $(BUILD_C_FLAGS) -c -o $@
$(SILENT)$(CC) $< $(BUILD_C_FLAGS) -c -o $@


$(BUILD_DIR)/%.cc.o: %.cc $(BUILD_DIR)/%.cc.o: %.cc
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<" @echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@


$(BUILD_DIR)/%.cpp.o: %.cpp $(BUILD_DIR)/%.cpp.o: %.cpp
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<" @echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@


clean: clean:
rm -rf $(BUILD_DIR) rm -rf $(BUILD_DIR)
@@ -135,22 +142,22 @@ clean:
$(BUILD_DIR)/DistrhoPluginMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp $(BUILD_DIR)/DistrhoPluginMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp
-@mkdir -p $(BUILD_DIR) -@mkdir -p $(BUILD_DIR)
@echo "Compiling DistrhoPluginMain.cpp ($*)" @echo "Compiling DistrhoPluginMain.cpp ($*)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@


$(BUILD_DIR)/DistrhoUIMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp $(BUILD_DIR)/DistrhoUIMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp
-@mkdir -p $(BUILD_DIR) -@mkdir -p $(BUILD_DIR)
@echo "Compiling DistrhoUIMain.cpp ($*)" @echo "Compiling DistrhoUIMain.cpp ($*)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@


$(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp
-@mkdir -p $(BUILD_DIR) -@mkdir -p $(BUILD_DIR)
@echo "Compiling DistrhoPluginMain.cpp (JACK)" @echo "Compiling DistrhoPluginMain.cpp (JACK)"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(shell $(PKG_CONFIG) --cflags jack) -DDISTRHO_PLUGIN_TARGET_JACK -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(shell $(PKG_CONFIG) --cflags jack) -DDISTRHO_PLUGIN_TARGET_JACK -c -o $@


$(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp
-@mkdir -p $(BUILD_DIR) -@mkdir -p $(BUILD_DIR)
@echo "Compiling DistrhoUIMain.cpp (DSSI)" @echo "Compiling DistrhoUIMain.cpp (DSSI)"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(shell $(PKG_CONFIG) --cflags liblo) -DDISTRHO_PLUGIN_TARGET_DSSI -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(shell $(PKG_CONFIG) --cflags liblo) -DDISTRHO_PLUGIN_TARGET_DSSI -c -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# JACK # JACK
@@ -164,7 +171,7 @@ $(jack): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o
endif endif
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating JACK standalone for $(NAME)" @echo "Creating JACK standalone for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs jack) -o $@
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs jack) -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# LADSPA # LADSPA
@@ -174,7 +181,7 @@ ladspa: $(ladspa_dsp)
$(ladspa_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LADSPA.cpp.o $(ladspa_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LADSPA.cpp.o
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating LADSPA plugin for $(NAME)" @echo "Creating LADSPA plugin for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# DSSI # DSSI
@@ -186,12 +193,12 @@ dssi_ui: $(dssi_ui)
$(dssi_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.o $(dssi_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.o
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating DSSI plugin library for $(NAME)" @echo "Creating DSSI plugin library for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@


$(dssi_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o $(DGL_LIB) $(dssi_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o $(DGL_LIB)
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating DSSI UI for $(NAME)" @echo "Creating DSSI UI for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs liblo) -o $@
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs liblo) -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# LV2 # LV2
@@ -203,17 +210,17 @@ lv2_sep: $(lv2_dsp) $(lv2_ui)
$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB) $(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin for $(NAME)" @echo "Creating LV2 plugin for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@


$(lv2_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(lv2_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin library for $(NAME)" @echo "Creating LV2 plugin library for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@


$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB) $(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin UI for $(NAME)" @echo "Creating LV2 plugin UI for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# VST # VST
@@ -227,7 +234,7 @@ $(vst): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o
endif endif
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating VST plugin for $(NAME)" @echo "Creating VST plugin for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------




+ 1
- 0
README.md View File

@@ -36,6 +36,7 @@ List of plugins made with DPF:<br/>
- [Rezonateur](https://github.com/jpcima/rezonateur) - [Rezonateur](https://github.com/jpcima/rezonateur)
- [QuadraFuzz](https://github.com/jpcima/quadrafuzz) - [QuadraFuzz](https://github.com/jpcima/quadrafuzz)
- [Stone Phaser](https://github.com/jpcima/stone-phaser) - [Stone Phaser](https://github.com/jpcima/stone-phaser)
- [Uhhyou Plugins](https://github.com/ryukau/LV2Plugins)
- [Shiru Plugins](https://github.com/linuxmao-org/shiru-plugins) (work in progress) - [Shiru Plugins](https://github.com/linuxmao-org/shiru-plugins) (work in progress)
- [midiomatic](https://github.com/SpotlightKid/midiomatic) (work in progress) - [midiomatic](https://github.com/SpotlightKid/midiomatic) (work in progress)
- [osamc-lv2-workshop](https://github.com/osamc-lv2-workshop/lv2-workshop) (simple plugins code examples) - [osamc-lv2-workshop](https://github.com/osamc-lv2-workshop/lv2-workshop) (simple plugins code examples)


+ 9
- 0
dgl/ImageWidgets.hpp View File

@@ -25,8 +25,13 @@ START_NAMESPACE_DGL


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


#ifndef DISTRHO_OS_HAIKU
class ImageAboutWindow : public Window, class ImageAboutWindow : public Window,
public Widget public Widget
#else
// crash when creating or opening 2nd window
class ImageAboutWindow
#endif
{ {
public: public:
explicit ImageAboutWindow(Window& parent, const Image& image = Image()); explicit ImageAboutWindow(Window& parent, const Image& image = Image());
@@ -34,11 +39,15 @@ public:


void setImage(const Image& image); void setImage(const Image& image);


#ifndef DISTRHO_OS_HAIKU
protected: protected:
void onDisplay() override; void onDisplay() override;
bool onKeyboard(const KeyboardEvent&) override; bool onKeyboard(const KeyboardEvent&) override;
bool onMouse(const MouseEvent&) override; bool onMouse(const MouseEvent&) override;
void onReshape(uint width, uint height) override; void onReshape(uint width, uint height) override;
#else
void exec() {}
#endif


private: private:
Image fImgBackground; Image fImgBackground;


+ 13
- 13
dgl/Makefile View File

@@ -77,65 +77,65 @@ all: $(TARGETS)
../build/libdgl-cairo.a: $(OBJS_cairo) ../build/libdgl-cairo.a: $(OBJS_cairo)
-@mkdir -p ../build -@mkdir -p ../build
@echo "Creating libdgl-cairo.a" @echo "Creating libdgl-cairo.a"
@rm -f $@
@$(AR) crs $@ $^
$(SILENT)rm -f $@
$(SILENT)$(AR) crs $@ $^


../build/libdgl-opengl.a: $(OBJS_opengl) ../build/libdgl-opengl.a: $(OBJS_opengl)
-@mkdir -p ../build -@mkdir -p ../build
@echo "Creating libdgl-opengl.a" @echo "Creating libdgl-opengl.a"
@rm -f $@
@$(AR) crs $@ $^
$(SILENT)rm -f $@
$(SILENT)$(AR) crs $@ $^


# Compat name, to be removed soon # Compat name, to be removed soon
../build/libdgl.a: ../build/libdgl-opengl.a ../build/libdgl.a: ../build/libdgl-opengl.a
@echo "Symlinking libdgl.a" @echo "Symlinking libdgl.a"
@ln -sf $< $@
$(SILENT)ln -sf $< $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


../build/dgl/%.c.o: src/%.c ../build/dgl/%.c.o: src/%.c
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $<" @echo "Compiling $<"
@$(CC) $< $(BUILD_C_FLAGS) -c -o $@
$(SILENT)$(CC) $< $(BUILD_C_FLAGS) -c -o $@


../build/dgl/%.cpp.o: src/%.cpp ../build/dgl/%.cpp.o: src/%.cpp
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $<" @echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


../build/dgl/%.cpp.cairo.o: src/%.cpp ../build/dgl/%.cpp.cairo.o: src/%.cpp
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $< (Cairo variant)" @echo "Compiling $< (Cairo variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -c -o $@


../build/dgl/Window.cpp.cairo.o: src/Window.cpp src/sofd/* src/pugl/* ../build/dgl/Window.cpp.cairo.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $< (Cairo variant)" @echo "Compiling $< (Cairo variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -c -o $@


../build/dgl/Window.mm.cairo.o: src/Window.cpp src/sofd/* src/pugl/* ../build/dgl/Window.mm.cairo.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $< (Cairo variant)" @echo "Compiling $< (Cairo variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -ObjC++ -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(CAIRO_FLAGS) -DDGL_CAIRO -ObjC++ -c -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


../build/dgl/%.cpp.opengl.o: src/%.cpp ../build/dgl/%.cpp.opengl.o: src/%.cpp
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)" @echo "Compiling $< (OpenGL variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@


../build/dgl/Window.cpp.opengl.o: src/Window.cpp src/sofd/* src/pugl/* ../build/dgl/Window.cpp.opengl.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)" @echo "Compiling $< (OpenGL variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -c -o $@


../build/dgl/Window.mm.opengl.o: src/Window.cpp src/sofd/* src/pugl/* ../build/dgl/Window.mm.opengl.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)" @echo "Compiling $< (OpenGL variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -ObjC++ -c -o $@
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(OPENGL_FLAGS) -DDGL_OPENGL -ObjC++ -c -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------




+ 9
- 0
dgl/src/ImageWidgets.cpp View File

@@ -25,6 +25,7 @@ START_NAMESPACE_DGL


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


#ifndef DISTRHO_OS_HAIKU
ImageAboutWindow::ImageAboutWindow(Window& parent, const Image& image) ImageAboutWindow::ImageAboutWindow(Window& parent, const Image& image)
: Window(parent.getApp(), parent), : Window(parent.getApp(), parent),
Widget((Window&)*this), Widget((Window&)*this),
@@ -44,6 +45,10 @@ ImageAboutWindow::ImageAboutWindow(Widget* widget, const Image& image)
Window::setSize(image.getSize()); Window::setSize(image.getSize());
Window::setTitle("About"); Window::setTitle("About");
} }
#else
ImageAboutWindow::ImageAboutWindow(Window& parent, const Image& image) : fImgBackground(image) {}
ImageAboutWindow::ImageAboutWindow(Widget* widget, const Image& image) : fImgBackground(image) {}
#endif


void ImageAboutWindow::setImage(const Image& image) void ImageAboutWindow::setImage(const Image& image)
{ {
@@ -51,9 +56,12 @@ void ImageAboutWindow::setImage(const Image& image)
return; return;


fImgBackground = image; fImgBackground = image;
#ifndef DISTRHO_OS_HAIKU
Window::setSize(image.getSize()); Window::setSize(image.getSize());
#endif
} }


#ifndef DISTRHO_OS_HAIKU
void ImageAboutWindow::onDisplay() void ImageAboutWindow::onDisplay()
{ {
fImgBackground.draw(); fImgBackground.draw();
@@ -86,6 +94,7 @@ void ImageAboutWindow::onReshape(uint width, uint height)
Widget::setSize(width, height); Widget::setSize(width, height);
Window::onReshape(width, height); Window::onReshape(width, height);
} }
#endif


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------




+ 175
- 74
dgl/src/Window.cpp View File

@@ -37,14 +37,17 @@
# pragma GCC diagnostic ignored "-Wimplicit-fallthrough" # pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#endif #endif


#if defined(DISTRHO_OS_WINDOWS)
# include "pugl/pugl_win.cpp"
# undef max
# undef min
#if defined(DISTRHO_OS_HAIKU)
# define DGL_DEBUG_EVENTS
# include "pugl/pugl_haiku.cpp"
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
# define PuglWindow DISTRHO_JOIN_MACRO(PuglWindow, DGL_NAMESPACE) # define PuglWindow DISTRHO_JOIN_MACRO(PuglWindow, DGL_NAMESPACE)
# define PuglOpenGLView DISTRHO_JOIN_MACRO(PuglOpenGLView, DGL_NAMESPACE) # define PuglOpenGLView DISTRHO_JOIN_MACRO(PuglOpenGLView, DGL_NAMESPACE)
# include "pugl/pugl_osx.m" # include "pugl/pugl_osx.m"
#elif defined(DISTRHO_OS_WINDOWS)
# include "pugl/pugl_win.cpp"
# undef max
# undef min
#else #else
# include <sys/types.h> # include <sys/types.h>
# include <unistd.h> # include <unistd.h>
@@ -99,9 +102,10 @@ struct Window::PrivateData {
fTitle(nullptr), fTitle(nullptr),
fWidgets(), fWidgets(),
fModal(), fModal(),
#if defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
#if defined(DISTRHO_OS_HAIKU)
bApplication(nullptr),
bView(nullptr),
bWindow(nullptr)
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
fNeedsIdle(true), fNeedsIdle(true),
mView(nullptr), mView(nullptr),
@@ -111,6 +115,9 @@ struct Window::PrivateData {
, fOpenFilePanel(nullptr), , fOpenFilePanel(nullptr),
fFilePanelDelegate(nullptr) fFilePanelDelegate(nullptr)
# endif # endif
#elif defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
#else #else
xDisplay(nullptr), xDisplay(nullptr),
xWindow(0) xWindow(0)
@@ -135,9 +142,10 @@ struct Window::PrivateData {
fTitle(nullptr), fTitle(nullptr),
fWidgets(), fWidgets(),
fModal(parent.pData), fModal(parent.pData),
#if defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
#if defined(DISTRHO_OS_HAIKU)
bApplication(nullptr),
bView(nullptr),
bWindow(nullptr)
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
fNeedsIdle(false), fNeedsIdle(false),
mView(nullptr), mView(nullptr),
@@ -147,6 +155,9 @@ struct Window::PrivateData {
, fOpenFilePanel(nullptr), , fOpenFilePanel(nullptr),
fFilePanelDelegate(nullptr) fFilePanelDelegate(nullptr)
# endif # endif
#elif defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
#else #else
xDisplay(nullptr), xDisplay(nullptr),
xWindow(0) xWindow(0)
@@ -158,11 +169,13 @@ struct Window::PrivateData {
const PuglInternals* const parentImpl(parent.pData->fView->impl); const PuglInternals* const parentImpl(parent.pData->fView->impl);


// NOTE: almost a 1:1 copy of setTransientWinId() // NOTE: almost a 1:1 copy of setTransientWinId()
#if defined(DISTRHO_OS_WINDOWS)
hwndParent = parentImpl->hwnd;
SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONG_PTR)hwndParent);
#if defined(DISTRHO_OS_HAIKU)
// TODO
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
mParentWindow = parentImpl->window; mParentWindow = parentImpl->window;
#elif defined(DISTRHO_OS_WINDOWS)
hwndParent = parentImpl->hwnd;
SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONG_PTR)hwndParent);
#else #else
XSetTransientForHint(xDisplay, xWindow, parentImpl->win); XSetTransientForHint(xDisplay, xWindow, parentImpl->win);
#endif #endif
@@ -183,9 +196,10 @@ struct Window::PrivateData {
fTitle(nullptr), fTitle(nullptr),
fWidgets(), fWidgets(),
fModal(), fModal(),
#if defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
#if defined(DISTRHO_OS_HAIKU)
bApplication(nullptr),
bView(nullptr),
bWindow(nullptr)
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
fNeedsIdle(parentId == 0), fNeedsIdle(parentId == 0),
mView(nullptr), mView(nullptr),
@@ -195,6 +209,9 @@ struct Window::PrivateData {
, fOpenFilePanel(nullptr), , fOpenFilePanel(nullptr),
fFilePanelDelegate(nullptr) fFilePanelDelegate(nullptr)
# endif # endif
#elif defined(DISTRHO_OS_WINDOWS)
hwnd(nullptr),
hwndParent(nullptr)
#else #else
xDisplay(nullptr), xDisplay(nullptr),
xWindow(0) xWindow(0)
@@ -249,9 +266,10 @@ struct Window::PrivateData {


PuglInternals* impl = fView->impl; PuglInternals* impl = fView->impl;


#if defined(DISTRHO_OS_WINDOWS)
hwnd = impl->hwnd;
DISTRHO_SAFE_ASSERT(hwnd != 0);
#if defined(DISTRHO_OS_HAIKU)
bApplication = impl->app;
bView = impl->view;
bWindow = impl->window;
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
mView = impl->view; mView = impl->view;
mWindow = impl->window; mWindow = impl->window;
@@ -261,6 +279,9 @@ struct Window::PrivateData {
} else { } else {
DISTRHO_SAFE_ASSERT(mWindow != nullptr); DISTRHO_SAFE_ASSERT(mWindow != nullptr);
} }
#elif defined(DISTRHO_OS_WINDOWS)
hwnd = impl->hwnd;
DISTRHO_SAFE_ASSERT(hwnd != 0);
#else #else
xDisplay = impl->display; xDisplay = impl->display;
xWindow = impl->win; xWindow = impl->win;
@@ -281,7 +302,6 @@ struct Window::PrivateData {
XInternAtom(xDisplay, "_NET_WM_WINDOW_TYPE_NORMAL", False) XInternAtom(xDisplay, "_NET_WM_WINDOW_TYPE_NORMAL", False)
}; };
XChangeProperty(xDisplay, xWindow, _wt, XA_ATOM, 32, PropModeReplace, (const uchar*)&_wts, 2); XChangeProperty(xDisplay, xWindow, _wt, XA_ATOM, 32, PropModeReplace, (const uchar*)&_wts, 2);

} }
#endif #endif
puglEnterContext(fView); puglEnterContext(fView);
@@ -327,11 +347,15 @@ struct Window::PrivateData {
fTitle = nullptr; fTitle = nullptr;
} }


#if defined(DISTRHO_OS_WINDOWS)
hwnd = 0;
#if defined(DISTRHO_OS_HAIKU)
bApplication = nullptr;
bView = nullptr;
bWindow = nullptr;
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
mView = nullptr; mView = nullptr;
mWindow = nullptr; mWindow = nullptr;
#elif defined(DISTRHO_OS_WINDOWS)
hwnd = 0;
#else #else
xDisplay = nullptr; xDisplay = nullptr;
xWindow = 0; xWindow = 0;
@@ -419,10 +443,12 @@ struct Window::PrivateData {


// the mouse position probably changed since the modal appeared, // the mouse position probably changed since the modal appeared,
// so send a mouse motion event to the modal's parent window // so send a mouse motion event to the modal's parent window
#if defined(DISTRHO_OS_WINDOWS)
#if defined(DISTRHO_OS_HAIKU)
// TODO // TODO
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
// TODO // TODO
#elif defined(DISTRHO_OS_WINDOWS)
// TODO
#else #else
int i, wx, wy; int i, wx, wy;
uint u; uint u;
@@ -440,13 +466,26 @@ struct Window::PrivateData {
void focus() void focus()
{ {
DBG("Window focus\n"); DBG("Window focus\n");
#if defined(DISTRHO_OS_WINDOWS)
SetForegroundWindow(hwnd);
SetActiveWindow(hwnd);
SetFocus(hwnd);
#if defined(DISTRHO_OS_HAIKU)
if (bWindow != nullptr)
{
if (bWindow->LockLooper())
{
bWindow->Activate(true);
bWindow->UnlockLooper();
}
}
else
{
bView->MakeFocus(true);
}
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
if (mWindow != nullptr) if (mWindow != nullptr)
[mWindow makeKeyWindow]; [mWindow makeKeyWindow];
#elif defined(DISTRHO_OS_WINDOWS)
SetForegroundWindow(hwnd);
SetActiveWindow(hwnd);
SetFocus(hwnd);
#else #else
XRaiseWindow(xDisplay, xWindow); XRaiseWindow(xDisplay, xWindow);
XSetInputFocus(xDisplay, xWindow, RevertToPointerRoot, CurrentTime); XSetInputFocus(xDisplay, xWindow, RevertToPointerRoot, CurrentTime);
@@ -476,38 +515,28 @@ struct Window::PrivateData {
if (yesNo && fFirstInit) if (yesNo && fFirstInit)
setSize(fWidth, fHeight, true); setSize(fWidth, fHeight, true);


#if defined(DISTRHO_OS_WINDOWS)
if (yesNo)
#if defined(DISTRHO_OS_HAIKU)
if (bWindow != nullptr)
{ {
if (fFirstInit)
if (bWindow->LockLooper())
{ {
RECT rectChild, rectParent;

if (hwndParent != nullptr &&
GetWindowRect(hwnd, &rectChild) &&
GetWindowRect(hwndParent, &rectParent))
{
SetWindowPos(hwnd, hwndParent,
rectParent.left + (rectChild.right-rectChild.left)/2,
rectParent.top + (rectChild.bottom-rectChild.top)/2,
0, 0, SWP_SHOWWINDOW|SWP_NOSIZE);
}
if (yesNo)
bWindow->Show();
else else
{
ShowWindow(hwnd, SW_SHOWNORMAL);
}
}
else
{
ShowWindow(hwnd, SW_RESTORE);
bWindow->Hide();

// TODO use flush?
bWindow->Sync();
bWindow->UnlockLooper();
} }
} }
else else
{ {
ShowWindow(hwnd, SW_HIDE);
if (yesNo)
bView->Show();
else
bView->Hide();
} }

UpdateWindow(hwnd);
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
if (yesNo) if (yesNo)
{ {
@@ -538,6 +567,38 @@ struct Window::PrivateData {
[mView setHidden:YES]; [mView setHidden:YES];
} }
} }
#elif defined(DISTRHO_OS_WINDOWS)
if (yesNo)
{
if (fFirstInit)
{
RECT rectChild, rectParent;

if (hwndParent != nullptr &&
GetWindowRect(hwnd, &rectChild) &&
GetWindowRect(hwndParent, &rectParent))
{
SetWindowPos(hwnd, hwndParent,
rectParent.left + (rectChild.right-rectChild.left)/2,
rectParent.top + (rectChild.bottom-rectChild.top)/2,
0, 0, SWP_SHOWWINDOW|SWP_NOSIZE);
}
else
{
ShowWindow(hwnd, SW_SHOWNORMAL);
}
}
else
{
ShowWindow(hwnd, SW_RESTORE);
}
}
else
{
ShowWindow(hwnd, SW_HIDE);
}

UpdateWindow(hwnd);
#else #else
if (yesNo) if (yesNo)
XMapRaised(xDisplay, xWindow); XMapRaised(xDisplay, xWindow);
@@ -579,13 +640,18 @@ struct Window::PrivateData {
fResizable = yesNo; fResizable = yesNo;
fView->user_resizable = yesNo; fView->user_resizable = yesNo;


#if defined(DISTRHO_OS_WINDOWS)
#if defined(DISTRHO_OS_HAIKU)
// TODO
// B_NO_BORDER
// B_TITLED_WINDOW_LOOK
// bWindow->SetFlags();
#elif defined(DISTRHO_OS_MAC)
const uint flags = yesNo ? (NSViewWidthSizable|NSViewHeightSizable) : 0x0;
[mView setAutoresizingMask:flags];
#elif defined(DISTRHO_OS_WINDOWS)
const int winFlags = fResizable ? GetWindowLong(hwnd, GWL_STYLE) | WS_SIZEBOX const int winFlags = fResizable ? GetWindowLong(hwnd, GWL_STYLE) | WS_SIZEBOX
: GetWindowLong(hwnd, GWL_STYLE) & ~WS_SIZEBOX; : GetWindowLong(hwnd, GWL_STYLE) & ~WS_SIZEBOX;
SetWindowLong(hwnd, GWL_STYLE, winFlags); SetWindowLong(hwnd, GWL_STYLE, winFlags);
#elif defined(DISTRHO_OS_MAC)
const uint flags(yesNo ? (NSViewWidthSizable|NSViewHeightSizable) : 0x0);
[mView setAutoresizingMask:flags];
#endif #endif


setSize(fWidth, fHeight, true); setSize(fWidth, fHeight, true);
@@ -624,16 +690,20 @@ struct Window::PrivateData {


DBGp("Window setSize called %s, size %i %i, resizable %s\n", forced ? "(forced)" : "(not forced)", width, height, fResizable?"true":"false"); DBGp("Window setSize called %s, size %i %i, resizable %s\n", forced ? "(forced)" : "(not forced)", width, height, fResizable?"true":"false");


#if defined(DISTRHO_OS_WINDOWS)
const int winFlags = WS_POPUPWINDOW | WS_CAPTION | (fResizable ? WS_SIZEBOX : 0x0);
RECT wr = { 0, 0, static_cast<LONG>(width), static_cast<LONG>(height) };
AdjustWindowRectEx(&wr, fUsingEmbed ? WS_CHILD : winFlags, FALSE, WS_EX_TOPMOST);
#if defined(DISTRHO_OS_HAIKU)
bView->ResizeTo(width, height);


SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top,
SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);
if (bWindow != nullptr && bWindow->LockLooper())
{
bWindow->MoveTo(50, 50);
bWindow->ResizeTo(width, height);


if (! forced)
UpdateWindow(hwnd);
if (! forced)
bWindow->Flush();

bWindow->UnlockLooper();
}
// TODO resizable
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
[mView setFrame:NSMakeRect(0, 0, width, height)]; [mView setFrame:NSMakeRect(0, 0, width, height)];


@@ -655,6 +725,16 @@ struct Window::PrivateData {
[[mWindow standardWindowButton:NSWindowZoomButton] setHidden:YES]; [[mWindow standardWindowButton:NSWindowZoomButton] setHidden:YES];
} }
} }
#elif defined(DISTRHO_OS_WINDOWS)
const int winFlags = WS_POPUPWINDOW | WS_CAPTION | (fResizable ? WS_SIZEBOX : 0x0);
RECT wr = { 0, 0, static_cast<LONG>(width), static_cast<LONG>(height) };
AdjustWindowRectEx(&wr, fUsingEmbed ? WS_CHILD : winFlags, FALSE, WS_EX_TOPMOST);

SetWindowPos(hwnd, 0, 0, 0, wr.right-wr.left, wr.bottom-wr.top,
SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER);

if (! forced)
UpdateWindow(hwnd);
#else #else


if (! fResizable) if (! fResizable)
@@ -700,8 +780,12 @@ struct Window::PrivateData {


fTitle = strdup(title); fTitle = strdup(title);


#if defined(DISTRHO_OS_WINDOWS)
SetWindowTextA(hwnd, title);
#if defined(DISTRHO_OS_HAIKU)
if (bWindow != nullptr&& bWindow->LockLooper())
{
bWindow->SetTitle(title);
bWindow->UnlockLooper();
}
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
if (mWindow != nullptr) if (mWindow != nullptr)
{ {
@@ -712,6 +796,8 @@ struct Window::PrivateData {


[mWindow setTitle:titleString]; [mWindow setTitle:titleString];
} }
#elif defined(DISTRHO_OS_WINDOWS)
SetWindowTextA(hwnd, title);
#else #else
XStoreName(xDisplay, xWindow, title); XStoreName(xDisplay, xWindow, title);
Atom netWmName = XInternAtom(xDisplay, "_NET_WM_NAME", False); Atom netWmName = XInternAtom(xDisplay, "_NET_WM_NAME", False);
@@ -724,15 +810,17 @@ struct Window::PrivateData {
{ {
DISTRHO_SAFE_ASSERT_RETURN(winId != 0,); DISTRHO_SAFE_ASSERT_RETURN(winId != 0,);


#if defined(DISTRHO_OS_WINDOWS)
hwndParent = (HWND)winId;
SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONG_PTR)winId);
#if defined(DISTRHO_OS_HAIKU)
// TODO
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
NSWindow* const parentWindow = [NSApp windowWithWindowNumber:winId]; NSWindow* const parentWindow = [NSApp windowWithWindowNumber:winId];
DISTRHO_SAFE_ASSERT_RETURN(parentWindow != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(parentWindow != nullptr,);


[parentWindow addChildWindow:mWindow [parentWindow addChildWindow:mWindow
ordered:NSWindowAbove]; ordered:NSWindowAbove];
#elif defined(DISTRHO_OS_WINDOWS)
hwndParent = (HWND)winId;
SetWindowLongPtr(hwnd, GWLP_HWNDPARENT, (LONG_PTR)winId);
#else #else
XSetTransientForHint(xDisplay, xWindow, static_cast< ::Window>(winId)); XSetTransientForHint(xDisplay, xWindow, static_cast< ::Window>(winId));
#endif #endif
@@ -780,6 +868,15 @@ struct Window::PrivateData {
{ {
puglProcessEvents(fView); puglProcessEvents(fView);


#ifdef DISTRHO_OS_HAIKU
if (bApplication != nullptr)
{
// bApplication->Lock();
// bApplication->Loop();
// bApplication->Unlock();
}
#endif

#ifdef DISTRHO_OS_MAC #ifdef DISTRHO_OS_MAC
if (fNeedsIdle) if (fNeedsIdle)
{ {
@@ -1164,12 +1261,10 @@ struct Window::PrivateData {
DISTRHO_DECLARE_NON_COPY_STRUCT(Modal) DISTRHO_DECLARE_NON_COPY_STRUCT(Modal)
} fModal; } fModal;


#if defined(DISTRHO_OS_WINDOWS)
HWND hwnd;
HWND hwndParent;
# ifndef DGL_FILE_BROWSER_DISABLED
String fSelectedFile;
# endif
#if defined(DISTRHO_OS_HAIKU)
BApplication* bApplication;
BView* bView;
BWindow* bWindow;
#elif defined(DISTRHO_OS_MAC) #elif defined(DISTRHO_OS_MAC)
bool fNeedsIdle; bool fNeedsIdle;
NSView<PuglGenericView>* mView; NSView<PuglGenericView>* mView;
@@ -1179,6 +1274,12 @@ struct Window::PrivateData {
NSOpenPanel* fOpenFilePanel; NSOpenPanel* fOpenFilePanel;
id fFilePanelDelegate; id fFilePanelDelegate;
# endif # endif
#elif defined(DISTRHO_OS_WINDOWS)
HWND hwnd;
HWND hwndParent;
# ifndef DGL_FILE_BROWSER_DISABLED
String fSelectedFile;
# endif
#else #else
Display* xDisplay; Display* xDisplay;
::Window xWindow; ::Window xWindow;


+ 441
- 0
dgl/src/pugl/pugl_haiku.cpp View File

@@ -0,0 +1,441 @@
/*
Copyright 2019 Filipe Coelho <falktx@falktx.com>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/**
@file pugl_haiku.cpp BeOS/HaikuOS Pugl Implementation.
*/

#include <Application.h>
#include <interface/Window.h>

#ifdef PUGL_CAIRO
#include <cairo/cairo.h>
typedef BView BViewType;
#endif
#ifdef PUGL_OPENGL
#include <GL/gl.h>
#include <opengl/GLView.h>
typedef BGLView BViewType;
#endif

#include "pugl_internal.h"

class DWindow;

struct PuglInternalsImpl {
BApplication* app;
BViewType* view;
DWindow* window;
};

static void
puglReshape(PuglView* view, int width, int height)
{
puglEnterContext(view);

if (view->reshapeFunc) {
view->reshapeFunc(view, width, height);
} else {
puglDefaultReshape(width, height);
}

puglLeaveContext(view, false);

view->width = width;
view->height = height;
}

static void
puglDisplay(PuglView* view)
{
puglEnterContext(view);

view->redisplay = false;
if (view->displayFunc) {
view->displayFunc(view);
}

puglLeaveContext(view, true);
}

void
puglEnterContext(PuglView* view)
{
PuglInternals* impl = view->impl;

#ifdef PUGL_OPENGL
// FIXME without the first unlock we freeze
impl->view->UnlockGL();
impl->view->LockGL();
#endif
}

void
puglLeaveContext(PuglView* view, bool flush)
{
PuglInternals* impl = view->impl;

#ifdef PUGL_OPENGL
if (flush)
impl->view->SwapBuffers();

impl->view->UnlockGL();
#endif
}

PuglInternals*
puglInitInternals()
{
return (PuglInternals*)calloc(1, sizeof(PuglInternals));
}

class DView : public BViewType
{
public:
#ifdef PUGL_CAIRO
DView(PuglView* const v)
: BView(nullptr,
B_FULL_UPDATE_ON_RESIZE|B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE|B_INPUT_METHOD_AWARE),
puglView(v) {}
#endif

#ifdef PUGL_OPENGL
DView(PuglView* const v)
: BGLView(BRect(), // causes "bitmap bounds is much too large: BRect(0.0, 0.0, 4294967296.0, 4294967296.0)"
"DPF-GLView",
0x0, // resize mode
B_FULL_UPDATE_ON_RESIZE|B_WILL_DRAW|B_NAVIGABLE_JUMP|B_FRAME_EVENTS|B_NAVIGABLE|B_INPUT_METHOD_AWARE,
BGL_RGB|BGL_DOUBLE|BGL_ALPHA|BGL_DEPTH|BGL_STENCIL),
puglView(v)
{
}
#endif

protected:
void GetPreferredSize(float* width, float* height) override
{
d_stdout("%s %i", __func__, __LINE__);
if (width != nullptr)
*width = puglView->width;
if (height != nullptr)
*height = puglView->height;
d_stdout("%s %i", __func__, __LINE__);
}
void Draw(BRect updateRect) override
{
d_stdout("%s %i", __func__, __LINE__);
puglDisplay(puglView);
#ifdef PUGL_OPENGL
BGLView::Draw(updateRect);
d_stdout("%s %i", __func__, __LINE__);
#endif
}

void MessageReceived(BMessage* message)
{
d_stdout("MessageReceived %p", message);
BViewType::MessageReceived(message);
}

void MouseDown(BPoint where) override
{
if (puglView->mouseFunc) {
// puglView->event_timestamp_ms = GetMessageTime();
d_stdout("MouseDown mask %u", EventMask());
puglView->mouseFunc(puglView, 1, true, where.x, where.y);
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
}
//BViewType::MouseDown(where);
}

void MouseUp(BPoint where) override
{
if (puglView->mouseFunc) {
d_stdout("MouseUp mask %u", EventMask());
// puglView->event_timestamp_ms = GetMessageTime();
puglView->mouseFunc(puglView, 1, false, where.x, where.y);
}
//BViewType::MouseUp(where);
}

void MouseMoved(BPoint where, uint32, const BMessage*) override
{
if (puglView->motionFunc) {
// puglView->event_timestamp_ms = GetMessageTime();
puglView->motionFunc(puglView, where.x, where.y);
}
}

void KeyDown(const char* bytes, int32 numBytes) override
{
d_stdout("KeyDown %i", numBytes);
if (numBytes != 1)
return; // TODO
if (puglView->keyboardFunc) {
puglView->keyboardFunc(puglView, true, bytes[0]);
}
}

void KeyUp(const char* bytes, int32 numBytes) override
{
d_stdout("KeyUp %i", numBytes);
if (numBytes != 1)
return; // TODO
if (puglView->keyboardFunc) {
puglView->keyboardFunc(puglView, false, bytes[0]);
}
}
void ScrollTo(BPoint where) override
{
d_stdout("ScrollTo mask %u", EventMask());
BViewType::ScrollTo(where);
}

void FrameResized(float newWidth, float newHeight) override
{
d_stdout("%s %i", __func__, __LINE__);
puglReshape(puglView, static_cast<int>(newWidth), static_cast<int>(newHeight));
#ifdef PUGL_OPENGL
BGLView::FrameResized(newWidth, newHeight);
#endif
d_stdout("%s %i", __func__, __LINE__);
}

private:
PuglView* const puglView;
};

class DWindow : public BWindow
{
public:
DWindow(PuglView* const v)
: BWindow(BRect(1.0f), "DPF-Window", B_TITLED_WINDOW, 0x0),
puglView(v),
needsQuit(true)
{
}
bool NeedsQuit() const
{
return needsQuit;
}

protected:
bool QuitRequested() override
{
d_stdout("%s %i", __func__, __LINE__);
if (puglView->closeFunc) {
puglView->closeFunc(puglView);
puglView->redisplay = false;
}
needsQuit = false;
d_stdout("%s %i", __func__, __LINE__);
return true;
}

private:
PuglView* const puglView;
bool needsQuit;
};

int
puglCreateWindow(PuglView* view, const char* title)
{
PuglInternals* impl = view->impl;

if (be_app == nullptr)
{
d_stdout("creating app");
status_t status;
BApplication* const app = new BApplication("application/x-vnd.dpf-application", &status);

if (status != B_OK)
{
d_stdout("app status error %u", status);
delete app;
return 1;
}

impl->app = app;
}
else
{
d_stdout("using existing app");
}
if (view->parent == 0) {
impl->window = new DWindow(view);
impl->window->Lock();
}

impl->view = new DView(view);

if (view->parent != 0) {
BView* const pview = (BView*)view->parent;
pview->AddChild(impl->view);
impl->view->LockGL();
return 0;
}

if (title != nullptr) {
impl->window->SetTitle(title);
}
impl->window->AddChild(impl->view);
impl->view->LockGL();
//puglEnterContext(view);
impl->window->Unlock();
return 0;
}

void
puglShowWindow(PuglView* view)
{
PuglInternals* impl = view->impl;

if (impl->window != nullptr)
{
if (impl->window->LockLooper())
{
impl->window->Show();
impl->window->UnlockLooper();
}
}
else
{
impl->view->Show();
}
}

void
puglHideWindow(PuglView* view)
{
PuglInternals* impl = view->impl;

if (impl->window != nullptr)
{
if (impl->window->LockLooper())
{
impl->window->Hide();
impl->window->UnlockLooper();
}
}
else
{
impl->view->Show();
}
}

void
puglDestroy(PuglView* view)
{
PuglInternals* impl = view->impl;

if (impl->window != nullptr)
{
// impl->window->Lock();
puglLeaveContext(view, false);
impl->window->RemoveChild(impl->view);
// impl->window->Unlock();

if (impl->window->NeedsQuit())
impl->window->Quit();
}

delete impl->view;
impl->view = nullptr;
impl->window = nullptr;

if (impl->app != nullptr && impl->app->CountWindows() == 0)
{
d_stdout("deleting app");
delete impl->app;
impl->app = nullptr;
} else
d_stdout("NOT deleting app");
}

PuglStatus
puglProcessEvents(PuglView* view)
{
return PUGL_SUCCESS;
}

void
puglPostRedisplay(PuglView* view)
{
PuglInternals* impl = view->impl;

view->redisplay = true;

if (impl->window != nullptr)
{
if (impl->window->LockLooper())
{
impl->view->Invalidate();
impl->window->UnlockLooper();
}
}
else
{
impl->view->Invalidate();
}
}

PuglNativeWindow
puglGetNativeWindow(PuglView* view)
{
PuglInternals* impl = view->impl;

#ifdef PUGL_OPENGL
// return (PuglNativeWindow)impl->view->EmbeddedView();
#endif

return (PuglNativeWindow)(BView*)impl->view;
}

void*
puglGetContext(PuglView* view)
{
return NULL;
}

int
puglUpdateGeometryConstraints(PuglView* view, int min_width, int min_height, bool aspect)
{
PuglInternals* impl = view->impl;

d_stdout("puglUpdateGeometryConstraints %i %i %i %i", min_width, min_height, view->width, view->height);
if (impl->window->LockLooper())
{
impl->window->SetSizeLimits(min_width,
view->user_resizable ? 4096 : min_width,
min_height,
view->user_resizable ? 4096 : min_height);

impl->window->UnlockLooper();
return 0;
}

return 1;

// TODO
(void)aspect;
}

+ 0
- 2
dgl/src/pugl/pugl_win.cpp View File

@@ -392,8 +392,6 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
case WM_SIZE: case WM_SIZE:
GetClientRect(view->impl->hwnd, &rect); GetClientRect(view->impl->hwnd, &rect);
puglReshape(view, rect.right, rect.bottom); puglReshape(view, rect.right, rect.bottom);
view->width = rect.right;
view->height = rect.bottom;
break; break;
case WM_GETMINMAXINFO: case WM_GETMINMAXINFO:
mmi = (MINMAXINFO*)lParam; mmi = (MINMAXINFO*)lParam;


+ 2
- 0
distrho/DistrhoPlugin.hpp View File

@@ -365,6 +365,8 @@ struct ParameterEnumerationValues {
values = nullptr; values = nullptr;
} }
} }

DISTRHO_DECLARE_NON_COPY_STRUCT(ParameterEnumerationValues)
}; };


/** /**


+ 6
- 1
distrho/src/DistrhoDefines.h View File

@@ -128,7 +128,12 @@ private: \
StructName& operator=(StructName&) = delete; \ StructName& operator=(StructName&) = delete; \
StructName& operator=(const StructName&) = delete; StructName& operator=(const StructName&) = delete;
#else #else
# define DISTRHO_DECLARE_NON_COPY_STRUCT(StructName)
# define DISTRHO_DECLARE_NON_COPY_STRUCT(StructName) \
private: \
StructName(StructName&); \
StructName(const StructName&); \
StructName& operator=(StructName&); \
StructName& operator=(const StructName&);
#endif #endif


/* Define DISTRHO_PREVENT_HEAP_ALLOCATION */ /* Define DISTRHO_PREVENT_HEAP_ALLOCATION */


+ 7
- 2
distrho/src/DistrhoPluginChecks.h View File

@@ -97,7 +97,7 @@
// Define DISTRHO_PLUGIN_HAS_EMBED_UI if needed // Define DISTRHO_PLUGIN_HAS_EMBED_UI if needed


#ifndef DISTRHO_PLUGIN_HAS_EMBED_UI #ifndef DISTRHO_PLUGIN_HAS_EMBED_UI
# if defined(HAVE_CAIRO) || defined(HAVE_OPENGL)
# if (defined(DGL_CAIRO) && defined(HAVE_CAIRO)) || (defined(DGL_OPENGL) && defined(HAVE_OPENGL))
# define DISTRHO_PLUGIN_HAS_EMBED_UI 1 # define DISTRHO_PLUGIN_HAS_EMBED_UI 1
# else # else
# define DISTRHO_PLUGIN_HAS_EMBED_UI 0 # define DISTRHO_PLUGIN_HAS_EMBED_UI 0
@@ -139,7 +139,12 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Disable UI if DGL or External UI is not available // Disable UI if DGL or External UI is not available


#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_HAS_EXTERNAL_UI && ! defined(HAVE_CAIRO) && ! defined(HAVE_OPENGL)
#if (defined(DGL_CAIRO) && ! defined(HAVE_CAIRO)) || (defined(DGL_OPENGL) && ! defined(HAVE_OPENGL))
# undef DISTRHO_PLUGIN_HAS_EMBED_UI
# define DISTRHO_PLUGIN_HAS_EMBED_UI 0
#endif

#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_HAS_EMBED_UI && ! DISTRHO_PLUGIN_HAS_EXTERNAL_UI
# undef DISTRHO_PLUGIN_HAS_UI # undef DISTRHO_PLUGIN_HAS_UI
# define DISTRHO_PLUGIN_HAS_UI 0 # define DISTRHO_PLUGIN_HAS_UI 0
#endif #endif


+ 41
- 10
distrho/src/DistrhoPluginLV2.cpp View File

@@ -166,6 +166,44 @@ public:


// ------------------------------------------------------------------- // -------------------------------------------------------------------


bool getPortControlValue(uint32_t index, float& value) const
{
if (const float* control = fPortControls[index])
{
switch (fPlugin.getParameterDesignation(index))
{
default:
value = *control;
break;
case kParameterDesignationBypass:
value = 1.0f - *control;
break;
}

return true;
}

return false;
}

void setPortControlValue(uint32_t index, float value)
{
if (float* control = fPortControls[index])
{
switch (fPlugin.getParameterDesignation(index))
{
default:
*control = value;
break;
case kParameterDesignationBypass:
*control = 1.0f - value;
break;
}
}
}

// -------------------------------------------------------------------

void lv2_activate() void lv2_activate()
{ {
#if DISTRHO_PLUGIN_WANT_TIMEPOS #if DISTRHO_PLUGIN_WANT_TIMEPOS
@@ -514,18 +552,13 @@ public:


for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i) for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{ {
if (fPortControls[i] == nullptr)
if (!getPortControlValue(i, curValue))
continue; continue;


curValue = *fPortControls[i];

if (fPlugin.isParameterInput(i) && d_isNotEqual(fLastControlValues[i], curValue)) if (fPlugin.isParameterInput(i) && d_isNotEqual(fLastControlValues[i], curValue))
{ {
fLastControlValues[i] = curValue; fLastControlValues[i] = curValue;


if (fPlugin.getParameterDesignation(i) == kParameterDesignationBypass)
curValue = 1.0f - curValue;

fPlugin.setParameterValue(i, curValue); fPlugin.setParameterValue(i, curValue);
} }
} }
@@ -757,8 +790,7 @@ public:


fLastControlValues[i] = fPlugin.getParameterValue(i); fLastControlValues[i] = fPlugin.getParameterValue(i);


if (fPortControls[i] != nullptr)
*fPortControls[i] = fLastControlValues[i];
setPortControlValue(i, fLastControlValues[i]);
} }


# if DISTRHO_PLUGIN_WANT_FULL_STATE # if DISTRHO_PLUGIN_WANT_FULL_STATE
@@ -1047,8 +1079,7 @@ private:
{ {
curValue = fLastControlValues[i] = fPlugin.getParameterValue(i); curValue = fLastControlValues[i] = fPlugin.getParameterValue(i);


if (fPortControls[i] != nullptr)
*fPortControls[i] = curValue;
setPortControlValue(i, curValue);
} }
else if ((fPlugin.getParameterHints(i) & kParameterIsTrigger) == kParameterIsTrigger) else if ((fPlugin.getParameterHints(i) & kParameterIsTrigger) == kParameterIsTrigger)
{ {


+ 10
- 2
distrho/src/DistrhoPluginLV2export.cpp View File

@@ -160,7 +160,7 @@ static const char* const lv2ManifestUiSupportedOptions[] =
}; };
#endif // DISTRHO_PLUGIN_HAS_UI #endif // DISTRHO_PLUGIN_HAS_UI


static void addAttribute(String& text,
static void addAttribute(DISTRHO_NAMESPACE::String& text,
const char* const attribute, const char* const attribute,
const char* const values[], const char* const values[],
const uint indent, const uint indent,
@@ -561,7 +561,14 @@ void lv2_generate_ttl(const char* const basename)
pluginString += " [\n"; pluginString += " [\n";


pluginString += " rdfs:label \"\"\"" + enumValue.label + "\"\"\" ;\n"; pluginString += " rdfs:label \"\"\"" + enumValue.label + "\"\"\" ;\n";
pluginString += " rdf:value " + String(enumValue.value) + " ;\n";

if (plugin.getParameterHints(i) & kParameterIsInteger) {
const int roundedValue = (int)(enumValue.value + 0.5f);
pluginString += " rdf:value " + String(roundedValue) + " ;\n";
}
else {
pluginString += " rdf:value " + String(enumValue.value) + " ;\n";
}


if (j+1 == enumValues.count) if (j+1 == enumValues.count)
pluginString += " ] ;\n\n"; pluginString += " ] ;\n\n";
@@ -606,6 +613,7 @@ void lv2_generate_ttl(const char* const basename)
else else
{ {
pluginString += " unit:unit [\n"; pluginString += " unit:unit [\n";
pluginString += " a unit:Unit ;\n";
pluginString += " rdfs:label \"" + unit + "\" ;\n"; pluginString += " rdfs:label \"" + unit + "\" ;\n";
pluginString += " unit:symbol \"" + unit + "\" ;\n"; pluginString += " unit:symbol \"" + unit + "\" ;\n";
pluginString += " unit:render \"%f " + unit + "\" ;\n"; pluginString += " unit:render \"%f " + unit + "\" ;\n";


+ 9
- 6
distrho/src/DistrhoPluginVST.cpp View File

@@ -231,6 +231,8 @@ public:


d_stdout("handlePluginKeyEvent %i %i %li\n", down, index, (long int)value); d_stdout("handlePluginKeyEvent %i %i %li\n", down, index, (long int)value);


using namespace DGL_NAMESPACE;

int special = 0; int special = 0;
switch (value) switch (value)
{ {
@@ -588,7 +590,8 @@ public:
return 1; return 1;


case effEditOpen: case effEditOpen:
if (fVstUI == nullptr)
delete fVstUI; // hosts which don't pair effEditOpen/effEditClose calls (Minihost Modular)
fVstUI = nullptr;
{ {
# if DISTRHO_OS_MAC # if DISTRHO_OS_MAC
if (! fUsingNsView) if (! fUsingNsView)
@@ -920,25 +923,25 @@ public:
return ranges.getNormalizedValue(fPlugin.getParameterValue(index)); return ranges.getNormalizedValue(fPlugin.getParameterValue(index));
} }


void vst_setParameter(const int32_t index, float value)
void vst_setParameter(const int32_t index, const float value)
{ {
const uint32_t hints(fPlugin.getParameterHints(index)); const uint32_t hints(fPlugin.getParameterHints(index));
const ParameterRanges& ranges(fPlugin.getParameterRanges(index)); const ParameterRanges& ranges(fPlugin.getParameterRanges(index));


value = ranges.getUnnormalizedValue(value);
// TODO figure out how to detect kVstParameterUsesIntegerMinMax host support, and skip normalization
float realValue = ranges.getUnnormalizedValue(value);


if (hints & kParameterIsBoolean) if (hints & kParameterIsBoolean)
{ {
const float midRange = ranges.min + (ranges.max - ranges.min) / 2.0f; const float midRange = ranges.min + (ranges.max - ranges.min) / 2.0f;
value = value > midRange ? ranges.max : ranges.min;
realValue = realValue > midRange ? ranges.max : ranges.min;
} }


if (hints & kParameterIsInteger) if (hints & kParameterIsInteger)
{ {
value = std::round(value);
realValue = std::round(realValue);
} }


const float realValue(value);
fPlugin.setParameterValue(index, realValue); fPlugin.setParameterValue(index, realValue);


#if DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_HAS_UI


+ 5
- 2
distrho/src/DistrhoUIDSSI.cpp View File

@@ -149,9 +149,12 @@ public:
fUI.setSampleRate(sampleRate, true); fUI.setSampleRate(sampleRate, true);
} }


void dssiui_show()
void dssiui_show(const bool focus = false)
{ {
fUI.setWindowVisible(true); fUI.setWindowVisible(true);

if (focus)
fUI.focus();
} }


void dssiui_hide() void dssiui_hide()
@@ -389,7 +392,7 @@ int main(int argc, char* argv[])
gUiTitle = "DSSI UI Test"; gUiTitle = "DSSI UI Test";


initUiIfNeeded(); initUiIfNeeded();
globalUI->dssiui_show();
globalUI->dssiui_show(true);
globalUI->exec(); globalUI->exec();


delete globalUI; delete globalUI;


+ 10
- 1
distrho/src/DistrhoUIInternal.hpp View File

@@ -406,6 +406,10 @@ public:
return true; return true;
} }


void focus()
{
}

void quit() void quit()
{ {
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr,);
@@ -430,6 +434,11 @@ public:
fUI->uiIdle(); fUI->uiIdle();
} }


void focus()
{
glWindow.focus();
}

bool idle() bool idle()
{ {
DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr, false); DISTRHO_SAFE_ASSERT_RETURN(fUI != nullptr, false);
@@ -519,7 +528,7 @@ public:
return glWindow.handlePluginKeyboard(press, key); return glWindow.handlePluginKeyboard(press, key);
} }


bool handlePluginSpecial(const bool press, const Key key)
bool handlePluginSpecial(const bool press, const DGL_NAMESPACE::Key key)
{ {
return glWindow.handlePluginSpecial(press, key); return glWindow.handlePluginSpecial(press, key);
} }


+ 8
- 0
examples/CairoUI/DemoWidgetBanner.cpp View File

@@ -19,6 +19,10 @@
#include "Cairo.hpp" #include "Cairo.hpp"
#include "Window.hpp" #include "Window.hpp"


START_NAMESPACE_DGL

// -----------------------------------------------------------------------

static const char* banner = static const char* banner =
" " " "
" * * * * * " " * * * * * "
@@ -90,3 +94,7 @@ void DemoWidgetBanner::onDisplay()
} }
} }
} }

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 10
- 0
examples/CairoUI/DemoWidgetBanner.hpp View File

@@ -16,9 +16,19 @@


#include "Widget.hpp" #include "Widget.hpp"


START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class DemoWidgetBanner : public Widget class DemoWidgetBanner : public Widget
{ {
public: public:
explicit DemoWidgetBanner(Widget* group); explicit DemoWidgetBanner(Widget* group);
void onDisplay() override; void onDisplay() override;
}; };

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

using DGL_NAMESPACE::DemoWidgetBanner;

+ 8
- 0
examples/CairoUI/DemoWidgetClickable.cpp View File

@@ -19,6 +19,10 @@
#include "Cairo.hpp" #include "Cairo.hpp"
#include "Window.hpp" #include "Window.hpp"


START_NAMESPACE_DGL

// -----------------------------------------------------------------------

DemoWidgetClickable::DemoWidgetClickable(Widget* group) DemoWidgetClickable::DemoWidgetClickable(Widget* group)
: Widget(group) : Widget(group)
{ {
@@ -77,3 +81,7 @@ bool DemoWidgetClickable::onMouse(const MouseEvent& event)


return Widget::onMouse(event); return Widget::onMouse(event);
} }

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 10
- 0
examples/CairoUI/DemoWidgetClickable.hpp View File

@@ -16,6 +16,10 @@


#include "Widget.hpp" #include "Widget.hpp"


START_NAMESPACE_DGL

// -----------------------------------------------------------------------

class DemoWidgetClickable : public Widget class DemoWidgetClickable : public Widget
{ {
public: public:
@@ -26,3 +30,9 @@ public:
private: private:
unsigned fColorId = 0; unsigned fColorId = 0;
}; };

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

using DGL_NAMESPACE::DemoWidgetClickable;

+ 1
- 1
examples/CairoUI/Makefile View File

@@ -35,7 +35,7 @@ TARGETS += jack
endif endif
endif endif


ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_CAIRO),true) ifeq ($(HAVE_CAIRO),true)
ifeq ($(HAVE_LIBLO),true) ifeq ($(HAVE_LIBLO),true)
TARGETS += dssi TARGETS += dssi


+ 3
- 0
examples/ExternalUI/Makefile View File

@@ -21,9 +21,12 @@ FILES_UI = \
# -------------------------------------------------------------- # --------------------------------------------------------------
# Do some magic # Do some magic


UI_TYPE = external
include ../../Makefile.plugins.mk include ../../Makefile.plugins.mk


ifneq ($(HAIKU),true)
LINK_FLAGS += -ldl LINK_FLAGS += -ldl
endif


# -------------------------------------------------------------- # --------------------------------------------------------------
# Enable all possible plugin types # Enable all possible plugin types


+ 4
- 0
examples/Info/DistrhoPluginInfo.h View File

@@ -29,6 +29,10 @@
#define DISTRHO_UI_USER_RESIZABLE 1 #define DISTRHO_UI_USER_RESIZABLE 1
#define DISTRHO_UI_USE_NANOVG 1 #define DISTRHO_UI_USE_NANOVG 1


#ifdef __MOD_DEVICES__
#define DISTRHO_PLUGIN_USES_MODGUI 1
#endif

enum Parameters { enum Parameters {
kParameterBufferSize = 0, kParameterBufferSize = 0,
kParameterTimePlaying, kParameterTimePlaying,


+ 42
- 0
examples/Info/modgui.ttl View File

@@ -0,0 +1,42 @@
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@prefix mod: <http://moddevices.com/ns/mod#> .
@prefix modgui: <http://moddevices.com/ns/modgui#> .

<http://distrho.sf.net/examples/Info>
mod:brand "DISTRHO" ;
mod:label "Info" ;
modgui:gui [
modgui:brand "DISTRHO" ;
modgui:label "Info" ;
modgui:resourcesDirectory <modgui> ;
modgui:iconTemplate <modgui/icon-info.html> ;
modgui:stylesheet <modgui/stylesheet-info.css> ;
modgui:screenshot <modgui/screenshot-info.png> ;
modgui:thumbnail <modgui/thumbnail-info.png> ;
modgui:javascript <modgui/script-info.js> ;
modgui:monitoredOutputs [
lv2:symbol "buffer_size" ;
] , [
lv2:symbol "time_playing" ;
] , [
lv2:symbol "time_frame" ;
] , [
lv2:symbol "time_validbbt" ;
] , [
lv2:symbol "time_bar" ;
] , [
lv2:symbol "time_beat" ;
] , [
lv2:symbol "time_tick" ;
] , [
lv2:symbol "time_barstarttick" ;
] , [
lv2:symbol "time_beatsperbar" ;
] , [
lv2:symbol "time_beattype" ;
] , [
lv2:symbol "time_ticksperbeat" ;
] , [
lv2:symbol "time_beatsperminute" ;
] ;
] .

BIN
examples/Info/modgui/box.png View File

Before After
Width: 230  |  Height: 431  |  Size: 134KB

+ 73
- 0
examples/Info/modgui/icon-info.html View File

@@ -0,0 +1,73 @@
<div class="mod-pedal distrho-info{{{cns}}}">
<div mod-role="drag-handle" class="mod-drag-handle"></div>

<div class="tables clearfix">
<div class="table-left">
<table>
<tr>
<td>Buffer Size:</td>
<td mod-role="buffer_size">---</td>
</tr>
<tr>
<td>Sample Rate:</td>
<td mod-role="sample_rate">---</td>
</tr>
<tr>
<td>Playing:</td>
<td mod-role="time_playing">---</td>
</tr>
<tr>
<td>Frame:</td>
<td mod-role="time_frame">---</td>
</tr>
<tr>
<td>Time:</td>
<td mod-role="time_frame_s">---</td>
</tr>
</table>
</div>
<div class="table-right">
<table>
<tr>
<td>BBT Valid:</td>
<td mod-role="time_validbbt">---</td>
</tr>
<tr>
<td>Bar:</td>
<td mod-role="time_bar">---</td>
</tr>
<tr>
<td>Beat:</td>
<td mod-role="time_beat">---</td>
</tr>
<tr>
<td>Tick:</td>
<td mod-role="time_tick">---</td>
</tr>
<tr>
<td>Bar Start Tick:</td>
<td mod-role="time_barstarttick">---</td>
</tr>
<tr>
<td>Beats Per Bar:</td>
<td mod-role="time_beatsperbar">---</td>
</tr>
<tr>
<td>Beat Type:</td>
<td mod-role="time_beattype">---</td>
</tr>
<tr>
<td>Ticks Per Beat:</td>
<td mod-role="time_ticksperbeat">---</td>
</tr>
<tr>
<td>BPM:</td>
<td mod-role="time_beatsperminute">---</td>
</tr>
</table>
</div>
</div>

<div class="mod-logo"></div>
<div class="mod-magic"></div>
</div>

BIN
examples/Info/modgui/screenshot-info.png View File

Before After
Width: 121  |  Height: 154  |  Size: 17KB

+ 57
- 0
examples/Info/modgui/script-info.js View File

@@ -0,0 +1,57 @@
function (event) {

function magic () {
if (event.data.magicHasHappened) {
$('#pedalboard-dashboard').css({
'background': "#111 url(/img/background.jpg) repeat",
});
} else {
$('#pedalboard-dashboard').css({
'background': "#111 url(/resources/tilesf1.jpg?uri=http%3A//distrho.sf.net/examples/Info) repeat",
});
}
event.data.magicHasHappened = !event.data.magicHasHappened;
}

function handle_event (symbol, value) {
switch (symbol) {
case 'time_playing':
case 'time_validbbt':
value = value > 0.5 ? "Yes" : "No";
break;
case 'time_beatsperminute':
value = value.toFixed(2);
break;
case 'time_frame': {
var time = value / SAMPLERATE;
var secs = time % 60;
var mins = (time / 60) % 60;
var hrs = (time / 3600) % 60;
event.icon.find('[mod-role=time_frame_s]').text(sprintf("%02d:%02d:%02d", hrs, mins, secs));
// fall-through
}
default:
value = value.toFixed();
break;
}

event.icon.find('[mod-role='+symbol+']').text(value);
}

if (event.type == 'start') {
var ports = event.ports;
for (var p in ports) {
if (ports[p].symbol[0] == ":") {
continue;
}
handle_event (ports[p].symbol, ports[p].value);
}
// special cases
event.icon.find ('[mod-role=sample_rate]').text(SAMPLERATE);
event.icon.find ('.mod-magic').click(magic);
}
else if (event.type == 'change') {
handle_event (event.symbol, event.value);
}

}

+ 88
- 0
examples/Info/modgui/stylesheet-info.css View File

@@ -0,0 +1,88 @@
@import url(/fonts/nexa/stylesheet.css);
@import url(/fonts/questrial/stylesheet.css);

.distrho-info{{{cns}}} {
background-image:url(/resources/box.png{{{ns}}});
background-position:center center;
background-repeat:no-repeat;
background-size:600px 300px;
width:600px;
height:300px;
/* position:absolute; */
border-radius: 21px;
/* font-size: 2rem !important; */
}

.distrho-info{{{cns}}} .mod-pedal-input.mono,
.distrho-info{{{cns}}} .mod-pedal-output.mono {
top: 60px !important;
}

.distrho-info{{{cns}}} .mod-pedal-input.stereo,
.distrho-info{{{cns}}} .mod-pedal-output.stereo {
top: 15px !important;
}

.distrho-info{{{cns}}} .mod-logo {
background: url(/img/watermark.png) 42px 146px no-repeat;
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
}

@keyframes mod-magic{{{cns}}} {
0% {
opacity: 0.1;
}
100% {
opacity: 0.75;
}
}

.distrho-info{{{cns}}} .mod-magic {
background: url(/img/social/favicon.png) no-repeat;
width: 118px;
height: 118px;
position: absolute;
top: 158px;
left: 52px;
background-size: cover;
opacity: 0;
cursor: pointer;
z-index: 21;
animation: mod-magic{{{cns}}} 5s infinite;
animation-direction: alternate;
animation-timing-function: ease-in;
}

.distrho-info{{{cns}}} .tables {
display: flex;
flex-direction: row;
height: 100%;
padding: 21px;
font-family: monospace;
font-size: 1.8rem;
font-weight: bold;
}

.distrho-info{{{cns}}} .table-left,
.distrho-info{{{cns}}} .table-right {
width: 50%;
}
.distrho-info{{{cns}}} .table-left {
padding-left: 36px;
}

.distrho-info{{{cns}}} table {
border-collapse: separate;
border-spacing: 6px 1px;
}

.distrho-info{{{cns}}} tr > td:first-child {
text-align: right;
}
.distrho-info{{{cns}}} tr > td:last-child {
font-weight: lighter;
}

BIN
examples/Info/modgui/thumbnail-tinygain.png View File

Before After
Width: 50  |  Height: 64  |  Size: 5.3KB

+ 4
- 0
examples/Info/modgui/tilesf1.LICENSE View File

@@ -0,0 +1,4 @@
From http://www.myfreetextures.com/generated-seamless-tile-background-texture/

Fair Use – You can use the images with credit / attribution to www.myfreetextures.com.
Sometimes it is not possible to give credit directly on a final project – in these cases please mention the site on your website, facebook or similar, whatever you think is fair.

BIN
examples/Info/modgui/tilesf1.jpg View File

Before After
Width: 2000  |  Height: 2000  |  Size: 321KB

+ 1
- 1
examples/Latency/Makefile View File

@@ -23,7 +23,7 @@ include ../../Makefile.plugins.mk
# -------------------------------------------------------------- # --------------------------------------------------------------
# Enable all possible plugin types # Enable all possible plugin types


ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
TARGETS += ladspa TARGETS += ladspa
TARGETS += dssi TARGETS += dssi
endif endif


+ 1
- 1
examples/Meters/ExampleUIMeters.cpp View File

@@ -21,7 +21,7 @@ START_NAMESPACE_DISTRHO
/** /**
We need the Color class from DGL. We need the Color class from DGL.
*/ */
using DGL::Color;
using DGL_NAMESPACE::Color;


/** /**
Smooth meters a bit. Smooth meters a bit.


+ 1
- 1
examples/Meters/Makefile View File

@@ -32,7 +32,7 @@ TARGETS += jack
endif endif
endif endif


ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_LIBLO),true) ifeq ($(HAVE_LIBLO),true)
ifeq ($(HAVE_OPENGL),true) ifeq ($(HAVE_OPENGL),true)
TARGETS += dssi TARGETS += dssi


+ 1
- 1
examples/Parameters/ExampleUIParameters.cpp View File

@@ -21,7 +21,7 @@ START_NAMESPACE_DISTRHO
/** /**
We need the rectangle class from DGL. We need the rectangle class from DGL.
*/ */
using DGL::Rectangle;
using DGL_NAMESPACE::Rectangle;


// ----------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------




+ 1
- 1
examples/Parameters/Makefile View File

@@ -32,7 +32,7 @@ TARGETS += jack
endif endif
endif endif


ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_LIBLO),true) ifeq ($(HAVE_LIBLO),true)
ifeq ($(HAVE_OPENGL),true) ifeq ($(HAVE_OPENGL),true)
TARGETS += ladspa TARGETS += ladspa


+ 5
- 0
examples/States/ExampleUIStates.cpp View File

@@ -18,6 +18,11 @@


START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


/**
We need the rectangle class from DGL.
*/
using DGL_NAMESPACE::Rectangle;

// ----------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------


class ExampleUIParameters : public UI class ExampleUIParameters : public UI


+ 1
- 1
examples/States/Makefile View File

@@ -32,7 +32,7 @@ TARGETS += jack
endif endif
endif endif


ifeq ($(LINUX),true)
ifneq ($(MACOS_OR_WINDOWS),true)
ifeq ($(HAVE_LIBLO),true) ifeq ($(HAVE_LIBLO),true)
ifeq ($(HAVE_OPENGL),true) ifeq ($(HAVE_OPENGL),true)
TARGETS += dssi TARGETS += dssi


+ 16
- 6
utils/lv2-ttl-generator/GNUmakefile View File

@@ -1,19 +1,29 @@
#!/usr/bin/makefile -f #!/usr/bin/makefile -f


include ../../Makefile.base.mk

all: build all: build


ifeq ($(WINDOWS),true) ifeq ($(WINDOWS),true)
build: ../lv2_ttl_generator.exe
else
build: ../lv2_ttl_generator
endif


../lv2_ttl_generator: lv2_ttl_generator.c
$(CC) $< $(CFLAGS) -o $@ $(LDFLAGS) -ldl
build: ../lv2_ttl_generator.exe


../lv2_ttl_generator.exe: lv2_ttl_generator.c ../lv2_ttl_generator.exe: lv2_ttl_generator.c
$(CC) $< $(CFLAGS) -o $@ $(LDFLAGS) -static $(CC) $< $(CFLAGS) -o $@ $(LDFLAGS) -static
touch ../lv2_ttl_generator touch ../lv2_ttl_generator


else # WINDOWS

ifneq ($(HAIKU),true)
LDFLAGS += -ldl
endif

build: ../lv2_ttl_generator

../lv2_ttl_generator: lv2_ttl_generator.c
$(CC) $< $(CFLAGS) -o $@ $(LDFLAGS)

endif # WINDOWS

clean: clean:
rm -f ../lv2_ttl_generator ../lv2_ttl_generator.exe rm -f ../lv2_ttl_generator ../lv2_ttl_generator.exe

Loading…
Cancel
Save