#include <cassert>
-#include <pbd/compose.h>
+#include "pbd/compose.h"
#include "i18n.h"
{
manager = _manager;
manager->GraphChanged.connect (sigc::mem_fun (*this, &ExportMultiplicator::redraw));
-
+
redraw();
}
if (!manager) { return; }
graph = &manager->get_graph();
-
+
/* Empty table */
-
+
table.foreach (sigc::mem_fun (table, &Gtk::Table::remove));
widget_map.clear();
/* Calculate table dimensions */
-
+
uint32_t max_width = 0;
GraphLevel max_level = NoLevel;
-
+
if (graph->timespans.size() > max_width) {
max_width = graph->timespans.size();
max_level = Timespans;
}
-
+
if (graph->channel_configs.size() > max_width) {
max_width = graph->channel_configs.size();
max_level = ChannelConfigs;
}
-
+
if (graph->formats.size() > max_width) {
max_width = graph->formats.size();
max_level = Formats;
}
-
+
if (graph->filenames.size() > max_width) {
max_width = graph->filenames.size();
max_level = Filenames;
}
-
+
table.resize (4, max_width);
-
+
std::cout << "Table width: " << max_width << std::endl;
-
+
/* Fill table */
-
+
for (list<ExportProfileManager::TimespanNodePtr>::const_iterator it = graph->timespans.begin(); it != graph->timespans.end(); ++it) {
draw_timespan (*it, get_bounds (it->get(), Timespans, max_level));
}
-
+
for (list<ExportProfileManager::ChannelConfigNodePtr>::const_iterator it = graph->channel_configs.begin(); it != graph->channel_configs.end(); ++it) {
draw_channel_config (*it, get_bounds (it->get(), ChannelConfigs, max_level));
}
-
+
for (list<ExportProfileManager::FormatNodePtr>::const_iterator it = graph->formats.begin(); it != graph->formats.end(); ++it) {
draw_format (*it, get_bounds (it->get(), Formats, max_level));
}
-
+
for (list<ExportProfileManager::FilenameNodePtr>::const_iterator it = graph->filenames.begin(); it != graph->filenames.end(); ++it) {
draw_filename (*it, get_bounds (it->get(), Filenames, max_level));
}
-
+
show_all_children ();
}
uint32_t left_bound = 0;
uint32_t right_bound = 0;
-
+
bool left_bound_found = false;
-
+
bool (ExportProfileManager::GraphNode::*relation_func) (ExportProfileManager::GraphNode const *) const;
if (max_level < current_level) {
std::cout << "using 'is_ancestor_of'" << std::endl;
std::cout << "using 'equals'" << std::endl;
relation_func = &ExportProfileManager::GraphNode::equals;
}
-
+
switch (max_level) {
case Timespans:
for (list<ExportProfileManager::TimespanNodePtr>::const_iterator it = graph->timespans.begin(); it != graph->timespans.end(); ++it) {
} else if (!left_bound_found) {
++left_bound;
}
-
+
if (left_bound_found && !CALL_MEMBER_FN(**it, relation_func) (node)) {
break;
} else {
}
}
break;
-
+
case ChannelConfigs:
for (list<ExportProfileManager::ChannelConfigNodePtr>::const_iterator it = graph->channel_configs.begin(); it != graph->channel_configs.end(); ++it) {
if (CALL_MEMBER_FN(**it, relation_func) (node)) {
} else if (!left_bound_found) {
++left_bound;
}
-
+
if (left_bound_found && !CALL_MEMBER_FN(**it, relation_func) (node)) {
break;
} else {
}
}
break;
-
+
case Formats:
for (list<ExportProfileManager::FormatNodePtr>::const_iterator it = graph->formats.begin(); it != graph->formats.end(); ++it) {
if (CALL_MEMBER_FN(**it, relation_func) (node)) {
} else if (!left_bound_found) {
++left_bound;
}
-
+
if (left_bound_found && !CALL_MEMBER_FN(**it, relation_func) (node)) {
break;
} else {
}
}
break;
-
+
case Filenames:
for (list<ExportProfileManager::FilenameNodePtr>::const_iterator it = graph->filenames.begin(); it != graph->filenames.end(); ++it) {
if (CALL_MEMBER_FN(**it, relation_func) (node)) {
std::cout << "filename relation check returned false" << std::endl;
++left_bound;
}
-
+
if (left_bound_found && !CALL_MEMBER_FN(**it, relation_func) (node)) {
break;
} else {
}
}
break;
-
+
case NoLevel:
// Not reached !
break;
}
-
+
return std::pair<uint32_t, uint32_t> (left_bound, right_bound);
}
{
WidgetMap::iterator it = widget_map.find (position);
if (it != widget_map.end()) { return it->second; }
-
+
boost::shared_ptr<Gtk::HBox> widget = widget_map.insert (WidgetPair (position, boost::shared_ptr<Gtk::HBox> (new Gtk::HBox ()))).first->second;
table.attach (*widget, position.left, position.right, position.row - 1, position.row);
-
+
return widget;
}
menu_actions = Gtk::ActionGroup::create();
menu_actions->add (Gtk::Action::create ("Split", _("_Split here")), sigc::mem_fun (*this, &ExportMultiplicator::ButtonWidget::split));
menu_actions->add (Gtk::Action::create ("Remove", _("_Remove")), sigc::mem_fun (*this, &ExportMultiplicator::ButtonWidget::remove));
-
+
ui_manager = Gtk::UIManager::create();
ui_manager->insert_action_group (menu_actions);
-
+
Glib::ustring ui_info =
"<ui>"
" <popup name='PopupMenu'>"
"</ui>";
ui_manager->add_ui_from_string (ui_info);
- menu = dynamic_cast<Gtk::Menu*> (ui_manager->get_widget ("/PopupMenu"));
+ menu = dynamic_cast<Gtk::Menu*> (ui_manager->get_widget ("/PopupMenu"));
add_events (Gdk::BUTTON_PRESS_MASK);
signal_button_press_event ().connect (sigc::mem_fun (*this, &ExportMultiplicator::ButtonWidget::on_button_press_event));
-
+
modify_bg (Gtk::STATE_NORMAL, Gdk::Color ("#0000"));
set_border_width (1);
vbox.pack_start (label, true, true, 4);
if(event->type != GDK_BUTTON_PRESS) { return false; }
if (event->button == 1) {
node->select (!node->selected ());
-
+
if (node->selected ()) {
unset_bg (Gtk::STATE_NORMAL);
modify_bg (Gtk::STATE_NORMAL, Gdk::Color ("#194756"));
unset_bg (Gtk::STATE_NORMAL);
modify_bg (Gtk::STATE_NORMAL, Gdk::Color ("#0000"));
}
-
+
return true;
-
+
} else if (event->button == 3) {
int x, y;
get_pointer (x, y);
split_position = (float) x / get_width();
-
+
menu->popup (event->button, event->time);
return true;
}