You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

654 lines
18KB

  1. /* SpiralLoops
  2. * Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <iostream>
  19. #include "../../../SpiralInfo.h"
  20. #include "Widgets/Fl_Loop.h"
  21. #include "LoopGUI.h"
  22. #include "../Loop.h"
  23. #include <FL/fl_file_chooser.h>
  24. static const int EFFECT_ADDITION = 130;
  25. static const int GUI_COLOUR = 154;
  26. static const int GUIBG_COLOUR = FL_GRAY;
  27. static const int GUIBG2_COLOUR = FL_GRAY;
  28. static const int MAX_TRIGGERS = 8;
  29. //static const int GUIBG_COLOUR = 144;
  30. //static const int GUIBG2_COLOUR = 145;
  31. /////////////////////////////////////////////////////////////////////////////
  32. LoopGUI::LoopGUI(Loop *o) :
  33. m_TriggerCount(0),
  34. GUILoopGroup(NULL)
  35. {
  36. m_loop=o;
  37. m_LastAngle=0;
  38. if (!m_loop) cerr<<"WARNING: Loop not correctly set up"<<endl;
  39. }
  40. LoopGUI::~LoopGUI()
  41. {
  42. delete GUILoopGroup;
  43. }
  44. void LoopGUI::CreateGUI(char *name)
  45. {
  46. int y=20;
  47. {
  48. GUILoopGroup = new Fl_Loop(0,y,300, 300, name);
  49. GUILoopGroup->box(FL_NO_BOX);
  50. GUILoopGroup->color(GUIBG2_COLOUR);
  51. GUILoopGroup->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
  52. GUILoopGroup->user_data((void*)(this));
  53. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  54. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  55. GUILoopGroup->SetPos(m_loop->GetPosPtr());
  56. GUILoopGroup->callback((Fl_Callback*)cb_Loop);
  57. GUILoopGroup->SetupCopyBufFuncs((Fl_Loop::cb_CopyBuf1*)cb_Cut,
  58. (Fl_Loop::cb_CopyBuf1*)cb_Copy,
  59. (Fl_Loop::cb_CopyBuf2*)cb_Paste,
  60. (Fl_Loop::cb_CopyBuf2*)cb_PasteMix,
  61. (Fl_Loop::cb_CopyBuf1*)cb_ZeroRange,
  62. (Fl_Loop::cb_CopyBuf1*)cb_ReverseRange,
  63. (Fl_Loop::cb_CopyBuf1*)cb_Halve,
  64. (Fl_Loop::cb_CopyBuf1*)cb_Hold,
  65. (Fl_Loop::cb_CopyBuf1*)cb_SelectAll,
  66. (Fl_Loop::cb_CopyBuf1*)cb_NewTrigger,
  67. (Fl_Loop::cb_CopyBuf1*)cb_Move);
  68. //GUILoopGroup->SetMainWin(m_loop->GetParent()->GetPluginWindow());
  69. Volume = new Fl_Slider(60, y+100, 20, 70, "Volume");
  70. Volume->type(4);
  71. Volume->color(GUIBG2_COLOUR);
  72. Volume->selection_color(GUI_COLOUR);
  73. Volume->labelsize(10);
  74. Volume->maximum(1.0f);
  75. Volume->step(0.001);
  76. Volume->value(0);
  77. Volume->callback((Fl_Callback*)cb_Volume);
  78. GUILoopGroup->add(Volume);
  79. Cutoff = new Fl_Slider(220, y+100, 20, 70, "Cutoff");
  80. Cutoff->type(4);
  81. Cutoff->color(GUIBG2_COLOUR);
  82. Cutoff->selection_color(GUI_COLOUR);
  83. Cutoff->labelsize(10);
  84. Cutoff->maximum(100);
  85. Cutoff->step(0.1);
  86. Cutoff->value(0);
  87. Cutoff->callback((Fl_Callback*)cb_Cutoff);
  88. GUILoopGroup->add(Cutoff);
  89. Resonance = new Fl_Knob(160, y+140, 45, 45, "Emphasis");
  90. Resonance->color(GUI_COLOUR);
  91. Resonance->type(Fl_Knob::DOTLIN);
  92. Resonance->labelsize(10);
  93. Resonance->maximum(10);
  94. Resonance->step(0.1);
  95. Resonance->value(0);
  96. Resonance->callback((Fl_Callback*)cb_Resonance);
  97. GUILoopGroup->add(Resonance);
  98. Balance = new Fl_Knob(95, y+140, 45, 45, "Balance");
  99. Balance->color(GUI_COLOUR);
  100. Balance->type(Fl_Knob::DOTLIN);
  101. Balance->labelsize(10);
  102. Balance->maximum(2);
  103. Balance->step(0.001);
  104. Balance->value(1.0);
  105. Balance->callback((Fl_Callback*)cb_Balance);
  106. GUILoopGroup->add(Balance);
  107. Speed = new Fl_Knob(95, y+60, 45, 45, "Speed");
  108. Speed->color(GUI_COLOUR);
  109. Speed->type(Fl_Knob::DOTLIN);
  110. Speed->labelsize(10);
  111. Speed->maximum(3);
  112. Speed->step(0.0001);
  113. Speed->value(1);
  114. Speed->callback((Fl_Callback*)cb_Speed);
  115. GUILoopGroup->add(Speed);
  116. Length = new Fl_Knob(160, y+60, 45, 45, "Length");
  117. Length->color(GUI_COLOUR);
  118. Length->type(Fl_Knob::DOTLIN);
  119. Length->labelsize(10);
  120. Length->maximum(1);
  121. Length->step(0.0001);
  122. Length->value(1);
  123. Length->callback((Fl_Callback*)cb_Length);
  124. GUILoopGroup->add(Length);
  125. Record = new Fl_Button(85, y+200, 60, 14, "Record");
  126. Record->type(1);
  127. Record->color(GUIBG2_COLOUR);
  128. Record->down_box(FL_DOWN_BOX);
  129. Record->labelsize(10);
  130. Record->callback((Fl_Callback*)cb_Record);
  131. GUILoopGroup->add(Record);
  132. Load = new Fl_Button(155, y+200, 60, 14, "Load");
  133. Load->color(GUIBG2_COLOUR);
  134. Load->type(0);
  135. Load->down_box(FL_DOWN_BOX);
  136. Load->labelsize(10);
  137. Load->callback((Fl_Callback*)cb_Load);
  138. GUILoopGroup->add(Load);
  139. //Effects = new Fl_Button(130, y+200, 40, 14, "Effects");
  140. //Effects->color(GUIBG2_COLOUR);
  141. //Effects->type(1);
  142. //Effects->down_box(FL_DOWN_BOX);
  143. //Effects->labelsize(10);
  144. //Effects->callback((Fl_Callback*)cb_Effects);
  145. Double = new Fl_Button(85, y+218, 60, 14, "Double");
  146. Double->color(GUIBG2_COLOUR);
  147. Double->type(0);
  148. Double->down_box(FL_DOWN_BOX);
  149. Double->labelsize(10);
  150. Double->callback((Fl_Callback*)cb_Double);
  151. GUILoopGroup->add(Double);
  152. //Match = new Fl_Button(130, y+218, 40, 14, "Match");
  153. //Match->color(GUIBG2_COLOUR);
  154. //Match->type(0);
  155. //Match->down_box(FL_DOWN_BOX);
  156. //Match->labelsize(10);
  157. //Match->callback((Fl_Callback*)cb_Match);
  158. Save = new Fl_Button(155, y+218, 60, 14, "Save");
  159. Save->color(GUIBG2_COLOUR);
  160. Save->type(0);
  161. Save->down_box(FL_DOWN_BOX);
  162. Save->labelsize(10);
  163. Save->callback((Fl_Callback*)cb_Save);
  164. GUILoopGroup->add(Save);
  165. Play = new Fl_LED_Button(255, y+275, 40, 25, "Play");
  166. Play->color(GUIBG2_COLOUR);
  167. Play->type(1);
  168. Play->value(1);
  169. Play->down_box(FL_DOWN_BOX);
  170. Play->labelsize(10);
  171. Play->callback((Fl_Callback*)cb_Play);
  172. GUILoopGroup->add(Play);
  173. SpeedOutput = new Fl_Value_Output(93, y+120, 50, 15);
  174. SpeedOutput->labelsize(10);
  175. SpeedOutput->textsize(10);
  176. GUILoopGroup->add(SpeedOutput);
  177. LengthOutput = new Fl_Value_Output(157, y+120, 50, 15);
  178. LengthOutput->labelsize(10);
  179. LengthOutput->textsize(10);
  180. GUILoopGroup->add(LengthOutput);
  181. MagicOutput = new Fl_Value_Output(125, y+235, 50, 15);
  182. MagicOutput->labelsize(10);
  183. MagicOutput->textsize(10);
  184. GUILoopGroup->add(MagicOutput);
  185. //Master = new Fl_LED_Button(2, y+5, 40, 25, "Master");
  186. //Master->type(1);
  187. //Master->color(GUIBG2_COLOUR);
  188. //Master->down_box(FL_DOWN_BOX);
  189. //Master->labelsize(10);
  190. //Master->callback((Fl_Callback*)cb_Master);
  191. Update = new Fl_LED_Button(2, y+275, 40, 25, "Update");
  192. Update->type(1);
  193. Update->value(0);
  194. Update->selection_color(3);
  195. Update->down_box(FL_DOWN_BOX);
  196. Update->labelsize(10);
  197. Update->callback((Fl_Callback*)cb_Update);
  198. GUILoopGroup->add(Update);
  199. WaveSize = new Fl_Knob(262, y+5, 30, 30, "WaveSize");
  200. WaveSize->color(GUI_COLOUR);
  201. WaveSize->type(Fl_Knob::DOTLIN);
  202. WaveSize->labelsize(8);
  203. WaveSize->maximum(10.0);
  204. WaveSize->step(0.01);
  205. WaveSize->value(0.0);
  206. WaveSize->callback((Fl_Callback*)cb_WaveSize);
  207. GUILoopGroup->add(WaveSize);
  208. GUILoopGroup->show();
  209. GUILoopGroup->end();
  210. }
  211. }
  212. void LoopGUI::SetMasterStatus(bool m)
  213. {
  214. m_loop->SetMasterStatus(m);
  215. Master->value(m);
  216. GUILoopGroup->redraw();
  217. }
  218. void LoopGUI::CheckTriggers(float CurrentAngle, vector<int> &LoopTriggers)
  219. {
  220. for (vector<Fl_Trigger*>::iterator i=m_TriggerVec.begin();
  221. i!=m_TriggerVec.end(); i++)
  222. {
  223. // Todo: Better detection needed
  224. if (CurrentAngle>(*i)->GetAngle() &&
  225. m_LastAngle<(*i)->GetAngle())
  226. {
  227. if ((*i)->Completed() && (*i)->GetPass()!=0)
  228. {
  229. m_loop->SetPlaying(false);
  230. Play->value(false);
  231. }
  232. LoopTriggers.push_back((*i)->GetID());
  233. (*i)->IncCount();
  234. }
  235. }
  236. m_LastAngle=CurrentAngle;
  237. }
  238. void LoopGUI::SetSnapAngle(int Angle)
  239. {
  240. m_SnapAngle = Angle;
  241. for (vector<Fl_Trigger*>::iterator i=m_TriggerVec.begin();
  242. i!=m_TriggerVec.end(); i++)
  243. {
  244. (*i)->SetSnapAngle(Angle);
  245. }
  246. GUILoopGroup->SetSnapAngle(Angle);
  247. GUILoopGroup->redraw();
  248. }
  249. void LoopGUI::SetSnap(bool s)
  250. {
  251. for (vector<Fl_Trigger*>::iterator i=m_TriggerVec.begin();
  252. i!=m_TriggerVec.end(); i++)
  253. {
  254. (*i)->SetSnap(s);
  255. }
  256. GUILoopGroup->SetSnap(s);
  257. }
  258. void LoopGUI::UpdateValues()
  259. {
  260. Volume->value(1.0f-m_loop->GetVolume());
  261. Cutoff->value(100.0f-sqrt(m_loop->GetCutoff()-10.0f));
  262. Resonance->value(m_loop->GetResonance()-1.0f);
  263. Balance->value(m_loop->GetBalance());
  264. Speed->value(m_loop->GetSpeed());
  265. Length->value(m_loop->GetLoopLength()/(float)m_loop->GetTotalLength());
  266. Effects->value(m_loop->GetEffects());
  267. Play->value(m_loop->IsPlaying());
  268. Master->value(m_loop->IsMaster());
  269. }
  270. void LoopGUI::UpdateDataPtr()
  271. {
  272. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  273. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  274. }
  275. //// Callbacks ////
  276. inline void LoopGUI::cb_Loop_i(Fl_Loop* o, void* v)
  277. {
  278. o->hide();
  279. m_loop->DelMe();
  280. }
  281. void LoopGUI::cb_Loop(Fl_Loop* o, void* v)
  282. { ((LoopGUI*)(o->user_data()))->cb_Loop_i(o,v); }
  283. inline void LoopGUI::cb_Volume_i(Fl_Slider* o, void* v)
  284. {
  285. m_loop->SetVolume(1.0f-o->value());
  286. }
  287. void LoopGUI::cb_Volume(Fl_Slider* o, void* v)
  288. { ((LoopGUI*)(o->parent()->user_data()))->cb_Volume_i(o,v); }
  289. inline void LoopGUI::cb_Cutoff_i(Fl_Slider* o, void* v)
  290. {
  291. m_loop->FilterBypass(o->value()==0);
  292. float value=100.0f-o->value();
  293. m_loop->SetCutoff((int)(value*value+10.0f));
  294. }
  295. void LoopGUI::cb_Cutoff(Fl_Slider* o, void* v)
  296. { ((LoopGUI*)(o->parent()->user_data()))->cb_Cutoff_i(o,v); }
  297. inline void LoopGUI::cb_Balance_i(Fl_Knob* o, void* v)
  298. {
  299. /*float rvalue=1+o->value()-1.0f;
  300. float lvalue=2-o->value();
  301. m_loop->SetLeftVol(lvalue/2.0f);
  302. m_loop->SetRightVol(rvalue/2.0f);*/
  303. m_loop->SetBalance(o->value());
  304. }
  305. void LoopGUI::cb_Balance(Fl_Knob* o, void* v)
  306. { ((LoopGUI*)(o->parent()->user_data()))->cb_Balance_i(o,v); }
  307. inline void LoopGUI::cb_Length_i(Fl_Knob* o, void* v)
  308. {
  309. m_loop->SetLength((int)(o->value()*m_loop->GetTotalLength()));
  310. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  311. //LengthOutput->value((float)m_loop->GetLoopLength()/(float)SpiralLoopsInfo::SAMPLERATE);
  312. GUILoopGroup->redraw();
  313. }
  314. void LoopGUI::cb_Length(Fl_Knob* o, void* v)
  315. { ((LoopGUI*)(o->parent()->user_data()))->cb_Length_i(o,v); }
  316. inline void LoopGUI::cb_Speed_i(Fl_Knob* o, void* v)
  317. {
  318. m_loop->SetSpeed(o->value());
  319. SpeedOutput->value(o->value());
  320. }
  321. void LoopGUI::cb_Speed(Fl_Knob* o, void* v)
  322. { ((LoopGUI*)(o->parent()->user_data()))->cb_Speed_i(o,v); }
  323. inline void LoopGUI::cb_Resonance_i(Fl_Knob* o, void* v)
  324. {
  325. m_loop->SetResonance((int)(o->value()+1.0f));
  326. }
  327. void LoopGUI::cb_Resonance(Fl_Knob* o, void* v)
  328. { ((LoopGUI*)(o->parent()->user_data()))->cb_Resonance_i(o,v); }
  329. inline void LoopGUI::cb_Record_i(Fl_Button* o, void* v)
  330. {
  331. m_loop->Record(o->value());
  332. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  333. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  334. GUILoopGroup->redraw();
  335. }
  336. void LoopGUI::cb_Record(Fl_Button* o, void* v)
  337. { ((LoopGUI*)(o->parent()->user_data()))->cb_Record_i(o,v); }
  338. inline void LoopGUI::cb_Load_i(Fl_Button* o, void* v)
  339. {
  340. //GUILoopGroup->UnsetIdle();
  341. char *fn=fl_file_chooser("Pick a Wav file to load", "*.wav", NULL);
  342. if (fn && fn!="")
  343. {
  344. m_loop->LoadWav(fn);
  345. }
  346. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  347. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  348. //LengthOutput->value(m_loop->GetLoopLength()/(float)SpiralLoopsInfo::SAMPLERATE);
  349. //GUILoopGroup->SetIdle();
  350. GUILoopGroup->redraw();
  351. }
  352. void LoopGUI::cb_Load(Fl_Button* o, void* v)
  353. { ((LoopGUI*)(o->parent()->user_data()))->cb_Load_i(o,v); }
  354. inline void LoopGUI::cb_Play_i(Fl_LED_Button* o, void* v)
  355. {
  356. m_loop->SetPlaying(o->value());
  357. }
  358. void LoopGUI::cb_Play(Fl_LED_Button* o, void* v)
  359. { ((LoopGUI*)(o->parent()->user_data()))->cb_Play_i(o,v); }
  360. inline void LoopGUI::cb_Master_i(Fl_LED_Button* o, void* v)
  361. {
  362. }
  363. void LoopGUI::cb_Master(Fl_LED_Button* o, void* v)
  364. { ((LoopGUI*)(o->parent()->user_data()))->cb_Master_i(o,v); }
  365. inline void LoopGUI::cb_Effects_i(Fl_Button* o, void* v)
  366. {
  367. Fl_Widget *p=GUILoopGroup->parent();
  368. if (o->value())
  369. {
  370. p->size(p->w(),p->h()+EFFECT_ADDITION);
  371. }
  372. else
  373. {
  374. p->size(p->w(),p->h()-EFFECT_ADDITION);
  375. }
  376. m_loop->SetEffects(o->value());
  377. }
  378. void LoopGUI::cb_Effects(Fl_Button* o, void* v)
  379. { ((LoopGUI*)(o->parent()->user_data()))->cb_Effects_i(o,v); }
  380. inline void LoopGUI::cb_Update_i(Fl_LED_Button* o, void* v)
  381. {
  382. GUILoopGroup->SetUpdate(o->value());
  383. }
  384. void LoopGUI::cb_Update(Fl_LED_Button* o, void* v)
  385. { ((LoopGUI*)(o->parent()->user_data()))->cb_Update_i(o,v); }
  386. inline void LoopGUI::cb_Double_i(Fl_Button* o, void* v)
  387. {
  388. m_loop->Double();
  389. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  390. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  391. GUILoopGroup->redraw();
  392. }
  393. void LoopGUI::cb_Double(Fl_Button* o, void* v)
  394. { ((LoopGUI*)(o->parent()->user_data()))->cb_Double_i(o,v); }
  395. inline void LoopGUI::cb_Match_i(Fl_Button* o, void* v)
  396. {
  397. }
  398. void LoopGUI::cb_Match(Fl_Button* o, void* v)
  399. { ((LoopGUI*)(o->parent()->user_data()))->cb_Match_i(o,v); }
  400. inline void LoopGUI::cb_Save_i(Fl_Button* o, void* v)
  401. {
  402. char *fn=fl_file_chooser("Save loop as Wav file", "*.wav", NULL);
  403. if (fn && fn!="")
  404. {
  405. m_loop->SaveWav(fn);
  406. }
  407. }
  408. void LoopGUI::cb_Save(Fl_Button* o, void* v)
  409. { ((LoopGUI*)(o->parent()->user_data()))->cb_Save_i(o,v); }
  410. inline void LoopGUI::cb_WaveSize_i(Fl_Knob* o, void* v)
  411. {
  412. GUILoopGroup->SetWaveSize(1+o->value());
  413. GUILoopGroup->redraw();
  414. }
  415. void LoopGUI::cb_WaveSize(Fl_Knob* o, void* v)
  416. { ((LoopGUI*)(o->parent()->user_data()))->cb_WaveSize_i(o,v); }
  417. ////////////////////////////////////////////////////////////////
  418. inline void LoopGUI::cb_Cut_i(Fl_Loop *o, int Start, int End)
  419. {
  420. m_loop->Cut(Start,End);
  421. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  422. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  423. GUILoopGroup->redraw();
  424. }
  425. void LoopGUI::cb_Cut(Fl_Loop *o, int Start, int End)
  426. { ((LoopGUI*)(o->user_data()))->cb_Cut_i(o,Start,End); }
  427. void LoopGUI::cb_Copy_i(Fl_Loop *o, int Start, int End)
  428. {
  429. m_loop->Copy(Start,End);
  430. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  431. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  432. GUILoopGroup->redraw();
  433. }
  434. void LoopGUI::cb_Copy(Fl_Loop *o, int Start, int End)
  435. { ((LoopGUI*)(o->user_data()))->cb_Copy_i(o,Start,End); }
  436. inline void LoopGUI::cb_Paste_i(Fl_Loop *o, int Start)
  437. {
  438. m_loop->Paste(Start);
  439. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  440. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  441. GUILoopGroup->redraw();
  442. }
  443. void LoopGUI::cb_Paste(Fl_Loop *o, int Start)
  444. { ((LoopGUI*)(o->user_data()))->cb_Paste_i(o,Start); }
  445. inline void LoopGUI::cb_PasteMix_i(Fl_Loop *o, int Start)
  446. {
  447. m_loop->PasteMix(Start);
  448. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  449. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  450. GUILoopGroup->redraw();
  451. }
  452. void LoopGUI::cb_PasteMix(Fl_Loop *o, int Start)
  453. { ((LoopGUI*)(o->user_data()))->cb_PasteMix_i(o,Start); }
  454. inline void LoopGUI::cb_ZeroRange_i(Fl_Loop *o, int Start, int End)
  455. {
  456. m_loop->ZeroRange(Start,End);
  457. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  458. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  459. GUILoopGroup->redraw();
  460. }
  461. void LoopGUI::cb_ZeroRange(Fl_Loop *o, int Start, int End)
  462. { ((LoopGUI*)(o->user_data()))->cb_ZeroRange_i(o,Start,End); }
  463. inline void LoopGUI::cb_ReverseRange_i(Fl_Loop *o, int Start, int End)
  464. {
  465. m_loop->ReverseRange(Start,End);
  466. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  467. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  468. GUILoopGroup->redraw();
  469. }
  470. void LoopGUI::cb_ReverseRange(Fl_Loop *o, int Start, int End)
  471. { ((LoopGUI*)(o->user_data()))->cb_ReverseRange_i(o,Start,End); }
  472. inline void LoopGUI::cb_Halve_i(Fl_Loop *o, int Start, int End)
  473. {
  474. m_loop->Halve();
  475. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  476. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  477. GUILoopGroup->redraw();
  478. }
  479. void LoopGUI::cb_Halve(Fl_Loop *o, int Start, int End)
  480. { ((LoopGUI*)(o->user_data()))->cb_Halve_i(o,Start,End); }
  481. inline void LoopGUI::cb_Hold_i(Fl_Loop *o, int Start, int End)
  482. {
  483. m_loop->Hold();
  484. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  485. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  486. GUILoopGroup->redraw();
  487. }
  488. void LoopGUI::cb_Hold(Fl_Loop *o, int Start, int End)
  489. { ((LoopGUI*)(o->user_data()))->cb_Hold_i(o,Start,End); }
  490. inline void LoopGUI::cb_SelectAll_i(Fl_Loop *o, int Start, int End)
  491. {
  492. m_loop->SelectAll();
  493. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  494. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  495. GUILoopGroup->redraw();
  496. }
  497. void LoopGUI::cb_SelectAll(Fl_Loop *o, int Start, int End)
  498. { ((LoopGUI*)(o->user_data()))->cb_SelectAll_i(o,Start,End); }
  499. inline void LoopGUI::cb_NewTrigger_i(Fl_Loop *o, int Start, int End)
  500. {
  501. if (m_TriggerCount>=8) return;
  502. Fl_Trigger *NewTrigger = new Fl_Trigger(0, 0, 20, 20);
  503. NewTrigger->SetCentreX(150);
  504. NewTrigger->SetCentreY(170);
  505. NewTrigger->SetCentreRadius(125);
  506. NewTrigger->SetID(m_TriggerCount);
  507. GUILoopGroup->add(NewTrigger);
  508. m_TriggerVec.push_back(NewTrigger);
  509. GUILoopGroup->redraw();
  510. GUILoopGroup->parent()->redraw();
  511. m_TriggerCount++;
  512. }
  513. void LoopGUI::cb_NewTrigger(Fl_Loop *o, int Start, int End)
  514. { ((LoopGUI*)(o->user_data()))->cb_NewTrigger_i(o,Start,End); }
  515. inline void LoopGUI::cb_Move_i(Fl_Loop *o, int Start, int End)
  516. {
  517. m_loop->Move(Start);
  518. GUILoopGroup->SetData(m_loop->GetLoopPtr());
  519. GUILoopGroup->SetLength(m_loop->GetLoopLength());
  520. GUILoopGroup->redraw();
  521. }
  522. void LoopGUI::cb_Move(Fl_Loop *o, int Start, int End)
  523. { ((LoopGUI*)(o->user_data()))->cb_Move_i(o,Start,End); }
  524. /////////////////////////////////////////////////////
  525. istream &operator>>(istream &s, LoopGUI &o)
  526. {
  527. int x,y,w,h;
  528. s>>x>>y>>w>>h;
  529. //o.GUILoopGroup->resize(x,y,w,h);
  530. int Num;
  531. s>>Num;
  532. for (int n=0; n<Num; n++)
  533. {
  534. Fl_Trigger *NewTrigger = new Fl_Trigger(0, 0, 20, 20);
  535. s>>*NewTrigger;
  536. o.GUILoopGroup->add(NewTrigger);
  537. o.m_TriggerVec.push_back(NewTrigger);
  538. }
  539. return s;
  540. }
  541. ostream &operator<<(ostream &s, LoopGUI &o)
  542. {
  543. s<<o.GUILoopGroup->GetX()<<" "<<o.GUILoopGroup->GetY()<<" "<<
  544. o.GUILoopGroup->GetW()<<" "<<o.GUILoopGroup->GetH()<<" ";
  545. s<<o.m_TriggerVec.size()<<" ";
  546. for (vector<Fl_Trigger*>::iterator i=o.m_TriggerVec.begin();
  547. i!=o.m_TriggerVec.end(); i++)
  548. {
  549. s<<**i;
  550. }
  551. return s;
  552. }