@@ -54,15 +54,14 @@ int Fl_PortButton::handle(int event) | |||
} | |||
Fl_DeviceGUI::Fl_DeviceGUI(const DeviceGUIInfo& Info, SpiralGUIType *PW, Fl_Pixmap *Icon, bool Terminal) : | |||
Fl_Group(Info.XPos, Info.YPos, Info.Width+(PortGroupWidth*2), Info.Height+TitleBarHeight, ""), | |||
m_PluginWindow(NULL), | |||
m_Icon(NULL), | |||
m_Name(Info.Name), | |||
m_ID(-1), | |||
m_DelMe(false), | |||
m_IsTerminal(Terminal), | |||
m_Minimised(true), | |||
m_Maximising(false) | |||
Fl_Group (Info.XPos, Info.YPos, Info.Width+(PortGroupWidth*2), Info.Height+TitleBarHeight, ""), | |||
m_PluginWindow (NULL), | |||
m_Icon (NULL), | |||
m_Name (Info.Name), | |||
m_ID (-1), | |||
m_DelMe (false), | |||
m_IsTerminal (Terminal), | |||
m_Minimised (true) | |||
{ | |||
for (int n=0; n<512; n++) Numbers[n]=n; | |||
@@ -119,7 +118,8 @@ void Fl_DeviceGUI::Clear() | |||
} | |||
inline void Fl_DeviceGUI::cb_Resize_i (void) { | |||
if (m_PluginWindow && !m_DelMe && !m_Minimised && !m_Maximising) Maximise(); | |||
if (m_PluginWindow && m_PluginWindow->visible() && !m_DelMe && !m_Minimised) | |||
ResizeToPluginWindow(); | |||
} | |||
void Fl_DeviceGUI::cb_Resize (Fl_DeviceGUI *o) { | |||
@@ -129,67 +129,55 @@ void Fl_DeviceGUI::cb_Resize (Fl_DeviceGUI *o) { | |||
int Fl_DeviceGUI::handle (int event) { | |||
int t=Fl_Group::handle(event); | |||
// Click on icon in minimised device - Maximise, hide icon | |||
if (m_IconButton && m_IconButton->value()) { | |||
m_IconButton->value (false); | |||
if (m_PluginWindow && !m_DelMe) { | |||
if (!m_PluginWindow->visible()) Maximise(); | |||
} | |||
} | |||
// this bit might be supposed to be in cb_resize_i, I'm not sure - Andy Preston | |||
// plugin GUI killed - minimise device, show icon | |||
if (!m_Minimised && !m_PluginWindow->visible()) { | |||
Minimise(); | |||
if (m_IconButton) m_IconButton->show(); | |||
} | |||
return 1; | |||
} | |||
void Fl_DeviceGUI::Minimise() | |||
{ | |||
m_Minimised=true; | |||
Resize(m_MiniWidth,m_MiniHeight); | |||
parent()->redraw(); | |||
void Fl_DeviceGUI::ResizeToPluginWindow (void) { | |||
if (m_PluginWindow->h()+2 > m_MiniHeight) | |||
Resize (m_PluginWindow->w()+(PortGroupWidth*2)-5, m_PluginWindow->h()+2); | |||
else | |||
Resize (m_PluginWindow->w()+(PortGroupWidth*2)-5, m_MiniHeight); | |||
} | |||
void Fl_DeviceGUI::Maximise() | |||
{ | |||
m_Minimised=false; | |||
m_Maximising=true; | |||
if (m_PluginWindow->h()+2>m_MiniHeight) | |||
{ | |||
Resize(m_PluginWindow->w()+(PortGroupWidth*2)-5,m_PluginWindow->h()+2); | |||
} | |||
else | |||
{ | |||
Resize(m_PluginWindow->w()+(PortGroupWidth*2)-5,m_MiniHeight); | |||
} | |||
m_PluginWindow->show(); | |||
m_IconButton->hide(); | |||
parent()->redraw(); | |||
((Fl_Canvas*)parent())->ToTop(this); | |||
m_Maximising=false; | |||
void Fl_DeviceGUI::Minimise() { | |||
m_Minimised = true; | |||
Resize (m_MiniWidth, m_MiniHeight); | |||
parent()->redraw(); | |||
} | |||
void Fl_DeviceGUI::Resize(int width, int height) | |||
{ | |||
int oldw = w(); | |||
int oldh = h(); | |||
size(width,height); | |||
m_DragBar->size(width,m_DragBar->h()); | |||
for (int n=m_Info.NumInputs; n<(int)m_PortVec.size(); n++) | |||
{ | |||
m_PortVec[n]->position(x()+width-8,m_PortVec[n]->y()); | |||
} | |||
position(x()+(oldw-w())/2,y()+(oldh-h())/2); | |||
m_Menu->resize(x(),y(),width,height); | |||
void Fl_DeviceGUI::Maximise() { | |||
m_Minimised=false; | |||
ResizeToPluginWindow(); | |||
m_PluginWindow->show(); | |||
m_IconButton->hide(); | |||
parent()->redraw(); | |||
((Fl_Canvas*)parent())->ToTop(this); | |||
} | |||
int Centx=x()+w()/2; | |||
int Centy=y()+h()/2; | |||
m_IconButton->position(Centx-m_Icon->w()/2,Centy-m_Icon->h()/2); | |||
void Fl_DeviceGUI::Resize (int width, int height) { | |||
int oldw = w(); | |||
int oldh = h(); | |||
size (width, height); | |||
m_DragBar->size (width, m_DragBar->h()); | |||
for (int n=m_Info.NumInputs; n<(int)m_PortVec.size(); n++) | |||
m_PortVec[n]->position (x()+width-8, m_PortVec[n]->y()); | |||
position (x()+(oldw-w())/2, y()+(oldh-h())/2); | |||
m_Menu->resize (x(), y(), width, height); | |||
int Centx = x()+w()/2; | |||
int Centy = y()+h()/2; | |||
m_IconButton->position (Centx-m_Icon->w()/2, Centy-m_Icon->h()/2); | |||
} | |||
void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | |||
@@ -16,6 +16,9 @@ | |||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||
*/ | |||
#ifndef DEVICEGUI | |||
#define DEVICEGUI | |||
#include <FL/Fl.H> | |||
#include <FL/Fl_Group.H> | |||
#include <FL/Fl_Button.H> | |||
@@ -29,9 +32,6 @@ | |||
#include <string> | |||
#include <stdio.h> | |||
#ifndef DEVICEGUI | |||
#define DEVICEGUI | |||
#define WIRE_COL0 91 | |||
#define WIRE_COL1 FL_GREEN | |||
#define WIRE_COL2 FL_YELLOW | |||
@@ -44,9 +44,8 @@ static const int TitleBarHeight = 12; | |||
static const int PortGroupWidth = 12; | |||
static const int PortSize=6; | |||
class Fl_PortButton : public Fl_Button | |||
{ | |||
public: | |||
class Fl_PortButton : public Fl_Button { | |||
public: | |||
enum Type {INPUT,OUTPUT}; | |||
Fl_PortButton(int x, int y, int w, int h, char *n); | |||
@@ -58,9 +57,7 @@ public: | |||
void Remove() { if (m_ConnectionCount>0) m_ConnectionCount--; } | |||
int GetCount() { return m_ConnectionCount; } | |||
int GetLastButton() { return m_LastButton; } | |||
private: | |||
private: | |||
Type m_Type; | |||
int m_ConnectionCount; | |||
int m_LastButton; | |||
@@ -79,65 +76,57 @@ struct DeviceGUIInfo | |||
vector<int> PortTypes; | |||
}; | |||
class Fl_DeviceGUI : public Fl_Group | |||
{ | |||
public: | |||
Fl_DeviceGUI(const DeviceGUIInfo& Info, SpiralGUIType *PW, Fl_Pixmap *Icon, bool Terminal=false); | |||
virtual int handle(int event); | |||
enum PortType {INPUT,OUTPUT}; | |||
int GetID() { return m_ID; } | |||
void SetID(int s) { m_ID=s; /*DisplayID(s);*/ } | |||
bool Killed() { return m_DelMe; } | |||
int GetPortX(int n) { return m_PortVec[n]->x()+PortSize/2; } | |||
int GetPortY(int n) { return m_PortVec[n]->y()+PortSize/2; } | |||
// aesthetic, to keep track of number of connections to know whether to | |||
// draw the port as occupied or not. | |||
bool AddConnection(int n); | |||
void RemoveConnection(int n); | |||
bool GetPortValue(int n) { return m_PortVec[n]->value(); } | |||
const DeviceGUIInfo* GetInfo() { return &m_Info; } | |||
SpiralGUIType* GetPluginWindow() { return m_PluginWindow; } | |||
string GetName() { return m_Name; } | |||
void SetName(const string &s) { m_Name=s; m_DragBar->label(m_Name.c_str()); } | |||
bool IsMinimised() { return m_Minimised; } | |||
void Minimise(); | |||
void Maximise(); | |||
// automatically called from the constructor, but may be redone at any time. | |||
virtual void Setup(const DeviceGUIInfo& Info, bool FirstTime = false); | |||
virtual void Clear(); | |||
int GetPortType(int n) { return m_Info.PortTypes[n]; } | |||
// do we belong to a plugin that is an output? | |||
bool IsTerminal() { return m_IsTerminal; } | |||
protected: | |||
DeviceGUIInfo m_Info; | |||
Fl_DragBar* m_DragBar; | |||
SpiralGUIType* m_PluginWindow; | |||
Fl_Pixmap* m_Icon; | |||
Fl_Button* m_IconButton; | |||
Fl_Menu_Button* m_Menu; | |||
private: | |||
void Resize(int width, int height); | |||
inline void cb_Resize_i (void); | |||
static void cb_Resize (Fl_DeviceGUI *o); | |||
inline void cb_Port_i(Fl_Button* o, void* v); | |||
static void cb_Port(Fl_Button* o, void* v); | |||
inline void cb_Rename_i(Fl_Menu_Button* o, void* v); | |||
static void cb_Rename(Fl_Menu_Button* o, void* v); | |||
inline void cb_Delete_i(Fl_Menu_Button* o, void* v); | |||
static void cb_Delete(Fl_Menu_Button* o, void* v); | |||
vector<Fl_PortButton*> m_PortVec; | |||
static int Numbers[512]; | |||
string m_Name; | |||
int m_ID, m_MiniWidth, m_MiniHeight; | |||
bool m_DelMe, m_IsTerminal, m_Minimised, m_Maximising; | |||
class Fl_DeviceGUI : public Fl_Group { | |||
public: | |||
Fl_DeviceGUI (const DeviceGUIInfo& Info, SpiralGUIType *PW, Fl_Pixmap *Icon, bool Terminal=false); | |||
virtual int handle (int event); | |||
enum PortType {INPUT,OUTPUT}; | |||
int GetID() { return m_ID; } | |||
void SetID (int s) { m_ID=s; /*DisplayID(s);*/ } | |||
bool Killed() { return m_DelMe; } | |||
int GetPortX (int n) { return m_PortVec[n]->x()+PortSize/2; } | |||
int GetPortY (int n) { return m_PortVec[n]->y()+PortSize/2; } | |||
// aesthetic, to keep track of number of connections to know whether to | |||
// draw the port as occupied or not. | |||
bool AddConnection (int n); | |||
void RemoveConnection (int n); | |||
bool GetPortValue (int n) { return m_PortVec[n]->value(); } | |||
const DeviceGUIInfo* GetInfo() { return &m_Info; } | |||
SpiralGUIType* GetPluginWindow() { return m_PluginWindow; } | |||
string GetName() { return m_Name; } | |||
void SetName (const string &s) { m_Name=s; m_DragBar->label (m_Name.c_str()); } | |||
bool IsMinimised() { return m_Minimised; } | |||
void Minimise(); | |||
void Maximise(); | |||
// automatically called from the constructor, but may be redone at any time. | |||
virtual void Setup (const DeviceGUIInfo& Info, bool FirstTime = false); | |||
virtual void Clear(); | |||
int GetPortType (int n) { return m_Info.PortTypes[n]; } | |||
// do we belong to a plugin that is an output? | |||
bool IsTerminal() { return m_IsTerminal; } | |||
protected: | |||
DeviceGUIInfo m_Info; | |||
Fl_DragBar* m_DragBar; | |||
SpiralGUIType* m_PluginWindow; | |||
Fl_Pixmap* m_Icon; | |||
Fl_Button* m_IconButton; | |||
Fl_Menu_Button* m_Menu; | |||
private: | |||
void ResizeToPluginWindow (void); | |||
void Resize (int width, int height); | |||
inline void cb_Resize_i (void); | |||
static void cb_Resize (Fl_DeviceGUI *o); | |||
inline void cb_Port_i (Fl_Button* o, void* v); | |||
static void cb_Port (Fl_Button* o, void* v); | |||
inline void cb_Rename_i (Fl_Menu_Button* o, void* v); | |||
static void cb_Rename (Fl_Menu_Button* o, void* v); | |||
inline void cb_Delete_i (Fl_Menu_Button* o, void* v); | |||
static void cb_Delete (Fl_Menu_Button* o, void* v); | |||
vector<Fl_PortButton*> m_PortVec; | |||
static int Numbers[512]; | |||
string m_Name; | |||
int m_ID, m_MiniWidth, m_MiniHeight; | |||
bool m_DelMe, m_IsTerminal, m_Minimised; | |||
}; | |||
#endif |
@@ -13,7 +13,7 @@ CXXFLAGS= @CXXFLAGS@ @FLTK_CXXFLAGS@ | |||
INCPATH = | |||
LINK = g++ | |||
LFLAGS = | |||
LIBS = @FLTK_LIBS@ -lm -ldl -lpng -lpthread | |||
LIBS = @FLTK_LIBS@ -lm -ldl -lpthread | |||
MOC = moc | |||
UIC = | |||
@@ -284,6 +284,8 @@ void LADSPAPluginGUI::Update(void) | |||
m_BSlider->resize(x()+60, y()+15, 50, 20); | |||
m_BSetup->resize(x() + w() - 55, y()+15, 50, 20); | |||
} | |||
// Andy Preston bodged this bit in - might be better somewhere else | |||
DoResizeCallback (); | |||
} | |||
// This lot is only done on patch load | |||
@@ -522,6 +524,8 @@ void LADSPAPluginGUI::SetPage(int index) | |||
m_BKnob->resize(x()+5, y()+15, 50, 20); | |||
m_BSlider->resize(x()+60, y()+15, 50, 20); | |||
m_BSetup->resize(x() + w() - 55, y()+15, 50, 20); | |||
// Andy Preston bodged this bit in - might be better somewhere else | |||
DoResizeCallback (); | |||
} | |||
void LADSPAPluginGUI::SetUniqueID(unsigned long n) | |||
@@ -813,6 +817,8 @@ void LADSPAPluginGUI::UpdateKnobs(void) | |||
m_KnobLabels[p]->hide(); | |||
} | |||
} | |||
// Andy Preston bodged this bit in - might be better somewhere else | |||
DoResizeCallback (); | |||
} | |||
// Rearrange sliders depending on connections | |||
@@ -919,6 +925,8 @@ void LADSPAPluginGUI::UpdateSliders(void) | |||
m_SliderLabels[p]->hide(); | |||
} | |||
} | |||
// Andy Preston bodged this bit in - might be better somewhere else | |||
DoResizeCallback (); | |||
} | |||
// Set value of slider and/or knob (both use the same settings) | |||
@@ -66,7 +66,7 @@ SpiralPluginGUI::~SpiralPluginGUI() | |||
void SpiralPluginGUI::resize (int newx, int newy, int neww, int newh) { | |||
m_Help->position (x()+neww-11, y()+2); | |||
SpiralGUIType::resize (newx, newy, neww, newh); | |||
DoResizeCallback (); | |||
//DoResizeCallback (); | |||
} | |||
void SpiralPluginGUI::Update() | |||