* Ignores any mouse clicks that are outside the globe * and handles globe rotation and zooming. * @param action Pointer to an action. * @param state State that the action handlers belong to. */
| 1942 | * @param state State that the action handlers belong to. |
| 1943 | */ |
| 1944 | void Globe::mouseClick(Action *action, State *state) |
| 1945 | { |
| 1946 | if (action->getDetails()->button.button == SDL_BUTTON_WHEELUP) |
| 1947 | { |
| 1948 | zoomIn(); |
| 1949 | } |
| 1950 | else if (action->getDetails()->button.button == SDL_BUTTON_WHEELDOWN) |
| 1951 | { |
| 1952 | zoomOut(); |
| 1953 | } |
| 1954 | |
| 1955 | double lon, lat; |
| 1956 | cartToPolar((Sint16)floor(action->getAbsoluteXMouse()), (Sint16)floor(action->getAbsoluteYMouse()), &lon, &lat); |
| 1957 | |
| 1958 | // The following is the workaround for a rare problem where sometimes |
| 1959 | // the mouse-release event is missed for any reason. |
| 1960 | // However if the SDL is also missed the release event, then it is to no avail :( |
| 1961 | // (this part handles the release if it is missed and now an other button is used) |
| 1962 | if (_isMouseScrolling) |
| 1963 | { |
| 1964 | if (action->getDetails()->button.button != Options::geoDragScrollButton |
| 1965 | && 0 == (SDL_GetMouseState(0, 0)&SDL_BUTTON(Options::geoDragScrollButton))) |
| 1966 | { // so we missed again the mouse-release :( |
| 1967 | // Check if we have to revoke the scrolling, because it was too short in time, so it was a click |
| 1968 | if ((!_mouseMovedOverThreshold) && (SDL_GetTicks() - _mouseScrollingStartTime <= (Options::dragScrollTimeTolerance))) |
| 1969 | { |
| 1970 | center(_lonBeforeMouseScrolling, _latBeforeMouseScrolling); |
| 1971 | } |
| 1972 | _isMouseScrolled = _isMouseScrolling = false; |
| 1973 | stopScrolling(action); |
| 1974 | } |
| 1975 | } |
| 1976 | |
| 1977 | // DragScroll-Button release: release mouse-scroll-mode |
| 1978 | if (_isMouseScrolling) |
| 1979 | { |
| 1980 | // While scrolling, other buttons are ineffective |
| 1981 | if (action->getDetails()->button.button == Options::geoDragScrollButton) |
| 1982 | { |
| 1983 | _isMouseScrolling = false; |
| 1984 | stopScrolling(action); |
| 1985 | } |
| 1986 | else |
| 1987 | { |
| 1988 | return; |
| 1989 | } |
| 1990 | // Check if we have to revoke the scrolling, because it was too short in time, so it was a click |
| 1991 | if ((!_mouseMovedOverThreshold) && (SDL_GetTicks() - _mouseScrollingStartTime <= (Options::dragScrollTimeTolerance))) |
| 1992 | { |
| 1993 | _isMouseScrolled = false; |
| 1994 | stopScrolling(action); |
| 1995 | center(_lonBeforeMouseScrolling, _latBeforeMouseScrolling); |
| 1996 | } |
| 1997 | if (_isMouseScrolled) return; |
| 1998 | } |
| 1999 | |
| 2000 | // Check for errors |
| 2001 | if (lat == lat && lon == lon) |
nothing calls this directly
no test coverage detected