diff --git a/.gitmodules b/.gitmodules
index 7fd9a3017ea..418515f43fb 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -8,3 +8,6 @@
[submodule "libs/midifile"]
path = libs/midifile
url = https://github.com/craigsapp/midifile.git
+[submodule "libs/nanosvg"]
+ path = libs/nanosvg
+ url = https://github.com/memononen/nanosvg.git
diff --git a/assets/original-vector/SVG/exported/bmp00102.svg b/assets/original-vector/SVG/exported/bmp00102.svg
new file mode 100644
index 00000000000..dd2ad338f04
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00102.svg
@@ -0,0 +1,285 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00105.svg b/assets/original-vector/SVG/exported/bmp00105.svg
new file mode 100644
index 00000000000..9f652dd0785
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00105.svg
@@ -0,0 +1,127 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00108.svg b/assets/original-vector/SVG/exported/bmp00108.svg
new file mode 100644
index 00000000000..539b5951cf0
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00108.svg
@@ -0,0 +1,200 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00112.svg b/assets/original-vector/SVG/exported/bmp00112.svg
new file mode 100644
index 00000000000..074a0b53e2f
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00112.svg
@@ -0,0 +1,416 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00113.svg b/assets/original-vector/SVG/exported/bmp00113.svg
new file mode 100644
index 00000000000..0c099510a6f
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00113.svg
@@ -0,0 +1,15 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00114.svg b/assets/original-vector/SVG/exported/bmp00114.svg
new file mode 100644
index 00000000000..6cd2d5fbd14
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00114.svg
@@ -0,0 +1,28 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00118.svg b/assets/original-vector/SVG/exported/bmp00118.svg
new file mode 100644
index 00000000000..6013d9d19cc
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00118.svg
@@ -0,0 +1,82 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00119.svg b/assets/original-vector/SVG/exported/bmp00119.svg
new file mode 100644
index 00000000000..ace6ad9273f
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00119.svg
@@ -0,0 +1,37 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00120.svg b/assets/original-vector/SVG/exported/bmp00120.svg
new file mode 100644
index 00000000000..9b9f61d7e31
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00120.svg
@@ -0,0 +1,77 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00121.svg b/assets/original-vector/SVG/exported/bmp00121.svg
new file mode 100644
index 00000000000..2eae571a0e1
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00121.svg
@@ -0,0 +1,18 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00122.svg b/assets/original-vector/SVG/exported/bmp00122.svg
new file mode 100644
index 00000000000..0c273aafa96
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00122.svg
@@ -0,0 +1,34 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00123.svg b/assets/original-vector/SVG/exported/bmp00123.svg
new file mode 100644
index 00000000000..01687be6ab5
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00123.svg
@@ -0,0 +1,77 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00124.svg b/assets/original-vector/SVG/exported/bmp00124.svg
new file mode 100644
index 00000000000..f85ab4cf8d5
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00124.svg
@@ -0,0 +1,15 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00125.svg b/assets/original-vector/SVG/exported/bmp00125.svg
new file mode 100644
index 00000000000..a1c9eea4a87
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00125.svg
@@ -0,0 +1,15 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00126.svg b/assets/original-vector/SVG/exported/bmp00126.svg
new file mode 100644
index 00000000000..127a68d69bc
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00126.svg
@@ -0,0 +1,15 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00132.svg b/assets/original-vector/SVG/exported/bmp00132.svg
new file mode 100644
index 00000000000..5a57ed7fb8f
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00132.svg
@@ -0,0 +1,13 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00134.svg b/assets/original-vector/SVG/exported/bmp00134.svg
new file mode 100644
index 00000000000..2db9bf2eb89
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00134.svg
@@ -0,0 +1,13 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00136.svg b/assets/original-vector/SVG/exported/bmp00136.svg
new file mode 100644
index 00000000000..713cab26db2
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00136.svg
@@ -0,0 +1,221 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00137.svg b/assets/original-vector/SVG/exported/bmp00137.svg
new file mode 100644
index 00000000000..e5ae1c219f9
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00137.svg
@@ -0,0 +1,47 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00140.svg b/assets/original-vector/SVG/exported/bmp00140.svg
new file mode 100644
index 00000000000..ffae76dfebd
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00140.svg
@@ -0,0 +1,16 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00143.svg b/assets/original-vector/SVG/exported/bmp00143.svg
new file mode 100644
index 00000000000..1cca548bae5
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00143.svg
@@ -0,0 +1,14 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00144.svg b/assets/original-vector/SVG/exported/bmp00144.svg
new file mode 100644
index 00000000000..5cce63c5b1d
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00144.svg
@@ -0,0 +1,46 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00145.svg b/assets/original-vector/SVG/exported/bmp00145.svg
new file mode 100644
index 00000000000..87f4422c18a
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00145.svg
@@ -0,0 +1,26 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00146.svg b/assets/original-vector/SVG/exported/bmp00146.svg
new file mode 100644
index 00000000000..a366e1a9d3b
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00146.svg
@@ -0,0 +1,26 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00148.svg b/assets/original-vector/SVG/exported/bmp00148.svg
new file mode 100644
index 00000000000..c06e630531d
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00148.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00149.svg b/assets/original-vector/SVG/exported/bmp00149.svg
new file mode 100644
index 00000000000..d5ab99a4a3c
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00149.svg
@@ -0,0 +1,13 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00151.svg b/assets/original-vector/SVG/exported/bmp00151.svg
new file mode 100644
index 00000000000..a16ed4a686e
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00151.svg
@@ -0,0 +1,185 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00152.svg b/assets/original-vector/SVG/exported/bmp00152.svg
new file mode 100644
index 00000000000..99a6ab879e4
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00152.svg
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00153.svg b/assets/original-vector/SVG/exported/bmp00153.svg
new file mode 100644
index 00000000000..b59583f47f9
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00153.svg
@@ -0,0 +1,47 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00154.svg b/assets/original-vector/SVG/exported/bmp00154.svg
new file mode 100644
index 00000000000..7aa15d402c2
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00154.svg
@@ -0,0 +1,222 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00157.svg b/assets/original-vector/SVG/exported/bmp00157.svg
new file mode 100644
index 00000000000..7572557113e
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00157.svg
@@ -0,0 +1,58 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00158.svg b/assets/original-vector/SVG/exported/bmp00158.svg
new file mode 100644
index 00000000000..324f1811740
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00158.svg
@@ -0,0 +1,26 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00159.svg b/assets/original-vector/SVG/exported/bmp00159.svg
new file mode 100644
index 00000000000..cc8d679f60b
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00159.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00160.svg b/assets/original-vector/SVG/exported/bmp00160.svg
new file mode 100644
index 00000000000..59f773ffe47
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00160.svg
@@ -0,0 +1,50 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00161.svg b/assets/original-vector/SVG/exported/bmp00161.svg
new file mode 100644
index 00000000000..e0163c9d1c7
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00161.svg
@@ -0,0 +1,26 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00162.svg b/assets/original-vector/SVG/exported/bmp00162.svg
new file mode 100644
index 00000000000..431f1a0b501
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00162.svg
@@ -0,0 +1,24 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00163.svg b/assets/original-vector/SVG/exported/bmp00163.svg
new file mode 100644
index 00000000000..de10cb275eb
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00163.svg
@@ -0,0 +1,25 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/bmp00164.svg b/assets/original-vector/SVG/exported/bmp00164.svg
new file mode 100644
index 00000000000..6f143ecc334
--- /dev/null
+++ b/assets/original-vector/SVG/exported/bmp00164.svg
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/assets/original-vector/SVG/exported/test/bmp00102.svg b/assets/original-vector/SVG/exported/test/bmp00102.svg
new file mode 100644
index 00000000000..3ef43dbf419
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00102.svg
@@ -0,0 +1,466 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00108.svg b/assets/original-vector/SVG/exported/test/bmp00108.svg
new file mode 100644
index 00000000000..ef03c74b012
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00108.svg
@@ -0,0 +1,398 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00112.svg b/assets/original-vector/SVG/exported/test/bmp00112.svg
new file mode 100644
index 00000000000..08637a76983
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00112.svg
@@ -0,0 +1,617 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00114.svg b/assets/original-vector/SVG/exported/test/bmp00114.svg
new file mode 100644
index 00000000000..9005bb8b3fb
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00114.svg
@@ -0,0 +1,78 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00118.svg b/assets/original-vector/SVG/exported/test/bmp00118.svg
new file mode 100644
index 00000000000..d27f2460722
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00118.svg
@@ -0,0 +1,169 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00119.svg b/assets/original-vector/SVG/exported/test/bmp00119.svg
new file mode 100644
index 00000000000..6174e90b64f
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00119.svg
@@ -0,0 +1,91 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00120.svg b/assets/original-vector/SVG/exported/test/bmp00120.svg
new file mode 100644
index 00000000000..03bc2c6f137
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00120.svg
@@ -0,0 +1,134 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00121.svg b/assets/original-vector/SVG/exported/test/bmp00121.svg
new file mode 100644
index 00000000000..bf06f19faa7
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00121.svg
@@ -0,0 +1,72 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00122.svg b/assets/original-vector/SVG/exported/test/bmp00122.svg
new file mode 100644
index 00000000000..3f1a3b749e1
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00122.svg
@@ -0,0 +1,47 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00123.svg b/assets/original-vector/SVG/exported/test/bmp00123.svg
new file mode 100644
index 00000000000..7981a07920c
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00123.svg
@@ -0,0 +1,116 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00132.svg b/assets/original-vector/SVG/exported/test/bmp00132.svg
new file mode 100644
index 00000000000..9c39ff100ce
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00132.svg
@@ -0,0 +1,64 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00140.svg b/assets/original-vector/SVG/exported/test/bmp00140.svg
new file mode 100644
index 00000000000..9d08db86a1a
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00140.svg
@@ -0,0 +1,70 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00151.svg b/assets/original-vector/SVG/exported/test/bmp00151.svg
new file mode 100644
index 00000000000..8589dfe87d0
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00151.svg
@@ -0,0 +1,256 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00158.svg b/assets/original-vector/SVG/exported/test/bmp00158.svg
new file mode 100644
index 00000000000..6b435293d10
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00158.svg
@@ -0,0 +1,34 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00160.svg b/assets/original-vector/SVG/exported/test/bmp00160.svg
new file mode 100644
index 00000000000..aacc4d6b02a
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00160.svg
@@ -0,0 +1,76 @@
+
diff --git a/assets/original-vector/SVG/exported/test/bmp00162.svg b/assets/original-vector/SVG/exported/test/bmp00162.svg
new file mode 100644
index 00000000000..3edd3ce03bc
--- /dev/null
+++ b/assets/original-vector/SVG/exported/test/bmp00162.svg
@@ -0,0 +1,36 @@
+
diff --git a/assets/original-vector/SVG/master/Surge_OG.sketch b/assets/original-vector/SVG/master/Surge_OG.sketch
new file mode 100644
index 00000000000..544d288dda0
Binary files /dev/null and b/assets/original-vector/SVG/master/Surge_OG.sketch differ
diff --git a/libs/nanosvg b/libs/nanosvg
new file mode 160000
index 00000000000..c1f6e209c16
--- /dev/null
+++ b/libs/nanosvg
@@ -0,0 +1 @@
+Subproject commit c1f6e209c16b18b46aa9f45d7e619acf42c29726
diff --git a/premake5.lua b/premake5.lua
index 4dffacc212c..b6ddad1d22b 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -154,6 +154,7 @@ end
includedirs {
"libs/xml",
+ "libs/nanosvg/src",
"src/common/vt_dsp",
"src/common/thread",
"vst3sdk/vstgui4",
@@ -375,6 +376,7 @@ function plugincommon()
"src/windows/scalableui.rc",
"resources/bitmaps/*.png",
"assets/original-vector/exported/*.png",
+ "assets/original-vector/SVG/exported/*.svg",
VSTGUI .. "vstgui_win32.cpp",
VSTGUI .. "vstgui_uidescription_win32.cpp",
}
diff --git a/scripts/linux/emit-vector-piggy.py b/scripts/linux/emit-vector-piggy.py
index 5a5e1c620b1..a1a152c5a98 100644
--- a/scripts/linux/emit-vector-piggy.py
+++ b/scripts/linux/emit-vector-piggy.py
@@ -13,7 +13,7 @@
import re
import sys
-assets_path = "assets/original-vector/exported"
+assets_path = "assets/original-vector/SVG/exported"
source_file = open(sys.argv[1] + "/src/linux/ScalablePiggy.S", "w")
source_file.write("""# THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT IT.
@@ -23,8 +23,8 @@
.section ".rodata", "a"
-memoryBitmapListStart:
- .globl memoryBitmapListStart
+memorySVGListStart:
+ .globl memorySVGListStart
""")
@@ -36,28 +36,28 @@
** in scripts/linux/emit-vector-piggy.py
*/
-struct MemoryBitmap {
+struct MemorySVG {
const char *name;
unsigned long size;
unsigned long offset;
};
-extern unsigned char memoryBitmapListStart[];
+extern unsigned char memorySVGListStart[];
-static const struct MemoryBitmap memoryBitmapList[] = {
+static const struct MemorySVG memorySVGList[] = {
""")
offset = 0
for name in os.listdir(sys.argv[1] + "/" + assets_path):
- if not re.match('bmp00(\\d+)(.*).png', name):
+ if not re.match('bmp00(\\d+)(.*).svg', name):
continue
path = os.path.join(assets_path, name)
size = os.stat(sys.argv[1] + "/" + path).st_size;
source_file.write(' .incbin "../../' + path + '"' + os.linesep)
- header_file.write(' {"scalable/' + name + '", ' + str(size) + ', ' +
+ header_file.write(' {"svg/' + name + '", ' + str(size) + ', ' +
str(offset) + '},' + os.linesep)
offset += size
diff --git a/scripts/macOS/package-au.sh b/scripts/macOS/package-au.sh
index 20affeb4f70..2ee825aebac 100755
--- a/scripts/macOS/package-au.sh
+++ b/scripts/macOS/package-au.sh
@@ -8,9 +8,10 @@ fi
# input config
RES_SRC_LOCATION="resources"
PACKAGE_SRC_LOCATION="$RES_SRC_LOCATION/osx-au"
-BITMAP_SRC_LOCATION="$RES_SRC_LOCATION/bitmaps"
+
FONT_SRC_LOCATION="$RES_SRC_LOCATION/fonts"
-VECTOR_BITMAP_SRC_LOCATION="assets/${SURGE_USE_VECTOR_SKIN}/exported"
+SVG_SRC_LOCATION="assets/${SURGE_USE_VECTOR_SKIN}/SVG/exported"
+
BUNDLE_RES_SRC_LOCATION="$RES_SRC_LOCATION/osx-resources"
EXEC_LOCATION="target/au/Release/Surge.dylib"
#EXEC_LOCATION="target/au/Debug/Surge-Debug.dylib"
@@ -40,15 +41,8 @@ cp $PACKAGE_SRC_LOCATION/* "$BUNDLE_DIR/Contents/"
# copy bundle resources
cp -R "$BUNDLE_RES_SRC_LOCATION" "$BUNDLE_DIR/Contents/Resources"
-if [[ -z "$SURGE_USE_VECTOR_SKIN" ]]; then
- cp $BITMAP_SRC_LOCATION/* "$BUNDLE_DIR/Contents/Resources/"
-else
- rm "$BUNDLE_DIR/Contents/Resources/bmp*.png"
- cp $VECTOR_BITMAP_SRC_LOCATION/bmp?????.png "$BUNDLE_DIR/Contents/Resources/"
- mkdir "$BUNDLE_DIR/Contents/Resources/scalable"
- cp $VECTOR_BITMAP_SRC_LOCATION/*png "$BUNDLE_DIR/Contents/Resources/scalable"
-fi
-
+mkdir "$BUNDLE_DIR/Contents/Resources/svg"
+cp $SVG_SRC_LOCATION/*svg "$BUNDLE_DIR/Contents/Resources/svg"
mkdir "$BUNDLE_DIR/Contents/Resources/fonts";
cp $FONT_SRC_LOCATION/* "$BUNDLE_DIR/Contents/Resources/fonts";
diff --git a/scripts/macOS/package-vst.sh b/scripts/macOS/package-vst.sh
index 4494f2d0176..d40c0e130b8 100755
--- a/scripts/macOS/package-vst.sh
+++ b/scripts/macOS/package-vst.sh
@@ -8,9 +8,10 @@ fi
# input config
RES_SRC_LOCATION="resources"
PACKAGE_SRC_LOCATION="$RES_SRC_LOCATION/osx-vst2"
-BITMAP_SRC_LOCATION="$RES_SRC_LOCATION/bitmaps"
-VECTOR_BITMAP_SRC_LOCATION="assets/${SURGE_USE_VECTOR_SKIN}/exported"
+
+SVG_SRC_LOCATION="assets/${SURGE_USE_VECTOR_SKIN}/SVG/exported"
FONT_SRC_LOCATION="$RES_SRC_LOCATION/fonts"
+
BUNDLE_RES_SRC_LOCATION="$RES_SRC_LOCATION/osx-resources"
EXEC_LOCATION="target/vst2/Release/Surge.dylib"
#EXEC_LOCATION="target/vst2/Debug/Surge-Debug.dylib"
@@ -40,14 +41,8 @@ cp $PACKAGE_SRC_LOCATION/* "$BUNDLE_DIR/Contents/"
# copy bundle resources
cp -R "$BUNDLE_RES_SRC_LOCATION" "$BUNDLE_DIR/Contents/Resources"
-if [[ -z "$SURGE_USE_VECTOR_SKIN" ]]; then
- cp $BITMAP_SRC_LOCATION/* "$BUNDLE_DIR/Contents/Resources/"
-else
- rm "$BUNDLE_DIR/Contents/Resources/bmp*.png"
- cp $VECTOR_BITMAP_SRC_LOCATION/bmp?????.png "$BUNDLE_DIR/Contents/Resources/"
- mkdir "$BUNDLE_DIR/Contents/Resources/scalable"
- cp $VECTOR_BITMAP_SRC_LOCATION/*png "$BUNDLE_DIR/Contents/Resources/scalable"
-fi
+mkdir "$BUNDLE_DIR/Contents/Resources/svg"
+cp $SVG_SRC_LOCATION/*svg "$BUNDLE_DIR/Contents/Resources/svg"
mkdir "$BUNDLE_DIR/Contents/Resources/fonts";
cp $FONT_SRC_LOCATION/* "$BUNDLE_DIR/Contents/Resources/fonts";
diff --git a/scripts/macOS/package-vst3.sh b/scripts/macOS/package-vst3.sh
index 1f0572389f1..8992af9a801 100755
--- a/scripts/macOS/package-vst3.sh
+++ b/scripts/macOS/package-vst3.sh
@@ -8,9 +8,10 @@ fi
# input config
RES_SRC_LOCATION="resources"
PACKAGE_SRC_LOCATION="$RES_SRC_LOCATION/osx-vst3"
-BITMAP_SRC_LOCATION="$RES_SRC_LOCATION/bitmaps"
+
FONT_SRC_LOCATION="$RES_SRC_LOCATION/fonts"
-VECTOR_BITMAP_SRC_LOCATION="assets/${SURGE_USE_VECTOR_SKIN}/exported"
+SVG_SRC_LOCATION="assets/${SURGE_USE_VECTOR_SKIN}/SVG/exported"
+
BUNDLE_RES_SRC_LOCATION="$RES_SRC_LOCATION/osx-resources"
EXEC_LOCATION="target/vst3/Release/Surge.dylib"
#EXEC_LOCATION="target/vst3/Debug/Surge-Debug.dylib"
@@ -40,14 +41,8 @@ cp $PACKAGE_SRC_LOCATION/* "$BUNDLE_DIR/Contents/"
# copy bundle resources
cp -R "$BUNDLE_RES_SRC_LOCATION" "$BUNDLE_DIR/Contents/Resources"
-if [[ -z "$SURGE_USE_VECTOR_SKIN" ]]; then
- cp $BITMAP_SRC_LOCATION/* "$BUNDLE_DIR/Contents/Resources/"
-else
- rm "$BUNDLE_DIR/Contents/Resources/bmp*.png"
- cp $VECTOR_BITMAP_SRC_LOCATION/bmp?????.png "$BUNDLE_DIR/Contents/Resources/"
- mkdir "$BUNDLE_DIR/Contents/Resources/scalable"
- cp $VECTOR_BITMAP_SRC_LOCATION/*png "$BUNDLE_DIR/Contents/Resources/scalable"
-fi
+mkdir "$BUNDLE_DIR/Contents/Resources/svg"
+cp $SVG_SRC_LOCATION/*svg "$BUNDLE_DIR/Contents/Resources/svg"
mkdir "$BUNDLE_DIR/Contents/Resources/fonts";
cp $FONT_SRC_LOCATION/* "$BUNDLE_DIR/Contents/Resources/fonts";
diff --git a/scripts/win/emit-vector-rc.py b/scripts/win/emit-vector-rc.py
index 1c2d4996f6c..2bdfeb8e933 100644
--- a/scripts/win/emit-vector-rc.py
+++ b/scripts/win/emit-vector-rc.py
@@ -42,13 +42,14 @@
import os, re
assetdir = "assets/original-vector/exported"
+svgassetdir = "assets/original-vector/SVG/exported"
IDBs=[]
digitToIDB = {}
IDBtoDigit = {}
scaleToOffset = {}
-scales = [ "100", "125", "150", "200", "300", "400" ]
+scales = [ "100", "125", "150", "200", "300", "400", "SVG" ]
xtnToPostfix = { "": "_SCALE_100",
"@125x": "_SCALE_125",
"@15x": "_SCALE_150",
@@ -57,7 +58,6 @@
"@4x": "_SCALE_400" }
-
with open( "src\\common\\resource.h", "r" ) as r:
for line in r:
matches = re.match( '#define (IDB\\S+) (\\d+)', line )
@@ -65,7 +65,7 @@
IDBs.append( matches.group(1) )
digitToIDB[ matches.group( 2 ) ] = matches.group( 1 )
IDBtoDigit[ matches.group( 1 ) ] = int( matches.group( 2 ) )
- matchscale = re.match( '#define SCALABLE_(\\d+)_OFFSET\\s+(\\d+)', line )
+ matchscale = re.match( '#define SCALABLE_(\\S+)_OFFSET\\s+(\\d+)', line )
if( matchscale ):
scaleToOffset[ matchscale.group( 1 ) ] = int( matchscale.group( 2 ) )
@@ -131,4 +131,32 @@
subrc.write( base + ofst + " PNG \"" + assetdir + "/" + file + "\"\n" )
+# Create the SVG rc file
+subrc = open( "src\\windows\\svgresources.rc", "w" );
+subrc.write( """
+/*
+** THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT IT
+**
+** If you need to modify this file, please read the comment
+** in scripts/win/emit-vector-rc.py
+**
+** This file imports the appropriate scaled SVG files
+** for each of the identifiers in scalableresource.h.
+**
+** You can address these items as IDB_BG_SCALE_SVG or
+** IDB_BG + SCALE_OFFSET_SVG in your non-rc code.
+*/
+
+""")
+
+lastBase = ""
+for file in os.listdir( svgassetdir ):
+ if file.endswith(".svg"):
+ fn = os.path.join(svgassetdir, file )
+ matches = re.match( 'bmp00(.*).svg', file );
+ if( matches ):
+ base = digitToIDB[matches.group(1)]
+ subrc.write( base + "_SCALE_SVG DATA \"" + svgassetdir + "/" + file + "\"\n" )
+
+
diff --git a/src/common/gui/CEffectSettings.cpp b/src/common/gui/CEffectSettings.cpp
index bcd319fa953..57a1e387698 100644
--- a/src/common/gui/CEffectSettings.cpp
+++ b/src/common/gui/CEffectSettings.cpp
@@ -42,12 +42,13 @@ int get_fxtype(int id)
CEffectSettings::CEffectSettings(const CRect& size,
IControlListener* listener,
long tag,
- int current)
+ int current,
+ std::shared_ptr bitmapStore)
: CControl(size, listener, tag, 0)
{
this->current = current;
- bg = getSurgeBitmap(IDB_FXCONF);
- labels = getSurgeBitmap(IDB_FXCONF_SYMBOLS);
+ bg = bitmapStore->getBitmap(IDB_FXCONF);
+ labels = bitmapStore->getBitmap(IDB_FXCONF_SYMBOLS);
disabled = 0;
}
diff --git a/src/common/gui/CEffectSettings.h b/src/common/gui/CEffectSettings.h
index 4045a90c151..64318b508b5 100644
--- a/src/common/gui/CEffectSettings.h
+++ b/src/common/gui/CEffectSettings.h
@@ -3,11 +3,16 @@
//-------------------------------------------------------------------------------------------------------
#pragma once
#include "vstcontrols.h"
+#include "SurgeBitmaps.h"
class CEffectSettings : public VSTGUI::CControl
{
public:
- CEffectSettings(const VSTGUI::CRect& size, VSTGUI::IControlListener* listener, long tag, int current);
+ CEffectSettings(const VSTGUI::CRect& size,
+ VSTGUI::IControlListener* listener,
+ long tag,
+ int current,
+ std::shared_ptr bitmapStore);
virtual void draw(VSTGUI::CDrawContext* dc);
virtual VSTGUI::CMouseEventResult
onMouseDown(VSTGUI::CPoint& where,
@@ -47,4 +52,4 @@ class CEffectSettings : public VSTGUI::CControl
}
CLASS_METHODS(CEffectSettings, VSTGUI::CControl)
-};
\ No newline at end of file
+};
diff --git a/src/common/gui/CModulationSourceButton.cpp b/src/common/gui/CModulationSourceButton.cpp
index 391f91fcbd3..dc06c02bca1 100644
--- a/src/common/gui/CModulationSourceButton.cpp
+++ b/src/common/gui/CModulationSourceButton.cpp
@@ -19,8 +19,12 @@ enum
//------------------------------------------------------------------------------------------------
-CModulationSourceButton::CModulationSourceButton(
- const CRect& size, IControlListener* listener, long tag, int state, int msid)
+CModulationSourceButton::CModulationSourceButton(const CRect& size,
+ IControlListener* listener,
+ long tag,
+ int state,
+ int msid,
+ std::shared_ptr bitmapStore)
: CCursorHidingControl(size, listener, tag, 0), OldValue(0.f)
{
this->state = state;
@@ -34,6 +38,7 @@ CModulationSourceButton::CModulationSourceButton(
controlstate = cs_none;
label[0] = 0;
blink = 0;
+ bmp = bitmapStore->getBitmap(IDB_MODSRC_BG);
}
//------------------------------------------------------------------------------------------------
@@ -223,7 +228,7 @@ void CModulationSourceButton::draw(CDrawContext* dc)
where.y = 8 * rh;
else
where.y = 7 * rh;
- getSurgeBitmap(IDB_MODSRC_BG)->draw(dc, sze, where, 0xff);
+ bmp->draw(dc, sze, where, 0xff);
}
setDirty(false);
diff --git a/src/common/gui/CModulationSourceButton.h b/src/common/gui/CModulationSourceButton.h
index f0fb727a0f8..16bc6bcd038 100644
--- a/src/common/gui/CModulationSourceButton.h
+++ b/src/common/gui/CModulationSourceButton.h
@@ -3,6 +3,7 @@
//-------------------------------------------------------------------------------------------------------
#pragma once
#include "vstcontrols.h"
+#include "SurgeBitmaps.h"
class CModulationSourceButton : public CCursorHidingControl
{
@@ -10,8 +11,12 @@ class CModulationSourceButton : public CCursorHidingControl
typedef CCursorHidingControl super;
public:
- CModulationSourceButton(
- const VSTGUI::CRect& size, VSTGUI::IControlListener* listener, long tag, int state, int msid);
+ CModulationSourceButton(const VSTGUI::CRect& size,
+ VSTGUI::IControlListener* listener,
+ long tag,
+ int state,
+ int msid,
+ std::shared_ptr bitmapStore);
~CModulationSourceButton();
virtual void setValue(float val)
@@ -35,6 +40,8 @@ class CModulationSourceButton : public CCursorHidingControl
VSTGUI::CPoint SourcePoint;
float OldValue;
+ VSTGUI::CBitmap* bmp = nullptr;
+
void setblink(bool state);
void setlabel(const char*);
void set_ismeta(bool);
diff --git a/src/common/gui/CParameterTooltip.h b/src/common/gui/CParameterTooltip.h
index f9d3062c6a2..80992c697ed 100644
--- a/src/common/gui/CParameterTooltip.h
+++ b/src/common/gui/CParameterTooltip.h
@@ -32,13 +32,13 @@ class CParameterTooltip : public VSTGUI::CControl
{
visible = true;
invalid();
- // setDirty();
+ setDirty(true);
}
void Hide()
{
visible = false;
invalid();
- // setDirty();
+ setDirty(true);
}
bool isNewTag(long tag)
{
@@ -72,6 +72,7 @@ class CParameterTooltip : public VSTGUI::CControl
smaller.x += shrink;*/
auto size = getViewSize();
+ size = size.inset(0.75, 0.75);
dc->setFrameColor(VSTGUI::kBlackCColor);
dc->drawRect(size);
VSTGUI::CRect sizem1(size);
diff --git a/src/common/gui/CScalableBitmap.cpp b/src/common/gui/CScalableBitmap.cpp
index e817a46c5f6..f604393c57b 100644
--- a/src/common/gui/CScalableBitmap.cpp
+++ b/src/common/gui/CScalableBitmap.cpp
@@ -6,113 +6,145 @@
#include
#if MAC
#include
+#include "vstgui/lib/platform/mac/macglobals.h"
#endif
#if LINUX
#include "ScalablePiggy.h"
#endif
+#if WINDOWS
+#include "vstgui/lib/platform/iplatformresourceinputstream.h"
+#endif
#include "resource.h"
+#include
+#include
+#include
+/*
+** CScalableBitmap is the only file which uses the SVG Implementatoin so it is also the one
+** and only one which ejexts the link symbols.
+*/
+#define NANOSVG_IMPLEMENTATION
+#include "nanosvg.h"
+
using namespace VSTGUI;
+#if MAC
+static const std::string svgFullFileNameFromBundle(const std::string& filename)
+{
+ CFStringRef cfStr = CFStringCreateWithCString(nullptr, filename.c_str(), kCFStringEncodingUTF8);
+ CFURLRef url = CFBundleCopyResourceURL(VSTGUI::getBundleRef(), cfStr, nullptr, nullptr);
+ CFRelease(cfStr);
+ if (url)
+ {
+ CFStringRef urlStr = CFURLGetString(url);
+ // std::cout << "URLString = " << urlStr << std::flush << std::endl;
+ const char* csp = CFStringGetCStringPtr(urlStr, kCFStringEncodingUTF8);
+ if (csp)
+ {
+ std::string resPath(CFStringGetCStringPtr(CFURLGetString(url), kCFStringEncodingUTF8));
+ if (resPath.find("file://") != std::string::npos)
+ resPath = resPath.substr(7);
+ return resPath;
+ }
+ }
+
+ return "";
+}
+#endif
+
#if LINUX
-static const struct MemoryBitmap *findMemoryBitmap(const std::string& filename)
+static const struct MemorySVG* findMemorySVG(const std::string& filename)
{
- for (const struct MemoryBitmap *bmp = &memoryBitmapList[0];
- bmp->name != NULL; bmp++)
- if (!std::strncmp(filename.c_str(), bmp->name, std::strlen(bmp->name)))
- return bmp;
+ for (const struct MemorySVG* svg = &memorySVGList[0]; svg->name != NULL; svg++)
+ if (!std::strncmp(filename.c_str(), svg->name, std::strlen(svg->name)))
+ return svg;
- throw Surge::Error(filename + " not found");
+ throw Surge::Error(filename + " not found");
+}
+#endif
+
+#if WINDOWS
+static int svgContentsFromRCFile(int id, char* svgData, int maxSz)
+{
+ VSTGUI::IPlatformResourceInputStream::Ptr istr =
+ VSTGUI::IPlatformResourceInputStream::create(CResourceDescription(id));
+
+ if (istr == NULL)
+ {
+ return -1;
+ }
+ memset(svgData, 0, maxSz);
+ uint32_t readSize = istr->readRaw(svgData, maxSz);
+ svgData[readSize] = 0;
+ return readSize;
}
#endif
// Remember this is user zoom * display zoom. See comment in CScalableBitmap.h
-int CScalableBitmap::currentPhysicalZoomFactor = 100;
void CScalableBitmap::setPhysicalZoomFactor(int zoomFactor)
{
currentPhysicalZoomFactor = zoomFactor;
}
-CScalableBitmap::CScalableBitmap(CResourceDescription desc)
- : CBitmap(desc)
+CScalableBitmap::CScalableBitmap(CResourceDescription desc, VSTGUI::CFrame* f)
+ : CBitmap(desc), svgImage(nullptr), frame(f)
{
int id = 0;
if(desc.type == CResourceDescription::kIntegerType)
id = (int32_t)desc.u.id;
- /*
- ** Scales are the percentage scale in units of percents. So 100 is 1x.
- ** This integerification allows us to hash on the scale values and still support
- ** things like a 1.25 bitmap set.
- */
-
- scales = {{ 100, /* 125, */ 150, 200, 300, 400 }}; // This is the collection of sizes we currently ask skins to export.
+ resourceID = id;
- std::map< int, std::string > scaleFilePostfixes;
- scaleFilePostfixes[ 100 ] = "";
- // scaleFilePostfixes[ 125 ] = "@125x";
- scaleFilePostfixes[ 150 ] = "@15x";
- scaleFilePostfixes[ 200 ] = "@2x";
- scaleFilePostfixes[ 300 ] = "@3x";
- scaleFilePostfixes[ 400 ] = "@4x";
+ std::stringstream filename;
+ filename << "svg/bmp" << std::setw(5) << std::setfill('0') << id << ".svg";
-#if WINDOWS
- // Only windows uses this integer indexing and knows these offsets
- std::map< int, int > scaleIDOffsets;
- scaleIDOffsets[ 100 ] = SCALABLE_100_OFFSET;
- // scaleIDOffsets[ 125 ] = SCALABLE_125_OFFSET;
- scaleIDOffsets[ 150 ] = SCALABLE_150_OFFSET;
- scaleIDOffsets[ 200 ] = SCALABLE_200_OFFSET;
- scaleIDOffsets[ 300 ] = SCALABLE_300_OFFSET;
- scaleIDOffsets[ 400 ] = SCALABLE_400_OFFSET;
+#if MAC
+ std::string fullFileName = svgFullFileNameFromBundle(filename.str());
+ svgImage = nsvgParseFromFile(fullFileName.c_str(), "px", 96);
#endif
-
- for(auto sc : scales)
- {
- CBitmap *scBmp = NULL;
-#if MAC || LINUX
- std::stringstream filename;
- auto postfix = scaleFilePostfixes[sc];
- filename << "scalable/bmp" << std::setw(5) << std::setfill('0') << id
- << scaleFilePostfixes[sc] << ".png";
-#endif
+#if WINDOWS
+ int svgid = id + SCALABLE_SVG_OFFSET;
+ char* svgData = new char[1024 * 1024];
- /*
- ** Macintosh addresses resources by path name; Windows addresses them by
- ** .rc file ID This fundamental difference means we need to create
- ** distinct names for our bitmaps.
- **
- ** The mapping of filename to id + offset on windows is automatically
- ** generated by the script scripts/win/emit-vector-rc.py.
- */
+ if (svgContentsFromRCFile(svgid, svgData, 1024 * 1024) > 0)
+ svgImage = nsvgParse(svgData, "px", 96);
+ else
+ svgImage = NULL;
-#if MAC
- scBmp = new CBitmap(CResourceDescription(filename.str().c_str()));
-#elif LINUX
- try {
- const MemoryBitmap *memBmp = findMemoryBitmap(filename.str());
- auto platBmp = IPlatformBitmap::createFromMemory(
- memoryBitmapListStart + memBmp->offset, memBmp->size);
- scBmp = new CBitmap(platBmp);
- } catch (Surge::Error err) {
- std::cerr << err.getMessage() << std::endl;
- }
-#elif WINDOWS
- scBmp = new CBitmap(CResourceDescription(id + scaleIDOffsets[sc]));
+ delete[] svgData;
+#endif
+
+#if LINUX
+ try
+ {
+ const MemorySVG* memSVG = findMemorySVG(filename.str());
+ char* svg = new char[memSVG->size + 1];
+ svg[memSVG->size] = '\0';
+ strncpy(svg, (const char*)(memorySVGListStart + memSVG->offset), memSVG->size);
+ svgImage = nsvgParse(svg, "px", 96);
+ delete svg;
+ }
+ catch (Surge::Error err)
+ {
+ std::cerr << err.getMessage() << std::endl;
+ }
#endif
- if(scBmp && scBmp->getWidth() > 0)
- scaledBitmaps[sc] = scBmp;
- else
- scaledBitmaps[sc] = NULL;
+ if (!svgImage)
+ {
+ std::cout << "Unable to load SVG Image " << filename.str() << std::endl;
}
- lastSeenZoom = -1; // we haven't seen a zoom yet!
extraScaleFactor = 100;
+ currentPhysicalZoomFactor = 100;
}
+#define DUMPR(r) \
+ "(x=" << r.getTopLeft().x << ",y=" << r.getTopLeft().y << ")+(w=" << r.getWidth() \
+ << ",h=" << r.getHeight() << ")"
+
void CScalableBitmap::draw (CDrawContext* context, const CRect& rect, const CPoint& offset, float alpha )
{
/*
@@ -146,80 +178,256 @@ void CScalableBitmap::draw (CDrawContext* context, const CRect& rect, const CPoi
return;
}
- if (lastSeenZoom != currentPhysicalZoomFactor)
+ if (svgImage)
{
- int ns = -1;
- for (auto s : scales)
- {
- if (s >= currentPhysicalZoomFactor && ns < 0)
- ns = s;
- }
- if (ns<0)
- {
- ns = scales.back();
- }
- bestFitScaleGroup = ns;
- lastSeenZoom = currentPhysicalZoomFactor;
- }
+ /*
+ ** Plan of attack here is to use coffscreencontext into a physicalzoomfactor scaled version
+ *of rect
+ ** see vstgui.surge/vstgui/lib/coffscreencontext.h for how that works. So we just need a good
+ *hash
+ ** on rect.size, off and physical zoom.
+ */
+ if (lastSeenZoom != currentPhysicalZoomFactor)
+ {
+ for (auto const& pair : offscreenCache)
+ {
+ auto val = pair.second;
+ if (val)
+ val->forget();
+ }
+ offscreenCache.clear();
+ lastSeenZoom = currentPhysicalZoomFactor;
+ }
+
+ CGraphicsTransform tf =
+ CGraphicsTransform().scale(lastSeenZoom / 100.0, lastSeenZoom / 100.0);
+ /*
+ ** VSTGUI has this wierdo bug where it shrinks backgrounds properly but doesn't grow them. Sigh.
+ ** So asymmetrically treat the extra factor here and only here.
+ */
+ int exs = (extraScaleFactor<100?100:extraScaleFactor);
+ CGraphicsTransform xtf =
+ CGraphicsTransform().scale(exs / 100.0, exs / 100.0);
+ CGraphicsTransform itf = tf.inverse();
+ CGraphicsTransform ixtf = xtf.inverse();
+
+ if (offscreenCache.find(offset) == offscreenCache.end())
+ {
+ VSTGUI::CPoint sz = rect.getSize();
+ ixtf.transform(sz);
+
+ VSTGUI::CPoint offScreenSz = sz;
+ tf.transform(offScreenSz);
+
+ if (auto offscreen = COffscreenContext::create(frame, offScreenSz.x, offScreenSz.y))
+ {
+ offscreen->beginDraw();
+ VSTGUI::CRect newRect(0, 0, rect.getWidth(), rect.getHeight());
+
+ CDrawContext::Transform trsf(*offscreen, tf);
+ CDrawContext::Transform xtrsf(*offscreen, ixtf);
+
+ drawSVG(offscreen, newRect, offset, alpha);
+
+ offscreen->endDraw();
+ CBitmap* tmp = offscreen->getBitmap();
+ if (tmp)
+ {
+ offscreenCache[offset] = tmp;
+ tmp->remember();
+ }
+ }
+ }
+
+ if (offscreenCache.find(offset) != offscreenCache.end())
+ {
+ context->saveGlobalState();
+
+ CDrawContext::Transform trsf(*context, itf);
+ CDrawContext::Transform trsf2(*context, xtf);
+
+ VSTGUI::CRect drect = rect;
+ tf.transform(drect);
+
+ VSTGUI::CRect origClip;
+ context->getClipRect(origClip);
+
+ VSTGUI::CRect clipR = origClip;
+
+ /*
+ ** The clipR goes up to and including the edge of the size; but at very high zooms that
+ *shows a
+ ** tiny bit of the adjacent image. So make the edge of our clip just inside the size.
+ ** This only matters at high zoom levels
+ */
+ clipR.bottom -= 0.01;
+ clipR.right -= 0.01;
+ context->setClipRect(clipR);
- // Check if my bitmaps are there and if so use them
- if (scaledBitmaps[ bestFitScaleGroup ] != NULL)
- {
- // Seems like you would do this backwards; but the TF shrinks and the invtf regrows for positioning
- // but it is easier to calculate the grow one since it is at our scale
- CGraphicsTransform invtf = CGraphicsTransform().scale( bestFitScaleGroup / 100.0, bestFitScaleGroup / 100.0 );
- CGraphicsTransform tf = invtf.inverse().scale(extraScaleFactor / 100.0, extraScaleFactor / 100.0);
-
-
- CDrawContext::Transform tr(*context, tf);
-
- // Have to de-const these to do the transform alas
- CRect ncrect = rect;
- CRect nr = invtf.transform(ncrect);
- if(extraScaleFactor<100)
- {
- /*
- ** VSTGUI has lots of bugs. One of them is with scaling backgrounds. It never grows a background.
- ** and it never shrinks a background. Hence the extraScaleFactor. But it does shrink (and only shrink)
- ** the draw rectangle for the background. So when we are at scales < 1 we have over-shrunk the
- ** extra scale factor. So undo that here. Obviously not great.
- */
- CGraphicsTransform upExtra = CGraphicsTransform().scale( 100.0/extraScaleFactor,100.0/extraScaleFactor);
- nr = upExtra.transform(nr);
- }
-
-
- CPoint ncoff = offset;
- CPoint no = invtf.transform(ncoff);
-
#if LINUX
- /*
- ** There's a bug in VSTGUI where images drawn with an alpha other than 1.0
- ** clip other images. The original fix - turn all 255 into 1.0 - is how we got
- ** linux working but in modulation mode Surge draws some elements - slider backgrounds
- ** especialy - with alpha 0x7f.
- **
- ** The correct fix is to figure out what's wrong with cairo_paint_with_alpha inside
- ** the alpha != 1.f at line 407 of vstgui.surge/vstgui/lib/platform/linux/cairocontext.cpp
- ** but an expedient approach is to just disable transparency on bitmaps on linux
- ** for now so at least elements don't dissapear.
- */
- alpha = 1.0f;
+ alpha = 1.0;
#endif
+ offscreenCache[offset]->draw(context, drect, CPoint(0, 0), alpha);
+ context->setClipRect(origClip);
- scaledBitmaps[ bestFitScaleGroup ]->draw(context, nr, no, alpha);
- }
- else
- {
- /*
- ** We have not found an asset at this scale, so we will draw the base class
- ** asset (which as configured is the original set of PNGs). There are a few
- ** cases mostly involving zoom before vector asset implementation in vst2
- ** where you are in this situation but still need to apply an additional
- ** zoom to handle background scaling
- */
- CGraphicsTransform tf = CGraphicsTransform().scale(extraScaleFactor / 100.0, extraScaleFactor / 100.0);
- CDrawContext::Transform tr(*context, tf);
- CBitmap::draw(context, rect, offset, alpha);
+ context->restoreGlobalState();
+ return;
+ }
}
+
+ /* SVG File is missing */
+ context->setFillColor(VSTGUI::kBlueCColor);
+ context->drawRect(rect, VSTGUI::kDrawFilled);
+ context->setFrameColor(VSTGUI::kRedCColor);
+ context->drawRect(rect, VSTGUI::kDrawStroked);
+ return;
+}
+
+void CScalableBitmap::drawSVG(CDrawContext* dc,
+ const CRect& rect,
+ const CPoint& offset,
+ float alpha)
+{
+ VSTGUI::CRect viewS = rect;
+
+ VSTGUI::CDrawMode origMode = dc->getDrawMode();
+ VSTGUI::CDrawMode newMode(VSTGUI::kAntiAliasing);
+ dc->setDrawMode(newMode);
+
+ VSTGUI::CRect origClip;
+ dc->getClipRect(origClip);
+ VSTGUI::CRect clipR = viewS;
+ /*
+ ** The clipR goes up to and including the edge of the size; but at very high zooms that shows a
+ ** tiny bit of the adjacent image. So make the edge of our clip just inside the size.
+ ** This only matters at high zoom levels
+ */
+ clipR.bottom -= 0.01;
+ clipR.right -= 0.01;
+ dc->setClipRect(clipR);
+
+ /*
+ ** Our overall transform moves us to the x/y position of our view rects top left point and shifts
+ *us by
+ ** our offset. Don't forgert the extra zoom also!
+ */
+
+ VSTGUI::CGraphicsTransform tf =
+ VSTGUI::CGraphicsTransform()
+ .translate(viewS.getTopLeft().x - offset.x, viewS.getTopLeft().y - offset.y)
+ .scale(extraScaleFactor / 100.0, extraScaleFactor / 100.0);
+ VSTGUI::CDrawContext::Transform t(*dc, tf);
+
+ for (auto shape = svgImage->shapes; shape != NULL; shape = shape->next)
+ {
+ if (!(shape->flags & NSVG_FLAGS_VISIBLE))
+ continue;
+
+ /*
+ ** We don't need to even bother drawing shapes outside of clip
+ */
+ CRect shapeBounds(shape->bounds[0], shape->bounds[1], shape->bounds[2], shape->bounds[3]);
+ tf.transform(shapeBounds);
+ if (!shapeBounds.rectOverlap(clipR))
+ continue;
+
+ /*
+ ** Build a path for this shape out of each subordinate path as a
+ ** graphics subpath
+ */
+ VSTGUI::CGraphicsPath* gp = dc->createGraphicsPath();
+ for (auto path = shape->paths; path != NULL; path = path->next)
+ {
+ for (auto i = 0; i < path->npts - 1; i += 3)
+ {
+ float* p = &path->pts[i * 2];
+
+ if (i == 0)
+ gp->beginSubpath(p[0], p[1]);
+ gp->addBezierCurve(p[2], p[3], p[4], p[5], p[6], p[7]);
+ }
+ if (path->closed)
+ gp->closeSubpath();
+ }
+
+ /*
+ ** Fill with constant or gradient
+ */
+ if (shape->fill.type != NSVG_PAINT_NONE)
+ {
+ if (shape->fill.type == NSVG_PAINT_COLOR)
+ {
+ dc->setFillColor(svgColorToCColor(shape->fill.color, shape->opacity));
+
+ VSTGUI::CDrawContext::PathDrawMode pdm = VSTGUI::CDrawContext::kPathFilled;
+ if (shape->fillRule == NSVGfillRule::NSVG_FILLRULE_EVENODD)
+ {
+ pdm = VSTGUI::CDrawContext::kPathFilledEvenOdd;
+ }
+ dc->drawGraphicsPath(gp, pdm);
+ }
+ else if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT)
+ {
+ bool evenOdd = (shape->fillRule == NSVGfillRule::NSVG_FILLRULE_EVENODD);
+ NSVGgradient* ngrad = shape->fill.gradient;
+
+ float* x = ngrad->xform;
+ VSTGUI::CGraphicsTransform gradXform(x[0], x[1], x[2], x[3], x[4], x[5]);
+ VSTGUI::CGradient::ColorStopMap csm;
+ VSTGUI::CGradient* cg = VSTGUI::CGradient::create(csm);
+
+ for (int i = 0; i < ngrad->nstops; ++i)
+ {
+ auto stop = ngrad->stops[i];
+ cg->addColorStop(stop.offset, svgColorToCColor(stop.color));
+ }
+ VSTGUI::CPoint s0(0, 0), s1(0, 1);
+ VSTGUI::CPoint p0 = gradXform.inverse().transform(s0);
+ VSTGUI::CPoint p1 = gradXform.inverse().transform(s1);
+
+ dc->fillLinearGradient(gp, *cg, p0, p1, evenOdd);
+ }
+ else
+ {
+ std::cerr << "No radial gradient support yet" << std::endl;
+ dc->setFillColor(VSTGUI::kRedCColor);
+ dc->drawGraphicsPath(gp, VSTGUI::CDrawContext::kPathFilled);
+ }
+ }
+
+ /*
+ ** And then the stroke
+ */
+ if (shape->stroke.type != NSVG_PAINT_NONE)
+ {
+ if (shape->stroke.type == NSVG_PAINT_COLOR)
+ {
+ dc->setFrameColor(svgColorToCColor(shape->stroke.color));
+ }
+ else
+ {
+ std::cerr << "No gradient support yet for stroke" << std::endl;
+ dc->setFrameColor(VSTGUI::kRedCColor);
+ }
+
+ dc->setLineWidth(shape->strokeWidth);
+ VSTGUI::CLineStyle cs((VSTGUI::CLineStyle::LineCap)(shape->strokeLineCap),
+ (VSTGUI::CLineStyle::LineJoin)(shape->strokeLineJoin));
+ dc->setLineStyle(cs);
+ dc->drawGraphicsPath(gp, VSTGUI::CDrawContext::kPathStroked);
+ }
+ gp->forget();
+ }
+
+ dc->resetClipRect();
+ dc->setDrawMode(origMode);
+}
+
+VSTGUI::CColor CScalableBitmap::svgColorToCColor(int svgColor, float opacity)
+{
+ int a = ((svgColor & 0xFF000000) >> 24) * opacity;
+ int b = (svgColor & 0x00FF0000) >> 16;
+ int g = (svgColor & 0x0000FF00) >> 8;
+ int r = (svgColor & 0x000000FF);
+ return VSTGUI::CColor(r, g, b, a);
}
diff --git a/src/common/gui/CScalableBitmap.h b/src/common/gui/CScalableBitmap.h
index 9a2097909b5..f9d4d11e1f3 100644
--- a/src/common/gui/CScalableBitmap.h
+++ b/src/common/gui/CScalableBitmap.h
@@ -1,3 +1,5 @@
+#pragma once
+
/*
** CScalableBitmap is an implmentation of VSGTUI::CBitmap which can
** load bitmaps at multiple resolutions and draw them scaled accordingly
@@ -8,39 +10,68 @@
#include
#include