| 212 | //----------------------------------------------------------------------------- |
| 213 | |
| 214 | void GuiScrollCtrl::scrollRectVisible(RectI rect) |
| 215 | { |
| 216 | // rect is passed in virtual client space |
| 217 | if(rect.extent.x > mContentExt.x) |
| 218 | rect.extent.x = mContentExt.x; |
| 219 | if(rect.extent.y > mContentExt.y) |
| 220 | rect.extent.y = mContentExt.y; |
| 221 | |
| 222 | // Determine the points bounding the requested rectangle |
| 223 | Point2I rectUpperLeft = rect.point; |
| 224 | Point2I rectLowerRight = rect.point + rect.extent; |
| 225 | |
| 226 | // Determine the points bounding the actual visible area... |
| 227 | Point2I visUpperLeft = mChildRelPos; |
| 228 | Point2I visLowerRight = mChildRelPos + mContentExt; |
| 229 | Point2I delta(0,0); |
| 230 | |
| 231 | // We basically try to make sure that first the top left of the given |
| 232 | // rect is visible, and if it is, then that the bottom right is visible. |
| 233 | |
| 234 | // Make sure the rectangle is visible along the X axis... |
| 235 | if(rectUpperLeft.x < visUpperLeft.x) |
| 236 | delta.x = rectUpperLeft.x - visUpperLeft.x; |
| 237 | else if(rectLowerRight.x > visLowerRight.x) |
| 238 | delta.x = rectLowerRight.x - visLowerRight.x; |
| 239 | |
| 240 | // Make sure the rectangle is visible along the Y axis... |
| 241 | if(rectUpperLeft.y < visUpperLeft.y) |
| 242 | delta.y = rectUpperLeft.y - visUpperLeft.y; |
| 243 | else if(rectLowerRight.y > visLowerRight.y) |
| 244 | delta.y = rectLowerRight.y - visLowerRight.y; |
| 245 | |
| 246 | // If we had any changes, scroll, otherwise don't. |
| 247 | if(delta.x || delta.y) |
| 248 | scrollDelta(delta.x, delta.y); |
| 249 | } |
| 250 | |
| 251 | //----------------------------------------------------------------------------- |
| 252 |
no outgoing calls
no test coverage detected