int key_minus_ch()
{
if ((key_shifts & KB_SHIFT_FLAG  || index_false_shift==1) && index_patch_window==1)
{
iddim=atol(numeric);

if(iddim>0 && iddim<513)
{
Dimmers_selected[iddim]=0;
strcat(string_monitor_patch,"D.");
strncat(string_monitor_patch,numeric,numeric_postext);
strcat(string_monitor_patch,"-");
numeric_postext=0;
reset_numeric_entry();
set_patch_scroll(iddim);
}
}
else{
if(index_type==0)
{
idchannel=atol(numeric);
if(idchannel>0 && idchannel<513)
{
switch (ClassicalChannelView)
{
case 0:
if(check_presence_of_a_channel_in_views(idchannel)==1)
{
Selected_Channel[idchannel]=0;
//last_ch_selected=idchannel;
numeric_postext=0;
reset_numeric_entry();
set_channel_scroll(last_ch_selected);
substract_channel_selection_to_layers_plot();
}
else if(check_presence_of_a_channel_in_views(idchannel)==0)
{
sprintf(string_Last_Order,"This Channel is not in an activ View");
numeric_postext=0;
reset_numeric_entry();
}
break;
case 1:
Selected_Channel[idchannel]=0;
//last_ch_selected=idchannel;
numeric_postext=0;
reset_numeric_entry();
set_channel_scroll(last_ch_selected);
substract_channel_selection_to_layers_plot();
break;
}


}
}
}
 return(0);
}
int call_mem_onpreset()
{

int mem_to_call=(int)(atof(numeric)*10.0001);
if ( mem_to_call>10000)
{sprintf(string_Last_Order,"a Mem can't be > to 1000");}
else
{
if(MemoiresExistantes[mem_to_call]==0)
{
sprintf(string_Last_Order,"Mem %d.%d doesn't exist", mem_to_call/10,mem_to_call%10);
}
else if (MemoiresExistantes[mem_to_call]==1)
{
sprintf(string_Last_Order,"Loaded %d.%d on preset", mem_to_call/10,mem_to_call%10);
position_preset=mem_to_call;
refresh_mem_onpreset(position_preset);
ratio_X1X2_together=ratio_cross_manuel[mem_to_call];
}
}
reset_numeric_entry();
someone_changed_in_sequences=1;//icat

return(0);
}
int call_mem_onstage()
{
int mem_to_call=(int)(atof(numeric)*10.0001);
if (mem_to_call>10000)
{sprintf(string_Last_Order,"a Mem can't be > to 1000");}
else
{
if(MemoiresExistantes[mem_to_call]==0)
{
sprintf(string_Last_Order,"Mem %d.%d doesn't exist", mem_to_call/10,mem_to_call%10);
}
if (MemoiresExistantes[mem_to_call]==1 && mem_to_call!=0)//eviter cherger mem 0 en clickant vide
{
sprintf(string_Last_Order,"Loaded %d.%d on Stage", mem_to_call/10,mem_to_call%10);
position_onstage=mem_to_call;
refresh_mem_onstage(position_onstage);
detect_mem_before_one();
detect_mem_preset();
refresh_mem_onpreset(position_preset);
}
if (MemoiresExistantes[mem_to_call]==1 && mem_to_call==0)//eviter cherger mem 0 en clickant vide
{
sprintf(string_Last_Order,"Mem 0.0 can't be loaded on Stage");
}
}
reset_numeric_entry();
someone_changed_in_sequences=1;//icat
return(0);
}
int Box_artnet_udpport(int macx, int macy)
{
   petitchiffre.Print("Art-Net UDP Ports",macx-5,macy-20);
   petitpetitchiffre.Print("- default 6454 -",macx+10,macy);
   petitpetitchiffre.Print("Out:",macx-5,macy+20);
   petitpetitchiffre.Print("In:",macx+70,macy+20);
   Rect UDPOut(Vec2D(macx+20,macy+5),Vec2D(45,25));
   UDPOut.SetRoundness(7.5);
   UDPOut.Draw(CouleurFond.WithAlpha(0.4));
   Rect UDPIn(Vec2D(macx+95,macy+5),Vec2D(45,25));
   UDPIn.SetRoundness(7.5);
   UDPIn.Draw(CouleurFond.WithAlpha(0.4));
   petitpetitchiffre.Print(ol::ToString(clientport_artnet),macx+25,macy+20);
   petitpetitchiffre.Print(ol::ToString(serveurport_artnet),macx+100,macy+20);


   if(mouse_y>macy+5 && mouse_y<macy+5+25 && window_focus_id==920)
   {
   if(mouse_x>macx+20 && mouse_x<macx+20+45)
   {
   UDPOut.DrawOutline(CouleurLevel);
   if(mouse_button==1 && mouse_released==0)
   {
   clientport_artnet=atoi(numeric);
   reset_numeric_entry();
   index_re_init_client_artnet=1;
   index_ask_confirm=1;
   mouse_released=1;
   }
   }
   else    if(mouse_x>macx+95 && mouse_x<macx+95+45)
   {
   UDPIn.DrawOutline(CouleurLevel);
   if(mouse_button==1 && mouse_released==0)
   {
   serveurport_artnet=atoi(numeric);
   reset_numeric_entry();
   index_re_init_serveur_artnet=1;
   index_ask_confirm=1;
   mouse_released=1;
   }
   }
   }

return(0);
}
int do_keyboard_conf(int cfgnetw_X, int cfgnetw_Y)//ancienne version
{

petitchiffre.Print("Keyboard Mapping: " ,cfgnetw_X, cfgnetw_Y);
Line(Vec2D(cfgnetw_X,cfgnetw_Y+5),Vec2D(cfgnetw_X+90,cfgnetw_Y+5)).Draw(CouleurLigne);
sprintf(string_clavier_is,"Asc= %d Allg= %d KEY= %s ",scan_ascii_is,scan_allegro_key_is,string_key_id);
petitchiffre.Print(string_clavier_is,cfgnetw_X,cfgnetw_Y+20);
char str_iskeyfunct[25];
for (int oi=0;oi<nbre_key_persos;oi++)
{
Rect keyParam(Vec2D(cfgnetw_X+60,cfgnetw_Y+25+(oi*30)),Vec2D(50,25));
keyParam.SetRoundness(7.5);
keyParam.SetLineWidth(epaisseur_ligne_fader);
keyParam.Draw(CouleurFond.WithAlpha(0.5));
switch(oi)
{
case 0:
sprintf(str_iskeyfunct,"AT LEVEL");
break;
case 1:
sprintf(str_iskeyfunct,"CH +");
break;
case 2:
sprintf(str_iskeyfunct,"CH -");
break;
case 3:
sprintf(str_iskeyfunct,"THRU");
break;
case 4:
sprintf(str_iskeyfunct,"CLEAR");
break;
}
if(mouse_x>cfgnetw_X+60 && mouse_x<cfgnetw_X+60+50 && mouse_y>cfgnetw_Y+25+(oi*30) && mouse_y<cfgnetw_Y+25+(oi*30)+25)
{
keyParam.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
int tmp_valAsc=atoi(numeric);
if((tmp_valAsc>0 && tmp_valAsc<255)|| tmp_valAsc==999)//999 pour eviter de bloquer les commandes en 0 ascii , genre touches de fonctions
{
mapping_temporaire[oi]=tmp_valAsc;
}
reset_numeric_entry();
mouse_released=1;
}
}
petitpetitchiffre.Print(str_iskeyfunct,cfgnetw_X,cfgnetw_Y+40+(oi*30));
petitpetitchiffre.Print(ol::ToString(mapping_temporaire[oi]),cfgnetw_X+75,cfgnetw_Y+40+(oi*30));
}

 return(0);
}
int DoDock(int fad, int dk)
{
 ClearDock(fad,dk);

 if(numeric_postext==0)//si pas de chaine de caracteres tapés
 {
 DockTypeIs[fad][dk]=0;//le type est 0, circuits normaux
 if(index_blind==0)
 {
 for (int dc=1;dc<514;dc++)
 {
 FaderDockContains[fad][dk][dc]=0;//nettoyage du fader
 FaderDockContains[fad][dk][dc]=bufferSequenciel[dc];
 //rajout
 bufferSaisie[dc]=0;
 Selected_Channel[dc]=0;
 }
 index_do_dock=0;
 Unselect_other_docks(fad,dk);
 DockIsSelected[fad][dk]=1;
 Fader[fad]=255;
 sprintf(string_Last_Order,">>n Stage Stored in F %d Dock %d",fad+1, dk);
 }

 else if(index_blind==1)
 {
 for (int dc=1;dc<514;dc++)
 {
 FaderDockContains[fad][dk][dc]=bufferBlind[dc];
 }
 index_do_dock=0;
 sprintf(string_Last_Order,">>n Preset Stored in F %d Dock %d",fad+1, dk);
 }
 }
 else if (numeric_postext>0)
 {
 int mem_to_load_in_dock= (int)(atof(numeric)*10.0001);
 if(MemoiresExistantes[mem_to_load_in_dock]==1)
 {
 //ClearDock(fad,dk);
 DockTypeIs[fad][dk]=5;
 int mem_to_load_in_dock= (int)(atof(numeric)*10.0001);
 DockHasMem[fad][dk]=mem_to_load_in_dock;
 reset_numeric_entry();
 sprintf(string_Last_Order,">>n Stored Mem %.1f in F %d Dock %d",(float (mem_to_load_in_dock))/10,fad+1, dk);
 }
 else
 {sprintf(string_Last_Order,">>n Mem %.1f doesn't exist",(float (mem_to_load_in_dock))/10);  }

 }
 return(0);
}
int key_at_zero()
{
 if ((key_shifts & KB_SHIFT_FLAG || index_false_shift==1) && index_patch_window==1)
           {patch_clear_selected();}
 else{
           reset_numeric_entry();
           for (int ci=1;ci<514;ci++)
           {
           if(Selected_Channel[ci]==1 && index_blind==0)    {bufferSaisie[ci]=0;}
           else if(Selected_Channel[ci]==1  && index_blind==1)    {bufferBlind[ci]=0;}
           }
           sprintf(string_Last_Order,">> Selection AT ZERO");
           index_level_attribue=1;//pour déselection lors prochain circuit piqué
 }
 return(0);
}
int do_logical_TheGrid_matrix ( int xb, int yb,int sizecase, int num_grid_player)
{
int grid_selected=index_grider_selected[num_grid_player];
int gr_st_selected=index_grider_step_is[num_grid_player];

if(index_enable_edit_Grider==1 && mouse_x>=xb && mouse_x<=xb+(grider_nb_col*sizecase) && mouse_y>=yb && mouse_y<=yb+(grider_nb_row*sizecase))
{
if( mouse_released==0)
{
if(numeric_postext==0)
{
if(grid_levels[index_grider_selected[num_grid_player]][gr_st_selected][position_grid_editing]==0)
{grid_levels[grid_selected][gr_st_selected][position_grid_editing]=255;}
else if(grid_levels[grid_selected][gr_st_selected][position_grid_editing]==255
|| grid_levels[index_grider_selected[num_grid_player]][gr_st_selected][position_grid_editing]>0 )
{grid_levels[grid_selected][gr_st_selected][position_grid_editing]=0;}
}
else if(numeric_postext>0)
{
int lev_to_attr_to_grid=0;
lev_to_attr_to_grid=atoi(numeric);
switch(dmx_view)
{
case 0://pourcent
if(lev_to_attr_to_grid>0)
{
grid_levels[grid_selected][gr_st_selected][position_grid_editing]=
(int)(((float)(lev_to_attr_to_grid) *2.55) +1);// + 1 pour arrondir le pourcentage lors de la conversion % -> dmx
}
else {grid_levels[grid_selected][gr_st_selected][position_grid_editing]=0;}
break;
case 1://dmx
if(lev_to_attr_to_grid>=0 && lev_to_attr_to_grid<=255)
{
grid_levels[grid_selected][gr_st_selected][position_grid_editing]=lev_to_attr_to_grid;
}
break;
}

}
reset_numeric_entry();
mouse_released=1;
}
}

return(0);
}
int do_direct_channel(int fad,int dk)
{
if(numeric_postext>0)
{
last_ch_selected=atoi(numeric);
reset_numeric_entry();
numeric_postext=0;
}

if(last_ch_selected>0 && last_ch_selected<513)
{
ClearDock(fad,dk);
switch(multiple_direct_chan)
{
case 0:
DockTypeIs[fad][dk]=10;//direct channel mode
FaderDirectChan[fad][dk]=last_ch_selected;
//report dans dock
sprintf( DockName[fad][dk], descriptif_projecteurs[last_ch_selected]);
sprintf(string_Last_Order,">>Direct Channel x1 done");
break;
case 1:
for(int l=0;l<12;l++)
{
if(fad+l<core_user_define_nb_faders)
{
DockTypeIs[fad+l][dk]=10;//direct channel mode
FaderDirectChan[fad+l][dk]=last_ch_selected+l;
//report dans dock
sprintf( DockName[fad+l][dk], descriptif_projecteurs[last_ch_selected+l]);
}
}
sprintf(string_Last_Order,">>Direct Channel x12 done");
break;
default:
break;
}
}
else
{
sprintf(string_Last_Order,">>Direct Channel: Please select a channel !");
}
return(0);
}
int key_unselect_ch()
{
reset_numeric_entry();

//if ((key_shifts & KB_SHIFT_FLAG  || index_false_shift==1))
if(key[KEY_LSHIFT]|| index_false_shift==1)
{
             if( index_patch_window==1 && index_ask_confirm==0)
             {
             patch_unselect_all_dimmers();
             strcpy(string_monitor_patch,"");
             index_patch_affect_is_done=0;
             }
}


else
{

             for (int ci=1;ci<514;ci++)
             {Selected_Channel[ci]=0;}
             last_ch_selected=0;
             index_type=0;index_level_attribue=0;
             substract_channel_selection_to_layers_plot();


             if(index_ask_confirm==1)
             {
             reset_indexs_confirmation();
             reset_index_actions();
             substract_a_window(W_ASKCONFIRM);
             window_focus_id=previous_window_focus_id;
             add_a_window(window_focus_id);
             }
}

return(0);
}
int do_artnet_affect_config(int cfgnetw_X, int cfgnetw_Y)
{


petitchiffre.Print("ArtNet IN is :",(cfgnetw_X), (cfgnetw_Y));

ol::Rect AllowIn(ol::Vec2D((cfgnetw_X+140), cfgnetw_Y-13),ol::Vec2D(50,20));
AllowIn.SetRoundness(7.5);
AllowIn.Draw(CouleurFond.WithAlpha(0.5));

switch(allow_artnet_in)
{
case 0:
petitchiffre.Print("/Off",(cfgnetw_X+150), (cfgnetw_Y));
break;
case 1:
AllowIn.Draw(CouleurFader);
petitchiffre.Print("/On",(cfgnetw_X+155), (cfgnetw_Y));
break;
}

if(mouse_x>cfgnetw_X+140 && mouse_x<cfgnetw_X+190 && mouse_y> cfgnetw_Y-13 && mouse_y< cfgnetw_Y+7  && window_focus_id==W_CFGMENU )
{
AllowIn.DrawOutline(CouleurNiveau);
if(mouse_button==1 && mouse_released==0)
{
allow_artnet_in=toggle(allow_artnet_in);
switch(allow_artnet_in)
{
case 0:
     fermeture_serveur_artnet();
break;
case 1:
     initialisation_serveur_artnet();
break;
}
mouse_released=1;
}
}



///////////////////////////////////////////////////////////////////////////////
ol::Rect AffectToDockN(ol::Vec2D(cfgnetw_X, cfgnetw_Y+17),ol::Vec2D(100,15));
AffectToDockN.SetRoundness(4);
AffectToDockN.Draw(CouleurBlind.WithAlpha(alpha_blinker*index_do_affect_net_to_dock));
AffectToDockN.DrawOutline(CouleurLigne.WithAlpha(0.7));

petitchiffre.Print("Affect to dock",(cfgnetw_X+5), (cfgnetw_Y+27));

if(window_focus_id==W_CFGMENU && mouse_x>cfgnetw_X && mouse_x<cfgnetw_X+100 && mouse_y>cfgnetw_Y+17 && mouse_y<cfgnetw_Y+17+15 && mouse_button==1 && mouse_released==0)
{
index_do_affect_net_to_dock=toggle(index_do_affect_net_to_dock);
index_do_dock=index_do_affect_net_to_dock;
mouse_released=1;
}

ol::Rect AffectD(ol::Vec2D(cfgnetw_X+140, cfgnetw_Y+12),ol::Vec2D(50,25));
AffectD.SetRoundness(7.5);
AffectD.Draw(CouleurFond.WithAlpha(0.5));

petitchiffre.Print(ol::ToString(select_artnet_to_listen),cfgnetw_X+160, cfgnetw_Y+27);

if(window_focus_id==W_CFGMENU && mouse_x>cfgnetw_X+140 && mouse_x<cfgnetw_X+190 && mouse_y>cfgnetw_Y+25 && mouse_y<cfgnetw_Y+47 )
{
AffectD.DrawOutline(CouleurLigne.WithAlpha(0.6));
if(mouse_button==1 && mouse_released==0   )
{
int nu=atoi(numeric);
reset_numeric_entry();
numeric_postext=0;
if(nu>=0 && nu<=15)
{
select_artnet_to_listen=nu;
}
else{sprintf(string_Last_Order,"Universe must be from 0 to 15");}
}
mouse_released=1;
}


return(0);
}
int mini_faders_panel_core(int xmf, int ymf, int larg)
{

if(mouse_y>ymf && mouse_y<ymf+20 )
{

if(mouse_x>xmf+(24*larg)+10 && mouse_x<xmf+(24*larg)+30)
{
if( Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(774,1);
}
else
{
position_minifader_selected--;
if(position_minifader_selected<0){position_minifader_selected=core_user_define_nb_faders;}
refresh_minifader_state_view_core(position_minifader_selected);
mouse_released=1;
}
}

else if(mouse_x>xmf+(24*larg)+35 && mouse_x<xmf+(24*larg)+55)
{
if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(775,1);
}
else
{
position_minifader_selected++;
if(position_minifader_selected>core_user_define_nb_faders){position_minifader_selected=0;}
refresh_minifader_state_view_core(position_minifader_selected);
mouse_released=1;
}
}
}


//SELECT ALL
if(mouse_y>ymf-25 && mouse_y<ymf-5 )
{
if(mouse_x>xmf+(24*larg)+10 && mouse_x<xmf+(24*larg)+55)
{
if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(145,1);
}
else
{
for(int i=0;i<core_user_define_nb_faders;i++)
{minifaders_selected[i]=1;}
}
}
}





 //select
if(mouse_x>xmf+(24*larg)+10 && mouse_x<xmf+(24*larg)+55 )
{

if(mouse_y>ymf+25 && mouse_y<ymf+45 && mouse_released==0 )
{
if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(776,1);
mouse_released=1;
}
else
{
minifaders_selected[position_minifader_selected]=toggle(minifaders_selected[position_minifader_selected]);
mouse_released=1;
}
}

else if(mouse_y>ymf+50 && mouse_y<ymf+70 && mouse_released==0 )
{
if( Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(777,1);
 }
else
{
for(int l=0;l<core_user_define_nb_faders;l++)
{
minifaders_selected[l]=0;
}
}
mouse_released=1;
}
}

///////////////LES ACTIONS////////////////////////////////////////////////////
for(int lu=0;lu<5;lu++)
{
for(int llu=0;llu<3;llu++)
{
int numcom=(lu*3)+llu;
//mouse action:
if(mouse_x>xmf+(24*larg)+70+(lu*25) && mouse_x<xmf+(24*larg)+70+(lu*25)+20 && mouse_y>ymf+(llu*25) && mouse_y<ymf+(llu*25)+20)
{
char tmp_c[36];
switch(numcom)
{
case 0:
sprintf(tmp_c,"Flash");
break;
case 1:
sprintf(tmp_c,"Lock");
break;
case 2:
sprintf(tmp_c,"Loop");
break;
case 3:
sprintf(tmp_c,"Lfo UP");
break;
case 4:
sprintf(tmp_c,"Lfo DOWN");
break;
case 5:
sprintf(tmp_c,"Lfo SAW");
break;
case 6:
sprintf(tmp_c,"All Dock Looped");
break;
case 7:
sprintf(tmp_c,"All at 0");
break;
case 8:
sprintf(tmp_c,"Set Pos");
break;
case 9:
sprintf(tmp_c,"To Prev Dock");
break;
case 10:
sprintf(tmp_c,"To Next Dock");
break;
case 11:
sprintf(tmp_c,"Up and Down");
break;
case 12:
sprintf(tmp_c,"Sel Prev Dock");
break;
case 13:
sprintf(tmp_c,"Sel Next Dock");
break;
case 14:
sprintf(tmp_c,"Play Embedded");
break;
default:
                    strcpy(tmp_c,"");
break;
}

sprintf(string_last_midi_id,"%s is Ch: %d Pitch: %d Type: %s",tmp_c, miditable[1][778+numcom],miditable[2][778+numcom],thetypinfo);

if(numcom!=0 )// hors flash
{
if( Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(778+numcom,1);
 }

else
{
do_action_on_selected_minifaders(numcom);
mouse_released=1;
}
}


}



}
}

//les presets de sélections de faders//////////////////////////////////////////////////////////

for(int lg=0;lg<8;lg++)
{

if(mouse_x>xmf+(24*larg)+10 && mouse_x<xmf+(24*larg)+10+20 && mouse_y>ymf+90+(lg*25) && mouse_y<ymf+90+(lg*25)+20)
{

if(Midi_Faders_Affectation_Type!=0)
{
 //midi report
 switch(miditable[0][794+lg])
 {
  case 0:
  sprintf(thetypinfo,"Note");
  break;
  case 1:
  sprintf(thetypinfo,"Key On");
  break;
  case 2:
  sprintf(thetypinfo,"Key Off");
  break;
  case 4:
  sprintf(thetypinfo,"Ctrl Change");
  break;
 }
  sprintf(string_last_midi_id,"FaderPreset %d is Ch: %d Pitch: %d Type: %s",lg+1, miditable[1][794+lg],miditable[2][794+lg],thetypinfo);

 if(Midi_Faders_Affectation_Type==1)
 {attribute_midi_solo_affectation(794+lg,1);}
 else if(Midi_Faders_Affectation_Type==2)
 {
 attribute_midi_to_control(794, Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);
 }
}
else
{
if(index_do_dock==1)
{
minifader_preset_is=lg;
index_record_minifader_preset=1;
index_ask_confirm=1;
}
else if(index_main_clear==1)
{
minifader_preset_is=lg;
index_clear_minifader_preset=1;
index_ask_confirm=1;
}
else //selection souris normale
{
for(int olp=0;olp<core_user_define_nb_faders;olp++)
{minifaders_selected[olp]=minifaders_preset_selection[lg][olp];}
sprintf(string_Last_Order,"Called Fader Selection from Preset %d", lg+1);
}

}
}
}
////////////Les locks presets///////////////////////////////////////////////////

