summaryrefslogtreecommitdiff
path: root/gtk2_ardour/export_timespan_selector.h
blob: e8a97326bc737e360f41fd6b49765746b5034386 (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
/*
    Copyright (C) 2008 Paul Davis
    Author: Sakari Bergen

    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., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#ifndef __export_timespan_selector_h__
#define __export_timespan_selector_h__

#include "public_editor.h"
#include "audio_clock.h"

#include <list>

#include <gtkmm.h>
#include <boost/shared_ptr.hpp>

#include <ardour/types.h>
#include <ardour/export_profile_manager.h>

namespace ARDOUR {
	class Location;
	class ExportTimespan;
	class ExportHandler;
	class Session;
}

using ARDOUR::CDMarkerFormat;

/// Timespan Selector base
class ExportTimespanSelector : public Gtk::VBox {
  public:

	ExportTimespanSelector ();
	virtual ~ExportTimespanSelector ();

	void set_state (ARDOUR::ExportProfileManager::TimespanStatePtr const state_, ARDOUR::Session * session_);
	
	sigc::signal<void> CriticalSelectionChanged;

  protected:

	typedef std::list<ARDOUR::Location *> LocationList;
	typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;

	typedef boost::shared_ptr<ARDOUR::ExportTimespan> TimespanPtr;
	typedef std::list<TimespanPtr> TimespanList;
	typedef boost::shared_ptr<TimespanList> TimespanListPtr;

	ARDOUR::Session *                              session;
	ARDOUR::ExportProfileManager::TimespanStatePtr state;

	virtual void fill_range_list () = 0;
	
	void add_range_to_selection (ARDOUR::Location const * loc);
	void set_time_format_from_state ();
	
	void change_time_format ();
	
	Glib::ustring construct_label (ARDOUR::Location const * location) const;
	Glib::ustring bbt_str (nframes_t frames) const;
	Glib::ustring smpte_str (nframes_t frames) const;
	Glib::ustring ms_str (nframes_t frames) const;

	void update_range_name (Glib::ustring const & path, Glib::ustring const & new_text);

	/*** GUI components ***/
	
	Gtk::HBox      option_hbox;
	Gtk::Label     time_format_label;
	
	/* Time format */
	
	typedef ARDOUR::ExportProfileManager::TimeFormat TimeFormat;
	
	struct TimeFormatCols : public Gtk::TreeModelColumnRecord
	{
	  public:
		Gtk::TreeModelColumn<TimeFormat>      format;
		Gtk::TreeModelColumn<Glib::ustring>   label;
	
		TimeFormatCols () { add(format); add(label); }
	};
	TimeFormatCols               time_format_cols;
	Glib::RefPtr<Gtk::ListStore> time_format_list;
	Gtk::ComboBox                time_format_combo;
	
	/* View */
	
	struct RangeCols : public Gtk::TreeModelColumnRecord
	{
	  public:
		Gtk::TreeModelColumn<ARDOUR::Location *>  location;
		Gtk::TreeModelColumn<Glib::ustring>       label;
		Gtk::TreeModelColumn<bool>                selected;
		Gtk::TreeModelColumn<Glib::ustring>       name;
	
		RangeCols () { add (location); add(label); add(selected); add(name); }
	};
	RangeCols                    range_cols;
	
	Glib::RefPtr<Gtk::ListStore> range_list;
	Gtk::TreeView                range_view;
	
	Gtk::ScrolledWindow          range_scroller;
};

/// Allows seleting multiple timespans
class ExportTimespanSelectorMultiple : public ExportTimespanSelector
{
  public:
	ExportTimespanSelectorMultiple ();

  private:

	virtual void fill_range_list ();

	void set_selection_from_state ();
	void update_selection ();
	void update_timespans ();
};

/// Displays one timespan
class ExportTimespanSelectorSingle : public ExportTimespanSelector
{
  public:
	ExportTimespanSelectorSingle (Glib::ustring range_id);

  private:

	virtual void fill_range_list ();
	
	Glib::ustring range_id;

};

#endif /* __export_timespan_selector_h__ */