Use signal_toggled instead of signal_clicked in ThemeManager so a theme is only ...
[ardour.git] / gtk2_ardour / editor.cc
index 6d9d6581afe319e117e29e277955ced399143f83..61250c1289126010153f80a1969669c58326f7e5 100644 (file)
@@ -17,6 +17,8 @@
 
 */
 
+/* Note: public Editor methods are documented in public_editor.h */
+
 #include <unistd.h>
 #include <cstdlib>
 #include <cmath>
@@ -81,9 +83,9 @@
 
 #include "i18n.h"
 
-/* <CMT Additions> */
+#ifdef WITH_CMT
 #include "imageframe_socket_handler.h"
-/* </CMT Additions> */
+#endif
 
 using namespace std;
 using namespace sigc;
@@ -135,8 +137,8 @@ static const gchar *_zoom_focus_strings[] = {
        N_("Left"),
        N_("Right"),
        N_("Center"),
-       N_("Playhead"),
-       N_("Edit Cursor"),
+       N_("Play"),
+       N_("Edit"),
        0
 };
 
@@ -206,9 +208,9 @@ Editor::Editor ()
          automation_mode_button (_("mode")),
          global_automation_button (_("automation")),
 
-         /* <CMT Additions> */
+#ifdef WITH_CMT
          image_socket_listener(0),
-         /* </CMT Additions> */
+#endif
 
          /* nudge */
 
@@ -310,11 +312,11 @@ Editor::Editor ()
        _dragging_playhead = false;
        _dragging_hscrollbar = false;
 
-       location_marker_color = color_map[cLocationMarker];
-       location_range_color = color_map[cLocationRange];
-       location_cd_marker_color = color_map[cLocationCDMarker];
-       location_loop_color = color_map[cLocationLoop];
-       location_punch_color = color_map[cLocationPunch];
+       location_marker_color = Config->canvasvar_LocationMarker.get();
+       location_range_color = Config->canvasvar_LocationRange.get();
+       location_cd_marker_color = Config->canvasvar_LocationCDMarker.get();
+       location_loop_color = Config->canvasvar_LocationLoop.get();
+       location_punch_color = Config->canvasvar_LocationPunch.get();
 
        range_marker_drag_rect = 0;
        marker_drag_line = 0;
@@ -445,7 +447,7 @@ Editor::Editor ()
        edit_packer.attach (edit_vscrollbar,         3, 4, 1, 2,    FILL,        FILL|EXPAND, 0, 0);
 
        edit_packer.attach (time_button_frame,       0, 2, 0, 1,    FILL,        FILL, 0, 0);
-       edit_packer.attach (time_canvas_event_box,   2, 3, 0, 1,    FILL|EXPAND, FILL, 0, 0);
+       edit_packer.attach (time_canvas_event_box,   2, 4, 0, 1,    FILL|EXPAND, FILL, 0, 0);
 
        edit_packer.attach (controls_layout,         1, 2, 1, 2,    FILL,        FILL|EXPAND, 0, 0);
        edit_packer.attach (track_canvas_event_box,  2, 3, 1, 2,    FILL|EXPAND, FILL|EXPAND, 0, 0);
@@ -626,10 +628,10 @@ Editor::Editor ()
 
        nlabel = manage (new Label (_("Regions")));
        nlabel->set_angle (-90);
-               the_notebook.append_page (region_list_scroller, *nlabel);
+       the_notebook.append_page (region_list_scroller, *nlabel);
        nlabel = manage (new Label (_("Tracks/Busses")));
        nlabel->set_angle (-90);
-               the_notebook.append_page (route_list_scroller, *nlabel);
+       the_notebook.append_page (route_list_scroller, *nlabel);
        nlabel = manage (new Label (_("Snapshots")));
        nlabel->set_angle (-90);
        the_notebook.append_page (snapshot_display_scroller, *nlabel);
@@ -740,7 +742,7 @@ Editor::Editor ()
 
 Editor::~Editor()
 {
-       /* <CMT Additions> */
+#ifdef WITH_CMT
        if(image_socket_listener)
        {
                if(image_socket_listener->is_connected())
@@ -751,7 +753,7 @@ Editor::~Editor()
                delete image_socket_listener ;
                image_socket_listener = 0 ;
        }
-       /* </CMT Additions> */
+#endif
 }
 
 void