for(int lck=0;lck<8;lck++)
{

if(mouse_x>xmf+(24*larg)+35 && mouse_x<xmf+(24*larg)+35+20 && mouse_y>ymf+90+(lck*25) && mouse_y<ymf+90+(lck*25)+20)
{

if( Midi_Faders_Affectation_Type!=0)
{

     //midi report
 switch(miditable[0][605+lck])
 {
  case 0:
  sprintf(thetypinfo,"Note");
  break;
  case 1:
  sprintf(thetypinfo,"Key On");
  break;
  case 2:
  sprintf(thetypinfo,"Key Off");
  break;
  case 4:
  sprintf(thetypinfo,"Ctrl Change");
  break;
 }
  sprintf(string_last_midi_id,"Lock Preset %d is Ch: %d Pitch: %d Type: %s",lck+1, miditable[1][605+lck],miditable[2][605+lck],thetypinfo);

  if(Midi_Faders_Affectation_Type==1)
 {attribute_midi_solo_affectation(605+lck,1);}
 else if(Midi_Faders_Affectation_Type==2)
 {
 attribute_midi_to_control(605, Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);
 }
}

else
 {

 if(index_do_dock==1)
 {

 minifader_lockpreset_is=lck;
 index_record_minifader_lockpreset=1;
 index_ask_confirm=1;
 }

 else  if(index_main_clear==1)
 {

 reset_indexs_confirmation();
 lock_preset_selected_for_record=lck;
 index_do_clear_lock_preset=1;
 index_ask_confirm=1;
 sprintf(string_Last_Order,">> Lock State %d cleared",lck+1);
 }
 else
 {
 do_lock_preset(lck);
 sprintf(string_Last_Order,">> Lock State %d called ",lck+1);
 }
mouse_released=1;
}
}
}


/////////////////ALL AT 0///////////////////////////////////////////////////////
all_at_zero_panel_core((xmf+24*larg)+60,ymf+80);

midi_send_faders_button_logical((xmf+24*larg)+140,ymf-40,W_MINIFADERS);


////////////////////////////////////////////////////////////////////////////////
/////////////////////////LES 48 POTARDS/////////////////////////////////////////
int hmfd=200;//hauteur d une ligne de 24 faders
for(int cmptfader=0; cmptfader<max_faders/2; cmptfader++)
{
for(int lfad=0;lfad<2;lfad++)
{

if(cmptfader+(lfad*24)<=core_user_define_nb_faders-1)//limitation nbre faders
{

////FX MODE

if(  window_focus_id==922 && mouse_released==0 && mouse_x>xmf+(cmptfader*larg) && mouse_x<xmf+(cmptfader*larg)+larg && mouse_y>(ymf+(lfad*hmfd))-12  && mouse_y<(ymf+(lfad*hmfd))-12+5 )
{
if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_to_control(1543+cmptfader+(lfad*24), Midi_Faders_Affectation_Type,  Midi_Faders_Affectation_Mode);
}
else
{
  fader_mode_with_buffers[cmptfader+(lfad*24)]++;
 if(fader_mode_with_buffers[cmptfader+(lfad*24)]>5){fader_mode_with_buffers[cmptfader+(lfad*24)]=0;}
}
mouse_released=1;
}

///////////SELECTION SOURIS SUR  NUMEROS AU DESSUS FADERS/////////////////////////////////////////////////////////
if( mouse_x>xmf+(cmptfader*larg) && mouse_x<xmf+(cmptfader*larg)+larg && mouse_y>(ymf+(lfad*hmfd))  && mouse_y<(ymf+15+(lfad*hmfd)) )
{
position_minifader_selected=cmptfader+(lfad*24);

int dock_selected_is=detect_dock_used(position_minifader_selected);


//SELECTION
if(index_do_dock==0 && index_do_modify==0 && index_do_dock==0   && index_type==0    && index_main_clear==0 )
{
 minifaders_selected[position_minifader_selected]=toggle(minifaders_selected[position_minifader_selected]);
 if(index_inspekt==1)//affichage qui dans dock si VIEW activé
 {
 show_who_is_in_dock( position_minifader_selected,   detect_dock_used(position_minifader_selected));
 }
 mouse_released=1;
}


 //store normal
 else if(index_do_dock==1 && index_direct_chan==0   && index_affect_chaser_to_dock==0  && index_affect_time==0 && index_affect_color_to_dock==0 && index_do_affect_net_to_dock==0
 && index_affect_dmxin==0 && index_affect_video_tracking_to_dock==0 && index_affect_audio_to_dock==0 && gridplayer_to_affect_is==-1
 && index_do_fgroup==0 && index_affect_to_dock_mover==0 && index_affect_draw_to_dock==0 &&  index_affect_echo_to_dock==0)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_record_on_faders=1;
 index_ask_confirm=1;
 }

  //affect time
 else if (index_do_dock==1 && index_affect_time==1 )
 {
 show_im_recording_a_time=1;
 DoTimeToDock(position_minifader_selected,dock_selected_is);
 sprintf(string_Last_Order,">>Time affected to Master %d Dock %d", position_minifader_selected+1,dock_selected_is);
 index_affect_time=0;
 }
 //color dock
 else if(index_do_dock==1 && index_affect_color_to_dock==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_color_on_faders=1;
 index_ask_confirm=1;
 }
 //dmx to dock
 else if(index_do_dock==1 && index_affect_dmxin==1 ) // affect couleurs dans dock
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_dmx_to_dock=1;
 index_ask_confirm=1;
 }
 //artnet to dock
 else if(index_do_dock==1 && index_do_affect_net_to_dock==1 ) // affect Network IN dans dock
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_artnet_to_dock=1;
 index_ask_confirm=1;
 }
 //video to dock
 else if(index_do_dock==1 && index_affect_video_tracking_to_dock==1) // affect Network IN dans dock
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_video_to_dock=1;
 index_ask_confirm=1;
 }
 //audio to dock
 else if(index_do_dock==1 &&  index_affect_audio_to_dock==1) // affect audio controls dans dock
 {
 if(player_to_affect_to_dock>=0 && player_to_affect_to_dock<4 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_audio_to_dock=1;
 index_ask_confirm=1;
 }
 }

 //store direct CH
 else if(index_do_dock==1 && index_direct_chan==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_record_direct_ch=1;
 index_ask_confirm=1;
 }
 //store FX
 else if(index_do_dock==1 && index_affect_chaser_to_dock==1)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_fx=1;
 index_ask_confirm=1;
 }
 //store Grid
 else if(index_do_dock==1 &&  gridplayer_to_affect_is>=0 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_grid_to_fader=1;
 index_ask_confirm=1;
 }
 //store group fader
 else if(index_do_dock==1 && index_do_fgroup==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 bool index_there_is_fader_selected=0;
 for(int io=0;io<48;io++)
 {
 if(minifaders_selected[io]==1){index_there_is_fader_selected=1;break;}
 }
 if(index_there_is_fader_selected==1)
 {
 index_do_affect_fgroup=1;
 index_ask_confirm=1;
 }
 else{sprintf(string_Last_Order,"No minifaders selected");}
 }

  //Store Mover dans dock
 else if (  index_do_dock==1 && index_affect_to_dock_mover==1)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_mover=1;
 index_ask_confirm=1;
 }


 //draw
 else if(index_do_dock==1 && index_affect_draw_to_dock==1)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 draw_preset_selected_for_order=draw_preset_selected;
 index_do_draw_affect_to_dock=1;
 index_ask_confirm=1;
 mouse_released=1;
 }
  //echo
 else if(index_do_dock==1 && index_affect_echo_to_dock==1)
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_affect_echo_to_dock=1;
 index_ask_confirm=1;
 mouse_released=1;
 }

 //modify
 else if( index_do_modify==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_modify_on_faders=1;
 index_ask_confirm=1;
 }


  //report
 if( index_do_report==1 && index_type==0 && index_do_dock==0 && index_do_modify==0 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_report_on_faders=1;
 index_ask_confirm=1;
 sprintf(string_Last_Order,"Report");
 }

 //nommage de dock
 else if( index_type==1 && index_do_dock==0 && index_do_report==0 && index_do_modify==0   && numeric_postext!=0 )
 {
 for(int tt=0;tt<24;tt++)
 {
 DockName[position_minifader_selected][dock_selected_is][tt]=numeric[tt];
 }
 DockName[position_minifader_selected][dock_selected_is][24]='\0';
 reset_numeric_entry();numeric_postext=0;
 if(index_text_auto_close==1){index_type=0;}
 sprintf(string_Last_Order,">>On Master %d GIVED A NAME FOR DOCK %d ", position_minifader_selected+1,dock_selected_is+1);
 }

  //clear
 else if(index_main_clear==1 )
 {
 fader_selected_for_record=position_minifader_selected;
 dock_selected_for_record=dock_selected_is;
 index_do_clear_dock=1;
 index_ask_confirm=1;
 }


refresh_minifader_state_view_core(position_minifader_selected);
}

//MANIP DU MINI FADER/////////////////////////////////////////////////////////////
if( mouse_x>xmf+(cmptfader*larg) && mouse_x<xmf+(cmptfader*larg)+larg && mouse_y>(ymf+15+(lfad*hmfd))  && mouse_y<(ymf+20+127+(lfad*hmfd)) )
{

position_minifader_selected=cmptfader+(lfad*24);
refresh_minifader_state_view_core(cmptfader+(lfad*24));
if(index_inspekt==1){ //affichage qui dans dock si VIEW activé
show_who_is_in_dock( cmptfader+(lfad*24),   detect_dock_used(cmptfader+(lfad*24)));
}
set_mouse_range(xmf+(cmptfader*larg), ymf+20+(lfad*hmfd), xmf+(cmptfader*larg)+larg, ymf+20+127+(lfad*hmfd));//pour pas deborder
//click niveau fader
if( index_main_clear==0)
{
//NIVEAU
Fader[cmptfader+(lfad*24)]=((ymf+127+20+(lfad*hmfd))-mouse_y)*2;
midi_levels[cmptfader+(lfad*24)]=((ymf+127+20+(lfad*hmfd))-mouse_y);//desafffceté pour trouver pb

if(Fader[cmptfader+(lfad*24)]>=254){Fader[cmptfader+(lfad*24)]=255;midi_levels[cmptfader+(lfad*24)]=127;}

index_fader_is_manipulated[cmptfader+(lfad*24)]=1;
if(midi_send_out[cmptfader+(lfad*24)]==1){ index_send_midi_out[cmptfader+(lfad*24)]=1;}
if(lfo_mode_is[cmptfader+(lfad*24)]==1 || lfo_mode_is[cmptfader+(lfad*24)]==2 || lfo_cycle_is_on[cmptfader+(lfad*24)]==1)
{
lfo_mode_is[cmptfader+(lfad*24)]=0; lfo_mode_is[cmptfader+(lfad*24)]=0; lfo_cycle_is_on[cmptfader+(lfad*24)]=0;
}
//CONFIG MIDI

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_to_control(cmptfader+(lfad*24), Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);
}
}
//NETTOYAGE DE FADER ET DOCK
if(index_main_clear==1)//clear de tous les dock du fader
{
 fader_selected_for_record=cmptfader+(lfad*24);
 index_do_clear_on_faders=1;
 index_ask_confirm=1;
 mouse_released=1  ;
}
}
}//fin limitation nb faders user define
}//fin doublage des faders
}
////////FIN DES 48 POTARDS//////////////////////////////////////////////////////

return(0);
}
int do_arduino_config(int cfg_X, int cfg_Y)
{
//port COM
petitchiffre.Print("DEVICE ON COM:",cfg_X+20,cfg_Y+45); 
Rect Comport(Vec2D(cfg_X+120,cfg_Y+30),Vec2D(50,25));
Comport.SetRoundness(rondeur_fader/2);
Comport.SetLineWidth(epaisseur_ligne_fader);  
Comport.Draw(CouleurFond.WithAlpha(0.5));
if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+30 && mouse_y<cfg_Y+30+25)
{
Comport.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
Comport.Draw(CouleurBlind);
int new_comport=atoi(numeric);
reset_numeric_entry();
if(  new_comport>0 && new_comport<18)
{
if(arduino_device_0_is_ignited==1){arduino_close(0);}
arduino_com0=new_comport;           
arduino_init(0);      
mouse_released=1; 
}                   
}                     
}
petitchiffre.Print(ol::ToString(arduino_com0),cfg_X+140,cfg_Y+45);

//BAUD RATE
petitchiffre.Print("BAUD-RATE:",cfg_X+20,cfg_Y+75); 
Rect BaudrateB(Vec2D(cfg_X+120,cfg_Y+60),Vec2D(50,25));
BaudrateB.SetRoundness(rondeur_fader/2);
BaudrateB.SetLineWidth(epaisseur_ligne_fader);  
BaudrateB.Draw(CouleurFond.WithAlpha(0.5));
if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+60 && mouse_y<cfg_Y+60+25)
{
BaudrateB.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
BaudrateB.Draw(CouleurBlind);
int new_Baudrate=atoi(numeric);
reset_numeric_entry();
if( new_Baudrate>0 && (new_Baudrate ==300 || new_Baudrate==1200 || new_Baudrate==2400 || new_Baudrate==4800 || new_Baudrate==9600 || 
new_Baudrate==14400 || new_Baudrate==19200 || new_Baudrate==28800 || new_Baudrate==38400 || new_Baudrate==57600 || new_Baudrate==115200))
{
if(arduino_device_0_is_ignited==1){arduino_close(0);}
arduino_baud_rate0=new_Baudrate;           
arduino_init(0);      
mouse_released=1; 
}                   
}                     
}
petitchiffre.Print(ol::ToString(arduino_baud_rate0),cfg_X+128,cfg_Y+75);

//REQUEST RATE
petitchiffre.Print("REQUEST-RATE:",cfg_X+20,cfg_Y+105); 
Rect ReqrateB(Vec2D(cfg_X+120,cfg_Y+90),Vec2D(50,25));
ReqrateB.SetRoundness(rondeur_fader/2);
ReqrateB.SetLineWidth(epaisseur_ligne_fader);  
ReqrateB.Draw(CouleurFond.WithAlpha(0.5));
if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+90 && mouse_y<cfg_Y+90+25)
{
ReqrateB.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
ReqrateB.Draw(CouleurBlind);
int new_Reqrate=atoi(numeric);
reset_numeric_entry();
if( new_Reqrate>0 && new_Reqrate<=100 )
{
ARDUINO_RATE=new_Reqrate;
install_int_ex(ticker_arduino ,BPS_TO_TIMER(ARDUINO_RATE));         
mouse_released=1; 
}                   
}                     
}
petitchiffre.Print(ol::ToString(ARDUINO_RATE),cfg_X+140,cfg_Y+105);

////////////////LIMITATION DE CARTES ///////////////////////////////////////////
petitchiffre.Print("LAST I/O:",cfg_X+20,cfg_Y+135); 
Rect MaxIOB(Vec2D(cfg_X+120,cfg_Y+120),Vec2D(50,25));
MaxIOB.SetRoundness(rondeur_fader/2);
MaxIOB.SetLineWidth(epaisseur_ligne_fader);  
MaxIOB.Draw(CouleurFond.WithAlpha(0.5));
if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+120 && mouse_y<cfg_Y+120+25)
{
MaxIOB.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
MaxIOB.Draw(CouleurBlind);
int new_maxio=atoi(numeric);
reset_numeric_entry();
if( new_maxio>=0 && new_maxio<=digital_limit )
{
arduino_max_digital=new_maxio;
mouse_released=1; 
}                   
}                     
}
petitchiffre.Print(ol::ToString(arduino_max_digital),cfg_X+140,cfg_Y+135);
///////////////////////////////
petitchiffre.Print("LAST ANALOG:",cfg_X+20,cfg_Y+165); 
Rect MaxAnB(Vec2D(cfg_X+120,cfg_Y+150),Vec2D(50,25));
MaxAnB.SetRoundness(rondeur_fader/2);
MaxAnB.SetLineWidth(epaisseur_ligne_fader);  
MaxAnB.Draw(CouleurFond.WithAlpha(0.5));
if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+150 && mouse_y<cfg_Y+150+25)
{
MaxAnB.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
MaxAnB.Draw(CouleurBlind);
int new_maxan=atoi(numeric);
reset_numeric_entry();
if( new_maxan>=0 && new_maxan<=analog_limit )
{
arduino_max_analog=new_maxan;
mouse_released=1; 
}                   
}                     
}
petitchiffre.Print(ol::ToString(arduino_max_analog),cfg_X+140,cfg_Y+165);
/////////////////////////////////
petitchiffre.Print("OPEN:",cfg_X+20,cfg_Y+195); 
Rect OpenB(Vec2D(cfg_X+120,cfg_Y+180),Vec2D(50,25));
OpenB.SetRoundness(rondeur_fader/2);
OpenB.SetLineWidth(epaisseur_ligne_fader);  
OpenB.Draw(CouleurFond.WithAlpha(0.5));
switch (arduino_device_0_is_ignited)
{
case 0:
petitchiffre.Print("is OFF",cfg_X+130,cfg_Y+195);      
break;
case 1:
petitchiffre.Print("is ON",cfg_X+130,cfg_Y+195);      
break;       
}
if(mouse_x>cfg_X+120 && mouse_x<cfg_X+120+50 && mouse_y>cfg_Y+180 && mouse_y<cfg_Y+180+25)
{
OpenB.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
OpenB.Draw(CouleurBlind);
switch (arduino_device_0_is_ignited)
{
case 0:
   arduino_init(0);   
break;
case 1:
   arduino_close(0); 
   arduino_device_0_is_ignited=0;    
break;       
}
mouse_released=1; 
}                     
}
///////////////////////////////////////////////////////////

petitchiffre.Print("Digital affectation:",cfg_X+200,cfg_Y+20);
petitchiffre.Print("Analog affectation:",cfg_X+510,cfg_Y+20);
///////////////////BOX AFFECTATION DIGITAL////////////////

char string_temp_def[25];
char string_temp_familly[25];



for (int y=0;y<12;y++)
{
////////DIG/////////////////////////////////////////////////////////////////
Rect OverTyp(Vec2D(cfg_X+200+5,(cfg_Y+40+(y*20)-10)),Vec2D(70,18));
OverTyp.SetRoundness(rondeur_fader/2);
OverTyp.Draw(CouleurFond.WithAlpha(0.3));

Rect OverAction(Vec2D(cfg_X+280+5,(cfg_Y+40+(y*20)-10)),Vec2D(140,18));
OverAction.SetRoundness(rondeur_fader/2);
OverAction.Draw(CouleurFond.WithAlpha(0.3));

Rect OverVal(Vec2D(cfg_X+430+5,(cfg_Y+40+(y*20)-10)),Vec2D(30,18));
OverVal.SetRoundness(rondeur_fader/2);
OverVal.Draw(CouleurFond.WithAlpha(0.3));
/////////ANA///////////////////////////////////////////////////////////////

Rect OverAff(Vec2D(cfg_X+520+5,(cfg_Y+40+(y*20)-10)),Vec2D(105,18));
OverAff.SetRoundness(rondeur_fader/2);
OverAff.Draw(CouleurFond.WithAlpha(0.3));

Rect OverValA(Vec2D(cfg_X+630+5,(cfg_Y+40+(y*20)-10)),Vec2D(30,18));
OverValA.SetRoundness(rondeur_fader/2);
OverValA.Draw(CouleurFond.WithAlpha(0.3));


if(mouse_y>(cfg_Y+40+(y*20)-10) && mouse_y<(cfg_Y+40+(y*20)+5))
{
////////////////////DIG//////////////////////////////////////////////////////////
//changement type
if(mouse_x>cfg_X+200+5 && mouse_x<cfg_X+200+5+70)
{
OverTyp.DrawOutline(CouleurLigne);                  
if(mouse_button==1 && mouse_released==0)
{
arduino_digital_type[position_line_io+y]++;
arduino_digital_function_input[position_line_io+y][1]=0;
arduino_digital_function_input[position_line_io+y][0]=0;
arduino_digital_function_output[position_line_io+y][1]=0;
arduino_digital_function_output[position_line_io+y][0]=0;
if(arduino_digital_type[position_line_io+y]>3)
{arduino_digital_type[position_line_io+y]=0;}
OverTyp.Draw(CouleurFader);    
mouse_released=1;               
}
}
//////L'ASSIGNATION INPUT/////////////////////////////////////////////
//arduino_digital_function_input[128][2];//action // Val 1 

if(mouse_x>cfg_X+280+5 && mouse_x<cfg_X+280+5+140)//famille d action
{
OverAction.DrawOutline(CouleurLigne);                  
if(mouse_button==1 && mouse_released==0)
{
if(arduino_digital_type[position_line_io+y]==1)//input
{
arduino_digital_function_input[position_line_io+y][0]++;
if(arduino_digital_function_input[position_line_io+y][0]>33)
{arduino_digital_function_input[position_line_io+y][0]=0;}
arduino_digital_function_input[position_line_io+y][1]=0;
}
if(arduino_digital_type[position_line_io+y]==2 || arduino_digital_type[position_line_io+y]==3)//output ON OF ET PWM
{
arduino_digital_function_output[position_line_io+y][0]++;
if(arduino_digital_function_output[position_line_io+y][0]>2)
{arduino_digital_function_output[position_line_io+y][0]=0;}
arduino_digital_function_output[position_line_io+y][1]=0;
}
OverAction.Draw(CouleurFader);    
mouse_released=1;               
}
}           


///////La valeur de l'ordre si il y en a une ( par ex. num fader)///////

if(mouse_x>cfg_X+430+5 && mouse_x<cfg_X+430+5+30)//famille d action
{
OverVal.DrawOutline(CouleurLigne);                  
if(mouse_button==1 && mouse_released==0)
{
int valois=atoi(numeric);

///INPUT/////////////////////////////////////////////////////////////////////
//data Val1 range pour un input de type fader ( 0 à 11 )
if(
arduino_digital_type[position_line_io+y]==1
&& arduino_digital_function_input[position_line_io+y][0]>=0 && arduino_digital_function_input[position_line_io+y][0]<=11 
&& valois>0 && valois<=48
)
{
arduino_digital_function_input[position_line_io+y][1]=valois;                                                            
}
//faire data range pour le picth: 0 à 127
if(
arduino_digital_type[position_line_io+y]==1
&& ( arduino_digital_function_input[position_line_io+y][0]>=17 || arduino_digital_function_input[position_line_io+y][0]<=32) 
&& valois>=0 && valois<=127
)
{
arduino_digital_function_input[position_line_io+y][1]=valois;                                                            
}
///////////OUTPUT ON OFF ET PWM///////////////////////////////////////////////////////////////
if((arduino_digital_type[position_line_io+y]==2 || arduino_digital_type[position_line_io+y]==3) && arduino_digital_function_output[position_line_io+y][0]==1
&& valois>0 && valois<513)//CHANNEL
{
arduino_digital_function_output[position_line_io+y][1]=valois;                                                 
}
if((arduino_digital_type[position_line_io+y]==2 || arduino_digital_type[position_line_io+y]==3) && arduino_digital_function_output[position_line_io+y][0]==2
&& valois>0 && valois<49)//Fader
{
arduino_digital_function_output[position_line_io+y][1]=valois;                                                 
}
reset_numeric_entry();
OverVal.Draw(CouleurFader);    
mouse_released=1;               
}
}
///////////////////////////////////////          
///////////////////BOX AFFECTATION ANALOG////////////////


//////L'ASSIGNATION Analog/////////////////////////////////////////////

//changement affectation
if(mouse_x>cfg_X+520+5 && mouse_x<cfg_X+520+5+105)
{
OverAff.DrawOutline(CouleurLigne);                  
if(mouse_button==1 && mouse_released==0)
{
arduino_analog_function_input[position_line_ana+y]++;
arduino_analog_attribution_input[position_line_ana+y]=0;
if(arduino_analog_function_input[position_line_ana+y]>20)
{arduino_analog_function_input[position_line_ana+y]=0;}
OverAff.Draw(CouleurFader);    
mouse_released=1;               
}
}
///////////////LA VALEUR/////////////////////////////
if(mouse_x>cfg_X+630+5 && mouse_x<cfg_X+630+5+30)//valeur
{
OverValA.DrawOutline(CouleurLigne);                  
if(mouse_button==1 && mouse_released==0)
{
int valana=0;
valana=atoi(numeric);
reset_numeric_entry();
/////////////INPUT
//limitation des valeurs aux types d entrees
if(arduino_analog_function_input[position_line_ana+y]==1 || arduino_analog_function_input[position_line_ana+y]==2)//faders level et speed
{
 if(valana>0 && valana<=48)
 {arduino_analog_attribution_input[position_line_ana+y]=valana-1;}
}
if(  arduino_analog_function_input[position_line_ana+y]==4)//seq scene et preset
{
 if(valana>0 && valana<=3)//1 stage 2 preset 3 speed
 {arduino_analog_attribution_input[position_line_ana+y]=valana-1;}
}
if(  arduino_analog_function_input[position_line_ana+y]>=5 &&  arduino_analog_function_input[position_line_ana+y]<=20 )//simulation midi
{
 if(valana>=0 && valana<=127)//Pitch
 {arduino_analog_attribution_input[position_line_ana+y]=valana;}
}



OverValA.Draw(CouleurFader);   
mouse_released=1;               
}
}           






/////////////////////////////////////////////////////////////////////////////// 
}
//////////////////AFFICHAGE///////////////////////////////

if(position_line_io+y==0)
{
sprintf(string_temp_def,"0: Serial",position_line_io+y);                          
sprintf(string_temp_familly,"Rx");
OverTyp.Draw(CouleurFond);
petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20));  
petitchiffre.Print(string_temp_def,cfg_X+200+15,cfg_Y+43+(y*20));  
petitchiffrerouge.Print(ol::ToString(digital_data_from_arduino[position_line_io+y]),cfg_X+475,cfg_Y+43+(y*20));    
}
if(position_line_io+y==1)
{
sprintf(string_temp_def,"1: Serial",position_line_io+y);
sprintf(string_temp_familly,"Tx");  
OverTyp.Draw(CouleurFond);  
petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20));  
petitchiffre.Print(string_temp_def,cfg_X+200+15,cfg_Y+43+(y*20));  
petitchiffrerouge.Print(ol::ToString(digital_data_from_arduino[position_line_io+y]),cfg_X+475,cfg_Y+43+(y*20));                        
}

