MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / update

Method update

src/components/ScrollableContainer.cpp:46–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void ScrollableContainer::update(int deltaTime)
47{
48 double scrollAmt = (double)deltaTime;
49
50 if(mAutoScrollSpeed != 0)
51 {
52 mAutoScrollTimer += deltaTime;
53
54 scrollAmt = (float)(mAutoScrollTimer - mAutoScrollDelay);
55
56 if(scrollAmt > 0)
57 {
58 //scroll the amount of time left over from the delay
59 mAutoScrollTimer = mAutoScrollDelay;
60
61 //scale speed by our width! more text per line = slower scrolling
62 const double widthMod = (680.0 / getSize().x());
63 mScrollDir = Eigen::Vector2d(0, mAutoScrollSpeed * widthMod);
64 }else{
65 //not enough to pass the delay, do nothing
66 scrollAmt = 0;
67 }
68 }
69
70 Eigen::Vector2d scroll = mScrollDir * scrollAmt;
71 mScrollPos += scroll;
72
73 //clip scrolling within bounds
74 if(mScrollPos.x() < 0)
75 mScrollPos[0] = 0;
76 if(mScrollPos.y() < 0)
77 mScrollPos[1] = 0;
78
79
80 Eigen::Vector2f contentSize = getContentSize();
81 if(mScrollPos.x() + getSize().x() > contentSize.x())
82 mScrollPos[0] = (double)contentSize.x() - getSize().x();
83 if(mScrollPos.y() + getSize().y() > contentSize.y())
84 mScrollPos[1] = (double)contentSize.y() - getSize().y();
85
86 GuiComponent::update(deltaTime);
87}
88
89//this should probably return a box to allow for when controls don't start at 0,0
90Eigen::Vector2f ScrollableContainer::getContentSize()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected