tidy up (a bit) locations editing widget ; use pixbuf/string code from 2.0;remove edit point clock

git-svn-id: svn://localhost/ardour2/branches/3.0@6074 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2009-11-12 20:39:53 +00:00
parent ab565167ff
commit ff9ddf5100
16 changed files with 175 additions and 216 deletions

View file

@ -1217,12 +1217,12 @@ style "tearoff_arrow" = "medium_bold_entry"
style "location_row_button" = "default_button" style "location_row_button" = "default_button"
{ {
font_name = "@FONT_BIG@" font_name = "@FONT_NORMAL@"
} }
style "location_rows_clock" = "default_clock_display" style "location_rows_clock" = "default_clock_display"
{ {
font_name = "@FONT_BIG@" font_name = "@FONT_NORMAL@"
} }
style "pan_slider" style "pan_slider"

View file

@ -1108,6 +1108,7 @@ bool
AudioClock::field_button_release_event (GdkEventButton *ev, Field field) AudioClock::field_button_release_event (GdkEventButton *ev, Field field)
{ {
if (dragging) { if (dragging) {
cerr << "button event on clock but we are dragging\n";
gdk_pointer_ungrab (GDK_CURRENT_TIME); gdk_pointer_ungrab (GDK_CURRENT_TIME);
dragging = false; dragging = false;
if (ev->y > drag_start_y+1 || ev->y < drag_start_y-1 || Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)){ if (ev->y > drag_start_y+1 || ev->y < drag_start_y-1 || Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)){
@ -1125,6 +1126,7 @@ AudioClock::field_button_release_event (GdkEventButton *ev, Field field)
} }
if (Keyboard::is_context_menu_event (ev)) { if (Keyboard::is_context_menu_event (ev)) {
cerr << "Context menu event on clock\n";
if (ops_menu == 0) { if (ops_menu == 0) {
build_ops_menu (); build_ops_menu ();
} }
@ -1954,6 +1956,32 @@ AudioClock::build_ops_menu ()
ops_items.push_back (MenuElem (_("Minutes:Seconds"), bind (mem_fun(*this, &AudioClock::set_mode), MinSec))); ops_items.push_back (MenuElem (_("Minutes:Seconds"), bind (mem_fun(*this, &AudioClock::set_mode), MinSec)));
ops_items.push_back (MenuElem (_("Samples"), bind (mem_fun(*this, &AudioClock::set_mode), Frames))); ops_items.push_back (MenuElem (_("Samples"), bind (mem_fun(*this, &AudioClock::set_mode), Frames)));
ops_items.push_back (MenuElem (_("Off"), bind (mem_fun(*this, &AudioClock::set_mode), Off))); ops_items.push_back (MenuElem (_("Off"), bind (mem_fun(*this, &AudioClock::set_mode), Off)));
if (editable && !is_duration) {
ops_items.push_back (SeparatorElem());
ops_items.push_back (MenuElem (_("Set From Playhead"), mem_fun(*this, &AudioClock::set_from_playhead)));
ops_items.push_back (MenuElem (_("Locate to this time"), mem_fun(*this, &AudioClock::locate)));
}
}
void
AudioClock::set_from_playhead ()
{
if (!session) {
return;
}
set (session->transport_frame());
}
void
AudioClock::locate ()
{
if (!session || is_duration) {
return;
}
session->request_locate (current_time(), false);
} }
void void

View file

@ -49,6 +49,8 @@ class AudioClock : public Gtk::HBox
void focus (); void focus ();
void set (nframes_t, bool force = false, nframes_t offset = 0, char which = 0); void set (nframes_t, bool force = false, nframes_t offset = 0, char which = 0);
void set_from_playhead ();
void locate ();
void set_mode (Mode); void set_mode (Mode);
void set_bbt_reference (nframes64_t); void set_bbt_reference (nframes64_t);

View file

@ -234,7 +234,6 @@ Editor::Editor ()
/* tool bar related */ /* tool bar related */
, edit_point_clock (X_("editpoint"), false, X_("EditPointClock"), true)
, zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true) , zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true)
, toolbar_selection_clock_table (2,3) , toolbar_selection_clock_table (2,3)
@ -471,8 +470,6 @@ Editor::Editor ()
build_cursors (); build_cursors ();
edit_point_clock.ValueChanged.connect (mem_fun(*this, &Editor::edit_point_clock_changed));
ArdourCanvas::Canvas* time_pad = manage(new ArdourCanvas::Canvas()); ArdourCanvas::Canvas* time_pad = manage(new ArdourCanvas::Canvas());
ArdourCanvas::SimpleLine* pad_line_1 = manage(new ArdourCanvas::SimpleLine(*time_pad->root(), ArdourCanvas::SimpleLine* pad_line_1 = manage(new ArdourCanvas::SimpleLine(*time_pad->root(),
0.0, 1.0, 100.0, 1.0)); 0.0, 1.0, 100.0, 1.0));
@ -547,7 +544,7 @@ Editor::Editor ()
the_notebook.set_show_tabs (true); the_notebook.set_show_tabs (true);
the_notebook.set_scrollable (true); the_notebook.set_scrollable (true);
the_notebook.popup_enable (); the_notebook.popup_disable ();
the_notebook.set_tab_pos (Gtk::POS_RIGHT); the_notebook.set_tab_pos (Gtk::POS_RIGHT);
the_notebook.show_all (); the_notebook.show_all ();
@ -785,27 +782,6 @@ Editor::instant_save ()
} }
} }
void
Editor::edit_point_clock_changed()
{
if (_dragging_edit_point) {
return;
}
if (selection->markers.empty()) {
return;
}
bool ignored;
Location* loc = find_location_from_marker (selection->markers.front(), ignored);
if (!loc) {
return;
}
loc->move_to (edit_point_clock.current_time());
}
void void
Editor::zoom_adjustment_changed () Editor::zoom_adjustment_changed ()
{ {
@ -1074,8 +1050,6 @@ Editor::connect_to_session (Session *t)
session_connections.push_back (session->Located.connect (mem_fun (*this, &Editor::located))); session_connections.push_back (session->Located.connect (mem_fun (*this, &Editor::located)));
session_connections.push_back (session->config.ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed))); session_connections.push_back (session->config.ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed)));
edit_point_clock.set_mode(AudioClock::BBT);
edit_point_clock.set_session (session);
zoom_range_clock.set_session (session); zoom_range_clock.set_session (session);
_playlist_selector->set_session (session); _playlist_selector->set_session (session);
nudge_clock.set_session (session); nudge_clock.set_session (session);
@ -2852,17 +2826,17 @@ Editor::setup_toolbar ()
zoom_box.set_border_width (0); zoom_box.set_border_width (0);
zoom_in_button.set_name ("EditorTimeButton"); zoom_in_button.set_name ("EditorTimeButton");
zoom_in_button.add (*(manage (new Image (::get_icon("zoom_in"))))); zoom_in_button.set_image (*(manage (new Image (Stock::ZOOM_IN, Gtk::ICON_SIZE_BUTTON))));
zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false)); zoom_in_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In")); ARDOUR_UI::instance()->tooltips().set_tip (zoom_in_button, _("Zoom In"));
zoom_out_button.set_name ("EditorTimeButton"); zoom_out_button.set_name ("EditorTimeButton");
zoom_out_button.add (*(manage (new Image (::get_icon("zoom_out"))))); zoom_out_button.set_image (*(manage (new Image (Stock::ZOOM_OUT, Gtk::ICON_SIZE_BUTTON))));
zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true)); zoom_out_button.signal_clicked().connect (bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out")); ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_button, _("Zoom Out"));
zoom_out_full_button.set_name ("EditorTimeButton"); zoom_out_full_button.set_name ("EditorTimeButton");
zoom_out_full_button.add (*(manage (new Image (::get_icon("zoom_full"))))); zoom_out_full_button.set_image (*(manage (new Image (Stock::ZOOM_100, Gtk::ICON_SIZE_BUTTON))));
zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session)); zoom_out_full_button.signal_clicked().connect (mem_fun(*this, &Editor::temporal_zoom_session));
ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session")); ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
@ -2918,7 +2892,6 @@ Editor::setup_toolbar ()
edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done)); edit_point_selector.signal_changed().connect (mem_fun(*this, &Editor::edit_point_selection_done));
ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point")); ARDOUR_UI::instance()->tooltips().set_tip (edit_point_selector, _("Edit point"));
snap_box.pack_start (edit_point_clock, false, false);
snap_box.pack_start (snap_mode_selector, false, false); snap_box.pack_start (snap_mode_selector, false, false);
snap_box.pack_start (snap_type_selector, false, false); snap_box.pack_start (snap_type_selector, false, false);
snap_box.pack_start (edit_point_selector, false, false); snap_box.pack_start (edit_point_selector, false, false);

