A possible method for correctly sizing the editor controls, and a couple buttons...
[ardour.git] / gtk2_ardour / ardour_ui2.cc
index 64f85c019251ef6b9ce7f18354603394d1740112..903cc0276c0deabb0f571d559afec4eec3c9179c 100644 (file)
@@ -41,6 +41,7 @@
 #include "ardour_ui.h"
 #include "public_editor.h"
 #include "audio_clock.h"
+#include "actions.h"
 #include "utils.h"
 
 #include "i18n.h"
@@ -49,6 +50,7 @@ using namespace std;
 using namespace ARDOUR;
 using namespace Gtkmm2ext;
 using namespace Gtk;
+using namespace Glib;
 using namespace sigc;
 
 int    
@@ -66,11 +68,6 @@ ARDOUR_UI::setup_windows ()
                return -1;
        }
 
-       if (create_meter_bridge ()) {
-               error << _("UI: cannot setup meter_bridge") << endmsg;
-               return -1;
-       }
-
        /* all other dialogs are created conditionally */
 
        we_have_dependents ();
@@ -204,14 +201,83 @@ ARDOUR_UI::setup_transport ()
                                                 static_cast<Gtk::Widget*> (&transport_frame), 1));
 
 
-       goto_start_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(start_xpm)))));
-       goto_end_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(end_xpm)))));
-       roll_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(arrow_xpm)))));
-       
-       stop_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(stop_xpm)))));
-       play_selection_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(play_selection_xpm)))));
-       rec_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(rec_xpm)))));
-       auto_loop_button.add (*(manage (new Image (Gdk::Pixbuf::create_from_xpm_data(loop_xpm)))));
+       Widget* w;
+
+#ifdef THE_OLD
+       w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(start_xpm)));
+       w->show();
+       goto_start_button.add (*w);
+       w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(end_xpm)));
+       w->show();
+       goto_end_button.add (*w);
+       w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(arrow_xpm)));
+       w->show();
+       roll_button.add (*w);
+       w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(stop_xpm)));
+       w->show();
+       stop_button.add (*w);
+       w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(play_selection_xpm)));
+       w->show();
+       play_selection_button.add (*w);
+       w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(rec_xpm)));
+       w->show();
+       rec_button.add (*w);
+       w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(loop_xpm)));
+       w->show();
+       auto_loop_button.add (*w);
+
+
+       stop_button.set_use_stock (false);
+       roll_button.set_use_stock (false);
+       rec_button.set_use_stock (false);
+       goto_start_button.set_use_stock (false);
+       goto_end_button.set_use_stock (false);
+       auto_loop_button.set_use_stock (false);
+#else
+       w = manage (new Image (Stock::MEDIA_PREVIOUS, ICON_SIZE_BUTTON));
+       w->show();
+       goto_start_button.add (*w);
+       w = manage (new Image (Stock::MEDIA_NEXT, ICON_SIZE_BUTTON));
+       w->show();
+       goto_end_button.add (*w);
+       w = manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_BUTTON));
+       w->show();
+       roll_button.add (*w);
+       w = manage (new Image (Stock::MEDIA_STOP, ICON_SIZE_BUTTON));
+       w->show();
+       stop_button.add (*w);
+       w = manage (new Image (Stock::MEDIA_PLAY, ICON_SIZE_BUTTON));
+       w->show();
+       play_selection_button.add (*w);
+       w = manage (new Image (Stock::MEDIA_RECORD, ICON_SIZE_BUTTON));
+       w->show();
+       rec_button.add (*w);
+       w = manage (new Image (Gdk::Pixbuf::create_from_xpm_data(loop_xpm)));
+       w->show();
+       auto_loop_button.add (*w);
+
+       stop_button.set_use_stock (true);
+       roll_button.set_use_stock (true);
+       rec_button.set_use_stock (true);
+       goto_start_button.set_use_stock (true);
+       goto_end_button.set_use_stock (true);
+       auto_loop_button.set_use_stock (true);
+#endif
+
+       RefPtr<Action> act;
+
+       act = ActionManager::get_action (X_("<Actions>/Common/TransportStop"));
+       act->connect_proxy (stop_button);
+       act = ActionManager::get_action (X_("<Actions>/Common/TransportRoll"));
+       act->connect_proxy (roll_button);
+       act = ActionManager::get_action (X_("<Actions>/Common/TransportRecord"));
+       act->connect_proxy (rec_button);
+       act = ActionManager::get_action (X_("<Actions>/Common/TransportGotoStart"));
+       act->connect_proxy (goto_start_button);
+       act = ActionManager::get_action (X_("<Actions>/Common/TransportGotoEnd"));
+       act->connect_proxy (goto_end_button);
+       act = ActionManager::get_action (X_("<Actions>/Common/TransportLoop"));
+       act->connect_proxy (auto_loop_button);
 
        ARDOUR_UI::instance()->tooltips().set_tip (roll_button, _("Play from playhead"));
        ARDOUR_UI::instance()->tooltips().set_tip (stop_button, _("Stop playback"));
