1 /* 2 * Copyright (C) 2016, Mike Walters <mike@flomp.net> 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 #pragma once 21 22 #include <QMouseEvent> 23 #include <QObject> 24 #include <QPainter> 25 #include <QPoint> 26 #include "cursor.h" 27 #include "util.h" 28 29 class Cursors : public QObject 30 { 31 Q_OBJECT 32 33 public: 34 Cursors(QObject * parent); 35 int segments(); 36 bool mouseEvent(QEvent::Type type, QMouseEvent event); 37 void paintFront(QPainter &painter, QRect &rect, range_t<size_t> sampleRange); 38 range_t<int> selection(); 39 void setSegments(int segments); 40 void setSelection(range_t<int> selection); 41 42 public slots: 43 void cursorMoved(); 44 45 signals: 46 void cursorsMoved(); 47 48 private: 49 bool pointWithinDragRegion(QPoint point); 50 51 Cursor *minCursor; 52 Cursor *maxCursor; 53 int segmentCount = 1; 54 55 QPoint dragPos; // keep track of dragging distance 56 bool cursorOverride = false; // used to record if cursor is overridden 57 bool dragging = false; // record if mouse is dragging 58 }; 59