blob: a4e3b4753dd9ee817e5f9b9a79b37efa54a98c4d (
plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <glaurent@telegraph-road.org>,
Chris Cannam <cannam@all-day-breakfast.com>,
Richard Bown <richard.bown@ferventsoftware.com>
This file is Copyright 2003-2006
D. Michael McIntyre <dmmcintyr@users.sourceforge.net>
The moral rights of Guillaume Laurent, Chris Cannam, and Richard
Bown to claim authorship of this work have been asserted.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for details.
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. See the file
COPYING included with this distribution for more information.
*/
#ifndef _RG_EVENTFILTERDIALOG_H_
#define _RG_EVENTFILTERDIALOG_H_
#include <kdialogbase.h>
#include <utility>
#include <vector>
#include "base/Event.h"
#include <tqcheckbox.h>
#include <tqcombobox.h>
class TQWidget;
class TQSpinBox;
class TQPushButton;
class TQGridLayout;
class TDEConfig;
namespace Rosegarden
{
class Event;
/**
* Creates a dialog box to allow the user to dial up various selection
* criteria used for removing events from a selection. It is up to the caller
* to actually manipulate the selection. After the dialog has been accepted,
* its filterEvent() method can be used to decide whether a particular event
* should continue to be selected. See matrixview.cpp slotFilterSelection()
* for an example of how to use this.
*/
class EventFilterDialog : public KDialogBase
{
TQ_OBJECT
public:
EventFilterDialog(TQWidget* parent);
~EventFilterDialog();
TDEConfig *cfg;
//-------[ accessor functions ]------------------------
// NOTE: the filterRange type is used to return an A B pair with A and B set
// according to the state of the related include/exclude combo. If A > B
// then this is an inclusive range. If A < B then it's an exclusive
// range. This saves passing around a third variable.
typedef std::pair<long, long> filterRange;
filterRange getPitch();
filterRange getVelocity();
filterRange getDuration();
// returns true if the property value falls with in the filterRange
bool eventInRange(filterRange foo, long property) {
if (foo.first > foo.second)
return (property <= foo.second || property >= foo.first);
else
return (property >= foo.first && property <= foo.second); }
// Used to do the work of deciding whether to keep or reject an event
// based on the state of the dialog's widgets. Returns true if an event
// should continue to be selected. This method is the heart of the
// EventFilterDialog's public interface.
bool keepEvent(Event* const &e);
protected:
//--------[ member functions ]-------------------------
// initialize the dialog
void initDialog();
// populate the duration combos
void populateDurationCombos();
// convert duration from combobox index into actual RG duration
// between 0 and LONG_MAX
long getDurationFromIndex(int index);
// simple A B swap used to flip inclusive/exclusive values
void invert (filterRange &);
// return inclusive/exclusive toggle states concisely for tidy code
bool pitchIsInclusive() { return (m_notePitchIncludeComboBox->currentItem() == 0); }
bool velocityIsInclusive() { return (m_noteVelocityIncludeComboBox->currentItem() == 0); }
bool durationIsInclusive() { return (m_noteDurationIncludeComboBox->currentItem() == 0); }
protected slots:
// set widget values to include everything
void slotToggleAll();
// set widget values to include nothing
void slotToggleNone();
// write out settings to tdeconfig data for next time and call accept()
virtual void slotOk();
// update note name text display and ensure From <= To
void slotPitchFromChanged(int pitch);
void slotPitchToChanged(int pitch);
// ensure From <= To to guarantee a logical range for these sets
void slotVelocityFromChanged(int velocity);
void slotVelocityToChanged(int velocity);
void slotDurationFromChanged(int index);
void slotDurationToChanged(int index);
// create a pitch chooser widget sub-dialog to show pitch on staff
void slotPitchFromChooser();
void slotPitchToChooser();
private:
//---------[ data members ]-----------------------------
TQGridLayout* layout;
TQComboBox* m_noteDurationFromComboBox;
TQComboBox* m_noteDurationIncludeComboBox;
TQComboBox* m_noteDurationToComboBox;
TQComboBox* m_notePitchIncludeComboBox;
TQComboBox* m_noteVelocityIncludeComboBox;
TQPushButton* m_pitchFromChooserButton;
TQPushButton* m_pitchToChooserButton;
TQPushButton* m_buttonAll;
TQPushButton* m_buttonNone;
TQSpinBox* m_pitchFromSpinBox;
TQSpinBox* m_pitchToSpinBox;
TQSpinBox* m_velocityFromSpinBox;
TQSpinBox* m_velocityToSpinBox;
std::vector<timeT> m_standardQuantizations;
};
}
#endif
|