Compare commits

...

10 commits

Author SHA1 Message Date
Robin Gareus
b51621a1ae
Fix assert() when using DnD to import MIDI files
When importing a multi-track MIDI files with identical track-names,
Ardour would create the same file for each track. Effectively
overwriting an existing file.

The following MIDI file would create the same file twice
in `interchange/`, once for each MTrk.

```
MFile 1 2 240
MTrk
0 Meta SeqName "Foo Bar"
0 TimeSig 4/4 24 8
0 Tempo 666667
0 Meta TrkEnd
TrkEnd
MTrk
0 Meta TrkName "Foo Bar"
0 On ch=10 n=36 v=95
...
```
2022-01-19 19:22:51 +01:00
Robin Gareus
50bccb44d5
Add static meta-data for x-ardour/region.pbdid DnD
During drag-motion callbacks the data to be dragged is n/a.
However we like to discriminate if drop is possible.

When dragging regions, the data-type of the region to be dragged
is unknown, so different `x-ardour/region` targets are not an
option, either.

Until a better option is presented, a static global is used
to set the data-type for region.pbdid drags.
2022-01-19 17:13:51 +01:00
Robin Gareus
62a098811c
Allow DnDTreeView drag w/o object reference 2022-01-19 17:13:51 +01:00
Robin Gareus
d4b436b4c5
Add SourceList to TriggerPage 2022-01-19 17:13:51 +01:00
Robin Gareus
c0ac99003b
Add RegionList to TriggerPage 2022-01-19 17:13:51 +01:00
Robin Gareus
37877fbdc2
Unify Source and RegionList abstraction 2022-01-19 17:13:51 +01:00
Robin Gareus
0204ea1f24
Unify Region Drag/Drop
Identify Regions using PDB::ID. This allows dragging regions
from almost anywhere to anywhere, without special cases.
2022-01-19 17:13:51 +01:00
Robin Gareus
5427cec821
Separate RegionList into a case-class for reusing in on the TriggerPage 2022-01-19 17:13:50 +01:00
Robin Gareus
9886d6c19e
Allow to disable clang_compilation_database
See also af69061644 and b8e1cd53c. This can be useful in
some cases where running a dry-run build will fail.
e.g. with --freedesktop files that are not generated before the
actual build.
2022-01-19 17:12:36 +01:00
Paul Davis
41ade3b024 add a distinct Marker type enum for cue markers
Plan is to change the shape before this is considered done; for now
it uses the same shape as a regular marker
2022-01-19 09:06:38 -07:00
27 changed files with 1722 additions and 2237 deletions

View file

@ -2581,7 +2581,6 @@ Editor::set_state (const XMLNode& node, int version)
XMLNodeList children = node.children ();
for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
selection->set_state (**i, Stateful::current_state_version);
_regions->set_state (**i);
_locations->set_state (**i);
}
@ -2683,7 +2682,6 @@ Editor::get_state ()
node->set_property (X_("show-touched-automation"), _show_touched_automation);
node->add_child_nocopy (selection->get_state ());
node->add_child_nocopy (_regions->get_state ());
node->set_property ("nudge-clock-value", nudge_clock->current_duration());
@ -5877,16 +5875,6 @@ Editor::consider_auditioning (boost::shared_ptr<Region> region)
last_audition_region = r;
}
boost::shared_ptr<ARDOUR::Region>
Editor::get_dragged_region_from_sidebar ()
{
boost::shared_ptr<ARDOUR::Region> rv = _regions->get_dragged_region ();
if (!rv) {
rv = _sources->get_dragged_region ();
}
return rv;
}
void
Editor::hide_a_region (boost::shared_ptr<Region> r)
{
@ -6215,8 +6203,6 @@ Editor::session_going_away ()
/* rip everything out of the list displays */
_regions->clear ();
_sources->clear ();
_routes->clear ();
_route_groups->clear ();

View file

@ -226,8 +226,6 @@ public:
void hide_a_region (boost::shared_ptr<ARDOUR::Region>);
void show_a_region (boost::shared_ptr<ARDOUR::Region>);
boost::shared_ptr<ARDOUR::Region> get_dragged_region_from_sidebar ();
#ifdef USE_RUBBERBAND
std::vector<std::string> rb_opt_strings;
int rb_current_opt;
@ -2123,16 +2121,7 @@ private:
gint y,
const Gtk::SelectionData& data,
guint info,
guint time,
bool from_region_list);
void drop_routes (
const Glib::RefPtr<Gdk::DragContext>& context,
gint x,
gint y,
const Gtk::SelectionData& data,
guint info,
guint time);
guint time);
/* audio export */

View file

