slider: implemented value ladder
Allows finer control over value changes.
This commit is contained in:
@@ -57,66 +57,25 @@ SliderLabel::SliderLabel(QWidget *parent) :
|
||||
void SliderLabel::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->modifiers() & Qt::AltModifier) {
|
||||
|
||||
emit RequestReset();
|
||||
|
||||
} else {
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||
CGGetLastMouseDelta(nullptr, nullptr);
|
||||
#else
|
||||
drag_start_ = QCursor::pos();
|
||||
|
||||
static_cast<QGuiApplication*>(QApplication::instance())->setOverrideCursor(Qt::BlankCursor);
|
||||
#endif
|
||||
|
||||
emit drag_start();
|
||||
|
||||
dragging_ = true;
|
||||
|
||||
emit LabelPressed();
|
||||
}
|
||||
}
|
||||
|
||||
void SliderLabel::mouseMoveEvent(QMouseEvent *)
|
||||
{
|
||||
if (dragging_) {
|
||||
|
||||
int32_t x_mvmt, y_mvmt;
|
||||
|
||||
// Keep cursor in the same position
|
||||
#if defined(Q_OS_MAC)
|
||||
CGGetLastMouseDelta(&x_mvmt, &y_mvmt);
|
||||
#else
|
||||
QPoint current_pos = QCursor::pos();
|
||||
|
||||
x_mvmt = current_pos.x() - drag_start_.x();
|
||||
y_mvmt = drag_start_.y() - current_pos.y();
|
||||
|
||||
QCursor::setPos(drag_start_);
|
||||
#endif
|
||||
|
||||
emit dragged(x_mvmt + y_mvmt);
|
||||
|
||||
emit LabelMoved();
|
||||
}
|
||||
}
|
||||
|
||||
void SliderLabel::mouseReleaseEvent(QMouseEvent *)
|
||||
{
|
||||
if (dragging_) {
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
CGDisplayShowCursor(kCGDirectMainDisplay);
|
||||
#else
|
||||
static_cast<QGuiApplication*>(QApplication::instance())->restoreOverrideCursor();
|
||||
#endif
|
||||
|
||||
emit drag_stop();
|
||||
|
||||
emit LabelReleased();
|
||||
dragging_ = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user