Make the close button in the config info dialog work.
[ardour.git] / gtk2_ardour / editor.cc
index e23b439fc3e68b1806fadbc77da3a979527e230d..d77296b07e2b9d9f45d477f65423ed926cff7fdd 100644 (file)
@@ -43,7 +43,7 @@
 #include "pbd/enumwriter.h"
 #include "pbd/memento_command.h"
 #include "pbd/unknown_type.h"
-#include "pbd/stacktrace.h"
+#include "pbd/unwind.h"
 
 #include <glibmm/miscutils.h>
 #include <gtkmm/image.h>
@@ -151,6 +151,8 @@ static const gchar *_snap_type_strings[] = {
        N_("Timecode Minutes"),
        N_("Seconds"),
        N_("Minutes"),
+       N_("Beats/128"),
+       N_("Beats/64"),
        N_("Beats/32"),
        N_("Beats/28"),
        N_("Beats/24"),
@@ -368,6 +370,7 @@ Editor::Editor ()
        layering_order_editor = 0;
        no_save_visual = false;
        resize_idle_id = -1;
+       within_track_canvas = false;
 
        scrubbing_direction = 0;
 
@@ -647,6 +650,10 @@ Editor::Editor ()
        set_snap_mode (_snap_mode);
        set_mouse_mode (MouseObject, true);
         pre_internal_mouse_mode = MouseObject;
+        pre_internal_snap_type = _snap_type;
+        pre_internal_snap_mode = _snap_mode;
+        internal_snap_type = _snap_type;
+        internal_snap_mode = _snap_mode;
        set_edit_point_preference (EditAtMouse, true);
 
        _playlist_selector = new PlaylistSelector();
@@ -2064,6 +2071,8 @@ Editor::set_snap_to (SnapType st)
        instant_save ();
 
        switch (_snap_type) {
+       case SnapToBeatDiv128:
+       case SnapToBeatDiv64:
        case SnapToBeatDiv32:
        case SnapToBeatDiv28:
        case SnapToBeatDiv24:
@@ -2222,7 +2231,7 @@ Editor::set_state (const XMLNode& node, int /*version*/)
        }
 
        if ((prop = node.property ("zoom-focus"))) {
-               set_zoom_focus ((ZoomFocus) atoi (prop->value()));
+               set_zoom_focus ((ZoomFocus) string_2_enum (prop->value(), zoom_focus));
        }
 
        if ((prop = node.property ("zoom"))) {
@@ -2232,11 +2241,27 @@ Editor::set_state (const XMLNode& node, int /*version*/)
        }
 
        if ((prop = node.property ("snap-to"))) {
-               set_snap_to ((SnapType) atoi (prop->value()));
+               set_snap_to ((SnapType) string_2_enum (prop->value(), _snap_type));
        }
 
        if ((prop = node.property ("snap-mode"))) {
-               set_snap_mode ((SnapMode) atoi (prop->value()));
+               set_snap_mode ((SnapMode) string_2_enum (prop->value(), _snap_mode));
+       }
+
+       if ((prop = node.property ("internal-snap-to"))) {
+               internal_snap_type = (SnapType) string_2_enum (prop->value(), internal_snap_type);
+       }
+
+       if ((prop = node.property ("internal-snap-mode"))) {
+               internal_snap_mode = (SnapMode) string_2_enum (prop->value(), internal_snap_mode);
+       }
+
+       if ((prop = node.property ("pre-internal-snap-to"))) {
+               pre_internal_snap_type = (SnapType) string_2_enum (prop->value(), pre_internal_snap_type);
+       }
+
+       if ((prop = node.property ("pre-internal-snap-mode"))) {
+               pre_internal_snap_mode = (SnapMode) string_2_enum (prop->value(), pre_internal_snap_mode);
        }
 
        if ((prop = node.property ("mouse-mode"))) {
@@ -2420,15 +2445,15 @@ Editor::get_state ()
 
        maybe_add_mixer_strip_width (*node);
 
-       snprintf (buf, sizeof(buf), "%d", (int) zoom_focus);
-       node->add_property ("zoom-focus", buf);
+       node->add_property ("zoom-focus", enum_2_string (zoom_focus));
        snprintf (buf, sizeof(buf), "%f", frames_per_unit);
        node->add_property ("zoom", buf);
-       snprintf (buf, sizeof(buf), "%d", (int) _snap_type);
-       node->add_property ("snap-to", buf);
-       snprintf (buf, sizeof(buf), "%d", (int) _snap_mode);
-       node->add_property ("snap-mode", buf);
-
+       node->add_property ("snap-to", enum_2_string (_snap_type));
+       node->add_property ("snap-mode", enum_2_string (_snap_mode));
+       node->add_property ("internal-snap-to", enum_2_string (internal_snap_type));
+       node->add_property ("internal-snap-mode", enum_2_string (internal_snap_mode));
+       node->add_property ("pre-internal-snap-to", enum_2_string (pre_internal_snap_type));
+       node->add_property ("pre-internal-snap-mode", enum_2_string (pre_internal_snap_mode));
        node->add_property ("edit-point", enum_2_string (_edit_point));
 
        snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame);
@@ -2635,6 +2660,12 @@ Editor::snap_to_internal (framepos_t& start, int32_t direction, bool for_mark)
                start = _session->tempo_map().round_to_beat (start, direction);
                break;
 
+       case SnapToBeatDiv128:
+               start = _session->tempo_map().round_to_beat_subdivision (start, 128, direction);
+               break;
+       case SnapToBeatDiv64:
+               start = _session->tempo_map().round_to_beat_subdivision (start, 64, direction);
+               break;
        case SnapToBeatDiv32:
                start = _session->tempo_map().round_to_beat_subdivision (start, 32, direction);
                break;
@@ -2791,6 +2822,9 @@ Editor::setup_toolbar ()
        smart_mode_joiner = manage (new ButtonJoiner ("mouse mode button", mouse_move_button, mouse_select_button));
        smart_mode_joiner->set_related_action (smart_mode_action);
 
+       mouse_move_button.set_elements (ArdourButton::Element (ArdourButton::Body|ArdourButton::Text));
+       mouse_select_button.set_elements (ArdourButton::Element (ArdourButton::Body|ArdourButton::Text));
+
        mouse_move_button.set_rounded_corner_mask (0x1); // upper left only 
        mouse_select_button.set_rounded_corner_mask (0x2); // upper right only 
 
@@ -3017,6 +3051,7 @@ Editor::setup_tooltips ()
        ARDOUR_UI::instance()->set_tip (snap_mode_selector, _("Snap/Grid Mode"));
        ARDOUR_UI::instance()->set_tip (edit_point_selector, _("Edit point"));
        ARDOUR_UI::instance()->set_tip (edit_mode_selector, _("Edit Mode"));
+       ARDOUR_UI::instance()->set_tip (nudge_clock, _("Nudge Clock\n(controls distance used to nudge regions and selections)"));
 }
 
 int
