Correction du défilement à la souris (pointeur)

This commit is contained in:
Mattéo Delabre 2016-04-28 10:32:54 +02:00
parent 7d46367eb5
commit dd54596cb7
1 changed files with 21 additions and 10 deletions

View File

@ -277,17 +277,28 @@ void Editor::frame() {
sf::Vector2i mouse = sf::Mouse::getPosition(window);
// détection du dépassement sur un des 4 bords
if (mouse.x < POINTER_SCROLL_PADDING && mouse.x >= -POINTER_SCROLL_PADDING) {
cur_center.x -= POINTER_SCROLL_SPEED;
} else if (mouse.x >= window_size.x - POINTER_SCROLL_PADDING && mouse.x < window_size.x + POINTER_SCROLL_PADDING) {
cur_center.x += POINTER_SCROLL_SPEED;
} else if (mouse.y < POINTER_SCROLL_PADDING && mouse.y >= -POINTER_SCROLL_PADDING) {
cur_center.y -= POINTER_SCROLL_SPEED;
} else if (mouse.y >= window_size.y - POINTER_SCROLL_PADDING && mouse.y < window_size.y + POINTER_SCROLL_PADDING) {
cur_center.y += POINTER_SCROLL_SPEED;
}
if (mouse.x >= -POINTER_SCROLL_PADDING &&
mouse.x < window_size.x + POINTER_SCROLL_PADDING &&
mouse.y >= -POINTER_SCROLL_PADDING &&
mouse.y < window_size.y + POINTER_SCROLL_PADDING) {
if (mouse.x < POINTER_SCROLL_PADDING) {
cur_center.x -= POINTER_SCROLL_SPEED;
}
setCenterGoal(cur_center);
if (mouse.x >= window_size.x - POINTER_SCROLL_PADDING) {
cur_center.x += POINTER_SCROLL_SPEED;
}
if (mouse.y < POINTER_SCROLL_PADDING) {
cur_center.y -= POINTER_SCROLL_SPEED;
}
if (mouse.y >= window_size.y - POINTER_SCROLL_PADDING) {
cur_center.y += POINTER_SCROLL_SPEED;
}
setCenterGoal(cur_center);
}
}
// màj du titre de la fenêtre