aboutsummaryrefslogtreecommitdiffstats
path: root/vstgui
diff options
context:
space:
mode:
Diffstat (limited to 'vstgui')
-rw-r--r--vstgui/vstgui.cpp50
-rw-r--r--vstgui/vstgui.h23
2 files changed, 44 insertions, 29 deletions
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 ();