@@ -281,16 +347,6 @@ ARDOUR_UI::setup_transport ()
        punch_in_button.set_events (punch_in_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
        punch_out_button.set_events (punch_out_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
 
-       goto_start_button.signal_clicked().connect (mem_fun(*this,&ARDOUR_UI::transport_goto_start));
-       goto_end_button.signal_clicked().connect (mem_fun(*this,&ARDOUR_UI::transport_goto_end));
-
-       roll_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_roll));
-       play_selection_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_play_selection));
-       auto_loop_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_loop));
-
-       stop_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_stop));
-       rec_button.signal_button_release_event().connect (mem_fun(*this,&ARDOUR_UI::mouse_transport_record));
-
        shuttle_box.signal_button_press_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_press));
        shuttle_box.signal_button_release_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_button_release));
        shuttle_box.signal_motion_notify_event().connect (mem_fun(*this, &ARDOUR_UI::shuttle_box_motion));
@@ -302,10 +358,7 @@ ARDOUR_UI::setup_transport ()
        ARDOUR_UI::Clock.connect (bind (mem_fun (secondary_clock, &AudioClock::set), false));
 
        primary_clock.set_mode (AudioClock::SMPTE);
-       primary_clock.set_name ("TransportClockDisplay");
        secondary_clock.set_mode (AudioClock::BBT);
-       secondary_clock.set_name ("TransportClockDisplay");
-
 
        primary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::primary_clock_value_changed));
        secondary_clock.ValueChanged.connect (mem_fun(*this, &ARDOUR_UI::secondary_clock_value_changed));
@@ -425,16 +478,24 @@ ARDOUR_UI::setup_clock ()
 {
        ARDOUR_UI::Clock.connect (bind (mem_fun (big_clock, &AudioClock::set), false));
        
-       big_clock_window = new ArdourDialog ("big clock window");
+       big_clock_window = new Gtk::Window (WINDOW_TOPLEVEL);
        
        big_clock_window->set_border_width (0);
        big_clock_window->add  (big_clock);
        big_clock_window->set_title (_("ardour: clock"));
        big_clock_window->set_type_hint (Gdk::WINDOW_TYPE_HINT_MENU);
+       big_clock_window->signal_realize().connect (bind (sigc::ptr_fun (set_decoration), big_clock_window,  (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH)));
+       big_clock_window->signal_unmap().connect (bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleBigClock")));
 
-       big_clock_window->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Gtk::Window*>(big_clock_window)));
+       manage_window (*big_clock_window);
+}
 
-       big_clock_window->signal_unmap().connect (mem_fun(*this, &ARDOUR_UI::big_clock_hiding));
+void
+ARDOUR_UI::manage_window (Window& win)
+{
+       win.signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), &win));
+       win.signal_enter_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::enter_window), &win));
+       win.signal_leave_notify_event().connect (bind (mem_fun (Keyboard::the_keyboard(), &Keyboard::leave_window), &win));
 }
 
 void
@@ -689,12 +750,18 @@ ARDOUR_UI::shuttle_box_expose (GdkEventExpose* event)
 void
 ARDOUR_UI::shuttle_style_clicked ()
 {
+       if (shuttle_style_menu == 0) {
+               shuttle_style_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleStylePopup"));
+       }
        shuttle_style_menu->popup (1, 0);
 }
 
 void
 ARDOUR_UI::shuttle_unit_clicked ()
 {
+       if (shuttle_unit_menu == 0) {
+               shuttle_unit_menu = dynamic_cast<Menu*> (ActionManager::get_widget ("/ShuttleUnitPopup"));
+       }
        shuttle_unit_menu->popup (1, 0);
 }