1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/* ---------------------------------------------------------------------
*
* Giada - Your Hardcore Loopmachine
*
* gd_bpmInput
*
* ---------------------------------------------------------------------
*
* Copyright (C) 2010-2015 Giovanni A. Zuliani | Monocasual
*
* This file is part of Giada - Your Hardcore Loopmachine.
*
* Giada - Your Hardcore Loopmachine is free software: you can
* redistribute it and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* Giada - Your Hardcore Loopmachine is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Giada - Your Hardcore Loopmachine. If not, see
* <http://www.gnu.org/licenses/>.
*
* ------------------------------------------------------------------ */
#include "../../core/conf.h"
#include "../../core/mixer.h"
#include "../../glue/glue.h"
#include "../../utils/gui_utils.h"
#include "../elems/ge_mixed.h"
#include "gd_bpmInput.h"
#include "gd_mainWindow.h"
extern Mixer G_Mixer;
extern Conf G_Conf;
extern gdMainWindow *mainWin;
gdBpmInput::gdBpmInput(const char *label)
: gWindow(144, 36, "Bpm") {
if (G_Conf.bpmX)
resize(G_Conf.bpmX, G_Conf.bpmY, w(), h());
set_modal();
input_a = new gInput(8, 8, 30, 20);
input_b = new gInput(42, 8, 20, 20);
ok = new gClick(66, 8, 70, 20, "Ok");
end();
char a[4];
snprintf(a, 4, "%d", (int) G_Mixer.bpm);
char b[2];
for (unsigned i=0; i<strlen(label); i++) // looking for the dot
if (label[i] == '.') {
snprintf(b, 2, "%c", label[i+1]);
break;
}
input_a->maximum_size(3);
input_a->type(FL_INT_INPUT);
input_a->value(a);
input_b->maximum_size(1);
input_b->type(FL_INT_INPUT);
input_b->value(b);
ok->shortcut(FL_Enter);
ok->callback(cb_update_bpm, (void*)this);
gu_setFavicon(this);
setId(WID_BPM);
show();
}
/* ------------------------------------------------------------------ */
gdBpmInput::~gdBpmInput() {
G_Conf.bpmX = x();
G_Conf.bpmY = y();
}
/* ------------------------------------------------------------------ */
void gdBpmInput::cb_update_bpm(Fl_Widget *w, void *p) { ((gdBpmInput*)p)->__cb_update_bpm(); }
/* ------------------------------------------------------------------ */
void gdBpmInput::__cb_update_bpm() {
if (strcmp(input_a->value(), "") == 0)
return;
glue_setBpm(input_a->value(), input_b->value());
do_callback();
}
|