/************************************************************************* handler function for when thumb moves. *************************************************************************/ bool Scrollbar::handleThumbMoved(const EventArgs&) { // adjust scroll bar position as required. setScrollPosition(getValueFromThumb()); return true; }
LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, const ScrollAlignment& alignX, const ScrollAlignment& alignY, ScrollType scrollType) { // We want to move the rect into the viewport that excludes the scrollbars so we intersect // the visual viewport with the scrollbar-excluded frameView content rect. However, we don't // use visibleContentRect directly since it floors the scroll position. Instead, we use // ScrollAnimatorBase::currentPosition and construct a LayoutRect from that. LayoutRect frameRectInContent = LayoutRect( layoutViewport().scrollAnimator().currentPosition(), layoutViewport().visibleContentRect().size()); LayoutRect visualRectInContent = LayoutRect( scrollOffsetFromScrollAnimators(), visualViewport().visibleContentRect().size()); // Intersect layout and visual rects to exclude the scrollbar from the view rect. LayoutRect viewRectInContent = intersection(visualRectInContent, frameRectInContent); LayoutRect targetViewport = ScrollAlignment::getRectToExpose(viewRectInContent, rectInContent, alignX, alignY); if (targetViewport != viewRectInContent) setScrollPosition(DoublePoint(targetViewport.x(), targetViewport.y()), scrollType); // RootFrameViewport only changes the viewport relative to the document so we can't change the input // rect's location relative to the document origin. return rectInContent; }
void WebWidget::mouseMoveEvent(QMouseEvent *event) { if (m_scrollMode == DragScroll && event->button() == Qt::LeftButton) { setScrollPosition(m_beginScrollPosition + m_beginCursorPosition - QCursor::pos()); } }
GUI::Widget::Slider::Slider(float x, float y, float length, float thickness, bool _vertical, CallbackType callback, float rangeMin_, float rangeMax_, float initialValue): Widget(x, y, (_vertical ? thickness : length), (_vertical ? length : thickness)), action(callback), vertical(_vertical) { sliderPosition = 0; isDragged = false; rangeMin = rangeMin_; rangeMax = rangeMax_; setScrollPosition(initialValue); }
void ZoomView::scrollToOrigin() { const QPoint origin(0 ,0); const QPoint current = scrollPosition(); if (current != origin) { if (debugZoomWidget) qDebug() << "ZoomView::scrollToOrigin from " << current; setScrollPosition(origin); } }
void ActivityList::dataUpdated(const QString& source, const Plasma::DataEngine::Data& data) { Q_UNUSED(source) Q_ASSERT(m_engine); int newItems = 0; foreach(const QString& key, data.keys()) { if (!data.value(key).value<Plasma::DataEngine::Data>().isEmpty()) { if (m_knownEvents.contains(source + data[key].value<Plasma::DataEngine::Data>().value("id").toString())) { continue; } QString id(source + data[key].value<Plasma::DataEngine::Data>().value("id").toString()); QDateTime time(data[key].value<Plasma::DataEngine::Data>().value("timestamp").toDateTime()); m_knownEvents.insert(id); ActivityWidget* widget = new ActivityWidget(m_engine, m_container); widget->setActivityData(data[key].value<Plasma::DataEngine::Data>()); int i; for(i = 0; i < m_layout->count(); ++i) { ActivityWidget* widget = static_cast<ActivityWidget*>(m_layout->itemAt(i)); if (time > widget->timestamp()) { break; } } m_layout->insertItem(i, widget); ++newItems; } } while (m_layout->count() > m_limit) { ActivityWidget* widget = static_cast<ActivityWidget*>(m_layout->itemAt(m_layout->count()-1)); m_layout->removeAt(m_layout->count()-1); widget->deleteLater(); } // Don't mass-spam the user with notifications if (newItems < 4) { for(int i = 0; i<newItems; ++i) { ActivityWidget* widget = static_cast<ActivityWidget*>(m_layout->itemAt(i)); KNotification* notification = new KNotification("activity"); notification->setTitle("OpenDesktop Activities"); notification->setText(widget->message()); notification->setComponentData(KComponentData("plasma-applet-opendesktop-activities", "plasma-applet-opendesktop-activities", KComponentData::SkipMainComponentRegistration)); notification->sendEvent(); } } // Go to the top of the list setScrollPosition(QPointF(0, 0)); }
/************************************************************************* Handler for scroll wheel changes *************************************************************************/ void Scrollbar::onMouseWheel(MouseEventArgs& e) { // base class processing Window::onMouseWheel(e); // scroll by e.wheelChange * stepSize setScrollPosition(d_position + d_stepSize * -e.wheelChange); // ensure the message does not go to our parent. ++e.handled; }
void ScrollView::setPadding(const Padding &p) { if (p != _paddingGlobal) { float offset = (isVertical()?_paddingGlobal.top:_paddingGlobal.left); float newOffset = (isVertical()?p.top:p.left); ScrollViewBase::setPadding(p); if (offset != newOffset) { setScrollPosition(getScrollPosition() + (offset - newOffset)); } } }
//----------------------------------------------------------------------------// bool Scrollbar::handleDecreaseClicked(const EventArgs& e) { if (((const MouseEventArgs&)e).button == LeftButton) { // adjust scroll bar position as required. setScrollPosition(d_position - d_stepSize); return true; } return false; }
int QWebFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 13) qt_static_metacall(this, _c, _id, _a); _id -= 13; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< qreal*>(_v) = textSizeMultiplier(); break; case 1: *reinterpret_cast< qreal*>(_v) = zoomFactor(); break; case 2: *reinterpret_cast< QString*>(_v) = title(); break; case 3: *reinterpret_cast< QUrl*>(_v) = url(); break; case 4: *reinterpret_cast< QUrl*>(_v) = requestedUrl(); break; case 5: *reinterpret_cast< QUrl*>(_v) = baseUrl(); break; case 6: *reinterpret_cast< QIcon*>(_v) = icon(); break; case 7: *reinterpret_cast< QSize*>(_v) = contentsSize(); break; case 8: *reinterpret_cast< QPoint*>(_v) = scrollPosition(); break; case 9: *reinterpret_cast< bool*>(_v) = hasFocus(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setTextSizeMultiplier(*reinterpret_cast< qreal*>(_v)); break; case 1: setZoomFactor(*reinterpret_cast< qreal*>(_v)); break; case 3: setUrl(*reinterpret_cast< QUrl*>(_v)); break; case 8: setScrollPosition(*reinterpret_cast< QPoint*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }
void VScroll::setPropertyOverride(const std::string& _key, const std::string& _value) { if (_key == "Range") setScrollRange(utility::parseValue<size_t>(_value)); else if (_key == "RangePosition") setScrollPosition(utility::parseValue<size_t>(_value)); else if (_key == "Page") setScrollPage(utility::parseValue<size_t>(_value)); else if (_key == "ViewPage") setScrollViewPage(utility::parseValue<size_t>(_value)); else if (_key == "MoveToClick") setMoveToClick(utility::parseValue<bool>(_value)); else { Base::setPropertyOverride(_key, _value); return; } eventChangeProperty(this, _key, _value); }
void ScrollBar::setPropertyOverride(const std::string& _key, const std::string& _value) { /// @wproperty{ScrollBar, Range, size_t} Диапазон прокрутки. if (_key == "Range") setScrollRange(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, RangePosition, size_t} Положение прокрутки. else if (_key == "RangePosition") setScrollPosition(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, Page, size_t} Шаг прокрутки при нажатии на кнопку начала или конца. else if (_key == "Page") setScrollPage(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, ViewPage, size_t} Шаг прокрутки при нажатии на одну из частей от кнопки до трекера. else if (_key == "ViewPage") setScrollViewPage(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, WheelPage, size_t} Шаг прокрутки при прокрутке колесиком мыши. else if (_key == "WheelPage") setScrollWheelPage(utility::parseValue<size_t>(_value)); /// @wproperty{ScrollBar, MoveToClick, bool} Режим перескакивания бегунка к месту клика. else if (_key == "MoveToClick") setMoveToClick(utility::parseValue<bool>(_value)); /// @wproperty{ScrollBar, VerticalAlignment, bool} Вертикальное выравнивание. else if (_key == "VerticalAlignment") setVerticalAlignment(utility::parseValue<bool>(_value)); /// @wproperty{ScrollBar, Repeat, bool} Sets whether scrollbar buttons should be triggered repeatedly so long as the mouse button is pressed down. else if (_key == "Repeat") setRepeatEnabled(utility::parseValue<bool>(_value)); /// @wproperty{ScrollBar, RepeatTriggerTime, float} How long the mouse needs to be pressed on a scrollbar button for repeating to start. else if (_key == "RepeatTriggerTime") setRepeatTriggerTime(utility::parseValue<float>(_value)); /// @wproperty{ScrollBar, RepeatStepTime, float) The time between each repeat step once repeating has started. else if (_key == "RepeatStepTime") setRepeatStepTime(utility::parseValue<float>(_value)); else { Base::setPropertyOverride(_key, _value); return; } eventChangeProperty(this, _key, _value); }
void Scrollbar::recalcScrollPosition(const Point& mouse) { const Size& size = getSize(); float deltaScrollPosition = 0; if (orientation == HORIZONTAL) { deltaScrollPosition = float(mouse.x - lastMousePosition.x) * (float(length) / float(size.width)); } else { deltaScrollPosition = float(mouse.y - lastMousePosition.y) * (float(length) / float(size.height)); } setScrollPosition(gluit::round(scrollPosition + deltaScrollPosition)); lastMousePosition = mouse; }
//----------------------------------------------------------------------------// void Scrollbar::setPageSize(float page_size) { if (d_pageSize != page_size) { const bool reset_max_position = d_endLockPosition && isAtEnd(); d_pageSize = page_size; if (reset_max_position) setScrollPosition(getMaxScrollPosition()); else updateThumb(); WindowEventArgs args(this); onScrollConfigChanged(args); } }
void WebViewSmoothScroller::handleAutoscroll () { if (std::fabs (ScrollDelta_) < std::numeric_limits<decltype (ScrollDelta_)>::epsilon ()) return; AccumulatedScrollShift_ += ScrollDelta_; if (std::abs (AccumulatedScrollShift_) >= 1) { const auto mf = View_->page ()->mainFrame (); auto pos = mf->scrollPosition (); pos += QPoint (0, AccumulatedScrollShift_); mf->setScrollPosition (pos); AccumulatedScrollShift_ -= static_cast<int> (AccumulatedScrollShift_); } }
//----------------------------------------------------------------------------// void Scrollbar::onMouseButtonDown(MouseEventArgs& e) { // base class processing Window::onMouseButtonDown(e); if (e.button == LeftButton) { const float adj = getAdjustDirectionFromPoint(e.position); // adjust scroll bar position in whichever direction as required. if (adj != 0) setScrollPosition( d_position + ((d_pageSize - d_overlapSize) * adj)); ++e.handled; } }
LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, const ScrollAlignment& alignX, const ScrollAlignment& alignY) { // We want to move the rect into the viewport that excludes the scrollbars so we intersect // the visual viewport with the scrollbar-excluded frameView content rect. However, we don't // use visibleContentRect directly since it floors the scroll position. Instead, we use // FrameView::scrollPositionDouble and construct a LayoutRect from that (the FrameView size // is always integer sized. LayoutRect frameRectInContent = LayoutRect( layoutViewport().scrollPositionDouble(), layoutViewport().visibleContentRect().size()); LayoutRect visualRectInContent = LayoutRect( layoutViewport().scrollPositionDouble() + toDoubleSize(visualViewport().scrollPositionDouble()), visualViewport().visibleContentRect().size()); LayoutRect viewRectInContent = intersection(visualRectInContent, frameRectInContent); LayoutRect targetViewport = ScrollAlignment::getRectToExpose(viewRectInContent, rectInContent, alignX, alignY); // visualViewport.scrollIntoView will attempt to center the given rect within the viewport // so to prevent it from adjusting r's coordinates the rect must match the viewport's size // i.e. add the subtracted scrollbars from above back in. // FIXME: This is hacky and required because getRectToExpose doesn't naturally account // for the two viewports. crbug.com/449340. targetViewport.setSize(LayoutSize(visualViewport().visibleContentRect().size())); // Snap the visible rect to layout units to match the calculated target viewport rect. FloatRect visible = LayoutRect(visualViewport().scrollPositionDouble(), visualViewport().visibleContentRect().size()); float centeringOffsetX = (visible.width() - targetViewport.width()) / 2; float centeringOffsetY = (visible.height() - targetViewport.height()) / 2; DoublePoint targetOffset( targetViewport.x() - centeringOffsetX, targetViewport.y() - centeringOffsetY); setScrollPosition(targetOffset, ProgrammaticScroll); // RootFrameViewport only changes the viewport relative to the document so we can't change the input // rect's location relative to the document origin. return rectInContent; }
void ScrollableArea::scrollIntoRect(const LayoutRect& rectInContent, const FloatRect& targetRectInFrame) { // Use |pixelSnappedIntRect| for rounding to pixel as opposed to |enclosingIntRect|. It gives a better // combined (location and size) rounding error resulting in a more accurate scroll offset. // FIXME: It would probably be best to do the whole calculation in LayoutUnits but contentsToRootFrame // and friends don't have LayoutRect/Point versions yet. IntRect boundsInContent = pixelSnappedIntRect(rectInContent); IntRect boundsInFrame(boundsInContent.location() - toIntSize(scrollPosition()), boundsInContent.size()); int centeringOffsetX = (targetRectInFrame.width() - boundsInFrame.width()) / 2; int centeringOffsetY = (targetRectInFrame.height() - boundsInFrame.height()) / 2; IntSize scrollDelta( boundsInFrame.x() - centeringOffsetX - targetRectInFrame.x(), boundsInFrame.y() - centeringOffsetY - targetRectInFrame.y()); DoublePoint targetOffset = DoublePoint(scrollPosition() + scrollDelta); setScrollPosition(targetOffset, ProgrammaticScroll); }
/////////////////////////////////////////////////////////// // // End the cursor definition // /////////////////////////////////////////////////////////// void view::endCursorDef(imbxInt32 cursorHotSpotX, imbxInt32 cursorHotSpotY) { // Remove the current cursor's lines /////////////////////////////////////////////////////////// invalidateLines(&m_cursorLines); // Copy the temporary lines into cursor's lines /////////////////////////////////////////////////////////// m_cursorLines.clear(); for(tCursorLinesList::iterator copyLines = m_tempCursorLines.begin(); copyLines != m_tempCursorLines.end(); ++copyLines) { m_cursorLines.push_back(*copyLines); } m_tempCursorLines.clear(); // Do we have to scroll the window because the hotspot is // outside the visible area? /////////////////////////////////////////////////////////// if(!isMouseCaptured() || m_originalImage == 0) { invalidateLines(&m_cursorLines); return; } // Convert the hotspot into window's coordinates /////////////////////////////////////////////////////////// imbxInt32 scrollX, scrollY; getScrollPosition(&scrollX, &scrollY); imbxUint32 imageSizeX, imageSizeY; m_originalImage->getSize(&imageSizeX, &imageSizeY); imbxInt32 windowHotSpotX = cursorHotSpotX * (m_rightPosition - m_leftPosition) / imageSizeX +m_leftPosition - scrollX; imbxInt32 windowHotSpotY = cursorHotSpotY * (m_bottomPosition - m_topPosition) / imageSizeY +m_topPosition - scrollY; // Find the amount of scroll to execute /////////////////////////////////////////////////////////// imbxUint32 windowSizeX, windowSizeY; getWindowSize(&windowSizeX, &windowSizeY); imbxInt32 limitX = windowSizeX / 10; imbxInt32 limitY = windowSizeY / 10; imbxInt32 executeScrollX = 0; imbxInt32 executeScrollY = 0; if(windowHotSpotX < limitX) { executeScrollX = windowHotSpotX - limitX; } if(windowHotSpotY < limitY) { executeScrollY = windowHotSpotY - limitY; } if(windowHotSpotX > ((imbxInt32)windowSizeX - limitX) ) { executeScrollX = windowHotSpotX - (imbxInt32)windowSizeX + limitX; } if(windowHotSpotY > ((imbxInt32)windowSizeY - limitY) ) { executeScrollY = windowHotSpotY - (imbxInt32)windowSizeY + limitY; } if(executeScrollX != 0 && executeScrollY != 0) { updateWindow(); setScrollPosition(scrollX + executeScrollX, scrollY + executeScrollY); } invalidateLines(&m_cursorLines); }
void Editor::setScrollPosition(const QPair<int, int> &position) { setScrollPosition(position.first, position.second); }
void ScrollableArea::scrollBy(const DoubleSize& delta, ScrollType type, ScrollBehavior behavior) { setScrollPosition(scrollPositionDouble() + delta, type, behavior); }
//----------------------------------------------------------------------------// void Scrollbar::scrollBackwardsByPage() { setScrollPosition(d_position - (d_pageSize - d_overlapSize)); }
//----------------------------------------------------------------------------// void Scrollbar::scrollBackwardsByStep() { setScrollPosition(d_position - d_stepSize); }
void ScrollingTreeFrameScrollingNode::scrollBy(const FloatSize& offset) { setScrollPosition(scrollPosition() + offset); }
//----------------------------------------------------------------------------// void Scrollbar::setUnitIntervalScrollPosition(float position) { const float range = d_documentSize - d_pageSize; setScrollPosition(range > 0 ? position * range : 0.0f); }
int QWebFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: javaScriptWindowObjectCleared(); break; case 1: provisionalLoad(); break; case 2: titleChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 3: urlChanged((*reinterpret_cast< const QUrl(*)>(_a[1]))); break; case 4: initialLayoutCompleted(); break; case 5: iconChanged(); break; case 6: contentsSizeChanged((*reinterpret_cast< const QSize(*)>(_a[1]))); break; case 7: loadStarted(); break; case 8: loadFinished((*reinterpret_cast< bool(*)>(_a[1]))); break; case 9: { QVariant _r = evaluateJavaScript((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QVariant*>(_a[0]) = _r; } break; case 10: print((*reinterpret_cast< QPrinter*(*)>(_a[1]))); break; default: ; } _id -= 11; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< qreal*>(_v) = textSizeMultiplier(); break; case 1: *reinterpret_cast< qreal*>(_v) = zoomFactor(); break; case 2: *reinterpret_cast< QString*>(_v) = title(); break; case 3: *reinterpret_cast< QUrl*>(_v) = url(); break; case 4: *reinterpret_cast< QUrl*>(_v) = requestedUrl(); break; case 5: *reinterpret_cast< QUrl*>(_v) = baseUrl(); break; case 6: *reinterpret_cast< QIcon*>(_v) = icon(); break; case 7: *reinterpret_cast< QSize*>(_v) = contentsSize(); break; case 8: *reinterpret_cast< QPoint*>(_v) = scrollPosition(); break; case 9: *reinterpret_cast< bool*>(_v) = hasFocus(); break; } _id -= 10; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setTextSizeMultiplier(*reinterpret_cast< qreal*>(_v)); break; case 1: setZoomFactor(*reinterpret_cast< qreal*>(_v)); break; case 3: setUrl(*reinterpret_cast< QUrl*>(_v)); break; case 8: setScrollPosition(*reinterpret_cast< QPoint*>(_v)); break; } _id -= 10; } else if (_c == QMetaObject::ResetProperty) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 10; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 10; } #endif // QT_NO_PROPERTIES return _id; }
/////////////////////////////////////////////////////////// // // Center the desidered image's pixel in the window // /////////////////////////////////////////////////////////// void view::setCenterPoint(imbxInt32 centerPointX, imbxInt32 centerPointY) { if(m_originalImage == 0) { return; } // Calculate the size of the area occupied by the image on // the screen /////////////////////////////////////////////////////////// imbxInt32 imageAreaWidth = m_rightPosition - m_leftPosition; imbxInt32 imageAreaHeight = m_bottomPosition - m_topPosition; // Get the window's width /////////////////////////////////////////////////////////// imbxUint32 windowWidth = 0; imbxUint32 windowHeight = 0; getWindowSize(&windowWidth, &windowHeight); // Get the scroll position /////////////////////////////////////////////////////////// imbxInt32 oldScrollPosX = 0; imbxInt32 oldScrollPosY = 0; getScrollPosition(&oldScrollPosX, &oldScrollPosY); imbxInt32 newScrollPosX = oldScrollPosX; imbxInt32 newScrollPosY = oldScrollPosY; // Get the image's size /////////////////////////////////////////////////////////// imbxUint32 imageSizeX, imageSizeY; m_originalImage->getSize(&imageSizeX, &imageSizeY); // Calculate the new scroll position /////////////////////////////////////////////////////////// if(centerPointX>=0) { newScrollPosX = imbxInt32((centerPointX * imageAreaWidth)/imageSizeX) + m_leftPosition - windowWidth/2; } if(centerPointY>=0) { newScrollPosY = imbxInt32((centerPointY * imageAreaHeight)/imageSizeY) + m_topPosition - windowHeight/2; } // Check if the scroll position is valid /////////////////////////////////////////////////////////// if(newScrollPosX+(imbxInt32)windowWidth>imageAreaWidth) { newScrollPosX=imageAreaWidth-(imbxInt32)windowWidth; } if(newScrollPosY+(imbxInt32)windowHeight>imageAreaHeight) { newScrollPosY=imageAreaHeight-(imbxInt32)windowHeight; } if(newScrollPosX < 0) { newScrollPosX = 0; } if(newScrollPosY < 0) { newScrollPosY = 0; } if(oldScrollPosX!=newScrollPosX || oldScrollPosY!=newScrollPosY) { setScrollPosition(newScrollPosX, newScrollPosY); } // Set the new scroll position /////////////////////////////////////////////////////////// if(newScrollPosX != oldScrollPosX || newScrollPosY != oldScrollPosY) { setScrollPosition(newScrollPosX, newScrollPosY); } }
//----------------------------------------------------------------------------// void Scrollbar::scrollForwardsByStep() { setScrollPosition(d_position + d_stepSize); }
//Reset scroll flag and scroll position automatically for display. //Keep calling every loop to keep scrolling going. void mizraith_HDSP2111::automaticallyResetScrollFlagAndPosition(uint8_t displaynum) { if(isScrollComplete(displaynum) ) { setScrollCompleteFlag(false, displaynum); setScrollPosition(0, displaynum); } }