@@ -61,7 +61,8 @@ m_Name(Info.Name), | |||
m_ID(-1), | |||
m_DelMe(false), | |||
m_IsTerminal(Terminal), | |||
m_Minimised(true) | |||
m_Minimised(true), | |||
m_Maximising(false) | |||
{ | |||
for (int n=0; n<512; n++) Numbers[n]=n; | |||
@@ -104,11 +105,10 @@ m_Minimised(true) | |||
m_PluginWindow = PW; | |||
if (m_PluginWindow) { | |||
m_PluginWindow->hide(); | |||
add (m_PluginWindow); | |||
add (m_PluginWindow); | |||
m_PluginWindow->ResizeCallback (&cb_Resize, this); | |||
} | |||
resizable(NULL); | |||
//Add the input/output ports | |||
Setup(Info, true); | |||
} | |||
@@ -118,6 +118,15 @@ void Fl_DeviceGUI::Clear() | |||
end(); | |||
} | |||
inline void Fl_DeviceGUI::cb_Resize_i (void) { | |||
if (m_PluginWindow && !m_DelMe && !m_Minimised && !m_Maximising) Maximise(); | |||
} | |||
void Fl_DeviceGUI::cb_Resize (Fl_DeviceGUI *o) { | |||
o->cb_Resize_i(); | |||
} | |||
int Fl_DeviceGUI::handle (int event) { | |||
int t=Fl_Group::handle(event); | |||
@@ -128,13 +137,7 @@ int Fl_DeviceGUI::handle (int event) { | |||
} | |||
} | |||
if (m_PluginWindow && !m_DelMe) { | |||
if (m_PluginWindow->needs_resize() && !m_Minimised) { | |||
Maximise(); | |||
m_PluginWindow->needs_resize(false); | |||
} | |||
} | |||
// this bit might be supposed to be in cb_resize_i, I'm not sure - Andy Preston | |||
if (!m_Minimised && !m_PluginWindow->visible()) { | |||
Minimise(); | |||
if (m_IconButton) m_IconButton->show(); | |||
@@ -152,7 +155,8 @@ void Fl_DeviceGUI::Minimise() | |||
void Fl_DeviceGUI::Maximise() | |||
{ | |||
m_Minimised=false; | |||
m_Minimised=false; | |||
m_Maximising=true; | |||
if (m_PluginWindow->h()+2>m_MiniHeight) | |||
{ | |||
Resize(m_PluginWindow->w()+(PortGroupWidth*2)-5,m_PluginWindow->h()+2); | |||
@@ -165,6 +169,7 @@ void Fl_DeviceGUI::Maximise() | |||
m_IconButton->hide(); | |||
parent()->redraw(); | |||
((Fl_Canvas*)parent())->ToTop(this); | |||
m_Maximising=false; | |||
} | |||
void Fl_DeviceGUI::Resize(int width, int height) | |||
@@ -200,22 +205,22 @@ void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | |||
// delete the current ports | |||
for(vector<Fl_PortButton*>::iterator i=m_PortVec.begin(); | |||
i!=m_PortVec.end(); i++) | |||
{ | |||
{ | |||
remove(*i); | |||
delete(*i); | |||
} | |||
m_PortVec.clear(); | |||
int InputX=x()+2; | |||
int OutputX=0; | |||
int StartY=y()+TitleBarHeight; | |||
int PortDist=10; | |||
int PortNum=0; | |||
m_MiniHeight=Info.Height+TitleBarHeight; | |||
bool Maximised = (m_PluginWindow && m_PluginWindow->visible()); | |||
if (!Maximised) | |||
if (!Maximised) | |||
{ | |||
h(m_MiniHeight); | |||
OutputX=x()+PortGroupWidth+Info.Width+4; | |||
@@ -224,7 +229,7 @@ void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | |||
{ | |||
OutputX=x()+w()-8; | |||
} | |||
for (int n=0; n<Info.NumInputs; n++) | |||
{ | |||
Fl_PortButton* NewInput = new Fl_PortButton(InputX,StartY+PortDist*n,PortSize,PortSize,""); | |||
@@ -232,7 +237,7 @@ void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | |||
NewInput->SetType(Fl_PortButton::INPUT); | |||
NewInput->value(false); | |||
NewInput->box(FL_ROUNDED_BOX); | |||
Fl_Color col = (Fl_Color) WIRE_COL0; | |||
switch (Info.PortTypes[n]) { | |||
case 0: col = (Fl_Color) WIRE_COL0; | |||
@@ -248,15 +253,15 @@ void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | |||
default: col = (Fl_Color) WIRE_COL0; | |||
} | |||
NewInput->selection_color(col); | |||
NewInput->down_box(FL_ROUNDED_BOX); | |||
NewInput->tooltip(Info.PortTips[n].c_str()); | |||
NewInput->callback((Fl_Callback*)cb_Port,(void*)&Numbers[PortNum]); | |||
NewInput->callback((Fl_Callback*)cb_Port,(void*)&Numbers[PortNum]); | |||
m_PortVec.push_back(NewInput); | |||
add(NewInput); | |||
PortNum++; | |||
} | |||
for (int n=0; n<Info.NumOutputs; n++) | |||
{ | |||
Fl_PortButton* NewOutput= NewOutput = new Fl_PortButton(OutputX,StartY+PortDist*n,PortSize,PortSize,""); | |||
@@ -280,20 +285,19 @@ void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | |||
default: col = (Fl_Color) WIRE_COL0; | |||
} | |||
NewOutput->selection_color(col); | |||
NewOutput->down_box(FL_ROUNDED_BOX); | |||
NewOutput->tooltip(Info.PortTips[n+Info.NumInputs].c_str()); | |||
NewOutput->callback((Fl_Callback*)cb_Port,(void*)&Numbers[PortNum]); | |||
NewOutput->callback((Fl_Callback*)cb_Port,(void*)&Numbers[PortNum]); | |||
m_PortVec.push_back(NewOutput); | |||
add(NewOutput); | |||
PortNum++; | |||
} | |||
} | |||
bool Fl_DeviceGUI::AddConnection(int n) | |||
{ | |||
if ( n < (int)m_PortVec.size() ) | |||
bool Fl_DeviceGUI::AddConnection(int n) | |||
{ | |||
if ( n < (int)m_PortVec.size() ) | |||
{ | |||
m_PortVec[n]->Add(); | |||
m_PortVec[n]->value(1); | |||
@@ -302,15 +306,15 @@ bool Fl_DeviceGUI::AddConnection(int n) | |||
} | |||
return false; | |||
} | |||
void Fl_DeviceGUI::RemoveConnection(int n) | |||
{ | |||
m_PortVec[n]->Remove(); | |||
if (!m_PortVec[n]->GetCount()) | |||
{ | |||
m_PortVec[n]->value(0); | |||
void Fl_DeviceGUI::RemoveConnection(int n) | |||
{ | |||
m_PortVec[n]->Remove(); | |||
if (!m_PortVec[n]->GetCount()) | |||
{ | |||
m_PortVec[n]->value(0); | |||
redraw(); | |||
} | |||
} | |||
} | |||
inline void Fl_DeviceGUI::cb_Port_i(Fl_Button* o, void* v) | |||
@@ -318,11 +322,11 @@ inline void Fl_DeviceGUI::cb_Port_i(Fl_Button* o, void* v) | |||
int Port=*(int*)(v); | |||
Fl_PortButton *PortButton = (Fl_PortButton *)o; | |||
PortType Pt; | |||
if (m_DelMe) return; | |||
// Find out if this is an input or an output. | |||
if (Port<m_Info.NumInputs) | |||
if (Port<m_Info.NumInputs) | |||
{ | |||
Pt=INPUT; | |||
} | |||
@@ -331,16 +335,16 @@ inline void Fl_DeviceGUI::cb_Port_i(Fl_Button* o, void* v) | |||
Pt=OUTPUT; | |||
Port-=m_Info.NumInputs; | |||
} | |||
if (PortButton->GetLastButton()==1) | |||
{ | |||
((Fl_Canvas*)(parent()))->PortClicked(this,Pt,Port,1); | |||
} | |||
else | |||
{ | |||
((Fl_Canvas*)(parent()))->PortClicked(this,Pt,Port,0); | |||
((Fl_Canvas*)(parent()))->PortClicked(this,Pt,Port,0); | |||
} | |||
} | |||
void Fl_DeviceGUI::cb_Port(Fl_Button* o, void* v) | |||
{((Fl_DeviceGUI*)(o->parent()))->cb_Port_i(o,v);} | |||
@@ -52,13 +52,13 @@ public: | |||
Fl_PortButton(int x, int y, int w, int h, char *n); | |||
virtual ~Fl_PortButton() {}; | |||
void SetType(Type s) { m_Type=s; } | |||
virtual int handle(int event); | |||
virtual int handle(int event); | |||
void Add() { m_ConnectionCount++; } | |||
void Remove() { if (m_ConnectionCount>0) m_ConnectionCount--; } | |||
int GetCount() { return m_ConnectionCount; } | |||
int GetLastButton() { return m_LastButton; } | |||
private: | |||
Type m_Type; | |||
@@ -69,7 +69,7 @@ private: | |||
struct DeviceGUIInfo | |||
{ | |||
int XPos; | |||
int YPos; | |||
int YPos; | |||
int Width; | |||
int Height; | |||
int NumInputs; | |||
@@ -93,13 +93,13 @@ public: | |||
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 | |||
// 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(); } | |||
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; } | |||
@@ -108,47 +108,36 @@ public: | |||
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 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; | |||
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; | |||
bool m_DelMe; | |||
bool m_IsTerminal; | |||
bool m_Minimised; | |||
int m_MiniWidth, m_MiniHeight; | |||
int m_ID, m_MiniWidth, m_MiniHeight; | |||
bool m_DelMe, m_IsTerminal, m_Minimised, m_Maximising; | |||
}; | |||
#endif |
@@ -17,10 +17,10 @@ | |||
#include "SpiralGUI.H" | |||
// Default label = 0 | |||
// Default label = 0 | |||
SpiralGUIType::SpiralGUIType (int x, int y, int w, int h, const char *label) : | |||
Fl_Group (x, y, w, h, label), | |||
m_NeedsResize (false) { | |||
m_ResizeSpiralGUI (0) { | |||
} | |||
SpiralGUIType::~SpiralGUIType () { | |||
@@ -20,14 +20,20 @@ | |||
#include <FL/Fl_Group.H> | |||
class Fl_DeviceGUI; | |||
class SpiralGUIType; | |||
typedef void (SpiralGUISizeCB)(Fl_DeviceGUI *o); | |||
class SpiralGUIType : public Fl_Group { | |||
public: | |||
SpiralGUIType (int x, int y, int w, int h, const char *label = 0); | |||
~SpiralGUIType (); | |||
bool needs_resize (void) { return m_NeedsResize; } | |||
void needs_resize (bool nr) { m_NeedsResize = nr; } | |||
void ResizeCallback (SpiralGUISizeCB *c, Fl_DeviceGUI *d) { m_ResizeSpiralGUI = c; m_DeviceGUI = d; } | |||
protected: | |||
void DoResizeCallback (void) { if (m_ResizeSpiralGUI) m_ResizeSpiralGUI(m_DeviceGUI); } | |||
private: | |||
bool m_NeedsResize; | |||
SpiralGUISizeCB *m_ResizeSpiralGUI; | |||
Fl_DeviceGUI *m_DeviceGUI; | |||
}; | |||
#endif |
@@ -1144,7 +1144,7 @@ inline void LADSPAPluginGUI::cb_Select_i(Fl_Choice* o) | |||
m_GUICH->Wait(); | |||
} | |||
SelectPlugin(); | |||
needs_resize (true); | |||
DoResizeCallback (); | |||
} | |||
void LADSPAPluginGUI::cb_Select(Fl_Choice* o) | |||
{ // Group GUI | |||
@@ -136,7 +136,7 @@ inline void LogicPluginGUI::cb_Inputs_i (Fl_Counter* o, void* v) { | |||
m_GUICH->Set ("Inputs", int (o->value ())); | |||
m_GUICH->SetCommand (LogicPlugin::SETINPUTS); | |||
m_GUICH->Wait (); | |||
needs_resize (true); | |||
DoResizeCallback (); | |||
} | |||
} | |||
@@ -283,8 +283,7 @@ inline void MidiPluginGUI::cb_AddControl_i(Fl_Button* o, void* v) | |||
m_GUICH->SetData("Name",Temp); | |||
m_GUICH->SetCommand(MidiPlugin::ADDCONTROL); | |||
m_GUICH->Wait (); | |||
needs_resize (true); | |||
DoResizeCallback (); | |||
//m_Plugin->AddControl(c,List[c]); | |||
} | |||
} | |||
@@ -295,7 +294,7 @@ inline void MidiPluginGUI::cb_RemoveControl_i(Fl_Button* o, void* v) | |||
{ | |||
m_GUICH->SetCommand(MidiPlugin::DELCONTROL); | |||
m_GUICH->Wait (); | |||
needs_resize (true); | |||
DoResizeCallback (); | |||
} | |||
void MidiPluginGUI::cb_RemoveControl(Fl_Button* o, void* v) | |||
{ ((MidiPluginGUI*)(o->parent()))->cb_RemoveControl_i(o,v);} | |||
@@ -53,6 +53,8 @@ SpiralGUIType(0,0,w,h,"") | |||
m_Help->down_box(FL_NO_BOX); | |||
m_Help->callback((Fl_Callback*)cb_Help); | |||
add(m_Help); | |||
resizable(NULL); | |||
} | |||
SpiralPluginGUI::~SpiralPluginGUI() | |||
@@ -61,9 +63,10 @@ SpiralPluginGUI::~SpiralPluginGUI() | |||
Fl::check(); | |||
} | |||
void SpiralPluginGUI::resize (int x, int y, int w, int h) { | |||
if (w != this->w() || h != this->h()) needs_resize (true); | |||
SpiralGUIType::resize (x, y, w, h); | |||
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 (); | |||
} | |||
void SpiralPluginGUI::Update() | |||