locate when clicking on start/end fields in time info box

git-svn-id: svn://localhost/ardour2/branches/3.0@9683 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-06-07 18:20:22 +00:00
parent f6e67fa3dd
commit 7e2b86dc83
3 changed files with 48 additions and 29 deletions

View File

@ -889,21 +889,23 @@ AudioClock::button_press (GdkEventButton *ev, CairoCell* cell)
{
switch (ev->button) {
case 1:
if (cell) {
editing_field = (Field) cell->id ();
display->start_editing (cell);
if (editable) {
if (cell) {
editing_field = (Field) cell->id ();
display->start_editing (cell);
}
Keyboard::magic_widget_grab_focus ();
/* make absolutely sure that the pointer is grabbed */
gdk_pointer_grab(ev->window,false ,
GdkEventMask( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK |Gdk::BUTTON_RELEASE_MASK),
NULL,NULL,ev->time);
dragging = true;
drag_accum = 0;
drag_start_y = ev->y;
drag_y = ev->y;
}
Keyboard::magic_widget_grab_focus ();
/* make absolutely sure that the pointer is grabbed */
gdk_pointer_grab(ev->window,false ,
GdkEventMask( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK |Gdk::BUTTON_RELEASE_MASK),
NULL,NULL,ev->time);
dragging = true;
drag_accum = 0;
drag_start_y = ev->y;
drag_y = ev->y;
break;
default:
@ -917,23 +919,17 @@ AudioClock::button_press (GdkEventButton *ev, CairoCell* cell)
bool
AudioClock::button_release (GdkEventButton *ev, CairoCell* cell)
{
if (dragging) {
gdk_pointer_ungrab (GDK_CURRENT_TIME);
dragging = false;
if (ev->y > drag_start_y+1 || ev->y < drag_start_y-1 || Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)){
// we actually dragged so return without setting editing focus, or we shift clicked
return true;
if (editable) {
if (dragging) {
gdk_pointer_ungrab (GDK_CURRENT_TIME);
dragging = false;
if (ev->y > drag_start_y+1 || ev->y < drag_start_y-1 || Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)){
// we actually dragged so return without setting editing focus, or we shift clicked
return true;
}
}
}
if (!editable) {
if (ops_menu == 0) {
build_ops_menu ();
}
ops_menu->popup (1, ev->time);
return true;
}
if (Keyboard::is_context_menu_event (ev)) {
if (ops_menu == 0) {
build_ops_menu ();
@ -942,7 +938,7 @@ AudioClock::button_release (GdkEventButton *ev, CairoCell* cell)
return true;
}
return true;
return false;
}
bool

View File

@ -125,6 +125,12 @@ TimeInfoBox::TimeInfoBox ()
punch_start->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), punch_start));
punch_end->mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::sync_punch_mode), punch_end));
selection_start->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), selection_start), true);
selection_end->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), selection_end), true);
punch_start->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), punch_start), true);
punch_end->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &TimeInfoBox::clock_button_release_event), punch_end), true);
Editor::instance().get_selection().TimeChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed));
}
@ -138,6 +144,21 @@ TimeInfoBox::~TimeInfoBox ()
delete punch_end;
}
bool
TimeInfoBox::clock_button_release_event (GdkEventButton* ev, AudioClock* src)
{
if (!_session) {
return false;
}
if (ev->button == 1) {
_session->request_locate (src->current_time ());
return true;
}
return false;
}
void
TimeInfoBox::sync_selection_mode (AudioClock* src)
{

View File

@ -72,6 +72,8 @@ class TimeInfoBox : public Gtk::Table, public ARDOUR::SessionHandlePtr
void sync_selection_mode (AudioClock*);
void sync_punch_mode (AudioClock*);
bool clock_button_release_event (GdkEventButton* ev, AudioClock* src);
};