Rev 2097 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
964 | jag | 1 | /* |
2 | * plugin_browser.cc |
||
2302 | jag | 3 | * DIN Is Noise is copyright (c) 2006-2025 Jagannathan Sampath |
1713 | jag | 4 | * DIN Is Noise is released under GNU Public License 2.0 |
1479 | jag | 5 | * For more information, please visit https://dinisnoise.org/ |
964 | jag | 6 | */ |
7 | |||
8 | #include "sine_mixer.h" |
||
9 | #include "fractaliser.h" |
||
10 | #include "starrer.h" |
||
11 | #include "spiraler.h" |
||
12 | #include "rose_milker.h" |
||
13 | #include "circler.h" |
||
14 | #include "plugin_browser.h" |
||
15 | #include "lissajous.h" |
||
16 | #include "superformula.h" |
||
17 | #include "ui_list.h" |
||
18 | #include "warper.h" |
||
19 | #include "countries.h" |
||
20 | #include "morpher.h" |
||
21 | #include "number.h" |
||
22 | #include "log.h" |
||
23 | using namespace std; |
||
24 | |||
25 | plugin_browser::~plugin_browser () { |
||
26 | widget_save ("d_plugin_browser", ctrls, num_ctrls); |
||
27 | } |
||
28 | |||
29 | void plugin_browser::setup () { |
||
1555 | jag | 30 | |
964 | jag | 31 | for (int i = 0; i < num_plugins; ++i) { |
978 | jag | 32 | plugin* pi = plugins [i]; |
964 | jag | 33 | add_children_of (pi); |
34 | il_plugins.add (pi->name); |
||
35 | } |
||
36 | |||
37 | l_title.set_moveable (1); |
||
38 | ab_fold.set_listener (this); |
||
39 | fb_list.set_listener (this); |
||
40 | il_plugins.set_listener (this); |
||
41 | |||
42 | cur = 0; |
||
43 | il_plugins.hide (); |
||
44 | |||
45 | ctrls[0]=&l_title;ctrls[1]=&ab_fold;ctrls[2]=&fb_list;ctrls[3]=&il_plugins; |
||
1714 | jag | 46 | for (int i = 1; i < num_ctrls; ++i) l_title.add_child (ctrls[i]); |
964 | jag | 47 | widget_load ("d_plugin_browser", ctrls, num_ctrls); |
48 | |||
49 | } |
||
50 | |||
51 | int plugin_browser::handle_input () { |
||
1249 | jag | 52 | int r = 0; |
1592 | jag | 53 | for (int i = 0; i < num_ctrls_1; ++i) { |
1249 | jag | 54 | r = ctrls[i]->handle_input (); |
55 | if (r) return r; |
||
56 | } |
||
57 | if (il_plugins.visible) r = il_plugins.handle_input (); else r = plugins[cur]->handle_input (); |
||
964 | jag | 58 | return r; |
59 | } |
||
60 | |||
61 | void plugin_browser::draw () { |
||
1592 | jag | 62 | for (int i = 0; i < num_ctrls_1; ++i) ctrls[i]->draw (); |
1249 | jag | 63 | if (il_plugins.visible) il_plugins.draw (); else plugins[cur]->draw (); |
964 | jag | 64 | } |
65 | |||
1249 | jag | 66 | void plugin_browser::update () { |
67 | for (int i = 0; i < num_ctrls; ++i) ctrls[i]->update (); |
||
68 | } |
||
69 | |||
964 | jag | 70 | void plugin_browser::add_children_of (plugin* p) { |
71 | vector<widget*>& pctrls = p->ctrls; |
||
72 | for (int i = 0, j = pctrls.size (); i < j; ++i) l_title.add_child (pctrls[i]); |
||
73 | } |
||
74 | |||
75 | void plugin_browser::clicked (button& b) { |
||
76 | if (&b == &fb_list) { |
||
1249 | jag | 77 | if (il_plugins.visible) |
78 | il_plugins.hide (); |
||
1714 | jag | 79 | else |
1249 | jag | 80 | il_plugins.show (); |
964 | jag | 81 | } else if (&b == &il_plugins) { |
82 | il_plugins.clicked (il_plugins); |
||
1249 | jag | 83 | set_cur (il_plugins.cur); |
84 | il_plugins.select (0); |
||
85 | il_plugins.hide (); |
||
86 | set_fold (0); |
||
964 | jag | 87 | } else { |
88 | if (folded()) { |
||
1226 | jag | 89 | set_fold (0); |
964 | jag | 90 | } else { |
1226 | jag | 91 | set_fold (1); |
964 | jag | 92 | } |
93 | } |
||
94 | } |
||
95 | |||
96 | void plugin_browser::set_cur (int c) { |
||
97 | cur = c; |
||
98 | plugin* pcur = plugins[cur]; |
||
99 | l_title.set_text (pcur->name); |
||
100 | } |
||
101 | |||
102 | void plugin_browser::set_fold (int f) { |
||
103 | if (f) { |
||
1015 | jag | 104 | ab_fold.set_dir (arrow_button::right); |
964 | jag | 105 | plugins[cur]->fold (); |
106 | } else { |
||
1015 | jag | 107 | ab_fold.set_dir (arrow_button::down); |
964 | jag | 108 | plugins[cur]->unfold (); |
109 | } |
||
1226 | jag | 110 | ed->draw_plugin_output = !f; |
964 | jag | 111 | } |
112 | |||
113 | int plugin_browser::folded () { |
||
1015 | jag | 114 | return (ab_fold.dir == arrow_button::right); |
964 | jag | 115 | } |
116 | |||
117 | void plugin_browser::draw (curve_editor* ed) { |
||
118 | if (folded() == 0) plugins[cur]->draw (ed); |
||
119 | } |
||
120 | |||
121 | plugin* plugin_browser::get_cur () { |
||
122 | return plugins[cur]; |
||
123 | } |
||
978 | jag | 124 | |
125 | void plugin_browser::set_ed (curve_editor* e) { |
||
1226 | jag | 126 | ed = e; |
978 | jag | 127 | for (int i = 0; i < num_plugins; ++i) plugins[i]->set_ed (e); |
128 | } |