summaryrefslogtreecommitdiff
path: root/gtk2_ardour/export_multiplicator.h
blob: 1e204e1a1de143dda9d19d65cacaa8987a25dfa0 (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
/* This file is not used at the moment. It includes code related to export a
 * multiplication graph system that can be used together with the code in
 * libs/ardour/export_multiplication.cc and libs/ardour/ardour/export_multiplication.h
 * - Sakari Bergen 6.8.2008 -
 */

/*
    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_multiplicator_h__
#define __export_multiplicator_h__

#include <utility>
#include <map>

#include "ardour/export_profile_manager.h"

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

using ARDOUR::ExportProfileManager;

class ExportMultiplicator : public Gtk::EventBox {
  public:

	ExportMultiplicator ();
	~ExportMultiplicator ();

	void set_manager (boost::shared_ptr<ExportProfileManager> _manager);

  private:

	boost::shared_ptr<ExportProfileManager>  manager;
	ExportProfileManager::MultiplicationGraph const * graph;

	/* Drawing stuff */

	Gtk::Table table;

	void redraw ();

	enum GraphLevel {
		NoLevel = 0,
		Timespans = 1,
		ChannelConfigs = 2,
		Formats = 3,
		Filenames = 4
	};

	std::pair<uint32_t, uint32_t> get_bounds (ExportProfileManager::GraphNode * node, GraphLevel current_level, GraphLevel max_level) const;

	void draw_timespan (ExportProfileManager::TimespanNodePtr node, std::pair<uint32_t, uint32_t> bounds);
	void draw_channel_config (ExportProfileManager::ChannelConfigNodePtr node, std::pair<uint32_t, uint32_t> bounds);
	void draw_format (ExportProfileManager::FormatNodePtr node, std::pair<uint32_t, uint32_t> bounds);
	void draw_filename (ExportProfileManager::FilenameNodePtr node, std::pair<uint32_t, uint32_t> bounds);

	struct TablePosition {
		uint32_t left;
		uint32_t right;
		uint32_t row;

		TablePosition (uint32_t left, uint32_t right, uint32_t row) :
		  left (left), right (right), row (row) {}

		bool operator== (TablePosition const & other) const { return (row == other.row && left == other.left && right == other.right); }
		bool operator< (TablePosition const & other) const { return (row < other.row || left < other.left || right < other.right); }
	};

	typedef std::map<TablePosition, boost::shared_ptr<Gtk::HBox> > WidgetMap;
	typedef std::pair<TablePosition, boost::shared_ptr<Gtk::HBox> > WidgetPair;

	boost::shared_ptr<Gtk::HBox> get_hbox (TablePosition position);
	WidgetMap widget_map;

	/* Button Widget */

	class ButtonWidget : public Gtk::EventBox {
	  public:
		ButtonWidget (std::string name, boost::shared_ptr<ExportProfileManager> m, ExportProfileManager::GraphNode * node);

	  private:

		Gtk::Label label;
		Gtk::VBox  vbox;

		bool on_button_press_event (GdkEventButton* event);

		void split ();
		void remove ();

		boost::shared_ptr<ExportProfileManager> manager;
		ExportProfileManager::GraphNode * node;
		float split_position;

		/* Context menu */

		Glib::RefPtr<Gtk::ActionGroup> menu_actions;
		Glib::RefPtr<Gtk::UIManager>   ui_manager;
		Gtk::Menu *                    menu;
	};
};

#endif /* __export_multiplicator_h__ */