aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-12 02:22:02 +0000
committerDavid Robillard <d@drobilla.net>2008-08-12 02:22:02 +0000
commit2f7d4f902639750d8c0ca49bb15ed11a3d5cadd9 (patch)
treefefaf7756ef4a2008208eb810fe946da3a229fb7
parent91402dee76921409319de689c471e49afce8a490 (diff)
downloadmda.lv2-2f7d4f902639750d8c0ca49bb15ed11a3d5cadd9.tar.gz
mda.lv2-2f7d4f902639750d8c0ca49bb15ed11a3d5cadd9.tar.bz2
mda.lv2-2f7d4f902639750d8c0ca49bb15ed11a3d5cadd9.zip
Move CBitmap interface closer to motif port for easier porting.
git-svn-id: http://svn.drobilla.net/lad/mda-lv2@1342 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--Makefile2
-rw-r--r--lvz/AEffEditor.hpp2
-rw-r--r--lvz/audioeffectx.h5
-rw-r--r--lvz/gui_wrapper.cpp21
-rw-r--r--src/mdaSpecMeterGUI.cpp13
-rw-r--r--src/mdaSpecMeterGUI.h2
-rw-r--r--vstgui/vstgui.cpp50
-rw-r--r--vstgui/vstgui.h23
8 files changed, 60 insertions, 58 deletions
diff --git a/Makefile b/Makefile
index 1627fd2..5a49bf7 100644
--- a/Makefile
+++ b/Makefile
@@ -81,8 +81,8 @@ install:
else \
install -d $(INSTALL_DIR)/mda.lv2; \
install -m 644 ./mda.lv2/*.ttl $(INSTALL_DIR)/mda.lv2; \
+ install -m 644 ./mda.lv2/*.png $(INSTALL_DIR)/mda.lv2; \
install -m 755 ./mda.lv2/*.so $(INSTALL_DIR)/mda.lv2; \
- install -m 755 ./mda.lv2/*.png $(INSTALL_DIR)/mda.lv2; \
fi
install-user:
diff --git a/lvz/AEffEditor.hpp b/lvz/AEffEditor.hpp
index 2d5152c..239c9d0 100644
--- a/lvz/AEffEditor.hpp
+++ b/lvz/AEffEditor.hpp
@@ -11,7 +11,7 @@ public:
, pluginURI("NULL")
{}
- virtual bool open(void* ptr) { return true; }
+ virtual long open(void* ptr) { return true; }
virtual void idle() {}
diff --git a/lvz/audioeffectx.h b/lvz/audioeffectx.h
index a1f975a..162d24b 100644
--- a/lvz/audioeffectx.h
+++ b/lvz/audioeffectx.h
@@ -80,6 +80,9 @@ class AudioEffect {
public:
AudioEffect() : editor(NULL) {}
virtual ~AudioEffect() {}
+
+ virtual void setParameter(LvzInt32 index, float value) = 0;
+ virtual float getParameter(LvzInt32 index) = 0;
void setEditor(AEffEditor* e) { editor = e; }
virtual void masterIdle() {}
@@ -112,8 +115,6 @@ public:
virtual LvzInt32 getNumOutputs() { return numOutputs; }
virtual LvzInt32 getNumParameters() { return numParams; }
- virtual void setParameter(LvzInt32 index, float value) = 0;
- virtual float getParameter(LvzInt32 index) = 0;
virtual void getParameterName(LvzInt32 index, char *label) = 0;
virtual bool getProductString(char* text) = 0;
diff --git a/lvz/gui_wrapper.cpp b/lvz/gui_wrapper.cpp
index cd8dc24..96d4f28 100644
--- a/lvz/gui_wrapper.cpp
+++ b/lvz/gui_wrapper.cpp
@@ -76,24 +76,12 @@ mda_ui_instantiate(const struct _LV2UI_Descriptor* descriptor,
LV2UI_Widget* widget,
const LV2_Feature* const* features)
{
- /* Some extensions need to be defined for this to work. Hosts must:
- * 1) Pass a pointer to the plugin (VST is crap and has no UI separation)
- * 2) Call idle on the UI periodically (VST is crap and uses polling)
- *
- * Thoughts:
- *
- * 1) This wrapper could be written explicitly in GTK and just get at
- * the idle handler that way. Less burden on the host...
- *
- * 2) A better idea is to have a 'get plugin extension data' feature
- * the UI (or anything else) can use to ask for any URI-identified
- * piece of extension data (failing in this case if plugin is remote)
- */
-
+ VSTGUI::setBundlePath(bundle_path);
+
MDAPluginUI* ui = (MDAPluginUI*)malloc(sizeof(MDAPluginUI));
ui->effect = NULL;
- typedef struct { const void* (*extension_data)(const char* uri); } LV2_ExtensionData;
+ typedef struct { const void* (*extension_data)(const char* uri); } LV2_DataAccess;
typedef const void* (*extension_data_func)(const char* uri);
typedef const AudioEffectX* (*get_effect_func)(LV2_Handle instance);
@@ -108,7 +96,7 @@ mda_ui_instantiate(const struct _LV2UI_Descriptor* descriptor,
if (!strcmp(feature->URI, "http://lv2plug.in/ns/ext/instance-access")) {
instance = (LV2_Handle)feature->data;
} else if (!strcmp(feature->URI, "http://lv2plug.in/ns/ext/data-access")) {
- LV2_ExtensionData* ext_data = (LV2_ExtensionData*)feature->data;
+ LV2_DataAccess* ext_data = (LV2_DataAccess*)feature->data;
extension_data_func func = (extension_data_func)feature->data;
get_effect = (get_effect_func)ext_data->extension_data(
"http://drobilla.net/ns/dev/vstgui");
@@ -124,7 +112,6 @@ mda_ui_instantiate(const struct _LV2UI_Descriptor* descriptor,
}
ui->ui = new UI_CLASS(ui->effect);
- ui->ui->setBundlePath(bundle_path);
ui->stolen = false;
ui->socket = GTK_SOCKET(gtk_socket_new());
diff --git a/src/mdaSpecMeterGUI.cpp b/src/mdaSpecMeterGUI.cpp
index d36622d..81ca615 100644
--- a/src/mdaSpecMeterGUI.cpp
+++ b/src/mdaSpecMeterGUI.cpp
@@ -9,10 +9,15 @@
#include <math.h>
+CResTable pngResources = { { 128, "mdaSpecMeter.png" } };
+
mdaSpecMeterGUI::mdaSpecMeterGUI(AudioEffect * effect)
: AEffGUIEditor(effect)
, background(NULL)
{
+ background = new CBitmap(128);
+ rect.right = (LvzInt16) background->getWidth();
+ rect.bottom = (LvzInt16) background->getHeight();
}
@@ -22,15 +27,9 @@ mdaSpecMeterGUI::~mdaSpecMeterGUI()
}
-bool
+long
mdaSpecMeterGUI::open(void *ptr)
{
- if (background == NULL) {
- background = new CBitmap(*this, "mdaSpecMeter.png");
- rect.right = (LvzInt16) background->getWidth();
- rect.bottom = (LvzInt16) background->getHeight();
- }
-
AEffGUIEditor::open(ptr);
CPoint offs(0, 0);
diff --git a/src/mdaSpecMeterGUI.h b/src/mdaSpecMeterGUI.h
index 263a20b..99a71f7 100644
--- a/src/mdaSpecMeterGUI.h
+++ b/src/mdaSpecMeterGUI.h
@@ -28,7 +28,7 @@ public:
mdaSpecMeterGUI(AudioEffect* effect);
~mdaSpecMeterGUI();
- bool open(void* ptr);
+ long open(void* ptr);
void idle();
void close();
diff --git a/vstgui/vstgui.cpp b/vstgui/vstgui.cpp
index ab52007..365c16b 100644
--- a/vstgui/vstgui.cpp
+++ b/vstgui/vstgui.cpp
@@ -90,7 +90,6 @@ AEffGUIEditor::AEffGUIEditor (AudioEffect* effect)
: AEffEditor (effect),
lLastTicks (0),
inIdleStuff (false),
- bundlePath(NULL),
frame (0)
{
rect.left = rect.top = rect.right = rect.bottom = 0;
@@ -322,6 +321,11 @@ void CRect::bound (const CRect& rect)
namespace VSTGUI {
+char* bundlePath = NULL;
+void setBundlePath(const char* path) {
+ VSTGUI::bundlePath = strdup(path);
+}
+
CColor kTransparentCColor = {255, 255, 255, 0};
CColor kBlackCColor = { 0, 0, 0, 255};
CColor kWhiteCColor = {255, 255, 255, 255};
@@ -3436,36 +3440,34 @@ void CViewContainer::dumpHierarchy ()
// CBitmap Implementation
//-----------------------------------------------------------------------------
/*! @class CBitmap
-@section cbitmap_alphablend Alpha Blend and Transparency
-With Version 3.0 of VSTGUI it is possible to use alpha blended bitmaps. This comes free on Mac OS X and with Windows you need to include libpng.
-Per default PNG images will be rendered alpha blended. If you want to use a transparency color with PNG Bitmaps, you need to call setNoAlpha(true) on the bitmap and set the transparency color.
-@section cbitmap_macos Classic Apple Mac OS
-The Bitmaps are PICTs and stored inside the resource fork.
-@section cbitmap_macosx Apple Mac OS X
-The Bitmaps can be of type PNG, JPEG, PICT, BMP and are stored in the Resources folder of the plugin bundle.
-They must be named bmp00100.png (or bmp00100.jpg, etc). The number is the resource id.
-@section cbitmap_windows Microsoft Windows
-The Bitmaps are .bmp files and must be included in the plug (usually using a .rc file).
-It's also possible to use png as of version 3.0 if you define the macro USE_LIBPNG and include the libpng and zlib libraries/sources to your project.
-*/
-CBitmap::CBitmap (AEffGUIEditor& editor, const char* filename)
- : resourceID (resourceID), width (0), height (0), noAlpha (true)
+ * Image resources must be in PNG format.
+ * Filenames are specified by the pngResources table defined in the GUI.
+ */
+CBitmap::CBitmap (long ID)
+ : resourceID (ID), width (0), height (0), noAlpha (true)
{
#if DEBUG
gNbCBitmap++;
#endif
-
- bool found = false;
- long i = 0;
- long ncolors, cpp;
-
- pHandle = 0;
- pMask = 0;
- if (editor.getBundlePath() == NULL) {
+ bool found = false;
+ long i = 0;
+
+ const char* p = NULL;
+ while (pngResources[i].id != 0) {
+ if (pngResources[i].id == resourceID) {
+ if (pngResources[i].path != NULL) {
+ found = true;
+ p = pngResources[i].path;
+ break;
+ }
+ }
+ }
+
+ if (VSTGUI::bundlePath == NULL) {
std::cerr << "ERROR: No bundle path set, unable to load images" << std::endl;
} else {
- std::string path = std::string(editor.getBundlePath()) + filename;
+ std::string path = std::string(VSTGUI::bundlePath) + p;
if (openPng(path.c_str())) // reads width, height
closePng();
}
diff --git a/vstgui/vstgui.h b/vstgui/vstgui.h
index 22fcb84..9ee6be0 100644
--- a/vstgui/vstgui.h
+++ b/vstgui/vstgui.h
@@ -68,10 +68,27 @@ struct ERect {
VstInt16 bottom;
};
+/** Table of PNG resources (by filename).
+ * This is ugly and weird, but designed to allow for easy porting
+ * from "motif" ported plugins (via simple search/replacing).
+ */
+struct CResTableEntry {
+ int id; ///< Resource ID (same as motif)
+ const char* path; ///< Filename (was char** xpmdata for motif)
+};
+
+typedef CResTableEntry CResTable[];
+extern CResTable pngResources;
+
//----------------------------------------------------
//----------------------------------------------------
namespace VSTGUI {
+extern char* bundlePath;
+void setBundlePath(const char* path);
+
+
+
class CFrame;
class CDrawContext;
class COffscreenContext;
@@ -122,9 +139,6 @@ public:
void idle ();
void update ();
- void setBundlePath(const char* path) { bundlePath = strdup(path); }
- const char* getBundlePath() { return bundlePath; }
-
#if VST_2_1_EXTENSIONS
long onKeyDown (VstKeyCode& keyCode);
long onKeyUp (VstKeyCode& keyCode);
@@ -137,7 +151,6 @@ protected:
unsigned int lLastTicks;
bool inIdleStuff;
static VstInt32 knobMode;
- char* bundlePath;
friend class VSTGUI::CFrame;
VSTGUI::CFrame* frame;
};
@@ -655,7 +668,7 @@ protected:
class CBitmap : public CReferenceCounter
{
public:
- CBitmap (AEffGUIEditor& editor, const char* img_name); ///< Create from a filename
+ CBitmap (long resourceID); ///< Create from a filename
CBitmap (CFrame &frame, CCoord width, CCoord height); ///< Create a pixmap with a given size.
virtual ~CBitmap ();