if(position_line_io+y>1 && position_line_io+y<=arduino_max_digital)
{
///////LE TYPE ////////////////////////////////////////////
switch(arduino_digital_type[position_line_io+y])
{
case 0://desafected
sprintf(string_temp_def,"%d: -",position_line_io+y);
break;
case 1://input      
sprintf(string_temp_def,"%d: Input",position_line_io+y);
OverTyp.Draw(CouleurRed);  
break;
case 2://output
sprintf(string_temp_def,"%d: Output",position_line_io+y);
OverTyp.Draw(CouleurGreen);  
break;
case 3://pwm
sprintf(string_temp_def,"%d: PWM",position_line_io+y);
OverTyp.Draw(CouleurYellow);  
break;      
default:
break;                                        
}      
                             
////////////ACTIONS /////////////////////////////////////////////////
////////////////GRANDE FAMILLE INPUT////////////////////////////////////////
if(arduino_digital_type[position_line_io+y]==1)//si de la famille des inputs
{
switch(arduino_digital_function_input[position_line_io+y][0])
{
case 0://desafected
sprintf(string_temp_familly,"-");
break;
case 1: //fader up                                                
sprintf(string_temp_familly,"Fader: UP");
break;
case 2://fader down
sprintf(string_temp_familly,"Fader: DOWN");
break;
case 3://Fader saw
sprintf(string_temp_familly,"Fader: SAW");
break;      
case 4:
sprintf(string_temp_familly,"Fader: ToPREVDock");     
break;
case 5:
sprintf(string_temp_familly,"Fader: ToNEXTDock");     
break;
case 6:
sprintf(string_temp_familly,"Fader: Up/Down");
break;
case 7:
sprintf(string_temp_familly,"Fader: LOCK");
break;
case 8:
sprintf(string_temp_familly,"Fader: FLASH");
break;
case 9:
sprintf(string_temp_familly,"Fader: All at 0");
break;
case 10:
sprintf(string_temp_familly,"Fader: L/Unloop dock");
break;
case 11:
sprintf(string_temp_familly,"Fader: L/Unloop all");
break;
case 12:
sprintf(string_temp_familly,"Seq: GO");
break;
case 13:
sprintf(string_temp_familly,"Seq: GO BACK");
break;
case 14:
sprintf(string_temp_familly,"Seq: JUMP");
break;
case 15:
sprintf(string_temp_familly,"Seq: SHIFT-W");
break;
case 16:
sprintf(string_temp_familly,"Seq: SHIFT-X");
break;
case 17:
sprintf(string_temp_familly,"Bang Banger num");
break;
case 18:
sprintf(string_temp_familly,"As Key-On CH0 Pitch:");
break;
case 19:
sprintf(string_temp_familly,"As Key-On CH1 Pitch:");
break;
case 20:
sprintf(string_temp_familly,"As Key-On CH2 Pitch:");
break;
case 21:
sprintf(string_temp_familly,"As Key-On CH3 Pitch:");
break;
case 22:
sprintf(string_temp_familly,"As Key-On CH4 Pitch:");
break;
case 23:
sprintf(string_temp_familly,"As Key-On CH5 Pitch:");
break;
case 24:
sprintf(string_temp_familly,"As Key-On CH6 Pitch:");
break;
case 25:
sprintf(string_temp_familly,"As Key-On CH7 Pitch:");
break;
case 26:
sprintf(string_temp_familly,"As Key-On CH8 Pitch:");
break;
case 27:
sprintf(string_temp_familly,"As Key-On CH9 Pitch:");
break;
case 28:
sprintf(string_temp_familly,"As Key-On CH10 Pitch:");
break;
case 29:
sprintf(string_temp_familly,"As Key-On CH11 Pitch:");
break;
case 30:
sprintf(string_temp_familly,"As Key-On CH12 Pitch:");
break;
case 31:
sprintf(string_temp_familly,"As Key-On CH13 Pitch:");
break;
case 32:
sprintf(string_temp_familly,"As Key-On CH14 Pitch:");
break;
case 33:
sprintf(string_temp_familly,"As Key-On CH15 Pitch:");
break;
default:
break;                                        
} 
petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20));  
petitchiffre.Print(ol::ToString(arduino_digital_function_input[position_line_io+y][1]),cfg_X+440+3,cfg_Y+43+(y*20)); 
}
petitchiffrerouge.Print(ol::ToString(digital_data_from_arduino[position_line_io+y]),cfg_X+475,cfg_Y+43+(y*20));  
petitchiffre.Print(string_temp_def,cfg_X+200+15,cfg_Y+43+(y*20));     
}

if(arduino_digital_type[position_line_io+y]==2)//si de la famille des Outputs
{
switch(arduino_digital_function_output[position_line_io+y][0])
{
case 0://desafected
sprintf(string_temp_familly,"-");
break;
case 1: //relié à un circuit  
sprintf(string_temp_familly,"Channel >10");            
break;
case 2://relié à un fader
sprintf(string_temp_familly,"Fader >10");
break;
}
petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20));  
petitchiffre.Print(ol::ToString(arduino_digital_function_output[position_line_io+y][1]),cfg_X+440+3,cfg_Y+43+(y*20)); 

}
if(arduino_digital_type[position_line_io+y]==3)//si de la famille pwm
{
switch(arduino_digital_function_output[position_line_io+y][0])
{
case 0://desafected
sprintf(string_temp_familly,"-");
break;
case 1: //relié à un circuit  
sprintf(string_temp_familly,"Channel");            
break;
case 2://relié à un fader
sprintf(string_temp_familly,"Fader");
break;
}
petitchiffre.Print(string_temp_familly,cfg_X+280+13,cfg_Y+43+(y*20));  
petitchiffre.Print(ol::ToString(arduino_digital_function_output[position_line_io+y][1]),cfg_X+440+3,cfg_Y+43+(y*20)); 
}


