本文整理汇总了C++中ScrollableArea::setScrollOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ ScrollableArea::setScrollOffset方法的具体用法?C++ ScrollableArea::setScrollOffset怎么用?C++ ScrollableArea::setScrollOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScrollableArea
的用法示例。
在下文中一共展示了ScrollableArea::setScrollOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: viewportSize
// Tests that scrolling the viewport when the layout viewport is
// !userInputScrollable (as happens when overflow:hidden is set) works
// correctly, that is, the visual viewport can scroll, but not the layout.
TEST_F(RootFrameViewportTest, UserInputScrollable) {
IntSize viewportSize(100, 150);
RootFrameViewStub* layoutViewport =
RootFrameViewStub::create(viewportSize, IntSize(200, 300));
VisualViewportStub* visualViewport =
VisualViewportStub::create(viewportSize, viewportSize);
ScrollableArea* rootFrameViewport =
RootFrameViewport::create(*visualViewport, *layoutViewport);
visualViewport->setScale(2);
// Disable just the layout viewport's horizontal scrolling, the
// RootFrameViewport should remain scrollable overall.
layoutViewport->setUserInputScrollable(false, true);
visualViewport->setUserInputScrollable(true, true);
EXPECT_TRUE(rootFrameViewport->userInputScrollable(HorizontalScrollbar));
EXPECT_TRUE(rootFrameViewport->userInputScrollable(VerticalScrollbar));
// Layout viewport shouldn't scroll since it's not horizontally scrollable,
// but visual viewport should.
rootFrameViewport->userScroll(ScrollByPixel, FloatSize(300, 0));
EXPECT_SIZE_EQ(ScrollOffset(0, 0), layoutViewport->getScrollOffset());
EXPECT_SIZE_EQ(ScrollOffset(50, 0), visualViewport->getScrollOffset());
EXPECT_SIZE_EQ(ScrollOffset(50, 0), rootFrameViewport->getScrollOffset());
// Vertical scrolling should be unaffected.
rootFrameViewport->userScroll(ScrollByPixel, FloatSize(0, 300));
EXPECT_SIZE_EQ(ScrollOffset(0, 150), layoutViewport->getScrollOffset());
EXPECT_SIZE_EQ(ScrollOffset(50, 75), visualViewport->getScrollOffset());
EXPECT_SIZE_EQ(ScrollOffset(50, 225), rootFrameViewport->getScrollOffset());
// Try the same checks as above but for the vertical direction.
// ===============================================
rootFrameViewport->setScrollOffset(ScrollOffset(), ProgrammaticScroll);
// Disable just the layout viewport's vertical scrolling, the
// RootFrameViewport should remain scrollable overall.
layoutViewport->setUserInputScrollable(true, false);
visualViewport->setUserInputScrollable(true, true);
EXPECT_TRUE(rootFrameViewport->userInputScrollable(HorizontalScrollbar));
EXPECT_TRUE(rootFrameViewport->userInputScrollable(VerticalScrollbar));
// Layout viewport shouldn't scroll since it's not vertically scrollable,
// but visual viewport should.
rootFrameViewport->userScroll(ScrollByPixel, FloatSize(0, 300));
EXPECT_SIZE_EQ(ScrollOffset(0, 0), layoutViewport->getScrollOffset());
EXPECT_SIZE_EQ(ScrollOffset(0, 75), visualViewport->getScrollOffset());
EXPECT_SIZE_EQ(ScrollOffset(0, 75), rootFrameViewport->getScrollOffset());
// Horizontal scrolling should be unaffected.
rootFrameViewport->userScroll(ScrollByPixel, FloatSize(300, 0));
EXPECT_SIZE_EQ(ScrollOffset(100, 0), layoutViewport->getScrollOffset());
EXPECT_SIZE_EQ(ScrollOffset(50, 75), visualViewport->getScrollOffset());
EXPECT_SIZE_EQ(ScrollOffset(150, 75), rootFrameViewport->getScrollOffset());
}