pax_global_header 0000666 0000000 0000000 00000000064 13510326665 0014521 g ustar 00root root 0000000 0000000 52 comment=0530b4309bf5f451c3ee00503acc9c997d30353c
DPF-Plugins-1.3/ 0000775 0000000 0000000 00000000000 13510326665 0013414 5 ustar 00root root 0000000 0000000 DPF-Plugins-1.3/.gitignore 0000664 0000000 0000000 00000000142 13510326665 0015401 0 ustar 00root root 0000000 0000000 *.a
*.d
*.o
*-e
*.exe
*.dll
*.dylib
*.gz
*.so
*.zip
.DS_Store
bin/*
dpf/utils/lv2_ttl_generator
DPF-Plugins-1.3/LICENSE 0000664 0000000 0000000 00000004207 13510326665 0014424 0 ustar 00root root 0000000 0000000 License / Copyright Information
The DPF-Plugins package consists of several plugins based on the DISTHRO Plugin
Framework (DPF). Different copyrights and licenses apply to different plugins.
For example, the Kars plugin code uses an ISC License and it is copyrighted by
its authors. See below for the list of the package components and the license
for each.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
DPF-Plugins licenses
Component Location License
------------------------------------------------------------------
DPF src/dpf ISC
glBars src/plugins/glBars GPL-3.0
Kars src/plugins/Kars ISC
Max-Gen:
MaBitcrush src/plugins/bitcrush LGPL-3.0
MaFreeverb src/plugins/freeverb LGPL-3.0
MaGigaverb src/plugins/gigaverb LGPL-3.0
MaPitchshift src/plugins/pitchshift LGPL-3.0
Mini-Series:
3BandEQ src/plugins/3BandEQ LGPL-3.0
3BandSplitter src/plugins/3BandSplitter LGPL-3.0
PingPongPan src/plugins/PingPongPan LGPL-3.0
ndc Plugs:
AmplitudeImposer src/plugins/AmplitudeImposer MIT
CycleShifter src/plugins/CycleShifter MIT
SoulForce src/plugins/SoulForce MIT
MVerb src/plugins/MVerb GPL-3.0
Nekobi src/plugins/Nekobi GPL-2.0
ProM src/plugins/ProM LGPL-3.0
------------------------------------------------------------------
The LICENSE file for each component can be retrieved at the specified Location.
DPF-Plugins-1.3/Makefile 0000664 0000000 0000000 00000010046 13510326665 0015055 0 ustar 00root root 0000000 0000000 #!/usr/bin/make -f
# Makefile for DISTRHO Plugins #
# ---------------------------- #
# Created by falkTX
#
include dpf/Makefile.base.mk
all: dgl plugins gen
# --------------------------------------------------------------
PREFIX ?= /usr/local
DESTDIR ?=
# --------------------------------------------------------------
HAVE_PROJM = $(shell pkg-config --exists libprojectM && echo true)
# --------------------------------------------------------------
dgl:
ifeq ($(HAVE_CAIRO_OR_OPENGL),true)
$(MAKE) -C dpf/dgl
endif
plugins: dgl
# Kars
$(MAKE) all -C plugins/Kars
# Mini-Series
$(MAKE) all -C plugins/3BandEQ
$(MAKE) all -C plugins/3BandSplitter
$(MAKE) all -C plugins/PingPongPan
# ndc-Plugs
$(MAKE) all -C plugins/AmplitudeImposer
$(MAKE) all -C plugins/CycleShifter
$(MAKE) all -C plugins/SoulForce
# MVerb
$(MAKE) all -C plugins/MVerb
# Nekobi
$(MAKE) all -C plugins/Nekobi
# Max-Gen stuff
$(MAKE) all -C plugins/bitcrush
$(MAKE) all -C plugins/freeverb
$(MAKE) all -C plugins/gigaverb
$(MAKE) all -C plugins/pitchshift
ifeq ($(HAVE_CAIRO_OR_OPENGL),true)
# glBars (needs OpenGL)
$(MAKE) all -C plugins/glBars
ifeq ($(HAVE_PROJM),true)
# ProM (needs OpenGL + ProjectM)
$(MAKE) all -C plugins/ProM
endif # HAVE_PROJM
endif # HAVE_CAIRO_OR_OPENGL
ifneq ($(CROSS_COMPILING),true)
gen: plugins dpf/utils/lv2_ttl_generator
@$(CURDIR)/dpf/utils/generate-ttl.sh
ifeq ($(MACOS),true)
@$(CURDIR)/dpf/utils/generate-vst-bundles.sh
endif
dpf/utils/lv2_ttl_generator:
$(MAKE) -C dpf/utils/lv2-ttl-generator
else
gen:
endif
# --------------------------------------------------------------
clean:
$(MAKE) clean -C dpf/dgl
$(MAKE) clean -C dpf/utils/lv2-ttl-generator
# glBars
$(MAKE) clean -C plugins/glBars
# Kars
$(MAKE) clean -C plugins/Kars
# Mini-Series
$(MAKE) clean -C plugins/3BandEQ
$(MAKE) clean -C plugins/3BandSplitter
$(MAKE) clean -C plugins/PingPongPan
# ndc-Plugs
$(MAKE) clean -C plugins/AmplitudeImposer
$(MAKE) clean -C plugins/CycleShifter
$(MAKE) clean -C plugins/SoulForce
# MVerb
$(MAKE) clean -C plugins/MVerb
# Nekobi
$(MAKE) clean -C plugins/Nekobi
# ProM
$(MAKE) clean -C plugins/ProM
# Max-Gen stuff
$(MAKE) clean -C plugins/bitcrush
$(MAKE) clean -C plugins/freeverb
$(MAKE) clean -C plugins/gigaverb
$(MAKE) clean -C plugins/pitchshift
# --------------------------------------------------------------
install:
install -d $(DESTDIR)$(PREFIX)/lib/ladspa/
install -d $(DESTDIR)$(PREFIX)/lib/dssi/
install -d $(DESTDIR)$(PREFIX)/lib/lv2/
install -d $(DESTDIR)$(PREFIX)/lib/vst/
install -d $(DESTDIR)$(PREFIX)/bin/
install -m 644 bin/*-ladspa.* $(DESTDIR)$(PREFIX)/lib/ladspa/
install -m 644 bin/*-dssi.* $(DESTDIR)$(PREFIX)/lib/dssi/
install -m 644 bin/*-vst.* $(DESTDIR)$(PREFIX)/lib/vst/
ifeq ($(HAVE_CAIRO_OR_OPENGL),true)
cp -r bin/*-dssi $(DESTDIR)$(PREFIX)/lib/dssi/
endif # HAVE_CAIRO_OR_OPENGL
cp -r bin/*.lv2 $(DESTDIR)$(PREFIX)/lib/lv2/
ifeq ($(HAVE_JACK),true)
install -m 755 bin/Kars $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/3BandEQ $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/3BandSplitter $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/PingPongPan $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/AmplitudeImposer $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/CycleShifter $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/SoulForce $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/MVerb $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/Nekobi $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/MaBitcrush $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/MaFreeverb $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/MaGigaverb $(DESTDIR)$(PREFIX)/bin/
install -m 755 bin/MaPitchshift $(DESTDIR)$(PREFIX)/bin/
ifeq ($(HAVE_CAIRO_OR_OPENGL),true)
install -m 755 bin/glBars $(DESTDIR)$(PREFIX)/bin/
ifeq ($(HAVE_PROJM),true)
install -m 755 bin/ProM $(DESTDIR)$(PREFIX)/bin/
endif # HAVE_PROJM
endif # HAVE_CAIRO_OR_OPENGL
endif # HAVE_JACK
# --------------------------------------------------------------
.PHONY: plugins
DPF-Plugins-1.3/README.md 0000664 0000000 0000000 00000003601 13510326665 0014673 0 ustar 00root root 0000000 0000000 DPF-Plugins
===========
Collection of DPF-based plugins ready for packaging.
They come in LADSPA, DSSI, LV2 and VST2 formats.
This repository does not use submodules,
everything you need to build is included in a simple clone.
The list of plugins/packs are:
- glBars
- Kars
- Max-Gen examples (MaBitcrush, MaFreeverb, MaGigaverb, MaPitchshift)
- Mini-Series (3BandEQ. 3BandSplitter, PingPongPan)
- ndc-Plugs (Amplitude Imposer, Cycle Shifter, Soul Force)
- MVerb
- Nekobi
- ProM
Screenshots
-----------
glBars

3 Band EQ

3 Band Splitter

Ping Pong Pan

Amplitude Imposer

Cycle Shifter

Soul Force

MVerb

Nekobi

ProM

DPF-Plugins-1.3/dpf/ 0000775 0000000 0000000 00000000000 13510326665 0014165 5 ustar 00root root 0000000 0000000 DPF-Plugins-1.3/dpf/LICENSE 0000664 0000000 0000000 00000001423 13510326665 0015172 0 ustar 00root root 0000000 0000000 DISTRHO Plugin Framework (DPF)
Copyright (C) 2012-2018 Filipe Coelho
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.
THE 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.
DPF-Plugins-1.3/dpf/Makefile.base.mk 0000664 0000000 0000000 00000016667 13510326665 0017164 0 ustar 00root root 0000000 0000000 #!/usr/bin/make -f
# Makefile for DPF #
# ---------------- #
# Created by falkTX
#
AR ?= ar
CC ?= gcc
CXX ?= g++
# ---------------------------------------------------------------------------------------------------------------------
# Auto-detect OS if not defined
ifneq ($(BSD),true)
ifneq ($(HAIKU),true)
ifneq ($(HURD),true)
ifneq ($(LINUX),true)
ifneq ($(MACOS),true)
ifneq ($(WINDOWS),true)
TARGET_MACHINE := $(shell $(CC) -dumpmachine)
ifneq (,$(findstring bsd,$(TARGET_MACHINE)))
BSD=true
endif
ifneq (,$(findstring haiku,$(TARGET_MACHINE)))
HAIKU=true
endif
ifneq (,$(findstring gnu,$(TARGET_MACHINE)))
HURD=true
endif
ifneq (,$(findstring linux,$(TARGET_MACHINE)))
LINUX=true
endif
ifneq (,$(findstring apple,$(TARGET_MACHINE)))
MACOS=true
endif
ifneq (,$(findstring mingw,$(TARGET_MACHINE)))
WINDOWS=true
endif
endif
endif
endif
endif
endif
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set PKG_CONFIG (can be overridden by environment variable)
ifeq ($(WINDOWS),true)
# Build statically on Windows by default
PKG_CONFIG ?= pkg-config --static
else
PKG_CONFIG ?= pkg-config
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set LINUX_OR_MACOS
ifeq ($(LINUX),true)
LINUX_OR_MACOS=true
endif
ifeq ($(MACOS),true)
LINUX_OR_MACOS=true
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set MACOS_OR_WINDOWS and HAIKU_OR_MACOS_OR_WINDOWS
ifeq ($(HAIKU),true)
HAIKU_OR_MACOS_OR_WINDOWS=true
endif
ifeq ($(MACOS),true)
MACOS_OR_WINDOWS=true
HAIKU_OR_MACOS_OR_WINDOWS=true
endif
ifeq ($(WINDOWS),true)
MACOS_OR_WINDOWS=true
HAIKU_OR_MACOS_OR_WINDOWS=true
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set UNIX
ifeq ($(BSD),true)
UNIX=true
endif
ifeq ($(HURD),true)
UNIX=true
endif
ifeq ($(LINUX),true)
UNIX=true
endif
ifeq ($(MACOS),true)
UNIX=true
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set build and link flags
BASE_FLAGS = -Wall -Wextra -pipe -MD -MP
BASE_OPTS = -O3 -ffast-math -mtune=generic -msse -msse2 -fdata-sections -ffunction-sections
ifeq ($(MACOS),true)
# MacOS linker flags
LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
else
# Common linker flags
LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed
ifneq ($(SKIP_STRIPPING),true)
LINK_OPTS += -Wl,--strip-all
endif
endif
ifeq ($(NOOPT),true)
# No CPU-specific optimization flags
BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections
endif
ifeq ($(WINDOWS),true)
# mingw has issues with this specific optimization
# See https://github.com/falkTX/Carla/issues/696
BASE_OPTS += -fno-rerun-cse-after-loop
# See https://github.com/falkTX/Carla/issues/855
BASE_OPTS += -mstackrealign
ifeq ($(BUILDING_FOR_WINDOWS),true)
BASE_FLAGS += -DBUILDING_CARLA_FOR_WINDOWS
endif
else
# Not needed for Windows
BASE_FLAGS += -fPIC -DPIC
endif
ifeq ($(DEBUG),true)
BASE_FLAGS += -DDEBUG -O0 -g
LINK_OPTS =
else
BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
CXXFLAGS += -fvisibility-inlines-hidden
endif
BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++0x $(CXXFLAGS)
LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
ifneq ($(MACOS),true)
# Not available on MacOS
LINK_FLAGS += -Wl,--no-undefined
endif
ifeq ($(MACOS_OLD),true)
BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
endif
ifeq ($(WINDOWS),true)
# Always build statically on windows
LINK_FLAGS += -static
endif
# ---------------------------------------------------------------------------------------------------------------------
# Strict test build
ifeq ($(TESTBUILD),true)
BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
BASE_FLAGS += -Wpointer-arith -Wabi -Winit-self -Wuninitialized -Wstrict-overflow=5
# BASE_FLAGS += -Wfloat-equal
ifeq ($(CC),clang)
BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
BASE_FLAGS += -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-exit-time-destructors -Wno-float-equal
else
BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
endif
ifneq ($(MACOS),true)
BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
ifneq ($(CC),clang)
BASE_FLAGS += -Wlogical-op
endif
endif
CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
endif
# ---------------------------------------------------------------------------------------------------------------------
# Check for required libraries
HAVE_CAIRO = $(shell $(PKG_CONFIG) --exists cairo && echo true)
ifeq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
HAVE_OPENGL = true
else
HAVE_OPENGL = $(shell $(PKG_CONFIG) --exists gl && echo true)
HAVE_X11 = $(shell $(PKG_CONFIG) --exists x11 && echo true)
endif
# ---------------------------------------------------------------------------------------------------------------------
# Check for optional libraries
HAVE_JACK = $(shell $(PKG_CONFIG) --exists jack && echo true)
HAVE_LIBLO = $(shell $(PKG_CONFIG) --exists liblo && echo true)
# ---------------------------------------------------------------------------------------------------------------------
# Set Generic DGL stuff
ifeq ($(MACOS),true)
DGL_SYSTEM_LIBS += -framework Cocoa
endif
ifeq ($(WINDOWS),true)
DGL_SYSTEM_LIBS += -lgdi32
endif
ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
DGL_FLAGS += $(shell $(PKG_CONFIG) --cflags x11)
DGL_SYSTEM_LIBS += $(shell $(PKG_CONFIG) --libs x11)
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set Cairo specific stuff
ifeq ($(HAVE_CAIRO),true)
DGL_FLAGS += -DHAVE_CAIRO
CAIRO_FLAGS = $(shell $(PKG_CONFIG) --cflags cairo)
CAIRO_LIBS = $(shell $(PKG_CONFIG) --libs cairo)
HAVE_CAIRO_OR_OPENGL = true
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set OpenGL specific stuff
ifeq ($(HAVE_OPENGL),true)
DGL_FLAGS += -DHAVE_OPENGL
ifeq ($(MACOS),true)
OPENGL_LIBS = -framework OpenGL
endif
ifeq ($(WINDOWS),true)
OPENGL_LIBS = -lopengl32
endif
ifneq ($(MACOS_OR_WINDOWS),true)
OPENGL_FLAGS = $(shell $(PKG_CONFIG) --cflags gl x11)
OPENGL_LIBS = $(shell $(PKG_CONFIG) --libs gl x11)
endif
HAVE_CAIRO_OR_OPENGL = true
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set app extension
ifeq ($(WINDOWS),true)
APP_EXT = .exe
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set shared lib extension
LIB_EXT = .so
ifeq ($(MACOS),true)
LIB_EXT = .dylib
endif
ifeq ($(WINDOWS),true)
LIB_EXT = .dll
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set shared library CLI arg
ifeq ($(MACOS),true)
SHARED = -dynamiclib
else
SHARED = -shared
endif
# ---------------------------------------------------------------------------------------------------------------------
DPF-Plugins-1.3/dpf/Makefile.plugins.mk 0000664 0000000 0000000 00000017700 13510326665 0017720 0 ustar 00root root 0000000 0000000 #!/usr/bin/make -f
# Makefile for DPF Example Plugins #
# -------------------------------- #
# Created by falkTX
#
# NOTE: NAME, FILES_DSP and FILES_UI must have been defined before including this file!
ifeq (,$(wildcard ../../Makefile.base.mk))
DPF_PATH=../../dpf
else
DPF_PATH=../..
endif
include $(DPF_PATH)/Makefile.base.mk
# ---------------------------------------------------------------------------------------------------------------------
# Basic setup
TARGET_DIR = ../../bin
BUILD_DIR = ../../build/$(NAME)
BUILD_C_FLAGS += -I.
BUILD_CXX_FLAGS += -I. -I$(DPF_PATH)/distrho -I$(DPF_PATH)/dgl
ifeq ($(HAVE_CAIRO),true)
DGL_FLAGS += -DHAVE_CAIRO
endif
ifeq ($(HAVE_OPENGL),true)
DGL_FLAGS += -DHAVE_OPENGL
endif
ifeq ($(HAVE_JACK),true)
BASE_FLAGS += -DHAVE_JACK
endif
ifeq ($(HAVE_LIBLO),true)
BASE_FLAGS += -DHAVE_LIBLO
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set files to build
OBJS_DSP = $(FILES_DSP:%=$(BUILD_DIR)/%.o)
OBJS_UI = $(FILES_UI:%=$(BUILD_DIR)/%.o)
# ---------------------------------------------------------------------------------------------------------------------
# Set plugin binary file targets
jack = $(TARGET_DIR)/$(NAME)$(APP_EXT)
ladspa_dsp = $(TARGET_DIR)/$(NAME)-ladspa$(LIB_EXT)
dssi_dsp = $(TARGET_DIR)/$(NAME)-dssi$(LIB_EXT)
dssi_ui = $(TARGET_DIR)/$(NAME)-dssi/$(NAME)_ui$(APP_EXT)
lv2 = $(TARGET_DIR)/$(NAME).lv2/$(NAME)$(LIB_EXT)
lv2_dsp = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_dsp$(LIB_EXT)
lv2_ui = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_ui$(LIB_EXT)
vst = $(TARGET_DIR)/$(NAME)-vst$(LIB_EXT)
# ---------------------------------------------------------------------------------------------------------------------
# Handle UI stuff, disable UI support automatically
ifeq ($(FILES_UI),)
UI_TYPE = none
endif
ifeq ($(UI_TYPE),)
UI_TYPE = opengl
endif
ifeq ($(UI_TYPE),cairo)
ifeq ($(HAVE_CAIRO),true)
DGL_FLAGS += $(CAIRO_FLAGS) -DDGL_CAIRO
DGL_LIBS += $(CAIRO_LIBS)
DGL_LIB = $(DPF_PATH)/build/libdgl-cairo.a
HAVE_DGL = true
else
HAVE_DGL = false
endif
endif
ifeq ($(UI_TYPE),opengl)
ifeq ($(HAVE_OPENGL),true)
DGL_FLAGS += $(OPENGL_FLAGS) -DDGL_OPENGL
DGL_LIBS += $(OPENGL_LIBS)
DGL_LIB = $(DPF_PATH)/build/libdgl-opengl.a
HAVE_DGL = true
else
HAVE_DGL = false
endif
endif
DGL_LIBS += $(DGL_SYSTEM_LIBS)
ifneq ($(HAVE_DGL),true)
dssi_ui =
lv2_ui =
DGL_LIBS =
OBJS_UI =
endif
# TODO split dsp and ui object build flags
BASE_FLAGS += $(DGL_FLAGS)
# ---------------------------------------------------------------------------------------------------------------------
# all needs to be first
all:
# ---------------------------------------------------------------------------------------------------------------------
# Common
$(BUILD_DIR)/%.c.o: %.c
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<"
@$(CC) $< $(BUILD_C_FLAGS) -c -o $@
$(BUILD_DIR)/%.cc.o: %.cc
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
$(BUILD_DIR)/%.cpp.o: %.cpp
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
clean:
rm -rf $(BUILD_DIR)
rm -rf $(TARGET_DIR)/$(NAME) $(TARGET_DIR)/$(NAME)-* $(TARGET_DIR)/$(NAME).lv2
# ---------------------------------------------------------------------------------------------------------------------
$(BUILD_DIR)/DistrhoPluginMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp
-@mkdir -p $(BUILD_DIR)
@echo "Compiling DistrhoPluginMain.cpp ($*)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@
$(BUILD_DIR)/DistrhoUIMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp
-@mkdir -p $(BUILD_DIR)
@echo "Compiling DistrhoUIMain.cpp ($*)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@
$(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp
-@mkdir -p $(BUILD_DIR)
@echo "Compiling DistrhoPluginMain.cpp (JACK)"
@$(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
-@mkdir -p $(BUILD_DIR)
@echo "Compiling DistrhoUIMain.cpp (DSSI)"
@$(CXX) $< $(BUILD_CXX_FLAGS) $(shell $(PKG_CONFIG) --cflags liblo) -DDISTRHO_PLUGIN_TARGET_DSSI -c -o $@
# ---------------------------------------------------------------------------------------------------------------------
# JACK
jack: $(jack)
ifeq ($(HAVE_DGL),true)
$(jack): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.o $(DGL_LIB)
else
$(jack): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o
endif
-@mkdir -p $(shell dirname $@)
@echo "Creating JACK standalone for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs jack) -o $@
# ---------------------------------------------------------------------------------------------------------------------
# LADSPA
ladspa: $(ladspa_dsp)
$(ladspa_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LADSPA.cpp.o
-@mkdir -p $(shell dirname $@)
@echo "Creating LADSPA plugin for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
# ---------------------------------------------------------------------------------------------------------------------
# DSSI
dssi: $(dssi_dsp) $(dssi_ui)
dssi_dsp: $(dssi_dsp)
dssi_ui: $(dssi_ui)
$(dssi_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.o
-@mkdir -p $(shell dirname $@)
@echo "Creating DSSI plugin library for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
$(dssi_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o $(DGL_LIB)
-@mkdir -p $(shell dirname $@)
@echo "Creating DSSI UI for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs liblo) -o $@
# ---------------------------------------------------------------------------------------------------------------------
# LV2
lv2: $(lv2)
lv2_dsp: $(lv2_dsp)
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)
-@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
$(lv2_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
-@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin library for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
-@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin UI for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
# ---------------------------------------------------------------------------------------------------------------------
# VST
vst: $(vst)
ifeq ($(HAVE_DGL),true)
$(vst): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST.cpp.o $(DGL_LIB)
else
$(vst): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o
endif
-@mkdir -p $(shell dirname $@)
@echo "Creating VST plugin for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
# ---------------------------------------------------------------------------------------------------------------------
-include $(OBJS_DSP:%.o=%.d)
ifeq ($(HAVE_DGL),true)
-include $(OBJS_UI:%.o=%.d)
endif
-include $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.d
-include $(BUILD_DIR)/DistrhoPluginMain_LADSPA.cpp.d
-include $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.d
-include $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.d
-include $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.d
-include $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.d
-include $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.d
-include $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.d
-include $(BUILD_DIR)/DistrhoUIMain_VST.cpp.d
# ---------------------------------------------------------------------------------------------------------------------
DPF-Plugins-1.3/dpf/README.md 0000664 0000000 0000000 00000004105 13510326665 0015444 0 ustar 00root root 0000000 0000000 # DPF - DISTRHO Plugin Framework
[](https://travis-ci.org/DISTRHO/DPF)
DPF is designed to make development of new plugins an easy and enjoyable task.
It allows developers to create plugins with custom UIs using a simple C++ API.
The framework facilitates exporting various different plugin formats from the same code-base.
DPF can build for LADSPA, DSSI, LV2 and VST formats.
All current plugin format implementations are complete.
A JACK/Standalone mode is also available, allowing you to quickly test plugins.
Plugin DSP and UI communication is done via key-value string pairs.
You send messages from the UI to the DSP side, which is automatically saved in the host when required.
(You can also store state internally if needed, but this breaks DSSI compatibility).
Getting time information from the host is possible.
It uses the same format as the JACK Transport API, making porting some code easier.
List of plugins made with DPF:
- [DISTRHO glBars](https://github.com/DISTRHO/glBars)
- [DISTRHO Kars](https://github.com/DISTRHO/Kars)
- [DISTRHO Mini-Series](https://github.com/DISTRHO/Mini-Series)
- [DISTRHO MVerb](https://github.com/DISTRHO/MVerb)
- [DISTRHO Nekobi](https://github.com/DISTRHO/Nekobi)
- [DISTRHO ProM](https://github.com/DISTRHO/ProM)
- [DISTRHO ndc Plugs](https://github.com/DISTRHO/ndc-Plugs)
- [Juice Plugins](https://github.com/DISTRHO/JuicePlugins) (work in progress)
- [ZamAudio Suite](https://github.com/zamaudio/zam-plugins)
- [DragonFly-Reverb](https://github.com/michaelwillis/dragonfly-reverb)
- [Wolf-Shaper](https://github.com/pdesaulniers/wolf-shaper) and [Wolf-Spectrum](https://github.com/pdesaulniers/wolf-spectrum)
- [YK Chorus](https://github.com/SpotlightKid/ykchorus)
Plugin examples are available in the `example/` folder inside this repo.
Extra OpenGL UI examples are available [here](https://github.com/DISTRHO/gl-examples).
Online documentation is available at [https://distrho.github.io/DPF/](https://distrho.github.io/DPF/).
DPF-Plugins-1.3/dpf/dgl/ 0000775 0000000 0000000 00000000000 13510326665 0014733 5 ustar 00root root 0000000 0000000 DPF-Plugins-1.3/dpf/dgl/Application.hpp 0000664 0000000 0000000 00000004765 13510326665 0017723 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_APP_HPP_INCLUDED
#define DGL_APP_HPP_INCLUDED
#include "Base.hpp"
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
// Forward class names
class Window;
// -----------------------------------------------------------------------
/**
Base DGL Application class.
One application instance is required for creating a window.
There's no single/global application instance in DGL, and multiple
windows can share the same app instance.
In standalone mode an application will automatically quit its
event-loop when all its windows are closed.
*/
class Application
{
public:
/**
Constructor.
*/
Application();
/**
Destructor.
*/
virtual ~Application();
/**
Idle function.
This runs the application event-loop once.
*/
void idle();
/**
Run the application event-loop until all Windows are closed.
idle() is called at regular intervals.
@note This function is meant for standalones only, *never* call this from plugins.
*/
void exec(int idleTime = 10);
/**
Quit the application.
This stops the event-loop and closes all Windows.
*/
void quit();
/**
Check if the application is about to quit.
Returning true means there's no event-loop running at the moment (or it's just about to stop).
*/
bool isQuiting() const noexcept;
private:
struct PrivateData;
PrivateData* const pData;
friend class Window;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Application)
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_APP_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/Base.hpp 0000664 0000000 0000000 00000005647 13510326665 0016332 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_BASE_HPP_INCLUDED
#define DGL_BASE_HPP_INCLUDED
#include "../distrho/extra/LeakDetector.hpp"
#include "../distrho/extra/ScopedPointer.hpp"
// -----------------------------------------------------------------------
// Define namespace
#ifndef DGL_NAMESPACE
# define DGL_NAMESPACE DGL
#endif
#define START_NAMESPACE_DGL namespace DGL_NAMESPACE {
#define END_NAMESPACE_DGL }
#define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
// Base DGL enums
/**
Convenience symbols for ASCII control characters.
*/
enum Char {
kCharBackspace = 0x08,
kCharEscape = 0x1B,
kCharDelete = 0x7F
};
/**
Keyboard modifier flags.
*/
enum Modifier {
kModifierShift = 1 << 0, /**< Shift key */
kModifierControl = 1 << 1, /**< Control key */
kModifierAlt = 1 << 2, /**< Alt/Option key */
kModifierSuper = 1 << 3 /**< Mod4/Command/Windows key */
};
/**
Special (non-Unicode) keyboard keys.
*/
enum Key {
kKeyF1 = 1,
kKeyF2,
kKeyF3,
kKeyF4,
kKeyF5,
kKeyF6,
kKeyF7,
kKeyF8,
kKeyF9,
kKeyF10,
kKeyF11,
kKeyF12,
kKeyLeft,
kKeyUp,
kKeyRight,
kKeyDown,
kKeyPageUp,
kKeyPageDown,
kKeyHome,
kKeyEnd,
kKeyInsert,
kKeyShift,
kKeyControl,
kKeyAlt,
kKeySuper
};
// -----------------------------------------------------------------------
// Base DGL classes
/**
Graphics context, definition depends on build type.
*/
struct GraphicsContext;
/**
Idle callback.
*/
class IdleCallback
{
public:
virtual ~IdleCallback() {}
virtual void idleCallback() = 0;
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#ifndef DONT_SET_USING_DGL_NAMESPACE
// If your code uses a lot of DGL classes, then this will obviously save you
// a lot of typing, but can be disabled by setting DONT_SET_USING_DGL_NAMESPACE.
using namespace DGL_NAMESPACE;
#endif
// -----------------------------------------------------------------------
#endif // DGL_BASE_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/Cairo.hpp 0000664 0000000 0000000 00000002332 13510326665 0016501 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_CAIRO_HPP_INCLUDED
#define DGL_CAIRO_HPP_INCLUDED
#include "Base.hpp"
#include
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
/**
Graphics context.
*/
struct GraphicsContext
{
cairo_t* cairo; // FIXME proper name..
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif
DPF-Plugins-1.3/dpf/dgl/Color.hpp 0000664 0000000 0000000 00000006270 13510326665 0016527 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_COLOR_HPP_INCLUDED
#define DGL_COLOR_HPP_INCLUDED
#include "Base.hpp"
struct NVGcolor;
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
/**
A color made from red, green, blue and alpha floating-point values in [0..1] range.
*/
struct Color {
/**
Direct access to the color values.
*/
union {
float rgba[4];
struct { float red, green, blue, alpha; };
};
/**
Create solid black color.
*/
Color() noexcept;
/**
Create a color from red, green, blue and alpha numeric values.
Values must be in [0..255] range.
*/
Color(int red, int green, int blue, int alpha = 255) noexcept;
/**
Create a color from red, green, blue and alpha floating-point values.
Values must in [0..1] range.
*/
Color(float red, float green, float blue, float alpha = 1.0f) noexcept;
/**
Create a color by copying another color.
*/
Color(const Color& color) noexcept;
Color& operator=(const Color& color) noexcept;
/**
Create a color by linearly interpolating two other colors.
*/
Color(const Color& color1, const Color& color2, float u) noexcept;
/**
Create a color specified by hue, saturation and lightness.
Values must in [0..1] range.
*/
static Color fromHSL(float hue, float saturation, float lightness, float alpha = 1.0f);
/**
Create a color from a HTML string like "#333" or "#112233".
*/
static Color fromHTML(const char* rgb, float alpha = 1.0f);
/**
Linearly interpolate this color against another.
*/
void interpolate(const Color& other, float u) noexcept;
/**
Check if this color matches another.
@note Comparison is forced within 8-bit color values.
*/
bool isEqual(const Color& color, bool withAlpha = true) noexcept;
bool isNotEqual(const Color& color, bool withAlpha = true) noexcept;
bool operator==(const Color& color) noexcept;
bool operator!=(const Color& color) noexcept;
/**
Fix color bounds if needed.
*/
void fixBounds() noexcept;
/**
@internal
Needed for NanoVG compatibility.
*/
Color(const NVGcolor&) noexcept;
operator NVGcolor() const noexcept;
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_COLOR_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/Geometry.hpp 0000664 0000000 0000000 00000041311 13510326665 0017237 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_GEOMETRY_HPP_INCLUDED
#define DGL_GEOMETRY_HPP_INCLUDED
#include "Base.hpp"
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
// Forward class names
template class Line;
template class Circle;
template class Triangle;
template class Rectangle;
// -----------------------------------------------------------------------
/**
DGL Point class.
This class describes a single point in space, defined by an X and Y value.
*/
template
class Point
{
public:
/**
Constructor for (0, 0) point.
*/
Point() noexcept;
/**
Constructor using custom X and Y values.
*/
Point(const T& x, const T& y) noexcept;
/**
Constructor using another Point class values.
*/
Point(const Point& pos) noexcept;
/**
Get X value.
*/
const T& getX() const noexcept;
/**
Get Y value.
*/
const T& getY() const noexcept;
/**
Set X value to @a x.
*/
void setX(const T& x) noexcept;
/**
Set Y value to @a y.
*/
void setY(const T& y) noexcept;
/**
Set X and Y values to @a x and @a y respectively.
*/
void setPos(const T& x, const T& y) noexcept;
/**
Set X and Y values according to @a pos.
*/
void setPos(const Point& pos) noexcept;
/**
Move this point by @a x and @a y values.
*/
void moveBy(const T& x, const T& y) noexcept;
/**
Move this point by @a pos.
*/
void moveBy(const Point& pos) noexcept;
/**
Return true if point is (0, 0).
*/
bool isZero() const noexcept;
/**
Return true if point is not (0, 0).
*/
bool isNotZero() const noexcept;
Point operator+(const Point& pos) noexcept;
Point operator-(const Point& pos) noexcept;
Point& operator=(const Point& pos) noexcept;
Point& operator+=(const Point& pos) noexcept;
Point& operator-=(const Point& pos) noexcept;
bool operator==(const Point& pos) const noexcept;
bool operator!=(const Point& pos) const noexcept;
private:
T fX, fY;
template friend class Line;
template friend class Circle;
template friend class Triangle;
template friend class Rectangle;
};
// -----------------------------------------------------------------------
/**
DGL Size class.
This class describes a size, defined by a width and height value.
*/
template
class Size
{
public:
/**
Constructor for null size (0x0).
*/
Size() noexcept;
/**
Constructor using custom width and height values.
*/
Size(const T& width, const T& height) noexcept;
/**
Constructor using another Size class values.
*/
Size(const Size& size) noexcept;
/**
Get width.
*/
const T& getWidth() const noexcept;
/**
Get height.
*/
const T& getHeight() const noexcept;
/**
Set width.
*/
void setWidth(const T& width) noexcept;
/**
Set height.
*/
void setHeight(const T& height) noexcept;
/**
Set size to @a width and @a height.
*/
void setSize(const T& width, const T& height) noexcept;
/**
Set size.
*/
void setSize(const Size& size) noexcept;
/**
Grow size by @a multiplier.
*/
void growBy(double multiplier) noexcept;
/**
Shrink size by @a divider.
*/
void shrinkBy(double divider) noexcept;
/**
Return true if size is null (0x0).
An null size is also invalid.
*/
bool isNull() const noexcept;
/**
Return true if size is not null (0x0).
A non-null size is still invalid if its width or height is negative.
*/
bool isNotNull() const noexcept;
/**
Return true if size is valid (width and height are higher than zero).
*/
bool isValid() const noexcept;
/**
Return true if size is invalid (width or height are lower or equal to zero).
An invalid size might not be null under some circumstances.
*/
bool isInvalid() const noexcept;
Size operator+(const Size& size) noexcept;
Size operator-(const Size& size) noexcept;
Size& operator=(const Size& size) noexcept;
Size& operator+=(const Size& size) noexcept;
Size& operator-=(const Size& size) noexcept;
Size& operator*=(double m) noexcept;
Size& operator/=(double d) noexcept;
bool operator==(const Size& size) const noexcept;
bool operator!=(const Size& size) const noexcept;
private:
T fWidth, fHeight;
template friend class Rectangle;
};
// -----------------------------------------------------------------------
/**
DGL Line class.
This class describes a line, defined by two points.
*/
template
class Line
{
public:
/**
Constructor for a null line ([0,0] to [0,0]).
*/
Line() noexcept;
/**
Constructor using custom start X, start Y, end X and end Y values.
*/
Line(const T& startX, const T& startY, const T& endX, const T& endY) noexcept;
/**
Constructor using custom start X, start Y and end pos values.
*/
Line(const T& startX, const T& startY, const Point& endPos) noexcept;
/**
Constructor using custom start pos, end X and end Y values.
*/
Line(const Point& startPos, const T& endX, const T& endY) noexcept;
/**
Constructor using custom start and end pos values.
*/
Line(const Point& startPos, const Point& endPos) noexcept;
/**
Constructor using another Line class values.
*/
Line(const Line& line) noexcept;
/**
Get start X value.
*/
const T& getStartX() const noexcept;
/**
Get start Y value.
*/
const T& getStartY() const noexcept;
/**
Get end X value.
*/
const T& getEndX() const noexcept;
/**
Get end Y value.
*/
const T& getEndY() const noexcept;
/**
Get start position.
*/
const Point& getStartPos() const noexcept;
/**
Get end position.
*/
const Point& getEndPos() const noexcept;
/**
Set start X value to @a x.
*/
void setStartX(const T& x) noexcept;
/**
Set start Y value to @a y.
*/
void setStartY(const T& y) noexcept;
/**
Set start X and Y values to @a x and @a y respectively.
*/
void setStartPos(const T& x, const T& y) noexcept;
/**
Set start X and Y values according to @a pos.
*/
void setStartPos(const Point& pos) noexcept;
/**
Set end X value to @a x.
*/
void setEndX(const T& x) noexcept;
/**
Set end Y value to @a y.
*/
void setEndY(const T& y) noexcept;
/**
Set end X and Y values to @a x and @a y respectively.
*/
void setEndPos(const T& x, const T& y) noexcept;
/**
Set end X and Y values according to @a pos.
*/
void setEndPos(const Point& pos) noexcept;
/**
Move this line by @a x and @a y values.
*/
void moveBy(const T& x, const T& y) noexcept;
/**
Move this line by @a pos.
*/
void moveBy(const Point& pos) noexcept;
/**
Draw this line using the current OpenGL state.
*/
void draw();
/**
Return true if line is null (start and end pos are equal).
*/
bool isNull() const noexcept;
/**
Return true if line is not null (start and end pos are different).
*/
bool isNotNull() const noexcept;
Line& operator=(const Line& line) noexcept;
bool operator==(const Line& line) const noexcept;
bool operator!=(const Line& line) const noexcept;
private:
Point fPosStart, fPosEnd;
};
// -----------------------------------------------------------------------
/**
DGL Circle class.
This class describes a circle, defined by position, size and a minimum of 3 segments.
TODO: report if circle starts at top-left, bottom-right or center.
and size grows from which point?
*/
template
class Circle
{
public:
/**
Constructor for a null circle.
*/
Circle() noexcept;
/**
Constructor using custom X, Y and size values.
*/
Circle(const T& x, const T& y, const float size, const uint numSegments = 300);
/**
Constructor using custom position and size values.
*/
Circle(const Point& pos, const float size, const uint numSegments = 300);
/**
Constructor using another Circle class values.
*/
Circle(const Circle& cir) noexcept;
/**
Get X value.
*/
const T& getX() const noexcept;
/**
Get Y value.
*/
const T& getY() const noexcept;
/**
Get position.
*/
const Point& getPos() const noexcept;
/**
Set X value to @a x.
*/
void setX(const T& x) noexcept;
/**
Set Y value to @a y.
*/
void setY(const T& y) noexcept;
/**
Set X and Y values to @a x and @a y respectively.
*/
void setPos(const T& x, const T& y) noexcept;
/**
Set X and Y values according to @a pos.
*/
void setPos(const Point& pos) noexcept;
/**
Get size.
*/
float getSize() const noexcept;
/**
Set size.
@note Must always be > 0
*/
void setSize(const float size) noexcept;
/**
Get the current number of line segments that make this circle.
*/
uint getNumSegments() const noexcept;
/**
Set the number of line segments that will make this circle.
@note Must always be >= 3
*/
void setNumSegments(const uint num);
/**
Draw this circle using the current OpenGL state.
*/
void draw();
/**
Draw lines (outline of this circle) using the current OpenGL state.
*/
void drawOutline();
Circle& operator=(const Circle& cir) noexcept;
bool operator==(const Circle& cir) const noexcept;
bool operator!=(const Circle& cir) const noexcept;
private:
Point fPos;
float fSize;
uint fNumSegments;
// cached values
float fTheta, fCos, fSin;
/** @internal */
void _draw(const bool outline);
};
// -----------------------------------------------------------------------
/**
DGL Triangle class.
This class describes a triangle, defined by 3 points.
*/
template
class Triangle
{
public:
/**
Constructor for a null triangle.
*/
Triangle() noexcept;
/**
Constructor using custom X and Y values.
*/
Triangle(const T& x1, const T& y1, const T& x2, const T& y2, const T& x3, const T& y3) noexcept;
/**
Constructor using custom position values.
*/
Triangle(const Point& pos1, const Point& pos2, const Point& pos3) noexcept;
/**
Constructor using another Triangle class values.
*/
Triangle(const Triangle& tri) noexcept;
/**
Return true if triangle is null (all its points are equal).
An null triangle is also invalid.
*/
bool isNull() const noexcept;
/**
Return true if triangle is not null (one its points is different from the others).
A non-null triangle is still invalid if two of its points are equal.
*/
bool isNotNull() const noexcept;
/**
Return true if triangle is valid (all its points are different).
*/
bool isValid() const noexcept;
/**
Return true if triangle is invalid (one or two of its points are equal).
An invalid triangle might not be null under some circumstances.
*/
bool isInvalid() const noexcept;
/**
Draw this triangle using the current OpenGL state.
*/
void draw();
/**
Draw lines (outline of this triangle) using the current OpenGL state.
*/
void drawOutline();
Triangle& operator=(const Triangle& tri) noexcept;
bool operator==(const Triangle& tri) const noexcept;
bool operator!=(const Triangle& tri) const noexcept;
private:
Point fPos1, fPos2, fPos3;
/** @internal */
void _draw(const bool outline);
};
// -----------------------------------------------------------------------
/**
DGL Rectangle class.
This class describes a rectangle, defined by a starting point and a size.
*/
template
class Rectangle
{
public:
/**
Constructor for a null rectangle.
*/
Rectangle() noexcept;
/**
Constructor using custom X, Y, width and height values.
*/
Rectangle(const T& x, const T& y, const T& width, const T& height) noexcept;
/**
Constructor using custom X, Y and size values.
*/
Rectangle(const T& x, const T& y, const Size& size) noexcept;
/**
Constructor using custom pos, width and height values.
*/
Rectangle(const Point& pos, const T& width, const T& height) noexcept;
/**
Constructor using custom position and size.
*/
Rectangle(const Point& pos, const Size& size) noexcept;
/**
Constructor using another Rectangle class values.
*/
Rectangle(const Rectangle& rect) noexcept;
/**
Get X value.
*/
const T& getX() const noexcept;
/**
Get Y value.
*/
const T& getY() const noexcept;
/**
Get width.
*/
const T& getWidth() const noexcept;
/**
Get height.
*/
const T& getHeight() const noexcept;
/**
Get position.
*/
const Point& getPos() const noexcept;
/**
Get size.
*/
const Size& getSize() const noexcept;
/**
Set X value as @a x.
*/
void setX(const T& x) noexcept;
/**
Set Y value as @a y.
*/
void setY(const T& y) noexcept;
/**
Set X and Y values as @a x and @a y respectively.
*/
void setPos(const T& x, const T& y) noexcept;
/**
Set X and Y values according to @a pos.
*/
void setPos(const Point& pos) noexcept;
/**
Move this rectangle by @a x and @a y values.
*/
void moveBy(const T& x, const T& y) noexcept;
/**
Move this rectangle by @a pos.
*/
void moveBy(const Point& pos) noexcept;
/**
Set width.
*/
void setWidth(const T& width) noexcept;
/**
Set height.
*/
void setHeight(const T& height) noexcept;
/**
Set size using @a width and @a height.
*/
void setSize(const T& width, const T& height) noexcept;
/**
Set size.
*/
void setSize(const Size& size) noexcept;
/**
Grow size by @a multiplier.
*/
void growBy(double multiplier) noexcept;
/**
Shrink size by @a divider.
*/
void shrinkBy(double divider) noexcept;
/**
Set rectangle using @a pos and @a size.
*/
void setRectangle(const Point& pos, const Size& size) noexcept;
/**
Set rectangle.
*/
void setRectangle(const Rectangle& rect) noexcept;
/**
Check if this rectangle contains the point defined by @a X and @a Y.
*/
bool contains(const T& x, const T& y) const noexcept;
/**
Check if this rectangle contains the point @a pos.
*/
bool contains(const Point& pos) const noexcept;
/**
Check if this rectangle contains X.
*/
bool containsX(const T& x) const noexcept;
/**
Check if this rectangle contains Y.
*/
bool containsY(const T& y) const noexcept;
/**
Draw this rectangle using the current OpenGL state.
*/
void draw();
/**
Draw lines (outline of this rectangle) using the current OpenGL state.
*/
void drawOutline();
Rectangle& operator=(const Rectangle& rect) noexcept;
Rectangle& operator*=(double m) noexcept;
Rectangle& operator/=(double d) noexcept;
bool operator==(const Rectangle& size) const noexcept;
bool operator!=(const Rectangle& size) const noexcept;
private:
Point fPos;
Size fSize;
/** @internal */
void _draw(const bool outline);
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_GEOMETRY_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/Image.hpp 0000664 0000000 0000000 00000007014 13510326665 0016470 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_IMAGE_HPP_INCLUDED
#define DGL_IMAGE_HPP_INCLUDED
#include "ImageBase.hpp"
#include "OpenGL.hpp"
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
/**
OpenGL Image class.
This is an Image class that handles raw image data in pixels.
You can init the image data on the contructor or later on by calling loadFromMemory().
To generate raw data useful for this class see the utils/png2rgba.py script.
Be careful when using a PNG without alpha channel, for those the format is 'GL_BGR'
instead of the default 'GL_BGRA'.
Images are drawn on screen via 2D textures.
*/
class Image : public ImageBase
{
public:
/**
Constructor for a null Image.
*/
Image();
/**
Constructor using raw image data.
@note @a rawData must remain valid for the lifetime of this Image.
*/
Image(const char* const rawData,
const uint width,
const uint height,
const GLenum format = GL_BGRA,
const GLenum type = GL_UNSIGNED_BYTE);
/**
Constructor using raw image data.
@note @a rawData must remain valid for the lifetime of this Image.
*/
Image(const char* const rawData,
const Size& size,
const GLenum format = GL_BGRA,
const GLenum type = GL_UNSIGNED_BYTE);
/**
Constructor using another image data.
*/
Image(const Image& image);
/**
Destructor.
*/
~Image() override;
/**
Load image data from memory.
@note @a rawData must remain valid for the lifetime of this Image.
*/
void loadFromMemory(const char* const rawData,
const uint width,
const uint height,
const GLenum format = GL_BGRA,
const GLenum type = GL_UNSIGNED_BYTE) noexcept;
/**
Load image data from memory.
@note @a rawData must remain valid for the lifetime of this Image.
*/
void loadFromMemory(const char* const rawData,
const Size& size,
const GLenum format = GL_BGRA,
const GLenum type = GL_UNSIGNED_BYTE) noexcept;
/**
Get the image format.
*/
GLenum getFormat() const noexcept;
/**
Get the image type.
*/
GLenum getType() const noexcept;
/**
TODO document this.
*/
Image& operator=(const Image& image) noexcept;
protected:
/** @internal */
void _drawAt(const Point& pos) override;
private:
GLenum fFormat;
GLenum fType;
GLuint fTextureId;
bool fIsReady;
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif
DPF-Plugins-1.3/dpf/dgl/ImageBase.hpp 0000664 0000000 0000000 00000006013 13510326665 0017261 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_IMAGE_BASE_HPP_INCLUDED
#define DGL_IMAGE_BASE_HPP_INCLUDED
#include "Geometry.hpp"
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
/**
Base DGL Image class.
This is an Image class that handles raw image data in pixels.
It is an abstract class that provides the common methods to build on top.
Cairo and OpenGL Image classes are based upon this one.
@see Image
*/
class ImageBase
{
protected:
/**
Constructor for a null Image.
*/
ImageBase();
/**
Constructor using raw image data.
@note @a rawData must remain valid for the lifetime of this Image.
*/
ImageBase(const char* const rawData, const uint width, const uint height);
/**
Constructor using raw image data.
@note @a rawData must remain valid for the lifetime of this Image.
*/
ImageBase(const char* const rawData, const Size& size);
/**
Constructor using another image data.
*/
ImageBase(const ImageBase& image);
public:
/**
Destructor.
*/
virtual ~ImageBase();
/**
Check if this image is valid.
*/
bool isValid() const noexcept;
/**
Get width.
*/
uint getWidth() const noexcept;
/**
Get height.
*/
uint getHeight() const noexcept;
/**
Get size.
*/
const Size& getSize() const noexcept;
/**
Get the raw image data.
*/
const char* getRawData() const noexcept;
/**
Draw this image at (0, 0) point.
*/
void draw();
/**
Draw this image at (x, y) point.
*/
void drawAt(const int x, const int y);
/**
Draw this image at position @a pos.
*/
void drawAt(const Point& pos);
/**
TODO document this.
*/
ImageBase& operator=(const ImageBase& image) noexcept;
bool operator==(const ImageBase& image) const noexcept;
bool operator!=(const ImageBase& image) const noexcept;
protected:
/** @internal */
virtual void _drawAt(const Point& pos) = 0;
const char* fRawData;
Size fSize;
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_IMAGE_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/ImageWidgets.hpp 0000664 0000000 0000000 00000017624 13510326665 0020027 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_IMAGE_WIDGETS_HPP_INCLUDED
#define DGL_IMAGE_WIDGETS_HPP_INCLUDED
#include "Image.hpp"
#include "Widget.hpp"
#include "Window.hpp"
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
class ImageAboutWindow : public Window,
public Widget
{
public:
explicit ImageAboutWindow(Window& parent, const Image& image = Image());
explicit ImageAboutWindow(Widget* widget, const Image& image = Image());
void setImage(const Image& image);
protected:
void onDisplay() override;
bool onKeyboard(const KeyboardEvent&) override;
bool onMouse(const MouseEvent&) override;
void onReshape(uint width, uint height) override;
private:
Image fImgBackground;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImageAboutWindow)
};
// -----------------------------------------------------------------------
class ImageButton : public Widget
{
public:
class Callback
{
public:
virtual ~Callback() {}
virtual void imageButtonClicked(ImageButton* imageButton, int button) = 0;
};
explicit ImageButton(Window& parent, const Image& image);
explicit ImageButton(Window& parent, const Image& imageNormal, const Image& imageDown);
explicit ImageButton(Window& parent, const Image& imageNormal, const Image& imageHover, const Image& imageDown);
explicit ImageButton(Widget* widget, const Image& image);
explicit ImageButton(Widget* widget, const Image& imageNormal, const Image& imageDown);
explicit ImageButton(Widget* widget, const Image& imageNormal, const Image& imageHover, const Image& imageDown);
~ImageButton() override;
void setCallback(Callback* callback) noexcept;
protected:
void onDisplay() override;
bool onMouse(const MouseEvent&) override;
bool onMotion(const MotionEvent&) override;
private:
struct PrivateData;
PrivateData* const pData;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImageButton)
};
// -----------------------------------------------------------------------
class ImageKnob : public Widget
{
public:
enum Orientation {
Horizontal,
Vertical
};
class Callback
{
public:
virtual ~Callback() {}
virtual void imageKnobDragStarted(ImageKnob* imageKnob) = 0;
virtual void imageKnobDragFinished(ImageKnob* imageKnob) = 0;
virtual void imageKnobValueChanged(ImageKnob* imageKnob, float value) = 0;
};
explicit ImageKnob(Window& parent, const Image& image, Orientation orientation = Vertical) noexcept;
explicit ImageKnob(Widget* widget, const Image& image, Orientation orientation = Vertical) noexcept;
explicit ImageKnob(const ImageKnob& imageKnob);
ImageKnob& operator=(const ImageKnob& imageKnob);
~ImageKnob() override;
float getValue() const noexcept;
void setDefault(float def) noexcept;
void setRange(float min, float max) noexcept;
void setStep(float step) noexcept;
void setValue(float value, bool sendCallback = false) noexcept;
void setUsingLogScale(bool yesNo) noexcept;
void setCallback(Callback* callback) noexcept;
void setOrientation(Orientation orientation) noexcept;
void setRotationAngle(int angle);
void setImageLayerCount(uint count) noexcept;
protected:
void onDisplay() override;
bool onMouse(const MouseEvent&) override;
bool onMotion(const MotionEvent&) override;
bool onScroll(const ScrollEvent&) override;
private:
Image fImage;
float fMinimum;
float fMaximum;
float fStep;
float fValue;
float fValueDef;
float fValueTmp;
bool fUsingDefault;
bool fUsingLog;
Orientation fOrientation;
int fRotationAngle;
bool fDragging;
int fLastX;
int fLastY;
Callback* fCallback;
bool fIsImgVertical;
uint fImgLayerWidth;
uint fImgLayerHeight;
uint fImgLayerCount;
bool fIsReady;
GLuint fTextureId;
float _logscale(float value) const;
float _invlogscale(float value) const;
DISTRHO_LEAK_DETECTOR(ImageKnob)
};
// -----------------------------------------------------------------------
// note set range and step before setting the value
class ImageSlider : public Widget
{
public:
class Callback
{
public:
virtual ~Callback() {}
virtual void imageSliderDragStarted(ImageSlider* imageSlider) = 0;
virtual void imageSliderDragFinished(ImageSlider* imageSlider) = 0;
virtual void imageSliderValueChanged(ImageSlider* imageSlider, float value) = 0;
};
explicit ImageSlider(Window& parent, const Image& image) noexcept;
explicit ImageSlider(Widget* widget, const Image& image) noexcept;
float getValue() const noexcept;
void setValue(float value, bool sendCallback = false) noexcept;
void setDefault(float def) noexcept;
void setStartPos(const Point& startPos) noexcept;
void setStartPos(int x, int y) noexcept;
void setEndPos(const Point& endPos) noexcept;
void setEndPos(int x, int y) noexcept;
void setInverted(bool inverted) noexcept;
void setRange(float min, float max) noexcept;
void setStep(float step) noexcept;
void setCallback(Callback* callback) noexcept;
protected:
void onDisplay() override;
bool onMouse(const MouseEvent&) override;
bool onMotion(const MotionEvent&) override;
private:
Image fImage;
float fMinimum;
float fMaximum;
float fStep;
float fValue;
float fValueDef;
float fValueTmp;
bool fUsingDefault;
bool fDragging;
bool fInverted;
bool fValueIsSet;
int fStartedX;
int fStartedY;
Callback* fCallback;
Point fStartPos;
Point fEndPos;
Rectangle fSliderArea;
void _recheckArea() noexcept;
// these should not be used
void setAbsoluteX(int) const noexcept {}
void setAbsoluteY(int) const noexcept {}
void setAbsolutePos(int, int) const noexcept {}
void setAbsolutePos(const Point&) const noexcept {}
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImageSlider)
};
// -----------------------------------------------------------------------
class ImageSwitch : public Widget
{
public:
class Callback
{
public:
virtual ~Callback() {}
virtual void imageSwitchClicked(ImageSwitch* imageSwitch, bool down) = 0;
};
explicit ImageSwitch(Window& parent, const Image& imageNormal, const Image& imageDown) noexcept;
explicit ImageSwitch(Widget* widget, const Image& imageNormal, const Image& imageDown) noexcept;
explicit ImageSwitch(const ImageSwitch& imageSwitch) noexcept;
ImageSwitch& operator=(const ImageSwitch& imageSwitch) noexcept;
bool isDown() const noexcept;
void setDown(bool down) noexcept;
void setCallback(Callback* callback) noexcept;
protected:
void onDisplay() override;
bool onMouse(const MouseEvent&) override;
private:
Image fImageNormal;
Image fImageDown;
bool fIsDown;
Callback* fCallback;
DISTRHO_LEAK_DETECTOR(ImageSwitch)
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_IMAGE_WIDGETS_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/Makefile 0000664 0000000 0000000 00000011400 13510326665 0016367 0 ustar 00root root 0000000 0000000 #!/usr/bin/make -f
# Makefile for DGL #
# ---------------- #
# Created by falkTX
#
include ../Makefile.base.mk
# ---------------------------------------------------------------------------------------------------------------------
BUILD_C_FLAGS += $(DGL_FLAGS) -I. -Isrc
BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. -Isrc -DDONT_SET_USING_DGL_NAMESPACE -Wno-unused-parameter
LINK_FLAGS += $(DGL_LIBS)
# ifneq ($(MACOS_OLD),true)
# needed by sofd right now, fix later
# BUILD_CXX_FLAGS += -Wno-type-limits -fpermissive
# endif
# ---------------------------------------------------------------------------------------------------------------------
OBJS_common = \
../build/dgl/Application.cpp.o \
../build/dgl/Color.cpp.o \
../build/dgl/Geometry.cpp.o \
../build/dgl/ImageBase.cpp.o \
../build/dgl/Resources.cpp.o \
../build/dgl/Widget.cpp.o
# TODO: ImageWidgets.cpp
# ---------------------------------------------------------------------------------------------------------------------
OBJS_cairo = $(OBJS_common) \
../build/dgl/Cairo.cpp.cairo.o \
../build/dgl/WidgetPrivateData.cpp.cairo.o
ifeq ($(MACOS),true)
OBJS_cairo += ../build/dgl/Window.mm.cairo.o
else
OBJS_cairo += ../build/dgl/Window.cpp.cairo.o
endif
# ---------------------------------------------------------------------------------------------------------------------
OBJS_opengl = $(OBJS_common) \
../build/dgl/OpenGL.cpp.opengl.o \
../build/dgl/Image.cpp.opengl.o \
../build/dgl/ImageWidgets.cpp.opengl.o \
../build/dgl/NanoVG.cpp.opengl.o \
../build/dgl/WidgetPrivateData.cpp.opengl.o
ifeq ($(MACOS),true)
OBJS_opengl += ../build/dgl/Window.mm.opengl.o
else
OBJS_opengl += ../build/dgl/Window.cpp.opengl.o
endif
# ---------------------------------------------------------------------------------------------------------------------
ifeq ($(HAVE_CAIRO),true)
TARGETS += ../build/libdgl-cairo.a
endif
ifeq ($(HAVE_OPENGL),true)
TARGETS += ../build/libdgl-opengl.a
# Compat name, to be removed soon
TARGETS += ../build/libdgl.a
endif
# ---------------------------------------------------------------------------------------------------------------------
all: $(TARGETS)
# ---------------------------------------------------------------------------------------------------------------------
../build/libdgl-cairo.a: $(OBJS_cairo)
-@mkdir -p ../build
@echo "Creating libdgl-cairo.a"
@rm -f $@
@$(AR) crs $@ $^
../build/libdgl-opengl.a: $(OBJS_opengl)
-@mkdir -p ../build
@echo "Creating libdgl-opengl.a"
@rm -f $@
@$(AR) crs $@ $^
# Compat name, to be removed soon
../build/libdgl.a: ../build/libdgl-opengl.a
@echo "Symlinking libdgl.a"
@ln -sf $< $@
# ---------------------------------------------------------------------------------------------------------------------
../build/dgl/%.c.o: src/%.c
-@mkdir -p ../build/dgl
@echo "Compiling $<"
@$(CC) $< $(BUILD_C_FLAGS) -c -o $@
../build/dgl/%.cpp.o: src/%.cpp
-@mkdir -p ../build/dgl
@echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
# ---------------------------------------------------------------------------------------------------------------------
../build/dgl/%.cpp.cairo.o: src/%.cpp
-@mkdir -p ../build/dgl
@echo "Compiling $< (Cairo variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_CAIRO -c -o $@
../build/dgl/Window.cpp.cairo.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl
@echo "Compiling $< (Cairo variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_CAIRO -c -o $@
../build/dgl/Window.mm.cairo.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl
@echo "Compiling $< (Cairo variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_CAIRO -ObjC++ -c -o $@
# ---------------------------------------------------------------------------------------------------------------------
../build/dgl/%.cpp.opengl.o: src/%.cpp
-@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_OPENGL -c -o $@
../build/dgl/Window.cpp.opengl.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_OPENGL -c -o $@
../build/dgl/Window.mm.opengl.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_OPENGL -ObjC++ -c -o $@
# ---------------------------------------------------------------------------------------------------------------------
clean:
rm -rf ../build/dgl ../build/libdgl*.*
debug:
$(MAKE) DEBUG=true
# ---------------------------------------------------------------------------------------------------------------------
-include $(OBJS_common:%.o=%.d)
-include $(OBJS_cairo:%.o=%.d)
-include $(OBJS_opengl:%.o=%.d)
# ---------------------------------------------------------------------------------------------------------------------
DPF-Plugins-1.3/dpf/dgl/NanoVG.hpp 0000664 0000000 0000000 00000071670 13510326665 0016607 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_NANO_WIDGET_HPP_INCLUDED
#define DGL_NANO_WIDGET_HPP_INCLUDED
#include "Color.hpp"
#include "OpenGL.hpp"
#include "Widget.hpp"
#ifndef DGL_NO_SHARED_RESOURCES
# define NANOVG_DEJAVU_SANS_TTF "__dpf_dejavusans_ttf__"
#endif
struct NVGcontext;
struct NVGpaint;
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
// Forward class names
class BlendishWidget;
class NanoVG;
// -----------------------------------------------------------------------
// NanoImage
/**
NanoVG Image class.
This implements NanoVG images as a C++ class where deletion is handled automatically.
Images need to be created within a NanoVG or NanoWidget class.
*/
class NanoImage
{
private:
struct Handle {
NVGcontext* context;
int imageId;
Handle() noexcept
: context(nullptr),
imageId(0) {}
Handle(NVGcontext* c, int id) noexcept
: context(c),
imageId(id) {}
};
public:
/**
Constructor for an invalid/null image.
*/
NanoImage();
/**
Constructor.
*/
NanoImage(const Handle& handle);
/**
Destructor.
*/
~NanoImage();
/**
Create a new image without recreating the C++ class.
*/
NanoImage& operator=(const Handle& handle);
/**
Wherever this image is valid.
*/
bool isValid() const noexcept;
/**
Get size.
*/
Size getSize() const noexcept;
/**
Get the OpenGL texture handle.
*/
GLuint getTextureHandle() const;
private:
Handle fHandle;
Size fSize;
friend class NanoVG;
/** @internal */
void _updateSize();
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoImage)
};
// -----------------------------------------------------------------------
// NanoVG
/**
NanoVG class.
This class exposes the NanoVG drawing API.
All calls should be wrapped in beginFrame() and endFrame().
@section State Handling
NanoVG contains state which represents how paths will be rendered.
The state contains transform, fill and stroke styles, text and font styles, and scissor clipping.
@section Render styles
Fill and stroke render style can be either a solid color or a paint which is a gradient or a pattern.
Solid color is simply defined as a color value, different kinds of paints can be created
using linearGradient(), boxGradient(), radialGradient() and imagePattern().
Current render style can be saved and restored using save() and restore().
@section Transforms
The paths, gradients, patterns and scissor region are transformed by an transformation
matrix at the time when they are passed to the API.
The current transformation matrix is a affine matrix:
[sx kx tx]
[ky sy ty]
[ 0 0 1]
Where: sx,sy define scaling, kx,ky skewing, and tx,ty translation.
The last row is assumed to be 0,0,1 and is not stored.
Apart from resetTransform(), each transformation function first creates
specific transformation matrix and pre-multiplies the current transformation by it.
Current coordinate system (transformation) can be saved and restored using save() and restore().
@section Images
NanoVG allows you to load jpg, png, psd, tga, pic and gif files to be used for rendering.
In addition you can upload your own image. The image loading is provided by stb_image.
@section Paints
NanoVG supports four types of paints: linear gradient, box gradient, radial gradient and image pattern.
These can be used as paints for strokes and fills.
@section Scissoring
Scissoring allows you to clip the rendering into a rectangle. This is useful for various
user interface cases like rendering a text edit or a timeline.
@section Paths
Drawing a new shape starts with beginPath(), it clears all the currently defined paths.
Then you define one or more paths and sub-paths which describe the shape. The are functions
to draw common shapes like rectangles and circles, and lower level step-by-step functions,
which allow to define a path curve by curve.
NanoVG uses even-odd fill rule to draw the shapes. Solid shapes should have counter clockwise
winding and holes should have counter clockwise order. To specify winding of a path you can
call pathWinding(). This is useful especially for the common shapes, which are drawn CCW.
Finally you can fill the path using current fill style by calling fill(), and stroke it
with current stroke style by calling stroke().
The curve segments and sub-paths are transformed by the current transform.
@section Text
NanoVG allows you to load .ttf files and use the font to render text.
The appearance of the text can be defined by setting the current text style
and by specifying the fill color. Common text and font settings such as
font size, letter spacing and text align are supported. Font blur allows you
to create simple text effects such as drop shadows.
At render time the font face can be set based on the font handles or name.
Font measure functions return values in local space, the calculations are
carried in the same resolution as the final rendering. This is done because
the text glyph positions are snapped to the nearest pixels sharp rendering.
The local space means that values are not rotated or scale as per the current
transformation. For example if you set font size to 12, which would mean that
line height is 16, then regardless of the current scaling and rotation, the
returned line height is always 16. Some measures may vary because of the scaling
since aforementioned pixel snapping.
While this may sound a little odd, the setup allows you to always render the
same way regardless of scaling. i.e. following works regardless of scaling:
@code
const char* txt = "Text me up.";
vg.textBounds(x,y, txt, NULL, bounds);
vg.beginPath();
vg.roundedRect(bounds[0], bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]);
vg.fill();
@endcode
Note: currently only solid color fill is supported for text.
*/
class NanoVG
{
public:
enum CreateFlags {
/**
Flag indicating if geometry based anti-aliasing is used (may not be needed when using MSAA).
*/
CREATE_ANTIALIAS = 1 << 0,
/**
Flag indicating if strokes should be drawn using stencil buffer. The rendering will be a little
slower, but path overlaps (i.e. self-intersecting or sharp turns) will be drawn just once.
*/
CREATE_STENCIL_STROKES = 1 << 1,
/**
Flag indicating that additional debug checks are done.
*/
CREATE_DEBUG = 1 << 2,
};
enum ImageFlags {
IMAGE_GENERATE_MIPMAPS = 1 << 0, // Generate mipmaps during creation of the image.
IMAGE_REPEAT_X = 1 << 1, // Repeat image in X direction.
IMAGE_REPEAT_Y = 1 << 2, // Repeat image in Y direction.
IMAGE_FLIP_Y = 1 << 3, // Flips (inverses) image in Y direction when rendered.
IMAGE_PREMULTIPLIED = 1 << 4 // Image data has premultiplied alpha.
};
enum Align {
// Horizontal align
ALIGN_LEFT = 1 << 0, // Align horizontally to left (default).
ALIGN_CENTER = 1 << 1, // Align horizontally to center.
ALIGN_RIGHT = 1 << 2, // Align horizontally to right.
// Vertical align
ALIGN_TOP = 1 << 3, // Align vertically to top.
ALIGN_MIDDLE = 1 << 4, // Align vertically to middle.
ALIGN_BOTTOM = 1 << 5, // Align vertically to bottom.
ALIGN_BASELINE = 1 << 6 // Align vertically to baseline (default).
};
enum LineCap {
BUTT,
ROUND,
SQUARE,
BEVEL,
MITER
};
enum Solidity {
SOLID = 1, // CCW
HOLE = 2 // CW
};
enum Winding {
CCW = 1, // Winding for solid shapes
CW = 2 // Winding for holes
};
struct Paint {
float xform[6];
float extent[2];
float radius;
float feather;
Color innerColor;
Color outerColor;
int imageId;
Paint() noexcept;
/**
@internal
*/
Paint(const NVGpaint&) noexcept;
operator NVGpaint() const noexcept;
};
struct GlyphPosition {
const char* str; // Position of the glyph in the input string.
float x; // The x-coordinate of the logical glyph position.
float minx, maxx; // The bounds of the glyph shape.
};
struct TextRow {
const char* start; // Pointer to the input text where the row starts.
const char* end; // Pointer to the input text where the row ends (one past the last character).
const char* next; // Pointer to the beginning of the next row.
float width; // Logical width of the row.
float minx, maxx; // Actual bounds of the row. Logical with and bounds can differ because of kerning and some parts over extending.
};
typedef int FontId;
/**
Constructor.
@see CreateFlags
*/
NanoVG(int flags = CREATE_ANTIALIAS);
/**
Constructor reusing a NanoVG context, used for subwidgets.
*/
NanoVG(NanoWidget* groupWidget);
/**
Destructor.
*/
virtual ~NanoVG();
/**
Get the NanoVG context.
You should not need this under normal circumstances.
*/
NVGcontext* getContext() const noexcept
{
return fContext;
}
/**
Begin drawing a new frame.
*/
void beginFrame(const uint width, const uint height, const float scaleFactor = 1.0f);
/**
Begin drawing a new frame inside a widget.
*/
void beginFrame(Widget* const widget);
/**
Cancels drawing the current frame.
*/
void cancelFrame();
/**
Ends drawing flushing remaining render state.
*/
void endFrame();
/* --------------------------------------------------------------------
* State Handling */
/**
Pushes and saves the current render state into a state stack.
A matching restore() must be used to restore the state.
*/
void save();
/**
Pops and restores current render state.
*/
void restore();
/**
Resets current render state to default values. Does not affect the render state stack.
*/
void reset();
/* --------------------------------------------------------------------
* Render styles */
/**
Sets current stroke style to a solid color.
*/
void strokeColor(const Color& color);
/**
Sets current stroke style to a solid color, made from red, green, blue and alpha numeric values.
Values must be in [0..255] range.
*/
void strokeColor(const int red, const int green, const int blue, const int alpha = 255);
/**
Sets current stroke style to a solid color, made from red, green, blue and alpha numeric values.
Values must in [0..1] range.
*/
void strokeColor(const float red, const float green, const float blue, const float alpha = 1.0f);
/**
Sets current stroke style to a paint, which can be a one of the gradients or a pattern.
*/
void strokePaint(const Paint& paint);
/**
Sets current fill style to a solid color.
*/
void fillColor(const Color& color);
/**
Sets current fill style to a solid color, made from red, green, blue and alpha numeric values.
Values must be in [0..255] range.
*/
void fillColor(const int red, const int green, const int blue, const int alpha = 255);
/**
Sets current fill style to a solid color, made from red, green, blue and alpha numeric values.
Values must in [0..1] range.
*/
void fillColor(const float red, const float green, const float blue, const float alpha = 1.0f);
/**
Sets current fill style to a paint, which can be a one of the gradients or a pattern.
*/
void fillPaint(const Paint& paint);
/**
Sets the miter limit of the stroke style.
Miter limit controls when a sharp corner is beveled.
*/
void miterLimit(float limit);
/**
Sets the stroke width of the stroke style.
*/
void strokeWidth(float size);
/**
Sets how the end of the line (cap) is drawn,
Can be one of: BUTT, ROUND, SQUARE.
*/
void lineCap(LineCap cap = BUTT);
/**
Sets how sharp path corners are drawn.
Can be one of MITER, ROUND, BEVEL.
*/
void lineJoin(LineCap join = MITER);
/**
Sets the transparency applied to all rendered shapes.
Already transparent paths will get proportionally more transparent as well.
*/
void globalAlpha(float alpha);
/* --------------------------------------------------------------------
* Transforms */
/**
Resets current transform to a identity matrix.
*/
void resetTransform();
/**
Pre-multiplies current coordinate system by specified matrix.
The parameters are interpreted as matrix as follows:
[a c e]
[b d f]
[0 0 1]
*/
void transform(float a, float b, float c, float d, float e, float f);
/**
Translates current coordinate system.
*/
void translate(float x, float y);
/**
Rotates current coordinate system. Angle is specified in radians.
*/
void rotate(float angle);
/**
Skews the current coordinate system along X axis. Angle is specified in radians.
*/
void skewX(float angle);
/**
Skews the current coordinate system along Y axis. Angle is specified in radians.
*/
void skewY(float angle);
/**
Scales the current coordinate system.
*/
void scale(float x, float y);
/**
Stores the top part (a-f) of the current transformation matrix in to the specified buffer.
[a c e]
[b d f]
[0 0 1]
*/
void currentTransform(float xform[6]);
/**
The following functions can be used to make calculations on 2x3 transformation matrices.
A 2x3 matrix is represented as float[6]. */
/**
Sets the transform to identity matrix.
*/
static void transformIdentity(float dst[6]);
/**
Sets the transform to translation matrix
*/
static void transformTranslate(float dst[6], float tx, float ty);
/**
Sets the transform to scale matrix.
*/
static void transformScale(float dst[6], float sx, float sy);
/**
Sets the transform to rotate matrix. Angle is specified in radians.
*/
static void transformRotate(float dst[6], float a);
/**
Sets the transform to skew-x matrix. Angle is specified in radians.
*/
static void transformSkewX(float dst[6], float a);
/**
Sets the transform to skew-y matrix. Angle is specified in radians.
*/
static void transformSkewY(float dst[6], float a);
/**
Sets the transform to the result of multiplication of two transforms, of A = A*B.
*/
static void transformMultiply(float dst[6], const float src[6]);
/**
Sets the transform to the result of multiplication of two transforms, of A = B*A.
*/
static void transformPremultiply(float dst[6], const float src[6]);
/**
Sets the destination to inverse of specified transform.
Returns 1 if the inverse could be calculated, else 0.
*/
static int transformInverse(float dst[6], const float src[6]);
/**
Transform a point by given transform.
*/
static void transformPoint(float& dstx, float& dsty, const float xform[6], float srcx, float srcy);
/**
Convert degrees to radians.
*/
static float degToRad(float deg);
/**
Convert radians to degrees.
*/
static float radToDeg(float rad);
/* --------------------------------------------------------------------
* Images */
/**
Creates image by loading it from the disk from specified file name.
*/
NanoImage::Handle createImageFromFile(const char* filename, ImageFlags imageFlags);
/**
Creates image by loading it from the disk from specified file name.
Overloaded function for convenience.
@see ImageFlags
*/
NanoImage::Handle createImageFromFile(const char* filename, int imageFlags);
/**
Creates image by loading it from the specified chunk of memory.
*/
NanoImage::Handle createImageFromMemory(uchar* data, uint dataSize, ImageFlags imageFlags);
/**
Creates image by loading it from the specified chunk of memory.
Overloaded function for convenience.
@see ImageFlags
*/
NanoImage::Handle createImageFromMemory(uchar* data, uint dataSize, int imageFlags);
/**
Creates image from specified image data.
*/
NanoImage::Handle createImageFromRGBA(uint w, uint h, const uchar* data, ImageFlags imageFlags);
/**
Creates image from specified image data.
Overloaded function for convenience.
@see ImageFlags
*/
NanoImage::Handle createImageFromRGBA(uint w, uint h, const uchar* data, int imageFlags);
/**
Creates image from an OpenGL texture handle.
*/
NanoImage::Handle createImageFromTextureHandle(GLuint textureId, uint w, uint h, ImageFlags imageFlags, bool deleteTexture = false);
/**
Creates image from an OpenGL texture handle.
Overloaded function for convenience.
@see ImageFlags
*/
NanoImage::Handle createImageFromTextureHandle(GLuint textureId, uint w, uint h, int imageFlags, bool deleteTexture = false);
/* --------------------------------------------------------------------
* Paints */
/**
Creates and returns a linear gradient. Parameters (sx,sy)-(ex,ey) specify the start and end coordinates
of the linear gradient, icol specifies the start color and ocol the end color.
The gradient is transformed by the current transform when it is passed to fillPaint() or strokePaint().
*/
Paint linearGradient(float sx, float sy, float ex, float ey, const Color& icol, const Color& ocol);
/**
Creates and returns a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering
drop shadows or highlights for boxes. Parameters (x,y) define the top-left corner of the rectangle,
(w,h) define the size of the rectangle, r defines the corner radius, and f feather. Feather defines how blurry
the border of the rectangle is. Parameter icol specifies the inner color and ocol the outer color of the gradient.
The gradient is transformed by the current transform when it is passed to fillPaint() or strokePaint().
*/
Paint boxGradient(float x, float y, float w, float h, float r, float f, const Color& icol, const Color& ocol);
/**
Creates and returns a radial gradient. Parameters (cx,cy) specify the center, inr and outr specify
the inner and outer radius of the gradient, icol specifies the start color and ocol the end color.
The gradient is transformed by the current transform when it is passed to fillPaint() or strokePaint().
*/
Paint radialGradient(float cx, float cy, float inr, float outr, const Color& icol, const Color& ocol);
/**
Creates and returns an image pattern. Parameters (ox,oy) specify the left-top location of the image pattern,
(ex,ey) the size of one image, angle rotation around the top-left corner, image is handle to the image to render.
The gradient is transformed by the current transform when it is passed to fillPaint() or strokePaint().
*/
Paint imagePattern(float ox, float oy, float ex, float ey, float angle, const NanoImage& image, float alpha);
/* --------------------------------------------------------------------
* Scissoring */
/**
Sets the current scissor rectangle.
The scissor rectangle is transformed by the current transform.
*/
void scissor(float x, float y, float w, float h);
/**
Intersects current scissor rectangle with the specified rectangle.
The scissor rectangle is transformed by the current transform.
Note: in case the rotation of previous scissor rect differs from
the current one, the intersection will be done between the specified
rectangle and the previous scissor rectangle transformed in the current
transform space. The resulting shape is always rectangle.
*/
void intersectScissor(float x, float y, float w, float h);
/**
Reset and disables scissoring.
*/
void resetScissor();
/* --------------------------------------------------------------------
* Paths */
/**
Clears the current path and sub-paths.
*/
void beginPath();
/**
Starts new sub-path with specified point as first point.
*/
void moveTo(float x, float y);
/**
Adds line segment from the last point in the path to the specified point.
*/
void lineTo(float x, float y);
/**
Adds cubic bezier segment from last point in the path via two control points to the specified point.
*/
void bezierTo(float c1x, float c1y, float c2x, float c2y, float x, float y);
/**
Adds quadratic bezier segment from last point in the path via a control point to the specified point.
*/
void quadTo(float cx, float cy, float x, float y);
/**
Adds an arc segment at the corner defined by the last path point, and two specified points.
*/
void arcTo(float x1, float y1, float x2, float y2, float radius);
/**
Closes current sub-path with a line segment.
*/
void closePath();
/**
Sets the current sub-path winding.
*/
void pathWinding(Winding dir);
/**
Creates new circle arc shaped sub-path. The arc center is at cx,cy, the arc radius is r,
and the arc is drawn from angle a0 to a1, and swept in direction dir (NVG_CCW or NVG_CW).
Angles are specified in radians.
*/
void arc(float cx, float cy, float r, float a0, float a1, Winding dir);
/**
Creates new rectangle shaped sub-path.
*/
void rect(float x, float y, float w, float h);
/**
Creates new rounded rectangle shaped sub-path.
*/
void roundedRect(float x, float y, float w, float h, float r);
/**
Creates new ellipse shaped sub-path.
*/
void ellipse(float cx, float cy, float rx, float ry);
/**
Creates new circle shaped sub-path.
*/
void circle(float cx, float cy, float r);
/**
Fills the current path with current fill style.
*/
void fill();
/**
Fills the current path with current stroke style.
*/
void stroke();
/* --------------------------------------------------------------------
* Text */
/**
Creates font by loading it from the disk from specified file name.
Returns handle to the font.
*/
FontId createFontFromFile(const char* name, const char* filename);
/**
Creates font by loading it from the specified memory chunk.
Returns handle to the font.
*/
FontId createFontFromMemory(const char* name, const uchar* data, uint dataSize, bool freeData);
/**
Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found.
*/
FontId findFont(const char* name);
/**
Sets the font size of current text style.
*/
void fontSize(float size);
/**
Sets the blur of current text style.
*/
void fontBlur(float blur);
/**
Sets the letter spacing of current text style.
*/
void textLetterSpacing(float spacing);
/**
Sets the proportional line height of current text style. The line height is specified as multiple of font size.
*/
void textLineHeight(float lineHeight);
/**
Sets the text align of current text style.
*/
void textAlign(Align align);
/**
Sets the text align of current text style.
Overloaded function for convenience.
@see Align
*/
void textAlign(int align);
/**
Sets the font face based on specified id of current text style.
*/
void fontFaceId(FontId font);
/**
Sets the font face based on specified name of current text style.
*/
void fontFace(const char* font);
/**
Draws text string at specified location. If end is specified only the sub-string up to the end is drawn.
*/
float text(float x, float y, const char* string, const char* end);
/**
Draws multi-line text string at specified location wrapped at the specified width.
If end is specified only the sub-string up to the end is drawn.
White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered.
Words longer than the max width are slit at nearest character (i.e. no hyphenation).
*/
void textBox(float x, float y, float breakRowWidth, const char* string, const char* end = nullptr);
/**
Measures the specified text string. The bounds value are [xmin,ymin, xmax,ymax].
Returns the horizontal advance of the measured text (i.e. where the next character should drawn).
Measured values are returned in local coordinate space.
*/
float textBounds(float x, float y, const char* string, const char* end, Rectangle& bounds);
/**
Measures the specified multi-text string. Parameter bounds should be a pointer to float[4],
if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax]
Measured values are returned in local coordinate space.
*/
void textBoxBounds(float x, float y, float breakRowWidth, const char* string, const char* end, float bounds[4]);
/**
Calculates the glyph x positions of the specified text. If end is specified only the sub-string will be used.
Measured values are returned in local coordinate space.
*/
int textGlyphPositions(float x, float y, const char* string, const char* end, GlyphPosition& positions, int maxPositions);
/**
Returns the vertical metrics based on the current text style.
Measured values are returned in local coordinate space.
*/
void textMetrics(float* ascender, float* descender, float* lineh);
/**
Breaks the specified text into lines. If end is specified only the sub-string will be used.
White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered.
Words longer than the max width are slit at nearest character (i.e. no hyphenation).
*/
int textBreakLines(const char* string, const char* end, float breakRowWidth, TextRow& rows, int maxRows);
#ifndef DGL_NO_SHARED_RESOURCES
/**
Load DPF's internal shared resources for this NanoVG class.
*/
virtual void loadSharedResources();
#endif
private:
NVGcontext* const fContext;
bool fInFrame;
bool fIsSubWidget;
friend class BlendishWidget;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoVG)
};
// -----------------------------------------------------------------------
// NanoWidget
/**
NanoVG Widget class.
This class implements the NanoVG drawing API inside a DGL Widget.
The drawing function onDisplay() is implemented internally but a
new onNanoDisplay() needs to be overridden instead.
*/
class NanoWidget : public Widget,
public NanoVG
{
public:
/**
Constructor.
@see CreateFlags
*/
explicit NanoWidget(Window& parent, int flags = CREATE_ANTIALIAS);
/**
Constructor for a subwidget.
*/
explicit NanoWidget(Widget* groupWidget, int flags = CREATE_ANTIALIAS);
/**
Constructor for a subwidget, reusing a NanoVG context.
*/
explicit NanoWidget(NanoWidget* groupWidget);
/**
Destructor.
*/
virtual ~NanoWidget();
protected:
/**
New virtual onDisplay function.
@see onDisplay
*/
virtual void onNanoDisplay() = 0;
private:
struct PrivateData;
PrivateData* const nData;
/**
Widget display function.
Implemented internally to wrap begin/endFrame() automatically.
*/
void onDisplay() override;
// these should not be used
void beginFrame(uint,uint) {}
void beginFrame(uint,uint,float) {}
void beginFrame(Widget*) {}
void cancelFrame() {}
void endFrame() {}
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NanoWidget)
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_NANO_WIDGET_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/OpenGL.hpp 0000664 0000000 0000000 00000006121 13510326665 0016570 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_OPENGL_HPP_INCLUDED
#define DGL_OPENGL_HPP_INCLUDED
#include "ImageBase.hpp"
// -----------------------------------------------------------------------
// Fix OpenGL includes for Windows, based on glfw code (part 1)
#undef DGL_CALLBACK_DEFINED
#undef DGL_WINGDIAPI_DEFINED
#ifdef DISTRHO_OS_WINDOWS
#ifndef APIENTRY
# define APIENTRY __stdcall
#endif // APIENTRY
/* We need WINGDIAPI defined */
#ifndef WINGDIAPI
# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
# define WINGDIAPI __declspec(dllimport)
# elif defined(__LCC__)
# define WINGDIAPI __stdcall
# else
# define WINGDIAPI extern
# endif
# define DGL_WINGDIAPI_DEFINED
#endif // WINGDIAPI
/* Some files also need CALLBACK defined */
#ifndef CALLBACK
# if defined(_MSC_VER)
# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
# define CALLBACK __stdcall
# else
# define CALLBACK
# endif
# else
# define CALLBACK __stdcall
# endif
# define DGL_CALLBACK_DEFINED
#endif // CALLBACK
/* Most GL/glu.h variants on Windows need wchar_t */
#include
#endif // DISTRHO_OS_WINDOWS
// -----------------------------------------------------------------------
// OpenGL includes
#ifdef DISTRHO_OS_MAC
# include
#else
# ifndef DISTRHO_OS_WINDOWS
# define GL_GLEXT_PROTOTYPES
# endif
# include
# include
#endif
// -----------------------------------------------------------------------
// Missing OpenGL defines
#if defined(GL_BGR_EXT) && !defined(GL_BGR)
# define GL_BGR GL_BGR_EXT
#endif
#if defined(GL_BGRA_EXT) && !defined(GL_BGRA)
# define GL_BGRA GL_BGRA_EXT
#endif
#ifndef GL_CLAMP_TO_BORDER
# define GL_CLAMP_TO_BORDER 0x812D
#endif
// -----------------------------------------------------------------------
// Fix OpenGL includes for Windows, based on glfw code (part 2)
#ifdef DGL_CALLBACK_DEFINED
# undef CALLBACK
# undef DGL_CALLBACK_DEFINED
#endif
#ifdef DGL_WINGDIAPI_DEFINED
# undef WINGDIAPI
# undef DGL_WINGDIAPI_DEFINED
#endif
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
/**
Graphics context.
*/
struct GraphicsContext
{
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif
DPF-Plugins-1.3/dpf/dgl/StandaloneWindow.hpp 0000664 0000000 0000000 00000003354 13510326665 0020731 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_STANDALONE_WINDOW_HPP_INCLUDED
#define DGL_STANDALONE_WINDOW_HPP_INCLUDED
#include "Application.hpp"
#include "Widget.hpp"
#include "Window.hpp"
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
class StandaloneWindow : public Application,
public Window
{
public:
/**
Constructor.
*/
StandaloneWindow();
/**
Show window and execute application.
*/
void exec();
private:
Widget* fWidget;
/** @internal */
void onReshape(uint width, uint height) override;
/** @internal */
void _addWidget(Widget* widget) override;
/** @internal */
void _removeWidget(Widget* widget) override;
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneWindow)
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_STANDALONE_WINDOW_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/Widget.hpp 0000664 0000000 0000000 00000023017 13510326665 0016672 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_WIDGET_HPP_INCLUDED
#define DGL_WIDGET_HPP_INCLUDED
#include "Geometry.hpp"
#include
// -----------------------------------------------------------------------
// Forward class names
#ifdef DISTRHO_DEFINES_H_INCLUDED
START_NAMESPACE_DISTRHO
class UI;
END_NAMESPACE_DISTRHO
#endif
START_NAMESPACE_DGL
class Application;
class ImageSlider;
class NanoWidget;
class Window;
class StandaloneWindow;
// -----------------------------------------------------------------------
/**
Base DGL Widget class.
This is the base Widget class, from which all widgets are built.
All widgets have a parent Window where they'll be drawn.
This parent is never changed during the widget lifetime.
Widgets receive events in relative coordinates.
(0, 0) means its top-left position.
Windows paint widgets in the order they are constructed.
Early widgets are drawn first, at the bottom, then newer ones on top.
Events are sent in the inverse order so that the top-most widget gets
a chance to catch the event and stop its propagation.
All widget event callbacks do nothing by default.
*/
class Widget
{
public:
/**
Base event data.
@a mod The currently active keyboard modifiers, @see Modifier.
@a time The timestamp (if any).
*/
struct BaseEvent {
uint mod;
uint32_t time;
/** Constuctor */
BaseEvent() noexcept : mod(0x0), time(0) {}
/** Destuctor */
virtual ~BaseEvent() noexcept {}
};
/**
Keyboard event.
@a press True if the key was pressed, false if released.
@a key Unicode point of the key pressed.
@see onKeyboard
*/
struct KeyboardEvent : BaseEvent {
bool press;
uint key;
/** Constuctor */
KeyboardEvent() noexcept
: BaseEvent(),
press(false),
key(0) {}
};
/**
Special keyboard event.
@a press True if the key was pressed, false if released.
@a key The key pressed.
@see onSpecial
*/
struct SpecialEvent : BaseEvent {
bool press;
Key key;
/** Constuctor */
SpecialEvent() noexcept
: BaseEvent(),
press(false),
key(Key(0)) {}
};
/**
Mouse event.
@a button The button number (1 = left, 2 = middle, 3 = right).
@a press True if the button was pressed, false if released.
@a pos The widget-relative coordinates of the pointer.
@see onMouse
*/
struct MouseEvent : BaseEvent {
int button;
bool press;
Point pos;
/** Constuctor */
MouseEvent() noexcept
: BaseEvent(),
button(0),
press(false),
pos(0, 0) {}
};
/**
Mouse motion event.
@a pos The widget-relative coordinates of the pointer.
@see onMotion
*/
struct MotionEvent : BaseEvent {
Point pos;
/** Constuctor */
MotionEvent() noexcept
: BaseEvent(),
pos(0, 0) {}
};
/**
Mouse scroll event.
@a pos The widget-relative coordinates of the pointer.
@a delta The scroll distance.
@see onScroll
*/
struct ScrollEvent : BaseEvent {
Point pos;
Point delta;
/** Constuctor */
ScrollEvent() noexcept
: BaseEvent(),
pos(0, 0),
delta(0.0f, 0.0f) {}
};
/**
Resize event.
@a size The new widget size.
@a oldSize The previous size, may be null.
@see onResize
*/
struct ResizeEvent {
Size size;
Size oldSize;
/** Constuctor */
ResizeEvent() noexcept
: size(0, 0),
oldSize(0, 0) {}
};
/**
Widget position changed event.
@a pos The new absolute position of the widget.
@a oldPos The previous absolute position of the widget.
@see onPositionChanged
*/
struct PositionChangedEvent {
Point pos;
Point oldPos;
/** Constuctor */
PositionChangedEvent() noexcept
: pos(0, 0),
oldPos(0, 0) {}
};
/**
Constructor.
*/
explicit Widget(Window& parent);
/**
Constructor for a subwidget.
*/
explicit Widget(Widget* groupWidget);
/**
Destructor.
*/
virtual ~Widget();
/**
Check if this widget is visible within its parent window.
Invisible widgets do not receive events except resize.
*/
bool isVisible() const noexcept;
/**
Set widget visible (or not) according to @a yesNo.
*/
void setVisible(bool yesNo);
/**
Show widget.
This is the same as calling setVisible(true).
*/
void show();
/**
Hide widget.
This is the same as calling setVisible(false).
*/
void hide();
/**
Get width.
*/
uint getWidth() const noexcept;
/**
Get height.
*/
uint getHeight() const noexcept;
/**
Get size.
*/
const Size& getSize() const noexcept;
/**
Set width.
*/
void setWidth(uint width) noexcept;
/**
Set height.
*/
void setHeight(uint height) noexcept;
/**
Set size using @a width and @a height values.
*/
void setSize(uint width, uint height) noexcept;
/**
Set size.
*/
void setSize(const Size& size) noexcept;
/**
Get absolute X.
*/
int getAbsoluteX() const noexcept;
/**
Get absolute Y.
*/
int getAbsoluteY() const noexcept;
/**
Get absolute position.
*/
const Point& getAbsolutePos() const noexcept;
/**
Set absolute X.
*/
void setAbsoluteX(int x) noexcept;
/**
Set absolute Y.
*/
void setAbsoluteY(int y) noexcept;
/**
Set absolute position using @a x and @a y values.
*/
void setAbsolutePos(int x, int y) noexcept;
/**
Set absolute position.
*/
void setAbsolutePos(const Point& pos) noexcept;
/**
Get this widget's window application.
Same as calling getParentWindow().getApp().
*/
Application& getParentApp() const noexcept;
/**
Get parent window, as passed in the constructor.
*/
Window& getParentWindow() const noexcept;
/**
Check if this widget contains the point defined by @a x and @a y.
*/
bool contains(int x, int y) const noexcept;
/**
Check if this widget contains the point @a pos.
*/
bool contains(const Point& pos) const noexcept;
/**
Tell this widget's window to repaint itself.
*/
void repaint() noexcept;
/**
Get the Id associated with this widget.
@see setId
*/
uint getId() const noexcept;
/**
Set an Id to be associated with this widget.
@see getId
*/
void setId(uint id) noexcept;
protected:
/**
A function called to draw the view contents with OpenGL.
*/
virtual void onDisplay() = 0;
/**
A function called when a key is pressed or released.
@return True to stop event propagation, false otherwise.
*/
virtual bool onKeyboard(const KeyboardEvent&);
/**
A function called when a special key is pressed or released.
@return True to stop event propagation, false otherwise.
*/
virtual bool onSpecial(const SpecialEvent&);
/**
A function called when a mouse button is pressed or released.
@return True to stop event propagation, false otherwise.
*/
virtual bool onMouse(const MouseEvent&);
/**
A function called when the pointer moves.
@return True to stop event propagation, false otherwise.
*/
virtual bool onMotion(const MotionEvent&);
/**
A function called on scrolling (e.g. mouse wheel or track pad).
@return True to stop event propagation, false otherwise.
*/
virtual bool onScroll(const ScrollEvent&);
/**
A function called when the widget is resized.
*/
virtual void onResize(const ResizeEvent&);
/**
A function called when the widget's absolute position is changed.
*/
virtual void onPositionChanged(const PositionChangedEvent&);
private:
struct PrivateData;
PrivateData* const pData;
/** @internal */
explicit Widget(Widget* groupWidget, bool addToSubWidgets);
friend class ImageSlider;
friend class NanoWidget;
friend class Window;
friend class StandaloneWindow;
#ifdef DISTRHO_DEFINES_H_INCLUDED
friend class DISTRHO_NAMESPACE::UI;
#endif
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Widget)
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_WIDGET_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/Window.hpp 0000664 0000000 0000000 00000010760 13510326665 0016717 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_WINDOW_HPP_INCLUDED
#define DGL_WINDOW_HPP_INCLUDED
#include "Geometry.hpp"
#ifdef DISTRHO_DEFINES_H_INCLUDED
START_NAMESPACE_DISTRHO
class UIExporter;
END_NAMESPACE_DISTRHO
#endif
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
class Application;
class Widget;
class StandaloneWindow;
class Window
{
public:
#ifndef DGL_FILE_BROWSER_DISABLED
/**
File browser options.
*/
struct FileBrowserOptions {
const char* startDir;
const char* title;
uint width;
uint height;
/**
File browser buttons.
0 means hidden.
1 means visible and unchecked.
2 means visible and checked.
*/
struct Buttons {
uint listAllFiles;
uint showHidden;
uint showPlaces;
/** Constuctor for default values */
Buttons()
: listAllFiles(2),
showHidden(1),
showPlaces(1) {}
} buttons;
/** Constuctor for default values */
FileBrowserOptions()
: startDir(nullptr),
title(nullptr),
width(0),
height(0),
buttons() {}
};
#endif // DGL_FILE_BROWSER_DISABLED
explicit Window(Application& app);
explicit Window(Application& app, Window& parent);
explicit Window(Application& app, intptr_t parentId, double scaling, bool resizable);
virtual ~Window();
void show();
void hide();
void close();
void exec(bool lockWait = false);
void focus();
void repaint() noexcept;
#ifndef DGL_FILE_BROWSER_DISABLED
bool openFileBrowser(const FileBrowserOptions& options);
#endif
bool isEmbed() const noexcept;
bool isVisible() const noexcept;
void setVisible(bool yesNo);
bool isResizable() const noexcept;
void setResizable(bool yesNo);
uint getWidth() const noexcept;
uint getHeight() const noexcept;
Size getSize() const noexcept;
void setSize(uint width, uint height);
void setSize(Size size);
const char* getTitle() const noexcept;
void setTitle(const char* title);
void setGeometryConstraints(uint width, uint height, bool aspect);
void setTransientWinId(uintptr_t winId);
double getScaling() const noexcept;
bool getIgnoringKeyRepeat() const noexcept;
void setIgnoringKeyRepeat(bool ignore) noexcept;
Application& getApp() const noexcept;
intptr_t getWindowId() const noexcept;
const GraphicsContext& getGraphicsContext() const noexcept;
void addIdleCallback(IdleCallback* const callback);
void removeIdleCallback(IdleCallback* const callback);
protected:
virtual void onDisplayBefore();
virtual void onDisplayAfter();
virtual void onReshape(uint width, uint height);
virtual void onClose();
#ifndef DGL_FILE_BROWSER_DISABLED
virtual void fileBrowserSelected(const char* filename);
#endif
// internal
void _setAutoScaling(double scaling) noexcept;
private:
struct PrivateData;
PrivateData* const pData;
friend class Application;
friend class Widget;
friend class StandaloneWindow;
#ifdef DISTRHO_DEFINES_H_INCLUDED
friend class DISTRHO_NAMESPACE::UIExporter;
#endif
virtual void _addWidget(Widget* const widget);
virtual void _removeWidget(Widget* const widget);
void _idle();
bool handlePluginKeyboard(const bool press, const uint key);
bool handlePluginSpecial(const bool press, const Key key);
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Window)
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_WINDOW_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/src/ 0000775 0000000 0000000 00000000000 13510326665 0015522 5 ustar 00root root 0000000 0000000 DPF-Plugins-1.3/dpf/dgl/src/Application.cpp 0000664 0000000 0000000 00000004066 13510326665 0020477 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#include "ApplicationPrivateData.hpp"
#include "../Window.hpp"
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
Application::Application()
: pData(new PrivateData()) {}
Application::~Application()
{
delete pData;
}
void Application::idle()
{
for (std::list::iterator it = pData->windows.begin(), ite = pData->windows.end(); it != ite; ++it)
{
Window* const window(*it);
window->_idle();
}
for (std::list::iterator it = pData->idleCallbacks.begin(), ite = pData->idleCallbacks.end(); it != ite; ++it)
{
IdleCallback* const idleCallback(*it);
idleCallback->idleCallback();
}
}
void Application::exec(int idleTime)
{
for (; pData->doLoop;)
{
idle();
d_msleep(idleTime);
}
}
void Application::quit()
{
pData->doLoop = false;
for (std::list::reverse_iterator rit = pData->windows.rbegin(), rite = pData->windows.rend(); rit != rite; ++rit)
{
Window* const window(*rit);
window->close();
}
}
bool Application::isQuiting() const noexcept
{
return !pData->doLoop;
}
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
DPF-Plugins-1.3/dpf/dgl/src/ApplicationPrivateData.hpp 0000664 0000000 0000000 00000003740 13510326665 0022627 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_APP_PRIVATE_DATA_HPP_INCLUDED
#define DGL_APP_PRIVATE_DATA_HPP_INCLUDED
#include "../Application.hpp"
#include "../../distrho/extra/Sleep.hpp"
#include
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
struct Application::PrivateData {
bool doLoop;
uint visibleWindows;
std::list windows;
std::list idleCallbacks;
PrivateData()
: doLoop(true),
visibleWindows(0),
windows(),
idleCallbacks() {}
~PrivateData()
{
DISTRHO_SAFE_ASSERT(! doLoop);
DISTRHO_SAFE_ASSERT(visibleWindows == 0);
windows.clear();
idleCallbacks.clear();
}
void oneShown() noexcept
{
if (++visibleWindows == 1)
doLoop = true;
}
void oneHidden() noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(visibleWindows > 0,);
if (--visibleWindows == 0)
doLoop = false;
}
DISTRHO_DECLARE_NON_COPY_STRUCT(PrivateData)
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_APP_PRIVATE_DATA_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/src/Cairo.cpp 0000664 0000000 0000000 00000002054 13510326665 0017264 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#include "../Base.hpp"
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
// nothing here yet
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
DPF-Plugins-1.3/dpf/dgl/src/Color.cpp 0000664 0000000 0000000 00000015242 13510326665 0017310 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#include "../Color.hpp"
#ifndef HAVE_DCAIRO
#include "nanovg/nanovg.h"
#endif
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
static float computeHue(float h, float m1, float m2)
{
if (h < 0) h += 1;
if (h > 1) h -= 1;
if (h < 1.0f/6.0f)
return m1 + (m2 - m1) * h * 6.0f;
if (h < 3.0f/6.0f)
return m2;
if (h < 4.0f/6.0f)
return m1 + (m2 - m1) * (2.0f/3.0f - h) * 6.0f;
return m1;
}
static void fixRange(float& value)
{
/**/ if (value < 0.0f)
value = 0.0f;
else if (value > 1.0f)
value = 1.0f;
}
static float getFixedRange(const float& value)
{
if (value <= 0.0f)
return 0.0f;
if (value >= 1.0f)
return 1.0f;
return value;
}
static uchar getFixedRange2(const float& value)
{
const float value2(getFixedRange(value)*255.0f);
if (value2 <= 0.0f)
return 0;
if (value2 >= 255.0f)
return 255;
return static_cast(value2);
}
// -----------------------------------------------------------------------
Color::Color() noexcept
: red(1.0f),
green(1.0f),
blue(1.0f),
alpha(1.0f) {}
Color::Color(int r, int g, int b, int a) noexcept
: red(static_cast(r)/255.0f),
green(static_cast(g)/255.0f),
blue(static_cast(b)/255.0f),
alpha(static_cast(a)/255.0f)
{
fixBounds();
}
Color::Color(float r, float g, float b, float a) noexcept
: red(r),
green(g),
blue(b),
alpha(a)
{
fixBounds();
}
Color::Color(const Color& color) noexcept
: red(color.red),
green(color.green),
blue(color.blue),
alpha(color.alpha)
{
fixBounds();
}
Color& Color::operator=(const Color& color) noexcept
{
red = color.red;
green = color.green;
blue = color.blue;
alpha = color.alpha;
fixBounds();
return *this;
}
Color::Color(const Color& color1, const Color& color2, float u) noexcept
: red(color1.red),
green(color1.green),
blue(color1.blue),
alpha(color1.alpha)
{
interpolate(color2, u);
}
Color Color::fromHSL(float hue, float saturation, float lightness, float alpha)
{
float m1, m2;
Color col;
hue = fmodf(hue, 1.0f);
if (hue < 0.0f) hue += 1.0f;
fixRange(saturation);
fixRange(lightness);
m2 = lightness <= 0.5f ? (lightness * (1 + saturation)) : (lightness + saturation - lightness * saturation);
m1 = 2 * lightness - m2;
col.red = computeHue(hue + 1.0f/3.0f, m1, m2);
col.green = computeHue(hue, m1, m2);
col.blue = computeHue(hue - 1.0f/3.0f, m1, m2);
col.alpha = alpha;
col.fixBounds();
return col;
}
Color Color::fromHTML(const char* rgb, float alpha)
{
Color fallback;
DISTRHO_SAFE_ASSERT_RETURN(rgb != nullptr && rgb[0] != '\0', fallback);
if (rgb[0] == '#') ++rgb;
DISTRHO_SAFE_ASSERT_RETURN(rgb[0] != '\0', fallback);
std::size_t rgblen(std::strlen(rgb));
DISTRHO_SAFE_ASSERT_RETURN(rgblen == 3 || rgblen == 6, fallback);
char rgbtmp[3] = { '\0', '\0', '\0' };
int r, g, b;
if (rgblen == 3)
{
rgbtmp[0] = rgb[0];
r = static_cast(std::strtol(rgbtmp, nullptr, 16));
rgbtmp[0] = rgb[1];
g = static_cast(std::strtol(rgbtmp, nullptr, 16));
rgbtmp[0] = rgb[2];
b = static_cast(std::strtol(rgbtmp, nullptr, 16));
}
else
{
rgbtmp[0] = rgb[0];
rgbtmp[1] = rgb[1];
r = static_cast(std::strtol(rgbtmp, nullptr, 16));
rgbtmp[0] = rgb[2];
rgbtmp[1] = rgb[3];
g = static_cast(std::strtol(rgbtmp, nullptr, 16));
rgbtmp[0] = rgb[4];
rgbtmp[1] = rgb[5];
b = static_cast(std::strtol(rgbtmp, nullptr, 16));
}
return Color(r, g, b, static_cast(getFixedRange(alpha)*255.0f));
}
void Color::interpolate(const Color& other, float u) noexcept
{
fixRange(u);
const float oneMinusU(1.0f - u);
red = red * oneMinusU + other.red * u;
green = green * oneMinusU + other.green * u;
blue = blue * oneMinusU + other.blue * u;
alpha = alpha * oneMinusU + other.alpha * u;
fixBounds();
}
// -----------------------------------------------------------------------
bool Color::isEqual(const Color& color, bool withAlpha) noexcept
{
const uchar r1 = getFixedRange2(rgba[0]);
const uchar g1 = getFixedRange2(rgba[1]);
const uchar b1 = getFixedRange2(rgba[2]);
const uchar a1 = getFixedRange2(rgba[3]);
const uchar r2 = getFixedRange2(color.rgba[0]);
const uchar g2 = getFixedRange2(color.rgba[1]);
const uchar b2 = getFixedRange2(color.rgba[2]);
const uchar a2 = getFixedRange2(color.rgba[3]);
if (withAlpha)
return (r1 == r2 && g1 == g2 && b1 == b2 && a1 == a2);
else
return (r1 == r2 && g1 == g2 && b1 == b2);
}
bool Color::isNotEqual(const Color& color, bool withAlpha) noexcept
{
const uchar r1 = getFixedRange2(rgba[0]);
const uchar g1 = getFixedRange2(rgba[1]);
const uchar b1 = getFixedRange2(rgba[2]);
const uchar a1 = getFixedRange2(rgba[3]);
const uchar r2 = getFixedRange2(color.rgba[0]);
const uchar g2 = getFixedRange2(color.rgba[1]);
const uchar b2 = getFixedRange2(color.rgba[2]);
const uchar a2 = getFixedRange2(color.rgba[3]);
if (withAlpha)
return (r1 != r2 || g1 != g2 || b1 != b2 || a1 != a2);
else
return (r1 != r2 || g1 != g2 || b1 != b2);
}
bool Color::operator==(const Color& color) noexcept
{
return isEqual(color, true);
}
bool Color::operator!=(const Color& color) noexcept
{
return isNotEqual(color, true);
}
// -----------------------------------------------------------------------
void Color::fixBounds() noexcept
{
fixRange(red);
fixRange(green);
fixRange(blue);
fixRange(alpha);
}
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
DPF-Plugins-1.3/dpf/dgl/src/Common.hpp 0000664 0000000 0000000 00000006413 13510326665 0017467 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#ifndef DGL_COMMON_HPP_INCLUDED
#define DGL_COMMON_HPP_INCLUDED
#include "../ImageWidgets.hpp"
START_NAMESPACE_DGL
// -----------------------------------------------------------------------
struct ButtonImpl {
enum State {
kStateNormal = 0,
kStateHover,
kStateDown
};
int button;
int state;
Widget* self;
ImageButton::Callback* callback_img;
ButtonImpl(Widget* const s) noexcept
: button(-1),
state(kStateNormal),
self(s),
callback_img(nullptr) {}
bool onMouse(const Widget::MouseEvent& ev)
{
// button was released, handle it now
if (button != -1 && ! ev.press)
{
DISTRHO_SAFE_ASSERT(state == kStateDown);
// release button
const int button2 = button;
button = -1;
// cursor was moved outside the button bounds, ignore click
if (! self->contains(ev.pos))
{
state = kStateNormal;
self->repaint();
return true;
}
// still on bounds, register click
state = kStateHover;
self->repaint();
if (callback_img != nullptr)
callback_img->imageButtonClicked((ImageButton*)self, button2);
return true;
}
// button was pressed, wait for release
if (ev.press && self->contains(ev.pos))
{
button = ev.button;
state = kStateDown;
self->repaint();
return true;
}
return false;
}
bool onMotion(const Widget::MotionEvent& ev)
{
// keep pressed
if (button != -1)
return true;
if (self->contains(ev.pos))
{
// check if entering hover
if (state == kStateNormal)
{
state = kStateHover;
self->repaint();
return true;
}
}
else
{
// check if exiting hover
if (state == kStateHover)
{
state = kStateNormal;
self->repaint();
return true;
}
}
return false;
}
DISTRHO_PREVENT_HEAP_ALLOCATION
DISTRHO_DECLARE_NON_COPY_STRUCT(ButtonImpl)
};
// -----------------------------------------------------------------------
END_NAMESPACE_DGL
#endif // DGL_APP_PRIVATE_DATA_HPP_INCLUDED
DPF-Plugins-1.3/dpf/dgl/src/Geometry.cpp 0000664 0000000 0000000 00000051061 13510326665 0020024 0 ustar 00root root 0000000 0000000 /*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho
*
* 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.
*
* THE 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.
*/
#include "../Geometry.hpp"
#include
START_NAMESPACE_DGL
static const float M_2PIf = 3.14159265358979323846f*2.0f;
// -----------------------------------------------------------------------
// Point
template
Point::Point() noexcept
: fX(0),
fY(0) {}
template
Point::Point(const T& x, const T& y) noexcept
: fX(x),
fY(y) {}
template
Point::Point(const Point& pos) noexcept
: fX(pos.fX),
fY(pos.fY) {}
template
const T& Point::getX() const noexcept
{
return fX;
}
template
const T& Point::getY() const noexcept
{
return fY;
}
template
void Point::setX(const T& x) noexcept
{
fX = x;
}
template
void Point::setY(const T& y) noexcept
{
fY = y;
}
template
void Point::setPos(const T& x, const T& y) noexcept
{
fX = x;
fY = y;
}
template
void Point::setPos(const Point& pos) noexcept
{
fX = pos.fX;
fY = pos.fY;
}
template
void Point::moveBy(const T& x, const T& y) noexcept
{
fX = static_cast(fX+x);
fY = static_cast(fY+y);
}
template
void Point::moveBy(const Point& pos) noexcept
{
fX = static_cast(fX+pos.fX);
fY = static_cast(fY+pos.fY);
}
template
bool Point::isZero() const noexcept
{
return fX == 0 && fY == 0;
}
template
bool Point::isNotZero() const noexcept
{
return fX != 0 || fY != 0;
}
template
Point Point::operator+(const Point& pos) noexcept
{
return Point(fX+pos.fX, fY+pos.fY);
}
template
Point Point::operator-(const Point& pos) noexcept
{
return Point(fX-pos.fX, fY-pos.fY);
}
template
Point& Point::operator=(const Point& pos) noexcept
{
fX = pos.fX;
fY = pos.fY;
return *this;
}
template
Point& Point::operator+=(const Point& pos) noexcept
{
fX = static_cast(fX+pos.fX);
fY = static_cast(fY+pos.fY);
return *this;
}
template
Point& Point::operator-=(const Point& pos) noexcept
{
fX = static_cast(fX-pos.fX);
fY = static_cast(fY-pos.fY);
return *this;
}
template
bool Point::operator==(const Point& pos) const noexcept
{
return (fX == pos.fX && fY == pos.fY);
}
template
bool Point::operator!=(const Point& pos) const noexcept
{
return (fX != pos.fX || fY != pos.fY);
}
// -----------------------------------------------------------------------
// Size
template
Size::Size() noexcept
: fWidth(0),
fHeight(0) {}
template
Size::Size(const T& width, const T& height) noexcept
: fWidth(width),
fHeight(height) {}
template
Size::Size(const Size& size) noexcept
: fWidth(size.fWidth),
fHeight(size.fHeight) {}
template
const T& Size::getWidth() const noexcept
{
return fWidth;
}
template
const T& Size