summaryrefslogtreecommitdiffstats
path: root/src/gui/general/RosegardenCanvasView.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 18:37:05 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 18:37:05 +0000
commit145364a8af6a1fec06556221e66d4b724a62fc9a (patch)
tree53bd71a544008c518034f208d64c932dc2883f50 /src/gui/general/RosegardenCanvasView.h
downloadrosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.tar.gz
rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.zip
Added old abandoned KDE3 version of the RoseGarden MIDI tool
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/rosegarden@1097595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/gui/general/RosegardenCanvasView.h')
-rw-r--r--src/gui/general/RosegardenCanvasView.h197
1 files changed, 197 insertions, 0 deletions
diff --git a/src/gui/general/RosegardenCanvasView.h b/src/gui/general/RosegardenCanvasView.h
new file mode 100644
index 0000000..509c1aa
--- /dev/null
+++ b/src/gui/general/RosegardenCanvasView.h
@@ -0,0 +1,197 @@
+
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
+
+/*
+ Rosegarden
+ A MIDI and audio sequencer and musical notation editor.
+
+ This program is Copyright 2000-2008
+ Guillaume Laurent <glaurent@telegraph-road.org>,
+ Chris Cannam <cannam@all-day-breakfast.com>,
+ Richard Bown <richard.bown@ferventsoftware.com>
+
+ The moral rights of Guillaume Laurent, Chris Cannam, and Richard
+ Bown to claim authorship of this work have been asserted.
+
+ Other copyrights also apply to some parts of this work. Please
+ see the AUTHORS file and individual file headers for details.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version. See the file
+ COPYING included with this distribution for more information.
+*/
+
+#ifndef _RG_ROSEGARDENCANVASVIEW_H_
+#define _RG_ROSEGARDENCANVASVIEW_H_
+
+#include <qpoint.h>
+#include <qtimer.h>
+#include <qcanvas.h>
+#include <qdatetime.h>
+#include <qwmatrix.h>
+
+class QWidget;
+class QWheelEvent;
+class QScrollBar;
+class QResizeEvent;
+
+
+namespace Rosegarden
+{
+
+/**
+ * A QCanvasView with an auxiliary horiz. scrollbar
+ * That scrollbar should be provided by the parent widget
+ * (typically an EditView). The RosegardenCanvasView keeps
+ * the auxilliary horiz. scrollbar range in sync with the
+ * one of its own scrollbar with slotUpdate().
+ */
+
+class RosegardenCanvasView : public QCanvasView
+{
+ Q_OBJECT
+public:
+ RosegardenCanvasView(QCanvas*,
+ QWidget* parent=0, const char* name=0, WFlags f=0);
+
+ /**
+ * EditTool::handleMouseMove() returns a OR-ed combination of these
+ * to indicate which direction to scroll to
+ */
+ enum {
+ NoFollow = 0x0,
+ FollowHorizontal = 0x1,
+ FollowVertical = 0x2
+ };
+
+ /**
+ * Sets the canvas width to be exactly the width needed to show
+ * all the items
+ */
+ void fitWidthToContents();
+
+ /**
+ * Sets the widget which will be between the scrollable part of the view
+ * and the horizontal scrollbar
+ */
+ void setBottomFixedWidget(QWidget*);
+
+ void updateBottomWidgetGeometry();
+
+ /**
+ * Sets the widget which will be between the scrollable part of the view
+ * and the left edge of the view.
+ */
+ void setLeftFixedWidget(QWidget*);
+
+ void updateLeftWidgetGeometry();
+
+ /// Map a point with the inverse world matrix
+ QPoint inverseMapPoint(const QPoint& p) { return inverseWorldMatrix().map(p); }
+
+ void setSmoothScroll(bool s) { m_smoothScroll = s; }
+
+ bool isTimeForSmoothScroll();
+
+ void setScrollDirectionConstraint(int d) { m_scrollDirectionConstraint = d; }
+
+ bool isAutoScrolling() const { return m_autoScrolling; }
+
+ virtual void wheelEvent(QWheelEvent *);
+
+public slots:
+ /// Update the RosegardenCanvasView after a change of content
+ virtual void slotUpdate();
+
+ /**
+ * Scroll horizontally to make the given position visible,
+ * paging to as to get some visibility of the next screenful
+ * (for playback etc)
+ */
+ void slotScrollHoriz(int hpos);
+
+ /**
+ * Scroll horizontally to make the given position somewhat
+ * nearer to visible, scrolling by only "a small distance"
+ * at a time
+ */
+ void slotScrollHorizSmallSteps(int hpos);
+
+ /**
+ * Scroll vertically to make the given position somewhat
+ * nearer to visible, scrolling by only "a small distance"
+ * at a time
+ */
+ void slotScrollVertSmallSteps(int vpos);
+
+ /**
+ * Scroll vertically so as to place the given position
+ * somewhere near the top of the viewport.
+ */
+ void slotScrollVertToTop(int vpos);
+
+ /**
+ * Set the x and y scrollbars to a particular position
+ */
+ void slotSetScrollPos(const QPoint &);
+
+ void startAutoScroll();
+ void startAutoScroll(int directionConstraint);
+ void stopAutoScroll();
+ void doAutoScroll();
+
+signals:
+ void bottomWidgetHeightChanged(int);
+
+ void zoomIn();
+ void zoomOut();
+
+protected:
+
+ virtual void resizeEvent(QResizeEvent*);
+ virtual void setHBarGeometry(QScrollBar &hbar, int x, int y, int w, int h);
+
+ virtual QScrollBar* getMainHorizontalScrollBar() { return horizontalScrollBar(); }
+
+ //--------------- Data members ---------------------------------
+ enum ScrollDirection { None, Top, Bottom, Left, Right };
+
+
+ QWidget* m_bottomWidget;
+ int m_currentBottomWidgetHeight;
+
+ QWidget* m_leftWidget;
+
+ bool m_smoothScroll;
+ int m_smoothScrollTimeInterval;
+ float m_minDeltaScroll;
+ QTime m_scrollTimer;
+ QTime m_scrollAccelerationTimer;
+
+ QTimer m_autoScrollTimer;
+ int m_autoScrollTime;
+ int m_autoScrollAccel;
+ QPoint m_previousP;
+ int m_autoScrollXMargin;
+ int m_autoScrollYMargin;
+ ScrollDirection m_currentScrollDirection;
+ int m_scrollDirectionConstraint;
+ bool m_autoScrolling;
+
+ static const int DefaultSmoothScrollTimeInterval;
+ static const double DefaultMinDeltaScroll;
+
+ static const int AutoscrollMargin;
+ static const int InitialScrollTime;
+ static const int InitialScrollAccel;
+ static const int MaxScrollDelta;
+ static const double ScrollAccelValue;
+
+};
+
+
+}
+
+#endif