Esempio n. 1
0
//====================================================================================
void AudioTransportCursor::fileChanged (AudioFilePlayer* player)
{
    if (player == &audioFilePlayer)
    {
        AudioFormatReaderSource* readerSource = audioFilePlayer.getAudioFormatReaderSource();

        AudioFormatReader* reader = nullptr;
        if (readerSource != nullptr)
            reader = readerSource->getAudioFormatReader();

        if (reader != nullptr && reader->sampleRate > 0.0
                && audioFilePlayer.getLengthInSeconds() > 0.0)
        {
            currentSampleRate = reader->sampleRate;
            fileLength = audioFilePlayer.getLengthInSeconds();
            oneOverFileLength = 1.0 / fileLength;
        }
        else
        {
            currentSampleRate = 44100;
            fileLength = 0.0;
            oneOverFileLength = 1.0;
        }

        startTimerIfNeeded();
    }
}
Esempio n. 2
0
bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
{
    if (m_pressedPart == ThumbPart) {
        moveThumb(m_orientation == HorizontalScrollbar ? 
                  convertFromContainingWindow(evt.pos()).x() :
                  convertFromContainingWindow(evt.pos()).y());
        return true;
    }

    if (m_pressedPart != NoPart)
        m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());

    ScrollbarPart part = theme()->hitTest(this, evt);    
    if (part != m_hoveredPart) {
        if (m_pressedPart != NoPart) {
            if (part == m_pressedPart) {
                // The mouse is moving back over the pressed part.  We
                // need to start up the timer action again.
                startTimerIfNeeded(theme()->autoscrollTimerDelay());
                theme()->invalidatePart(this, m_pressedPart);
            } else if (m_hoveredPart == m_pressedPart) {
                // The mouse is leaving the pressed part.  Kill our timer
                // if needed.
                stopTimerIfNeeded();
                theme()->invalidatePart(this, m_pressedPart);
            }
        } 
        
        setHoveredPart(part);
    } 

    return true;
}
Esempio n. 3
0
void Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
{
    if (m_pressedPart == ThumbPart) {
        moveThumb(m_orientation == HorizontalScrollbar ?
                  convertFromContainingView(evt.position()).x() :
                  convertFromContainingView(evt.position()).y());
        return;
    }

    if (m_pressedPart != NoPart)
        m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingView(evt.position()).x() : convertFromContainingView(evt.position()).y();

    // FIXME(sky): Cleanup this code now that part is always NoPart.
    ScrollbarPart part = NoPart;
    if (part != m_hoveredPart) {
        if (m_pressedPart != NoPart) {
            if (part == m_pressedPart) {
                // The mouse is moving back over the pressed part.  We
                // need to start up the timer action again.
                startTimerIfNeeded(autoscrollTimerDelay());
                invalidatePart(m_pressedPart);
            } else if (m_hoveredPart == m_pressedPart) {
                // The mouse is leaving the pressed part.  Kill our timer
                // if needed.
                stopTimerIfNeeded();
                invalidatePart(m_pressedPart);
            }
        }

        setHoveredPart(part);
    }

    return;
}
Esempio n. 4
0
void AudioTransportCursor::mouseUp (const MouseEvent& /*e*/)
{
    if (showTransportCursor)
    {
        setMouseCursor (MouseCursor::NormalCursor);

        startTimerIfNeeded();
    }
}
void Scrollbar::autoscrollPressedPart(double delay)
{
    // Don't do anything for the thumb or if nothing was pressed.
    if (m_pressedPart == ThumbPart || m_pressedPart == NoPart)
        return;

    // Handle the track.
    if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbWillBeUnderMouse()) {
        setHoveredPart(ThumbPart);
        return;
    }

    // Handle the arrows and track.
    if (m_scrollableArea && m_scrollableArea->userScroll(pressedPartScrollGranularity(), toScrollDelta(pressedPartScrollDirectionPhysical(), 1)).didScroll())
        startTimerIfNeeded(delay);
}
Esempio n. 6
0
void Scrollbar::autoscrollPressedPart(double delay)
{
    // Don't do anything for the thumb or if nothing was pressed.
    if (m_pressedPart == ThumbPart || m_pressedPart == NoPart)
        return;

    // Handle the track.
    if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
        theme()->invalidatePart(this, m_pressedPart);
        setHoveredPart(ThumbPart);
        return;
    }

    // Handle the arrows and track.
    if (m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity()))
        startTimerIfNeeded(delay);
}
Esempio n. 7
0
void PlatformScrollbar::autoscrollPressedPart(double delay)
{
    // Don't do anything for the thumb or if nothing was pressed.
    if (m_pressedPart == QStyle::SC_ScrollBarSlider || m_pressedPart == QStyle::SC_None)
        return;

    // Handle the track.
    if (m_pressedPart == QStyle::SC_ScrollBarGroove && thumbUnderMouse()) {
        invalidate();
        m_hoveredPart = QStyle::SC_ScrollBarSlider;
        return;
    }

    // Handle the arrows and track.
    if (scroll(pressedPartScrollDirection(), pressedPartScrollGranularity()))
        startTimerIfNeeded(delay);
}
Esempio n. 8
0
void Scrollbar::mouseMoved(const PlatformMouseEvent& evt) {
  if (m_pressedPart == ThumbPart) {
    if (theme().shouldSnapBackToDragOrigin(*this, evt)) {
      if (m_scrollableArea) {
        m_scrollableArea->setScrollOffsetSingleAxis(
            m_orientation,
            m_dragOrigin + m_scrollableArea->minimumScrollOffset(m_orientation),
            UserScroll);
      }
    } else {
      moveThumb(m_orientation == HorizontalScrollbar
                    ? convertFromRootFrame(evt.position()).x()
                    : convertFromRootFrame(evt.position()).y(),
                theme().shouldDragDocumentInsteadOfThumb(*this, evt));
    }
    return;
  }

  if (m_pressedPart != NoPart)
    m_pressedPos = orientation() == HorizontalScrollbar
                       ? convertFromRootFrame(evt.position()).x()
                       : convertFromRootFrame(evt.position()).y();

  ScrollbarPart part = theme().hitTest(*this, evt.position());
  if (part != m_hoveredPart) {
    if (m_pressedPart != NoPart) {
      if (part == m_pressedPart) {
        // The mouse is moving back over the pressed part.  We
        // need to start up the timer action again.
        startTimerIfNeeded(theme().autoscrollTimerDelay());
      } else if (m_hoveredPart == m_pressedPart) {
        // The mouse is leaving the pressed part.  Kill our timer
        // if needed.
        stopTimerIfNeeded();
      }
    }

    setHoveredPart(part);
  }

  return;
}
Esempio n. 9
0
bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
{
    if (m_pressedPart == ThumbPart) {
        if (theme()->shouldSnapBackToDragOrigin(this, evt)) {
            if (m_scrollableArea)
                m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, m_dragOrigin);
        } else {
            moveThumb(m_orientation == HorizontalScrollbar ? 
                      convertFromContainingWindow(evt.pos()).x() :
                      convertFromContainingWindow(evt.pos()).y(), theme()->shouldDragDocumentInsteadOfThumb(this, evt));
        }
        return true;
    }

    if (m_pressedPart != NoPart)
        m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());

    ScrollbarPart part = theme()->hitTest(this, evt);    
    if (part != m_hoveredPart) {
        if (m_pressedPart != NoPart) {
            if (part == m_pressedPart) {
                // The mouse is moving back over the pressed part.  We
                // need to start up the timer action again.
                startTimerIfNeeded(theme()->autoscrollTimerDelay());
                theme()->invalidatePart(this, m_pressedPart);
            } else if (m_hoveredPart == m_pressedPart) {
                // The mouse is leaving the pressed part.  Kill our timer
                // if needed.
                stopTimerIfNeeded();
                theme()->invalidatePart(this, m_pressedPart);
            }
        } 
        
        setHoveredPart(part);
    } 

    return true;
}
Esempio n. 10
0
bool PlatformScrollbar::handleMouseMoveEvent(const PlatformMouseEvent& evt)
{
    const QPoint pos = convertFromContainingWindow(evt.pos());
    //qDebug() << "PlatformScrollbar::handleMouseMoveEvent" << m_opt.rect << pos << evt.pos();

    m_opt.state |= QStyle::State_MouseOver;
    const QPoint topLeft = m_opt.rect.topLeft();
    m_opt.rect.moveTo(QPoint(0, 0));
    QStyle::SubControl sc = QApplication::style()->hitTestComplexControl(QStyle::CC_ScrollBar, &m_opt, pos, 0);
    m_opt.rect.moveTo(topLeft);

    if (m_pressedPart == QStyle::SC_ScrollBarSlider) {
        // Drag the thumb.
        int thumbPos = thumbPosition();
        int thumbLen = thumbLength();
        int trackLen = trackLength();
        int maxPos = trackLen - thumbLen;
        int delta = 0;
        if (m_orientation == HorizontalScrollbar)
            delta = pos.x() - m_pressedPos;
        else
            delta = pos.y() - m_pressedPos;

        if (delta > 0)
            // The mouse moved down/right.
            delta = min(maxPos - thumbPos, delta);
        else if (delta < 0)
            // The mouse moved up/left.
            delta = max(-thumbPos, delta);

        if (delta != 0) {
            setValue((int)((float)(thumbPos + delta) * (m_totalSize - m_visibleSize) / (trackLen - thumbLen)));
            m_pressedPos += thumbPosition() - thumbPos;
        }

        return true;
    }

    if (m_pressedPart != QStyle::SC_None)
        m_pressedPos = m_orientation == HorizontalScrollbar ? pos.x() : pos.y();

    if (sc != m_hoveredPart) {
        if (m_pressedPart != QStyle::SC_None) {
            if (sc == m_pressedPart) {
                // The mouse is moving back over the pressed part.  We
                // need to start up the timer action again.
                startTimerIfNeeded(cNormalTimerDelay);
                invalidate();
            } else if (m_hoveredPart == m_pressedPart) {
                // The mouse is leaving the pressed part.  Kill our timer
                // if needed.
                stopTimerIfNeeded();
                invalidate();
            }
        } else {
            invalidate();
        }
        m_hoveredPart = sc;
    }

    return true;
}
Esempio n. 11
0
void AudioTransportCursor::setCursorDisplayed (bool shouldDisplayCursor)
{
    showTransportCursor = shouldDisplayCursor;

    startTimerIfNeeded();
}
Esempio n. 12
0
void AudioTransportCursor::playerStoppedOrStarted (AudioFilePlayer* player)
{
    if (player == &audioFilePlayer)
        startTimerIfNeeded();
}