along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
*/
#include <cstdlib>
#include <pbd/error.h>
#include <pbd/stl_delete.h>
+#include <pbd/whitespace.h>
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/selector.h>
#include "i18n.h"
using namespace ARDOUR;
+using namespace PBD;
using namespace sigc;
using namespace Gtk;
-
-//XXX should really have a common home...
-static const gchar* small_x_xpm[] = {
- "11 11 2 1",
- " c None",
- ". c #000000",
- " ",
- " ",
- " . . ",
- " . . ",
- " . . ",
- " . ",
- " . . ",
- " . . ",
- " . . ",
- " ",
- " "};
-
/**
* Abstract Constructor for base visual time axis classes
* @param sess the current session
* @param canvas the parent canvas object
*/
-VisualTimeAxis::VisualTimeAxis(stringcr_t name, PublicEditor& ed, ARDOUR::Session& sess, Canvas& canvas)
+VisualTimeAxis::VisualTimeAxis(const string & name, PublicEditor& ed, ARDOUR::Session& sess, Canvas& canvas)
: AxisView(sess),
TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas),
visual_button (_("v")),
size_button (_("h"))
{
time_axis_name = name ;
- name_prompter = 0 ;
_color = unique_random_color() ;
_marked_for_display = true;
size_button.set_name("TrackSizeButton") ;
visual_button.set_name("TrackVisualButton") ;
hide_button.set_name("TrackRemoveButton") ;
- Glib::RefPtr<Gdk::Pixbuf> small_x_pixbuf = Gdk::Pixbuf::create_from_xpm_data(small_x_xpm);
- hide_button.add(*(Gtk::manage(new Gtk::Image(small_x_pixbuf)))) ;
+ hide_button.add (*(manage (new Image (::get_icon("hide")))));
+ hide_button.show_all ();
+
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")) ;
-
+
+if (0) {
+ /* old school - when we used to put an extra row of buttons in place */
controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
-
+}
/* remove focus from the buttons */
size_button.unset_flags(Gtk::CAN_FOCUS) ;
hide_button.unset_flags(Gtk::CAN_FOCUS) ;
visual_button.unset_flags(Gtk::CAN_FOCUS) ;
- set_height(Normal) ;
+ set_height (hNormal) ;
}
/**
*/
VisualTimeAxis::~VisualTimeAxis()
{
- if(name_prompter)
- {
- delete name_prompter ;
- name_prompter = 0 ;
- }
}
// Name/Id Accessors/Mutators
void
-VisualTimeAxis::set_time_axis_name(stringcr_t name, void* src)
+VisualTimeAxis::set_time_axis_name(const string & name, void* src)
{
std::string old_name = time_axis_name ;
/**
* Sets the height of this TrackView to one of the defined TrackHeghts
*
- * @param h the TrackHeight value to set
+ * @param h
*/
void
-VisualTimeAxis::set_height(TrackHeight h)
+VisualTimeAxis::set_height(uint32_t h)
{
- TimeAxisView::set_height(h) ;
+ TimeAxisView::set_height(h);
- switch (height)
- {
- case Largest:
- case Large:
- case Larger:
- case Normal:
- {
- name_label.hide() ;
- name_entry.show() ;
- other_button_hbox.show_all() ;
- break;
- }
- case Smaller:
- {
- name_label.hide() ;
- name_entry.show() ;
- other_button_hbox.hide_all() ;
- break;
- }
- case Small:
- {
- name_label.show() ;
- name_entry.hide() ;
- other_button_hbox.hide_all() ;
- }
- break;
+ if (h >= hNormal) {
+ hide_name_label ();
+ show_name_entry ();
+ visual_button.show();
+ size_button.show();
+ hide_button.show();
+ } else if (h >= hSmaller) {
+ hide_name_label ();
+ show_name_entry ();
+ visual_button.hide ();
+ size_button.hide ();
+ hide_button.hide();
+ } else if (h >= hSmall) {
+ hide_name_entry ();
+ show_name_label ();
+ visual_button.hide ();
+ size_button.hide ();
+ hide_button.hide ();
}
}
void
VisualTimeAxis::hide_click()
{
- editor.unselect_strip_in_display (*this);
+ // LAME fix for hide_button display refresh
+ hide_button.set_sensitive(false);
+
+ editor.hide_track_in_display (*this);
+
+ hide_button.set_sensitive(true);
}
}
void
-VisualTimeAxis::set_selected_regionviews (AudioRegionSelection& regions)
+VisualTimeAxis::set_selected_regionviews (RegionSelection& regions)
{
// Not handled by purely visual TimeAxis
}
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."));
+ choices.push_back (_("Yes, remove it."));
Gtkmm2ext::Choice prompter (prompt, choices);
- prompter.chosen.connect(sigc::ptr_fun(Gtk::Main::quit));
- prompter.show_all ();
-
- Gtk::Main::run ();
-
- if (prompter.get_choice() == 0)
- {
+ if (prompter.run () == 1) {
/*
- defer to idle loop, otherwise we'll delete this object
- while we're still inside this function ...
+ defer to idle loop, otherwise we'll delete this object
+ while we're still inside this function ...
*/
- Glib::signal_idle().connect(bind(sigc::ptr_fun(&VisualTimeAxis::idle_remove_this_time_axis), this, src));
+ Glib::signal_idle().connect(bind(sigc::ptr_fun(&VisualTimeAxis::idle_remove_this_time_axis), this, src));
}
}
void
VisualTimeAxis::start_time_axis_rename()
{
- if(name_prompter)
- {
- delete name_prompter ;
- name_prompter = 0 ;
- }
-
- name_prompter = new ArdourPrompter() ;
+ ArdourPrompter name_prompter;
- name_prompter->set_prompt (_("new name: ")) ;
- name_prompter->show_all() ;
+ name_prompter.set_prompt (_("new name: ")) ;
+ name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
+ name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
+ name_prompter.show_all() ;
- switch (name_prompter->run ()) {
- case GTK_RESPONSE_ACCEPT:
+ 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 ;
- }
+ name_prompter.get_result (result);
+ if (result.length()) {
+ 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() ;
-
-
}
/**
return;
}
+ strip_whitespace_edges(x);
+
if (x.length() == 0) {
name_entry.set_text (time_axis_name);
return;
}
- strip_whitespace_edges(x);
-
if (!editor.get_named_time_axis(x)) {
set_time_axis_name(x, this);
} else {
- ARDOUR_UI::instance()->popup_error (_("a track already exists with that name"));
+ ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
name_entry.set_text(time_axis_name);
}
}
// Super class methods not handled by VisualTimeAxis
void
-VisualTimeAxis::show_timestretch (jack_nframes_t start, jack_nframes_t end)
+VisualTimeAxis::show_timestretch (nframes_t start, nframes_t end)
{
// Not handled by purely visual TimeAxis
}