/usr/lib/faust/gui/GUI.h is in faust 0.9.46-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | #ifndef FAUST_GUI_H
#define FAUST_GUI_H
#include "UI.h"
#include <list>
#include <map>
using namespace std;
/*******************************************************************************
* GUI : Abstract Graphic User Interface
* Provides additional macchanismes to synchronize widgets and zones. Widgets
* should both reflect the value of a zone and allow to change this value.
******************************************************************************/
struct uiItem;
typedef void (*uiCallback)(float val, void* data);
class GUI : public UI
{
typedef list<uiItem*> clist;
typedef map<float*, clist*> zmap;
private:
static list<GUI*> fGuiList;
zmap fZoneMap;
bool fStopped;
public:
GUI() : fStopped(false) {
fGuiList.push_back(this);
}
virtual ~GUI() {
// suppression de this dans fGuiList
}
// -- registerZone(z,c) : zone management
void registerZone(float* z, uiItem* c)
{
if (fZoneMap.find(z) == fZoneMap.end()) fZoneMap[z] = new clist();
fZoneMap[z]->push_back(c);
}
void updateAllZones();
void updateZone(float* z);
static void updateAllGuis()
{
list<GUI*>::iterator g;
for (g = fGuiList.begin(); g != fGuiList.end(); g++) {
(*g)->updateAllZones();
}
}
void addCallback(float* zone, uiCallback foo, void* data);
virtual void show() {};
virtual void run() {};
void stop() { fStopped = true; }
bool stopped() { return fStopped; }
virtual void declare(float* , const char* , const char* ) {}
};
/**
* User Interface Item: abstract definition
*/
class uiItem
{
protected :
GUI* fGUI;
float* fZone;
float fCache;
uiItem (GUI* ui, float* zone) : fGUI(ui), fZone(zone), fCache(-123456.654321)
{
ui->registerZone(zone, this);
}
public :
virtual ~uiItem() {}
void modifyZone(float v)
{
fCache = v;
if (*fZone != v) {
*fZone = v;
fGUI->updateZone(fZone);
}
}
float cache() { return fCache; }
virtual void reflectZone() = 0;
};
/**
* Callback Item
*/
struct uiCallbackItem : public uiItem
{
uiCallback fCallback;
void* fData;
uiCallbackItem(GUI* ui, float* zone, uiCallback foo, void* data)
: uiItem(ui, zone), fCallback(foo), fData(data) {}
virtual void reflectZone() {
float v = *fZone;
fCache = v;
fCallback(v, fData);
}
};
// en cours d'installation de call back. a finir!!!!!
/**
* Update all user items reflecting zone z
*/
inline void GUI::updateZone(float* z)
{
float v = *z;
clist* l = fZoneMap[z];
for (clist::iterator c = l->begin(); c != l->end(); c++) {
if ((*c)->cache() != v) (*c)->reflectZone();
}
}
/**
* Update all user items not up to date
*/
inline void GUI::updateAllZones()
{
for (zmap::iterator m = fZoneMap.begin(); m != fZoneMap.end(); m++) {
float* z = m->first;
clist* l = m->second;
float v = *z;
for (clist::iterator c = l->begin(); c != l->end(); c++) {
if ((*c)->cache() != v) (*c)->reflectZone();
}
}
}
inline void GUI::addCallback(float* zone, uiCallback foo, void* data)
{
new uiCallbackItem(this, zone, foo, data);
};
#endif
|