Update Location UI to include section marker flags
This commit is contained in:
parent
3aadf2daf0
commit
1f772d30d3
@ -21,9 +21,13 @@
|
||||
#include "ardour/session.h"
|
||||
#include "pbd/unwind.h"
|
||||
|
||||
#include "gtkmm2ext/keyboard.h"
|
||||
|
||||
#include "ardour_ui.h"
|
||||
#include "editor_sections.h"
|
||||
#include "gui_thread.h"
|
||||
#include "keyboard.h"
|
||||
#include "main_clock.h"
|
||||
#include "public_editor.h"
|
||||
#include "utils.h"
|
||||
|
||||
@ -35,11 +39,14 @@ using namespace Gtk;
|
||||
using namespace ARDOUR;
|
||||
|
||||
EditorSections::EditorSections ()
|
||||
: _ignore_redisplay (false)
|
||||
: _old_focus (0)
|
||||
, _no_redisplay (false)
|
||||
{
|
||||
_model = ListStore::create (_columns);
|
||||
_view.set_model (_model);
|
||||
_view.append_column (_("Name"), _columns.name);
|
||||
_view.append_column (_("Start"), _columns.s_start);
|
||||
_view.append_column (_("End"), _columns.s_end);
|
||||
_view.set_headers_visible (true);
|
||||
_view.get_selection ()->set_mode (Gtk::SELECTION_SINGLE);
|
||||
|
||||
@ -61,6 +68,14 @@ EditorSections::EditorSections ()
|
||||
_view.signal_drag_motion ().connect (sigc::mem_fun (*this, &EditorSections::drag_motion));
|
||||
_view.signal_drag_leave ().connect (sigc::mem_fun (*this, &EditorSections::drag_leave));
|
||||
_view.signal_drag_data_received ().connect (sigc::mem_fun (*this, &EditorSections::drag_data_received));
|
||||
|
||||
/* Allow to scroll using key up/down */
|
||||
_view.signal_enter_notify_event ().connect (sigc::mem_fun (*this, &EditorSections::enter_notify), false);
|
||||
_view.signal_leave_notify_event ().connect (sigc::mem_fun (*this, &EditorSections::leave_notify), false);
|
||||
_scroller.signal_focus_in_event ().connect (sigc::mem_fun (*this, &EditorSections::focus_in), false);
|
||||
_scroller.signal_focus_out_event ().connect (sigc::mem_fun (*this, &EditorSections::focus_out));
|
||||
|
||||
ARDOUR_UI::instance ()->primary_clock->mode_changed.connect (sigc::mem_fun (*this, &EditorSections::clock_format_changed));
|
||||
}
|
||||
|
||||
void
|
||||
@ -85,7 +100,7 @@ EditorSections::set_session (Session* s)
|
||||
void
|
||||
EditorSections::redisplay ()
|
||||
{
|
||||
if (_ignore_redisplay) {
|
||||
if (_no_redisplay) {
|
||||
return;
|
||||
}
|
||||
_view.set_model (Glib::RefPtr<ListStore> ());
|
||||
@ -112,9 +127,28 @@ EditorSections::redisplay ()
|
||||
}
|
||||
} while (l);
|
||||
|
||||
clock_format_changed ();
|
||||
|
||||
_view.set_model (_model);
|
||||
}
|
||||
|
||||
void
|
||||
EditorSections::clock_format_changed ()
|
||||
{
|
||||
if (!_session) {
|
||||
return;
|
||||
}
|
||||
|
||||
TreeModel::Children rows = _model->children ();
|
||||
for (auto const& r : rows) {
|
||||
char buf[16];
|
||||
ARDOUR_UI_UTILS::format_position (_session, r[_columns.start], buf, sizeof (buf));
|
||||
r[_columns.s_start] = buf;
|
||||
ARDOUR_UI_UTILS::format_position (_session, r[_columns.end], buf, sizeof (buf));
|
||||
r[_columns.s_end] = buf;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
EditorSections::scroll_row_timeout ()
|
||||
{
|
||||
@ -296,10 +330,10 @@ EditorSections::drag_data_received (Glib::RefPtr<Gdk::DragContext> const& contex
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
cout << "cut copy '" << s.location->name () << "' " << s.start << " - " << s.end << " to " << to << "\n";
|
||||
cout << "cut copy '" << s.location->name () << "' " << s.start << " - " << s.end << " to " << to << " op = " << op << "\n";
|
||||
#endif
|
||||
{
|
||||
PBD::Unwinder<bool> uw (_ignore_redisplay, true);
|
||||
PBD::Unwinder<bool> uw (_no_redisplay, true);
|
||||
_session->cut_copy_section (s.start, s.end, to, op);
|
||||
}
|
||||
redisplay ();
|
||||
@ -329,9 +363,56 @@ EditorSections::key_release (GdkEventKey* ev)
|
||||
timepos_t start = row[_columns.start];
|
||||
timepos_t end = row[_columns.end];
|
||||
{
|
||||
PBD::Unwinder<bool> uw (_ignore_redisplay, true);
|
||||
PBD::Unwinder<bool> uw (_no_redisplay, true);
|
||||
_session->cut_copy_section (start, end, timepos_t (0), DeleteSection);
|
||||
}
|
||||
redisplay ();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
EditorSections::focus_in (GdkEventFocus*)
|
||||
{
|
||||
Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
|
||||
|
||||
if (win) {
|
||||
_old_focus = win->get_focus ();
|
||||
} else {
|
||||
_old_focus = 0;
|
||||
}
|
||||
|
||||
/* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
EditorSections::focus_out (GdkEventFocus*)
|
||||
{
|
||||
if (_old_focus) {
|
||||
_old_focus->grab_focus ();
|
||||
_old_focus = 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
EditorSections::enter_notify (GdkEventCrossing*)
|
||||
{
|
||||
Gtkmm2ext::Keyboard::magic_widget_grab_focus ();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
EditorSections::leave_notify (GdkEventCrossing* ev)
|
||||
{
|
||||
if (_old_focus) {
|
||||
_old_focus->grab_focus ();
|
||||
_old_focus = 0;
|
||||
}
|
||||
|
||||
if (ev->detail != GDK_NOTIFY_INFERIOR && ev->detail != GDK_NOTIFY_ANCESTOR) {
|
||||
Gtkmm2ext::Keyboard::magic_widget_drop_focus ();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -50,6 +50,12 @@ private:
|
||||
bool key_release (GdkEventKey*);
|
||||
void selection_changed ();
|
||||
bool scroll_row_timeout ();
|
||||
void clock_format_changed ();
|
||||
|
||||
bool focus_in (GdkEventFocus*);
|
||||
bool focus_out (GdkEventFocus*);
|
||||
bool enter_notify (GdkEventCrossing*);
|
||||
bool leave_notify (GdkEventCrossing*);
|
||||
|
||||
struct Section {
|
||||
Section ()
|
||||
@ -75,11 +81,15 @@ private:
|
||||
Columns ()
|
||||
{
|
||||
add (name);
|
||||
add (s_start);
|
||||
add (s_end);
|
||||
add (location);
|
||||
add (start);
|
||||
add (end);
|
||||
}
|
||||
Gtk::TreeModelColumn<std::string> name;
|
||||
Gtk::TreeModelColumn<std::string> s_start;
|
||||
Gtk::TreeModelColumn<std::string> s_end;
|
||||
Gtk::TreeModelColumn<ARDOUR::Location*> location;
|
||||
Gtk::TreeModelColumn<Temporal::timepos_t> start;
|
||||
Gtk::TreeModelColumn<Temporal::timepos_t> end;
|
||||
@ -89,8 +99,9 @@ private:
|
||||
Glib::RefPtr<Gtk::ListStore> _model;
|
||||
Gtk::TreeView _view;
|
||||
Gtk::ScrolledWindow _scroller;
|
||||
Gtk::Widget* _old_focus;
|
||||
|
||||
bool _ignore_redisplay;
|
||||
bool _no_redisplay;
|
||||
sigc::connection _scroll_timeout;
|
||||
};
|
||||
|
||||
|
@ -65,6 +65,7 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
|
||||
, locate_to_end_button (_("Goto"))
|
||||
, length_clock (X_("locationlength"), true, "", true, false, true)
|
||||
, cd_check_button (_("CD"))
|
||||
, section_check_button (_("Sect."))
|
||||
, hide_check_button (_("Hide"))
|
||||
, lock_check_button (_("Lock"))
|
||||
, _clock_group (0)
|
||||
@ -80,6 +81,7 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
|
||||
name_label.set_name ("LocationEditNameLabel");
|
||||
name_entry.set_name ("LocationEditNameEntry");
|
||||
cd_check_button.set_name ("LocationEditCdButton");
|
||||
section_check_button.set_name ("LocationEditSectionButton");
|
||||
hide_check_button.set_name ("LocationEditHideButton");
|
||||
lock_check_button.set_name ("LocationEditLockButton");
|
||||
isrc_label.set_name ("LocationEditNumberLabel");
|
||||
@ -164,6 +166,7 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
|
||||
length_clock.ValueChanged.connect (sigc::bind ( sigc::mem_fun(*this, &LocationEditRow::clock_changed), LocLength));
|
||||
|
||||
cd_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::cd_toggled));
|
||||
section_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::section_toggled));
|
||||
hide_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::hide_toggled));
|
||||
lock_check_button.signal_toggled().connect(sigc::mem_fun(*this, &LocationEditRow::lock_toggled));
|
||||
|
||||
@ -283,20 +286,21 @@ LocationEditRow::set_location (Location *loc)
|
||||
name_entry.show();
|
||||
|
||||
if (!cd_check_button.get_parent()) {
|
||||
item_table.attach (cd_check_button, 4, 5, 0, 1, FILL, Gtk::AttachOptions (0), 4, 0);
|
||||
item_table.attach (cd_check_button, 3, 4, 0, 1, FILL, Gtk::AttachOptions (0), 4, 0);
|
||||
}
|
||||
|
||||
if (!section_check_button.get_parent()) {
|
||||
item_table.attach (section_check_button, 4, 5, 0, 1, FILL, Gtk::AttachOptions (0), 4, 0);
|
||||
}
|
||||
|
||||
if (location->is_session_range()) {
|
||||
remove_button.set_sensitive (false);
|
||||
}
|
||||
|
||||
if (location->is_cue_marker()) {
|
||||
cd_check_button.set_sensitive (false);
|
||||
}
|
||||
flags_changed ();
|
||||
|
||||
cd_check_button.set_active (location->is_cd_marker());
|
||||
cd_check_button.show();
|
||||
|
||||
section_check_button.show();
|
||||
hide_check_button.show();
|
||||
lock_check_button.show();
|
||||
}
|
||||
@ -534,6 +538,15 @@ LocationEditRow::cd_toggled ()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LocationEditRow::section_toggled ()
|
||||
{
|
||||
if (i_am_the_modifier || !location) {
|
||||
return;
|
||||
}
|
||||
location->set_section (section_check_button.get_active());
|
||||
}
|
||||
|
||||
void
|
||||
LocationEditRow::hide_toggled ()
|
||||
{
|
||||
@ -667,8 +680,23 @@ LocationEditRow::flags_changed ()
|
||||
i_am_the_modifier++;
|
||||
|
||||
cd_check_button.set_active (location->is_cd_marker());
|
||||
section_check_button.set_active (location->is_section());
|
||||
hide_check_button.set_active (location->is_hidden());
|
||||
|
||||
if (location->is_cue_marker()) {
|
||||
cd_check_button.set_sensitive (false);
|
||||
section_check_button.set_sensitive (false);
|
||||
} else if (location->is_section()) {
|
||||
cd_check_button.set_sensitive (false);
|
||||
section_check_button.set_sensitive (true);
|
||||
} else if (location->is_cd_marker()) {
|
||||
cd_check_button.set_sensitive (true);
|
||||
section_check_button.set_sensitive (false);
|
||||
} else {
|
||||
cd_check_button.set_sensitive (true);
|
||||
section_check_button.set_sensitive (true);
|
||||
}
|
||||
|
||||
i_am_the_modifier--;
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,7 @@ protected:
|
||||
|
||||
AudioClock length_clock;
|
||||
Gtk::CheckButton cd_check_button;
|
||||
Gtk::CheckButton section_check_button;
|
||||
Gtk::CheckButton hide_check_button;
|
||||
Gtk::CheckButton lock_check_button;
|
||||
|
||||
@ -131,6 +132,7 @@ protected:
|
||||
bool locate_to_clock (GdkEventButton*, AudioClock*);
|
||||
|
||||
void cd_toggled ();
|
||||
void section_toggled ();
|
||||
void hide_toggled ();
|
||||
void lock_toggled ();
|
||||
void remove_button_pressed ();
|
||||
|
Loading…
Reference in New Issue
Block a user