X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fvisual_time_axis.cc;h=9782a8c9f6f8e2cb6c3cf6a663f7167bddd4111f;hb=a7055e0863ff8cd9054eb88fcf3b292e385408a7;hp=71c0da3ebe879cc0b0a8ad81632b386e8e04a5e8;hpb=e493b2b7c4fbbbfc457f02babf9546289b430177;p=ardour.git diff --git a/gtk2_ardour/visual_time_axis.cc b/gtk2_ardour/visual_time_axis.cc index 71c0da3ebe..9782a8c9f6 100644 --- a/gtk2_ardour/visual_time_axis.cc +++ b/gtk2_ardour/visual_time_axis.cc @@ -41,7 +41,6 @@ #include "ardour_ui.h" #include "public_editor.h" #include "imageframe_time_axis.h" -#include "canvas-simplerect.h" #include "imageframe_time_axis_view.h" #include "marker_time_axis_view.h" #include "imageframe_view.h" @@ -50,6 +49,7 @@ #include "utils.h" #include "prompter.h" #include "rgb_macros.h" +#include "canvas_impl.h" #include "i18n.h" @@ -83,7 +83,7 @@ static const gchar* small_x_xpm[] = { * @param sess the current session * @param canvas the parent canvas object */ -VisualTimeAxis::VisualTimeAxis(std::string name, PublicEditor& ed, ARDOUR::Session& sess, Widget *canvas) +VisualTimeAxis::VisualTimeAxis(const string & name, PublicEditor& ed, ARDOUR::Session& sess, Canvas& canvas) : AxisView(sess), TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas), visual_button (_("v")), @@ -94,19 +94,19 @@ VisualTimeAxis::VisualTimeAxis(std::string name, PublicEditor& ed, ARDOUR::Sessi _color = unique_random_color() ; _marked_for_display = true; - name_entry.activate.connect(slot(*this, &VisualTimeAxis::name_entry_changed)) ; - name_entry.focus_out_event.connect(slot(*this, &VisualTimeAxis::name_entry_focus_out_handler)) ; - name_entry.button_press_event.connect(slot(*this, &VisualTimeAxis::name_entry_button_press_handler)) ; - name_entry.button_release_event.connect(slot(*this, &VisualTimeAxis::name_entry_button_release_handler)) ; - name_entry.key_release_event.connect(slot(*this, &VisualTimeAxis::name_entry_key_release_handler)) ; + name_entry.signal_activate().connect(mem_fun(*this, &VisualTimeAxis::name_entry_changed)) ; + name_entry.signal_button_press_event().connect(mem_fun(*this, &VisualTimeAxis::name_entry_button_press_handler)) ; + name_entry.signal_button_release_event().connect(mem_fun(*this, &VisualTimeAxis::name_entry_button_release_handler)) ; + name_entry.signal_key_release_event().connect(mem_fun(*this, &VisualTimeAxis::name_entry_key_release_handler)) ; size_button.set_name("TrackSizeButton") ; visual_button.set_name("TrackVisualButton") ; hide_button.set_name("TrackRemoveButton") ; - hide_button.add(*(Gtk::manage(new Gtk::Image(small_x_xpm)))) ; - size_button.button_release_event.connect (slot (*this, &VisualTimeAxis::size_click)) ; - visual_button.signal_clicked().connect (slot (*this, &VisualTimeAxis::visual_click)) ; - hide_button.signal_clicked().connect (slot (*this, &VisualTimeAxis::hide_click)) ; + Glib::RefPtr small_x_pixbuf = Gdk::Pixbuf::create_from_xpm_data(small_x_xpm); + hide_button.add(*(Gtk::manage(new Gtk::Image(small_x_pixbuf)))) ; + size_button.signal_button_release_event().connect (mem_fun (*this, &VisualTimeAxis::size_click)) ; + visual_button.signal_clicked().connect (mem_fun (*this, &VisualTimeAxis::visual_click)) ; + hide_button.signal_clicked().connect (mem_fun (*this, &VisualTimeAxis::hide_click)) ; ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height")) ; ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options")) ; ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track")) ; @@ -141,7 +141,7 @@ VisualTimeAxis::~VisualTimeAxis() // Name/Id Accessors/Mutators void -VisualTimeAxis::set_time_axis_name(std::string name, void* src) +VisualTimeAxis::set_time_axis_name(const string & name, void* src) { std::string old_name = time_axis_name ; @@ -222,7 +222,7 @@ VisualTimeAxis::visual_click() void VisualTimeAxis::hide_click() { - editor.unselect_strip_in_display (*this); + editor.hide_track_in_display (*this); } @@ -247,15 +247,17 @@ bool VisualTimeAxis::choose_time_axis_color() { bool picked ; - GdkColor color ; + Gdk::Color color ; gdouble current[4] ; + Gdk::Color current_color ; current[0] = _color.get_red() / 65535.0 ; current[1] = _color.get_green() / 65535.0 ; current[2] = _color.get_blue() / 65535.0 ; current[3] = 1.0 ; - - color = Gtkmm2ext::UI::instance()->get_color(_("ardour: color selection"),picked, current) ; + + current_color.set_rgb_p (current[0],current[1],current[2]); + color = Gtkmm2ext::UI::instance()->get_color(_("ardour: color selection"),picked, ¤t_color) ; if (picked) { @@ -270,7 +272,7 @@ VisualTimeAxis::choose_time_axis_color() * @param c the new TimeAxis color */ void -VisualTimeAxis::set_time_axis_color(Gdk_Color c) +VisualTimeAxis::set_time_axis_color(Gdk::Color c) { _color = c ; } @@ -294,14 +296,14 @@ VisualTimeAxis::remove_this_time_axis(void* src) { vector choices; - std::string prompt = compose (_("Do you really want to remove track \"%1\" ?\n(cannot be undone)"), time_axis_name); + std::string prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n(cannot be undone)"), time_axis_name); choices.push_back (_("Yes, remove it.")); choices.push_back (_("No, do nothing.")); Gtkmm2ext::Choice prompter (prompt, choices); - prompter.chosen.connect (Gtk::Main::quit.slot()); + prompter.chosen.connect(sigc::ptr_fun(Gtk::Main::quit)); prompter.show_all (); Gtk::Main::run (); @@ -312,7 +314,7 @@ VisualTimeAxis::remove_this_time_axis(void* src) defer to idle loop, otherwise we'll delete this object while we're still inside this function ... */ - Gtk::Main::idle.connect(bind(slot(&VisualTimeAxis::idle_remove_this_time_axis), this, src)); + Glib::signal_idle().connect(bind(sigc::ptr_fun(&VisualTimeAxis::idle_remove_this_time_axis), this, src)); } } @@ -356,47 +358,32 @@ VisualTimeAxis::start_time_axis_rename() name_prompter = new ArdourPrompter() ; name_prompter->set_prompt (_("new name: ")) ; - ARDOUR_UI::instance()->allow_focus(true) ; - name_prompter->done.connect (slot(*this, &VisualTimeAxis::finish_time_axis_rename)) ; name_prompter->show_all() ; -} -/** - * Handles the new name for this TimeAxis from the name prompt - * - * @see start_time_axis_rename() - */ -void -VisualTimeAxis::finish_time_axis_rename() -{ - name_prompter->hide_all () ; - ARDOUR_UI::instance()->allow_focus (false) ; - - if (name_prompter->status == Gtkmm2ext::Prompter::cancelled) - { - return; - } - - string result ; - name_prompter->get_result (result) ; - //time_axis_name = result ; - - if (editor.get_named_time_axis(result) != 0) { - ARDOUR_UI::instance()->popup_error (_("A track already exists with that name")); - return ; + switch (name_prompter->run ()) { + case GTK_RESPONSE_ACCEPT: + string result; + name_prompter->get_result (result); + if (editor.get_named_time_axis(result) != 0) { + ARDOUR_UI::instance()->popup_error (_("A track already exists with that name")); + return ; + } + + set_time_axis_name(result, this) ; } - - set_time_axis_name(result, this) ; - delete name_prompter ; name_prompter = 0 ; label_view() ; + + } /** - * Handle the (re-)displaying of the TimeAxis name label + * Handles the new name for this TimeAxis from the name prompt * + * @see start_time_axis_rename() */ + void VisualTimeAxis::label_view() { @@ -412,8 +399,6 @@ VisualTimeAxis::label_view() void VisualTimeAxis::name_entry_changed() { - ARDOUR_UI::generic_focus_out_event (0); - string x = name_entry.get_text (); if (x == time_axis_name) { @@ -450,13 +435,6 @@ VisualTimeAxis::name_entry_button_release_handler(GdkEventButton *ev) return FALSE; } -gint -VisualTimeAxis::name_entry_focus_out_handler(GdkEventFocus* ev) -{ - name_entry_changed(); - return TRUE; -} - gint VisualTimeAxis::name_entry_key_release_handler(GdkEventKey* ev) {