当前位置: 首页>>代码示例>>C++>>正文


C++ ScrollableArea::userScroll方法代码示例

本文整理汇总了C++中ScrollableArea::userScroll方法的典型用法代码示例。如果您正苦于以下问题:C++ ScrollableArea::userScroll方法的具体用法?C++ ScrollableArea::userScroll怎么用?C++ ScrollableArea::userScroll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScrollableArea的用法示例。


在下文中一共展示了ScrollableArea::userScroll方法的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());
}
开发者ID:,项目名称:,代码行数:62,代码来源:


注:本文中的ScrollableArea::userScroll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。