View file

@ -1484,7 +1484,6 @@ public:
void editor_mixer_button_toggled (); void editor_mixer_button_toggled ();
void editor_list_button_toggled (); void editor_list_button_toggled ();
AudioClock edit_point_clock;
AudioClock zoom_range_clock; AudioClock zoom_range_clock;
Gtk::Button zoom_in_button; Gtk::Button zoom_in_button;
Gtk::Button zoom_out_button; Gtk::Button zoom_out_button;
@ -1558,8 +1557,6 @@ public:
void zoom_adjustment_changed(); void zoom_adjustment_changed();
void edit_point_clock_changed();
void setup_toolbar (); void setup_toolbar ();
Gtkmm2ext::TearOff* tools_tearoff; Gtkmm2ext::TearOff* tools_tearoff;
@ -1957,8 +1954,6 @@ public:
std::vector<std::string> edit_point_strings; std::vector<std::string> edit_point_strings;
void selected_marker_moved (ARDOUR::Location*); void selected_marker_moved (ARDOUR::Location*);
sigc::connection edit_point_clock_connection_a;
sigc::connection edit_point_clock_connection_b;
bool get_edit_op_range (nframes64_t& start, nframes64_t& end) const; bool get_edit_op_range (nframes64_t& start, nframes64_t& end) const;

