int do_logical_ChannelsMenuSelection(int chx, int chy)
{

//LOGIQUE
//if(window_focus_id==0 && index_over_A_window==0 && index_over_faderspace==0 && mouse_button==1 && mouse_released==0)
if(window_focus_id==0 && index_over_faderspace==0 && mouse_button==1 && mouse_released==0)
{
if( mouse_y>chy+1 && mouse_y<chy+1+18 && mouse_x>chx+70 && mouse_x<chx+70+60 )
 {
 if(Midi_Faders_Affectation_Type!=0)
{
  attribute_midi_solo_affectation(1644,Midi_Faders_Affectation_Mode);
}
else
{
 ClassicalChannelView=toggle(ClassicalChannelView);
}
 mouse_released=1;
 }
for(int lv=0;lv<2;lv++)
{
for(int i=0;i<8;i++)
{
if(mouse_x>chx+140+(i*15) && mouse_x<chx+140+(i*15)+10 && mouse_y>chy+1+(15*lv) && mouse_y<chy+1+(15*lv)+10)
{
if(Midi_Faders_Affectation_Type!=0)
{
  attribute_midi_to_control(1628+i+(lv*8),Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);
}
else
{
if(index_do_dock==0 && index_do_modify==0 && index_main_clear==0)
{
if(ClassicalChannelView==1){ClassicalChannelView=0;if(Channel_View_MODE[i+(lv*8)]==0){Channel_View_MODE[i+(lv*8)]=1;}}
else
{
Channel_View_MODE[i+(lv*8)]=toggle(Channel_View_MODE[i+(lv*8)]);
ClassicalChannelView=0;
}
}
else if(index_do_dock==1 && i+(lv*8)!=0)//=vue patch
{
channel_view_is=i+(lv*8);
index_ask_record_selection_of_view=i+(lv*8);
index_ask_confirm=1;
}
else if(index_do_modify==1 && i+(lv*8)!=0)//=vue patch
{
channel_view_is=i+(lv*8);

index_ask_modify_selection_of_view=1;
index_ask_confirm=1;
}
else if(index_main_clear==1 && i+(lv*8)!=0)//=vue patch
{
channel_view_is=i+(lv*8);
index_ask_confirm=1;
index_ask_clear_selection_of_view=1;
}
}
mouse_released=1;
}
}
}
command_button_logical(chx+270,chy+1,index_blind,"Blind","Shift-F10",754,110);
command_button_logical(chx+340,chy+1,index_direct_chan,"Direct CH.","",1333,111);
command_button_logical(chx+410,chy+1,index_inspekt,"View","",1334,112);// int x, inty ,bool state, char *textedesc, int midiaffectation
command_button_logical(chx+480,chy+1,index_do_hipass,"HiPass","",1542,113);// int x, inty ,bool state, char *textedesc, int midiaffectation
command_button_logical(chx+550,chy+1,index_do_fgroup,"FGroup","",1592,114);// int x, inty ,bool state, char *textedesc, int midiaffectation

command_button_logical(chx+620,chy+1,Midi_Faders_Affectation_Type,"MidiAffect","",1625,106);// int x, inty ,bool state, char *textedesc, int midiaffectation
command_button_logical(chx+690,chy+1,index_midi_mute,"MidiMute","",1277,107);// int x, inty ,bool state, char *textedesc, int midiaffectation
command_button_logical(chx+760,chy+1,index_global_midi_send_on_faders,"M.Out Fad.","",1593,109);// int x, inty ,bool state, char *textedesc, int midiaffectation

command_button_logical(chx+830,chy+1,index_do_dock,"STORE","F1",743,102);// int x, inty ,bool state, char *textedesc, int midiaffectation
command_button_logical(chx+900,chy+1,index_do_modify,"MODIFY","F2",744,103);
command_button_logical(chx+970,chy+1,index_do_report,"REPORT","F3",745,104);
command_button_logical(chx+1040,chy+1,index_main_clear,"CLEAR","F4",746,105);
command_button_logical(chx+1110,chy+1,index_show_main_menu,"MENUS","RIGHT CLICK",1626,108);
}
//fin windows focus
return(0);
}
int do_logical_Menus( int xmenu, int ymenu)
{
if(window_focus_id==W_MAINMENU)
{
//AUTOCLOSE
if(mouse_x> xmenu+330 && mouse_x< xmenu+360 && mouse_y>ymenu+8  && mouse_y<ymenu+23 && mouse_button==1 && mouse_released==0)
{
index_text_auto_close=toggle(index_text_auto_close);
mouse_released=1;
}


int IDmidi=0; int IDcommand=0;
char nom_commande[24];
char raccourci_commande[24];
bool stae=0;
for(int cl=0;cl<5;cl++)
{
switch(cl)
{
case 0://sequenciel window
IDmidi=751;
IDcommand=cl;
sprintf(nom_commande,"CueList");
sprintf(raccourci_commande,"F9");
stae=index_window_sequentiel;
break;
case 1://time
IDmidi=748;
IDcommand=cl;
sprintf(nom_commande,"Time");
sprintf(raccourci_commande,"F6");
stae=index_time;
break;
case 2://banger
IDmidi=753;
IDcommand=cl;
sprintf(nom_commande,"Banger");
sprintf(raccourci_commande,"F11");
stae=index_show_banger_window;
break;
case 3://wizard
IDmidi=1329;
IDcommand=cl;
sprintf(nom_commande,"Wizard");
sprintf(raccourci_commande,"-");
stae= index_show_wizard_window;
break;
case 4://save
IDmidi=1330;
IDcommand=cl;
sprintf(nom_commande,"Save");
sprintf(raccourci_commande,"");
stae=index_menu_save;
break;
default:
break;
}
 command_button_logical(xmenu+10,ymenu+50+(cl*25),stae,nom_commande,raccourci_commande,IDmidi,IDcommand);// int x, inty ,bool state, char *textedesc, int midiaffectation
}



//2ème colonne Circuit relatif
for(int cl=0;cl<6;cl++)
{
switch(cl)
{
case 0:
IDmidi=1331;
IDcommand=cl+10;
sprintf(nom_commande,"Patch");
sprintf(raccourci_commande,"Shift-P");
stae=index_patch_window;
break;
case 1:
IDmidi=1332;
IDcommand=cl+10;
sprintf(nom_commande,"List");
sprintf(raccourci_commande,"");
stae=index_list_projecteurs;
break;
case 2:
IDmidi=1594;
IDcommand=cl+10;
sprintf(nom_commande,"Light Plot");
sprintf(raccourci_commande,"");
stae=index_plot_window;
break;
case 3:
IDmidi=1335;
IDcommand=cl+10;
sprintf(nom_commande,"Freeze");
sprintf(raccourci_commande,"");
stae=index_do_freeze;
break;
case 4:
IDmidi=1541;
IDcommand=cl+10;
sprintf(nom_commande,"Exclude");
sprintf(raccourci_commande,"");
stae=index_do_exclude;
break;
case 5://my window
IDmidi=2047; // c est la derniere commande midi, a changer et  définir voir tableau affectations midi
IDcommand=cl+10;
sprintf(nom_commande,"MY WINDOW");
sprintf(raccourci_commande,"");
stae= index_my_window;
break;
default:
break;
}
command_button_logical(xmenu+80,ymenu+50+(cl*25),stae,nom_commande,raccourci_commande,IDmidi,IDcommand);// int x, inty ,bool state, char *textedesc, int midiaffectation
}


//3ème colonne grands blocs
for(int cl=0;cl<5;cl++)
{
switch(cl)
{
case 0:
IDmidi=752;
IDcommand=cl+20;
sprintf(nom_commande,"Faders");
sprintf(raccourci_commande,"F10");
stae=index_show_faders;
break;
case 1:
IDmidi=1336;
IDcommand=cl+20;
sprintf(nom_commande,"MiniFaders");
sprintf(raccourci_commande,"Shift-F10");
stae=index_show_minifaders;
break;
case 2:
IDmidi=749;
IDcommand=cl+20;
sprintf(nom_commande,"Trichromy");
sprintf(raccourci_commande,"F7");
stae=index_trichro_window;
break;
case 3:
IDmidi=1337;
IDcommand=cl+20;
sprintf(nom_commande,"Chasers");
sprintf(raccourci_commande,"Shift-C");
stae=index_window_chasers;
break;
case 4:
IDmidi=1340;
IDcommand=cl+20;
sprintf(nom_commande,"GridPl.");
sprintf(raccourci_commande,"");
stae=index_grider_window;
break;

default:
break;
}
command_button_logical(xmenu+150,ymenu+50+(cl*25),stae,nom_commande,raccourci_commande,IDmidi,IDcommand);// int x, inty ,bool state, char *textedesc, int midiaffectation
}



//4ème colonne grands blocs
for(int cl=0;cl<6;cl++)
{
switch(cl)
{
case 0:
IDmidi=750;
IDcommand=cl+30;
sprintf(nom_commande,"Track.Vid.");
sprintf(raccourci_commande,"F8");
stae=index_video_window;
break;
case 1:
IDmidi=1339;
IDcommand=cl+30;
sprintf(nom_commande,"Mover");
sprintf(raccourci_commande,"");
stae=index_show_mover_window;
break;
case 2:
IDmidi=1662;
IDcommand=cl+30;
sprintf(nom_commande,"ECHO");
sprintf(raccourci_commande,"");
stae=index_show_echo_window;
break;
case 3:
IDmidi=756;
IDcommand=cl+30;
sprintf(nom_commande,"AudioPl.");
sprintf(raccourci_commande,"Ctrl-A");
stae=index_show_audio_window;
break;
case 4:
IDmidi=747;
IDcommand=cl+30;
sprintf(nom_commande,"Name");
sprintf(raccourci_commande,"F5");
stae=index_type;
break;
case 5:
IDmidi=1659;
IDcommand=cl+30;
sprintf(nom_commande,"Draw");
sprintf(raccourci_commande,"");
break;
default:
break;
}
command_button_logical(xmenu+220,ymenu+50+(cl*25),stae,nom_commande,raccourci_commande,IDmidi,IDcommand);// int x, inty ,bool state, char *textedesc, int midiaffectation
}



//5ème colonne grands blocs
for(int cl=0;cl<5;cl++)
{
switch(cl)
{
case 0:
IDmidi=755;
IDcommand=cl+40;
sprintf(nom_commande,"CFG-Menu");
sprintf(raccourci_commande,"Shift-F11");
stae=index_show_config_window;
break;
case 1:
IDmidi=1341;
IDcommand=cl+40;
sprintf(nom_commande,"iCat Builder");
sprintf(raccourci_commande,"");
stae=index_window_gui_iCat;
break;
case 2:
IDmidi=1338;
IDcommand=cl+40;
sprintf(nom_commande,"N-Pad");
sprintf(raccourci_commande,"P");
stae=index_visual_pad;
break;
case 3:
IDmidi=1342;
IDcommand=cl+40;
sprintf(nom_commande,"Help");
sprintf(raccourci_commande,"");
stae=index_call_help;
break;
case 4:
IDmidi=757;
IDcommand=cl+40;
sprintf(nom_commande,"QUIT");
sprintf(raccourci_commande,"CTRL-F12");
stae=index_do_quit_with_save;
break;
default:
break;
}
command_button_logical(xmenu+290,ymenu+50+(cl*25),stae,nom_commande,raccourci_commande,IDmidi,IDcommand);// int x, inty ,bool state, char *textedesc, int midiaffectation
}
//fin condition focus + souris
}
 return(0);
}