mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-11 00:56:33 +01:00
mouse drag operations in beatbox
This commit is contained in:
parent
62eb966dae
commit
20047e09f2
2 changed files with 33 additions and 0 deletions
|
|
@ -451,6 +451,7 @@ StepView::StepView (SequencerGrid& sg, Step& s, ArdourCanvas::Item* parent)
|
||||||
, _step (s)
|
, _step (s)
|
||||||
, _seq (sg)
|
, _seq (sg)
|
||||||
, text (new Text (this))
|
, text (new Text (this))
|
||||||
|
, grabbed (false)
|
||||||
{
|
{
|
||||||
set_fill_color (UIConfiguration::instance().color ("selection"));
|
set_fill_color (UIConfiguration::instance().color ("selection"));
|
||||||
|
|
||||||
|
|
@ -552,6 +553,31 @@ StepView::on_event (GdkEvent *ev)
|
||||||
bool
|
bool
|
||||||
StepView::motion_event (GdkEventMotion* ev)
|
StepView::motion_event (GdkEventMotion* ev)
|
||||||
{
|
{
|
||||||
|
if (!grabbed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const double xdelta = ev->x - last_motion.first;
|
||||||
|
const double ydelta = last_motion.second - ev->y;
|
||||||
|
//const double distance = sqrt (xdelta * xdelta + ydelta * ydelta);
|
||||||
|
const double distance = ydelta;
|
||||||
|
|
||||||
|
if ((ev->state & GDK_MOD1_MASK) || _seq.mode() == SequencerGrid::Pitch) {
|
||||||
|
cerr << "adjust pitch by " << distance << endl;
|
||||||
|
adjust_step_pitch (distance);
|
||||||
|
} else if (_seq.mode() == SequencerGrid::Velocity) {
|
||||||
|
cerr << "adjust velocity by " << distance << endl;
|
||||||
|
adjust_step_velocity (distance);
|
||||||
|
} else if (_seq.mode() == SequencerGrid::Duration) {
|
||||||
|
cerr << "adjust duration by " << Step::DurationRatio (distance, 32) << endl;
|
||||||
|
adjust_step_duration (Step::DurationRatio (distance, 32)); /* adjust by 1/32 of the sequencer step size */
|
||||||
|
} else if (_seq.mode() == SequencerGrid::Octave) {
|
||||||
|
adjust_step_octave (distance);
|
||||||
|
} else if (_seq.mode() == SequencerGrid::Group) {
|
||||||
|
}
|
||||||
|
|
||||||
|
last_motion = std::make_pair (ev->x, ev->y);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -559,12 +585,17 @@ bool
|
||||||
StepView::button_press_event (GdkEventButton* ev)
|
StepView::button_press_event (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
grab_at = std::make_pair (ev->x, ev->y);
|
grab_at = std::make_pair (ev->x, ev->y);
|
||||||
|
last_motion = grab_at;
|
||||||
|
grab ();
|
||||||
|
grabbed = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
StepView::button_release_event (GdkEventButton* ev)
|
StepView::button_release_event (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
|
ungrab ();
|
||||||
|
grabbed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,8 +78,10 @@ class StepView : public ArdourCanvas::Rectangle, public sigc::trackable {
|
||||||
ARDOUR::Step& _step;
|
ARDOUR::Step& _step;
|
||||||
SequencerGrid& _seq;
|
SequencerGrid& _seq;
|
||||||
ArdourCanvas::Text* text;
|
ArdourCanvas::Text* text;
|
||||||
|
bool grabbed;
|
||||||
|
|
||||||
std::pair<double,double> grab_at;
|
std::pair<double,double> grab_at;
|
||||||
|
std::pair<double,double> last_motion;
|
||||||
|
|
||||||
bool motion_event (GdkEventMotion*);
|
bool motion_event (GdkEventMotion*);
|
||||||
bool button_press_event (GdkEventButton*);
|
bool button_press_event (GdkEventButton*);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue