review code button et fontutils

separation-create-menu
Mathis RIBEMONT 3 years ago
parent faf47fa469
commit 75f45eafde

@ -65,9 +65,9 @@ bool isHover(P_Button* button);// dit si le bouton est survolé en donnant les c
* \param[in] button the button target
* \param[in] x x of the point
* \param[in] y y of the point
* \return 1 if the cursor has just entry in the button, 2 if it has just exit, else 0
* \return BUTTON_ENTRY if the cursor has just entry in the button, BUTTON_EXIT if it has just exit, else BUTTON_NOTHING
*/
int isButtonInteractWithCursor(P_Button * button,const int x,const int y);
ButtonEvent isButtonInteractWithCursor(P_Button * button,const int x,const int y);
/**
* \brief Free the texture of a button.

@ -65,13 +65,16 @@ bool changeButtonHoverTexture(P_Button* button, SDL_Texture* texture)
void freeButton(P_Button * button){
SDL_DestroyTexture(button->texture);
SDL_DestroyTexture(button->hoverTexture);
button->enable = false;
button->texture = NULL;
button->hoverTexture = NULL;
}
bool isHover(P_Button * button) {
return button->hover;
}
int isButtonInteractWithCursor(P_Button * button,const int x,const int y){
ButtonEvent isButtonInteractWithCursor(P_Button * button,const int x,const int y){
if (!button->enable) return BUTTON_NOTHING;
SDL_Point coord;

@ -4,6 +4,7 @@
void action_none(P_Button* caller) {
//return nothing
}
@ -25,4 +26,3 @@ void action_muteSound(P_Button* caller)
//Change Icon -> Mute icon
//caller->texture = createTextureFromPath(renderer,"rsrc/img/MuteResized.png");
}

@ -3,8 +3,7 @@
int calculateStringPixelLenght(TTF_Font* font, char* str)
{
char curentChar;
int lenght = 0;
int length = 0;
int minx, maxx;
int i=0;
@ -19,12 +18,11 @@ int calculateStringPixelLenght(TTF_Font* font, char* str)
return 0;
}
curentChar = *str;
while(i < textLenght)
{
TTF_GlyphMetrics(font, curentChar, &minx, &maxx, NULL, NULL, NULL);
lenght += maxx-minx;
TTF_GlyphMetrics(font, str[i], &minx, &maxx, NULL, NULL, NULL);
length += maxx-minx;
++i;
}
return lenght;
return length;
}

Loading…
Cancel
Save