MCPcopy Create free account
hub / github.com/MyGUI/mygui / recalculateTime

Method recalculateTime

MyGUIEngine/src/MyGUI_ControllerEdgeHide.cpp:127–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 }
126
127 void ControllerEdgeHide::recalculateTime(Widget* _widget)
128 {
129 float k = 0;
130 const MyGUI::IntCoord& coord = _widget->getCoord();
131 const MyGUI::IntSize& view_size = _widget->getParentSize();
132
133 bool behindLeft = coord.left <= 0;
134 bool behindRight = coord.right() >= view_size.width - 1;
135 bool behindTop = coord.top <= 0;
136 bool behindBottom = coord.bottom() >= view_size.height - 1;
137 // check if widget is near any border and not near opposite borders at same time
138 if (behindLeft && !behindRight)
139 {
140 k = -(float)coord.left / (coord.width - mRemainPixels - mShadowSize);
141 }
142 else if (behindTop && !behindBottom)
143 {
144 k = -(float)coord.top / (coord.height - mRemainPixels - mShadowSize);
145 }
146 else if (behindRight && !behindLeft)
147 {
148 k = (float)(coord.right() - view_size.width + 1) / (coord.width - mRemainPixels);
149 }
150 else if (behindBottom && !behindTop)
151 {
152 k = (float)(coord.bottom() - view_size.height + 1) / (coord.height - mRemainPixels);
153 }
154
155 //mElapsedTime = (asin(k)/M_PI + 1./2) * mTime;
156 // this is reversed formula from ControllerEdgeHide::addTime k calculation
157 if (k > 0.5f)
158 mElapsedTime = (std::asin(std::pow(2 * k - 1, 1 / 0.7f)) / M_PI + 1.f / 2) * mTime;
159 else
160 mElapsedTime = (std::asin(-std::pow(-2 * k + 1, 1 / 0.7f)) / M_PI + 1.f / 2) * mTime;
161 }
162
163 void ControllerEdgeHide::setTime(float _value)
164 {

Callers

nothing calls this directly

Calls 3

getParentSizeMethod · 0.80
rightMethod · 0.80
bottomMethod · 0.80

Tested by

no test coverage detected