View file

@ -2378,13 +2378,11 @@ MarkerDrag::motion (GdkEvent* event, bool)
assert (!_copied_locations.empty()); assert (!_copied_locations.empty());
_editor->edit_point_clock.set (_copied_locations.front()->start());
_editor->show_verbose_time_cursor (newframe, 10); _editor->show_verbose_time_cursor (newframe, 10);
#ifdef GTKOSX #ifdef GTKOSX
_editor->update_canvas_now (); _editor->update_canvas_now ();
#endif #endif
_editor->edit_point_clock.set (copy_location->start());
} }
void void

View file

@ -1177,34 +1177,10 @@ Editor::marker_selection_changed ()
} }
} }
edit_point_clock_connection_a.disconnect();
edit_point_clock_connection_b.disconnect();
if (selection->markers.empty()) {
edit_point_clock.set (0);
return;
}
for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) { for (MarkerSelection::iterator x = selection->markers.begin(); x != selection->markers.end(); ++x) {
(*x)->add_line (cursor_group, 0, _canvas_height); (*x)->add_line (cursor_group, 0, _canvas_height);
(*x)->show_line (); (*x)->show_line ();
} }
edit_point_clock.set (selection->markers.front()->position());
bool ignored;
Location* loc = find_location_from_marker (selection->markers.front(), ignored);
if (loc) {
edit_point_clock_connection_a = loc->changed.connect (mem_fun (*this, &Editor::selected_marker_moved));
edit_point_clock_connection_b = loc->start_changed.connect (mem_fun (*this, &Editor::selected_marker_moved));
}
}
void
Editor::selected_marker_moved (Location* loc)
{
edit_point_clock.set (loc->start());
} }
struct SortLocationsByPosition { struct SortLocationsByPosition {

View file

@ -360,10 +360,6 @@ Editor::session_going_away ()
_routes->clear (); _routes->clear ();
_route_groups->clear (); _route_groups->clear ();
edit_point_clock_connection_a.disconnect();
edit_point_clock_connection_b.disconnect();
edit_point_clock.set_session (0);
zoom_range_clock.set_session (0); zoom_range_clock.set_session (0);
nudge_clock.set_session (0); nudge_clock.set_session (0);

View file

@ -197,7 +197,7 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)
uint32_t keyval; uint32_t keyval;
bool ret = false; bool ret = false;
#if 0 #if 1
cerr << "snoop widget " << widget << " key " << event->keyval << " type: " << event->type cerr << "snoop widget " << widget << " key " << event->keyval << " type: " << event->type
<< " state " << std::hex << event->state << std::dec << " state " << std::hex << event->state << std::dec
<< endl; << endl;

View file

@ -45,30 +45,26 @@ using namespace Gtkmm2ext;
LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num) LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
: location(0), session(0), : location(0), session(0),
item_table (1, 7, false), item_table (1, 6, false),
start_set_button (_("Use PH")),
start_go_button (_("Go")),
start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true), start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true),
end_set_button (_("Use PH")),
end_go_button (_("Go")),
end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true), end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true),
length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, true), length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, true),
cd_check_button (_("CD")), cd_check_button (_("CD")),
hide_check_button (_("Hidden")), hide_check_button (_("Hide")),
remove_button (_("Remove")),
scms_check_button (_("SCMS")), scms_check_button (_("SCMS")),
preemph_check_button (_("Pre-Emphasis")) preemph_check_button (_("Pre-Emphasis"))
{ {
i_am_the_modifier = 0; i_am_the_modifier = 0;
start_go_button.set_image (*manage (new Image (Stock::JUMP_TO, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
end_go_button.set_image (*manage (new Image (Stock::JUMP_TO, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
remove_button.set_image (*manage (new Image (Stock::REMOVE, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
number_label.set_name ("LocationEditNumberLabel"); number_label.set_name ("LocationEditNumberLabel");
name_label.set_name ("LocationEditNameLabel"); name_label.set_name ("LocationEditNameLabel");
name_entry.set_name ("LocationEditNameEntry"); name_entry.set_name ("LocationEditNameEntry");
start_set_button.set_name ("LocationEditSetButton");
start_go_button.set_name ("LocationEditGoButton"); start_go_button.set_name ("LocationEditGoButton");
end_set_button.set_name ("LocationEditSetButton");
end_go_button.set_name ("LocationEditGoButton"); end_go_button.set_name ("LocationEditGoButton");
cd_check_button.set_name ("LocationEditCdButton"); cd_check_button.set_name ("LocationEditCdButton");
hide_check_button.set_name ("LocationEditHideButton"); hide_check_button.set_name ("LocationEditHideButton");
@ -82,9 +78,6 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
composer_label.set_name ("LocationEditNumberLabel"); composer_label.set_name ("LocationEditNumberLabel");
composer_entry.set_name ("LocationEditNameEntry"); composer_entry.set_name ("LocationEditNameEntry");
ARDOUR_UI::instance()->tooltips().set_tip(start_set_button, _("Set value to Playhead"));
ARDOUR_UI::instance()->tooltips().set_tip(end_set_button, _("Set value to Playhead"));
isrc_label.set_text ("ISRC: "); isrc_label.set_text ("ISRC: ");
isrc_label.set_size_request (30, -1); isrc_label.set_size_request (30, -1);
performer_label.set_text ("Performer: "); performer_label.set_text ("Performer: ");
@ -117,44 +110,29 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
scms_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::scms_toggled)); scms_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::scms_toggled));
preemph_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::preemph_toggled)); preemph_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::preemph_toggled));
set_session (sess); set_session (sess);
// start_hbox.pack_start (start_go_button, false, false);
item_table.attach (number_label, 0, 1, 0, 1, FILL, FILL, 3, 0);
start_hbox.pack_start (start_go_button, false, false);
start_hbox.pack_start (start_clock, false, false); start_hbox.pack_start (start_clock, false, false);
start_hbox.pack_start (start_set_button, false, false);
item_table.attach (start_hbox, 2, 3, 0, 1, FILL, FILL, 4, 0); /* this is always in this location, no matter what the location is */
item_table.attach (start_hbox, 1, 2, 0, 1, FILL, FILL, 4, 0);
start_set_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::set_button_pressed), LocStart));
start_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocStart)); start_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocStart));
start_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocStart)); start_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocStart));
start_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocStart)); start_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocStart));
// end_hbox.pack_start (end_go_button, false, false);
end_hbox.pack_start (end_go_button, false, false);
end_hbox.pack_start (end_clock, false, false); end_hbox.pack_start (end_clock, false, false);
end_hbox.pack_start (end_set_button, false, false);
//item_table.attach (end_hbox, 2, 3, 0, 1, 0, 0, 4, 0);
end_set_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::set_button_pressed), LocEnd));
end_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocEnd)); end_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocEnd));
end_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocEnd)); end_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocEnd));
end_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocEnd)); end_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocEnd));
// item_table.attach (length_clock, 3, 4, 0, 1, 0, 0, 4, 0);
length_clock.ValueChanged.connect (bind ( mem_fun(*this, &LocationEditRow::clock_changed), LocLength)); length_clock.ValueChanged.connect (bind ( mem_fun(*this, &LocationEditRow::clock_changed), LocLength));
length_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocLength)); length_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocLength));
// item_table.attach (cd_check_button, 4, 5, 0, 1, 0, Gtk::FILL, 4, 0);
// item_table.attach (hide_check_button, 5, 6, 0, 1, 0, Gtk::FILL, 4, 0);
// item_table.attach (remove_button, 7, 8, 0, 1, 0, Gtk::FILL, 4, 0);
cd_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::cd_toggled)); cd_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::cd_toggled));
hide_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::hide_toggled)); hide_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::hide_toggled));
@ -216,7 +194,7 @@ LocationEditRow::set_location (Location *loc)
if (!location) return; if (!location) return;
if (!hide_check_button.get_parent()) { if (!hide_check_button.get_parent()) {
item_table.attach (hide_check_button, 6, 7, 0, 1, FILL, Gtk::FILL, 4, 0); item_table.attach (hide_check_button, 5, 6, 0, 1, FILL, Gtk::FILL, 4, 0);
} }
hide_check_button.set_active (location->is_hidden()); hide_check_button.set_active (location->is_hidden());
@ -227,7 +205,7 @@ LocationEditRow::set_location (Location *loc)
name_label.set_size_request (80, -1); name_label.set_size_request (80, -1);
if (!name_label.get_parent()) { if (!name_label.get_parent()) {
item_table.attach (name_label, 1, 2, 0, 1, FILL, FILL, 4, 0); item_table.attach (name_label, 0, 1, 0, 1, FILL, FILL, 4, 0);
} }
name_label.show(); name_label.show();
@ -240,21 +218,17 @@ LocationEditRow::set_location (Location *loc)
name_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::name_entry_changed)); name_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::name_entry_changed));
if (!name_entry.get_parent()) { if (!name_entry.get_parent()) {
item_table.attach (name_entry, 1, 2, 0, 1, FILL | EXPAND, FILL, 4, 0); item_table.attach (name_entry, 0, 1, 0, 1, FILL | EXPAND, FILL, 4, 0);
} }
name_entry.show(); name_entry.show();
if (!cd_check_button.get_parent()) { if (!cd_check_button.get_parent()) {
item_table.attach (cd_check_button, 5, 6, 0, 1, FILL, FILL, 4, 0); item_table.attach (cd_check_button, 4, 5, 0, 1, FILL, FILL, 4, 0);
} }
if (!remove_button.get_parent()) { if (!remove_button.get_parent()) {
item_table.attach (remove_button, 7, 8, 0, 1, FILL, FILL, 4, 0); item_table.attach (remove_button, 6, 7, 0, 1, FILL, FILL, 4, 0);
} }
/* XXX i can't find a way to hide the button without messing up
the row spacing, so make it insensitive (paul).
*/
if (location->is_end() || location->is_start()) { if (location->is_end() || location->is_start()) {
remove_button.set_sensitive (false); remove_button.set_sensitive (false);
} }
@ -276,27 +250,35 @@ LocationEditRow::set_location (Location *loc)
if (!location->is_mark()) { if (!location->is_mark()) {
if (!end_hbox.get_parent()) { if (!end_hbox.get_parent()) {
item_table.attach (end_hbox, 3, 4, 0, 1, FILL, FILL, 4, 0); item_table.attach (end_hbox, 2, 3, 0, 1, FILL, FILL, 4, 0);
} }
if (!length_clock.get_parent()) { if (!length_clock.get_parent()) {
item_table.attach (length_clock, 4, 5, 0, 1, FILL, FILL, 4, 0); item_table.attach (length_clock, 3, 4, 0, 1, FILL, FILL, 4, 0);
} }
end_clock.set (location->end(), true); end_clock.set (location->end(), true);
length_clock.set (location->length(), true); length_clock.set (location->length(), true);
end_set_button.show();
end_go_button.show(); end_go_button.show();
end_clock.show(); end_clock.show();
length_clock.show(); length_clock.show();
ARDOUR_UI::instance()->tooltips().set_tip (end_go_button, _("Jump to the end of this range"));
ARDOUR_UI::instance()->tooltips().set_tip (start_go_button, _("Jump to the start of this range"));
ARDOUR_UI::instance()->tooltips().set_tip (remove_button, _("Forget this range"));
ARDOUR_UI::instance()->tooltips().set_tip (start_clock, _("Start time"));
ARDOUR_UI::instance()->tooltips().set_tip (end_clock, _("End time"));
ARDOUR_UI::instance()->tooltips().set_tip (length_clock, _("Length"));
} else { } else {
end_set_button.hide(); ARDOUR_UI::instance()->tooltips().set_tip (start_go_button, _("Jump to this marker"));
ARDOUR_UI::instance()->tooltips().set_tip (remove_button, _("Forget this marker"));
ARDOUR_UI::instance()->tooltips().set_tip (start_clock, _("Position"));
end_go_button.hide(); end_go_button.hide();
end_clock.hide(); end_clock.hide();
length_clock.hide(); length_clock.hide();
} }
start_clock.set_sensitive (!location->locked()); start_clock.set_sensitive (!location->locked());
@ -365,23 +347,6 @@ LocationEditRow::composer_entry_changed ()
} }
void
LocationEditRow::set_button_pressed (LocationPart part)
{
if (!location) return;
switch (part) {
case LocStart:
location->set_start (session->transport_frame ());
break;
case LocEnd:
location->set_end (session->transport_frame ());
break;
default:
break;
}
}
void void
LocationEditRow::go_button_pressed (LocationPart part) LocationEditRow::go_button_pressed (LocationPart part)
{ {
@ -467,7 +432,7 @@ LocationEditRow::cd_toggled ()
} }
if (!cd_track_details_hbox.get_parent()) { if (!cd_track_details_hbox.get_parent()) {
item_table.attach (cd_track_details_hbox, 1, 8, 1, 2, FILL | EXPAND, FILL, 4, 0); item_table.attach (cd_track_details_hbox, 0, 7, 1, 2, FILL | EXPAND, FILL, 4, 0);
} }
// item_table.resize(2, 7); // item_table.resize(2, 7);
cd_track_details_hbox.show_all(); cd_track_details_hbox.show_all();
@ -621,13 +586,16 @@ LocationEditRow::focus_name() {
LocationUI::LocationUI () LocationUI::LocationUI ()
: session (0) : session (0)
, add_location_button (_("Add New Location")) , add_location_button (_("New Location"))
, add_range_button (_("Add New Range")) , add_range_button (_("New Range"))
{ {
i_am_the_modifier = 0; i_am_the_modifier = 0;
location_vpacker.set_spacing (5); location_vpacker.set_spacing (5);
add_location_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON)));
add_range_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON)));
location_vpacker.pack_start (loop_edit_row, false, false); location_vpacker.pack_start (loop_edit_row, false, false);
location_vpacker.pack_start (punch_edit_row, false, false); location_vpacker.pack_start (punch_edit_row, false, false);
@ -646,10 +614,14 @@ LocationUI::LocationUI ()
loc_frame_box.pack_start (location_rows_scroller, true, true); loc_frame_box.pack_start (location_rows_scroller, true, true);
add_location_button.set_name ("LocationAddLocationButton"); add_location_button.set_name ("LocationAddLocationButton");
loc_frame_box.pack_start (add_location_button, false, false);
HBox* add_button_box = manage (new HBox);
// loc_frame_box.pack_start (add_location_button, false, false);
add_button_box->pack_start (add_location_button, true, true);
loc_frame.set_name ("LocationLocEditorFrame"); loc_frame.set_name ("LocationLocEditorFrame");
loc_frame.set_label (_("Location (CD index) markers")); loc_frame.set_label (_("Markers (including CD index)"));
loc_frame.add (loc_frame_box); loc_frame.add (loc_frame_box);
loc_range_panes.pack1(loc_frame, true, false); loc_range_panes.pack1(loc_frame, true, false);
@ -666,13 +638,16 @@ LocationUI::LocationUI ()
range_frame_box.pack_start (range_rows_scroller, true, true); range_frame_box.pack_start (range_rows_scroller, true, true);
add_range_button.set_name ("LocationAddRangeButton"); add_range_button.set_name ("LocationAddRangeButton");
range_frame_box.pack_start (add_range_button, false, false); //range_frame_box.pack_start (add_range_button, false, false);
add_button_box->pack_start (add_range_button, true, true);
range_frame.set_name ("LocationRangeEditorFrame"); range_frame.set_name ("LocationRangeEditorFrame");
range_frame.set_label (_("Range (CD track) markers")); range_frame.set_label (_("Ranges (including CD track ranges)"));
range_frame.add (range_frame_box); range_frame.add (range_frame_box);
loc_range_panes.pack2(range_frame, true, false); loc_range_panes.pack2(range_frame, true, false);
location_vpacker.pack_start (loc_range_panes, true, true); location_vpacker.pack_start (loc_range_panes, true, true);
location_vpacker.pack_start (*add_button_box, false, false);
pack_start (location_vpacker, true, true); pack_start (location_vpacker, true, true);
@ -880,8 +855,6 @@ LocationUI::refresh_location_list ()
loc_children.clear(); loc_children.clear();
range_children.clear(); range_children.clear();
cerr << "about to map locations with session = " << session << endl;
if (session) { if (session) {
session->locations()->apply (*this, &LocationUI::map_locations); session->locations()->apply (*this, &LocationUI::map_locations);
} }
@ -941,7 +914,6 @@ LocationUIWindow::~LocationUIWindow()
void void
LocationUIWindow::on_show() LocationUIWindow::on_show()
{ {
cerr << "Show loc list\n";
_ui.refresh_location_list(); _ui.refresh_location_list();
ArdourDialog::on_show(); ArdourDialog::on_show();
} }
@ -956,8 +928,6 @@ LocationUIWindow::on_delete_event (GdkEventAny*)
void void
LocationUIWindow::set_session (Session *s) LocationUIWindow::set_session (Session *s)
{ {
cerr << "Setting session in LUW, with s = " << s << "\n";
ArdourDialog::set_session (s); ArdourDialog::set_session (s);
_ui.set_session (s); _ui.set_session (s);

View file

@ -77,12 +77,10 @@ class LocationEditRow : public Gtk::HBox
Gtk::Label number_label; Gtk::Label number_label;
Gtk::HBox start_hbox; Gtk::HBox start_hbox;
Gtk::Button start_set_button;
Gtk::Button start_go_button; Gtk::Button start_go_button;
AudioClock start_clock; AudioClock start_clock;
Gtk::HBox end_hbox; Gtk::HBox end_hbox;
Gtk::Button end_set_button;
Gtk::Button end_go_button; Gtk::Button end_go_button;
AudioClock end_clock; AudioClock end_clock;

View file

@ -356,39 +356,12 @@ Marker::the_item() const
void void
Marker::set_name (const string& new_name) Marker::set_name (const string& new_name)
{ {
uint32_t pb_width; int name_width = pixel_width (new_name, *name_font) + 2;
double font_size;
if (new_name.empty()) { name_pixbuf->property_pixbuf() = pixbuf_from_ustring(new_name, name_font, name_width, name_height);
return;
}
font_size = name_font->get_size() / Pango::SCALE;
pb_width = new_name.length() * font_size;
Glib::RefPtr<Gdk::Pixbuf> buf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, pb_width, name_height);
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, pb_width, name_height);
cairo_t *cr = cairo_create (surface);
cairo_text_extents_t te;
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
cairo_select_font_face (cr, name_font->get_family().c_str(),
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, font_size);
cairo_text_extents (cr, new_name.c_str(), &te);
cairo_move_to (cr, 0.5,
0.5 - te.height / 2 - te.y_bearing + name_height / 2);
cairo_show_text (cr, new_name.c_str());
unsigned char* src = cairo_image_surface_get_data (surface);
convert_bgra_to_rgba(src, buf->get_pixels(), pb_width, name_height);
cairo_destroy(cr);
name_pixbuf->property_pixbuf() = buf;
if (_type == End || _type == LoopEnd || _type == PunchOut) { if (_type == End || _type == LoopEnd || _type == PunchOut) {
name_pixbuf->property_x() = -(te.width); name_pixbuf->property_x() = - (name_width);
} }
} }

View file

@ -56,6 +56,7 @@ bool TimeAxisViewItem::have_name_font = false;
const double TimeAxisViewItem::NAME_X_OFFSET = 15.0; const double TimeAxisViewItem::NAME_X_OFFSET = 15.0;
const double TimeAxisViewItem::GRAB_HANDLE_LENGTH = 6 ; const double TimeAxisViewItem::GRAB_HANDLE_LENGTH = 6 ;
int TimeAxisViewItem::NAME_HEIGHT;
double TimeAxisViewItem::NAME_Y_OFFSET; double TimeAxisViewItem::NAME_Y_OFFSET;
double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE; double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE;
double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH; double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH;
@ -96,6 +97,7 @@ TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group&
layout->set_font_description (*NAME_FONT); layout->set_font_description (*NAME_FONT);
Gtkmm2ext::get_ink_pixel_size (layout, width, height); Gtkmm2ext::get_ink_pixel_size (layout, width, height);
NAME_HEIGHT = height;
NAME_Y_OFFSET = height + 3; NAME_Y_OFFSET = height + 3;
NAME_HIGHLIGHT_SIZE = height + 2; NAME_HIGHLIGHT_SIZE = height + 2;
NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3; NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
@ -145,6 +147,8 @@ TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color const & ba
show_vestigial = true; show_vestigial = true;
visibility = vis; visibility = vis;
_sensitive = true; _sensitive = true;
name_pixbuf_width = 0;
last_item_width = 0;
if (duration == 0) { if (duration == 0) {
warning << "Time Axis Item Duration == 0" << endl ; warning << "Time Axis Item Duration == 0" << endl ;
@ -525,48 +529,16 @@ TimeAxisViewItem::get_time_axis_view()
void void
TimeAxisViewItem::set_name_text(const ustring& new_name) TimeAxisViewItem::set_name_text(const ustring& new_name)
{ {
uint32_t pb_width, it_width; if (!name_pixbuf) {
double font_size;
font_size = NAME_FONT->get_size() / Pango::SCALE;
it_width = trackview.editor().frame_to_pixel(item_duration);
pb_width = new_name.length() * font_size;
if (pb_width > it_width - NAME_X_OFFSET) {
pb_width = it_width - NAME_X_OFFSET;
}
if (pb_width <= 0 || it_width < NAME_X_OFFSET) {
if (name_pixbuf) {
name_pixbuf->hide();
}
return; return;
} else {
name_pixbuf->show();
} }
Glib::RefPtr<Gdk::Pixbuf> buf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, pb_width, NAME_HIGHLIGHT_SIZE); last_item_width = trackview.editor().frame_to_pixel(item_duration);
name_pixbuf_width = pixel_width (new_name, *NAME_FONT) + 2;
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, pb_width, NAME_HIGHLIGHT_SIZE ); name_pixbuf->property_pixbuf() = pixbuf_from_ustring(new_name, NAME_FONT, name_pixbuf_width, NAME_HEIGHT);
cairo_t *cr = cairo_create (surface);
cairo_text_extents_t te;
cairo_set_source_rgba (cr, 0.2, 0.2, 0.2, 1.0);
cairo_select_font_face (cr, NAME_FONT->get_family().c_str(),
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, 10);
cairo_text_extents (cr, new_name.c_str(), &te);
cairo_move_to (cr, 0.5,
0.5 - te.height / 2 - te.y_bearing + NAME_HIGHLIGHT_SIZE / 2);
cairo_show_text (cr, new_name.c_str());
unsigned char* src = cairo_image_surface_get_data (surface);
convert_bgra_to_rgba(src, buf->get_pixels(), pb_width, NAME_HIGHLIGHT_SIZE);
cairo_destroy(cr);
name_pixbuf->property_pixbuf() = buf;
} }
/** /**
* Set the height of this item * Set the height of this item
* *
@ -897,7 +869,40 @@ TimeAxisViewItem::reset_width_dependent_items (double pixel_width)
void void
TimeAxisViewItem::reset_name_width (double /*pixel_width*/) TimeAxisViewItem::reset_name_width (double /*pixel_width*/)
{ {
set_name_text (item_name); uint32_t it_width;
int pb_width;
bool pixbuf_holds_full_name;
if (!name_pixbuf) {
return;
}
it_width = trackview.editor().frame_to_pixel(item_duration);
pb_width = name_pixbuf_width;
pixbuf_holds_full_name = last_item_width > pb_width + NAME_X_OFFSET;
last_item_width = it_width;
if (pixbuf_holds_full_name && (it_width >= pb_width + NAME_X_OFFSET)) {
/*
we've previously had the full name length showing
and its still showing.
*/
return;
}
if (pb_width > it_width - NAME_X_OFFSET) {
pb_width = it_width - NAME_X_OFFSET;
}
if (pb_width <= 0 || it_width <= NAME_X_OFFSET) {
name_pixbuf->hide();
return;
} else {
name_pixbuf->show();
}
name_pixbuf->property_pixbuf() = pixbuf_from_ustring(item_name, NAME_FONT, pb_width, NAME_HEIGHT);
} }

View file

@ -275,6 +275,7 @@ class TimeAxisViewItem : public Selectable
/* these are not constant, but vary with the pixel size /* these are not constant, but vary with the pixel size
of the font used to display the item name. of the font used to display the item name.
*/ */
static int NAME_HEIGHT;
static double NAME_Y_OFFSET ; static double NAME_Y_OFFSET ;
static double NAME_HIGHLIGHT_SIZE ; static double NAME_HIGHLIGHT_SIZE ;
static double NAME_HIGHLIGHT_THRESH ; static double NAME_HIGHLIGHT_THRESH ;
@ -453,6 +454,8 @@ class TimeAxisViewItem : public Selectable
uint32_t lock_handle_color_r ; uint32_t lock_handle_color_r ;
uint32_t lock_handle_color_g ; uint32_t lock_handle_color_g ;
uint32_t lock_handle_color_b ; uint32_t lock_handle_color_b ;
uint32_t last_item_width;
int name_pixbuf_width;
ArdourCanvas::Group* group; ArdourCanvas::Group* group;
ArdourCanvas::SimpleRect* vestigial_frame; ArdourCanvas::SimpleRect* vestigial_frame;

View file

@ -936,3 +936,40 @@ resize_window_to_proportion_of_monitor (Gtk::Window* window, int max_width, int
window->resize (w, h); window->resize (w, h);
} }
Glib::RefPtr<Gdk::Pixbuf>
pixbuf_from_ustring(const ustring& name, Pango::FontDescription* font, int clip_width, int clip_height)
{
static Glib::RefPtr<Gdk::Pixbuf>* empty_pixbuf = 0;
if (name.empty()) {
if (empty_pixbuf == 0) {
empty_pixbuf = new Glib::RefPtr<Gdk::Pixbuf>;
*empty_pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, clip_width, clip_height);
}
cerr << "\n\nUSE EMPTY PIXBUF\n";
return *empty_pixbuf;
}
Glib::RefPtr<Gdk::Pixbuf> buf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, clip_width, clip_height);
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, clip_width, clip_height);
cairo_t* cr = cairo_create (surface);
cairo_text_extents_t te;
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
cairo_select_font_face (cr, font->get_family().c_str(),
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, font->get_size() / Pango::SCALE);
cairo_text_extents (cr, name.c_str(), &te);
cairo_move_to (cr, 0.5, 0.5 - te.height / 2 - te.y_bearing + clip_height / 2);
cairo_show_text (cr, name.c_str());
convert_bgra_to_rgba(cairo_image_surface_get_data (surface), buf->get_pixels(), clip_width, clip_height);
cairo_destroy(cr);
cairo_surface_destroy(surface);
return buf;
}

View file

@ -102,6 +102,11 @@ void convert_bgra_to_rgba (guint8 const* src,
int width, int width,
int height); int height);
Glib::RefPtr<Gdk::Pixbuf> pixbuf_from_ustring (const Glib::ustring& name,
Pango::FontDescription* font,
int clip_width,
int clip_height);
void resize_window_to_proportion_of_monitor (Gtk::Window*, int, int); void resize_window_to_proportion_of_monitor (Gtk::Window*, int, int);
#endif /* __ardour_gtk_utils_h__ */ #endif /* __ardour_gtk_utils_h__ */