]> git.zarvox.org Git - shareboard.git/blob - shareboardcanvas.cpp
Alignment tweaks; return to connection prompt if disconnected.
[shareboard.git] / shareboardcanvas.cpp
1 #include "shareboardcanvas.h"
2 #include <QMouseEvent>
3 #include <QPaintEvent>
4 #include <QPainter>
5 #include <QPixmap>
6 #include <QDebug>
7
8 ShareboardCanvas::ShareboardCanvas(QWidget* parent) : QWidget(parent) {
9         setMinimumSize(640,480);
10         setMouseTracking(true);
11         currentScene = new QPixmap(size());
12         currentScene->fill();
13         mouseDown = false;
14 }
15
16 ShareboardCanvas::~ShareboardCanvas() {
17         if (currentScene)
18                 delete currentScene;
19 }
20
21 void ShareboardCanvas::mouseMoveEvent(QMouseEvent* event) {
22         // Send mouse move event to network thread
23         // If the button is down
24         if(mouseDown)
25                 dragPath.append(event->posF());
26         // Trigger a repaint
27         update();
28 }
29
30 void ShareboardCanvas::mousePressEvent(QMouseEvent* event) {
31         mouseDown = true;
32         dragPath.append(event->posF()); // We're starting a new drag path
33         //
34 }
35
36 void ShareboardCanvas::mouseReleaseEvent(QMouseEvent* event) {
37         mouseDown = false;
38         qDebug() << dragPath.size() << "mouse move events counted this drag";
39         // Depending on the tool, we now dispatch different types of events
40         dragPath.clear(); // Clear the path; we're no longer tracking a drag
41 }
42
43 void ShareboardCanvas::paintEvent(QPaintEvent* event) {
44         QPainter p(this);
45         // Paint the background from the saved state
46         p.drawPixmap(0, 0, *currentScene);
47         // Now paint our local changes on top of it
48         //p.set
49         // Now paint the set of mouse cursors on top of that
50 }