add name editing for transport masters
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 26 Sep 2018 23:11:31 +0000 (19:11 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 27 Sep 2018 15:31:13 +0000 (11:31 -0400)
gtk2_ardour/transport_masters_dialog.cc
gtk2_ardour/transport_masters_dialog.h

index 99cef0fcad3833cb9e498348b18b011870ce558e..540f39fbbd653932f336490f784ac1c51c1cbe41 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "pbd/enumwriter.h"
+#include "pbd/i18n.h"
 
 #include "temporal/time.h"
 
@@ -32,9 +33,9 @@
 #include "gtkmm2ext/gui_thread.h"
 
 #include "ardour_ui.h"
+#include "floating_text_entry.h"
 #include "transport_masters_dialog.h"
 
-#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Gtk;
@@ -62,7 +63,6 @@ TransportMastersWidget::TransportMastersWidget ()
        col_title[11].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("Clock\nSynced")));
        col_title[12].set_markup (string_compose ("<span weight=\"bold\">%1</span>", _("29.97/30")));
 
-#if 0
        set_tooltip (col_title[12], _("<b>When enabled</b> the external timecode source is assumed to use 29.97 fps instead of 30000/1001.\n"
                                      "SMPTE 12M-1999 specifies 29.97df as 30000/1001. The spec further mentions that "
                                      "drop-sample timecode has an accumulated error of -86ms over a 24-hour period.\n"
@@ -73,7 +73,6 @@ TransportMastersWidget::TransportMastersWidget ()
 
        set_tooltip (col_title[11], string_compose (_("<b>When enabled</b> the external timecode source is assumed to be sample-clock synced to the audio interface\n"
                                                      "being used by %1."), PROGRAM_NAME));
-#endif
 
        table.set_spacings (6);
 
@@ -137,9 +136,11 @@ TransportMastersWidget::rebuild ()
 
                int col = 0;
 
+               r->label_box.add (r->label);
+
                table.attach (r->use_button, col, col+1, n, n+1); ++col;
+               table.attach (r->label_box, col, col+1, n, n+1); ++col;
                table.attach (r->type, col, col+1, n, n+1); ++col;
-               table.attach (r->label, col, col+1, n, n+1); ++col;
                table.attach (r->format, col, col+1, n, n+1); ++col;
                table.attach (r->current, col, col+1, n, n+1); ++col;
                table.attach (r->last, col, col+1, n, n+1); ++col;
@@ -157,6 +158,8 @@ TransportMastersWidget::rebuild ()
                        r->fr2997_button.signal_toggled().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::fr2997_button_toggled));
                }
 
+               r->label_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
+               r->label_box.signal_button_press_event().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::name_press));
                r->port_combo.signal_changed().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::port_choice_changed));
                r->use_button.signal_toggled().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::use_button_toggled));
                r->collect_button.signal_toggled().connect (sigc::mem_fun (*r, &TransportMastersWidget::Row::collect_button_toggled));
@@ -184,10 +187,35 @@ TransportMastersWidget::rebuild ()
 
 TransportMastersWidget::Row::Row ()
        : request_option_menu (0)
+       , name_editor (0)
        , ignore_active_change (false)
 {
 }
 
+bool
+TransportMastersWidget::Row::name_press (GdkEventButton* ev)
+{
+       if (ev->type == GDK_2BUTTON_PRESS && ev->button == 1) {
+               Gtk::Window* toplevel = dynamic_cast<Gtk::Window*> (label.get_toplevel());
+               if (!toplevel) {
+                       return false;
+               }
+               name_editor = new FloatingTextEntry (toplevel, tm->name());
+               name_editor->use_text.connect (sigc::mem_fun (*this, &TransportMastersWidget::Row::name_edited));
+               name_editor->show ();
+               return true;
+       }
+       return false;
+}
+
+void
+TransportMastersWidget::Row::name_edited (string str, int ignored)
+{
+       tm->set_name (str);
+       /* floating text entry deletes itself */
+       name_editor = 0;
+}
+
 void
 TransportMastersWidget::Row::prop_change (PropertyChange what_changed)
 {
index 752aec1dad1dafa417be4e064f18c55ff0400f82..5848328f8ab152074bb4f5ce09f0a0acc43050dd 100644 (file)
@@ -24,6 +24,7 @@
 #include <string>
 
 #include <gtkmm/button.h>
+#include <gtkmm/eventbox.h>
 #include <gtkmm/radiobutton.h>
 #include <gtkmm/label.h>
 #include <gtkmm/table.h>
@@ -39,6 +40,8 @@ namespace ARDOUR {
        class TransportMaster;
 }
 
+class FloatingTextEntry;
+
 class TransportMastersWidget : public Gtk::VBox, public ARDOUR::SessionHandlePtr
 {
   public:
@@ -54,6 +57,7 @@ class TransportMastersWidget : public Gtk::VBox, public ARDOUR::SessionHandlePtr
   private:
 
        struct Row : sigc::trackable, PBD::ScopedConnectionList {
+               Gtk::EventBox label_box;
                Gtk::Label label;
                Gtk::Label type;
                Gtk::Label format;
@@ -68,6 +72,7 @@ class TransportMastersWidget : public Gtk::VBox, public ARDOUR::SessionHandlePtr
                Gtk::CheckButton fr2997_button;
                Gtk::Button request_options;
                Gtk::Menu* request_option_menu;
+               FloatingTextEntry* name_editor;
 
                void build_request_options();
 
@@ -100,6 +105,9 @@ class TransportMastersWidget : public Gtk::VBox, public ARDOUR::SessionHandlePtr
                bool request_option_press (GdkEventButton*);
                void prop_change (PBD::PropertyChange);
 
+               bool name_press (GdkEventButton*);
+               void name_edited (std::string, int);
+
                PBD::ScopedConnection property_change_connection;
                bool ignore_active_change;
        };