From e9bc7f35c4eb8b5ac19673e7e6ae2179df9fc489 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Fri, 27 Feb 2009 23:40:56 +0000 Subject: [PATCH] Bookmarks: '...' now disappears when Renaming, Clear asks for confirmation, empty bookmarks display the dropdown on both mouse buttons and their only itemis "Set". git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@662 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- boutons.c | 13 ++++++++----- files.c | 17 +++++++++++++++++ moteur.c | 33 ++++++++++++++++----------------- moteur.h | 2 +- 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/boutons.c b/boutons.c index 8ee7f5d7..afa64db1 100644 --- a/boutons.c +++ b/boutons.c @@ -2545,9 +2545,6 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) Dropdown_bookmark[Temp]= Fenetre_Definir_bouton_dropdown(126+(88+1)*(Temp%2),17+(Temp/2)*12,88,11,56,"",0,0,1,A_DROITE); // 10-13 Fenetre_Afficher_sprite_drive(Dropdown_bookmark[Temp]->Pos_X+3,Dropdown_bookmark[Temp]->Pos_Y+2,5); - Fenetre_Dropdown_choix(Dropdown_bookmark[Temp],0,"Set"); - Fenetre_Dropdown_choix(Dropdown_bookmark[Temp],1,"Rename"); - Fenetre_Dropdown_choix(Dropdown_bookmark[Temp],2,"Clear"); Afficher_bookmark(Dropdown_bookmark[Temp],Temp); } // On prend bien soin de passer dans le répertoire courant (le bon qui faut! Oui madame!) @@ -2873,14 +2870,20 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) case 1: // Rename if (Config.Bookmark_directory[Bouton_clicke-10]) { - Readline_ex(Dropdown_bookmark[Bouton_clicke-10]->Pos_X+3+10,Dropdown_bookmark[Bouton_clicke-10]->Pos_Y+2,Config.Bookmark_label[Bouton_clicke-10],8,8,0); + // On enlève les "..." avant l'édition + char Bookmark_label[8+1]; + strcpy(Bookmark_label, Config.Bookmark_label[Bouton_clicke-10]); + if (Bookmark_label[7]==CARACTERE_SUSPENSION) + Bookmark_label[7]='\0'; + if (Readline_ex(Dropdown_bookmark[Bouton_clicke-10]->Pos_X+3+10,Dropdown_bookmark[Bouton_clicke-10]->Pos_Y+2,Bookmark_label,8,8,0)) + strcpy(Config.Bookmark_label[Bouton_clicke-10],Bookmark_label); Afficher_bookmark(Dropdown_bookmark[Bouton_clicke-10],Bouton_clicke-10); Afficher_curseur(); } break; case 2: // Clear - if (Config.Bookmark_directory[Bouton_clicke-10]) + if (Config.Bookmark_directory[Bouton_clicke-10] && Demande_de_confirmation("Erase bookmark ?")) { free(Config.Bookmark_directory[Bouton_clicke-10]); Config.Bookmark_directory[Bouton_clicke-10]=NULL; diff --git a/files.c b/files.c index 8c59c8ec..854f96a7 100644 --- a/files.c +++ b/files.c @@ -54,6 +54,7 @@ #include "windows.h" #include "loadsave.h" #include "mountlist.h" +#include "moteur.h" #define COULEUR_FICHIER_NORMAL CM_Clair // Couleur du texte pour une ligne de fichier non sélectionné #define COULEUR_REPERTOIRE_NORMAL CM_Fonce // Couleur du texte pour une ligne de répertoire non sélectionné @@ -718,13 +719,29 @@ void Afficher_bookmark(struct Fenetre_Bouton_dropdown * Bouton, int Numero_bookm if (Config.Bookmark_directory[Numero_bookmark]) { int Taille; + // Libellé Print_dans_fenetre_limite(Bouton->Pos_X+3+10,Bouton->Pos_Y+2,Config.Bookmark_label[Numero_bookmark],8,CM_Noir,CM_Clair); Taille=strlen(Config.Bookmark_label[Numero_bookmark]); if (Taille<8) Block(Fenetre_Pos_X+(Menu_Facteur_X*(Bouton->Pos_X+3+10+Taille*8)),Fenetre_Pos_Y+(Menu_Facteur_Y*(Bouton->Pos_Y+2)),Menu_Facteur_X*(8-Taille)*8,Menu_Facteur_Y*8,CM_Clair); + // Menu apparait sur clic droit + Bouton->Bouton_actif=A_DROITE; + // Choix actifs + Fenetre_Dropdown_vider_choix(Bouton); + Fenetre_Dropdown_choix(Bouton,0,"Set"); + Fenetre_Dropdown_choix(Bouton,1,"Rename"); + Fenetre_Dropdown_choix(Bouton,2,"Clear"); } else + { + // Libellé Print_dans_fenetre(Bouton->Pos_X+3+10,Bouton->Pos_Y+2,"--------",CM_Fonce,CM_Clair); + // Menu apparait sur clic droit ou gauche + Bouton->Bouton_actif=A_DROITE|A_GAUCHE; + // Choix actifs + Fenetre_Dropdown_vider_choix(Bouton); + Fenetre_Dropdown_choix(Bouton,0,"Set"); + } } diff --git a/moteur.c b/moteur.c index 2fc16e5d..88b97652 100644 --- a/moteur.c +++ b/moteur.c @@ -39,6 +39,8 @@ #include "windows.h" #include "brush.h" #include "input.h" +#include "moteur.h" + // we need this as global short Old_MX = -1; @@ -1160,7 +1162,6 @@ void Fermer_fenetre(void) struct Fenetre_Bouton_scroller * Temp3; struct Fenetre_Bouton_special * Temp4; struct Fenetre_Bouton_dropdown * Temp5; - struct Bouton_dropdown_choix * Temp6; Effacer_curseur(); @@ -1191,15 +1192,7 @@ void Fermer_fenetre(void) while (Fenetre_Liste_boutons_dropdown) { Temp5=Fenetre_Liste_boutons_dropdown->Next; - - // Il faut libérer la liste des boutons qui sont dans le dropdown - while (Fenetre_Liste_boutons_dropdown->Premier_choix) - { - Temp6 = Fenetre_Liste_boutons_dropdown->Premier_choix->Next; - free(Fenetre_Liste_boutons_dropdown->Premier_choix); - Fenetre_Liste_boutons_dropdown->Premier_choix = Temp6; - } - + Fenetre_Dropdown_vider_choix(Fenetre_Liste_boutons_dropdown); free(Fenetre_Liste_boutons_dropdown); Fenetre_Liste_boutons_dropdown=Temp5; } @@ -1637,6 +1630,18 @@ void Fenetre_Dropdown_choix(struct Fenetre_Bouton_dropdown * Dropdown, word Nume } } +// ------------- Suppression de tous les choix d'une dropdown --------- +void Fenetre_Dropdown_vider_choix(struct Fenetre_Bouton_dropdown * Dropdown) +{ + struct Bouton_dropdown_choix * Choix_suivant; + while (Dropdown->Premier_choix) + { + Choix_suivant=Dropdown->Premier_choix->Next; + free(Dropdown->Premier_choix); + Dropdown->Premier_choix=Choix_suivant; + } +} + //----------------------- Ouverture d'un pop-up ----------------------- void Ouvrir_popup(word Pos_X, word Pos_Y, word Largeur,word Hauteur) @@ -1730,13 +1735,7 @@ void Fermer_popup(void) } 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; - } + Fenetre_Dropdown_vider_choix(Fenetre_Liste_boutons_dropdown); Temp5=Fenetre_Liste_boutons_dropdown->Next; free(Fenetre_Liste_boutons_dropdown); Fenetre_Liste_boutons_dropdown=Temp5; diff --git a/moteur.h b/moteur.h index a63d8548..dff70f6a 100644 --- a/moteur.h +++ b/moteur.h @@ -67,7 +67,7 @@ struct Fenetre_Bouton_special * Fenetre_Definir_bouton_special(word Pos_X,word P 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,word Largeur_choix,char *Libelle,byte Affiche_choix,byte Affiche_centre,byte Affiche_fleche,byte Bouton_actif); void Fenetre_Dropdown_choix(struct Fenetre_Bouton_dropdown * Dropdown, word Numero, const char *Libelle); - +void Fenetre_Dropdown_vider_choix(struct Fenetre_Bouton_dropdown * Dropdown); 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); void Recuperer_couleur_derriere_fenetre(byte * Couleur, byte * Click);