@@ -810,6 +812,9 @@ Editor::show_window ()
 {
        show_all ();
        present ();
+       
+       /* re-hide editor list if necessary */
+       editor_list_button_toggled ();
 
        /* now reset all audio_time_axis heights, because widgets might need
           to be re-hidden
@@ -840,9 +845,9 @@ Editor::instant_save ()
        }
 
        if (session) {
-               session->add_instant_xml(get_state(), session->path());
+               session->add_instant_xml(get_state());
        } else {
-               Config->add_instant_xml(get_state(), get_user_ardour_path());
+               Config->add_instant_xml(get_state());
        }
 }
 
@@ -1487,13 +1492,16 @@ Editor::add_region_context_items (Menu_Helpers::MenuList& edit_items)
 
        items.push_back (MenuElem (_("Lock"), bind (mem_fun (*this, &Editor::set_region_lock), true)));
        items.push_back (MenuElem (_("Unlock"), bind (mem_fun (*this, &Editor::set_region_lock), false)));
+       items.push_back (MenuElem (_("Lock Position"), bind (mem_fun (*this, &Editor::set_region_position_lock), true)));
+       items.push_back (MenuElem (_("Unlock Position"), bind (mem_fun (*this, &Editor::set_region_position_lock), false)));
        items.push_back (MenuElem (_("Mute"), bind (mem_fun (*this, &Editor::set_region_mute), true)));
        items.push_back (MenuElem (_("Unmute"), bind (mem_fun (*this, &Editor::set_region_mute), false)));
        items.push_back (MenuElem (_("Opaque"), bind (mem_fun (*this, &Editor::set_region_opaque), true)));
        items.push_back (MenuElem (_("Transparent"), bind (mem_fun (*this, &Editor::set_region_opaque), false)));
 
        /* We allow "Original position" if at least one region is not at its
-          natural position */
+          natural position 
+       */
        RegionSelection::iterator i = selection->regions.begin();
        while (i != selection->regions.end() && (*i)->region()->at_natural_position() == true) {
                ++i;
@@ -1961,6 +1969,22 @@ Editor::set_state (const XMLNode& node)
                        tact->set_active (yn);
                }
        }
+       
+       if ((prop = node.property ("show-editor-list"))) {
+
+               Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
+               assert(act);
+               if (act) {
+
+                       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
+                       bool yn = (prop->value() == X_("yes"));
+
+                       /* do it twice to force the change */
+                       
+                       tact->set_active (!yn);
+                       tact->set_active (yn);
+               }
+       }
 
 
        return 0;
@@ -2032,6 +2056,12 @@ Editor::get_state ()
                Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
                node->add_property (X_("show-editor-mixer"), tact->get_active() ? "yes" : "no");
        }
+       
+       act = ActionManager::get_action (X_("Editor"), X_("show-editor-list"));
+       if (act) {
+               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
+               node->add_property (X_("show-editor-list"), tact->get_active() ? "yes" : "no");
+       }
 
        return *node;
 }
@@ -2054,7 +2084,7 @@ Editor::trackview_by_y_position (double y)
 }
 
 void
-Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
+Editor::snap_to (nframes64_t& start, int32_t direction, bool for_mark)
 {
        Location* before = 0;
        Location* after = 0;
@@ -2063,11 +2093,11 @@ Editor::snap_to (nframes_t& start, int32_t direction, bool for_mark)
                return;
        }
 
-       const nframes_t one_second = session->frame_rate();
-       const nframes_t one_minute = session->frame_rate() * 60;
-       const nframes_t one_smpte_second = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
-       nframes_t one_smpte_minute = (nframes_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
-       nframes_t presnap = start;
+       const nframes64_t one_second = session->frame_rate();
+       const nframes64_t one_minute = session->frame_rate() * 60;
+       const nframes64_t one_smpte_second = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame());
+       nframes64_t one_smpte_minute = (nframes64_t)(rint(session->smpte_frames_per_second()) * session->frames_per_smpte_frame() * 60);
+       nframes64_t presnap = start;
 
        switch (snap_type) {
        case SnapToFrame:
@@ -2389,7 +2419,7 @@ Editor::setup_toolbar ()
        ARDOUR_UI::instance()->tooltips().set_tip (zoom_out_full_button, _("Zoom to Session"));
 
        zoom_focus_selector.set_name ("ZoomFocusSelector");
-       Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Edit Cursor", FUDGE, 0);
+       Gtkmm2ext::set_size_request_to_display_given_text (zoom_focus_selector, "Center", FUDGE, 0);
        set_popdown_strings (zoom_focus_selector, zoom_focus_strings);
        zoom_focus_selector.signal_changed().connect (mem_fun(*this, &Editor::zoom_focus_selection_done));
        ARDOUR_UI::instance()->tooltips().set_tip (zoom_focus_selector, _("Zoom focus"));
@@ -2857,9 +2887,9 @@ Editor::zoom_focus_selection_done ()
                focus_type = ZoomFocusRight;
        } else if (choice == _("Center")) {
                focus_type = ZoomFocusCenter;
-       } else if (choice == _("Playhead")) {
+       } else if (choice == _("Play")) {
                focus_type = ZoomFocusPlayhead;
-       } else if (choice == _("Edit Cursor")) {
+       } else if (choice == _("Edit")) {
                focus_type = ZoomFocusEdit;
        } 
        
@@ -3619,3 +3649,4 @@ Editor::edit_cursor_position(bool sync)
 
        return edit_cursor->current_frame;
 }
+