@@ -3347,6 +3382,10 @@ Editor::snap_type_selection_done ()
                snaptype = SnapToBeatDiv28;
        } else if (choice == _("Beats/32")) {
                snaptype = SnapToBeatDiv32;
+       } else if (choice == _("Beats/64")) {
+               snaptype = SnapToBeatDiv64;
+       } else if (choice == _("Beats/128")) {
+               snaptype = SnapToBeatDiv128;
        } else if (choice == _("Beats")) {
                snaptype = SnapToBeat;
        } else if (choice == _("Bars")) {
@@ -3754,6 +3793,12 @@ Editor::get_grid_type_as_beats (bool& success, framepos_t position)
                return 1.0;
                break;
 
+       case SnapToBeatDiv128:
+               return 1.0/128.0;
+               break;
+       case SnapToBeatDiv64:
+               return 1.0/64.0;
+               break;
        case SnapToBeatDiv32:
                return 1.0/32.0;
                break;
@@ -4102,8 +4147,8 @@ Editor::reposition_and_zoom (framepos_t frame, double fpu)
        }
 }
 
-Editor::VisualState::VisualState ()
-       : gui_state (new GUIObjectState)
+Editor::VisualState::VisualState (bool with_tracks)
+       : gui_state (with_tracks ? new GUIObjectState : 0)
 {
 }
 
@@ -4115,14 +4160,14 @@ Editor::VisualState::~VisualState ()
 Editor::VisualState*
 Editor::current_visual_state (bool with_tracks)
 {
-       VisualState* vs = new VisualState;
+       VisualState* vs = new VisualState (with_tracks);
        vs->y_position = vertical_adjustment.get_value();
        vs->frames_per_unit = frames_per_unit;
        vs->leftmost_frame = leftmost_frame;
        vs->zoom_focus = zoom_focus;
 
        if (with_tracks) {      
-               *(vs->gui_state) = *ARDOUR_UI::instance()->gui_object_state;
+               *vs->gui_state = *ARDOUR_UI::instance()->gui_object_state;
        }
 
        return vs;
@@ -4135,10 +4180,12 @@ Editor::undo_visual_state ()
                return;
        }
 
-       redo_visual_stack.push_back (current_visual_state());
-
        VisualState* vs = undo_visual_stack.back();
        undo_visual_stack.pop_back();
+
+
+       redo_visual_stack.push_back (current_visual_state (vs ? vs->gui_state != 0 : false));
+
        use_visual_state (*vs);
 }
 
@@ -4149,10 +4196,11 @@ Editor::redo_visual_state ()
                return;
        }
 
-       undo_visual_stack.push_back (current_visual_state());
-
        VisualState* vs = redo_visual_stack.back();
        redo_visual_stack.pop_back();
+
+       undo_visual_stack.push_back (current_visual_state (vs ? vs->gui_state != 0 : false));
+
        use_visual_state (*vs);
 }
 
@@ -4169,7 +4217,7 @@ Editor::swap_visual_state ()
 void
 Editor::use_visual_state (VisualState& vs)
 {
-       no_save_visual = true;
+       PBD::Unwinder<bool> nsv (no_save_visual, true);
 
        _routes->suspend_redisplay ();
 
@@ -4178,16 +4226,16 @@ Editor::use_visual_state (VisualState& vs)
        set_zoom_focus (vs.zoom_focus);
        reposition_and_zoom (vs.leftmost_frame, vs.frames_per_unit);
        
-       *ARDOUR_UI::instance()->gui_object_state = *vs.gui_state;
-
-       for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {    
-               (*i)->reset_visual_state ();
+       if (vs.gui_state) {
+               *ARDOUR_UI::instance()->gui_object_state = *vs.gui_state;
+               
+               for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {    
+                       (*i)->reset_visual_state ();
+               }
        }
 
        _routes->update_visibility ();
        _routes->resume_redisplay ();
-
-       no_save_visual = false;
 }
 
 void