diff --git a/boutons.c b/boutons.c index 33da1d45..a1f9b722 100644 --- a/boutons.c +++ b/boutons.c @@ -2311,15 +2311,15 @@ void Print_Nom_fichier_dans_selecteur(void) } -void Print_Format(void) +void Print_Format(struct Fenetre_Bouton_dropdown * Dropdown) // // Affiche le libellé correspondant à Principal_Format // { if (Principal_Format==0) - Print_dans_fenetre(83,65,"*.*",CM_Noir,CM_Clair); + Print_dans_fenetre(Dropdown->Pos_X+2+7*8,Dropdown->Pos_Y+2,"*.*",CM_Noir,CM_Clair); else - Print_dans_fenetre(83,65,FormatFichier[Principal_Format-1].Extension,CM_Noir,CM_Clair); + Print_dans_fenetre(Dropdown->Pos_X+2+7*8,Dropdown->Pos_Y+2,FormatFichier[Principal_Format-1].Extension,CM_Noir,CM_Clair); } @@ -2457,6 +2457,7 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) { short Bouton_clicke; struct Fenetre_Bouton_scroller * Scroller_de_fichiers; + struct Fenetre_Bouton_dropdown * Dropdown_des_formats; short Temp; int Bidon=0; // Sert à appeler SDL_GetKeyState word Drives_Debut_Y; @@ -2522,7 +2523,7 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) Fenetre_Definir_bouton_normal(125, 89+FILENAMESPACE,51,14,"Delete",0,1,SDLK_DELETE); // 3 // Cadre autour des formats - Fenetre_Afficher_cadre( 7, 51,103, 35); + Fenetre_Afficher_cadre( 7, 51,104, 35); // Cadre autour des infos sur le fichier de dessin Fenetre_Afficher_cadre(116, 51,187, 35); // Cadre autour de la preview @@ -2535,8 +2536,18 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) // Scroller du fileselector Scroller_de_fichiers = Fenetre_Definir_bouton_scroller(110,89+FILENAMESPACE,82,1,10,0); // 5 - // Scroller des formats - Fenetre_Definir_bouton_scroller(12,55,27,(Load)?NB_FORMATS_LOAD+1:NB_FORMATS_SAVE,1,(Load)?Principal_Format:Principal_Format-1); // 6 + // Dropdown pour les formats de fichier + Dropdown_des_formats=Fenetre_Definir_bouton_dropdown(12,56,94,11,"",1); // 6 + if (Load) + Fenetre_Dropdown_choix(Dropdown_des_formats,0,"*.*"); + for (Temp=0;TempPos_X+2,Dropdown_des_formats->Pos_Y+2,"Format",CM_Noir,CM_Clair); + Print_Format(Dropdown_des_formats); // Texte de commentaire des dessins Print_dans_fenetre(7,174+FILENAMESPACE,"Txt:",CM_Fonce,CM_Clair); @@ -2548,13 +2559,10 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) // Saisie du nom de fichier Fenetre_Definir_bouton_saisie(11+9*8,88,27); // 8 - Print_dans_fenetre( 27,65,"Format:",CM_Fonce,CM_Clair); Print_dans_fenetre(120,55,"Image size :",CM_Fonce,CM_Clair); Print_dans_fenetre(120,63,"File size :",CM_Fonce,CM_Clair); Print_dans_fenetre(120,72,"Format :",CM_Fonce,CM_Clair); - Print_Format(); - // Selecteur de Lecteur / Volume Fenetre_Definir_bouton_normal(8,21,120,14,"Select drive",0,1,SDLK_LAST); // 9 @@ -2566,7 +2574,7 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) Fenetre_Definir_bouton_normal(130+((Temp%8)*20),Drives_Debut_Y+((Temp/8)*12),19,11,Nom_drive,0,1, SDLK_LAST); // 10 et + Fenetre_Afficher_sprite_drive(140+((Temp%8)*20),Drives_Debut_Y+2+((Temp/8)*12),Drive[Temp].Type); } - + // On prend bien soin de passer dans le répertoire courant (le bon qui faut! Oui madame!) if (Load) { @@ -2750,9 +2758,9 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) case 6 : // Scroller des formats Effacer_curseur(); // On met à jour le format de browsing du fileselect: - Principal_Format=(Load)?Fenetre_Attribut2:Fenetre_Attribut2+1; + Principal_Format=Fenetre_Attribut2; // On affiche le nouveau format de lecture: - Print_Format(); + Print_Format(Dropdown_des_formats); // Comme on change de liste, on se place en début de liste: Principal_File_list_Position=0; Principal_File_list_Decalage=0; diff --git a/global.h b/global.h index 3234ab0c..989b2a51 100644 --- a/global.h +++ b/global.h @@ -367,6 +367,10 @@ GFX2_GLOBAL struct Fenetre_Bouton_scroller * Pile_Fenetre_Liste_boutons_scroller GFX2_GLOBAL struct Fenetre_Bouton_special * Pile_Fenetre_Liste_boutons_special[8]; #define Fenetre_Liste_boutons_special Pile_Fenetre_Liste_boutons_special[Fenetre-1] +GFX2_GLOBAL struct Fenetre_Bouton_dropdown * Pile_Fenetre_Liste_boutons_dropdown[8]; +#define Fenetre_Liste_boutons_dropdown Pile_Fenetre_Liste_boutons_dropdown[Fenetre-1] + + GFX2_GLOBAL int Pile_Fenetre_Attribut1[8]; #define Fenetre_Attribut1 Pile_Fenetre_Attribut1[Fenetre-1] diff --git a/moteur.c b/moteur.c index 6da6ed69..14738c05 100644 --- a/moteur.c +++ b/moteur.c @@ -1144,6 +1144,7 @@ void Ouvrir_fenetre(word Largeur,word Hauteur, char * Titre) Fenetre_Liste_boutons_palette =NULL; Fenetre_Liste_boutons_scroller=NULL; Fenetre_Liste_boutons_special =NULL; + Fenetre_Liste_boutons_dropdown=NULL; Nb_boutons_fenetre =0; } @@ -1158,6 +1159,7 @@ void Fermer_fenetre(void) struct Fenetre_Bouton_palette * Temp2; struct Fenetre_Bouton_scroller * Temp3; struct Fenetre_Bouton_special * Temp4; + struct Fenetre_Bouton_dropdown * Temp5; Effacer_curseur(); @@ -1185,6 +1187,12 @@ void Fermer_fenetre(void) free(Fenetre_Liste_boutons_special); Fenetre_Liste_boutons_special=Temp4; } + while (Fenetre_Liste_boutons_dropdown) + { + Temp5=Fenetre_Liste_boutons_dropdown->Next; + free(Fenetre_Liste_boutons_dropdown); + Fenetre_Liste_boutons_dropdown=Temp5; + } if (Fenetre != 1) { @@ -1564,8 +1572,50 @@ struct Fenetre_Bouton_special * Fenetre_Definir_bouton_saisie(word Pos_X,word Po return Temp; } +struct Fenetre_Bouton_dropdown * Fenetre_Definir_bouton_dropdown(word Pos_X,word Pos_Y,word Largeur,word Hauteur,char *Libelle,byte Affiche_choix) +{ + struct Fenetre_Bouton_dropdown *Temp; + + Temp=(struct Fenetre_Bouton_dropdown *)malloc(sizeof(struct Fenetre_Bouton_dropdown)); + Temp->Numero =++Nb_boutons_fenetre; + Temp->Pos_X =Pos_X; + Temp->Pos_Y =Pos_Y; + Temp->Largeur =Largeur; + Temp->Hauteur =Hauteur; + Temp->AfficheChoix =Affiche_choix; + Temp->Premier_choix=NULL; + Temp->Next=Fenetre_Liste_boutons_dropdown; + Fenetre_Liste_boutons_dropdown=Temp; + Fenetre_Dessiner_bouton_normal(Pos_X,Pos_Y,Largeur,Hauteur,Libelle,-1,1); + return Temp; +} +// Ajoute un choix à une dropdown. Le libellé est seulement référencé, +// il doit pointer sur une zone qui doit être encore valide à la fermeture +// de la fenêtre (comprise). +void Fenetre_Dropdown_choix(struct Fenetre_Bouton_dropdown * Dropdown, word Numero, const char *Libelle) +{ + struct Bouton_dropdown_choix *Temp; + struct Bouton_dropdown_choix *Dernier; + + Temp=(struct Bouton_dropdown_choix *)malloc(sizeof(struct Bouton_dropdown_choix)); + Temp->Numero =Numero; + Temp->Libelle=Libelle; + Temp->Next=NULL; + + Dernier=Dropdown->Premier_choix; + if (Dernier) + { + for (;Dernier->Next;Dernier=Dernier->Next) + ; + Dernier->Next=Temp; + } + else + { + Dropdown->Premier_choix=Temp; + } +} //----------------------- Ouverture d'un pop-up ----------------------- @@ -1579,20 +1629,20 @@ void Ouvrir_popup(word Pos_X, word Pos_Y, word Largeur,word Hauteur) // -Pas de titre // -Pas de cadre en relief mais seulement un plat, et il est blanc au lieu de noir. { - Effacer_curseur(); - Fenetre++; Fenetre_Largeur=Largeur; Fenetre_Hauteur=Hauteur; - Fenetre_Pos_X=Pos_X*Menu_Facteur_X; - Fenetre_Pos_Y=Pos_Y*Menu_Facteur_X; + Fenetre_Pos_X=Pos_X; + Fenetre_Pos_Y=Pos_Y; // Sauvegarde de ce que la fenêtre remplace - Sauve_fond(&(Fond_fenetre[Fenetre-1]), Fenetre_Pos_X, Fenetre_Pos_Y, Largeur*Menu_Facteur_X, Hauteur*Menu_Facteur_X); + Sauve_fond(&(Fond_fenetre[Fenetre-1]), Fenetre_Pos_X, Fenetre_Pos_Y, Largeur, Hauteur); // Fenêtre grise - Block(Fenetre_Pos_X+(Menu_Facteur_X),Fenetre_Pos_Y+(Menu_Facteur_Y),(Largeur-2)*Menu_Facteur_X,(Hauteur-2)*Menu_Facteur_Y,CM_Clair); + Block(Fenetre_Pos_X+1*Menu_Facteur_X, + Fenetre_Pos_Y+1*Menu_Facteur_Y, + (Largeur-2)*Menu_Facteur_X,(Hauteur-2)*Menu_Facteur_Y,CM_Clair); // Cadre noir puis en relief Fenetre_Afficher_cadre_mono(0,0,Largeur,Hauteur,CM_Blanc); @@ -1614,6 +1664,7 @@ void Ouvrir_popup(word Pos_X, word Pos_Y, word Largeur,word Hauteur) Fenetre_Liste_boutons_palette =NULL; Fenetre_Liste_boutons_scroller=NULL; Fenetre_Liste_boutons_special =NULL; + Fenetre_Liste_boutons_dropdown =NULL; Nb_boutons_fenetre =0; } @@ -1628,6 +1679,7 @@ void Fermer_popup(void) struct Fenetre_Bouton_palette * Temp2; struct Fenetre_Bouton_scroller * Temp3; struct Fenetre_Bouton_special * Temp4; + struct Fenetre_Bouton_dropdown * Temp5; Effacer_curseur(); @@ -1655,6 +1707,19 @@ void Fermer_popup(void) free(Fenetre_Liste_boutons_special); Fenetre_Liste_boutons_special=Temp4; } + while (Fenetre_Liste_boutons_dropdown) + { + while (Fenetre_Liste_boutons_dropdown->Premier_choix) + { + struct Bouton_dropdown_choix *Temp6; + Temp6=Fenetre_Liste_boutons_dropdown->Premier_choix->Next; + free(Fenetre_Liste_boutons_dropdown->Premier_choix); + Fenetre_Liste_boutons_dropdown->Premier_choix=Temp6; + } + Temp5=Fenetre_Liste_boutons_dropdown->Next; + free(Fenetre_Liste_boutons_dropdown); + Fenetre_Liste_boutons_dropdown=Temp5; + } if (Fenetre != 1) { @@ -2014,7 +2079,95 @@ void Deplacer_fenetre(short Dx, short Dy) } +// Gestion des dropdown +short Fenetre_Dropdown_click(struct Fenetre_Bouton_dropdown *Bouton) +{ + short Nb_choix; + short Indice_choix; + short Indice_selectionne; + short Ancien_Indice_selectionne; + short Hauteur_boite; + struct Bouton_dropdown_choix *Choix; + + // Comptage des items pour calculer la taille + Nb_choix=0; + for (Choix=Bouton->Premier_choix; Choix!=NULL; Choix=Choix->Next) + { + Nb_choix++; + } + Hauteur_boite=2+Nb_choix*8+1; + + Effacer_curseur(); + Fenetre_Enfoncer_bouton_normal(Bouton->Pos_X,Bouton->Pos_Y,Bouton->Largeur,Bouton->Hauteur); + Ouvrir_popup( + Fenetre_Pos_X+(Bouton->Pos_X)*Menu_Facteur_X, + Fenetre_Pos_Y+(Bouton->Pos_Y+Bouton->Hauteur)*Menu_Facteur_Y, + Bouton->Largeur, + Hauteur_boite); + + Indice_selectionne=-1; + while (1) + { + Ancien_Indice_selectionne = Indice_selectionne; + // Fenêtre grise + Block(Fenetre_Pos_X+1*Menu_Facteur_X, + Fenetre_Pos_Y+1*Menu_Facteur_Y, + (Bouton->Largeur-2)*Menu_Facteur_X,(Hauteur_boite-2)*Menu_Facteur_Y,CM_Clair); + // Affichage des items + for(Choix=Bouton->Premier_choix,Indice_choix=0; Choix!=NULL; Choix=Choix->Next,Indice_choix++) + { + byte C1; + byte C2; + if (Indice_choix==Indice_selectionne) + { + C1=CM_Blanc; + C2=CM_Fonce; + Block(Fenetre_Pos_X+2*Menu_Facteur_X, + Fenetre_Pos_Y+((1+Indice_choix*8)*Menu_Facteur_Y), + (Bouton->Largeur-4)*Menu_Facteur_X,(8)*Menu_Facteur_Y,CM_Fonce); + } + else + { + C1=CM_Noir; + C2=CM_Clair; + } + Print_dans_fenetre(3,1+Indice_choix*8,Choix->Libelle,C1,C2); + } + UpdateRect(Fenetre_Pos_X,Fenetre_Pos_Y,Fenetre_Largeur*Menu_Facteur_X,Fenetre_Hauteur*Menu_Facteur_Y); + Afficher_curseur(); + do + { + // Attente + if(!Get_input()) + Wait_VBL(); + // Mise à jour du survol + Indice_selectionne=Fenetre_click_dans_zone(1,1,Bouton->Largeur-1,Hauteur_boite-1)? + (((Mouse_Y-Fenetre_Pos_Y)/Menu_Facteur_Y-1)>>3) : -1; + + } while (Mouse_K && Indice_selectionne==Ancien_Indice_selectionne); + + if (!Mouse_K) + break; + Effacer_curseur(); + } + + Fermer_popup(); + + + Fenetre_Desenfoncer_bouton_normal(Bouton->Pos_X,Bouton->Pos_Y,Bouton->Largeur,Bouton->Hauteur); + Afficher_curseur(); + + Fenetre_Attribut2=0; + if (Indice_selectionne>=0 && Indice_selectionnePremier_choix; Indice_selectionne; Choix=Choix->Next,Indice_selectionne--) + ; + Fenetre_Attribut2=Choix->Numero; + return Bouton->Numero; + } + return 0; +} // --- Renvoie le numéro du bouton clicke (-1:hors de la fenêtre, 0:aucun) --- short Fenetre_Numero_bouton_clicke(void) @@ -2023,6 +2176,7 @@ short Fenetre_Numero_bouton_clicke(void) struct Fenetre_Bouton_palette * Temp2; struct Fenetre_Bouton_scroller * Temp3; struct Fenetre_Bouton_special * Temp4; + struct Fenetre_Bouton_dropdown * Temp5; //long Hauteur_Curseur_jauge; long Hauteur_maxi_jauge; @@ -2200,6 +2354,13 @@ short Fenetre_Numero_bouton_clicke(void) return Temp4->Numero; } + // Test du click sur une dropdown + for (Temp5=Fenetre_Liste_boutons_dropdown; Temp5; Temp5=Temp5->Next) + { + if (Fenetre_click_dans_zone(Temp5->Pos_X,Temp5->Pos_Y,Temp5->Pos_X+Temp5->Largeur-1,Temp5->Pos_Y+Temp5->Hauteur-1)) + return Fenetre_Dropdown_click(Temp5); + } + return 0; } diff --git a/moteur.h b/moteur.h index 8306ffc2..e97a2114 100644 --- a/moteur.h +++ b/moteur.h @@ -65,6 +65,8 @@ struct Fenetre_Bouton_scroller * Fenetre_Definir_bouton_scroller(word Pos_X, wor word Position_initiale); struct Fenetre_Bouton_special * Fenetre_Definir_bouton_special(word Pos_X,word Pos_Y,word Largeur,word Hauteur); struct Fenetre_Bouton_special * Fenetre_Definir_bouton_saisie(word Pos_X,word Pos_Y,word Largeur_en_caracteres); +struct Fenetre_Bouton_dropdown * Fenetre_Definir_bouton_dropdown(word Pos_X,word Pos_Y,word Largeur,word Hauteur,char *Libelle,byte Affiche_choix); +void Fenetre_Dropdown_choix(struct Fenetre_Bouton_dropdown * Dropdown, word Numero, const char *Libelle); byte Fenetre_click_dans_zone(short Debut_X,short Debut_Y,short Fin_X,short Fin_Y); short Attendre_click_dans_palette(struct Fenetre_Bouton_palette * Enreg); diff --git a/pxdouble.c b/pxdouble.c index 73e5dbb8..5bdea0e5 100644 --- a/pxdouble.c +++ b/pxdouble.c @@ -27,6 +27,7 @@ #include "global.h" #include "sdlscreen.h" #include "divers.h" +#include "pxwide.h" // for Afficher_une_ligne_transparente_a_l_ecran_Wide() #define ZOOMX 2 #define ZOOMY 2 diff --git a/pxwide.h b/pxwide.h index f908b647..bb68c622 100644 --- a/pxwide.h +++ b/pxwide.h @@ -42,3 +42,4 @@ void Affiche_brosse_Wide (byte * B, word Pos_X,word Pos_Y,word Decalage_X,word Decalage_Y,word Largeur,word Hauteur,byte Couleur_de_transparence,word Largeur_brosse); void Afficher_une_ligne_ecran_fast_Wide (word Pos_X,word Pos_Y,word Largeur,byte * Ligne); + void Afficher_une_ligne_transparente_a_l_ecran_Wide(word Pos_X,word Pos_Y,word Largeur,byte* Ligne,byte Couleur_transparence); diff --git a/struct.h b/struct.h index bd8b45a2..b952b003 100644 --- a/struct.h +++ b/struct.h @@ -109,6 +109,25 @@ struct Fenetre_Bouton_special struct Fenetre_Bouton_special * Next; }; +struct Bouton_dropdown_choix +{ + short Numero; + const char * Libelle; + struct Bouton_dropdown_choix * Next; +}; + +struct Fenetre_Bouton_dropdown +{ + short Numero; + word Pos_X; + word Pos_Y; + word Largeur; + word Hauteur; + byte AfficheChoix; + struct Bouton_dropdown_choix * Premier_choix; + struct Fenetre_Bouton_dropdown * Next; +}; + struct T_Drive { diff --git a/windows.c b/windows.c index 27da416c..494647ea 100644 --- a/windows.c +++ b/windows.c @@ -381,7 +381,7 @@ void Afficher_menu(void) // -- Afficher une chaîne n'importe où à l'écran -- -void Print_general(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur_fond) +void Print_general(short X,short Y,const char * Chaine,byte Couleur_texte,byte Couleur_fond) { word Indice; int Pos_X; @@ -411,7 +411,7 @@ void Print_general(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur // -- Afficher un caractère dans une fenêtre -- -void Print_char_dans_fenetre(short Pos_X,short Pos_Y,unsigned char Caractere,byte Couleur_texte,byte Couleur_fond) +void Print_char_dans_fenetre(short Pos_X,short Pos_Y,const unsigned char Caractere,byte Couleur_texte,byte Couleur_fond) { short X,Y; byte *Carac; @@ -429,7 +429,7 @@ void Print_char_dans_fenetre(short Pos_X,short Pos_Y,unsigned char Caractere,byt // -- Afficher un caractère sans fond dans une fenêtre -- -void Print_char_transparent_dans_fenetre(short Pos_X,short Pos_Y,unsigned char Caractere,byte Couleur) +void Print_char_transparent_dans_fenetre(short Pos_X,short Pos_Y,const unsigned char Caractere,byte Couleur) { short X,Y; byte *Carac; @@ -464,7 +464,7 @@ void Print_dans_fenetre_limite(short X,short Y,const char * Chaine,byte Taille,b // -- Afficher une chaîne dans une fenêtre -- -void Print_dans_fenetre(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur_fond) +void Print_dans_fenetre(short X,short Y,const char * Chaine,byte Couleur_texte,byte Couleur_fond) { Print_general((X*Menu_Facteur_X)+Fenetre_Pos_X, (Y*Menu_Facteur_Y)+Fenetre_Pos_Y, @@ -474,7 +474,7 @@ void Print_dans_fenetre(short X,short Y,char * Chaine,byte Couleur_texte,byte Co // -- Afficher une chaîne dans le menu -- -void Print_dans_menu(char * Chaine, short Position) +void Print_dans_menu(const char * Chaine, short Position) { Print_general((18+(Position<<3))*Menu_Facteur_X,Menu_Ordonnee_Texte,Chaine,CM_Noir,CM_Clair); UpdateRect((18+(Position<<3))*Menu_Facteur_X,Menu_Ordonnee_Texte,strlen(Chaine)*8*Menu_Facteur_X,8*Menu_Facteur_Y); @@ -541,7 +541,7 @@ void Print_nom_fichier(void) // Fonction d'affichage d'une chaine numérique avec une fonte très fine // Spécialisée pour les compteurs RGB -void Print_compteur(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur_fond) +void Print_compteur(short X,short Y,const char * Chaine,byte Couleur_texte,byte Couleur_fond) { // Macros pour écrire des litteraux binaires. // Ex: Ob(11110000) == 0xF0 diff --git a/windows.h b/windows.h index 4c1a194b..2de1ff04 100644 --- a/windows.h +++ b/windows.h @@ -47,15 +47,15 @@ int Couleur_palette(void); word Palette_Cells_X(void); word Palette_Cells_Y(void); -void Print_general(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur_fond); -void Print_dans_fenetre(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur_fond); +void Print_general(short X,short Y,const char * Chaine,byte Couleur_texte,byte Couleur_fond); +void Print_dans_fenetre(short X,short Y,const char * Chaine,byte Couleur_texte,byte Couleur_fond); void Print_dans_fenetre_limite(short X,short Y,const char * Chaine,byte Taille,byte Couleur_texte,byte Couleur_fond); -void Print_char_dans_fenetre(short Pos_X,short Pos_Y,unsigned char Caractere,byte Couleur_texte,byte Couleur_fond); -void Print_char_transparent_dans_fenetre(short Pos_X,short Pos_Y,unsigned char Caractere,byte Couleur); -void Print_dans_menu(char * Chaine, short Position); +void Print_char_dans_fenetre(short Pos_X,short Pos_Y,const unsigned char Caractere,byte Couleur_texte,byte Couleur_fond); +void Print_char_transparent_dans_fenetre(short Pos_X,short Pos_Y,const unsigned char Caractere,byte Couleur); +void Print_dans_menu(const char * Chaine, short Position); void Print_coordonnees(void); void Print_nom_fichier(void); -void Print_compteur(short X,short Y,char * Chaine,byte Couleur_texte,byte Couleur_fond); +void Print_compteur(short X,short Y,const char * Chaine,byte Couleur_texte,byte Couleur_fond); byte Demande_de_confirmation(char * Message); void Warning_message(char * Message);