//affichage analog
if(position_line_ana+y<=arduino_max_analog)
{
sprintf(string_temp_def,"%d:",position_line_ana+y);
petitchiffre.Print(string_temp_def,cfg_X+510,cfg_Y+43+(y*20)); 
switch(arduino_analog_function_input[position_line_ana+y])
{
case 0://desafected
sprintf(string_temp_familly,"-");
break;
case 1: //faders  lvl                                           
sprintf(string_temp_familly,"Fader Level:");
petitchiffre.Print(ol::ToString((arduino_analog_attribution_input[position_line_ana+y]+1)),cfg_X+645,cfg_Y+43+(y*20));     
break;
case 2://faders speeed
sprintf(string_temp_familly,"Fader Speed:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]+1),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 3://master
sprintf(string_temp_familly,"Grand Master");
break;      
case 4://seq scene et preset et vitesse
sprintf(string_temp_familly,"Sequence:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]+1),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 5://Midi CH0
sprintf(string_temp_familly,"As CC CH0 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 6://Midi CH1
sprintf(string_temp_familly,"As CC CH1 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 7://Midi CH2
sprintf(string_temp_familly,"As CC CH2 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 8://Midi CH3
sprintf(string_temp_familly,"As CC CH3 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 9://Midi CH4
sprintf(string_temp_familly,"As CC CH4 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 10://Midi CH5
sprintf(string_temp_familly,"As CC CH5 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 11://Midi CH6
sprintf(string_temp_familly,"As CC CH6 Picth:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 12://Midi CH7
sprintf(string_temp_familly,"As CC CH7 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 13://Midi CH8
sprintf(string_temp_familly,"As CC CH8 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 14://Midi CH9
sprintf(string_temp_familly,"As CC CH9 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 15://Midi CH10
sprintf(string_temp_familly,"As CC CH10 Picth:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 16://Midi CH11
sprintf(string_temp_familly,"As CC CH11 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 17://Midi CH12
sprintf(string_temp_familly,"As CC CH12 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 18://Midi CH13
sprintf(string_temp_familly,"As CC CH13 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 19://Midi CH14
sprintf(string_temp_familly,"As CC CH14 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
case 20://Midi CH15
sprintf(string_temp_familly,"As CC CH15 Pitch:");
petitchiffre.Print(ol::ToString(arduino_analog_attribution_input[position_line_ana+y]),cfg_X+645,cfg_Y+43+(y*20)); 
break;
default:
break;
}
petitchiffre.Print(string_temp_familly,cfg_X+515+15,cfg_Y+43+(y*20));     
petitchiffrerouge.Print(ol::ToString(analog_data_from_arduino[position_line_ana+y]),cfg_X+670+5,cfg_Y+43+(y*20));                                             
}

//fin boucle des 12 lignes
}
/////////////////UP DOWN LINE IO /////////////////////
Circle LineUp(Vec2D(cfg_X+200+200,cfg_Y+15),12);
LineUp.Draw(CouleurFond.WithAlpha(0.3));
Circle LineDown(Vec2D(cfg_X+200+240,cfg_Y+15),12);
LineDown.Draw(CouleurFond.WithAlpha(0.3));

if(mouse_y>cfg_Y+15-12 && mouse_y<cfg_Y+15+12)
{  
if(mouse_x>cfg_X+200+200-12 && mouse_x<cfg_X+200+200+12)
{                    
LineUp.Draw(CouleurSurvol);
if(mouse_button==1)
{
LineUp.Draw(CouleurFader);
if(position_line_io>0){position_line_io--;}
}                 
}
else if(mouse_x>cfg_X+200+240-12 && mouse_x<cfg_X+200+240+12)
{
LineDown.Draw(CouleurSurvol);
if(mouse_button==1)
{
LineDown.Draw(CouleurFader);
if(position_line_io<digital_limit-1){position_line_io++;}
}                  
}                                                
}
petitchiffre.Print("-",cfg_X+200+198,cfg_Y+19);
petitchiffre.Print("+",cfg_X+200+236,cfg_Y+19);
LineUp.DrawOutline(CouleurLigne.WithAlpha(0.6));
LineDown.DrawOutline(CouleurLigne.WithAlpha(0.6));

/////////////////UP DOWN ANA /////////////////////
Circle LineUpA(Vec2D(cfg_X+510+150,cfg_Y+15),12);
LineUpA.Draw(CouleurFond.WithAlpha(0.3));
Circle LineDownA(Vec2D(cfg_X+510+190,cfg_Y+15),12);
LineDownA.Draw(CouleurFond.WithAlpha(0.3));

if(mouse_y>cfg_Y+15-12 && mouse_y<cfg_Y+15+12)
{  
if(mouse_x>cfg_X+510+150-12 && mouse_x<cfg_X+510+150+12)
{                    
LineUpA.Draw(CouleurSurvol);
if(mouse_button==1)
{
LineUpA.Draw(CouleurFader);
if(position_line_ana>0){position_line_ana--;}
}                 
}
else if(mouse_x>cfg_X+510+190-12 && mouse_x<cfg_X+510+190+12)
{
LineDownA.Draw(CouleurSurvol);
if(mouse_button==1)
{
LineDownA.Draw(CouleurFader);
if(position_line_ana<analog_limit-1){position_line_ana++;}
}                  
}                                                
}
petitchiffre.Print("-",cfg_X+510+148,cfg_Y+19);
petitchiffre.Print("+",cfg_X+510+186,cfg_Y+19);
LineUpA.DrawOutline(CouleurLigne.WithAlpha(0.6));
LineDownA.DrawOutline(CouleurLigne.WithAlpha(0.6));



//FEEDBACK
petitpetitchiffre.Print("Bytes received:",cfg_X+10,cfg_Y+260);  
petitchiffre.Print(ol::ToString( nBytesReadArduino0),cfg_X+110,cfg_Y+260); 
petitpetitchiffre.Print("Last str. received:",cfg_X+10,cfg_Y+270);  
petitpetitchiffre.Print(tmp_str_arduino,cfg_X+110,cfg_Y+270);  
petitchiffrerouge.Print(string_Arduino_status,cfg_X+10,cfg_Y+285);
  

return(0);                              
}
int do_logical_Time_Window(int xtime, int ytime, int timerayon)
{

//////////////////////ROUE DE TEMPS//////////////////////////////////////////////////////
//affectation midi

if( Midi_Faders_Affectation_Type!=0)
{
if(mouse_x>xtime+150  && mouse_x< xtime+150+100 && mouse_y>ytime+150 && mouse_y<ytime+150+100 )
 {
 //midi report
  switch(miditable[0][758])
  {
  case 0: sprintf(thetypinfo,"Note");break;
  case 1: sprintf(thetypinfo,"Key On");break;
  case 2: sprintf(thetypinfo,"Key Off");break;
  case 4: sprintf(thetypinfo,"Ctrl Change");break;
  }
  sprintf(string_last_midi_id,"TIMEWHEEL FADER is Ch: %d Pitch: %d Typ: %s" , miditable[1][758],miditable[2][758],thetypinfo);

  attribute_midi_solo_affectation(758,Midi_Faders_Affectation_Mode);
  mouse_released=1;
 }
}
/////////////////////////////////////////////////////////////////////////////////////////
if(index_play_chrono==0 )
{
for(time_angle = 0 ; time_angle <5.980005; time_angle+=0.01)//radians
{
   vtimex = cos(time_angle)*timerayon;
   vtimey = sin(time_angle)*timerayon;

   if(mouse_x>xtime+vtimex+150-15  && mouse_x< xtime+vtimex+150+15 && mouse_y>ytime+vtimey+150-15 && mouse_y<ytime+vtimey+150+15 )
   {

   actual_tickers_chrono=0;//reset du chrono
   angle_timesnap=time_angle;//angle rotation roue time
   position_curseur_time_x= xtime+150+vtimex;
   position_curseur_time_y=ytime+150+vtimey ;
   midi_levels[758]=(int)((angle_timesnap/5.980005)* 128);

   if(midi_send_out[758]==1){index_send_midi_out[758]=1;}

   if(time_wheel_datatype_is==0)//minutes
   {
   angle_timesnap_min=angle_timesnap;
   time_minutes=(int)((angle_timesnap_min/5.980005)*60);
   }
   if(time_wheel_datatype_is==1)//secondes
   {
   angle_timesnap_sec=angle_timesnap;
   time_secondes=(int)((angle_timesnap_sec/5.980005)*60);
   }
   if(time_wheel_datatype_is==2)//dixiemes
   {
   angle_timesnap_dix=angle_timesnap;
   time_centiemes=(int)((angle_timesnap_dix/5.980005)*100);
   }

   }
}
}




//////////////////////////CHRONO//////////////////////////////////////////////////

if(mouse_x>xtime+140-15 && mouse_x<xtime+140+15 && mouse_y>ytime+190-15 && mouse_y<ytime+190+15)
{

switch(miditable[0][765])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"ChronoPlay is Ch: %d Pitch: %d Typ: %s",miditable[1][765],miditable[2][765],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(765,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
Chrono_PlayPause();
mouse_released=1;
}
}

if(mouse_x>xtime+180-8 && mouse_x<xtime+180+8 && mouse_y>ytime+200-8 && mouse_y<ytime+200+8)
{

switch(miditable[0][766])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"ChronoReset is Ch: %d Pitch: %d Typ: %s",miditable[1][766],miditable[2][766],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(766,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
Chrono_Reset();
mouse_released=1;
}
}

///////////////////////CHOIX DE SELECTION ROUE= SECONDES ou MINUTES ou HEURES


if(mouse_x>xtime+120 && mouse_x<xtime+180 && mouse_y>ytime+80 && mouse_y<ytime+100)
{

switch(miditable[0][759])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"TimeType is Ch: %d Pitch: %d Typ: %s",miditable[1][759],miditable[2][759],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(759,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
time_wheel_datatype_is++;
if(time_wheel_datatype_is>2){time_wheel_datatype_is=0;}
set_time_cursor_to_time_type(time_wheel_datatype_is);
mouse_released=1;
}
}



/////////////////////////CASES D' AFFECTATION AUX DOCK ET MEMOIRES

//la selection des modes de temps in out din dout
if(mouse_x>xtime+300 && mouse_x<xtime+350)
{
//DIN
if(mouse_y>ytime+120 && mouse_y<ytime+150)
{

switch(miditable[0][760])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"DelayIn Button is Ch: %d Pitch: %d Typ: %s",miditable[1][760],miditable[2][760],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(760,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_type_of_time_to_affect[0]==0){index_type_of_time_to_affect[0]=1;}
else if(index_type_of_time_to_affect[0]==1){index_type_of_time_to_affect[0]=0;}
mouse_released=1;
}
}
//IN
if(mouse_y>ytime+20 && mouse_y<ytime+50)
{

switch(miditable[0][761])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"In Button is Ch: %d Pitch: %d Typ: %s",miditable[1][761],miditable[2][761],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(761,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_type_of_time_to_affect[1]==0){index_type_of_time_to_affect[1]=1;}
else if(index_type_of_time_to_affect[1]==1){index_type_of_time_to_affect[1]=0;}
mouse_released=1;
}
}
//DOUT
if(mouse_y>ytime+170 && mouse_y<ytime+200)
{

switch(miditable[0][762])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"DelayOut Button is Ch: %d Pitch: %d Typ: %s",miditable[1][762],miditable[2][762],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(762,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_type_of_time_to_affect[2]==0){index_type_of_time_to_affect[2]=1;}
else if(index_type_of_time_to_affect[2]==1){index_type_of_time_to_affect[2]=0;}
mouse_released=1;
}
}
//OUT
if(mouse_y>ytime+70 && mouse_y<ytime+100)
{

switch(miditable[0][763])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Out Button is Ch: %d Pitch: %d Typ: %s",miditable[1][763],miditable[2][763],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(763,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_type_of_time_to_affect[3]==0){index_type_of_time_to_affect[3]=1;}
else if(index_type_of_time_to_affect[3]==1){index_type_of_time_to_affect[3]=0;}
mouse_released=1;
}
}
}

///TAP TEMPO sending
if(mouse_x>xtime+265 && mouse_x<xtime+265+15 && mouse_y>ytime+210 && mouse_y<ytime+210+15)
{

switch(miditable[0][1328])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Send Tap is Ch: %d Pitch: %d Typ: %s",miditable[1][1328],miditable[2][1328],thetypinfo);

if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(1328,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(numeric_postext==0 && index_window_chasers==1)
            {
            set_chaser_tempo_unit(chaser_selected);
            }
            else//si chiffre de chaser tapé
            {
            int chazr=atoi(numeric);
            if(chazr>0 && chazr<128)
            {
            set_chaser_tempo_unit(chazr-1);
            numeric_postext=0;
            reset_numeric_entry();
            }
            }
            mouse_released=1;
do_light_send_tap=1;
}

}



///TAP TEMPO reoording
if(mouse_x>xtime+285 && mouse_x<xtime+285+15 && mouse_y>ytime+210 && mouse_y<ytime+210+15)
{

switch(miditable[0][1327])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Record Tap is Ch: %d Pitch: %d Typ: %s",miditable[1][1327],miditable[2][1327],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(1327,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
index_recording_tap_tempo=toggle(index_recording_tap_tempo);
if(index_recording_tap_tempo==1)
{
start_tempo_ticks=actual_time;nbr_steps_tempo=0;tempo_interm=0;
sprintf(string_tap_tempo_average,"Step:   -    Global: -");
sprintf(string_actual_tap_tempo,"Last: ");
sprintf(string_Last_Order,"Tap Tempo Rec ON");
}
else{sprintf(string_Last_Order,"Tap Tempo Rec Off");}
mouse_released=1;
}


}


//tap button tempo
if(mouse_x>xtime+310 && mouse_x<xtime+310+40 && mouse_y>ytime+210 && mouse_y<ytime+210+30)
{

switch(miditable[0][1326])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Tap Tempo is Ch: %d Pitch: %d Typ: %s",miditable[1][1326],miditable[2][1326],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(1326,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
set_new_time_in_tap_tempo();
mouse_released=1;
}
}


//AFFECT TIME
if(mouse_x>xtime+280 && mouse_x<xtime+350 && mouse_y>ytime+260 && mouse_y<ytime+290)
{

switch(miditable[0][764])
{
//midi report
case 0:
sprintf(thetypinfo,"Note");
break;
case 1:
sprintf(thetypinfo,"Key On");
break;
case 2:
sprintf(thetypinfo,"Key Off");
break;
case 4:
sprintf(thetypinfo,"Ctrl Change");
break;
}
sprintf(string_last_midi_id,"Affect Time Button is Ch: %d Pitch: %d Typ: %s",miditable[1][764],miditable[2][764],thetypinfo);

if( Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(764,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(index_affect_time==0)
{
reset_index_actions();
reset_indexs_confirmation();
index_affect_time=1;
}
else
{
reset_index_actions();
}
index_do_dock=index_affect_time;
mouse_released=1;
}
}


button_midi_out_core( xtime+250, ytime+250,758);

return(0);
}
Esempio n. 15
0
int do_logical_echo_window(int xe, int ye)
{
if(window_focus_id==W_ECHO && dragging_channel_in_echo==0 && mouse_button==1)
{

//edit
if( mouse_released==0 && mouse_x>xe+610 && mouse_x<xe+610+50 && mouse_y>ye+10 && mouse_y<ye+10+20 )
{
index_enable_edit_echo=toggle(index_enable_edit_echo);
mouse_released=1;
}


int index_ec=0;
//SElection presets
for(int le=0;le<3;le++)
{
for(int cel=0;cel<8;cel++)
{
index_ec=cel+(le*8);
if( mouse_x> xe+180+(40*cel) && mouse_x<xe+180+(40*cel)+30 && mouse_y>ye+10+(le*25) && mouse_y<ye+10+(le*25)+20)
{
if( mouse_released==0 )
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
 attribute_midi_to_control(1663+index_ec,Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);
}
else
{
if(index_main_clear==1)
{
if(index_enable_edit_echo==1)
{
index_selected_echo_for_manipulation=index_ec;
index_ask_clear_echo_preset=1;
index_ask_confirm=1;             //clear_echo_preset(index_selected_echo_for_manipulation);
}
}

else
{
echo_selected=index_ec;

}
}
mouse_released=1;
}
}
}
}


//Set ChanPos
if( mouse_x>xe+615 && mouse_x<xe+615+40 && mouse_y>ye+65 && mouse_y<ye+65+20 && mouse_released==0 && dragging_channel_in_echo==0 && numeric_postext>0)
 {
 echo_grid_channel_position[echo_selected]=atoi(numeric)-1;
 echo_grid_channel_position[echo_selected]= constrain_int_data_to_this_range(echo_grid_channel_position[echo_selected],0,511-14);
 reset_numeric_entry();
 numeric_postext=0;
 mouse_released=1;
 }


//ECHO ACTION PANNEL

for (int n=0;n<5;n++)
{
//actions
if(mouse_x>xe+30 && mouse_x<xe+30+115 && mouse_y>ye+50+(n*30) && mouse_y<ye+50+30+(n*30))
{
if( mouse_released==0 )
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1686+n,Midi_Faders_Affectation_Mode);
}
else
{
switch(n)
{
case 0:
     echo_is_echo_mode[echo_selected]=toggle(echo_is_echo_mode[echo_selected]);
     do_bounce[echo_selected]=echo_is_echo_mode[echo_selected];
break;
case 1:
     snap_fader_state(echo_selected,echo_pointing_fader_num[echo_selected]-1);
break;
case 2:
     bounce(echo_selected);
break;
case 3:
     snap_kill_and_bounce(echo_selected,echo_pointing_fader_num[echo_selected]-1);
break;
case 4:
     recall_fader_state_echo(echo_pointing_fader_num[echo_selected]-1);
break;
default:
break;
}
}
mouse_released=1;
}

}
}

//Fader point to
if( mouse_x>xe+70 && mouse_x<xe+70+45 && mouse_y>ye+200 && mouse_y<ye+200+35 && mouse_released==0 && numeric_postext>0)
{
echo_pointing_fader_num[echo_selected]=constrain_int_data_to_this_range(atoi(numeric),1,48);
reset_numeric_entry();
numeric_postext=0;
mouse_released=1;
}


////AFFECT TO DOCK
if( mouse_released==0 && mouse_x>xe+10 && mouse_x<xe+10+110 && mouse_y>ye+245 && mouse_y<ye+245+20  )
{
if(index_affect_echo_to_dock==0)
{
reset_index_actions();
reset_indexs_confirmation();
index_affect_echo_to_dock=1;
}
else
{
reset_index_actions();
}
index_do_dock=index_affect_echo_to_dock;
mouse_released=1;
}


//manipulate channel params Level mode / ground mode
if( mouse_released==0 && mouse_x>xe+500 && mouse_x<xe+500+70 && mouse_y>ye+10 && mouse_y<ye+10+20)
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1696,Midi_Faders_Affectation_Mode);
}
else
{
if(index_main_clear==1 && index_enable_edit_echo==1)
{
switch(echo_channel_manipulate_mode[echo_selected])
{
 case 0://levels
 clear_echo_levels(echo_selected);
 break;
 case 1:
 clear_ground_levels(echo_selected);
 break;
}
index_main_clear=0;
}
else
{
echo_channel_manipulate_mode[echo_selected]=toggle(echo_channel_manipulate_mode[echo_selected]);
}
}
mouse_released=1;
}






//les Trois parametres globaux: gravite masse energy
for (int cl=0;cl<3;cl++)
{

if(mouse_x>=xe+155+(cl*180) && mouse_x<=xe+155+(cl*180)+130 && mouse_y>=ye+255 && mouse_y<=ye+255+10)
{
if(  mouse_released==0)
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1693+cl,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
echo_global_params[echo_selected][cl]= (float)(constrain_data_to_midi_range(mouse_x-( xe+155+(cl*180))))/127;
midi_levels[1693+cl]=(int)(echo_global_params[echo_selected][cl]*127);
}
}
}
//midi out
if( mouse_released==0 && mouse_x>=xe+290+(cl*180) && mouse_x<=xe+290+(cl*180)+10 && mouse_y>=ye+260 && mouse_y<=ye+265+10)
{
 midi_send_out[1693+cl]=toggle(midi_send_out[1693+cl]);
 mouse_released=1;
}

}//fin des 3 sliders



}
//hors du dragging 0
do_logical_Echo_Aera(xe+155,ye+95);
return(0);
}
int do_logical_GlobalGridViewer(int xb, int yb, int taillecase)
{
//appel de grille

if(mouse_x>xb+40 && mouse_x<xb+40+50 && mouse_y>yb+10 && mouse_y<yb+10+20  )
{
if(mouse_released==0)
{
if(numeric_postext>0)
{
int temp_num_grid=atoi(numeric);
if(temp_num_grid>0 && temp_num_grid<128)
{
grid_selected_for_view  =temp_num_grid-1;
reset_numeric_entry();
}
}
}
mouse_released=1;
}


if(mouse_x>xb+150 && mouse_x<xb+150+50 && mouse_y>yb+10 && mouse_y<yb+10+20 )
{
if( mouse_released==0)
{
if(numeric_postext>0)
{
int temp_num_grid=atoi(numeric);
if(temp_num_grid>0 && temp_num_grid<1024)
{
grid_step_view =temp_num_grid-1;
reset_numeric_entry();
}
}
mouse_released=1;
}
}

//déplacement dans les pas

if(mouse_x>xb+220 && mouse_x<xb+220+20 && mouse_y>yb+10 && mouse_y<yb+10+20)
{
if( mouse_released==0)
{
grid_step_view--;
if(grid_step_view<0){grid_step_view=0;}
mouse_released=1;
}
}
if(mouse_x>xb+250 && mouse_x<xb+250+20 && mouse_y>yb+10 && mouse_y<yb+10+20)
{
if( mouse_released==0)
{
grid_step_view++;
if(grid_step_view>1022){grid_step_view=1022;}
mouse_released=1;
}
}

return(0);
}
Esempio n. 17
0
int do_screen_config( int x_cfg_sc,int y_cfg_sc, int largeur_cfg_sc, int hauteur_cfg_sc)
{
//////////////////SCREEN SIZE//////////////////////////////////////////////////
Rect EncadreScreen(Vec2D(x_cfg_sc+10,y_cfg_sc+40),Vec2D(200,230));
EncadreScreen.SetRoundness(7.5);
EncadreScreen.SetLineWidth(epaisseur_ligne_fader);

petitchiffre.Print("SIZE -need restart- " ,(x_cfg_sc+20), (y_cfg_sc+60));

for (int lps=0;lps<2;lps++)
{
Rect screen_mode(Vec2D( x_cfg_sc+20,y_cfg_sc+75+(lps*30)),Vec2D(55,15));
screen_mode.SetRoundness(5);
screen_mode.Draw(CouleurFond.WithAlpha(0.5));
//FULLSCREEN or WINDOWED
if(lps==0)
{
petitchiffre.Print("Fullscreen " ,(x_cfg_sc+85), y_cfg_sc+85+(lps*30));
if(mouse_x>x_cfg_sc+20 && mouse_x<x_cfg_sc+75 && mouse_y>y_cfg_sc+75+(lps*30) && mouse_y<y_cfg_sc+90+(lps*30)  && window_focus_id==920)
{
screen_mode.Draw(CouleurSurvol);
if(mouse_button==1 && mouse_released==0)
{
if(index_fullscreen==0) {index_fullscreen=1;index_specify_size=0;largeur_ecran= GetSystemMetrics(SM_CXVIRTUALSCREEN);
hauteur_ecran = GetSystemMetrics(SM_CYVIRTUALSCREEN);}
else if (index_fullscreen==1) {index_fullscreen=0;}
mouse_released=1;
}
}
if(index_fullscreen==1)
{screen_mode.Draw(CouleurFader);}
}

//SPECIFY SIZE
else if(lps==1)
{
petitchiffre.Print("Set new size: " ,(x_cfg_sc+85), y_cfg_sc+50+35+(lps*30));
if(mouse_x>x_cfg_sc+20 && mouse_x<x_cfg_sc+75 && mouse_y>y_cfg_sc+75+(lps*30) && mouse_y<y_cfg_sc+90+(lps*30)  && window_focus_id==920)
{
screen_mode.Draw(CouleurSurvol);
if(mouse_button==1 && mouse_released==0)
{
if(index_specify_size==0)
{
index_specify_size=1;
index_fullscreen=0;
}
else if (index_specify_size==1) {index_specify_size=0;}
mouse_released=1;
}
}
if(index_specify_size==1)
{screen_mode.Draw(CouleurFader);}
}

}


Rect boxlargeur(Vec2D((x_cfg_sc+100),y_cfg_sc+130),Vec2D(65,30));
boxlargeur.SetRoundness(7.5);
boxlargeur.Draw(CouleurFond.WithAlpha(0.5));


Rect boxhauteur(Vec2D((x_cfg_sc+100),y_cfg_sc+165),Vec2D(65,30));
boxhauteur.SetRoundness(7.5);
boxhauteur.Draw(CouleurFond.WithAlpha(0.5));

if(mouse_x>(x_cfg_sc+100) && mouse_x<(x_cfg_sc+165) && window_focus_id==920)
{
if(mouse_y> y_cfg_sc+130 && mouse_y<y_cfg_sc+160)
{
boxlargeur.DrawOutline(CouleurLigne);
if(mouse_button==1 && mouse_released==0 && index_specify_size==1)
{
if(atoi(numeric)>=1024)
{
largeur_ecran=atoi(numeric);
reset_numeric_entry();
}
else {sprintf(string_Last_Order,"Screen Width must be at minimum 1024 px");}
mouse_released=1;
}
}
if(mouse_y> y_cfg_sc+165 && mouse_y<y_cfg_sc+195)
{
boxhauteur.DrawOutline(CouleurLigne);
if(mouse_button==1 && mouse_released==0 && index_specify_size==1)
{
if(atoi(numeric)>=600)
{
hauteur_ecran=atoi(numeric);
reset_numeric_entry();
}
else {sprintf(string_Last_Order,"Screen Height must be at minimum 600 px");}
mouse_released=1;
}
}
}
petitchiffre.Print("Width: " ,(x_cfg_sc+40), y_cfg_sc+150);
petitchiffre.Print(ol::ToString(largeur_ecran) ,(x_cfg_sc+120), y_cfg_sc+150);
petitchiffre.Print("Height: " ,(x_cfg_sc+40), y_cfg_sc+185);
petitchiffre.Print(ol::ToString(hauteur_ecran) ,(x_cfg_sc+120), y_cfg_sc+185);
EncadreScreen.DrawOutline(CouleurLigne);

/////////////////////WINDOW POS///////////////////////////////////////////////////

Rect EncadrePos(Vec2D(x_cfg_sc+10+230,y_cfg_sc+40),Vec2D(200,230));
EncadrePos.SetRoundness(7.5);
EncadrePos.SetLineWidth(epaisseur_ligne_fader);
petitchiffre.Print("POSITIONS " ,(x_cfg_sc+250), (y_cfg_sc+60));

for (int lpos=0;lpos<4;lpos++)
{
Rect pos_mode(Vec2D( x_cfg_sc+250,y_cfg_sc+75+(lpos*30)),Vec2D(55,15));
pos_mode.SetRoundness(5);
pos_mode.Draw(CouleurFond.WithAlpha(0.5));
//reset windows general
if(lpos==0)
{
petitchiffre.Print("Reset Internal" ,(x_cfg_sc+325), y_cfg_sc+50+35+(lpos*30));
petitchiffre.Print("         Windows" ,(x_cfg_sc+325), y_cfg_sc+50+35+(lpos*30)+15);
if(mouse_x>x_cfg_sc+250 && mouse_x<x_cfg_sc+305 && mouse_y>y_cfg_sc+75+(lpos*30) && mouse_y<y_cfg_sc+90+(lpos*30)  && window_focus_id==920)
{
pos_mode.Draw(CouleurSurvol);
if(mouse_button==1 && mouse_released==0)
{
pos_mode.Draw(CouleurFader);
reset_window_positions();
mouse_released=1;
}
}
}
//record custom
else if(lpos==1)
{
petitchiffre.Print("Record Pos" ,(x_cfg_sc+325), y_cfg_sc+85+(lpos*30));
if(mouse_x>x_cfg_sc+250 && mouse_x<x_cfg_sc+305 && mouse_y>y_cfg_sc+75+(lpos*30) && mouse_y<y_cfg_sc+90+(lpos*30) && window_focus_id==920)
{
pos_mode.Draw(CouleurSurvol);
if(mouse_button==1 && mouse_released==0)
{
pos_mode.Draw(CouleurFader);
store_window_positions();
mouse_released=1;
}
}
}
//load custom
else if(lpos==2)
{
petitchiffre.Print("Reload Pos" ,(x_cfg_sc+325), y_cfg_sc+85+(lpos*30));
if(mouse_x>x_cfg_sc+250 && mouse_x<x_cfg_sc+305 && mouse_y>y_cfg_sc+75+(lpos*30) && mouse_y<y_cfg_sc+90+(lpos*30) && window_focus_id==920)
{
pos_mode.Draw(CouleurSurvol);
if(mouse_button==1 && mouse_released==0)
{
pos_mode.Draw(CouleurFader);
reload_window_positions();
mouse_released=1;
}
}
}
//set position
else if(lpos==3)
{
petitchiffre.Print("Program Position" ,(x_cfg_sc+325), y_cfg_sc+85+(lpos*30));
if(mouse_x>x_cfg_sc+250 && mouse_x<x_cfg_sc+305 && mouse_y>y_cfg_sc+75+(lpos*30) && mouse_y<y_cfg_sc+90+(lpos*30) && window_focus_id==920)
{
pos_mode.Draw(CouleurSurvol);
if(mouse_button==1 && mouse_released==0)
{
if(index_set_pos==0){index_set_pos=1;}
else if(index_set_pos==1){index_set_pos=0;}
mouse_released=1;
}
}
if(index_set_pos==1){pos_mode.Draw(CouleurFader);}
}
}
EncadrePos.DrawOutline(CouleurLigne);

Rect boxposx(Vec2D((x_cfg_sc+330),y_cfg_sc+190),Vec2D(65,30));
boxposx.SetRoundness(7.5);
boxposx.Draw(CouleurFond.WithAlpha(0.5));

Rect boxposy(Vec2D((x_cfg_sc+330),y_cfg_sc+225),Vec2D(65,30));
boxposy.SetRoundness(7.5);
boxposy.Draw(CouleurFond.WithAlpha(0.5));

if(mouse_x>(x_cfg_sc+330) && mouse_x<(x_cfg_sc+395) && window_focus_id==920)
{
if(mouse_y> y_cfg_sc+190 && mouse_y<y_cfg_sc+220)
{
boxposx.DrawOutline(CouleurLigne);
if(mouse_button==1 && mouse_released==0 && index_set_pos==1)
{
posX_mainwindow=atoi(numeric);
reset_numeric_entry();
mouse_released=1;
}
}
if(mouse_y> y_cfg_sc+225 && mouse_y<y_cfg_sc+255)
{
boxposy.DrawOutline(CouleurLigne);
if(mouse_button==1 && mouse_released==0 && index_set_pos==1)
{
posY_mainwindow=atoi(numeric);
reset_numeric_entry();
mouse_released=1;
}
}
}

petitchiffre.Print("X: " ,(x_cfg_sc+300), y_cfg_sc+210);
petitchiffre.Print(ol::ToString(posX_mainwindow) ,(x_cfg_sc+350), y_cfg_sc+210);
petitchiffre.Print("Y: " ,(x_cfg_sc+300), y_cfg_sc+245);
petitchiffre.Print(ol::ToString(posY_mainwindow) ,(x_cfg_sc+350), y_cfg_sc+245);
EncadreScreen.DrawOutline(CouleurLigne);

//////////////////////COLOR THEME/////////////////////////////////////////////


Rect EncadreTheme(Vec2D(x_cfg_sc+470,y_cfg_sc+40),Vec2D(350,230));
EncadreTheme.SetRoundness(7.5);
EncadreTheme.SetLineWidth(epaisseur_ligne_fader);
petitchiffre.Print("COLOR THEMES " ,(x_cfg_sc+500), (y_cfg_sc+60));

for (int thp=0;thp<6;thp++)
{
Rect theme_mode(Vec2D( x_cfg_sc+480,y_cfg_sc+75+(thp*30)),Vec2D(55,15));
theme_mode.SetRoundness(5);
theme_mode.Draw(CouleurFond.WithAlpha(0.5));
if(thp==0)
{
petitchiffre.Print("Black 70's" ,(x_cfg_sc+550), y_cfg_sc+85+(thp*30));
}
else if(thp==1)
{
petitchiffre.Print("Classic Grey" ,(x_cfg_sc+550), y_cfg_sc+85+(thp*30));
}
else if(thp==2)
{
petitchiffre.Print("Electric Night" ,(x_cfg_sc+550), y_cfg_sc+85+(thp*30));
}
else if(thp==3)
{
petitchiffre.Print("Discrete" ,(x_cfg_sc+550), y_cfg_sc+85+(thp*30));
}
else if(thp==4)
{
petitchiffre.Print("Matrix" ,(x_cfg_sc+550), y_cfg_sc+85+(thp*30));
}
else if(thp==5)
{
petitchiffre.Print("User Colors :" ,(x_cfg_sc+550), y_cfg_sc+85+(thp*30));
}

if(mouse_x>x_cfg_sc+480 && mouse_x<x_cfg_sc+535 && mouse_y>y_cfg_sc+65+(thp*30) && mouse_y<y_cfg_sc+90+(thp*30) && window_focus_id==920)
{
theme_mode.Draw(CouleurSurvol);
if(mouse_button==1 && mouse_released==0)
{
config_color_style_is=thp;
LoadWhiteCatColorProfil();
mouse_released=1;
}
}
if(config_color_style_is==thp){theme_mode.Draw(CouleurFader);}
}

///////////////////////////////////////////////////////////////////////////
//selection et affectation user
Rect theme_receive(Vec2D( x_cfg_sc+665,y_cfg_sc+105),Vec2D(55,15));
theme_receive.SetRoundness(5);
theme_receive.Draw(CouleurFond.WithAlpha(0.5));
petitchiffre.Print("Receive" ,(x_cfg_sc+730),y_cfg_sc+105);
petitchiffre.Print("Trichromy" ,(x_cfg_sc+730),y_cfg_sc+120);

if(mouse_x> x_cfg_sc+665 && mouse_x< x_cfg_sc+720 && mouse_y>y_cfg_sc+105 && mouse_y<y_cfg_sc+120 && window_focus_id==920)
{
theme_receive.Draw(CouleurSurvol);
 if(mouse_button==1 && mouse_released==0)
 {
 if( receive_from_trichro==0){receive_from_trichro=1;}
 else if( receive_from_trichro==1){receive_from_trichro=0;}
 mouse_released=1;
 }
}

if(receive_from_trichro==1){theme_receive.Draw(CouleurFader);}

for (int lg=0;lg<3;lg++)
{
 for   (int cl=0;cl<4;cl++)
 {
 Rect ColUser(Vec2D(x_cfg_sc+660+(cl*40),y_cfg_sc+140+(lg*40)),Vec2D(30,30));
 ColUser.SetRoundness(5);
 index_color_user_to_affect=cl+(lg*4);   ;

 switch (index_color_user_to_affect)
 {
 case 0:
 CouleurUserLoop=CouleurUser1;
 break;
 case 1:
 CouleurUserLoop=CouleurUser2;
 break;
 case 2:
 CouleurUserLoop=CouleurUser3;
 break;
 case 3:
 CouleurUserLoop=CouleurUser4;
 break;
 case 4:
 CouleurUserLoop=CouleurUser5;
 break;
 case 5:
 CouleurUserLoop=CouleurUser6;
 break;
 case 6:
 CouleurUserLoop=CouleurUser7;
 break;
 case 7:
 CouleurUserLoop=CouleurUser8;
 break;
 case 8:
 CouleurUserLoop=CouleurUser9;
 break;
 case 9:
 CouleurUserLoop=CouleurUser10;
 break;
 case 10:
 CouleurUserLoop=CouleurUser11;
 break;
 case 11:
 CouleurUserLoop=CouleurUser12;
 break;
 }
 ColUser.Draw(CouleurUserLoop);

 if(mouse_x>x_cfg_sc+660+(cl*40) && mouse_x<x_cfg_sc+690+(cl*40) && mouse_y>y_cfg_sc+140+(lg*40) && mouse_y<y_cfg_sc+170+(lg*40) && window_focus_id==920)
 {
 if(mouse_button==1 && mouse_released==0)
 {
 index_color_user_selected=cl+(lg*4);
 mouse_released=1;
 }
 }
 ColUser.DrawOutline(CouleurLigne);
 if(index_color_user_to_affect==index_color_user_selected)
 {
 ColUser.SetLineWidth(epaisseur_ligne_fader);
 ColUser.DrawOutline(CouleurFader);
 }
}
}
//ventilation couleurs
 if(receive_from_trichro==1 && index_affect_color_to_dock==1)
 {
  couleurs_user[index_color_user_selected][0]=float(my_red)/255;
  couleurs_user[index_color_user_selected][1]=float(my_green)/255;
  couleurs_user[index_color_user_selected][2]=float(my_blue)/255;

  Rgba TmpColor (couleurs_user[index_color_user_selected][0],couleurs_user[index_color_user_selected][1],couleurs_user[index_color_user_selected][2]);

  switch (index_color_user_selected)
 {
 case 0:
 CouleurUser1=TmpColor;
 sprintf(descriptif_colors_user_conf,"Your color is:Background");
 break;
 case 1:
 CouleurUser2=TmpColor;
 sprintf(descriptif_colors_user_conf,"Your color is:Lines");
 break;
 case 2:
 CouleurUser3=TmpColor;
 sprintf(descriptif_colors_user_conf,"Your color is:Fader");
 break;
 case 3:
 sprintf(descriptif_colors_user_conf,"Your color is:Selected");
 CouleurUser4=TmpColor;
 break;
 case 4:
 sprintf(descriptif_colors_user_conf,"Your color is:On mouse over");
 CouleurUser5=TmpColor;
 break;
 case 5:
 sprintf(descriptif_colors_user_conf,"Your color is:Levels");
 CouleurUser6=TmpColor;
 break;
 case 6:
 sprintf(descriptif_colors_user_conf,"Your color is:Selection");
 CouleurUser7=TmpColor;
 break;
 case 7:
 sprintf(descriptif_colors_user_conf,"Your color is:Back levels");
 CouleurUser8=TmpColor;
 break;
 case 8:
 sprintf(descriptif_colors_user_conf,"Your color is:Blind");
 CouleurUser9=TmpColor;
 break;
 case 9:
 sprintf(descriptif_colors_user_conf,"Your color is:Lock");
 CouleurUser10=TmpColor;
 break;
 case 10:
 sprintf(descriptif_colors_user_conf,"Your color is:Config");
 CouleurUser11=TmpColor;
 break;
 case 11:
 sprintf(descriptif_colors_user_conf,"Your color is:Procedure");
 CouleurUser12=TmpColor;
 break;
 }
 LoadWhiteCatColorProfil();
}

petitchiffre.Print(descriptif_colors_user_conf,x_cfg_sc+660,y_cfg_sc+70);
EncadreTheme.DrawOutline(CouleurLigne);

//////////////////SCREEN SIZE//////////////////////////////////////////////////
Rect EncadreUseCol(Vec2D(x_cfg_sc+655,y_cfg_sc+90),Vec2D(160,170));
EncadreUseCol.SetRoundness(7.5);
EncadreUseCol.SetLineWidth(demi_epaisseur_ligne_fader);
EncadreUseCol.DrawOutline(CouleurLigne);

Line(Vec2D(x_cfg_sc+655,y_cfg_sc+230),Vec2D(x_cfg_sc+630,y_cfg_sc+230)).Draw(CouleurLigne);

return(0);
}
int do_dmx_config(int cfgdmx_X, int cfgdmx_Y, int largeurCFGdmxwindow,int hauteurCFGdmxwindow)
{

//definition des aires devices
Rect DeviceArtNetDevice( Vec2D((cfgdmx_X+10),(cfgdmx_Y+50)),Vec2D(180,30));
DeviceArtNetDevice.SetRoundness(15);

Rect DeviceEnttecOpen( Vec2D((cfgdmx_X+10),(cfgdmx_Y+80)),Vec2D(180,30));
DeviceEnttecOpen.SetRoundness(15);

Rect DeviceEnttecPro( Vec2D((cfgdmx_X+10),(cfgdmx_Y+110)),Vec2D(180,30));
DeviceEnttecPro.SetRoundness(15);


Rect DeviceSunlite ( Vec2D((cfgdmx_X+10),(cfgdmx_Y+170)),Vec2D(180,30));
DeviceSunlite.SetRoundness(15);


//definition des aires univers
Rect ArtNetSendUniverse( Vec2D((cfgdmx_X+220),(cfgdmx_Y+50)),Vec2D(70,30));
ArtNetSendUniverse.SetRoundness(15);

//definition des aire d edition d adresse
Rect ArtNetSendAdress( Vec2D((cfgdmx_X+320),(cfgdmx_Y+50)),Vec2D(170,30));
ArtNetSendAdress.SetRoundness(15);

//SPEC. ARTNET: BROADCAST MODE
Rect ArtNetBroadcastMode( Vec2D((cfgdmx_X+520),(cfgdmx_Y+50)),Vec2D(130,30));
ArtNetBroadcastMode.SetRoundness(15);

//SPEC ARTNET ARTPOLL
Rect ArtNetPollforDevices( Vec2D((cfgdmx_X+670),(cfgdmx_Y+50)),Vec2D(100,30));
ArtNetPollforDevices.SetRoundness(15);

//SPEC ARTNET DOUBLE DMX
Rect ArtNetDoubleDMX( Vec2D((cfgdmx_X+770),(cfgdmx_Y+50)),Vec2D(60,30));
ArtNetDoubleDMX.SetRoundness(15);



//SPEC ENTTEC PROIN
Rect EnttecProIN( Vec2D((cfgdmx_X+240),(cfgdmx_Y+110)),Vec2D(170,30));
EnttecProIN.SetRoundness(15);



//SPEC SUNLITE
Rect SunliteAllowsIN( Vec2D((cfgdmx_X+240),(cfgdmx_Y+170)),Vec2D(150,30));
SunliteAllowsIN.SetRoundness(15);





{

//SELECTION DE L INTERFACE
if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+20 && mouse_x<cfgdmx_X+200 )
{
   if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80)) //artnet
   {
   DeviceArtNetDevice.Draw(CouleurFond.WithAlpha(0.5));
   Survol_interface_numero=1;
   if(mouse_button==1 && mouse_released==0 )
   {
   SelectDmxDevice(1);
   }
   }
   else if( mouse_y>(cfgdmx_Y+90) && mouse_y< (cfgdmx_Y+110)) //enttec open
   {
   DeviceEnttecOpen.Draw(CouleurFond.WithAlpha(0.5));
   Survol_interface_numero=2;
   if(mouse_button==1 && mouse_released==0  )
   {
   SelectDmxDevice(2);

   }
   }
   else if( mouse_y>(cfgdmx_Y+120) && mouse_y< (cfgdmx_Y+140)) //enttec pro
   {
   DeviceEnttecPro.Draw(CouleurFond.WithAlpha(0.5));
   Survol_interface_numero=3;
   if(mouse_button==1 && mouse_released==0 )
   {
   SelectDmxDevice(3);
   }
   }

    else if( mouse_y>(cfgdmx_Y+170) && mouse_y< (cfgdmx_Y+200)) //sunlite
   {
   DeviceSunlite.Draw(CouleurFond.WithAlpha(0.5));
   Survol_interface_numero=4;
   if(mouse_button==1 && mouse_released==0  )
   {
   SelectDmxDevice(4);
   }
   }
}

