Exemple #1
0
void RootFrameViewport::restoreToAnchor(const ScrollOffset& targetOffset) {
  // Clamp the scroll offset of each viewport now so that we force any invalid
  // offsets to become valid so we can compute the correct deltas.
  visualViewport().setScrollOffset(visualViewport().getScrollOffset(),
                                   ProgrammaticScroll);
  layoutViewport().setScrollOffset(layoutViewport().getScrollOffset(),
                                   ProgrammaticScroll);

  ScrollOffset delta = targetOffset - getScrollOffset();

  visualViewport().setScrollOffset(visualViewport().getScrollOffset() + delta,
                                   ProgrammaticScroll);

  delta = targetOffset - getScrollOffset();

  // Since the main thread FrameView has integer scroll offsets, scroll it to
  // the next pixel and then we'll scroll the visual viewport again to
  // compensate for the sub-pixel offset. We need this "overscroll" to ensure
  // the pixel of which we want to be partially in appears fully inside the
  // FrameView since the VisualViewport is bounded by the FrameView.
  IntSize layoutDelta = IntSize(
      delta.width() < 0 ? floor(delta.width()) : ceil(delta.width()),
      delta.height() < 0 ? floor(delta.height()) : ceil(delta.height()));

  layoutViewport().setScrollOffset(
      ScrollOffset(layoutViewport().scrollOffsetInt() + layoutDelta),
      ProgrammaticScroll);

  delta = targetOffset - getScrollOffset();
  visualViewport().setScrollOffset(visualViewport().getScrollOffset() + delta,
                                   ProgrammaticScroll);
}
Exemple #2
0
void LayerAndroid::updateLocalTransformAndClip(const TransformationMatrix& parentMatrix,
                                               const FloatRect& clipping)
{
    FloatPoint position(getPosition().x() + m_replicatedLayerPosition.x() - getScrollOffset().x(),
                        getPosition().y() + m_replicatedLayerPosition.y() - getScrollOffset().y());
    float originX = getAnchorPoint().x() * getWidth();
    float originY = getAnchorPoint().y() * getHeight();

    TransformationMatrix localMatrix;

    if (isPositionFixed())
        m_drawTransform.makeIdentity();
    else
        m_drawTransform = parentMatrix;
    m_drawTransform.translate3d(originX + position.x(),
                                originY + position.y(),
                                anchorPointZ());
    m_drawTransform.multiply(m_transform);
    m_drawTransform.translate3d(-originX,
                                -originY,
                                -anchorPointZ());

    m_drawTransformUnfudged = m_drawTransform;
    if (m_drawTransform.isIdentityOrTranslation()
        && surface() && surface()->allowTransformFudging()) {
        // adjust the translation coordinates of the draw transform matrix so
        // that layers (defined in content coordinates) will align to display/view pixels

        // the surface may not allow fudging if it uses the draw transform at paint time
        float desiredContentX = round(m_drawTransform.m41() * m_scale) / m_scale;
        float desiredContentY = round(m_drawTransform.m42() * m_scale) / m_scale;
        ALOGV("fudging translation from %f, %f to %f, %f",
              m_drawTransform.m41(), m_drawTransform.m42(),
              desiredContentX, desiredContentY);
        m_drawTransform.setM41(desiredContentX);
        m_drawTransform.setM42(desiredContentY);
    }

    m_zValue = TilesManager::instance()->shader()->zValue(m_drawTransform,
                                                          getSize().width(),
                                                          getSize().height());

    if (m_haveClip) {
        // The clipping rect calculation and intersetion will be done in content
        // coordinates.
        FloatRect rect(0, 0, getWidth(), getHeight());
        FloatRect clip = m_drawTransform.mapRect(rect);
        clip.intersect(clipping);
        setDrawClip(clip);
    } else {
        setDrawClip(clipping);
    }
    ALOGV("%s - %d %f %f %f %f",
          subclassType() == BaseLayer ? "BASE" : "nonbase",
          m_haveClip, m_clippingRect.x(), m_clippingRect.y(),
          m_clippingRect.width(), m_clippingRect.height());

    setVisible(m_backfaceVisibility || m_drawTransform.inverse().m33() >= 0);
}
Exemple #3
0
void LayerAndroid::updateGLPositionsAndScale(const TransformationMatrix& parentMatrix,
                                             const FloatRect& clipping, float opacity,
                                             float scale, bool forceCalculation,
                                             bool disableFixedElemUpdate)
{
    m_scale = scale;

    opacity *= getOpacity();
    setDrawOpacity(opacity);

    // constantly recalculate the draw transform of layers that may require it (and their children)
    forceCalculation |= hasDynamicTransform();

    forceCalculation &= !(disableFixedElemUpdate && isPositionFixed());
    if (forceCalculation)
        updateLocalTransformAndClip(parentMatrix, clipping);

    if (!countChildren() || !m_visible)
        return;

    TransformationMatrix localMatrix = m_drawTransformUnfudged;

    // Flatten to 2D if the layer doesn't preserve 3D.
    if (!preserves3D()) {
        localMatrix.setM13(0);
        localMatrix.setM23(0);
        localMatrix.setM31(0);
        localMatrix.setM32(0);
        localMatrix.setM33(1);
        localMatrix.setM34(0);
        localMatrix.setM43(0);
    }

    // now apply it to our children

    TransformationMatrix childMatrix;
    childMatrix = localMatrix;
    childMatrix.translate3d(getScrollOffset().x(), getScrollOffset().y(), 0);
    if (!m_childrenTransform.isIdentity()) {
        childMatrix.translate(getSize().width() * 0.5f, getSize().height() * 0.5f);
        childMatrix.multiply(m_childrenTransform);
        childMatrix.translate(-getSize().width() * 0.5f, -getSize().height() * 0.5f);
    }
    for (int i = 0; i < countChildren(); i++)
        this->getChild(i)->updateGLPositionsAndScale(childMatrix, drawClip(),
                                                     opacity, scale, forceCalculation,
                                                     disableFixedElemUpdate);
}
void SortableView::dragMoveEvent(QDragMoveEvent *ev)
{
	SortableWidget *widget =
		(SortableWidget *)ev->mimeData()->data(m_mimeType).toULongLong();
	m_curLevel = widget->getLevel();
	m_curMousePos = ev->pos();

	// If the cursor is near the edge of the widget automatically scroll
	const int SCROLL_DISTANCE = 48;
	m_scrollDelta = 0;
	if(ev->pos().y() < SCROLL_DISTANCE)
		m_scrollDelta -= SCROLL_DISTANCE - ev->pos().y();
	else if(ev->pos().y() > height() - SCROLL_DISTANCE)
		m_scrollDelta += SCROLL_DISTANCE - (height() - ev->pos().y());
	if(m_scrollDelta != 0) {
		m_scrollDelta /= 2;
		if(!m_scrollTimer.isActive()) {
			m_scrollTimer.setSingleShot(false);
			m_scrollTimer.start(100); // 10 Hz
		}
	} else
		m_scrollTimer.stop();

	// Move the indicator
	int before = sortableIndexAtPos(
		ev->pos() + getScrollOffset(), widget->getLevel(), true);
	moveIndicator(before);
	if(isIndexValidForLevel(before, widget->getLevel()))
		m_indicator.show();
	else
		m_indicator.hide();
}
Exemple #5
0
FloatRect VisualViewport::viewportToRootFrame(
    const FloatRect& rectInViewport) const {
  FloatRect rectInRootFrame = rectInViewport;
  rectInRootFrame.scale(1 / scale());
  rectInRootFrame.move(getScrollOffset());
  return rectInRootFrame;
}
void displayStreamInfo(){
    LcdBackLight(LCD_BACKLIGHT_ON);
    char offset = getScrollOffset();


    if (offset == 0)
        (*write_display_ptr[1])("                ", 17);

    (*write_display_ptr[0])("  Station Info  ", 17);

    //char* streamInfo = getStreamInfo();

    // I have to copy the StreamInfo buffer, I kept overwriting it.
    char streamInfo[48] = "    No  info    ";
    char* streamInfoPtr = &streamInfo[0];
    strncpy(streamInfo, getStreamInfo(), 48); // copy the streamInfo buffer.
    streamInfo[48] = '\0'; // To be sure...

    if (offset >= 0)
        streamInfoPtr += offset;
    streamInfoPtr[16] = '\0';

    (*write_display_ptr[1])(streamInfoPtr, 17);

    incrementScrollOffset();

    NutDelay(500);
}
Exemple #7
0
FloatPoint VisualViewport::viewportToRootFrame(
    const FloatPoint& pointInViewport) const {
  FloatPoint pointInRootFrame = pointInViewport;
  pointInRootFrame.scale(1 / scale(), 1 / scale());
  pointInRootFrame.move(getScrollOffset());
  return pointInRootFrame;
}
Exemple #8
0
FloatPoint VisualViewport::rootFrameToViewport(
    const FloatPoint& pointInRootFrame) const {
  FloatPoint pointInViewport = pointInRootFrame;
  pointInViewport.move(-getScrollOffset());
  pointInViewport.scale(scale(), scale());
  return pointInViewport;
}
Exemple #9
0
FloatRect VisualViewport::rootFrameToViewport(
    const FloatRect& rectInRootFrame) const {
  FloatRect rectInViewport = rectInRootFrame;
  rectInViewport.move(-getScrollOffset());
  rectInViewport.scale(scale());
  return rectInViewport;
}
void SortableView::dragEnterEvent(QDragEnterEvent *ev)
{
	if(!ev->mimeData()->hasFormat(m_mimeType))
		return;
	SortableWidget *widget =
		(SortableWidget *)ev->mimeData()->data(m_mimeType).toULongLong();

	// Make sure the widget is valid before accepting
	bool found = false;
	for(int i = 0; i < m_children.count(); i++) {
		if(m_children.at(i) == widget) {
			found = true;
			break;
		}
	}
	if(!found)
		return; // Not a valid widget
	ev->acceptProposedAction();

	// Show the indicator and make sure it's above all other widgets
	//m_indicator.raise();
	m_indicator.setFixedWidth(viewport()->width());
	int before = sortableIndexAtPos(
		ev->pos() + getScrollOffset(), widget->getLevel(), true);
	moveIndicator(before);
	if(isIndexValidForLevel(before, widget->getLevel()))
		m_indicator.show();
	else
		m_indicator.hide();
}
Exemple #11
0
bool VisualViewport::magnifyScaleAroundAnchor(float magnifyDelta,
                                              const FloatPoint& anchor) {
  const float oldPageScale = scale();
  const float newPageScale =
      frameHost().chromeClient().clampPageScaleFactorToLimits(magnifyDelta *
                                                              oldPageScale);
  if (newPageScale == oldPageScale)
    return false;
  if (!mainFrame() || !mainFrame()->view())
    return false;

  // Keep the center-of-pinch anchor in a stable position over the course
  // of the magnify.
  FloatPoint anchorAtOldScale = anchor.scaledBy(1.f / oldPageScale);
  FloatPoint anchorAtNewScale = anchor.scaledBy(1.f / newPageScale);
  FloatSize anchorDelta = anchorAtOldScale - anchorAtNewScale;

  // First try to use the anchor's delta to scroll the FrameView.
  FloatSize anchorDeltaUnusedByScroll = anchorDelta;

  // Manually bubble any remaining anchor delta up to the visual viewport.
  FloatPoint newLocation(FloatPoint(getScrollOffset()) +
                         anchorDeltaUnusedByScroll);
  setScaleAndLocation(newPageScale, newLocation);
  return true;
}
Exemple #12
0
FloatPoint VisualViewport::viewportCSSPixelsToRootFrame(
    const FloatPoint& point) const {
  // Note, this is in CSS Pixels so we don't apply scale.
  FloatPoint pointInRootFrame = point;
  pointInRootFrame.move(getScrollOffset());
  return pointInRootFrame;
}
Exemple #13
0
//-----------------------------------------------------------------------------
void CDataBrowser::valueChanged (CControl *pControl)
{
	CPoint origOffset = getScrollOffset ();
	CScrollView::valueChanged (pControl);
	CPoint offset = getScrollOffset ();
	if (origOffset != offset)
	{
		switch (pControl->getTag ())
		{
			case kHSBTag:
			{
				if (dbHeader)
				{
					CRect viewSize = dbHeader->getViewSize (viewSize);
					CCoord width = viewSize.getWidth ();
					viewSize.left = offset.x;
					viewSize.setWidth (width);
					dbHeader->setViewSize (viewSize);
					dbHeader->setMouseableArea (viewSize);
					dbHeader->invalid ();
				}
				break;
			}
		}
		if (isAttached () && (mouseDownView == dbView || mouseDownView == 0))
		{
			CPoint where;
			getFrame ()->getCurrentMouseLocation (where);
			if (getFrame ()->getViewAt (where, true) == dbView)
			{
				int32_t row = -1;
				int32_t column = -1;
				dbView->frameToLocal (where);
				dbView->getCell (where, row, column);
				db->dbOnMouseMoved (where, getFrame ()->getCurrentMouseButtons (), row, column, this);
			}
		}
	}
}
/// <summary>
/// Moves the indicator widgets so that it is inserted before the specified
/// item index.
/// </summary>
void SortableView::moveIndicator(int before)
{
	// "m_layout.count() - 1" as we have a spacer at the end
	if(before < 0) {
		// Position is relative to the right
		before += (m_layout.count() - 1) + 1;
	}
	before = qBound(0, before, m_layout.count() - 1);

	if(before >= m_layout.count() - 1) {
		// Display after the last item
		const QRect &geom = m_children.last()->getWidget()->geometry();
		m_indicator.move(0, geom.bottom() - getScrollOffset().y() - 1);
	} else {
		// Display before the specified item
		const QRect &geom = m_children.at(before)->getWidget()->geometry();
		if(before > 0)
			m_indicator.move(0, geom.top() - getScrollOffset().y() - 2);
		else {
			// Show 2px of the indicator instead of 1px
			m_indicator.move(0, geom.top() - getScrollOffset().y() - 1);
		}
	}
}
void SortableView::scrollTimeout()
{
	if(m_scrollDelta == 0) {
		// Nothing to do
		m_scrollTimer.stop();
		return;
	}

	QScrollBar *bar = verticalScrollBar();
	bar->setValue(bar->value() + m_scrollDelta);

	// Move the indicator
	int before = sortableIndexAtPos(
		m_curMousePos + getScrollOffset(), m_curLevel, true);
	moveIndicator(before);
	if(isIndexValidForLevel(before, m_curLevel))
		m_indicator.show();
	else
		m_indicator.hide();
}
void SortableView::dropEvent(QDropEvent *ev)
{
	SortableWidget *widget =
		(SortableWidget *)ev->mimeData()->data(m_mimeType).toULongLong();

	// Hide the indicator
	m_indicator.hide();

	// Get the position to insert the widget at
	int before = sortableIndexAtPos(
		ev->pos() + getScrollOffset(), widget->getLevel(), true);

	if(!isIndexValidForLevel(before, widget->getLevel()))
		return; // Invalid position

	// Forward the event for processing
	if(!moveChild(widget, before))
		return; // Failed to move

	// Notify the sender that we accepted the drop
	ev->acceptProposedAction();
}
Exemple #17
0
IntSize RootFrameViewport::scrollOffsetInt() const {
  return flooredIntSize(getScrollOffset());
}
Exemple #18
0
 IntRect visibleContentRect(IncludeScrollbarsInRect) const override {
   FloatSize size(m_viewportSize);
   size.scale(1 / m_scale);
   return IntRect(IntPoint(flooredIntSize(getScrollOffset())),
                  expandedIntSize(size));
 }
Exemple #19
0
FloatRect VisualViewport::visibleRect() const {
  return FloatRect(FloatPoint(getScrollOffset()), visibleSize());
}