Debian Codegraph @

src/cursor.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2016, Mike Walters <[email protected]>
3 *
4 * This file is part of inspectrum.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <QApplication>
21 #include "cursor.h"cxx . . $ `<file>/src/cursor.h`/
22
23 Cursorcxx . . $ Cursor#::Cursorcxx . . $ Cursor#Cursor(ae0eefa7fd332390).(Qtcxx . . $ Qt/::Orientationcxx . . $ Qt/Orientation# orientation, Qtcxx . . $ Qt/::CursorShapecxx . . $ Qt/CursorShape# mouseCursorShape, QObjectcxx . . $ QObject# * parent) : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).::QObjectcxx . . $ QObject#(parent), orientationcxx . . $ Cursor#orientation.(orientation), cursorShapecxx . . $ Cursor#cursorShape.(mouseCursorShape)
24 {
25
26 }
27
28 int Cursorcxx . . $ Cursor#::fromPointcxx . . $ Cursor#fromPoint(70366837c528ef32).(QPointcxx . . $ QPoint# point)
29 {
30 return (orientationcxx . . $ Cursor#orientation. == Qtcxx . . $ Qt/::Verticalcxx . . $ Qt/Vertical.) ? point.xcxx . . $ QPoint#x(455f465bc33b4cdf).() : point.ycxx . . $ QPoint#y(455f465bc33b4cdf).();
31 }
32
33 bool Cursorcxx . . $ Cursor#::pointOverCursorcxx . . $ Cursor#pointOverCursor(578814ae554e72f6).(QPointcxx . . $ QPoint# point)
34 {
35 const int margin = 5;
36 range_tcxx . . $ range_t#<int> range = {cursorPositioncxx . . $ Cursor#cursorPosition. - margin, cursorPositioncxx . . $ Cursor#cursorPosition. + margin};
37 return range.containscxx . . $ range_t#contains(8877ebe272b9620d).(fromPointcxx . . $ Cursor#fromPoint(70366837c528ef32).(point));
38 }
39
40 bool Cursorcxx . . $ Cursor#::mouseEventcxx . . $ Cursor#mouseEvent(bf65bbe40893342c).(QEventcxx . . $ QEvent#::Typecxx . . $ QEvent#Type# type, QMouseEventcxx . . $ QMouseEvent# *event)
41 {
42 // If the mouse pointer moves over a cursor, display a resize pointer
43 if (pointOverCursorcxx . . $ Cursor#pointOverCursor(578814ae554e72f6).(event->poscxx . . $ QMouseEvent#pos(75d69cfbd3c4b2dd).())) {
44 if (!cursorOverridencxx . . $ Cursor#cursorOverriden.) {
45 cursorOverridencxx . . $ Cursor#cursorOverriden. = true;
46 QApplicationcxx . . $ QApplication#::setOverrideCursorcxx . . $ QGuiApplication#setOverrideCursor(abdcfda6ee8376ea).(QCursorcxx . . $ QCursor#QCursor(1a9232e7b845eb22).(cursorShapecxx . . $ Cursor#cursorShape.));
47 }
48 // Restore pointer if it moves off the cursor
49 } else if (cursorOverridencxx . . $ Cursor#cursorOverriden.) {
50 cursorOverridencxx . . $ Cursor#cursorOverriden. = false;
51 QApplicationcxx . . $ QApplication#::restoreOverrideCursorcxx . . $ QGuiApplication#restoreOverrideCursor(49f6e7a06ebc5aa8).();
52 }
53
54 // Start dragging on left mouse button press, if over a cursor
55 if (type == QEventcxx . . $ QEvent#::MouseButtonPresscxx . . $ QEvent#MouseButtonPress.) {
56 if (event->buttoncxx . . $ QMouseEvent#button(4a2598559eeedfc9).() == Qtcxx . . $ Qt/::LeftButtoncxx . . $ Qt/LeftButton.) {
57 if (pointOverCursorcxx . . $ Cursor#pointOverCursor(578814ae554e72f6).(event->poscxx . . $ QMouseEvent#pos(75d69cfbd3c4b2dd).())) {
58 draggingcxx . . $ Cursor#dragging. = true;
59 return true;
60 }
61 }
62
63 // Update current cursor position if we're dragging
64 } else if (type == QEventcxx . . $ QEvent#::MouseMovecxx . . $ QEvent#MouseMove.) {
65 if (draggingcxx . . $ Cursor#dragging.) {
66 cursorPositioncxx . . $ Cursor#cursorPosition. = fromPointcxx . . $ Cursor#fromPoint(70366837c528ef32).(event->poscxx . . $ QMouseEvent#pos(75d69cfbd3c4b2dd).());
67 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! posChangedcxx . . $ Cursor#posChanged(49f6e7a06ebc5aa8).();
68 }
69
70 // Stop dragging on left mouse button release
71 } else if (type == QEventcxx . . $ QEvent#::MouseButtonReleasecxx . . $ QEvent#MouseButtonRelease.) {
72 if (event->buttoncxx . . $ QMouseEvent#button(4a2598559eeedfc9).() == Qtcxx . . $ Qt/::LeftButtoncxx . . $ Qt/LeftButton. && draggingcxx . . $ Cursor#dragging.) {
73 draggingcxx . . $ Cursor#dragging. = false;
74 return true;
75 }
76 }
77 return false;
78 }
79
80 void Cursorcxx . . $ Cursor#::leaveEventcxx . . $ Cursor#leaveEvent(49f6e7a06ebc5aa8).()
81 {
82 if (cursorOverridencxx . . $ Cursor#cursorOverriden.) {
83 cursorOverridencxx . . $ Cursor#cursorOverriden. = false;
84 QApplicationcxx . . $ QApplication#::restoreOverrideCursorcxx . . $ QGuiApplication#restoreOverrideCursor(49f6e7a06ebc5aa8).();
85 }
86 }
87
88 int Cursorcxx . . $ Cursor#::poscxx . . $ Cursor#pos(b126dc7c1de90089).()
89 {
90 return cursorPositioncxx . . $ Cursor#cursorPosition.;
91 }
92
93 void Cursorcxx . . $ Cursor#::setPoscxx . . $ Cursor#setPos(d4f767463ce0a6b3).(int newPos)
94 {
95 cursorPositioncxx . . $ Cursor#cursorPosition. = newPos;
96 }