//SELECTION DE L UNIVERS
if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+230 && mouse_x<cfgdmx_X+300 )
{
   if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) && myDMXinterfaceis==1) //artnet
   {
   ArtNetSendUniverse.DrawOutline(CouleurLigne.WithAlpha(0.5));
   if(mouse_button==1 &&  mouse_released==0 )
   {
   Univers=atoi(numeric);  if(Univers>15){Univers=15;}
   reset_numeric_entry();
   numeric_postext=0;

   mouse_released=1;
   }
   }

}

//SELECTION DE L ADRESSE OUT ARTNET OU DU VCOM POUR LES INTERFACES DMX
if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+320 && mouse_x<cfgdmx_X+490 )
{
   if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) && myDMXinterfaceis==1) //artnet
   {
   ArtNetSendAdress.DrawOutline(CouleurLigne.WithAlpha(0.7));
   if(mouse_button==1 &&  mouse_released==0  && numeric_postext>0)
   {
   Close_dmx_interface();
   sprintf(ip_artnet,numeric);
   reset_numeric_entry();
   Init_dmx_interface();
   mouse_released=1;
   }
   }

}


//SPECIFIC A CHAQUE INTERFACE
if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+520 && mouse_x<cfgdmx_X+620 )
{
   if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) && myDMXinterfaceis==1) //artnet BROADCAST MODE   ON OFF
   {
   ArtNetBroadcastMode.DrawOutline(CouleurLigne.WithAlpha(0.7));

   if(mouse_button==1 &&  mouse_released==0 )
   {
   ArtNetBroadcastMode.DrawOutline(CouleurLigne.WithAlpha(0.7));
   Close_dmx_interface();
   if(index_broadcast==0)
   {
   index_broadcast=1;
   Init_dmx_interface();
   }
   else if(index_broadcast==1)
   {
   index_broadcast=0;
   Init_dmx_interface();
   }
   mouse_released=1;
   }
   }
}

//SPECIFIC A CHAQUE INTERFACE <ARTNET SUITE>
if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+670 && mouse_x<cfgdmx_X+770 )
{
   if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) ) //artpoll for devices
   {
   ArtNetPollforDevices.DrawOutline(CouleurLigne.WithAlpha(0.7));

   if(mouse_button==1 &&  mouse_released==0 )
   {
   if (myDMXinterfaceis!=1)//dans le cas d un art poll avec interface usb
   {
    initialisation_client_artnet();
    ConstructArtPoll();
    }

   if(index_art_polling==0)
   {
   reset_poll_list();
   ticks_poll=0;
   index_art_polling=1;
   index_show_artpoll_reply_content=1;
   nbrbytessended=sendto(sockartnet, ArtPollBuffer,sizeof( ArtPollBuffer),0,(SOCKADDR*)&sinS,sinsize);
   }
  else if(index_art_polling==1)
   {
   index_art_polling=0;
   if (myDMXinterfaceis!=1)//dans le cas d un art poll avec interface usb
   {fermeture_client_artnet();}
   }
   mouse_released=1;
   }

   }
}
//DOUBLE DMX
if(window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+770 && mouse_x<cfgdmx_X+830 )
{
   if( mouse_y>(cfgdmx_Y+60) && mouse_y< (cfgdmx_Y+80) ) //double dmx
   {
   ArtNetDoubleDMX.DrawOutline(CouleurLigne.WithAlpha(0.7));

   if(mouse_button==1 &&  mouse_released==0 &&  myDMXinterfaceis!=1)
   {
   index_artnet_doubledmx=toggle(index_artnet_doubledmx);
   mouse_released=1;
   switch(index_artnet_doubledmx)
   {
   case 0:
         fermeture_client_artnet();
   break;
   case 1:
         initialisation_client_artnet();
         //ConstructArtPoll();
         ConstructArtPollReply();
         nbrbytessended=sendto(sockartnet, ArtPollBuffer,sizeof( ArtPollBuffer),0,(SOCKADDR*)&sinS,sinsize);
         //ArtNet
         ArtDmx();
         //nbrbytessended=sendto(sockartnet, ArtDmxBuffer,sizeof( ArtDmxBuffer),0,(SOCKADDR*)&sinS,sinsize);
   break;

   }
    }
    }
}
//ENTTEC PRO IN MODULE

if (window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+270 && mouse_x<cfgdmx_X+420 && mouse_y>cfgdmx_Y+120 && mouse_y<cfgdmx_Y+140 )
{
EnttecProIN.Draw(CouleurFond.WithAlpha(0.5));

   if(mouse_button==1 &&  mouse_released==0 )
   {

   if (index_init_EnttecPROIN_ok==0)
   {   Detect_EnttecProIn() ;
       Open_ProIn();
   }
   else if (index_init_EnttecPROIN_ok==1)
   {   Close_ProIn() ; index_init_EnttecPROIN_ok=0;}

   }
   mouse_released=1;
}

//sunlite allows IN
if (window_focus_id==W_CFGMENU && mouse_x>cfgdmx_X+240 && mouse_x<cfgdmx_X+390 && mouse_y>cfgdmx_Y+180 && mouse_y<cfgdmx_Y+210 && myDMXinterfaceis==5)
{
SunliteAllowsIN.Draw(CouleurFond.WithAlpha(0.5));
if(mouse_button==1 &&  mouse_released==0 &&  window_focus_id==920)
   {
   index_allow_sunlite_dmxIN=toggle(index_allow_sunlite_dmxIN);
   mouse_released=1;
   }
}



}//fin condition etre 920 fenetre maitre


/////////////////////////////////////////////////////////////////////////////////////
if(myDMXinterfaceis==1){   DeviceArtNetDevice.DrawOutline(CouleurLevel); }
else if(myDMXinterfaceis==2){   DeviceEnttecOpen.DrawOutline(CouleurLevel); }
else if(myDMXinterfaceis==3){   DeviceEnttecPro.DrawOutline(CouleurLevel); }
else if(myDMXinterfaceis==4)
{
DeviceSunlite.DrawOutline(CouleurLevel);
petitchiffre.Print("Version:",cfgdmx_X+400, cfgdmx_Y+190);
petitchiffre.Print(ol::ToString(sunlite_version_number),cfgdmx_X+460, cfgdmx_Y+190);
petitchiffre.Print("Serial:",cfgdmx_X+500, cfgdmx_Y+190);
petitchiffre.Print(ol::ToString(sunlite_serial_number),cfgdmx_X+550, cfgdmx_Y+190);
petitchiffre.Print(string_sunlite_is,cfgdmx_X+670, cfgdmx_Y+190);
}

if(index_art_polling==1)
{
  ArtNetPollforDevices.DrawOutline(CouleurLevel);
}

if(index_artnet_doubledmx==1)
{
ArtNetDoubleDMX.Draw(CouleurFader);
}
//////////////////////////////////////////////

if (index_init_EnttecPROIN_ok==1)
{
EnttecProIN.DrawOutline(CouleurLevel);
}
/////////////////////////////////////////////

/////////////////////////////////////////////

switch(index_allow_sunlite_dmxIN)
{
case 0:
petitchiffre.Print("DMX-IN OFF", cfgdmx_X+250, cfgdmx_Y+190);
break;
case 1:
SunliteAllowsIN.Draw(CouleurSurvol);
petitchiffre.Print("DMX-IN ON", cfgdmx_X+250, cfgdmx_Y+190);
break;

}



//affichage
sprintf(string_title_panel_config,"DMX CONFIGURATION PANEL");


petitpetitchiffre.Print("Universe" ,(cfgdmx_X+220), (cfgdmx_Y+50));
petitpetitchiffre.Print("To IP" ,(cfgdmx_X+350), (cfgdmx_Y+50));
petitpetitchiffre.Print("Mode" ,(cfgdmx_X+560), (cfgdmx_Y+50));
petitpetitchiffre.Print("Call" ,(cfgdmx_X+710), (cfgdmx_Y+50));
////////////////////////////////////////////////////////////////////////////////
petitchiffre.Print("ART-NET" ,(cfgdmx_X+20), (cfgdmx_Y+70));
petitchiffre.Print(ol::ToString(Univers),(cfgdmx_X+240), (cfgdmx_Y+70));
petitchiffre.Print(ip_artnet,(cfgdmx_X+340), (cfgdmx_Y+70));
if(index_broadcast==0)
{petitchiffre.Print("UNICAST" ,(cfgdmx_X+540), (cfgdmx_Y+70));}
else if (index_broadcast==1)
{petitchiffre.Print("BROADCAST" ,(cfgdmx_X+540), (cfgdmx_Y+70));}
petitchiffre.Print("ART-POLL",(cfgdmx_X+690), (cfgdmx_Y+70));
petitpetitchiffre.Print("Double",(cfgdmx_X+780), (cfgdmx_Y+65));
petitpetitchiffre.Print("DMX",(cfgdmx_X+790), (cfgdmx_Y+75));
////////////////////////////////////////////////////////////////////////////////
petitchiffre.Print("ENTTEC-OPEN-DMX" ,(cfgdmx_X+20), (cfgdmx_Y+100));
petitchiffre.Print("ENTTEC-PRO OUT /VCOM" ,(cfgdmx_X+20), (cfgdmx_Y+130));
petitchiffre.Print(ol::ToString(istheresomeone_in_enttecpro),(cfgdmx_X+170), (cfgdmx_Y+130));
petitchiffre.Print("ENTTEC-PRO IN /VCOM" ,(cfgdmx_X+250), (cfgdmx_Y+130));
petitchiffre.Print(ol::ToString(vcom_inposition_is),(cfgdmx_X+390), (cfgdmx_Y+130));

////////////////////////////////////////////////////////////////////////////////
petitchiffre.Print("SUNLITE SIUDI " ,(cfgdmx_X+20), (cfgdmx_Y+190));
////////////////////////////////////////////////////////////////////////////////

Rect DmxFeedbackZone(Vec2D((cfgdmx_X+10), (cfgdmx_Y+265)),Vec2D(560,25));
DmxFeedbackZone.SetRoundness(5);
DmxFeedbackZone.Draw(CouleurFond.WithAlpha(0.5));
petitchiffre.Print("DMX feedback: >>",(cfgdmx_X+20), (cfgdmx_Y+280));
petitchiffrerouge.Print(string_display_dmx_params,(cfgdmx_X+130), (cfgdmx_Y+280));

affect_dmx_in(cfgdmx_X+710,cfgdmx_Y+200);

return(0);
}
int do_logical_TheGrid_commands ( int xb, int yb, int num_grid_player)
{

//accélérometer du player
if(mouse_x>xb-5 && mouse_x<xb+127+5 && mouse_y>=yb+30 && mouse_y<=yb+30+10 )
{
if(Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1508+num_grid_player,Midi_Faders_Affectation_Mode);
}
else
{
 if(grid_player_slave[num_grid_player]==0)
 {
  set_mouse_range(xb-5,yb+30,xb+127+5,yb+30+10);
  grid_crossfade_speed[num_grid_player]=mouse_x-xb;
  if(grid_crossfade_speed[num_grid_player]<0){grid_crossfade_speed[num_grid_player]=0;}
  else  if(grid_crossfade_speed[num_grid_player]>127){grid_crossfade_speed[num_grid_player]=127;}
  //integration gridplayer 1 au sequenciel
  if(index_link_speed_crossfade_to_gpl1==1 && num_grid_player==0)
  {
   grid_crossfade_speed[0]=crossfade_speed;
   midi_levels[1508]=crossfade_speed;
  }
  gridder_prepare_cross(num_grid_player,index_grider_selected[num_grid_player],index_grider_step_is[num_grid_player]);
 }
}
}

////////////////SLAVE MODE////////////////////////////////////////////////////
if(mouse_x>xb+150 && mouse_x<xb+150+40 && mouse_y>yb+25 && mouse_y<yb+25+15)
{
if(mouse_released==0)
{
if(Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1504+num_grid_player,Midi_Faders_Affectation_Mode);
}
else
{
grid_player_slave[num_grid_player]=toggle(grid_player_slave[num_grid_player]);
}
mouse_released=1;
}
}




for(int sp=0;sp<4;sp++)
{
if( mouse_x>xb && mouse_x<xb+10 && mouse_y>yb+70+(sp*20) && mouse_y<yb+70+(sp*20)+10 )
{
if( mouse_released==0 )
{
 if( Midi_Faders_Affectation_Type!=0)
 {
 attribute_midi_solo_affectation(1512+(sp*4)+num_grid_player,Midi_Faders_Affectation_Mode);
 }
 else
 {
 switch(sp)
 {
 case 0:
 grider_goto_mode[num_grid_player]=toggle(grider_goto_mode[num_grid_player]);
 break;
 case 1:
 grider_count_mode[num_grid_player]=toggle(grider_count_mode[num_grid_player]);
 break;
 case 2:
 grider_seekto_mode[num_grid_player]=toggle(grider_seekto_mode[num_grid_player]);
 break;
 case 3:
 grider_stoplay_mode[num_grid_player]=toggle(grider_stoplay_mode[num_grid_player]);
 break;
 default:
 break;
 }
 }
 mouse_released=1;
}
}
}//fin boucle4

//Goto Grid num
if( index_enable_edit_Grider==1  && mouse_x>xb+105 && mouse_x<xb+105+30 && mouse_y>yb+70 && mouse_y<yb+70+15 )
{
 if(  mouse_released==0 )
 {
 grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][0]=atoi(numeric)-1;
 if(grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][0]<0)
 {grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][0]=-1;}//désaffectation
 if(grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][0]>127)
 {grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][0]=127;}
 reset_numeric_entry();
 mouse_released=1;
 }
}
//Goto step num
if(index_enable_edit_Grider==1  &&  mouse_x>xb+150 && mouse_x<xb+150+40 && mouse_y>yb+70 && mouse_y<yb+70+15 )
{
if( mouse_released==0)
 {
  grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][1]=atoi(numeric)-1;
 if(grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][1]<0)
 {grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][1]=-1;}//désaffectation
 if(grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][1]>1023)
 {grid_goto[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][1]=1023;}
 reset_numeric_entry();
 mouse_released=1;
 }
}

//count num
if( index_enable_edit_Grider==1  && mouse_x>xb+150 && mouse_x<xb+150+40 && mouse_y>yb+90 && mouse_y<yb+90+15  )
{
if( mouse_released==0)
 {
 grid_count[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]=atoi(numeric);
 if(grid_count[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]<0)
 {
 grid_count[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]=0;
 }
 reset_numeric_entry();
 mouse_released=1;
 }
}


//Seek step num
if( index_enable_edit_Grider==1  && mouse_x>xb+150 && mouse_x<xb+150+40 && mouse_y>yb+110 && mouse_y<yb+110+15  )
{
if( mouse_released==0)
 {
  grid_seekpos[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]=atoi(numeric)-1;
 if(grid_seekpos[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]<0)
 {grid_seekpos[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]=-1;}//désaffectation
 if(grid_seekpos[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]>1023)
 {grid_seekpos[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]=1023;}
 reset_numeric_entry();
 mouse_released=1;
 }
}

//Stoplay button
if( index_enable_edit_Grider==1  && mouse_x>xb+100 && mouse_x<xb+100+90 && mouse_y>yb+130 && mouse_y<yb+130+15 && mouse_b&1 && mouse_released==0)
{
 grid_stoplay[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]=toggle(grid_stoplay[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]);
 mouse_released=1;
}
return(0);
}
int do_logical_TheGrid_divers( int xb, int yb, int num_grid_player)
{
//affect to dock
 if(mouse_x>xb+60 && mouse_x<xb+60+50 && mouse_y>yb && mouse_y<yb+30 &&  mouse_released==0)
 {

index_do_dock=index_affect_color_to_dock;
  if(num_grid_player==gridplayer_to_affect_is)
  {
  reset_index_actions();
  index_do_dock=0;
  }
  else  {
        reset_index_actions();
        reset_indexs_confirmation();
        gridplayer_to_affect_is=num_grid_player;
        index_do_dock=1;
        }


  mouse_released=1;
 }

 if(  index_enable_edit_Grider==1 && mouse_x>xb && mouse_x<xb+10 && mouse_y>yb+45 && mouse_y<yb+45+10 && mouse_released==0)
 {
 to_step_editing_mode[num_grid_player]=toggle(to_step_editing_mode[num_grid_player]);
 mouse_released=1;
 }

 if( index_enable_edit_Grider==1 && mouse_x>xb+60 && mouse_x<xb+60+40 && mouse_y>yb+45 && mouse_y<yb+45+15 && mouse_released==0  )
 {
 int tempstepto=atoi(numeric)-1;
 if(tempstepto>index_grider_step_is[num_grid_player] && tempstepto<1023)
 {index_StepTo[num_grid_player]=tempstepto;}
 reset_numeric_entry();
 mouse_released=1;
 }

 ///////////COPY TO ////////////////////////////////////////////////////////////



 //copy mode
 if(  index_enable_edit_Grider==1 && mouse_x>xb && mouse_x<xb+50 && mouse_y>yb+75 && mouse_y<yb+75+15 && mouse_released==0)
 {
  index_for_copy_grid=1;
  index_grid_tostep_or_not=to_step_editing_mode[num_grid_player];
  from_gridstep_to=index_StepTo[num_grid_player];
  destination_grid_for_copy= index_Grid_copyto[num_grid_player][0];
  destination_step_for_copy= index_Grid_copyto[num_grid_player][1];
  grid_to_clear=index_grider_selected[num_grid_player];       //utilisé pour menus confirm
  step_grid_to_clear=index_grider_step_is[num_grid_player]; //utilisé pour les menus confirm
  index_ask_confirm=1;
  mouse_released=1;
 }

  //insert mode
 if( index_enable_edit_Grider==1 &&  mouse_x>xb+55 && mouse_x<xb+55+50 && mouse_y>yb+75 && mouse_y<yb+75+15 )
 {
  index_for_insert_grid=1;
  destination_step_for_copy= index_Grid_copyto[num_grid_player][1];//le nombre de steps à insérer après la position actuelle
  grid_to_clear=index_grider_selected[num_grid_player];       //utilisé pour menus confirm
  step_grid_to_clear=index_grider_step_is[num_grid_player]; //utilisé pour les menus confirm
  index_ask_confirm=1;
  mouse_released=1;
 }
 //grid   entry
 if(index_enable_edit_Grider==1 && mouse_x>xb && mouse_x<xb+30 && mouse_y>yb+95 && mouse_y<yb+95+15 && mouse_released==0)
 {
 int tempstepto=atoi(numeric)-1;
 if(tempstepto>=0 && tempstepto<127)
 {index_Grid_copyto[num_grid_player][0]=tempstepto;}
  reset_numeric_entry();
  mouse_released=1;
 }
 //step entry
 if(index_enable_edit_Grider==1 && mouse_x>xb+45 && mouse_x<xb+45+40 && mouse_y>yb+95 && mouse_y<yb+95+15 && mouse_released==0 )
 {
  int tempstepto=atoi(numeric)-1;
 if(tempstepto>=0 && tempstepto<1023)
 {index_Grid_copyto[num_grid_player][1]=tempstepto;}
  reset_numeric_entry();
  mouse_released=1;
  }

  //snap fader
 if( index_enable_edit_Grider==1  &&  mouse_x>xb && mouse_x<xb+105 && mouse_y>yb+135 && mouse_y<yb+135+15 && mouse_released==0)
 {
 if(index_do_dock==1 && numeric_postext>0)
 {
 int getfad=atoi(numeric)-1;
 if(getfad>=0 && getfad<48)
 {GplSnapFader[num_grid_player]=getfad;}
 reset_numeric_entry();
  mouse_released=1;
  index_do_dock=0;
  }
  else//enregistrement
  {
  for(int i=0;i<513;i++)
   {
   if(i+grider_begin_channel_is+1<513)
   {
   grid_levels[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][i]=FaderDoDmx[(GplSnapFader[num_grid_player])][i+grider_begin_channel_is];
   }
   }
   mouse_released=1;
  }
 }



if(num_grid_player==0 )//asservissement speed au séquenciel
{
if(mouse_x>xb && mouse_x<xb+105 && mouse_y>yb+115 && mouse_y<yb+115+15 && mouse_released==0)
{
if(Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(1540,Midi_Faders_Affectation_Mode);
}

else
{
index_link_speed_crossfade_to_gpl1=toggle(index_link_speed_crossfade_to_gpl1);
if(index_link_speed_crossfade_to_gpl1==1)
{  grid_crossfade_speed[0]=crossfade_speed;
   midi_levels[1508]=crossfade_speed;
}
}
mouse_released=1;
}
}

return(0);
}
int do_logical_TheStepBox(int xb,int yb, int num_grid_player)
{

//STEP IS

//Step minus
if(mouse_x>xb & mouse_x<xb+20 && mouse_y>yb && mouse_y<yb+20 )
{
if( mouse_released==0)
{
if(Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1484+num_grid_player,Midi_Faders_Affectation_Mode);
}
else
{
  gridplayer_step_minus(num_grid_player);
 }
  mouse_released=1;
}
}
 //Step plus
if(mouse_x>xb+60 & mouse_x<xb+60+20 && mouse_y>yb && mouse_y<yb+20 )
{
if( mouse_released==0)
{
if(Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1488+num_grid_player,Midi_Faders_Affectation_Mode);
}
else
{
  gridplayer_step_plus(num_grid_player);
}
  mouse_released=1;
 }
}

//set +127 box pour les pas
if(mouse_x>xb+60 && mouse_x<xb+60+20 && mouse_y>yb-6 && mouse_y<yb-6+5)
{
if( mouse_released==0)
 {
 if( Midi_Faders_Affectation_Type!=0)//config midi
 {
 attribute_midi_solo_affectation(1536+num_grid_player,Midi_Faders_Affectation_Mode);
 }
 mouse_released=1;
}
}
//chargement d'un pas, ou affectation d'un temps ou clear  du pas
if(mouse_x>xb+22 & mouse_x<xb+22+35 && mouse_y>yb-5 && mouse_y<yb-5+30 )
 {
if( mouse_released==0)
 {
 if( Midi_Faders_Affectation_Type!=0)//config midi
 {
 attribute_midi_solo_affectation(1532+num_grid_player,Midi_Faders_Affectation_Mode);
 }
 else
 {
 if(numeric_postext>0 && index_affect_time==0 && index_main_clear==0 && index_do_dock==0 )
                      {
                      int step_to_affect_to_grid=0;
                      step_to_affect_to_grid=atoi(numeric);
                      if(step_to_affect_to_grid>0 && step_to_affect_to_grid<1024)
                      {
                       index_grider_step_is[num_grid_player]=step_to_affect_to_grid-1;
                       if(grider_seekto_mode[num_grid_player]==1 && grid_seekpos[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]]>0 )//seek position
                       {index_grider_seek_pos[num_grid_player]=grid_seekpos[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]];}
                      }
                      reset_numeric_entry();
                      }
 else if (numeric_postext>0  && index_do_dock==1 && index_enable_edit_Grider==1)//charge mem
 {
  int mem_to_affect_to_grid=0;
  mem_to_affect_to_grid=int(atof(numeric)*10);
  if(MemoiresExistantes[mem_to_affect_to_grid]==1)
  {
    for(int i=1;i<513;i++)
   {
   if(i+grider_begin_channel_is+1<513)
   {
   grid_levels[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][i+1]=Memoires[mem_to_affect_to_grid][i+grider_begin_channel_is+1];
   }
   }
   reset_numeric_entry();
   index_do_dock=0;
  }
 }
 else if (index_do_dock==1 && index_enable_edit_Grider==1)//charge circuits
 {
 if(index_affect_time==0)
 {
 switch(index_blind)
 {
 case 0:
  for(int i=1;i<513;i++)
 {
  grid_levels[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][i-1]=bufferSaisie[i];
  bufferSaisie[i]=0;
 }
 break;
  case 1:
  for(int i=1;i<513;i++)
 {
  grid_levels[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][i-1]=bufferBlind[i];
  bufferBlind[i]=0;
 }
 break;
 }
 }
  else if(index_affect_time==1 )
 {
 switch(to_step_editing_mode[num_grid_player])
 {
 case 0:
                      for(int ty=0;ty<4;ty++)
                      {
                      if(index_type_of_time_to_affect[ty]==1)
                      {
                      grid_times[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][ty]=
                      (time_minutes*60)+time_secondes+(0.01*time_centiemes);
                      }
                      }
                      gridder_prepare_cross(num_grid_player, index_grider_selected[num_grid_player], index_grider_step_is[num_grid_player]);
 break;
 case 1://step to step mode
 if(index_grider_step_is[index_grider_selected[num_grid_player]]<index_StepTo[num_grid_player])
 {
 for(int st=index_grider_step_is[num_grid_player];st<=index_StepTo[num_grid_player];st++)
 {
                       for(int ty=0;ty<4;ty++)
                      {
                      if(index_type_of_time_to_affect[ty]==1)
                      {
                      grid_times[index_grider_selected[num_grid_player]][st][ty]=
                      (time_minutes*60)+time_secondes+(0.01*time_centiemes);
                      }
                      }
 }
 }
 break;
 }
 index_affect_time=0;
 }

 index_do_dock=0;
 }
 else if(index_do_modify==1 && index_enable_edit_Grider==1)
 {
 switch(index_blind)
 {
 case 0:
  for(int i=1;i<513;i++)
 {
  if(Selected_Channel[i]==1)
  {
  grid_levels[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][i-1]=bufferSaisie[i];
  bufferSaisie[i]=0;
 }
 }
 break;
  case 1:
  for(int i=1;i<513;i++)
 {
 if(Selected_Channel[i]==1)
 {
  grid_levels[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][i-1]=bufferBlind[i];
  bufferBlind[i]=0;
 }
 }
 break;
 }
 index_do_modify=0;
 }

 else if(index_do_report==1 && index_enable_edit_Grider==1)
 {

 for (int u=1;u<513;u++)
 {
 if(bufferSequenciel[u] >= bufferFaders[u])
 {
  grid_levels[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][u-1]
 =  bufferSequenciel[u];
 }
 if(bufferFaders[u]>bufferSequenciel[u])
 {
grid_levels[index_grider_selected[num_grid_player]][index_grider_step_is[num_grid_player]][u-1]=bufferFaders[u];
 }
 Selected_Channel[u]=0;
 }

 index_do_report=0;
 }

 else if(index_main_clear==1 && index_affect_time==0 && index_enable_edit_Grider==1 )
 {
 grid_to_clear=index_grider_selected[num_grid_player];

  switch(to_step_editing_mode[num_grid_player])
 {
 case 0:
 step_grid_to_clear=index_grider_step_is[num_grid_player];
 index_ask_confirm=1;
 index_clear_a_grid_step=1;
 break;
 case 1:
 index_ask_confirm=1;
 step_grid_to_clear=index_grider_step_is[num_grid_player];
 index_clear_a_grid_serie_step=1;
 index_for_grid_stepto=index_StepTo[num_grid_player];
 break;
 }
 }
 }
 mouse_released=1;
 }

}

 return(0);
}
int do_logical_deroule_repertoire_classical_save(int xrep, int yrep, char name_of_rep[25])
{


for (int y=0;y<8;y++)
{


if(window_focus_id==W_SAVE && mouse_x>xrep+5 && mouse_x<xrep+155 && mouse_y>(yrep+175+(y*20)) && mouse_y<(yrep+190+(y*20)))
{

if(mouse_button==1 && mouse_released==0)
{
savefile_selected=(y+line_save);
sprintf(savefile_name,list_save_files[savefile_selected]);
mouse_released=1;
}
}

}
//nom du spectacle

if(window_focus_id==W_SAVE && mouse_x>xrep+5 && mouse_x<xrep+245 && mouse_y>yrep+347 && mouse_y<yrep+377)
{

if(mouse_button==1 && mouse_released==0 && index_type==1)
{

for (int tt=0;tt<24;tt++)
{
savefile_name[tt]=numeric[tt];
}
reset_numeric_entry();
index_type=0;
mouse_released=1;
}
}

if(window_focus_id==W_SAVE && mouse_x>xrep+208 && mouse_x<xrep+232)
{
if(mouse_y>yrep+188 && mouse_y<yrep+212)
{

if(mouse_button==1)
{

if(line_save>0){line_save--;}
mouse_released=1;
}
}
else if(mouse_y>yrep+298 && mouse_y<yrep+322)
{

if(mouse_button==1)
{

if(line_save<127){line_save++;}
mouse_released=1;
}
}
}
///////////////////////////////////////////////////////////////////////////////
//save button
if(window_focus_id==W_SAVE && mouse_x>xrep+40 && mouse_x<xrep+110 && mouse_y>yrep+390 && mouse_y<yrep+420)
{

if(mouse_button==1 && mouse_released==0)
{

if(strcmp(savefile_name,"")==0){sprintf(savefile_name,"unnamed");}
index_do_saveshow=1;
index_ask_confirm=1;
mouse_released=1;
}
}

////////////////////////////////////////////////////////////////////////////////
//load button
if(window_focus_id==W_SAVE && mouse_x>xrep+140 && mouse_x<xrep+210 && mouse_y>yrep+390 && mouse_y<yrep+420)
{
if(mouse_button==1 && mouse_released==0)
{

if(strcmp(savefile_name,"")==1)
{
index_do_loadshow=1;
index_ask_confirm=1;
}
mouse_released=1;
}
}

////////////////////////////////////////////////////////////////////////////////
//reset button

if(window_focus_id==W_SAVE && mouse_x>xrep+280 && mouse_x<xrep+350 && mouse_y>yrep+390 && mouse_y<yrep+420)
{

if(mouse_button==1 && mouse_released==0)
{
index_do_resetshow=1;
index_ask_confirm=1;
mouse_released=1;
}
}
return(0);
}
int do_core_config( int x_cfg_sc,int y_cfg_sc, int largeur_cfg_sc, int hauteur_cfg_sc)
{
petitchiffre.Print("Max Calculations:", x_cfg_sc+15, y_cfg_sc+40);
Line(Vec2D( x_cfg_sc+15, y_cfg_sc+50),Vec2D( x_cfg_sc+120, y_cfg_sc+50)).Draw(CouleurLigne);

int def_param=0;
int def_param_min=1;
int def_param_max=1;

for (int l=0;l<7;l++)
{
Rect Param(Vec2D(x_cfg_sc+120,y_cfg_sc+60+(l*30)),Vec2D(50,25));
Param.SetRoundness(7.5);
Param.Draw(CouleurFond.WithAlpha(0.5));
switch(l)
{
case 0:
petitchiffre.Print("Faders", x_cfg_sc+15,y_cfg_sc+75+(l*30));
petitchiffre.Print(ol::ToString(core_user_define_nb_faders), x_cfg_sc+135,y_cfg_sc+75+(l*30));
def_param_max=48;
def_param_min=1;
break;
case 1:
petitchiffre.Print("Docks", x_cfg_sc+15,y_cfg_sc+75+(l*30));
petitchiffre.Print(ol::ToString(core_user_define_nb_docks), x_cfg_sc+140,y_cfg_sc+75+(l*30));
def_param_max=6;
break;
case 2:
petitchiffre.Print("Chasers", x_cfg_sc+15,y_cfg_sc+75+(l*30));
petitchiffre.Print(ol::ToString(core_user_define_nb_chasers), x_cfg_sc+135,y_cfg_sc+75+(l*30));
def_param_max=128;
break;
case 3:
petitchiffre.Print("Tracks/Chasers", x_cfg_sc+15,y_cfg_sc+75+(l*30));
petitchiffre.Print(ol::ToString(core_user_define_nb_tracks_per_chasers), x_cfg_sc+135,y_cfg_sc+75+(l*30));
def_param_max=24;
break;
case 4:
petitchiffre.Print("Gridplayers", x_cfg_sc+15,y_cfg_sc+75+(l*30));
petitchiffre.Print(ol::ToString(core_user_define_nb_gridplayers), x_cfg_sc+140,y_cfg_sc+75+(l*30));
def_param_max=4;
break;
case 5:
petitchiffre.Print("Bangers", x_cfg_sc+15,y_cfg_sc+75+(l*30));
petitchiffre.Print(ol::ToString(core_user_define_nb_bangers), x_cfg_sc+135,y_cfg_sc+75+(l*30));
def_param_max=128;
break;
case 6:
petitchiffre.Print("Echo", x_cfg_sc+15,y_cfg_sc+75+(l*30));
petitchiffre.Print(ol::ToString(core_user_define_nb_echo), x_cfg_sc+135,y_cfg_sc+75+(l*30));
def_param_max=24;
break;
}
if(window_focus_id==920 && mouse_x>x_cfg_sc+120 && mouse_x<x_cfg_sc+120+50 && mouse_y>y_cfg_sc+60+(l*30) && mouse_y<y_cfg_sc+60+(l*30)+25)
{
Param.DrawOutline(CouleurLigne);
if(mouse_b&1 && mouse_released==0  &&  numeric_postext>0)
{
def_param=atoi(numeric);
if(def_param<=def_param_max && def_param>=def_param_min)
{
switch(l)
{
case 0:
core_user_define_nb_faders=def_param;
break;
case 1:
core_user_define_nb_docks=def_param;
for(int i=0;i<48;i++)//core adapt
{
for(int d=0;d<6;d++)
{
DockIsSelected[i][d]=0;
}

DockIsSelected[i][0]=1;
}
break;
case 2:
core_user_define_nb_chasers=def_param;
break;
case 3:
core_user_define_nb_tracks_per_chasers=def_param;
nbre_track_visualisables=core_user_define_nb_tracks_per_chasers;
if(nbre_track_visualisables>8){nbre_track_visualisables=8;}
break;
case 4:
core_user_define_nb_gridplayers=def_param;
break;
case 5:
core_user_define_nb_bangers=def_param;
break;
case 6:
core_user_define_nb_echo=def_param;
break;
}
mouse_released=1;
reset_numeric_entry();
}
}
}
}

petitchiffre.Print("Do Calculations:", x_cfg_sc+200, y_cfg_sc+40);
Line(Vec2D( x_cfg_sc+200, y_cfg_sc+50),Vec2D( x_cfg_sc+305, y_cfg_sc+50)).Draw(CouleurLigne);
char tmp_state_core[8];
for (int l=0;l<9;l++)
{
Rect BParam(Vec2D(x_cfg_sc+300,y_cfg_sc+60+(l*25)),Vec2D(50,20));
BParam.SetRoundness(7.5);
BParam.Draw(CouleurFond.WithAlpha(0.5));
switch(core_do_calculations[l])
{
case 0:
sprintf(tmp_state_core,"/Off");
break;
case 1:
BParam.Draw(CouleurFader);
sprintf(tmp_state_core,"/On");
break;
}
switch(l)
{
case 0:
petitchiffre.Print("Faders", x_cfg_sc+200,y_cfg_sc+75+(l*25));
break;
case 1:
petitchiffre.Print("CueList", x_cfg_sc+200,y_cfg_sc+75+(l*25));
break;
case 2:
petitchiffre.Print("Banger", x_cfg_sc+200,y_cfg_sc+75+(l*25));
break;
case 3:
petitchiffre.Print("Trichromy", x_cfg_sc+200,y_cfg_sc+75+(l*25));
break;
case 4:
petitchiffre.Print("VideoTracking", x_cfg_sc+200,y_cfg_sc+75+(l*25));
break;
case 5:
petitchiffre.Print("Chasers", x_cfg_sc+200,y_cfg_sc+75+(l*25));
break;
case 6:
petitchiffre.Print("Grid", x_cfg_sc+200,y_cfg_sc+75+(l*25));
break;
case 7:
petitchiffre.Print("Ch. Macros", x_cfg_sc+200,y_cfg_sc+75+(l*25));
break;
case 8:
petitchiffre.Print("Echo", x_cfg_sc+200,y_cfg_sc+75+(l*25));
break;
default:
break;
}
petitchiffre.Print(tmp_state_core,x_cfg_sc+310,y_cfg_sc+75+(l*25));
if(window_focus_id==920 && mouse_x>x_cfg_sc+305 && mouse_x<x_cfg_sc+305+50 && mouse_y>y_cfg_sc+60+(l*25) && mouse_y<y_cfg_sc+60+(l*25)+20
&& mouse_released==0)
{
core_do_calculations[l]=toggle(core_do_calculations[l]);
mouse_released=1;
}

}

petitchiffre.Print("FPS RATE:", x_cfg_sc+370, y_cfg_sc+40);
Line(Vec2D( x_cfg_sc+370, y_cfg_sc+50),Vec2D( x_cfg_sc+485, y_cfg_sc+50)).Draw(CouleurLigne);
for (int l=0;l<2;l++)
{
Rect BCParam(Vec2D(x_cfg_sc+470,y_cfg_sc+60+(l*30)),Vec2D(50,25));
BCParam.SetRoundness(7.5);
BCParam.Draw(CouleurFond.WithAlpha(0.5));
switch(l)
{
case 0:
petitchiffre.Print("DMX:", x_cfg_sc+370, y_cfg_sc+75+(l*30));
petitchiffre.Print(ol::ToString(BPS_RATE), x_cfg_sc+485, y_cfg_sc+75+(l*30));
break;
case 1:
petitchiffre.Print("DMX IN:", x_cfg_sc+370, y_cfg_sc+75+(l*30));
petitchiffre.Print(ol::ToString(dmxINrate), x_cfg_sc+485, y_cfg_sc+75+(l*30));
break;
default:
break;
}
if(window_focus_id==920 && mouse_x>x_cfg_sc+470 && mouse_x<x_cfg_sc+470+50 && mouse_y>y_cfg_sc+60+(l*30) && mouse_y<y_cfg_sc+60+(l*30)+25)
{
BCParam.DrawOutline(CouleurLevel);
if(mouse_b&1 && mouse_released==0  &&  numeric_postext>0)
{
def_param=atoi(numeric);
switch(l)
{
case 0://BPS RATE
if(def_param>=10 && def_param<=250)
{
BPS_RATE=def_param;
ticker_rate = BPS_TO_TIMER(BPS_RATE);
install_int_ex(ticker , ticker_rate);
reset_numeric_entry();
}
break;
case 1://DMX IN RATE
if(def_param>=10 && def_param<=50)
{
dmxINrate=def_param;
ticker_dmxIn_rate = BPS_TO_TIMER(dmxINrate);
install_int_ex(ticker_dmxIn , ticker_dmxIn_rate);
reset_numeric_entry();
}
break;
}
mouse_released=1;
}
}
}

 return(0);
}
int do_logical_Grider_Box(int xb, int yb)
{

/////////////nbre Gridplayers affichage///////////////////////////

for(int o=0;o<core_user_define_nb_gridplayers;o++)
{
if( mouse_x>xb+540+(o*15) && mouse_x<xb+540+(o*15)+10 && mouse_y>yb+20 && mouse_y<yb+20+10)
{
if( mouse_released==0)
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1472+o,Midi_Faders_Affectation_Mode);
}
else
{
index_show_grid_player[o]=toggle(index_show_grid_player[o]);
refresh_hauteur_fenetre_grider();
}
mouse_released=1;
}
}
}
//paramètres de grid
if( mouse_y>yb+15 && mouse_y<yb+15+20 )
{
//////def chan begin
if(mouse_x>xb+245 && mouse_x<xb+245+40 &&  index_enable_edit_Grider==1)//chan edit
{
if(mouse_released==0 )
{
int temp_begchan=atoi(numeric);
if(temp_begchan>0 && temp_begchan<512)
{
grider_begin_channel_is=temp_begchan;
}
reset_numeric_entry();
mouse_released=1;
}
}
if(mouse_x>xb+315 && mouse_x<xb+315+40 &&  index_enable_edit_Grider==1 )//col edit
{
if(mouse_released==0)
{
int temp_col=atoi(numeric);
if(temp_col>0 && temp_col<=24)
{
grider_nb_col=temp_col;
}
reset_numeric_entry();
mouse_released=1;
}
}
if(mouse_x>xb+385 && mouse_x<xb+385+40 &&  index_enable_edit_Grider==1)//rows edit
{

if(mouse_released==0 )
{
int temp_row=atoi(numeric);
if(temp_row>0 && temp_row<=24)
{
grider_nb_row=temp_row;
refresh_hauteur_fenetre_grider();
}
reset_numeric_entry();
mouse_released=1;
}
}
if(mouse_x>xb+430 && mouse_x<xb+430+50)//edit mode
{
if(mouse_released==0 )
{
index_enable_edit_Grider=toggle(index_enable_edit_Grider);
if(index_enable_edit_Grider==0)
{
for(int i=0;i<4;i++)
{
to_step_editing_mode[i]=0;
}
}
mouse_released=1;
}

}
}

