diff --git a/Controleur/controleur.c b/Controleur/controleur.c index fe16add..eaefd8e 100644 --- a/Controleur/controleur.c +++ b/Controleur/controleur.c @@ -39,6 +39,7 @@ ErrEnum controlePoints(sfRenderWindow *window, const char *cheminFichier, Mode m sfEvent event; Rectangle carre; Action action = NO_ACTION; + Tool currentTool = NO_TOOL; bool centerCursor = false; // Un pointeur sur une carte qui stockera successivement les vues. @@ -167,7 +168,7 @@ ErrEnum controlePoints(sfRenderWindow *window, const char *cheminFichier, Mode m afficherMenu(renderTexture, &menu); - carre = waitingOnMapEvent(window, &event, renderTexture, renderSprite, carte, nbPointsAffiches, ptsAffiches, tabPointeursCercles, &nbPointSuppr, pointsSuppr, nbAgglos, tabPointeursCerclesAgglos, agglos, agglosSuppr, &nbAgglosSuppr, nbElements, tabPoints, tabDatesConverties, font, &action, &menu); + carre = waitingOnMapEvent(window, &event, renderTexture, renderSprite, carte, nbPointsAffiches, ptsAffiches, tabPointeursCercles, &nbPointSuppr, pointsSuppr, nbAgglos, tabPointeursCerclesAgglos, agglos, agglosSuppr, &nbAgglosSuppr, nbElements, tabPoints, tabDatesConverties, font, &action, &menu, ¤tTool); free(ptsAffiches); ptsAffiches = NULL; diff --git a/Controleur/waiting.c b/Controleur/waiting.c index 5f311ff..4af2c5b 100644 --- a/Controleur/waiting.c +++ b/Controleur/waiting.c @@ -104,7 +104,7 @@ Rectangle waitingOnMap(sfRenderWindow *const window, sfEvent *const event, sfRen } -Rectangle waitingOnMapEvent(sfRenderWindow *const window, sfEvent *const event, sfRenderTexture *renderTexture, sfSprite *renderSprite, const Carte *const carte, const uint32_t nbPointsAffiches, Point ** ptsAffiches, sfCircleShape *tabPointeursCercles[nbPointsAffiches], uint32_t *const nbPointSuppr, uint32_t pointsSuppr[*nbPointSuppr], const uint32_t nbAgglos, sfCircleShape *tabPointeursCerclesAgglos[nbAgglos], Agglomerat *agglos, uint32_t agglosSuppr[nbAgglos], uint32_t *nbAgglosSuppr, uint32_t nbPoints, Point *tabPoint, char **tabDatesConverties, const sfFont *const font, Action *const action, const Menu *const menu) +Rectangle waitingOnMapEvent(sfRenderWindow *const window, sfEvent *const event, sfRenderTexture *renderTexture, sfSprite *renderSprite, const Carte *const carte, const uint32_t nbPointsAffiches, Point ** ptsAffiches, sfCircleShape *tabPointeursCercles[nbPointsAffiches], uint32_t *const nbPointSuppr, uint32_t pointsSuppr[*nbPointSuppr], const uint32_t nbAgglos, sfCircleShape *tabPointeursCerclesAgglos[nbAgglos], Agglomerat *agglos, uint32_t agglosSuppr[nbAgglos], uint32_t *nbAgglosSuppr, uint32_t nbPoints, Point *tabPoint, char **tabDatesConverties, const sfFont *const font, Action *const action, const Menu *const menu, Tool * currentTool) { sfTexture *originalTexture = sfTexture_copy(sfRenderTexture_getTexture(renderTexture)); @@ -195,7 +195,7 @@ Rectangle waitingOnMapEvent(sfRenderWindow *const window, sfEvent *const event, break; } - else if(event->type == sfEvtMouseButtonPressed) + else if(event->type == sfEvtMouseButtonPressed && event->mouseButton.x > MAPSIZE) { // Dans quasiment tous les cas, il faudra sortir de la boucle englobante... bool needToBreakTheWhile = true; @@ -218,7 +218,8 @@ Rectangle waitingOnMapEvent(sfRenderWindow *const window, sfEvent *const event, break; case TOOL_ZOOMZONE: - // TO DO ! + needToBreakTheWhile = false; + *currentTool = *currentTool == TOOL_ZOOMZONE?NO_TOOL:TOOL_ZOOMZONE; break; case TOOL_ZOOMPREV: @@ -253,7 +254,7 @@ Rectangle waitingOnMapEvent(sfRenderWindow *const window, sfEvent *const event, } } - else if(sfMouse_isButtonPressed(sfMouseLeft) && *action == ACTION_ZOOMABLE && inWindow) + else if(sfMouse_isButtonPressed(sfMouseLeft) && *action == ACTION_ZOOMABLE && inWindow && *currentTool == TOOL_ZOOMZONE) { Rectangle carre = selectionRectangle(window, event, renderSprite, true); diff --git a/Controleur/waiting.h b/Controleur/waiting.h index a268b75..116c3cb 100644 --- a/Controleur/waiting.h +++ b/Controleur/waiting.h @@ -57,6 +57,7 @@ Rectangle waitingOnMap(sfRenderWindow *const window, sfEvent *const event, sfRen * @param font Pointeur sur la fonte à utiliser pour les dates à afficher. * @param action Variable de type particulier qui indique l'action effectuée par l'utilisateur. * @param menu Notre menu chéri ! + * @param currentTool L'outil actuellement sélectionné par l'utilisateur. * @return Le carré saisi par l'utilisateur. */ -Rectangle waitingOnMapEvent(sfRenderWindow *const window, sfEvent *const event, sfRenderTexture *renderTexture, sfSprite *renderSprite, const Carte *const carte, const uint32_t nbPointsAffiches, Point ** ptsAffiches, sfCircleShape *tabPointeursCercles[nbPointsAffiches], uint32_t *const nbPointSuppr, uint32_t pointsSuppr[*nbPointSuppr], const uint32_t nbAgglos, sfCircleShape *tabPointeursCerclesAgglos[nbAgglos], Agglomerat *agglos, uint32_t agglosSuppr[nbAgglos], uint32_t * nbAgglosSuppr,uint32_t nbPoints ,Point * tabPoint, char **tabDatesConverties, const sfFont *const font, Action *const action, const Menu *const menu); +Rectangle waitingOnMapEvent(sfRenderWindow *const window, sfEvent *const event, sfRenderTexture *renderTexture, sfSprite *renderSprite, const Carte *const carte, const uint32_t nbPointsAffiches, Point ** ptsAffiches, sfCircleShape *tabPointeursCercles[nbPointsAffiches], uint32_t *const nbPointSuppr, uint32_t pointsSuppr[*nbPointSuppr], const uint32_t nbAgglos, sfCircleShape *tabPointeursCerclesAgglos[nbAgglos], Agglomerat *agglos, uint32_t agglosSuppr[nbAgglos], uint32_t * nbAgglosSuppr,uint32_t nbPoints ,Point * tabPoint, char **tabDatesConverties, const sfFont *const font, Action *const action, const Menu *const menu, Tool * const currentTool); diff --git a/Vue/selection.c b/Vue/selection.c index 9eaf9f7..fc869a9 100644 --- a/Vue/selection.c +++ b/Vue/selection.c @@ -16,7 +16,7 @@ Rectangle selectionRectangle(sfRenderWindow *const window, sfEvent *event, const { sfRenderWindow_clear(window, sfWhite); - positionCurseur.x = event->mouseMove.x; + positionCurseur.x = event->mouseMove.x < MAPSIZE ?event->mouseMove.x:MAPSIZE; positionCurseur.y = event->mouseMove.y; shape = creerRectangle(positionInitiale, positionCurseur, (sfColor){0, 0, 255, 32});