[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/sheetcanvas ClipsViewPort.cpp Shee...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src/sheetcanvas ClipsViewPort.cpp Shee... |
Date: |
Tue, 29 Jan 2008 10:23:12 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 08/01/29 10:23:12
Modified files:
src/sheetcanvas: ClipsViewPort.cpp SheetView.cpp SheetView.h
Log message:
* defer populating the SheetView with TrackViews until the
ClipsViewPort has been initialized and resized, so we _know_ our size too!
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/ClipsViewPort.cpp?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/SheetView.cpp?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/SheetView.h?cvsroot=traverso&r1=1.2&r2=1.3
Patches:
Index: ClipsViewPort.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/sheetcanvas/ClipsViewPort.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ClipsViewPort.cpp 21 Jan 2008 16:17:27 -0000 1.1
+++ ClipsViewPort.cpp 29 Jan 2008 10:23:11 -0000 1.2
@@ -67,7 +67,7 @@
void ClipsViewPort::resizeEvent( QResizeEvent * e )
{
ViewPort::resizeEvent(e);
- m_sw->get_sheetview()->update_scrollbars();
+ m_sw->get_sheetview()->clipviewport_resize_event();
}
Index: SheetView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/sheetcanvas/SheetView.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- SheetView.cpp 22 Jan 2008 20:47:16 -0000 1.2
+++ SheetView.cpp 29 Jan 2008 10:23:11 -0000 1.3
@@ -95,11 +95,13 @@
m_vScrollBar = sheetwidget->m_vScrollBar;
m_hScrollBar = sheetwidget->m_hScrollBar;
m_actOnPlayHead = true;
+ m_viewportReady = false;
m_clipsViewPort->scene()->addItem(this);
m_playCursor = new PlayHead(this, m_sheet, m_clipsViewPort);
m_workCursor = new WorkCursor(this, m_sheet);
+
connect(m_sheet, SIGNAL(workingPosChanged()), m_workCursor,
SLOT(update_position()));
connect(m_sheet, SIGNAL(transferStarted()), this,
SLOT(follow_play_head()));
connect(m_sheet, SIGNAL(transportPosSet()), this,
SLOT(follow_play_head()));
@@ -112,16 +114,8 @@
m_tlvp->setSceneRect(0, -TIMELINE_HEIGHT, MAX_CANVAS_WIDTH, 0);
m_tpvp->setSceneRect(-200, 0, 0, MAX_CANVAS_HEIGHT);
- // Set up the viewports scale factor, and our timeref_scalefactor /
m_peakCacheZoomFactor
- // Needed for our childs TrackView, AudioClipView etc which are created
below.
- scale_factor_changed();
-
sheet_mode_changed();
- foreach(Track* track, m_sheet->get_tracks()) {
- add_new_trackview(track);
- }
-
connect(m_sheet, SIGNAL(hzoomChanged()), this,
SLOT(scale_factor_changed()));
connect(m_sheet, SIGNAL(tempFollowChanged(bool)), this,
SLOT(set_follow_state(bool)));
connect(m_sheet, SIGNAL(trackAdded(Track*)), this,
SLOT(add_new_trackview(Track*)));
@@ -134,13 +128,6 @@
connect(m_hScrollBar, SIGNAL(valueChanged(int)), this,
SLOT(hscrollbar_value_changed(int)));
connect(m_vScrollBar, SIGNAL(valueChanged(int)),
m_clipsViewPort->verticalScrollBar(), SLOT(setValue(int)));
- load_theme_data();
-
- int x, y;
- m_sheet->get_scrollbar_xy(x, y);
- set_hscrollbar_value(x);
- set_vscrollbar_value(y);
-
m_shuttleCurve = new Curve(0);
m_shuttleCurve->set_sheet(m_sheet);
m_dragShuttleCurve = new Curve(0);
@@ -163,7 +150,6 @@
cmd->set_instantanious(true);
Command::process_command(cmd);
}
-
}
SheetView::~SheetView()
@@ -177,23 +163,7 @@
timeref_scalefactor = qint64(m_sheet->get_hzoom() *
(UNIVERSAL_SAMPLE_RATE / 44100));
m_tlvp->scale_factor_changed();
-// int highbit;
-// unsigned long nearestpow2 =
nearest_power_of_two(long(m_sheet->get_hzoom()), highbit);
-// if (nearestpow2 == 0) {
-// nearestpow2 = 1;
-// }
-// qreal xscale = nearestpow2 / m_sheet->get_hzoom();
-// QMatrix matrix;
-// matrix.scale(xscale, 1);
-// m_clipsViewPort->setScene(0);
-// m_clipsViewPort->setMatrix(matrix);
-// m_clipsViewPort->setScene(scene());
-
layout_tracks();
-
-/* printf("nearestpow2 %ld, highbit %d \n", nearestpow2, highbit);
- printf("sheet hzoom %f\n", m_sheet->get_hzoom());
- printf("xscale %f\n", xscale);*/
}
void SheetView::sheet_mode_changed()
@@ -277,6 +247,9 @@
void SheetView::update_scrollbars()
{
int width = (int)(m_sheet->get_last_location() / timeref_scalefactor) -
(m_clipsViewPort->width() / 4);
+ if (width < m_clipsViewPort->width() / 4) {
+ width = m_clipsViewPort->width() / 4;
+ }
m_hScrollBar->setRange(0, width);
m_hScrollBar->setSingleStep(m_clipsViewPort->width() / 10);
@@ -346,6 +319,8 @@
void SheetView::layout_tracks()
{
+ if (m_trackViews.isEmpty() || !m_viewportReady) return;
+
int verticalposition = m_trackTopIndent;
for (int i=0; i<m_trackViews.size(); ++i) {
TrackView* view = m_trackViews.at(i);
@@ -711,3 +686,41 @@
m_sheet->set_scrollbar_xy(m_hScrollBar->value(), m_vScrollBar->value());
}
+void SheetView::clipviewport_resize_event()
+{
+ // Once the ClipViewPort has been initialed, and _resized_
+ // only _then_ we know _our_ size, at which time it makes
+ // sense to populate the view with tracks.
+ static int wasCalledBefore;
+ if (!wasCalledBefore) {
+ // Set up the viewports scale factor, and our
timeref_scalefactor / m_peakCacheZoomFactor
+ // Needed for our childs TrackView, AudioClipView etc which are
created below.
+ scale_factor_changed();
+
+ // fill the view with trackviews, add_new_trackview()
+ // doesn't yet layout the new tracks.
+ foreach(Track* track, m_sheet->get_tracks()) {
+ add_new_trackview(track);
+ }
+
+ // layout_track() now will do it's work when it is called
+ m_viewportReady = true;
+
+ // this will call layout_tracks() for us too
+ // which will continue now, due m_viewportReady is true now
+ load_theme_data();
+
+ // Everything is in place to scroll to the last position
+ // we were at, at closing this view.
+ int x, y;
+ m_sheet->get_scrollbar_xy(x, y);
+ set_hscrollbar_value(x);
+ set_vscrollbar_value(y);
+ } else {
+ // if the viewport was resized, and everything was setup
allready
+ // it suffices to recalculate the scrollbar values.
+ update_scrollbars();
+ }
+
+}
+
Index: SheetView.h
===================================================================
RCS file: /sources/traverso/traverso/src/sheetcanvas/SheetView.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- SheetView.h 22 Jan 2008 20:47:16 -0000 1.2
+++ SheetView.h 29 Jan 2008 10:23:11 -0000 1.3
@@ -82,6 +82,7 @@
void set_shuttle_factor_values(int x, int y);
void vzoom(qreal scale);
void hzoom(qreal scale);
+ void clipviewport_resize_event();
int hscrollbar_value() const;
int vscrollbar_value() const;
int get_peak_cache_zoom_factor() const {return m_peakCacheZoomFactor;}
@@ -107,6 +108,7 @@
QScrollBar* m_vScrollBar;
QScrollBar* m_hScrollBar;
bool m_actOnPlayHead;
+ bool m_viewportReady;
// Themeing data
int m_trackSeperatingHeight;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src/sheetcanvas ClipsViewPort.cpp Shee...,
Remon Sijrier <=