Changeset 60:23a1d2b1ec5f
- Timestamp:
- 06/24/08 15:40:52
(7 months ago)
- Author:
- Diggory Hardy <diggory.hardy@gmail.com>
- branch:
- default
- Message:
Fixed a little bug giving the mouse pointer the correct position.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r34 |
r60 |
|
| 30 | 30 | Some unifications of the coordinate system are needed: |
|---|
| 31 | 31 | By default OpenGL uses the bottom left as the origin, with the first (bottom-left most) pixel at 0,0. |
|---|
| 32 | | SDL's mouse events use the top left as the origin, with the first (top-left most) pixel at 1,1. |
|---|
| 33 | | I decided, for the GUI, to use the top-left at the origin with the top-left most pixel at 0,0. For OpenGL, the projection can simply be modified to achieve this; for SDL's events 1 is subtracted from each coordinate when the event is recieved. |
|---|
| | 32 | SDL's mouse events use the top left as the origin, with the first (top-left most) pixel at 0,0. |
|---|
| | 33 | I decided, for the GUI, to use the top-left at the origin with the top-left most pixel at 0,0. For OpenGL, the projection can simply be modified to achieve this. |
|---|
| r37 |
r60 |
|
| 191 | 191 | * some functionality at least is retained. |
|---|
| 192 | 192 | * |
|---|
| 193 | | * Note that the mouse coordinates as reported by SDL put the top-left most pixel at 1,1. |
|---|
| 194 | | * Internal coordinates put that pixel at 0,0 (see gui/GUI notes.txt). |
|---|
| | 193 | * Coordinates don't need adjusting (they put the top-left most pixel at 0,0). |
|---|
| 195 | 194 | */ |
|---|
| 196 | 195 | switch (event.type) { |
|---|
| … | … | |
| 199 | 198 | foreach (dg; mouseClickCallbacks) { |
|---|
| 200 | 199 | try |
|---|
| 201 | | dg (event.button.x - 1, event.button.y - 1, |
|---|
| | 200 | dg (event.button.x, event.button.y, |
|---|
| 202 | 201 | event.button.button, event.button.state == SDL_PRESSED); |
|---|
| 203 | 202 | catch (Exception e) |
|---|
| … | … | |
| 207 | 206 | |
|---|
| 208 | 207 | case SDL_MOUSEMOTION: |
|---|
| 209 | | mouse_x = event.motion.x - 1; |
|---|
| 210 | | mouse_y = event.motion.y - 1; |
|---|
| | 208 | mouse_x = event.motion.x; |
|---|
| | 209 | mouse_y = event.motion.y; |
|---|
| 211 | 210 | |
|---|
| 212 | 211 | foreach (dg; mouseMotionCallbacks) { |
|---|
| 213 | 212 | try |
|---|
| 214 | | dg (event.motion.x - 1, event.motion.y - 1); |
|---|
| | 213 | dg (event.motion.x, event.motion.y); |
|---|
| 215 | 214 | catch (Exception e) |
|---|
| 216 | 215 | logger.error (CB_EXC ~ e.msg); |
|---|