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.

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