Diffstat (limited to 'noncore/graphics/drawpad/shapetool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/shapetool.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/graphics/drawpad/shapetool.cpp b/noncore/graphics/drawpad/shapetool.cpp index 8870a78..22e3dd6 100644 --- a/noncore/graphics/drawpad/shapetool.cpp +++ b/noncore/graphics/drawpad/shapetool.cpp | |||
@@ -23,72 +23,72 @@ ShapeTool::ShapeTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | |||
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | m_mousePressed = false; | 25 | m_mousePressed = false; |
26 | m_polyline.resize(3); | 26 | m_polyline.resize(3); |
27 | } | 27 | } |
28 | 28 | ||
29 | ShapeTool::~ShapeTool() | 29 | ShapeTool::~ShapeTool() |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
33 | void ShapeTool::mousePressEvent(QMouseEvent* e) | 33 | void ShapeTool::mousePressEvent(QMouseEvent* e) |
34 | { | 34 | { |
35 | m_pDrawPadCanvas->backupPage(); | ||
36 | |||
35 | m_mousePressed = true; | 37 | m_mousePressed = true; |
36 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); | 38 | m_polyline[2] = m_polyline[1] = m_polyline[0] = e->pos(); |
37 | } | 39 | } |
38 | 40 | ||
39 | void ShapeTool::mouseReleaseEvent(QMouseEvent* e) | 41 | void ShapeTool::mouseReleaseEvent(QMouseEvent* e) |
40 | { | 42 | { |
41 | Q_UNUSED(e) | 43 | Q_UNUSED(e) |
42 | 44 | ||
43 | QPainter painter; | 45 | QPainter painter; |
44 | painter.begin(m_pDrawPadCanvas->currentPage()); | 46 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
45 | drawFinalShape(painter); | 47 | drawFinalShape(painter); |
46 | painter.end(); | 48 | painter.end(); |
47 | 49 | ||
48 | QRect r = m_polyline.boundingRect(); | 50 | QRect r = m_polyline.boundingRect(); |
49 | r = r.normalize(); | 51 | r = r.normalize(); |
50 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 52 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
51 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 53 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
52 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 54 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
53 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 55 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
54 | 56 | ||
55 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 57 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
56 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 58 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
57 | 59 | ||
58 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 60 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
59 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 61 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
60 | 62 | ||
61 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 63 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
62 | 64 | ||
63 | m_mousePressed = false; | 65 | m_mousePressed = false; |
64 | |||
65 | m_pDrawPadCanvas->backupPage(); | ||
66 | } | 66 | } |
67 | 67 | ||
68 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) | 68 | void ShapeTool::mouseMoveEvent(QMouseEvent* e) |
69 | { | 69 | { |
70 | if (m_mousePressed) { | 70 | if (m_mousePressed) { |
71 | m_polyline[0] = e->pos(); | 71 | m_polyline[0] = e->pos(); |
72 | QPainter painter; | 72 | QPainter painter; |
73 | painter.begin(m_pDrawPadCanvas->currentPage()); | 73 | painter.begin(m_pDrawPadCanvas->currentPage()->pixmap()); |
74 | drawTemporaryShape(painter); | 74 | drawTemporaryShape(painter); |
75 | painter.end(); | 75 | painter.end(); |
76 | 76 | ||
77 | QRect r = m_polyline.boundingRect(); | 77 | QRect r = m_polyline.boundingRect(); |
78 | r = r.normalize(); | 78 | r = r.normalize(); |
79 | r.setLeft(r.left() - m_pDrawPad->pen().width()); | 79 | r.setLeft(r.left() - m_pDrawPad->pen().width()); |
80 | r.setTop(r.top() - m_pDrawPad->pen().width()); | 80 | r.setTop(r.top() - m_pDrawPad->pen().width()); |
81 | r.setRight(r.right() + m_pDrawPad->pen().width()); | 81 | r.setRight(r.right() + m_pDrawPad->pen().width()); |
82 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); | 82 | r.setBottom(r.bottom() + m_pDrawPad->pen().width()); |
83 | 83 | ||
84 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), | 84 | QRect viewportRect(m_pDrawPadCanvas->contentsToViewport(r.topLeft()), |
85 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); | 85 | m_pDrawPadCanvas->contentsToViewport(r.bottomRight())); |
86 | 86 | ||
87 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), | 87 | bitBlt(m_pDrawPadCanvas->viewport(), viewportRect.x(), viewportRect.y(), |
88 | m_pDrawPadCanvas->currentPage(), r.x(), r.y(), r.width(), r.height()); | 88 | m_pDrawPadCanvas->currentPage()->pixmap(), r.x(), r.y(), r.width(), r.height()); |
89 | 89 | ||
90 | m_pDrawPadCanvas->viewport()->update(viewportRect); | 90 | m_pDrawPadCanvas->viewport()->update(viewportRect); |
91 | 91 | ||
92 | m_polyline[1] = m_polyline[0]; | 92 | m_polyline[1] = m_polyline[0]; |
93 | } | 93 | } |
94 | } | 94 | } |