@ -268,8 +268,7 @@ Editor::initialize_canvas ()
vector<TargetEntry> target_table;
target_table.push_back (TargetEntry ("x-ardour/region.erl", TARGET_SAME_APP)); // DnD from the region list will generate this target
target_table.push_back (TargetEntry ("x-ardour/region.esl", TARGET_SAME_APP)); // DnD from the source list will generate this target
target_table.push_back (TargetEntry ("x-ardour/region.pbdid", TARGET_SAME_APP));
target_table.push_back (TargetEntry ("text/uri-list"));
target_table.push_back (TargetEntry ("text/plain"));
target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
@ -391,10 +390,8 @@ Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context
if (!ARDOUR_UI_UTILS::engine_is_running ()) {
return;
}
if (data.get_target() == "x-ardour/region.erl") {
drop_regions (context, x, y, data, info, time, true);
} else if (data.get_target() == "x-ardour/region.esl") {
drop_regions (context, x, y, data, info, time, false);
if (data.get_target() == "x-ardour/region.pbdid") {
drop_regions (context, x, y, data, info, time);
} else {
drop_paths (context, x, y, data, info, time);
}
@ -435,7 +432,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, timepos_t const & p, d
/* drop onto canvas background: create new tracks */
InstrumentSelector is; // instantiation builds instrument-list and sets default.
do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, SMFTrackName, SMFTempoIgnore, pos, is.selected_instrument(), false);
do_import (midi_paths, Editing::ImportDistinctFiles, ImportAsTrack, SrcBest, SMFTrackNumber, SMFTempoIgnore, pos, is.selected_instrument(), false);
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
do_import (audio_paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack,
@ -453,7 +450,7 @@ Editor::drop_paths_part_two (const vector<string>& paths, timepos_t const & p, d
selection->set (tv);
do_import (midi_paths, Editing::ImportSerializeFiles, ImportToTrack,
SrcBest, SMFTrackName, SMFTempoIgnore, pos);
SrcBest, SMFTrackNumber, SMFTempoIgnore, pos);
if (UIConfiguration::instance().get_only_copy_imported_files() || copy) {
do_import (audio_paths, Editing::ImportSerializeFiles, Editing::ImportToTrack,

View file

@ -1210,37 +1210,17 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
if (can_drop) {
if (target == "x-ardour/region.erl") {
region = _regions->get_dragged_region ();
} else if (target == "x-ardour/region.esl") {
region = _sources->get_dragged_region ();
}
if (region) {
if (tv.first == 0
&& (
boost::dynamic_pointer_cast<AudioRegion> (region) != 0 ||
boost::dynamic_pointer_cast<MidiRegion> (region) != 0
)
)
{
if (target == "x-ardour/region.pbdid") {
if (tv.first == 0 && pbdid_dragged_dt != DataType::NIL) {
/* drop to drop-zone */
context->drag_status (context->get_suggested_action(), time);
context->drag_status (Gdk::ACTION_COPY, time);
return true;
}
if ((boost::dynamic_pointer_cast<AudioRegion> (region) != 0 &&
dynamic_cast<AudioTimeAxisView*> (tv.first) != 0) ||
(boost::dynamic_pointer_cast<MidiRegion> (region) != 0 &&
dynamic_cast<MidiTimeAxisView*> (tv.first) != 0)) {
/* audio to audio
OR
midi to midi
*/
context->drag_status (context->get_suggested_action(), time);
if ((pbdid_dragged_dt == DataType::AUDIO && dynamic_cast<AudioTimeAxisView*> (tv.first) != 0) ||
(pbdid_dragged_dt == DataType::MIDI && dynamic_cast<MidiTimeAxisView*> (tv.first) != 0)) {
/* audio to audio OR MIDI to MIDI */
context->drag_status (Gdk::ACTION_COPY, time);
return true;
}
} else {
@ -1270,9 +1250,8 @@ Editor::track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context,
void
Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
int x, int y,
const SelectionData& /*data*/,
guint /*info*/, guint /*time*/,
bool from_region_list)
const SelectionData& data,
guint /*info*/, guint /*time*/)
{
GdkEvent event;
double px;
@ -1285,13 +1264,8 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
event.motion.state = Gdk::BUTTON1_MASK;
samplepos_t const pos = window_event_sample (&event, &px, &py);
boost::shared_ptr<Region> region;
if (from_region_list) {
region = _regions->get_dragged_region ();
} else {
region = _sources->get_dragged_region ();
}
PBD::ID rid (data.get_data_as_string ());
boost::shared_ptr<Region> region = RegionFactory::region_by_id (rid);
if (!region) { return; }

View file

@ -122,7 +122,7 @@ Editor::add_new_location_internal (Location* location)
lam->start = new ArdourMarker (*this, *cd_marker_group, color, location->name(), ArdourMarker::Mark, location->start());
group = cd_marker_group;
} else if (location->is_cue_marker() && ruler_cue_marker_action->get_active()) {
lam->start = new ArdourMarker (*this, *cue_marker_group, color, location->name(), ArdourMarker::Mark, location->start());
lam->start = new ArdourMarker (*this, *cue_marker_group, color, location->name(), ArdourMarker::Cue, location->start());
group = cue_marker_group;
} else {
lam->start = new ArdourMarker (*this, *marker_group, color, location->name(), ArdourMarker::Mark, location->start());

File diff suppressed because it is too large Load diff

View file

@ -3,6 +3,7 @@
* Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
* Copyright (C) 2009-2018 Paul Davis <paul@linuxaudiosystems.com>
* Copyright (C) 2018 Ben Loftis <ben@harrisonconsoles.com>
* Copyright (C) 2021 Robin Gareus <robin@gareus.org>
*
* 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
@ -21,188 +22,34 @@
#ifndef __gtk_ardour_editor_regions_h__
#define __gtk_ardour_editor_regions_h__
#include <boost/unordered_map.hpp>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/treemodel.h>
#include <gtkmm/treerowreference.h>
#include <gtkmm/treestore.h>
#include "editor_component.h"
#include "region_list_base.h"
#include "region_selection.h"
class EditorRegions : public EditorComponent, public ARDOUR::SessionHandlePtr
class EditorRegions : public EditorComponent, public RegionListBase
{
public:
EditorRegions (Editor *);
void set_session (ARDOUR::Session *);
Gtk::Widget& widget () {
return _scroller;
}
void clear ();
void set_selected (RegionSelection &);
void selection_mapover (sigc::slot<void,boost::shared_ptr<ARDOUR::Region> >);
boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
boost::shared_ptr<ARDOUR::Region> get_single_selection ();
void redisplay ();
void suspend_redisplay () {
_no_redisplay = true;
}
void resume_redisplay () {
_no_redisplay = false;
redisplay ();
}
void block_change_connection (bool b) {
_change_connection.block (b);
}
void unselect_all () {
_display.get_selection()->unselect_all ();
}
EditorRegions (Editor*);
void set_selected (RegionSelection&);
void selection_mapover (sigc::slot<void, boost::shared_ptr<ARDOUR::Region>>);
void remove_unused_regions ();
XMLNode& get_state () const;
void set_state (const XMLNode &);
boost::shared_ptr<ARDOUR::Region> get_single_selection ();
void unselect_all ()
{
_display.get_selection ()->unselect_all ();
}
protected:
void regions_changed (boost::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const&);
private:
struct Columns : public Gtk::TreeModel::ColumnRecord {
Columns () {
add (name);
add (channels);
add (tags);
add (start);
add (length);
add (end);
add (sync);
add (fadein);
add (fadeout);
add (locked);
add (glued);
add (muted);
add (opaque);
add (path);
add (region);
add (color_);
add (position);
}
Gtk::TreeModelColumn<std::string> name;
Gtk::TreeModelColumn<int> channels;
Gtk::TreeModelColumn<std::string> tags;
Gtk::TreeModelColumn<Temporal::timepos_t> position;
Gtk::TreeModelColumn<std::string> start;
Gtk::TreeModelColumn<std::string> end;
Gtk::TreeModelColumn<std::string> length;
Gtk::TreeModelColumn<std::string> sync;
Gtk::TreeModelColumn<std::string> fadein;
Gtk::TreeModelColumn<std::string> fadeout;
Gtk::TreeModelColumn<bool> locked;
Gtk::TreeModelColumn<bool> glued;
Gtk::TreeModelColumn<bool> muted;
Gtk::TreeModelColumn<bool> opaque;
Gtk::TreeModelColumn<std::string> path;
Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
Gtk::TreeModelColumn<Gdk::Color> color_;
};
Columns _columns;
Gtk::TreeModel::RowReference last_row;
void freeze_tree_model ();
void thaw_tree_model ();
void regions_changed (boost::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const &);
void init ();
void selection_changed ();
sigc::connection _change_connection;
int _sort_col_id;
Gtk::SortType _sort_type;
bool selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);
Gtk::Widget* old_focus;
Gtk::CellEditable* name_editable;
void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
void name_edit (const std::string&, const std::string&);
Gtk::CellEditable* tags_editable;
void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&);
void tag_edit (const std::string&, const std::string&);
void locked_changed (std::string const &);
void glued_changed (std::string const &);
void muted_changed (std::string const &);
void opaque_changed (std::string const &);
bool key_press (GdkEventKey *);
bool button_press (GdkEventButton *);
bool focus_in (GdkEventFocus*);
bool focus_out (GdkEventFocus*);
bool enter_notify (GdkEventCrossing*);
bool leave_notify (GdkEventCrossing*);
bool button_press (GdkEventButton*);
void show_context_menu (int button, int time);
void format_position (Temporal::timepos_t const & pos, char* buf, size_t bufsize, bool onoff = true);
void add_region (boost::shared_ptr<ARDOUR::Region>);
void destroy_region (boost::shared_ptr<ARDOUR::Region>);
void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, PBD::PropertyChange const &);
void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_length (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void update_row (boost::shared_ptr<ARDOUR::Region>);
void clock_format_changed ();
Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const;
Gtk::Menu* _menu;
Gtk::ScrolledWindow _scroller;
Gtk::Frame _frame;
Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
Glib::RefPtr<Gtk::TreeStore> _model;
bool _no_redisplay;
typedef boost::unordered_map<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> RegionRowMap;
RegionRowMap region_row_map;
PBD::ScopedConnection region_property_connection;
PBD::ScopedConnection check_new_region_connection;
PBD::ScopedConnection editor_freeze_connection;
PBD::ScopedConnection editor_thaw_connection;
};
#endif /* __gtk_ardour_editor_regions_h__ */

File diff suppressed because it is too large Load diff

View file

@ -18,137 +18,29 @@
#ifndef __gtk_ardour_editor_sources_h__
#define __gtk_ardour_editor_sources_h__
#include <boost/unordered_map.hpp>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/treemodel.h>
#include <gtkmm/treerowreference.h>
#include <gtkmm/treestore.h>
#include "editor_component.h"
#include "source_list_base.h"
#include "selection.h"
class EditorSources : public EditorComponent, public ARDOUR::SessionHandlePtr
class EditorSources : public EditorComponent, public SourceListBase
{
public:
EditorSources (Editor *);
EditorSources (Editor*);
void set_session (ARDOUR::Session *);
Gtk::Widget& widget () {
return _scroller;
}
void clear ();
boost::shared_ptr<ARDOUR::Region> get_dragged_region ();
boost::shared_ptr<ARDOUR::Region> get_single_selection ();
void unselect_all () {
_display.get_selection()->unselect_all ();
}
/* user actions */
void remove_selected_sources ();
void recover_selected_sources();
XMLNode& get_state () const;
void set_state (const XMLNode &);
void recover_selected_sources ();
private:
struct Columns : public Gtk::TreeModel::ColumnRecord {
Columns () {
add (name);
add (channels);
add (captd_for);
add (tags);
add (take_id);
add (natural_pos);
add (path);
add (color_);
add (region);
add (natural_s);
add (captd_xruns);
}
Gtk::TreeModelColumn<std::string> name;
Gtk::TreeModelColumn<int> channels;
Gtk::TreeModelColumn<std::string> captd_for;
Gtk::TreeModelColumn<std::string> tags;
Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region> > region;
Gtk::TreeModelColumn<Gdk::Color> color_;
Gtk::TreeModelColumn<std::string> natural_pos;
Gtk::TreeModelColumn<std::string> path;
Gtk::TreeModelColumn<std::string> take_id;
Gtk::TreeModelColumn<Temporal::timepos_t> natural_s;
Gtk::TreeModelColumn<size_t> captd_xruns;
};
Columns _columns;
Gtk::TreeModel::RowReference last_row;
void freeze_tree_model ();
void thaw_tree_model ();
void regions_changed (boost::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const&);
void populate_row (Gtk::TreeModel::Row row, boost::shared_ptr<ARDOUR::Region> region);
void selection_changed ();
sigc::connection _change_connection;
int _sort_col_id;
Gtk::SortType _sort_type;
Gtk::Widget* old_focus;
Gtk::CellEditable* tags_editable;
void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&);
void tag_edit (const std::string&, const std::string&);
Gtk::CellEditable* name_editable;
void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
void name_edit (const std::string&, const std::string&);
bool key_press (GdkEventKey *);
bool button_press (GdkEventButton *);
bool focus_in (GdkEventFocus*);
bool focus_out (GdkEventFocus*);
bool enter_notify (GdkEventCrossing*);
bool leave_notify (GdkEventCrossing*);
void init ();
bool key_press (GdkEventKey*);
bool button_press (GdkEventButton*);
void show_context_menu (int button, int time);
void format_position (Temporal::timepos_t const & pos, char* buf, size_t bufsize, bool onoff = true);
void selection_changed ();
void add_source (boost::shared_ptr<ARDOUR::Region>);
void remove_source (boost::shared_ptr<ARDOUR::Source>);
void remove_weak_region (boost::weak_ptr<ARDOUR::Region>);
void remove_weak_source (boost::weak_ptr<ARDOUR::Source>);
void clock_format_changed ();
void redisplay ();
void drag_data_received (
Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
);
Gtk::ScrolledWindow _scroller;
Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > _display;
Glib::RefPtr<Gtk::TreeStore> _model;
PBD::ScopedConnection source_property_connection;
PBD::ScopedConnection add_source_connection;
PBD::ScopedConnection remove_source_connection;
PBD::ScopedConnectionList remove_region_connections;
PBD::ScopedConnection editor_freeze_connection;
PBD::ScopedConnection editor_thaw_connection;
void drag_data_received (Glib::RefPtr<Gdk::DragContext> const&, gint, gint, Gtk::SelectionData const&, guint, guint);
};
#endif

View file

@ -167,6 +167,8 @@ ArdourMarker::ArdourMarker (PublicEditor& ed, ArdourCanvas::Item& parent, guint3
* \ |
* MH,MH
*
* Cue:
* ben: put your shape here :)
*/
switch (type) {
@ -268,6 +270,20 @@ ArdourMarker::ArdourMarker (PublicEditor& ed, ArdourCanvas::Item& parent, guint3
_label_offset = 0.0;
break;
case Cue:
/* ben: new shape needed here */
points = new ArdourCanvas::Points ();
points->push_back (ArdourCanvas::Duple (0.0, 0.0));
points->push_back (ArdourCanvas::Duple ( M6, 0.0));
points->push_back (ArdourCanvas::Duple ( M6, MH * .4));
points->push_back (ArdourCanvas::Duple ( M3, MH));
points->push_back (ArdourCanvas::Duple (0.0, MH * .4));
points->push_back (ArdourCanvas::Duple (0.0, 0.0));
_shift = 3;
_label_offset = 10.0;
break;
}
_position = pos;

View file

@ -66,7 +66,8 @@ public:
LoopEnd,
PunchIn,
PunchOut,
RegionCue
RegionCue,
Cue
};

View file

@ -31,6 +31,8 @@ const int PublicEditor::horizontal_spacing = 6;
sigc::signal<void> PublicEditor::DropDownKeys;
ARDOUR::DataType PublicEditor::pbdid_dragged_dt = ARDOUR::DataType::NIL;
PublicEditor::PublicEditor (Gtk::Widget& content)
: Tabbable (content, _("Editor"), X_("editor"))
{

View file

@ -203,9 +203,6 @@ public:
*/
virtual void consider_auditioning (boost::shared_ptr<ARDOUR::Region> r) = 0;
/* Editor::_regions DnD */
virtual boost::shared_ptr<ARDOUR::Region> get_dragged_region_from_sidebar () = 0;
/* import dialogs -> ardour-ui ?! */
virtual void external_audio_dialog () = 0;
virtual void session_import_dialog () = 0;
@ -428,6 +425,9 @@ public:
: action (a), target (tgt) {}
};
/* data-type of [region] object currently dragged with x-ardour/region.pbdid */
static ARDOUR::DataType pbdid_dragged_dt;
std::map<std::string,RegionAction> region_action_map;
Glib::RefPtr<Gtk::ActionGroup> editor_actions;

View file

@ -0,0 +1,937 @@
/*
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
* Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
* Copyright (C) 2009-2018 Paul Davis <paul@linuxaudiosystems.com>
* Copyright (C) 2013-2021 Robin Gareus <robin@gareus.org>
* Copyright (C) 2015-2016 Tim Mayberry <mojofunk@gmail.com>
* Copyright (C) 2016 Nick Mainsbridge <mainsbridge@gmail.com>
* Copyright (C) 2018-2019 Ben Loftis <ben@harrisonconsoles.com>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <algorithm>
#include <string>
#include "pbd/file_utils.h"
#include "ardour/audiofilesource.h"
#include "ardour/audioregion.h"
#include "ardour/midi_source.h"
#include "ardour/region_factory.h"
#include "ardour/session.h"
#include "ardour/session_directory.h"
#include "ardour/session_playlist.h"
#include "ardour/silentfilesource.h"
#include "ardour/smf_source.h"
#include "gtkmm2ext/treeutils.h"
#include "gtkmm2ext/utils.h"
#include "widgets/tooltips.h"
#include "actions.h"
#include "ardour_ui.h"
#include "audio_clock.h"
#include "gui_thread.h"
#include "keyboard.h"
#include "main_clock.h"
#include "public_editor.h"
#include "region_list_base.h"
#include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
using namespace Temporal;
using Gtkmm2ext::Keyboard;
RegionListBase::RegionListBase ()
: _name_editable (0)
, _tags_editable (0)
, _old_focus (0)
, _no_redisplay (false)
{
_display.set_size_request (100, -1);
_display.set_rules_hint (true);
_display.set_name ("RegionList");
_display.set_fixed_height_mode (true);
_display.set_reorderable (false);
/* Try to prevent single mouse presses from initiating edits.
* This relies on a hack in gtktreeview.c:gtk_treeview_button_press() */
_display.set_data ("mouse-edits-require-mod1", (gpointer)0x1);
_model = TreeStore::create (_columns);
_model->set_sort_column (0, SORT_ASCENDING);
_display.add_object_drag (-1, "x-ardour/region.pbdid", Gtk::TARGET_SAME_APP);
_display.set_drag_column (_columns.name.index ());
_display.signal_drag_begin ().connect (sigc::mem_fun (*this, &RegionListBase::drag_begin));
_display.signal_drag_end ().connect (sigc::mem_fun (*this, &RegionListBase::drag_end));
_display.signal_drag_data_get ().connect (sigc::mem_fun (*this, &RegionListBase::drag_data_get));
_display.set_model (_model);
_display.set_headers_visible (true);
_display.set_rules_hint ();
if (UIConfiguration::instance ().get_use_tooltips ()) {
/* show path as the row tooltip */
_display.set_tooltip_column (13); /* path */
}
_display.get_selection ()->set_mode (SELECTION_MULTIPLE);
_scroller.add (_display);
_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
_display.signal_button_press_event ().connect (sigc::mem_fun (*this, &RegionListBase::button_press), false);
_display.signal_enter_notify_event ().connect (sigc::mem_fun (*this, &RegionListBase::enter_notify), false);
_display.signal_leave_notify_event ().connect (sigc::mem_fun (*this, &RegionListBase::leave_notify), false);
_scroller.signal_focus_in_event ().connect (sigc::mem_fun (*this, &RegionListBase::focus_in), false);
_scroller.signal_focus_out_event ().connect (sigc::mem_fun (*this, &RegionListBase::focus_out));
_scroller.signal_key_press_event ().connect (sigc::mem_fun (*this, &RegionListBase::key_press), false);
ARDOUR_UI::instance ()->primary_clock->mode_changed.connect (sigc::mem_fun (*this, &RegionListBase::clock_format_changed));
}
void
RegionListBase::setup_col (TreeViewColumn* col, int sort_idx, Gtk::AlignmentEnum al, const char* label, const char* tooltip)
{
/* add the label */
Gtk::Label* l = manage (new Label (label));
l->set_alignment (al);
ArdourWidgets::set_tooltip (*l, tooltip);
col->set_widget (*l);
l->show ();
col->set_sort_column (sort_idx);
col->set_expand (false);
/* this sets the alignment of the column header... */
col->set_alignment (al);
/* ...and this sets the alignment for the data cells */
CellRendererText* renderer = dynamic_cast<CellRendererText*> (col->get_first_cell_renderer ());
if (renderer) {
renderer->property_xalign () = (al == ALIGN_RIGHT ? 1.0 : (al == ALIGN_LEFT ? 0.0 : 0.5));
}
}
void
RegionListBase::setup_toggle (Gtk::TreeViewColumn* tvc, sigc::slot<void, std::string> cb)
{
CellRendererToggle* tc = dynamic_cast<CellRendererToggle*> (tvc->get_first_cell_renderer ());
tc->property_activatable () = true;
tc->signal_toggled ().connect (cb);
}
void
RegionListBase::add_name_column ()
{
TreeViewColumn* tvc = append_col (_columns.name, 120);
setup_col (tvc, 0, ALIGN_LEFT, _("Name"), ("Region name"));
/* Region Name: make editable */
CellRendererText* region_name_cell = dynamic_cast<CellRendererText*> (tvc->get_first_cell_renderer ());
region_name_cell->property_editable () = true;
region_name_cell->signal_edited ().connect (sigc::mem_fun (*this, &RegionListBase::name_edit));
region_name_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &RegionListBase::name_editing_started));
/* Region Name: color turns red if source is missing. */
tvc->add_attribute (region_name_cell->property_text (), _columns.name);
tvc->add_attribute (region_name_cell->property_foreground_gdk (), _columns.color_);
tvc->set_expand (true);
}
void
RegionListBase::add_tag_column ()
{
TreeViewColumn* tvc = append_col (_columns.tags, "2099-10-10 10:10:30");
setup_col (tvc, 2, ALIGN_LEFT, _("Tags"), _("Tags"));
/* Tags cell: make editable */
CellRendererText* region_tags_cell = dynamic_cast<CellRendererText*> (tvc->get_first_cell_renderer ());
region_tags_cell->property_editable () = true;
region_tags_cell->signal_edited ().connect (sigc::mem_fun (*this, &RegionListBase::tag_edit));
region_tags_cell->signal_editing_started ().connect (sigc::mem_fun (*this, &RegionListBase::tag_editing_started));
}
bool
RegionListBase::focus_in (GdkEventFocus*)
{
Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
if (win) {
_old_focus = win->get_focus ();
} else {
_old_focus = 0;
}
_tags_editable = 0;
_name_editable = 0;
/* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
return true;
}
bool
RegionListBase::focus_out (GdkEventFocus*)
{
if (_old_focus) {
_old_focus->grab_focus ();
_old_focus = 0;
}
_tags_editable = 0;
_name_editable = 0;
return false;
}
bool
RegionListBase::enter_notify (GdkEventCrossing*)
{
if (_name_editable || _tags_editable) {
return true;
}
Keyboard::magic_widget_grab_focus ();
return false;
}
bool
RegionListBase::leave_notify (GdkEventCrossing*)
{
if (_old_focus) {
_old_focus->grab_focus ();
_old_focus = 0;
}
Keyboard::magic_widget_drop_focus ();
return false;
}
void
RegionListBase::drag_begin (Glib::RefPtr<Gdk::DragContext> const&)
{
if (_display.get_selection ()->count_selected_rows () == 0) {
PublicEditor::instance ().pbdid_dragged_dt = DataType::NIL;
}
TreeView::Selection::ListHandle_Path rows = _display.get_selection ()->get_selected_rows ();
for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin (); i != rows.end (); ++i) {
boost::shared_ptr<Region> region = (*_model->get_iter (*i))[_columns.region];
PublicEditor::instance ().pbdid_dragged_dt = region->data_type ();
break;
}
}
void
RegionListBase::drag_end (Glib::RefPtr<Gdk::DragContext> const&)
{
PublicEditor::instance ().pbdid_dragged_dt = DataType::NIL;
}
void
RegionListBase::drag_data_get (Glib::RefPtr<Gdk::DragContext> const&, Gtk::SelectionData& data, guint, guint)
{
if (data.get_target () != "x-ardour/region.pbdid") {
return;
}
TreeView::Selection::ListHandle_Path rows = _display.get_selection ()->get_selected_rows ();
for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin (); i != rows.end (); ++i) {
boost::shared_ptr<Region> region = (*_model->get_iter (*i))[_columns.region];
data.set (data.get_target (), region->id ().to_s ());
break;
}
}
void
RegionListBase::set_session (ARDOUR::Session* s)
{
SessionHandlePtr::set_session (s);
if (!s) {
clear ();
return;
}
ARDOUR::Region::RegionsPropertyChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&RegionListBase::regions_changed, this, _1, _2), gui_context ());
ARDOUR::RegionFactory::CheckNewRegion.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&RegionListBase::add_region, this, _1), gui_context ());
redisplay ();
}
void
RegionListBase::remove_weak_region (boost::weak_ptr<ARDOUR::Region> r)
{
boost::shared_ptr<ARDOUR::Region> region = r.lock ();
if (!region) {
return;
}
RegionRowMap::iterator map_it = region_row_map.find (region);
if (map_it != region_row_map.end ()) {
Gtk::TreeModel::iterator r_it = map_it->second;
region_row_map.erase (map_it);
_model->erase (r_it);
}
}
bool
RegionListBase::list_region (boost::shared_ptr<ARDOUR::Region> region) const
{
/* whole-file regions are shown in the Source List */
return !region->whole_file ();
}
void
RegionListBase::add_region (boost::shared_ptr<Region> region)
{
if (!region || !_session || !list_region (region)) {
return;
}
/* we only show files-on-disk.
* if there's some other kind of region, we ignore it (for now)
*/
boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (region->source ());
if (!fs) {
return;
}
if (fs->empty ()) {
/* MIDI sources are allowed to be empty */
if (!boost::dynamic_pointer_cast<MidiSource> (region->source ())) {
return;
}
}
if (region->whole_file ()) {
region->DropReferences.connect (_remove_region_connections, MISSING_INVALIDATOR, boost::bind (&RegionListBase::remove_weak_region, this, boost::weak_ptr<Region> (region)), gui_context ());
}
PropertyChange pc;
boost::shared_ptr<RegionList> rl (new RegionList);
rl->push_back (region);
regions_changed (rl, pc);
}
void
RegionListBase::regions_changed (boost::shared_ptr<RegionList> rl, const PropertyChange& what_changed)
{
bool freeze = rl->size () > 2;
if (freeze) {
freeze_tree_model ();
}
for (RegionList::const_iterator i = rl->begin (); i != rl->end (); ++i) {
boost::shared_ptr<Region> r = *i;
RegionRowMap::iterator map_it = region_row_map.find (r);
boost::shared_ptr<ARDOUR::Playlist> pl = r->playlist ();
bool is_on_active_playlist = pl && _session && _session->playlist_is_active (pl);
if (!((is_on_active_playlist || r->whole_file ()) && list_region (r))) {
/* this region is not on an active playlist
* maybe it got deleted, or whatever */
if (map_it != region_row_map.end ()) {
Gtk::TreeModel::iterator r_it = map_it->second;
region_row_map.erase (map_it);
_model->erase (r_it);
}
break;
}
if (map_it != region_row_map.end ()) {
/* found the region, update its row properties */
TreeModel::Row row = *(map_it->second);
populate_row (r, row, what_changed);
} else {
/* new region, add it to the list */
TreeModel::iterator iter = _model->append ();
TreeModel::Row row = *iter;
region_row_map.insert (pair<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> (r, iter));
/* set the properties that don't change */
row[_columns.region] = r;
/* now populate the properties that might change... */
populate_row (r, row, PropertyChange ());
}
}
if (freeze) {
thaw_tree_model ();
}
}
void
RegionListBase::redisplay ()
{
if (_no_redisplay || !_session) {
return;
}
/* store sort column id and type for later */
_model->get_sort_column_id (_sort_col_id, _sort_type);
_remove_region_connections.drop_connections ();
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
_model->clear ();
/* Disable sorting to gain performance */
_model->set_sort_column (-2, SORT_ASCENDING);
region_row_map.clear ();
RegionFactory::foreach_region (sigc::mem_fun (*this, &RegionListBase::add_region));
/* re-enabale sorting */
_model->set_sort_column (_sort_col_id, _sort_type);
_display.set_model (_model);
}
void
RegionListBase::clock_format_changed ()
{
if (!_session) {
return;
}
PropertyChange change;
change.add (ARDOUR::Properties::start);
change.add (ARDOUR::Properties::length);
change.add (ARDOUR::Properties::sync_position);
change.add (ARDOUR::Properties::fade_in);
change.add (ARDOUR::Properties::fade_out);
TreeModel::Children rows = _model->children ();
for (TreeModel::iterator i = rows.begin (); i != rows.end (); ++i) {
boost::shared_ptr<ARDOUR::Region> r = (*i)[_columns.region];
populate_row (r, *i, change);
}
}
void
RegionListBase::format_position (timepos_t const& p, char* buf, size_t bufsize, bool onoff)
{
Temporal::BBT_Time bbt;
Timecode::Time timecode;
samplepos_t pos (p.samples ());
if (pos < 0) {
error << string_compose (_("RegionListBase::format_position: negative timecode position: %1"), pos) << endmsg;
snprintf (buf, bufsize, "invalid");
return;
}
switch (ARDOUR_UI::instance ()->primary_clock->mode ()) {
case AudioClock::BBT:
bbt = Temporal::TempoMap::use ()->bbt_at (p);
if (onoff) {
snprintf (buf, bufsize, "%03d|%02d|%04d", bbt.bars, bbt.beats, bbt.ticks);
} else {
snprintf (buf, bufsize, "(%03d|%02d|%04d)", bbt.bars, bbt.beats, bbt.ticks);
}
break;
case AudioClock::MinSec:
samplepos_t left;
int hrs;
int mins;
float secs;
left = pos;
hrs = (int)floor (left / (_session->sample_rate () * 60.0f * 60.0f));
left -= (samplecnt_t)floor (hrs * _session->sample_rate () * 60.0f * 60.0f);
mins = (int)floor (left / (_session->sample_rate () * 60.0f));
left -= (samplecnt_t)floor (mins * _session->sample_rate () * 60.0f);
secs = left / (float)_session->sample_rate ();
if (onoff) {
snprintf (buf, bufsize, "%02d:%02d:%06.3f", hrs, mins, secs);
} else {
snprintf (buf, bufsize, "(%02d:%02d:%06.3f)", hrs, mins, secs);
}
break;
case AudioClock::Seconds:
if (onoff) {
snprintf (buf, bufsize, "%.1f", pos / (float)_session->sample_rate ());
} else {
snprintf (buf, bufsize, "(%.1f)", pos / (float)_session->sample_rate ());
}
break;
case AudioClock::Samples:
if (onoff) {
snprintf (buf, bufsize, "%" PRId64, pos);
} else {
snprintf (buf, bufsize, "(%" PRId64 ")", pos);
}
break;
case AudioClock::Timecode:
default:
_session->timecode_time (pos, timecode);
if (onoff) {
snprintf (buf, bufsize, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
} else {
snprintf (buf, bufsize, "(%02d:%02d:%02d:%02d)", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
}
break;
}
}
void
RegionListBase::populate_row (boost::shared_ptr<Region> region, TreeModel::Row const& row, PBD::PropertyChange const& what_changed)
{
assert (region);
{
Gdk::Color c;
bool missing_source = boost::dynamic_pointer_cast<SilentFileSource> (region->source ()) != NULL;
if (missing_source) {
set_color_from_rgba (c, UIConfiguration::instance ().color ("region list missing source"));
} else {
set_color_from_rgba (c, UIConfiguration::instance ().color ("region list whole file"));
}
row[_columns.color_] = c;
}
boost::shared_ptr<AudioRegion> audioregion = boost::dynamic_pointer_cast<AudioRegion> (region);
PropertyChange c;
const bool all = what_changed == c;
if (all || what_changed.contains (Properties::length)) {
populate_row_position (region, row);
}
if (all || what_changed.contains (Properties::start) || what_changed.contains (Properties::sync_position)) {
populate_row_sync (region, row);
}
if (all || what_changed.contains (Properties::fade_in)) {
populate_row_fade_in (region, row, audioregion);
}
if (all || what_changed.contains (Properties::fade_out)) {
populate_row_fade_out (region, row, audioregion);
}
if (all || what_changed.contains (Properties::locked)) {
populate_row_locked (region, row);
}
if (all || what_changed.contains (Properties::time_domain)) {
populate_row_glued (region, row);
}
if (all || what_changed.contains (Properties::muted)) {
populate_row_muted (region, row);
}
if (all || what_changed.contains (Properties::opaque)) {
populate_row_opaque (region, row);
}
if (all || what_changed.contains (Properties::length)) {
populate_row_end (region, row);
populate_row_length (region, row);
}
if (all) {
populate_row_source (region, row);
}
if (all || what_changed.contains (Properties::name) || what_changed.contains (Properties::tags)) {
populate_row_name (region, row);
}
/* CAPTURED DROPOUTS */
row[_columns.captd_xruns] = region->source ()->n_captured_xruns ();
}
void
RegionListBase::populate_row_length (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
char buf[16];
if (ARDOUR_UI::instance ()->primary_clock->mode () == AudioClock::BBT) {
TempoMap::SharedPtr map (TempoMap::use ());
Temporal::BBT_Time bbt; /* uninitialized until full duration works */
// Temporal::BBT_Time bbt = map->bbt_duration_at (region->position(), region->length());
snprintf (buf, sizeof (buf), "%03d|%02d|%04d", bbt.bars, bbt.beats, bbt.ticks);
} else {
format_position (timepos_t (region->length ()), buf, sizeof (buf));
}
row[_columns.length] = buf;
}
void
RegionListBase::populate_row_end (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
#ifndef SHOW_REGION_EXTRAS
return;
#endif
if (region->last_sample () >= region->first_sample ()) {
char buf[16];
format_position (region->nt_last (), buf, sizeof (buf));
row[_columns.end] = buf;
} else {
row[_columns.end] = "empty";
}
}
void
RegionListBase::populate_row_position (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
row[_columns.position] = region->position ();
char buf[16];
format_position (region->position (), buf, sizeof (buf));
row[_columns.start] = buf;
}
void
RegionListBase::populate_row_sync (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
#ifndef SHOW_REGION_EXTRAS
return;
#endif
if (region->sync_position () == region->position ()) {
row[_columns.sync] = _("Start");
} else if (region->sync_position () == (region->last_sample ())) {
row[_columns.sync] = _("End");
} else {
char buf[16];
format_position (region->sync_position (), buf, sizeof (buf));
row[_columns.sync] = buf;
}
}
void
RegionListBase::populate_row_fade_in (boost::shared_ptr<Region> region, TreeModel::Row const& row, boost::shared_ptr<AudioRegion> audioregion)
{
#ifndef SHOW_REGION_EXTRAS
return;
#endif
if (!audioregion) {
row[_columns.fadein] = "";
} else {
char buf[32];
format_position (audioregion->fade_in ()->back ()->when, buf, sizeof (buf), audioregion->fade_in_active ());
row[_columns.fadein] = buf;
}
}
void
RegionListBase::populate_row_fade_out (boost::shared_ptr<Region> region, TreeModel::Row const& row, boost::shared_ptr<AudioRegion> audioregion)
{
#ifndef SHOW_REGION_EXTRAS
return;
#endif
if (!audioregion) {
row[_columns.fadeout] = "";
} else {
char buf[32];
format_position (audioregion->fade_out ()->back ()->when, buf, sizeof (buf), audioregion->fade_out_active ());
row[_columns.fadeout] = buf;
}
}
void
RegionListBase::populate_row_locked (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
row[_columns.locked] = region->locked ();
}
void
RegionListBase::populate_row_glued (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
if (region->position_time_domain () == Temporal::BeatTime) {
row[_columns.glued] = true;
} else {
row[_columns.glued] = false;
}
}
void
RegionListBase::populate_row_muted (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
row[_columns.muted] = region->muted ();
}
void
RegionListBase::populate_row_opaque (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
row[_columns.opaque] = region->opaque ();
}
void
RegionListBase::populate_row_name (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
row[_columns.name] = Gtkmm2ext::markup_escape_text (region->name ());
if (region->data_type () == DataType::MIDI) {
row[_columns.channels] = 0; /*TODO: some better recognition of midi regions*/
} else {
row[_columns.channels] = region->sources ().size ();
}
row[_columns.tags] = region->tags ();
}
void
RegionListBase::populate_row_source (boost::shared_ptr<Region> region, TreeModel::Row const& row)
{
boost::shared_ptr<ARDOUR::Source> source = region->source ();
if (boost::dynamic_pointer_cast<SilentFileSource> (source)) {
row[_columns.path] = _("MISSING ") + Gtkmm2ext::markup_escape_text (source->name ());
} else {
row[_columns.path] = Gtkmm2ext::markup_escape_text (source->name ());
boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (source);
if (fs) {
boost::shared_ptr<AudioFileSource> afs = boost::dynamic_pointer_cast<AudioFileSource> (source);
if (afs) {
const string audio_directory = _session->session_directory ().sound_path ();
if (!PBD::path_is_within (audio_directory, fs->path ())) {
row[_columns.path] = Gtkmm2ext::markup_escape_text (fs->path ());
}
}
boost::shared_ptr<SMFSource> mfs = boost::dynamic_pointer_cast<SMFSource> (source);
if (mfs) {
const string midi_directory = _session->session_directory ().midi_path ();
if (!PBD::path_is_within (midi_directory, fs->path ())) {
row[_columns.path] = Gtkmm2ext::markup_escape_text (fs->path ());
}
}
}
}
row[_columns.captd_for] = source->captured_for ();
row[_columns.take_id] = source->take_id ();
/* Natural Position (samples, an invisible column for sorting) */
row[_columns.natural_s] = source->natural_position ();
/* Natural Position (text representation) */
if (source->have_natural_position ()) {
char buf[64];
format_position (source->natural_position (), buf, sizeof (buf));
row[_columns.natural_pos] = buf;
} else {
row[_columns.natural_pos] = X_("--");
}
}
bool
RegionListBase::key_press (GdkEventKey* ev)
{
TreeViewColumn* col;
switch (ev->keyval) {
case GDK_Tab:
case GDK_ISO_Left_Tab:
if (_name_editable) {
_name_editable->editing_done ();
_name_editable = 0;
}
if (_tags_editable) {
_tags_editable->editing_done ();
_tags_editable = 0;
}
col = _display.get_column (0); // select&focus on name column
if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
treeview_select_previous (_display, _model, col);
} else {
treeview_select_next (_display, _model, col);
}
return true;
break;
default:
break;
}
return false;
}
void
RegionListBase::name_editing_started (CellEditable* ce, const Glib::ustring& path)
{
_name_editable = ce;
/* give it a special name */
Gtk::Entry* e = dynamic_cast<Gtk::Entry*> (ce);
if (e) {
e->set_name (X_("RegionNameEditorEntry"));
TreeIter iter;
if ((iter = _model->get_iter (path))) {
boost::shared_ptr<Region> region = (*iter)[_columns.region];
if (region) {
e->set_text (region->name ());
}
}
}
}
void
RegionListBase::name_edit (const std::string& path, const std::string& new_text)
{
_name_editable = 0;
boost::shared_ptr<Region> region;
TreeIter row_iter;
if ((row_iter = _model->get_iter (path))) {
region = (*row_iter)[_columns.region];
(*row_iter)[_columns.name] = new_text;
}
if (region) {
region->set_name (new_text);
populate_row_name (region, (*row_iter));
}
}
void
RegionListBase::tag_editing_started (CellEditable* ce, const Glib::ustring& path)
{
_tags_editable = ce;
/* give it a special name */
Gtk::Entry* e = dynamic_cast<Gtk::Entry*> (ce);
if (e) {
e->set_name (X_("RegionTagEditorEntry"));
TreeIter iter;
if ((iter = _model->get_iter (path))) {
boost::shared_ptr<Region> region = (*iter)[_columns.region];
if (region) {
e->set_text (region->tags ());
}
}
}
}
void
RegionListBase::tag_edit (const std::string& path, const std::string& new_text)
{
_tags_editable = 0;
boost::shared_ptr<Region> region;
TreeIter row_iter;
if ((row_iter = _model->get_iter (path))) {
region = (*row_iter)[_columns.region];
(*row_iter)[_columns.tags] = new_text;
}
if (region) {
region->set_tags (new_text);
populate_row_name (region, (*row_iter));
}
}
void
RegionListBase::clear ()
{
_remove_region_connections.drop_connections ();
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
_model->clear ();
_display.set_model (_model);
/* Clean up the maps */
region_row_map.clear ();
}
void
RegionListBase::freeze_tree_model ()
{
/* store sort column id and type for later */
_model->get_sort_column_id (_sort_col_id, _sort_type);
_change_connection.block (true);
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
_model->set_sort_column (-2, SORT_ASCENDING); //Disable sorting to gain performance
}
void
RegionListBase::thaw_tree_model ()
{
_model->set_sort_column (_sort_col_id, _sort_type); // re-enabale sorting
_display.set_model (_model);
_change_connection.block (false);
}
void
RegionListBase::locked_changed (std::string const& path)
{
TreeIter i = _model->get_iter (path);
if (i) {
boost::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
if (region) {
region->set_locked (!(*i)[_columns.locked]);
}
}
}
void
RegionListBase::glued_changed (std::string const& path)
{
TreeIter i = _model->get_iter (path);
if (i) {
boost::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
if (region) {
/* `glued' means MusicTime, and we're toggling here */
region->set_position_time_domain ((*i)[_columns.glued] ? Temporal::AudioTime : Temporal::BeatTime);
}
}
}
void
RegionListBase::muted_changed (std::string const& path)
{
TreeIter i = _model->get_iter (path);
if (i) {
boost::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
if (region) {
region->set_muted (!(*i)[_columns.muted]);
}
}
}
void
RegionListBase::opaque_changed (std::string const& path)
{
TreeIter i = _model->get_iter (path);
if (i) {
boost::shared_ptr<ARDOUR::Region> region = (*i)[_columns.region];
if (region) {
region->set_opaque (!(*i)[_columns.opaque]);
}
}
}

View file

@ -0,0 +1,253 @@
/*
* Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
* Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
* Copyright (C) 2009-2018 Paul Davis <paul@linuxaudiosystems.com>
* Copyright (C) 2018 Ben Loftis <ben@harrisonconsoles.com>
* Copyright (C) 2021 Robin Gareus <robin@gareus.org>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _gtk_ardour_region_list_base_h_
#define _gtk_ardour_region_list_base_h_
#include <boost/unordered_map.hpp>
#include <gtkmm/celleditable.h>
#include <gtkmm/frame.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/treemodel.h>
#include <gtkmm/treerowreference.h>
#include <gtkmm/treestore.h>
#include "gtkmm2ext/utils.h"
#include "pbd/properties.h"
#include "pbd/signals.h"
#include "ardour/session_handle.h"
#include "ardour/types.h"
#include "gtkmm2ext/dndtreeview.h"
//#define SHOW_REGION_EXTRAS
namespace ARDOUR
{
class Region;
class AudioRegion;
}
class RegionListBase : public ARDOUR::SessionHandlePtr
{
public:
RegionListBase ();
void set_session (ARDOUR::Session*);
Gtk::Widget& widget ()
{
return _scroller;
}
void clear ();
void redisplay ();
void suspend_redisplay ()
{
_no_redisplay = true;
}
void resume_redisplay ()
{
_no_redisplay = false;
redisplay ();
}
void block_change_connection (bool b)
{
_change_connection.block (b);
}
void unselect_all ()
{
_display.get_selection ()->unselect_all ();
}
protected:
struct Columns : public Gtk::TreeModel::ColumnRecord {
Columns ()
{
add (name); // 0
add (channels); // 1
add (tags); // 2
add (start); // 3
add (length); // 3
add (end); // 5
add (sync); // 6
add (fadein); // 7
add (fadeout); // 8
add (locked); // 9
add (glued); // 10
add (muted); // 11
add (opaque); // 12
add (path); // 13
add (region); // 14
add (color_); // 15
add (position); // 16
/* src-list */
add (captd_for); // 17
add (take_id); // 18
add (natural_pos); // 19
add (natural_s); // 20
add (captd_xruns);
}
Gtk::TreeModelColumn<std::string> name;
Gtk::TreeModelColumn<int> channels;
Gtk::TreeModelColumn<std::string> tags;
Gtk::TreeModelColumn<Temporal::timepos_t> position;
Gtk::TreeModelColumn<std::string> start;
Gtk::TreeModelColumn<std::string> end;
Gtk::TreeModelColumn<std::string> length;
Gtk::TreeModelColumn<std::string> sync;
Gtk::TreeModelColumn<std::string> fadein;
Gtk::TreeModelColumn<std::string> fadeout;
Gtk::TreeModelColumn<bool> locked;
Gtk::TreeModelColumn<bool> glued;
Gtk::TreeModelColumn<bool> muted;
Gtk::TreeModelColumn<bool> opaque;
Gtk::TreeModelColumn<std::string> path;
Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Region>> region;
Gtk::TreeModelColumn<Gdk::Color> color_;
Gtk::TreeModelColumn<std::string> captd_for;
Gtk::TreeModelColumn<std::string> take_id;
Gtk::TreeModelColumn<std::string> natural_pos;
Gtk::TreeModelColumn<Temporal::timepos_t> natural_s;
Gtk::TreeModelColumn<size_t> captd_xruns;
};
void add_name_column ();
void add_tag_column ();
template <class T>
Gtk::TreeViewColumn* append_col (Gtk::TreeModelColumn<T> const& col, int width)
{
Gtk::TreeViewColumn* c = manage (new Gtk::TreeViewColumn ("", col));
c->set_fixed_width (width);
c->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
_display.append_column (*c);
return c;
}
template <class T>
Gtk::TreeViewColumn* append_col (Gtk::TreeModelColumn<T> const& col, std::string const& sizing_text)
{
int w, h;
Glib::RefPtr<Pango::Layout> layout = _display.create_pango_layout (sizing_text);
Gtkmm2ext::get_pixel_size (layout, w, h);
return append_col (col, w);
}
void setup_col (Gtk::TreeViewColumn*, int, Gtk::AlignmentEnum, const char*, const char*);
void setup_toggle (Gtk::TreeViewColumn*, sigc::slot<void, std::string>);
void freeze_tree_model ();
void thaw_tree_model ();
void remove_weak_region (boost::weak_ptr<ARDOUR::Region>);
virtual void regions_changed (boost::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const&);
void name_editing_started (Gtk::CellEditable*, const Glib::ustring&);
void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&);
virtual void name_edit (const std::string&, const std::string&);
virtual void tag_edit (const std::string&, const std::string&);
void locked_changed (std::string const&);
void glued_changed (std::string const&);
void muted_changed (std::string const&);
void opaque_changed (std::string const&);
virtual bool key_press (GdkEventKey*);
virtual bool button_press (GdkEventButton*)
{
return false;
}
bool focus_in (GdkEventFocus*);
bool focus_out (GdkEventFocus*);
bool enter_notify (GdkEventCrossing*);
bool leave_notify (GdkEventCrossing*);
void format_position (Temporal::timepos_t const& pos, char* buf, size_t bufsize, bool onoff = true);
void add_region (boost::shared_ptr<ARDOUR::Region>);
void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const&, PBD::PropertyChange const&);
void populate_row_used (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_position (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_end (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_sync (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_fade_in (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
void populate_row_fade_out (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row, boost::shared_ptr<ARDOUR::AudioRegion>);
void populate_row_locked (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_muted (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_glued (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_opaque (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_length (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_name (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void populate_row_source (boost::shared_ptr<ARDOUR::Region> region, Gtk::TreeModel::Row const& row);
void clock_format_changed ();
void drag_begin (Glib::RefPtr<Gdk::DragContext> const&);
void drag_end (Glib::RefPtr<Gdk::DragContext> const&);
void drag_data_get (Glib::RefPtr<Gdk::DragContext> const&, Gtk::SelectionData&, guint, guint);
virtual bool list_region (boost::shared_ptr<ARDOUR::Region>) const;
Columns _columns;
int _sort_col_id;
Gtk::SortType _sort_type;
Gtk::CellEditable* _name_editable;
Gtk::CellEditable* _tags_editable;
Gtk::Widget* _old_focus;
Gtk::ScrolledWindow _scroller;
Gtk::Frame _frame;
Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region>> _display;
Glib::RefPtr<Gtk::TreeStore> _model;
bool _no_redisplay;
typedef boost::unordered_map<boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::iterator> RegionRowMap;
RegionRowMap region_row_map;
sigc::connection _change_connection;
PBD::ScopedConnection _editor_freeze_connection;
PBD::ScopedConnection _editor_thaw_connection;
PBD::ScopedConnectionList _remove_region_connections;
};
#endif /* _gtk_ardour_region_list_base_h_ */

View file

@ -0,0 +1,104 @@
/*
* Copyright (C) 2021 Robin Gareus <robin@gareus.org>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ardour/region.h"
#include "ardour/session.h"
#include "gui_thread.h"
#include "source_list_base.h"
#include "pbd/i18n.h"
using namespace Gtk;
SourceListBase::SourceListBase ()
{
}
void
SourceListBase::set_session (ARDOUR::Session* s)
{
if (s) {
s->SourceRemoved.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&SourceListBase::remove_weak_source, this, _1), gui_context ());
}
RegionListBase::set_session (s);
}
void
SourceListBase::remove_weak_source (boost::weak_ptr<ARDOUR::Source> src)
{
boost::shared_ptr<ARDOUR::Source> source = src.lock ();
if (source) {
remove_source (source);
}
}
void
SourceListBase::remove_source (boost::shared_ptr<ARDOUR::Source> source)
{
TreeModel::iterator i;
TreeModel::Children rows = _model->children ();
for (i = rows.begin (); i != rows.end (); ++i) {
boost::shared_ptr<ARDOUR::Region> rr = (*i)[_columns.region];
if (rr->source () == source) {
RegionRowMap::iterator map_it = region_row_map.find (rr);
assert (map_it != region_row_map.end () && i == map_it->second);
region_row_map.erase (map_it);
_model->erase (i);
break;
}
}
}
bool
SourceListBase::list_region (boost::shared_ptr<ARDOUR::Region> region) const
{
/* by definition, the Source List only shows whole-file regions
* this roughly equates to Source objects, but preserves the stereo-ness
* (or multichannel-ness) of a stereo source file.
*/
return region->whole_file ();
}
void
SourceListBase::tag_edit (const std::string& path, const std::string& new_text)
{
RegionListBase::tag_edit (path, new_text);
TreeIter row_iter;
if ((row_iter = _model->get_iter (path))) {
boost::shared_ptr<ARDOUR::Region> region = (*row_iter)[_columns.region];
if (region) {
_session->set_dirty (); // whole-file regions aren't in a playlist to catch property changes, so we need to explicitly set the session dirty
}
}
}
void
SourceListBase::name_edit (const std::string& path, const std::string& new_text)
{
RegionListBase::name_edit (path, new_text);
TreeIter row_iter;
if ((row_iter = _model->get_iter (path))) {
boost::shared_ptr<ARDOUR::Region> region = (*row_iter)[_columns.region];
if (region) {
_session->set_dirty (); // whole-file regions aren't in a playlist to catch property changes, so we need to explicitly set the session dirty
}
}
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2021 Robin Gareus <robin@gareus.org>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _gtk_ardour_source_list_base_h_
#define _gtk_ardour_source_list_base_h_
#include "region_list_base.h"
class SourceListBase : public RegionListBase
{
public:
SourceListBase ();
void set_session (ARDOUR::Session*);
protected:
void name_edit (const std::string&, const std::string&);
void tag_edit (const std::string&, const std::string&);
bool list_region (boost::shared_ptr<ARDOUR::Region>) const;
private:
void remove_source (boost::shared_ptr<ARDOUR::Source>);
void remove_weak_source (boost::weak_ptr<ARDOUR::Source>);
};
#endif /* _gtk_ardour_source_list_base_h_ */

View file

@ -108,8 +108,7 @@ TriggerPage::TriggerPage ()
_no_strips.signal_drag_data_received ().connect (sigc::mem_fun (*this, &TriggerPage::no_strip_drag_data_received));
std::vector<Gtk::TargetEntry> target_table;
target_table.push_back (Gtk::TargetEntry ("x-ardour/region.erl", Gtk::TARGET_SAME_APP));
target_table.push_back (Gtk::TargetEntry ("x-ardour/region.esl", Gtk::TARGET_SAME_APP));
target_table.push_back (Gtk::TargetEntry ("x-ardour/region.pbdid", Gtk::TARGET_SAME_APP));
target_table.push_back (Gtk::TargetEntry ("text/uri-list"));
target_table.push_back (Gtk::TargetEntry ("text/plain"));
target_table.push_back (Gtk::TargetEntry ("application/x-rootwin-drop"));
@ -126,6 +125,8 @@ TriggerPage::TriggerPage ()
_sidebar_vbox.pack_start (_sidebar_notebook);
add_sidebar_page (_("Clips"), _trigger_clip_picker);
add_sidebar_page (_("Sources"), _trigger_source_list.widget ());
add_sidebar_page (_("Regions"), _trigger_region_list.widget ());
/* Upper pane ([slot | strips] | file browser) */
_pane_upper.add (_strip_group_box);
@ -265,6 +266,8 @@ TriggerPage::set_session (Session* s)
_cue_box.set_session (s);
_trigger_clip_picker.set_session (s);
_master.set_session (s);
_trigger_source_list.set_session (s);
_trigger_region_list.set_session (s);
if (!_session) {
return;
@ -527,8 +530,9 @@ TriggerPage::no_strip_drag_motion (Glib::RefPtr<Gdk::DragContext> const& context
void
TriggerPage::no_strip_drag_data_received (Glib::RefPtr<Gdk::DragContext> const& context, int /*x*/, int y, Gtk::SelectionData const& data, guint /*info*/, guint time)
{
if (data.get_target () == "x-ardour/region.erl" || data.get_target () == "x-ardour/region.esl") {
boost::shared_ptr<Region> region = PublicEditor::instance ().get_dragged_region_from_sidebar ();
if (data.get_target () == "x-ardour/region.pbdid") {
PBD::ID rid (data.get_data_as_string ());
boost::shared_ptr<Region> region = RegionFactory::region_by_id (rid);
boost::shared_ptr<TriggerBox> triggerbox;
if (boost::dynamic_pointer_cast<AudioRegion> (region)) {
@ -598,8 +602,8 @@ TriggerPage::drop_paths_part_two (std::vector<std::string> paths)
InstrumentSelector is; // instantiation builds instrument-list and sets default.
timepos_t pos (0);
Editing::ImportDisposition disposition = Editing::ImportSerializeFiles; // or Editing::ImportDistinctFiles // TODO use drop modifier? config?
PublicEditor::instance().do_import (midi_paths, disposition, Editing::ImportAsTrigger, SrcBest, SMFTrackName, SMFTempoIgnore, pos, is.selected_instrument (), false);
PublicEditor::instance().do_import (audio_paths, disposition, Editing::ImportAsTrigger, SrcBest, SMFTrackName, SMFTempoIgnore, pos);
PublicEditor::instance().do_import (midi_paths, disposition, Editing::ImportAsTrigger, SrcBest, SMFTrackNumber, SMFTempoIgnore, pos, is.selected_instrument (), false);
PublicEditor::instance().do_import (audio_paths, disposition, Editing::ImportAsTrigger, SrcBest, SMFTrackNumber, SMFTempoIgnore, pos);
}
bool

View file

@ -40,6 +40,8 @@
#include "midi_trigger_properties_box.h"
#include "slot_properties_box.h"
#include "trigger_clip_picker.h"
#include "trigger_region_list.h"
#include "trigger_source_list.h"
#include "trigger_master.h"
class TriggerStrip;
@ -103,6 +105,8 @@ private:
Gtk::VBox _sidebar_vbox;
Gtk::Notebook _sidebar_notebook;
TriggerClipPicker _trigger_clip_picker;
TriggerSourceList _trigger_source_list;
TriggerRegionList _trigger_region_list;
CueBoxWidget _cue_box;
FittedCanvasWidget _master_widget;

View file

@ -0,0 +1,30 @@
/*
* Copyright (C) 2021 Robin Gareus <robin@gareus.org>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "trigger_region_list.h"
#include "pbd/i18n.h"
using namespace Gtk;
TriggerRegionList::TriggerRegionList ()
{
add_name_column ();
setup_col (append_col (_columns.channels, "Chans "), 1, ALIGN_LEFT, _("# Ch"), _("# Channels in the region"));
add_tag_column ();
}

View file

@ -0,0 +1,29 @@
/*
* Copyright (C) 2021 Robin Gareus <robin@gareus.org>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _gtk_ardour_trigger_region_list_h_
#define _gtk_ardour_trigger_region_list_h_
#include "region_list_base.h"
class TriggerRegionList : public RegionListBase
{
public:
TriggerRegionList ();
};
#endif /* _gtk_ardour_trigger_region_list_h_ */

View file

@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Robin Gareus <robin@gareus.org>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ardour/region.h"
#include "ardour/session.h"
#include "trigger_source_list.h"
#include "pbd/i18n.h"
using namespace Gtk;
TriggerSourceList::TriggerSourceList ()
{
add_name_column ();
setup_col (append_col (_columns.channels, "Chans "), 1, ALIGN_LEFT, _("# Ch"), _("# Channels in the region"));
add_tag_column ();
setup_col (append_col (_columns.captd_xruns, "1234567890"), 21, ALIGN_RIGHT, _("# Xruns"), _("Number of dropouts that occured during recording"));
setup_col (append_col (_columns.take_id, "2021-01-19 02:34:03"), 18, ALIGN_LEFT, _("Take ID"), _("Take ID"));
_display.get_column (0)->set_resizable (true);
}

View file

@ -0,0 +1,29 @@
/*
* Copyright (C) 2021 Robin Gareus <robin@gareus.org>
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _gtk_ardour_trigger_source_list_h_
#define _gtk_ardour_trigger_source_list_h_
#include "source_list_base.h"
class TriggerSourceList : public SourceListBase
{
public:
TriggerSourceList ();
};
#endif /* _gtk_ardour_trigger_source_list_h_ */

View file

@ -801,12 +801,21 @@ TriggerEntry::drag_begin (Glib::RefPtr<Gdk::DragContext> const& context)
/* ctx leaves scope, cr is destroyed, and pixmap surface is flush()ed */
}
boost::shared_ptr<Region> region = trigger ()->region ();
if (region) {
PublicEditor::instance ().pbdid_dragged_dt = region->data_type ();
} else {
PublicEditor::instance ().pbdid_dragged_dt = DataType::NIL;
}
context->set_icon (pixmap->get_colormap (), pixmap, Glib::RefPtr<Gdk::Bitmap> (NULL), width / 2, height / 2);
}
void
TriggerEntry::drag_end (Glib::RefPtr<Gdk::DragContext> const&)
{
if (_drag_active) {
PublicEditor::instance ().pbdid_dragged_dt = DataType::NIL;
}
_drag_active = false;
}
@ -855,8 +864,6 @@ TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb)
}
std::vector<Gtk::TargetEntry> target_table;
target_table.push_back (Gtk::TargetEntry ("x-ardour/region.erl", Gtk::TARGET_SAME_APP));
target_table.push_back (Gtk::TargetEntry ("x-ardour/region.esl", Gtk::TARGET_SAME_APP));
target_table.push_back (Gtk::TargetEntry ("x-ardour/region.pbdid", Gtk::TARGET_SAME_APP));
target_table.push_back (Gtk::TargetEntry ("text/uri-list"));
target_table.push_back (Gtk::TargetEntry ("text/plain"));
@ -944,8 +951,9 @@ TriggerBoxUI::slot_at_y (int y) const
bool
TriggerBoxUI::drag_motion (Glib::RefPtr<Gdk::DragContext> const& context, int, int y, guint time)
{
bool can_drop = true;
uint64_t n = slot_at_y (y);
bool can_drop = PublicEditor::instance ().pbdid_dragged_dt == _triggerbox.data_type ();
uint64_t n = slot_at_y (y);
if (n >= _slots.size ()) {
assert (0);
can_drop = false;
@ -986,21 +994,8 @@ TriggerBoxUI::drag_data_received (Glib::RefPtr<Gdk::DragContext> const& context,
context->drag_finish (false, false, time);
return;
}
if (data.get_target () == "x-ardour/region.erl" || data.get_target () == "x-ardour/region.esl") {
boost::shared_ptr<Region> region = PublicEditor::instance ().get_dragged_region_from_sidebar ();
if (region) {
_triggerbox.set_from_selection (n, region);
context->drag_finish (true, false, time);
} else {
context->drag_finish (false, false, time);
}
return;
}
if (data.get_target () == "x-ardour/region.pbdid") {
/* Long term goal is to receive all information from another TriggerBox Slot,
* not just the region.
*/
PBD::ID rid (data.get_data_as_string ());
boost::shared_ptr<Region> region = RegionFactory::region_by_id (rid);
if (region) {

View file

@ -250,6 +250,7 @@ gtk2_ardour_sources = [
'region_editor.cc',
'region_gain_line.cc',
'region_layering_order_editor.cc',
'region_list_base.cc',
'region_peak_cursor.cc',
'region_selection.cc',
'region_view.cc',
@ -279,6 +280,7 @@ gtk2_ardour_sources = [
'sfdb_ui.cc',
'shuttle_control.cc',
'slot_properties_box.cc',
'source_list_base.cc',
'soundcloud_export_selector.cc',
'splash.cc',
'speaker_dialog.cc',
@ -312,6 +314,8 @@ gtk2_ardour_sources = [
'transpose_dialog.cc',
'trigger_clip_picker.cc',
'trigger_page.cc',
'trigger_region_list.cc',
'trigger_source_list.cc',
'trigger_strip.cc',
'trigger_master.cc',
'trigger_ui.cc',

View file

@ -136,13 +136,15 @@ class /*LIBGTKMM2EXT_API*/ DnDTreeView : public DnDTreeViewBase
TreeView::on_drag_data_get (context, selection_data, info, time);
} else if (selection_data.get_target() == object_type) {
} else if (selection_data.get_target() == object_type && drag_data.data_column >= 0) {
/* return a pointer to this object, which allows
* the receiver to call on_drag_data_received()
*/
void *c = this;
selection_data.set (8, (guchar*)&c, sizeof(void*));
} else {
TreeView::on_drag_data_get (context, selection_data, info, time);
}
}
@ -178,7 +180,7 @@ class /*LIBGTKMM2EXT_API*/ DnDTreeView : public DnDTreeViewBase
void get_object_drag_data (std::list<DataType>& l, Gtk::TreeView** source) const {
if (drag_data.source == 0) {
if (drag_data.source == 0 || drag_data.data_column < 0) {
return;
}

View file

@ -807,6 +807,8 @@ def options(opt):
help='Compile with -rdynamic -- allow obtaining backtraces from within Ardour')
opt.add_option('--no-carbon', action='store_true', default=False, dest='nocarbon',
help='Compile without support for AU Plugins with only CARBON UI (needed for 64bit)')
opt.add_option('--no-compile-database', action='store_true', default=False, dest='clang_compile_db',
help='Do not call clang_compilation_database to write compile_commands.json prior to build')
opt.add_option('--boost-sp-debug', action='store_true', default=False, dest='boost_sp_debug',
help='Compile with Boost shared pointer debugging')
opt.add_option('--debug-symbols', action='store_true', default=False, dest='debug_symbols',
@ -935,7 +937,7 @@ def configure(conf):
conf.load('compiler_cxx')
if Options.options.dist_target == 'mingw':
conf.load('winres')
else:
elif not Options.options.clang_compile_db:
conf.load('clang_compilation_database')
if Options.options.dist_target == 'msvc':