//Global grid viewer

////Affichage viewer
switch(show_global_view_grider)
{
case 0:
hauteurGlobalGridviewer=0;
break;
case 1:
hauteurGlobalGridviewer=100+(grider_nb_row*size_preview_case);
do_logical_GlobalGridViewer(xb,yb+40,size_preview_case);  //x y taille de previsu de la grille
break;
}

if(mouse_x>xb+495 && mouse_x<xb+495+40 && mouse_y>yb+20 && mouse_y<yb+20+10)
{
show_global_view_grider=toggle(show_global_view_grider);
refresh_hauteur_fenetre_grider();
mouse_released=1;
}


//AFFICHAGE DES GRID PLAYERS

int numerodeplayer_affiche=0;
for(int yo=0;yo<core_user_define_nb_gridplayers;yo++)
{
if(index_show_grid_player[yo]==1)
{
do_logical_Grid_player(xb, yb+50+hauteurGlobalGridviewer+(numerodeplayer_affiche*(60+(grider_facteur_hauteur*size_grille))), yo);
numerodeplayer_affiche++;
}
}

return(0);
}
int do_logical_Interface_Trichromie(int xchroma, int ychroma, int rayon, int largeurchroma)
{

/////////////////TRICHRO / QUADRI CHOOSE//////////////////////////////////////

if(mouse_x>xchroma-60 && mouse_x<xchroma+80 && mouse_y>ychroma-190 && mouse_y<ychroma-160)
{

if(index_quadri==0){index_quadri=1;dock_color_type[dock_color_selected]=1;}
else if(index_quadri==1){index_quadri=0;dock_color_type[dock_color_selected]=0;}
mouse_released=1;
}


//GEL LIST BUTTON
if(mouse_x>xchroma+90 && mouse_x<xchroma+150 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
show_gel_list=toggle(show_gel_list);
mouse_released=1;
}

/////////////////////AFFECTATION ON / OFF AUX DOCKS FADERS///////////////////////////

if(mouse_x>xchroma+20 && mouse_x<xchroma+150 && mouse_y>ychroma+300 && mouse_y< ychroma+330)
{
if(index_affect_color_to_dock==0)
{
reset_index_actions();
reset_indexs_confirmation();
index_affect_color_to_dock=1;
}
else
{
reset_index_actions();
}
index_do_dock=index_affect_color_to_dock;
mouse_released=1;
}
/////////////////////////////////////////////////////////////////////////////////

//////////////////////ROUE DE COULEUR//////////////////////////////////////////////////////

//AFFECTATION MIDI
if( Midi_Faders_Affectation_Type!=0)//config midi
  {
  //midi report
  switch(miditable[0][497])
  {
  case 0: sprintf(thetypinfo,"Note");break;
  case 1: sprintf(thetypinfo,"Key On");break;
  case 2: sprintf(thetypinfo,"Key Off");break;
  case 4: sprintf(thetypinfo,"Ctrl Change");break;
  }
  sprintf(string_last_midi_id,"COLOR WHEEL FADER is Ch: %d Pitch: %d Typ: %s" , miditable[1][497],miditable[2][497],thetypinfo);

  if(mouse_x>xchroma-140 && mouse_x<xchroma+140 && mouse_y>ychroma-140 && mouse_y<ychroma+140)
  {
    attribute_midi_solo_affectation(497,Midi_Faders_Affectation_Mode);
    mouse_released=1;
   }
}


/////////////////////DOCKING DES COULEURS////////////////////////////////////////
//emplacement des box pour actions de storage RVB sur 6 presets

//affectation des circuits aux RVB Y

if(mouse_y>ychroma+165 && mouse_y<ychroma+185)
{
if(mouse_x> xchroma-130 && mouse_x< xchroma-80 )//RED
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,0);}
couleur_to_affect=0;
bool there_is_asel_chan=0;

switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1)
{there_is_asel_chan=1;break;}
}

if(there_is_asel_chan==1 && (index_do_dock==1|| index_do_modify==1 || index_do_report==1))
{index_do_affect_color_trichro=1;index_ask_confirm=1;}

else {index_do_affect_color_trichro=0;index_ask_confirm=0;sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_red;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_red;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly RED result");
break;
}
mouse_released=1;
}

else if (mouse_x> xchroma-65 && mouse_x< xchroma-15 )//GREEN
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,1);}
couleur_to_affect=1;
bool there_is_asel_chan=0;
switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{if(Selected_Channel[p]==1){there_is_asel_chan=1;break;}}
if(there_is_asel_chan==1 && (index_do_dock==1|| index_do_modify==1 || index_do_report==1))
{index_do_affect_color_trichro=1;index_ask_confirm=1;}
else {sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_green;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_green;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly GREEN result");
break;
}
mouse_released=1;
}

else if (mouse_x> xchroma && mouse_x< xchroma+50 )//BLUE
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,2);}

couleur_to_affect=2;
bool there_is_asel_chan=0;
switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{if(Selected_Channel[p]==1){there_is_asel_chan=1;break;}}
if(there_is_asel_chan==1 && (index_do_dock==1|| index_do_modify==1 || index_do_report==1)){index_do_affect_color_trichro=1;index_ask_confirm=1;}
else {sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_blue;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_blue;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly BLUE result");
break;
}
mouse_released=1;
}

else if (mouse_x> xchroma+65 && mouse_x< xchroma+115 )//YELLOW
{
if (index_inspekt==1){show_who_is_in_dock_color(dock_color_selected,3);}
couleur_to_affect=3;
bool there_is_asel_chan=0;
switch(index_paste_on_the_fly)
{
case 0:
for(int p=1;p<513;p++)
{if(Selected_Channel[p]==1){there_is_asel_chan=1;break;}}
if(there_is_asel_chan==1&& (index_do_dock==1|| index_do_modify==1 || index_do_report==1)){index_do_affect_color_trichro=1;index_ask_confirm=1;}
else {sprintf(string_Last_Order,"No channel selected to store as color");}
break;
case 1:
if(index_blind==0)
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferSaisie[p]=my_yellow;}
}
}
else
{
for(int p=1;p<513;p++)
{
if(Selected_Channel[p]==1){bufferBlind[p]=my_yellow;}
}
}
sprintf(string_Last_Order,"Pasted On the Fly YELLOW result");
break;
}
mouse_released=1;
}
}


//midi out de la roue

if(mouse_x> xchroma+140-10 && mouse_x< xchroma+140+10 && mouse_y>ychroma+110-10 && mouse_y<ychroma+110+10)
{

  if(midi_send_out[497]==0){midi_send_out[497]=1; }
  else if(midi_send_out[497]==1){midi_send_out[497]=0; }
  mouse_released=1;
  }

raccrochage_midi_logical_circulaire (xchroma-6, ychroma, 497, 125, 125);



//premiere rangee de dock colors

for (int dock_color=0;dock_color<4;dock_color++)
{
if(mouse_x>xchroma-130+(65*dock_color) && mouse_x<xchroma-80+(65*dock_color) && mouse_y>ychroma+215 && mouse_y<ychroma+235)
{
if( Midi_Faders_Affectation_Type!=0)
{
if(dock_color==0 && Midi_Faders_Affectation_Type==2)
{attribute_midi_to_control(949,Midi_Faders_Affectation_Type,Midi_Faders_Affectation_Mode);}
else{attribute_midi_solo_affectation(949+dock_color, Midi_Faders_Affectation_Mode);}
}
else
{
dock_color_selected=dock_color;
load_etat_picker_dans_dockcolor(dock_color_selected);
sprintf(string_Last_Order,">>Dock Color Selected %d",(dock_color_selected+1));
mouse_released=1;
}
}
}
//deuxième rangee de dockcolors
for (int dock_colortwo=0;dock_colortwo<4;dock_colortwo++)
{
if(mouse_x>xchroma-130+(65*dock_colortwo) && mouse_x<xchroma-80+(65*dock_colortwo) && mouse_y>ychroma+255 && mouse_y<ychroma+275)
{
if(Midi_Faders_Affectation_Type!=0)
{
attribute_midi_solo_affectation(949+(dock_colortwo+4), Midi_Faders_Affectation_Mode);
}
else
{
dock_color_selected=dock_colortwo+4;
load_etat_picker_dans_dockcolor(dock_color_selected);
sprintf(string_Last_Order,">>Dock Color Selected %d",dock_color_selected+1);
mouse_released=1;
}
}
}

//PASTE ON THE FLY
if(mouse_x>xchroma-150 && mouse_x<xchroma-20 && mouse_y>ychroma+300 && mouse_y< ychroma+330)
{
if(mouse_b&1 &&  mouse_released==0 && window_focus_id==902)
{
index_paste_on_the_fly=toggle(index_paste_on_the_fly);
mouse_released=1;
}
}


//GEL LIST
if(show_gel_list==1)
{

if(mouse_x>xchroma+180 && mouse_x<xchroma+250 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
index_gel_type_selected++;
if(index_gel_type_selected>3)index_gel_type_selected=0;
mouse_released=1;
}
//numeric or designer list
if(mouse_x>xchroma+260 && mouse_x<xchroma+330 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
show_designer_list=toggle(show_designer_list);
switch(show_designer_list)
{
case 0://numerical order
break;
case 1://designer order
break;
}
mouse_released=1;
}

//saisie d une ref de gelat
if(mouse_x>xchroma+340 && mouse_x<xchroma+390 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
call_ref_number=atoi(numeric);
mouse_released=1;
if(call_ref_number<10000 && call_ref_number!=0)
{

//repositionnemennt de la liste
for (int i=0;i<10000;i++)
{
if(refs_of_gels[index_gel_type_selected][i]==call_ref_number )
{
gel_position[index_gel_type_selected]=i;
report_gels_to_rvb_trichro(index_gel_type_selected,gel_position[index_gel_type_selected]);
break;
}
}
reset_numeric_entry();
}

}
//+ - Index gelatine
if(mouse_y>ychroma-187 && mouse_y<ychroma-163)
{
//- index
if(mouse_x>xchroma+398 && mouse_x<xchroma+422)
{
if(gel_position[index_gel_type_selected]>10)gel_position[index_gel_type_selected]-=10;
mouse_released=1;
}
//+ index
if(mouse_x>xchroma+428 && mouse_x<xchroma+452)
{
if(gel_position[index_gel_type_selected]<10000-10)gel_position[index_gel_type_selected]+=10;
mouse_released=1;
}
}

//Transmission calculation
if(mouse_x>xchroma+510 && mouse_x<xchroma+550 && mouse_y>ychroma-185 && mouse_y<ychroma-165)
{
index_use_transmission=toggle(index_use_transmission);
mouse_released=1;
}

//sélection gel
for(int i=0;i<30;i++)
{
if( mouse_x>xchroma+175 && mouse_x<xchroma+485 && mouse_y>ychroma-150+(i*16) && mouse_y<ychroma-134+(i*16) )
{
call_ref_number=refs_of_gels[index_gel_type_selected][gel_position[index_gel_type_selected]+i];
report_gels_to_rvb_trichro(index_gel_type_selected,gel_position[index_gel_type_selected]+i);
mouse_released=1;
}
}
//fin gel list
}


return(0);
}
int do_logical_Sequenciel_Window(int xseq, int yseq,int largeur_seq,int hauteur_seq)
{

do_logical_refresh_vision_memories(xseq,yseq);
do_logical_x1_x2(xseq,yseq-25);

////////////////////MENUS///////////////////////////////////////////////////////
//options hautes

///alink
if(mouse_x>xseq+180 && mouse_x<xseq+180+35 && mouse_y>yseq+50 && mouse_y<yseq+50+15)
{
if(index_link_is_on==0){index_link_is_on=1;}
else if(index_link_is_on==1){index_link_is_on=0;}
mouse_released=1;
}

///banger
if(mouse_x>xseq+223 && mouse_x<xseq+263 && mouse_y>yseq+50 && mouse_y<yseq+50+15)
{
index_banger_is_on=toggle(index_banger_is_on);
mouse_released=1;
}

//grid player 1 embeded
if(mouse_x>xseq+275 && mouse_x<xseq+275+30 && mouse_y>yseq+50 && mouse_y<yseq+50+15 )
{
show_gridplayer_in_seq=toggle(show_gridplayer_in_seq);
mouse_released=1;
}



/////menus bas
int rangee_y= yseq+180+(35*(nbre_memoires_visualisables_en_preset+1));
int index_atoi=0;
for (int op=0;op<7;op++)
{
///actions mouse
if(mouse_x>xseq+20+(op*60) && mouse_x<xseq+20+(op*60)+50 && mouse_y>rangee_y && mouse_y<rangee_y+20)
{
switch(op)
{
case 0:         //create
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(768,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
reset_indexs_confirmation();
index_do_create_mem=1;
index_ask_confirm=1;
}
break;
case 1://delete mem
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(769,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
reset_indexs_confirmation();
index_do_delete_mem=1;
index_ask_confirm=1;
}
break;
case 2://stage minus
if(  Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(770,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
    if(index_go==0 && index_go_back==0 && index_pause==0)
           {
           position_onstage=mem_before_one;
           }
           else {index_go=0;index_pause=0; index_go_back=0;}

refresh_mem_onstage(position_onstage);
detect_mem_before_one();
detect_mem_preset();
refresh_mem_onpreset(position_preset);
niveauX1=255; niveauX2=0;
refresh_banger_wx();
refresh_integrated_gridplayer1();
}
break;
case 3://stage +
if(  Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(771,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{

 if(index_go==0 && index_go_back==0 && index_pause==0)
           {
           position_onstage=position_preset;
           }
            else {index_go=0;index_pause=0; index_go_back=0;}

refresh_mem_onstage(position_onstage);
detect_mem_before_one();
detect_mem_preset();
refresh_mem_onpreset(position_preset);
niveauX1=255; niveauX2=0;
refresh_banger_wx();
refresh_integrated_gridplayer1();
}
break;
case 4://preset -
if(Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(772,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
index_go=0;index_pause=0; index_go_back=0;
detect_mem_preset_previous();
refresh_mem_onpreset(position_preset);
niveauX2=0;
}
break;
case 5://preset +
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(773,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
index_go=0;index_pause=0; index_go_back=0;
detect_next_preset();
refresh_mem_onpreset(position_preset);
niveauX2=0;
}
break;
case 6://goto
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1645,Midi_Faders_Affectation_Mode);
mouse_released=1;
}
else
{
if(numeric_postext>0)
{
index_atoi=(int)(atof(numeric)*10);
if(MemoiresExistantes[index_atoi]==1)
{
position_preset=index_atoi;
refresh_mem_onpreset(position_preset);
reset_numeric_entry();
numeric_postext=0;
}
}
}
break;

default:
break;
}//fin des switch
mouse_released=1;
}
}

//grid player 1 embarqué
if(show_gridplayer_in_seq==1)
{

//UP DOWN griders number selected

if(mouse_x>xseq+880-12 && mouse_x<xseq+880+12 && mouse_y>yseq+40-12 && mouse_y<yseq+40+12)
{

if(mouse_released==0)
{
if(Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1476,Midi_Faders_Affectation_Mode);
}
else
{
if(index_grider_selected[0]>0)
{index_grider_selected[0]--;}
}
 mouse_released=1;
}
}


if( mouse_x>xseq+910-12 && mouse_x<xseq+910+12 && mouse_y>yseq+40-12 && mouse_y<yseq+40+12)
{

if( mouse_released==0)
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1480,Midi_Faders_Affectation_Mode);
}
else
{
if(index_grider_selected[0]<127){index_grider_selected[0]++;}
}
mouse_released=1;
}
}

do_logical_TheStepBox(xseq+660,yseq+90,0);
do_logical_ThePlayCommands(xseq+760,yseq+90,0);
do_logical_TheGrid_commands(xseq+660,yseq+130,0);//pos x, posy y, num player

if(mouse_x>xseq+690 && mouse_x<xseq+690+105 && mouse_y>yseq+295 && mouse_y<yseq+295+15 && mouse_released==0)
{
if( Midi_Faders_Affectation_Type!=0)
{
 attribute_midi_solo_affectation(1540,Midi_Faders_Affectation_Mode);
}

else
{
index_link_speed_crossfade_to_gpl1=toggle(index_link_speed_crossfade_to_gpl1);
if(index_link_speed_crossfade_to_gpl1==1)
{  grid_crossfade_speed[0]=crossfade_speed;
   midi_levels[1508]=crossfade_speed;
}
}
mouse_released=1;
}
}


return(0);
}
int do_logical_deroule_repertoire_export_import(int xrep, int yrep, char name_of_rep[25])
{

//////////////////////LISTE DOSSIERS ETC///////////////////////////////////////

for (int y=0;y<8;y++)
{


if(window_focus_id==W_SAVE && mouse_x>xrep+5 && mouse_x<xrep+155 && mouse_y>(yrep+175+(y*20)) && mouse_y<(yrep+190+(y*20)))
{

if(mouse_button==1 && mouse_released==0)
{
importfile_selected=(y+line_import);
if(y+line_import<127)
{sprintf(importfile_name,list_import_files[importfile_selected]);  }
check_import_type();
mouse_released=1;
}
}

 //fin des 8 lignes
}



//selection depuis chaine de caracteres pour export plot


if(window_focus_id==W_SAVE && mouse_x>xrep+5 && mouse_x<xrep+205 && mouse_y>yrep+347 && mouse_y<yrep+367)
{

if(mouse_button==1 && mouse_released==0 && index_type==1 )
{
for (int tt=0;tt<24;tt++)
{
importfile_name[tt]=numeric[tt];
}
reset_numeric_entry();
index_type=0;
check_import_type();
mouse_released=1;
}
}




//////////////////UP DOWN LINE IMPORT/////////////////////

if(window_focus_id==W_SAVE && mouse_x>xrep+208 && mouse_x<xrep+232)
{
if(mouse_y>yrep+188 && mouse_y<yrep+212)
{

if(mouse_button==1)
{
if(line_import>0){line_import--;}
mouse_released=1;
}
}
else if(window_focus_id==W_SAVE && mouse_y>yrep+298 && mouse_y<yrep+322)
{

if(mouse_button==1)
{
if(line_import<127){line_import++;}
mouse_released=1;
}
}
}



/////////////////////////////SAVE LOAD && CONDITIONS////////////////////////////////
/*switch (index_export_choice)
{
case 0://ascii
enable_export=1;
enable_import=1;
break;
case 1://schwz
enable_export=0;
enable_import=1;
break;
case 2://alq
enable_export=0;
enable_import=1;
break;
case 3://pdf
enable_export=1;
enable_import=0;
break;

}*/ //mis dans  affichage
////////////////////////////////////////////////////////////////////////////////
if(enable_export==1)
{
if(window_focus_id==W_SAVE && mouse_x>xrep+40 && mouse_x<xrep+110 && mouse_y>yrep+390 && mouse_y<yrep+420)
{
if(mouse_button==1 && mouse_released==0)
{
index_do_export=1;
index_ask_confirm=1;
mouse_released=1;
}
}
}
////////////////////////////////////////////////////////////////////////////////
if(enable_import==1)
{
if(window_focus_id==W_SAVE && mouse_x>xrep+140 && mouse_x<xrep+210 && mouse_y>yrep+390 && mouse_y<yrep+420)
{
if(mouse_button==1 && mouse_released==0)
{
index_do_import=1;
index_ask_confirm=1;
mouse_released=1;
}
}
}
return(0);
}
int do_logical_TheCallGridBox(int xb, int yb, int num_grider)
{

if(mouse_x>xb+10 && mouse_x<xb+10+50 && mouse_y>yb && mouse_y<yb+20)
{
if(mouse_released==0)
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1528+num_grider,Midi_Faders_Affectation_Mode);
}
else
{
if(numeric_postext>0)
{
int temp_num_grid=atoi(numeric);
if(temp_num_grid>0 && temp_num_grid<128)
{
//rajout
bool was_playing=grider_is_playing[num_grider];
grider_is_playing[num_grider]=0;
grid_niveauX1[num_grider]=255;
grid_niveauX2[num_grider]=0;
grid_floatX1[num_grider]=255.0;
grid_floatX2[num_grider]=0.0;
grid_fraction_X2_in[num_grider]=0.0;
grid_fraction_X1_out[num_grider]=0.0;

index_grider_selected[num_grider]=temp_num_grid-1;//avant modif du 5 nov que cette ligne la

//rajout
index_grider_step_is[num_grider]=0;
//chargement à la volée rafraichissement grid
gridder_prepare_cross(num_grider, index_grider_selected[num_grider], index_grider_step_is[num_grider]);


if(grider_seekto_mode[num_grider]==1 && grid_seekpos[index_grider_selected[num_grider]][index_grider_step_is[num_grider]]>0)//seek position original fonction
  {index_grider_seek_pos[num_grider]=grid_seekpos[index_grider_selected[num_grider]][index_grider_step_is[num_grider]];}

//rajout
if(was_playing==1){grider_is_playing[num_grider]=1;}

reset_numeric_entry();
}
}
else if(index_main_clear==1)
{
 grid_to_clear=index_grider_selected[num_grider];
 step_grid_to_clear=index_grider_step_is[index_grider_selected[num_grider]];
 index_ask_confirm=1;
 index_clear_a_grid=1;
}
}
mouse_released=1;
}
}

if(mouse_x>xb+70 && mouse_x<xb+70+170 && mouse_y>yb && mouse_y<yb+20 && index_type==1 && mouse_released==0)
{
 for(int tt=0;tt<24;tt++)
 {
 grider_name[index_grider_selected[num_grider]][tt]=numeric[tt];
 }
 grider_name[index_grider_selected[num_grider]][24]='\0';
 reset_numeric_entry();numeric_postext=0; if(index_text_auto_close==1){index_type=0;}
mouse_released=1;
}

//UP DOWN griders number selected

if(mouse_x>xb+265-12 && mouse_x<xb+265+12 && mouse_y>yb+10-12 && mouse_y<yb+10+12)
{

if(mouse_released==0)
{
if( Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1476+num_grider,Midi_Faders_Affectation_Mode);
}
else
{
if(index_grider_selected[num_grider]>0)
{index_grider_selected[num_grider]--;}
}
 mouse_released=1;
}
}


