-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathbpmtext.cpp
121 lines (79 loc) · 3.07 KB
/
bpmtext.cpp
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* Copyright 2016 Kjetil S. Matheussen
This program 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 2
of the License, or (at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <math.h>
#include "nsmtracker.h"
#include "vector_proc.h"
#include "list_proc.h"
#include "realline_calc_proc.h"
#include "undo.h"
#include "undo_tempos_proc.h"
#include "tempos_proc.h"
#include "data_as_text_proc.h"
#include "player_pause_proc.h"
#include "time_proc.h"
#include "bpmtext_proc.h"
int BPMTEXT_subsubtrack(struct Tracker_Windows *window){
if (window->curr_track != TEMPOTRACK)
return -1;
int curr_track_sub = window->curr_othertrack_sub;
if (curr_track_sub < 0)
return -1;
if (curr_track_sub > 3)
return -1;
return curr_track_sub;
}
bool BPMTEXT_keypress(struct Tracker_Windows *window, struct WBlocks *wblock, int realline, const Place *place, int key){
int subsubtrack = BPMTEXT_subsubtrack(window);
if (subsubtrack==-1)
return false;
QVector<Tempos*> bpms = BPMs_get(wblock, realline);
/*
if (bpms.size() > 1) {
// MORE THAN ONE ELEMENT (treat last element instead)
if (key == EVENT_DEL){
PC_Pause();{
ListRemoveElement3(&wblock->block->tempos, &(bpms.last()->l));
UpdateSTimes(wblock->block);
}PC_StopPause(NULL);
//const struct LocalZooms lz2 = realline==wblock->num_reallines-1 ? p_Create(wblock->block->num_lines, 0, 1) : *wblock->reallines[realline+1];
//RemoveTempos(wblock->block, place, &lz2->l.p);
}else
return false;
} else
*/
if (bpms.size() == 0) {
// NO ELEMENTS
if (key == EVENT_DEL)
return true;
data_as_text_t dat = DAT_get_newvalue(subsubtrack, key, root->tempo, LOGTYPE_HOLD, 1, 999, 1, 999, false, true, false);
if (dat.is_valid==false)
return false;
ADD_UNDO(Tempos_CurrPos(window));
SetTempo(wblock->block, place, dat.value, dat.logtype);
} else {
// ONE ELEMENT (or more than one element)
struct Tempos *bpm = bpms.last();
if (key == EVENT_DEL) {
ADD_UNDO(Tempos_CurrPos(window));
RemoveTempo(wblock->block, bpm);
} else {
data_as_text_t dat = DAT_get_overwrite(bpm->tempo, bpm->logtype, subsubtrack, key, 1, 999, 1, 999, false, false);
if (dat.is_valid==false)
return false;
//printf(" LOg bef: %d, aft: %d, ", bpm->logtype, dat.logtype);
SetTempo(wblock->block, &bpm->l.p, dat.value, dat.logtype);
//printf(" aft2: %d\n", bpm->logtype);
}
}
return true;
}