summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-03-07 02:11:59 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-03-07 02:11:59 +0000
commit5d82179323ccadff0107143914c796e1c09c6793 (patch)
tree24fc3950a80ad855e3ec56a56638baea47226506 /gtk2_ardour
parentcbfe2f2fa56bd44536e1dbf9dbd3419b5be5f535 (diff)
fix up a substantial mess with the operation of toggle-zoom and related actions, partially caused by XMLNode semantics fixed in a previous commit, but partially caused by issues fixed here
git-svn-id: svn://localhost/ardour2/branches/3.0@11614 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc35
-rw-r--r--gtk2_ardour/editor.h2
-rw-r--r--gtk2_ardour/editor_ops.cc24
-rw-r--r--gtk2_ardour/time_axis_view.cc2
4 files changed, 33 insertions, 30 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index ea8a34b6f4..2b7b0e9918 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -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>
@@ -4146,8 +4146,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)
{
}
@@ -4159,14 +4159,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;
@@ -4179,10 +4179,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);
}
@@ -4193,10 +4195,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);
}
@@ -4213,7 +4216,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 ();
@@ -4222,16 +4225,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
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 62387b535a..857a9786ae 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -484,7 +484,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
typedef std::pair<TimeAxisView*,XMLNode*> TAVState;
struct VisualState {
- VisualState();
+ VisualState (bool with_tracks);
~VisualState ();
double y_position;
double frames_per_unit;
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index cdad586125..70606e28be 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -31,6 +31,7 @@
#include "pbd/basename.h"
#include "pbd/pthread_utils.h"
#include "pbd/memento_command.h"
+#include "pbd/unwind.h"
#include "pbd/whitespace.h"
#include "pbd/stateful_diff_command.h"
@@ -1485,16 +1486,15 @@ Editor::temporal_zoom_region (bool both_axes)
end = max_framepos;
}
- if (both_axes) {
- /* save visual state with track states included, and prevent
- set_frames_per_unit() from doing it again.
- */
- undo_visual_stack.push_back (current_visual_state(true));
- no_save_visual = true;
- }
+ /* if we're zooming on both axes we need to save track heights etc.
+ */
- temporal_zoom_by_frame (start, end, "zoom to region");
+ undo_visual_stack.push_back (current_visual_state (both_axes));
+ PBD::Unwinder<bool> nsv (no_save_visual, true);
+
+ temporal_zoom_by_frame (start, end, "zoom to region");
+
if (both_axes) {
uint32_t per_track_height = (uint32_t) floor ((_canvas_height - canvas_timebars_vsize - 10.0) / tracks.size());
@@ -1517,10 +1517,9 @@ Editor::temporal_zoom_region (bool both_axes)
_routes->resume_redisplay ();
vertical_adjustment.set_value (0.0);
- no_save_visual = false;
}
- redo_visual_stack.push_back (current_visual_state());
+ redo_visual_stack.push_back (current_visual_state (both_axes));
}
void
@@ -6487,7 +6486,8 @@ Editor::fit_tracks (TrackViewList & tracks)
return;
}
- undo_visual_stack.push_back (current_visual_state());
+ undo_visual_stack.push_back (current_visual_state (true));
+ no_save_visual = true;
/* build a list of all tracks, including children */
@@ -6542,7 +6542,7 @@ Editor::fit_tracks (TrackViewList & tracks)
controls_layout.property_height () = full_canvas_height - canvas_timebars_vsize;
vertical_adjustment.set_value (first_y_pos);
- redo_visual_stack.push_back (current_visual_state());
+ redo_visual_stack.push_back (current_visual_state (true));
}
void
diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc
index 60d19ad6d4..104209d884 100644
--- a/gtk2_ardour/time_axis_view.cc
+++ b/gtk2_ardour/time_axis_view.cc
@@ -1312,7 +1312,7 @@ TimeAxisView::reset_visual_state ()
/* this method is not required to trigger a global redraw */
string str = gui_property ("height");
-
+
if (!str.empty()) {
set_height (atoi (str));
} else {