if( mouse_x>xb+295-12 && mouse_x<xb+295+12 && mouse_y>yb+10-12 && mouse_y<yb+10+12)
{

if( mouse_released==0)
{
if(Midi_Faders_Affectation_Type!=0)//config midi
{
attribute_midi_solo_affectation(1480+num_grider,Midi_Faders_Affectation_Mode);
}
else
{
if(index_grider_selected[num_grider]<127){index_grider_selected[num_grider]++;}
}
mouse_released=1;
}
}
return(0);
}
int do_logical_Draw_Channel_Preset_Title(int xchan, int ychan, int prst_v)
{


 if(window_focus_id==0 && mouse_button==1  && mouse_released==0 && prst_v!=0 )
 {
 if(mouse_y>ychan && mouse_y<ychan+20  )
 {
 //TITRE VIEW
 if(mouse_x> xchan+40 && mouse_x<xchan+40+210)
 {
 if(prst_v>0 && index_type==1 )
 {
 sprintf( channel_view_Name[prst_v],numeric);
 reset_numeric_entry();
 numeric_postext=0;
 mouse_released=1;
 }
 }
 // Mem sel
 else if(mouse_x>  xchan+435 && mouse_x<xchan+435+20)
 {
 if(channel_view_type_of_behaviour[prst_v]!=1){channel_view_type_of_behaviour[prst_v]=1;}
 else{channel_view_type_of_behaviour[prst_v]=0;}
 mouse_released=1;
 }
 // fader sel
 else if(mouse_x>  xchan+460 && mouse_x<xchan+460+20 )
 {
 if(channel_view_type_of_behaviour[prst_v]!=2){channel_view_type_of_behaviour[prst_v]=2;}
 else{channel_view_type_of_behaviour[prst_v]=0;}
 mouse_released=1;
 }

 //All sel
  else if(mouse_x>  xchan+485 && mouse_x<xchan+485+30  )
 {
 channel_view_mode_builder[prst_v]=toggle(channel_view_mode_builder[prst_v]);
 mouse_released=1;
 }

 //do build logique sortie car plantage grave à la reconstruction. il faut garder ca dans la boucle affichage
/* else if(mouse_x>  xchan+520 && mouse_x<xchan+520+55 )
 {
 channel_view_is=prst_v;
 if(index_do_dock==1)
 {
 if(channel_view_type_of_behaviour[channel_view_is]==0 &&  channel_view_mode_builder[channel_view_is]==0)
 {index_ask_record_selection_of_view=1 ; index_ask_confirm=1; mouse_released=1;}
 else  {index_ask_build_view=1; index_ask_confirm=1; mouse_released=1;  }
 }

 else if(index_do_modify==1)
 {
 index_ask_modify_selection_of_view=1 ;index_ask_confirm=1;   mouse_released=1;
 }
 else if(index_do_report==1)
 {
 index_ask_report_selection_of_view=1;index_ask_confirm=1;      mouse_released=1;
 }
 else if(index_main_clear==1)
 {
 index_ask_clear_selection_of_view=1;   mouse_released=1;
 }

 } */


 }

 }

 return(0);
}
int do_main_config(int cfgnetw_X, int cfgnetw_Y, int largeurCFGdmxwindow,int hauteurCFGdmxwindow)
{
//config channels
for (int oi=0;oi<5;oi++)
{
Rect UnderParam(Vec2D(cfgnetw_X+155,cfgnetw_Y+55+(oi*30)),Vec2D(50,25));
UnderParam.SetRoundness(7.5);
UnderParam.SetLineWidth(epaisseur_ligne_fader);
UnderParam.Draw(CouleurFond.WithAlpha(0.5));
if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+155 && mouse_x<cfgnetw_X+155+50 && mouse_y>cfgnetw_Y+55+(oi*30) && mouse_y<cfgnetw_Y+55+(oi*30)+25)
{
UnderParam.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
int param_data_in=0;
switch(dmx_view)
{
case 0:
if(oi!=1){param_data_in=(int)(atoi(numeric)*2.55)+1;}
else {param_data_in=atoi(numeric);}
reset_numeric_entry();
break;
case 1:
param_data_in=atoi(numeric);
reset_numeric_entry();
break;
}
switch(oi)
{
case 0:
dmx_view=toggle(dmx_view);
break;
case 1:
default_step_level=param_data_in;
break;
case 2:
check_channel_level=param_data_in;
break;
case 3:
dimmer_check_level=param_data_in;
break;
case 4:
index_blink_change_memories=toggle(index_blink_change_memories);
break;
}
UnderParam.Draw(CouleurBlind);
mouse_released=1;
}
}
}
char string_cfg_main[32];
petitchiffre.Print("Channels: " ,(cfgnetw_X+10), (cfgnetw_Y+40));
Line(Vec2D(cfgnetw_X+10,cfgnetw_Y+45),Vec2D(cfgnetw_X+100,cfgnetw_Y+45)).Draw(CouleurLigne);
petitchiffre.Print("Display mode:", (cfgnetw_X+20), (cfgnetw_Y+70) );
switch(dmx_view)
{
case 0:
sprintf(string_cfg_main,"/100");
break;
case 1:
sprintf(string_cfg_main,"/255");
break;
}
petitchiffre.Print(string_cfg_main, (cfgnetw_X+170), (cfgnetw_Y+70) );

//step level ne varie pas
sprintf(string_cfg_main,"%d", default_step_level);
petitchiffre.Print("Default step level:", (cfgnetw_X+20), (cfgnetw_Y+100) );
petitchiffre.Print(string_cfg_main ,(cfgnetw_X+170), (cfgnetw_Y+100));

switch(dmx_view)
{
case 0:
sprintf(string_cfg_main,"%d", (int)(((float)check_channel_level)/2.55));
break;
case 1:
sprintf(string_cfg_main,"%d", check_channel_level);
break;
}
petitchiffre.Print("Check channels level:", (cfgnetw_X+20), (cfgnetw_Y+130) );
petitchiffre.Print(string_cfg_main ,(cfgnetw_X+170), (cfgnetw_Y+130));

switch(dmx_view)
{
case 0:
sprintf(string_cfg_main,"%d", (int)(((float)dimmer_check_level)/2.55));
break;
case 1:
sprintf(string_cfg_main,"%d", dimmer_check_level);
break;
}
petitchiffre.Print("Check dimmers level:", (cfgnetw_X+20), (cfgnetw_Y+160) );
petitchiffre.Print(string_cfg_main ,(cfgnetw_X+170), (cfgnetw_Y+160));



switch(index_blink_change_memories)
{
case 0:
sprintf(string_cfg_main,"/Off");
break;
case 1:
sprintf(string_cfg_main,"/On");
break;
}
petitchiffre.Print("Show Change/Mem:", (cfgnetw_X+20), (cfgnetw_Y+190) );
petitchiffre.Print(string_cfg_main ,(cfgnetw_X+170), (cfgnetw_Y+190));

/////////////////////////NBRE AUDIO PLAYERS///////////////////////////////////////////////////

Rect UnderParam(Vec2D(cfgnetw_X+155,cfgnetw_Y+235),Vec2D(50,25));
UnderParam.SetRoundness(7.5);
UnderParam.SetLineWidth(epaisseur_ligne_fader);
UnderParam.Draw(CouleurFond.WithAlpha(0.5));

Rect UnderParam2(Vec2D(cfgnetw_X+155,cfgnetw_Y+265),Vec2D(50,20));
UnderParam2.SetRoundness(7.5);
UnderParam2.SetLineWidth(epaisseur_ligne_fader);
UnderParam2.Draw(CouleurFond.WithAlpha(0.5));




if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+155 && mouse_x<cfgnetw_X+155+50 )
{
if( mouse_y>cfgnetw_Y+235 && mouse_y<cfgnetw_Y+235+25)//nbre de channels audio
{
UnderParam.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
int param_data_in=0;
param_data_in=atoi(numeric);
index_nbre_players_visibles=param_data_in;
if(index_nbre_players_visibles<1){index_nbre_players_visibles=1;}
else if(index_nbre_players_visibles>4){index_nbre_players_visibles=4;}
reset_numeric_entry();
UnderParam.Draw(CouleurBlind);
mouse_released=1;
}
}
if(window_focus_id==W_CFGMENU &&  mouse_y>cfgnetw_Y+265 && mouse_y<cfgnetw_Y+265+20)//nbre de channels audio
{
UnderParam2.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
index_preloaded_sounds=toggle(index_preloaded_sounds);
UnderParam2.Draw(CouleurBlind);
mouse_released=1;
}
}
}


petitchiffre.Print("Audio: " ,(cfgnetw_X+10), (cfgnetw_Y+220));
petitchiffre.Print(audio_device_name,(cfgnetw_X+120), (cfgnetw_Y+220));
Line(Vec2D(cfgnetw_X+10,cfgnetw_Y+225),Vec2D(cfgnetw_X+100,cfgnetw_Y+225)).Draw(CouleurLigne);
petitchiffre.Print("Number of Players:", (cfgnetw_X+20), (cfgnetw_Y+250) );
sprintf(string_cfg_main,"%d", index_nbre_players_visibles);
petitchiffre.Print(string_cfg_main ,(cfgnetw_X+170), (cfgnetw_Y+250));
petitchiffre.Print("Preload on read:",(cfgnetw_X+20), (cfgnetw_Y+280));
switch(index_preloaded_sounds)
{
case 0:
sprintf(string_cfg_main,"/Off");
break;
case 1:
sprintf(string_cfg_main,"/On");
break;
}
petitchiffre.Print(string_cfg_main,(cfgnetw_X+170), (cfgnetw_Y+280));



///////////////////DEUXIEME COLONNE

for (int oi=0;oi<8;oi++)
{
Rect UnderParam(Vec2D(cfgnetw_X+365,cfgnetw_Y+55+(oi*30)),Vec2D(50,25));
UnderParam.SetRoundness(7.5);
UnderParam.SetLineWidth(epaisseur_ligne_fader);
UnderParam.Draw(CouleurFond.WithAlpha(0.5));
if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+365 && mouse_x<cfgnetw_X+365+50 && mouse_y>cfgnetw_Y+55+(oi*30) && mouse_y<cfgnetw_Y+55+(oi*30)+25)
{
UnderParam.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
//sab 02/03/2014 unused var int param_data_in=0;

switch(oi)//action souris
{
case 0://Temps par defaut
default_time=atof(numeric);
reset_numeric_entry();
break;
case 1://temps par defaut d un bang
default_time_of_the_bang=atof(numeric);
reset_numeric_entry();
break;
case 2://time digit nbre decimales affichages chasers
index_affichage_digit_time_unit=atoi(numeric)-1;
if(index_affichage_digit_time_unit<=0){index_affichage_digit_time_unit=0;}
else
{
if (index_affichage_digit_time_unit>3)
{index_affichage_digit_time_unit=3;}
reset_numeric_entry();
}
break;
case 3://nbre tracks visualisables chasers
nbre_track_visualisables=atoi(numeric);
if(nbre_track_visualisables<1){nbre_track_visualisables=1;}
if(nbre_track_visualisables>nbre_tracks_par_chaser){nbre_track_visualisables=nbre_tracks_par_chaser;}
reset_numeric_entry();
break;
case 4://midi force mode pour le play
Midi_Force_Go=toggle(Midi_Force_Go);
break;
case 5://nombre cues dans preset view
nbre_memoires_visualisables_en_preset=atoi(numeric);
if(nbre_memoires_visualisables_en_preset<5){nbre_memoires_visualisables_en_preset=5;}
if(nbre_memoires_visualisables_en_preset>25){nbre_memoires_visualisables_en_preset=25;}
hauteur_globale_sequenciel=180+(35*(nbre_memoires_visualisables_en_preset+1))+35;
reset_numeric_entry();
break;
case 6: // on Go light Channel
go_channel_is=atoi(numeric);
if(go_channel_is<1 || ( go_channel_is> 512)){go_channel_is=0;}
reset_numeric_entry();
break;
case 7: // on Pause light Channel
pause_channel_is=atoi(numeric);
if(pause_channel_is<1 || ( pause_channel_is> 512)){pause_channel_is=0;}
reset_numeric_entry();
break;
default:
break;
}
mouse_released=1;
}
}

switch(oi)//affichage
{
case 0://Temps par defaut
petitchiffre.Print("CueList / Bangs / Chasers " ,(cfgnetw_X+225), (cfgnetw_Y+40));
Line(Vec2D(cfgnetw_X+225,cfgnetw_Y+45),Vec2D(cfgnetw_X+410,cfgnetw_Y+45)).Draw(CouleurLigne);
petitchiffre.Print("Record Default time:",cfgnetw_X+235,cfgnetw_Y+70+(oi*30));
petitchiffre.Print(ol::ToString(default_time),cfgnetw_X+380,cfgnetw_Y+70+(oi*30));
break;
case 1:
petitchiffre.Print("Bang stay-on time:",cfgnetw_X+235,cfgnetw_Y+70+(oi*30));
char tmpo[10];
sprintf(tmpo,"%.1f",default_time_of_the_bang);
petitchiffre.Print(tmpo,cfgnetw_X+380,cfgnetw_Y+70+(oi*30));
break;
case 2:
petitchiffre.Print("Time Unit Digits:",cfgnetw_X+235,cfgnetw_Y+70+(oi*30));
petitchiffre.Print(ol::ToString(index_affichage_digit_time_unit+1),cfgnetw_X+380,cfgnetw_Y+70+(oi*30));
break;
case 3:
petitchiffre.Print("Chaser View Tracks:",cfgnetw_X+235,cfgnetw_Y+70+(oi*30));
petitchiffre.Print(ol::ToString(nbre_track_visualisables),cfgnetw_X+380,cfgnetw_Y+70+(oi*30));
break;
case 4:
petitchiffre.Print("GO Midi ForceMode:",cfgnetw_X+235,cfgnetw_Y+70+(oi*30));
switch(Midi_Force_Go)
{
case 0:
petitchiffre.Print("/Off",cfgnetw_X+380,cfgnetw_Y+70+(oi*30));
break;
case 1:
petitchiffre.Print("/On",cfgnetw_X+380,cfgnetw_Y+70+(oi*30));
break;
}
break;
case 5:
petitchiffre.Print("Cues in Preset:",cfgnetw_X+235,cfgnetw_Y+70+(oi*30));
petitchiffre.Print(ol::ToString(nbre_memoires_visualisables_en_preset),cfgnetw_X+380,cfgnetw_Y+70+(oi*30));
break;
case 6:
petitchiffre.Print("Go Channel:",cfgnetw_X+235,cfgnetw_Y+70+(oi*30));
petitchiffre.Print(ol::ToString(go_channel_is),cfgnetw_X+380,cfgnetw_Y+70+(oi*30));
break;
case 7:
petitchiffre.Print("Pause Channel:",cfgnetw_X+235,cfgnetw_Y+70+(oi*30));
petitchiffre.Print(ol::ToString(pause_channel_is),cfgnetw_X+380,cfgnetw_Y+70+(oi*30));
break;
default:
break;
}

}

//quatrieme bloc

petitchiffre.Print("On Start" ,(cfgnetw_X+430), (cfgnetw_Y+40));
Line(Vec2D(cfgnetw_X+430,cfgnetw_Y+45),Vec2D(cfgnetw_X+530,cfgnetw_Y+45)).Draw(CouleurLigne);
petitchiffre.Print("Open Camera",cfgnetw_X+430,cfgnetw_Y+70);
Rect CamOn(Vec2D(cfgnetw_X+525,cfgnetw_Y+55),Vec2D(50,20));
CamOn.SetRoundness(7.5);
CamOn.SetLineWidth(epaisseur_ligne_fader);
CamOn.Draw(CouleurFond.WithAlpha(0.5));

if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+525 && mouse_x<cfgnetw_X+525+50 && mouse_y>cfgnetw_Y+55 && mouse_y<cfgnetw_Y+55+20)
{
CamOn.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
load_camera_on_start=toggle(load_camera_on_start);
CamOn.Draw(CouleurBlind);
mouse_released=1;
}
}
switch(load_camera_on_start)
{
case 0:
sprintf(string_cfg_main,"/Off");
break;
case 1:
sprintf(string_cfg_main,"/On");
break;
}
petitchiffre.Print(string_cfg_main,cfgnetw_X+540,cfgnetw_Y+70);



petitchiffre.Print("Open Arduino",cfgnetw_X+430,cfgnetw_Y+100);
Rect ArduinOn(Vec2D(cfgnetw_X+525,cfgnetw_Y+85),Vec2D(50,20));
ArduinOn.SetRoundness(7.5);
ArduinOn.SetLineWidth(epaisseur_ligne_fader);
ArduinOn.Draw(CouleurFond.WithAlpha(0.5));

if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+525 && mouse_x<cfgnetw_X+525+50 && mouse_y>cfgnetw_Y+85 && mouse_y<cfgnetw_Y+85+20)
{
ArduinOn.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
open_arduino_on_open=toggle(open_arduino_on_open);
ArduinOn.Draw(CouleurBlind);
mouse_released=1;
}
}
switch(open_arduino_on_open)
{
case 0:
sprintf(string_cfg_main,"/Off");
break;
case 1:
sprintf(string_cfg_main,"/On");
break;
}
petitchiffre.Print(string_cfg_main,cfgnetw_X+540,cfgnetw_Y+100);

//iCat enable_iCat
petitchiffre.Print("Open iCat",cfgnetw_X+430,cfgnetw_Y+130);
Rect iCatOn(Vec2D(cfgnetw_X+525,cfgnetw_Y+115),Vec2D(50,20));
iCatOn.SetRoundness(7.5);
iCatOn.SetLineWidth(epaisseur_ligne_fader);
iCatOn.Draw(CouleurFond.WithAlpha(0.5));

if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+525 && mouse_x<cfgnetw_X+525+50 && mouse_y>cfgnetw_Y+115 && mouse_y<cfgnetw_Y+115+20)
{
iCatOn.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
enable_iCat=toggle(enable_iCat);
mouse_released=1;
}
}
switch(enable_iCat)
{
case 0:
sprintf(string_cfg_main,"/Off");
break;
case 1:
sprintf(string_cfg_main,"/On");
break;
}
petitchiffre.Print(string_cfg_main,cfgnetw_X+540,cfgnetw_Y+130);



//PROCESS ACCESS>>multicore

Rect ProcessB(Vec2D(cfgnetw_X+525,cfgnetw_Y+190),Vec2D(50,20));
ProcessB.SetRoundness(7.5);
ProcessB.SetLineWidth(epaisseur_ligne_fader);
ProcessB.Draw(CouleurFond.WithAlpha(0.5));

if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+525 && mouse_x<cfgnetw_X+525+50 && mouse_y>cfgnetw_Y+190 && mouse_y<cfgnetw_Y+190+20)
{
ProcessB.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
index_allow_multicore=toggle(index_allow_multicore);
ProcessB.Draw(CouleurBlind);
mouse_released=1;
if(index_allow_multicore==1 && core_to_assign>0 && core_to_assign<9)
{process_assign_to_core(core_to_assign);}
}
}


Rect ProcessCorB(Vec2D(cfgnetw_X+525,cfgnetw_Y+215),Vec2D(50,20));
ProcessCorB.SetRoundness(7.5);
ProcessCorB.SetLineWidth(epaisseur_ligne_fader);
ProcessCorB.Draw(CouleurFond.WithAlpha(0.5));

if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+525 && mouse_x<cfgnetw_X+525+50 && mouse_y>cfgnetw_Y+215 && mouse_y<cfgnetw_Y+215+20)
{
ProcessCorB.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
core_to_assign=atoi(numeric);
reset_numeric_entry();
if(core_to_assign>0 && core_to_assign<9 && index_allow_multicore==1)
{process_assign_to_core(core_to_assign);}
ProcessCorB.Draw(CouleurBlind);
mouse_released=1;
}
}
petitchiffre.Print("Multicore: " ,(cfgnetw_X+430), (cfgnetw_Y+203));
Line(Vec2D(cfgnetw_X+430,cfgnetw_Y+210),Vec2D(cfgnetw_X+500,cfgnetw_Y+210)).Draw(CouleurLigne);
switch(index_allow_multicore)
{
case 0:
sprintf(string_cfg_main,"/Off");
break;
case 1:
sprintf(string_cfg_main,"/On");
break;
}
petitchiffre.Print(string_cfg_main,(cfgnetw_X+540), (cfgnetw_Y+203));
petitchiffre.Print("Affect to Core:",cfgnetw_X+430,cfgnetw_Y+228);
petitchiffre.Print(ol::ToString(core_to_assign),cfgnetw_X+545,cfgnetw_Y+228);



//suite Fader space
//LargeurEspaceFaderSize

Rect faderSpace(Vec2D(cfgnetw_X+525,cfgnetw_Y+265),Vec2D(50,20));
faderSpace.SetRoundness(7.5);
faderSpace.SetLineWidth(epaisseur_ligne_fader);
faderSpace.Draw(CouleurFond.WithAlpha(0.5));

if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+525 && mouse_x<cfgnetw_X+525+50 && mouse_y>cfgnetw_Y+265 && mouse_y<cfgnetw_Y+265+20)
{
faderSpace.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
LargeurEspaceFaderSize=atoi(numeric);
reset_numeric_entry();
if(LargeurEspaceFaderSize<1024 ){LargeurEspaceFaderSize=1024;}
if(LargeurEspaceFaderSize>largeur_ecran){LargeurEspaceFaderSize=largeur_ecran;}
faderSpace.Draw(CouleurBlind);
mouse_released=1;
}
}
petitchiffre.Print("Fader Space Width: " ,(cfgnetw_X+430), (cfgnetw_Y+255));
Line(Vec2D(cfgnetw_X+430,cfgnetw_Y+260),Vec2D(cfgnetw_X+560,cfgnetw_Y+260)).Draw(CouleurLigne);
petitchiffre.Print(ol::ToString(LargeurEspaceFaderSize),(cfgnetw_X+540), (cfgnetw_Y+280));


////////////////////////////////////////////////////



do_keyboard_conf((cfgnetw_X+620), (cfgnetw_Y+40));


//EXPERT MODE confirmations ou non

Rect ExpertB(Vec2D(cfgnetw_X+740,cfgnetw_Y+225),Vec2D(50,20));
ExpertB.SetRoundness(7.5);
ExpertB.SetLineWidth(epaisseur_ligne_fader);
ExpertB.Draw(CouleurFond.WithAlpha(0.5));
ExpertB.Draw(CouleurFader.WithAlpha(expert_mode*alpha_blinker));

if(window_focus_id==W_CFGMENU && mouse_x> cfgnetw_X+740 && mouse_x<cfgnetw_X+740+50 && mouse_y>cfgnetw_Y+225 && mouse_y<cfgnetw_Y+225+20)
{
ExpertB.DrawOutline(CouleurLevel);
if(mouse_button==1 && mouse_released==0)
{
expert_mode=toggle(expert_mode);
ExpertB.Draw(CouleurBlind);
mouse_released=1;
}
}


petitchiffre.Print("EXPERT MODE: " ,(cfgnetw_X+620), (cfgnetw_Y+240));
switch(expert_mode)
{
case 0:
sprintf(string_cfg_main,"/Off");
break;
case 1:
sprintf(string_cfg_main,"/On");
break;
}
petitchiffre.Print(string_cfg_main,(cfgnetw_X+750), (cfgnetw_Y+240));



return(0);
}