annotate panned.cpp @ 46:bd3accba9b3f

* Better layout for branches; spline connection paths
author Chris Cannam
date Wed, 10 Nov 2010 17:11:41 +0000
parents 4286836bb3c9
children 3c46b2ac45d3
rev   line source
cannam@45 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@45 2
cannam@45 3 /*
cannam@45 4 Rosegarden
cannam@45 5 A MIDI and audio sequencer and musical notation editor.
cannam@45 6 Copyright 2000-2010 the Rosegarden development team.
cannam@45 7
cannam@45 8 Other copyrights also apply to some parts of this work. Please
cannam@45 9 see the AUTHORS file and individual file headers for details.
cannam@45 10
cannam@45 11 This program is free software; you can redistribute it and/or
cannam@45 12 modify it under the terms of the GNU General Public License as
cannam@45 13 published by the Free Software Foundation; either version 2 of the
cannam@45 14 License, or (at your option) any later version. See the file
cannam@45 15 COPYING included with this distribution for more information.
cannam@45 16 */
cannam@45 17
cannam@45 18 #include "panned.h"
cannam@45 19
cannam@45 20 #include <QScrollBar>
Chris@46 21 #include <QGLWidget>
cannam@45 22
cannam@45 23 #include <iostream>
cannam@45 24
cannam@45 25 Panned::Panned()
cannam@45 26 {
Chris@46 27 // setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
Chris@46 28 setRenderHints(QPainter::Antialiasing);
cannam@45 29 }
cannam@45 30
cannam@45 31 void
cannam@45 32 Panned::resizeEvent(QResizeEvent *ev)
cannam@45 33 {
cannam@45 34 QPointF near = mapToScene(0, 0);
cannam@45 35 QPointF far = mapToScene(width(), height());
cannam@45 36 QSizeF sz(far.x()-near.x(), far.y()-near.y());
cannam@45 37 QRectF pr(near, sz);
cannam@45 38
cannam@45 39 if (pr != m_pannedRect) {
cannam@45 40 m_pannedRect = pr;
cannam@45 41 emit pannedRectChanged(pr);
cannam@45 42 }
cannam@45 43
cannam@45 44 QGraphicsView::resizeEvent(ev);
cannam@45 45 }
cannam@45 46
cannam@45 47 void
cannam@45 48 Panned::paintEvent(QPaintEvent *e)
cannam@45 49 {
cannam@45 50 QGraphicsView::paintEvent(e);
cannam@45 51 }
cannam@45 52
cannam@45 53 void
cannam@45 54 Panned::drawForeground(QPainter *paint, const QRectF &)
cannam@45 55 {
cannam@45 56 QPointF near = mapToScene(0, 0);
cannam@45 57 QPointF far = mapToScene(width(), height());
cannam@45 58 QSizeF sz(far.x()-near.x(), far.y()-near.y());
cannam@45 59 QRectF pr(near, sz);
cannam@45 60
cannam@45 61 if (pr != m_pannedRect) {
cannam@45 62 if (pr.x() != m_pannedRect.x()) emit pannedContentsScrolled();
cannam@45 63 m_pannedRect = pr;
cannam@45 64 emit pannedRectChanged(pr);
cannam@45 65 }
cannam@45 66 }
cannam@45 67
cannam@45 68 void
cannam@45 69 Panned::slotSetPannedRect(QRectF pr)
cannam@45 70 {
cannam@45 71 centerOn(pr.center());
cannam@45 72 // setSceneRect(pr);
cannam@45 73 // m_pannedRect = pr;
cannam@45 74 }
cannam@45 75
cannam@45 76 void
cannam@45 77 Panned::wheelEvent(QWheelEvent *ev)
cannam@45 78 {
cannam@45 79 emit wheelEventReceived(ev);
cannam@45 80 QGraphicsView::wheelEvent(ev);
cannam@45 81 }
cannam@45 82
cannam@45 83 void
cannam@45 84 Panned::slotEmulateWheelEvent(QWheelEvent *ev)
cannam@45 85 {
cannam@45 86 QGraphicsView::wheelEvent(ev);
cannam@45 87 }
cannam@45 88
cannam@45 89 void
cannam@45 90 Panned::leaveEvent(QEvent *)
cannam@45 91 {
cannam@45 92 emit mouseLeaves();
cannam@45 93 }