# data file for the Fltk User Interface Designer (fluid)
version 1.0300 
header_name {.H} 
code_name {.C}
comment {//
// Copyright (C) 2008-2010 Jonathan Moore Liles
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
} {in_source in_header
} 

decl {const float STATUS_UPDATE_FREQ = 0.5f;} {private local
} 

decl {class Fl_Flowpack;} {public global
} 

decl {\#include <unistd.h>} {private local
} 

decl {\#include <sys/types.h>} {private local
} 

decl {\#include <sys/wait.h>} {private local
} 

decl {\#include <FL/Fl_Overlay_Window.H>} {private local
} 

decl {\#include <FL/Fl_Menu_Settings.H>} {private local
} 

decl {\#include "Timeline.H"} {private local
} 

decl {\#include "Transport.H"} {private local
} 

decl {\#include "Loggable.H"} {private local
} 

decl {\#include "Project.H"} {private local
} 

decl {\#include "Clock.H"} {public local
} 

decl {\#include <FL/Fl_Flowpack.H>} {private local
} 

decl {\#include <FL/New_Project_Dialog.H>} {private local
} 

decl {\#include "Track.H" // for capture_format} {private local
} 

decl {\#include "Waveform.H" // for options} {private local
} 

decl {\#include "Audio_Region.H" // for options} {private local
} 

decl {\#include "Control_Sequence.H" // for options} {private local
} 

decl {\#include <FL/Fl_File_Chooser.H>} {private local
} 

decl {\#include <FL/Fl_Shared_Image.H>} {private local
} 

decl {\#include <FL/Fl.H>} {private local
} 

decl {\#include <FL/fl_ask.H>} {private local
} 

decl {\#include "Engine/Engine.H"} {private local
} 

decl {\#include "Engine/Audio_File.H" // for supported formats} {private local
} 

decl {\#include <FL/About_Dialog.H>} {private local
} 

decl {extern char project_display_name[256];} {private global
} 

decl {\#include <nsm.h>} {private local
} 

decl {extern nsm_client_t *nsm;} {private global
} 

decl {extern char *user_config_dir;} {private global
} 

decl {extern char *APP_NAME;} {private global
} 

class TLE_Window {open : {public Fl_Overlay_Window}
} {
  Function {TLE_Window(int W, int H, const char *L = 0) : Fl_Overlay_Window( W, H, L )} {open
  } {
    code {} {}
  }
  Function {draw_overlay(void)} {open return_type void
  } {
    code {timeline->draw_overlay();} {}
  }
  Function {~TLE_Window()} {open return_type virtual
  } {
    code {} {}
  }
} 

class TLE {open
} {
  decl {Fl_Color system_colors[3];} {private local
  }
  Function {save_options()} {open
  } {
    code {const char options_filename[] = "options";
  // const char state_filename[] = "state";
  
  // save options
  
  char *path;
  asprintf( &path, "%s/%s", user_config_dir, options_filename );
  ((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Options" ), path );
  free( path );} {}
  }
  Function {save()} {open
  } {
    code {timeline->command_save();} {}
  }
  Function {quit()} {} {
    code {timeline->command_quit();} {}
  }
  Function {open( const char *name )} {} {
    code {timeline->command_load( name, NULL );} {}
  }
  Function {save_timeline_settings()} {open
  } {
    code {if ( ! Project::open() )
	return;
	

// save project local options (Timeline menu)
((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Project/Se&ttings" ), "options" );} {}
  }
  Function {reset_timeline_settings( void )} {open private return_type void
  } {
    code {char path[256];
snprintf( path, sizeof( path ), "%s/%s", user_config_dir, ".default_project_settings" );

((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Project/Se&ttings" ), path );} {}
  }
  Function {load_timeline_settings()} {open
  } {
    code {reset_timeline_settings();


if ( Project::open() )
	((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Project/Se&ttings" ), "options" );

update_menu();

project_name->redraw();} {}
  }
  Function {run()} {} {
    code {update_menu();

// main_window->show();

Fl::lock();

// Fl::run();} {}
  }
  Function {TLE()} {open
  } {
    code {make_window();
	
Fl::visible_focus( 0 );

// constrain window to size of screen.
{
        int sx, sy, sw, sh;

        Fl::screen_xywh( sx, sy, sw, sh );

        main_window->size_range( 947, 500 );
        main_window->size( 947, 600 );

        if ( main_window->w() > sw ||
             main_window->h() > sh )
                main_window->resize( sx, sy, sw, sh );
}

Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );

fl_message_icon()->box( FL_RSHADOW_BOX );
fl_message_icon()->labelcolor( FL_BLACK );
fl_message_icon()->color( FL_RED );
fl_message_font( FL_HELVETICA, 18 );


std::list <const char *> formats;

Audio_File::all_supported_formats( formats );

for ( std::list <const char *>::const_iterator f = formats.begin(); f != formats.end(); ++f )
{
//	capture_format_menu->add( *f, FL_MENU_RADIO, 0, 0, 0 );
//;
	char pat[256];
	snprintf( pat, sizeof( pat ), "&Project/Se&ttings/Capture Format/%s", *f );	

	menubar->add( pat, 0, &TLE::capture_format_cb, this, FL_MENU_RADIO );
}

menubar->picked( menubar->find_item( "&Project/Se&ttings/Capture Format/Wav 24" ) );

char *path;
asprintf( &path, "%s/options", user_config_dir );
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Options" ), path );
free( path );


menubar->add( "&Timeline", 0, 0, const_cast< Fl_Menu_Item *>( timeline->menu->menu() ), FL_SUBMENU_POINTER );


// save a copy of the project settings menu so that we can restore the defaults later
{
	char path[512];
	snprintf( path, sizeof( path ), "%s/%s", user_config_dir, ".default_project_settings" );

	((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Project/Se&ttings" ), path );
}


Loggable::progress_callback( &TLE::progress_cb, this );} {}
  }
  Function {make_window()} {open
  } {
    Fl_Window main_window {
      label {Non Timeline}
      callback {if ( Fl::event_key() != FL_Escape )
	timeline->command_quit();} open
      xywh {204 266 1025 770} type Double resizable
      code0 {o->xclass( APP_NAME );}
      class TLE_Window size_range {947 300 0 0} visible
    } {
      Fl_Group {} {open
        xywh {0 -53 1025 126} box FLAT_BOX
      } {
        Fl_Menu_Bar menubar {open
          private xywh {0 0 1025 25}
        } {
          Submenu {} {
            label {&Project} open
            xywh {5 5 74 25}
          } {
            MenuItem {} {
              label {&Info}
              callback {Project_Info_Dialog pi;

pi.run();}
              xywh {5 5 40 25} deactivate
            }
            Submenu {} {
              label {Se&ttings} open
              xywh {25 25 74 25}
            } {
              MenuItem {} {
                label {&Follow Playhead}
                callback {Timeline::follow_playhead = menu_picked_value( o );}
                xywh {45 45 40 25} type Toggle value 1
              }
              MenuItem {} {
                label {&Center Playhead}
                callback {Timeline::center_playhead = menu_picked_value( o );}
                xywh {55 55 40 25} type Toggle value 1
              }
              Submenu {} {
                label {&Snap to} open
                xywh {25 25 74 25}
              } {
                MenuItem {} {
                  label Bars
                  callback {Timeline::snap_to = Timeline::Bars;}
                  xywh {25 25 40 25} type Radio value 1
                }
                MenuItem {} {
                  label Beats
                  callback {Timeline::snap_to = Timeline::Beats;}
                  xywh {35 35 40 25} type Radio
                }
                MenuItem {} {
                  label Off
                  callback {Timeline::snap_to = Timeline::None;}
                  xywh {45 45 40 25} type Radio
                }
              }
              MenuItem {} {
                label {Magnetic snap}
                callback {Timeline::snap_magnetic = menu_picked_value( o );}
                xywh {35 35 40 25} type Toggle value 1
              }
              Submenu {} {
                label {Capture Format} open
                xywh {25 25 74 25}
              } {}
              MenuItem {} {
                label {Playback Latency Compensation}
                callback {Timeline::playback_latency_compensation = menu_picked_value( o );} selected
                xywh {55 55 40 25} type Toggle
              }
            }
            MenuItem {} {
              label {&New}
              callback {save_timeline_settings();

              
        char *result_path;    

        char *default_path = read_line( user_config_dir, "default_path" );
        result_path = default_path;

        char *path = new_project_chooser( &result_path );

        if ( path )
        {
            if ( ! Project::create( path, NULL ) )
                fl_alert( "Error creating project!" );
            free( path );
        }

        if ( result_path != default_path )
            free(default_path);

        if ( result_path )
        {
            write_line( user_config_dir, "default_path", result_path );
            free( result_path );
        }


load_timeline_settings();

update_menu();

main_window->redraw();}
              xywh {5 5 40 25}
            }
            MenuItem {} {
              label {&Open}
              callback {char *path = read_line( user_config_dir, "default_path" );

const char *name = fl_dir_chooser( "Open Project", path );

free( path );

open( name );}
              xywh {15 15 40 25}
            }
            MenuItem {} {
              label {&Compact}
              callback {int n = fl_choice( "Compacting will replace the project history with a snapshot of the current state.\\nYou will not be able to use Undo to go back beyond this point.\\n\\nThis operation is irreversible!", NULL, "&Cancel", "Pr&ocede with compaction" );

if ( n != 2 )
	return;
	
Project::compact();}
              xywh {25 25 40 25}
            }
            Submenu {} {
              label {I&mport} open
              xywh {20 20 74 25}
            } {
              MenuItem {} {
                label {Import Ardour Session}
                callback {if ( !Project::open() )
{
	fl_alert( "You must create a new project before importing" );
	return;
}

if ( timeline->ntracks() )
{
	fl_alert( "You can only import into an empty session!" );
	return;
}


pid_t pid;
if ( ! (pid = fork()) )
{
	exit( system( "import-ardour-session_gui" ) );
}

char *path = strdup( Project::path() );

Project::close();

int status;

while ( 0 == waitpid( pid, &status, WNOHANG ) )
{
	Fl::wait(0.2);
}

Project::open(path);

free(path);}
                xywh {20 20 40 25}
              }
            }
            Submenu {} {
              label {&Export} open
              xywh {5 5 74 25} hide deactivate
            } {
              MenuItem {} {
                label Project
                xywh {5 5 40 25}
              }
              MenuItem {} {
                label Range
                xywh {15 15 40 25}
              }
            }
            MenuItem {} {
              label {&Quit}
              callback {quit()}
              xywh {45 45 40 25} shortcut 0x40071
            }
          }
          Submenu {} {
            label {&Edit} open
            xywh {5 5 74 25}
          } {
            MenuItem {} {
              label Undo
              callback {timeline->command_undo();}
              xywh {5 5 40 25} shortcut 0x4007a divider
            }
            MenuItem {} {
              label {Select None}
              callback {timeline->select_none();}
              xywh {15 15 40 25} shortcut 0x50061
            }
            MenuItem {} {
              label {Delete  Selected}
              callback {timeline->delete_selected();}
              xywh {25 25 40 25} shortcut 0xffff
            }
          }
          Submenu {} {
            label {T&ransport} open
            xywh {5 5 74 25}
          } {
            MenuItem {} {
              label Start
              callback {transport->locate( 0 );}
              xywh {5 5 40 25} shortcut 0xff50
            }
            MenuItem {} {
              label End
              callback {transport->locate( timeline->length() );}
              xywh {15 15 40 25} shortcut 0xff57
            }
            MenuItem {} {
              label {Play/Stop}
              callback {transport->toggle();}
              xywh {25 25 40 25} shortcut 0x20
            }
            MenuItem {} {
              label Record
              callback {transport->toggle_record();}
              xywh {45 45 40 25} shortcut 0x10072
            }
          }
          MenuItem {} {
            label {&Timeline}
            xywh {5 5 40 25}
          }
          Submenu {} {
            label {&View} open
            xywh {5 5 74 25}
          } {
            Submenu {} {
              label {&Zoom} open
              xywh {5 5 74 25}
            } {
              MenuItem {} {
                label {&In}
                callback {timeline->zoom_in();}
                xywh {25 25 40 25} shortcut 0x2b
              }
              MenuItem {} {
                label {&Out}
                callback {timeline->zoom_out();}
                xywh {35 35 40 25} shortcut 0x5f
              }
              MenuItem {} {
                label {&Fit}
                callback {timeline->zoom_fit();}
                xywh {15 15 40 25} shortcut 0x3d divider
              }
              MenuItem {} {
                label {1 sec.}
                callback {timeline->zoom( 1 );}
                xywh {15 15 40 25} shortcut 0x31
              }
              MenuItem {} {
                label {1 min.}
                callback {timeline->zoom( 60 );}
                xywh {25 25 40 25} shortcut 0x32
              }
              MenuItem {} {
                label {1 hour.}
                callback {timeline->zoom( 60 * 60 );}
                xywh {35 35 40 25} shortcut 0x33
              }
            }
            MenuItem {} {
              label {&Theme}
              callback {fl_theme_chooser();}
              xywh {15 15 40 24}
              code0 {\#include "FL/Fl_Theme_Chooser.H"}
            }
          }
          Submenu {} {
            label {&Options} open
            xywh {5 5 74 25} divider
          } {
            Submenu {} {
              label {&Display} open
              xywh {15 15 74 25}
            } {
              Submenu {} {
                label {&Timeline} open
                xywh {15 15 74 25}
              } {
                MenuItem {} {
                  label {&Measure lines}
                  callback {Timeline::draw_with_measure_lines = menu_picked_value( o );

timeline->redraw();}
                  xywh {15 15 40 25} type Toggle value 1
                }
                MenuItem {} {
                  label {&Cursor Overlay}
                  callback {Timeline::draw_with_cursor_overlay = menu_picked_value( o );

timeline->redraw();}
                  xywh {15 14 40 25} type Toggle value 1
                }
              }
              Submenu {} {
                label {&Waveform} open
                xywh {15 15 74 25}
              } {
                MenuItem {} {
                  label Fill
                  callback {Waveform::fill = menu_picked_value( o );

timeline->redraw();}
                  xywh {25 25 40 25} type Toggle value 1
                }
                MenuItem {} {
                  label Outline
                  callback {Waveform::outline = menu_picked_value( o );

timeline->redraw();}
                  xywh {45 45 40 25} type Toggle value 1
                }
                MenuItem {} {
                  label {Vary color}
                  callback {Waveform::vary_color = menu_picked_value( o );

timeline->redraw();}
                  xywh {35 35 40 25} type Toggle value 1
                }
              }
              Submenu {} {
                label {&Region} open
                xywh {15 15 74 25}
              } {
                MenuItem {} {
                  label {Filled fades}
                  xywh {45 45 40 25} type Toggle value 1
                }
                MenuItem {} {
                  label {Inherit track color}
                  callback {Audio_Region::inherit_track_color = menu_picked_value( o );

timeline->redraw();}
                  xywh {55 55 40 25} type Toggle value 1
                }
                MenuItem {} {
                  label {Show box}
                  callback {Audio_Region::show_box = menu_picked_value( o );

timeline->redraw();}
                  xywh {55 55 40 25} type Toggle value 1
                }
              }
              Submenu {} {
                label {&Control Sequence} open
                xywh {15 15 74 25}
              } {
                MenuItem {} {
                  label Ruled
                  callback {Control_Sequence::draw_with_grid = menu_picked_value( o );

timeline->redraw();}
                  xywh {55 55 40 25} type Toggle value 1
                }
              }
              Submenu {} {
                label {&Track} open
                xywh {15 15 74 25}
              } {
                MenuItem {} {
                  label {Colored tracks}
                  callback {Track::colored_tracks = menu_picked_value( o );

timeline->redraw();}
                  xywh {45 45 40 25} type Toggle value 1
                }
              }
            }
            Submenu {} {
              label {&Behavior} open
              xywh {5 5 74 25}
            } {
              Submenu {} {
                label {&Transport} open
                xywh {5 5 74 25}
              } {
                MenuItem {} {
                  label {Stop Disables Record}
                  callback {transport->stop_disables_record( ((Fl_Menu_*)o)->mvalue()->flags & FL_MENU_VALUE );}
                  xywh {10 10 40 25} type Toggle value 1
                }
                MenuItem {} {
                  label {Loop Playback}
                  callback {transport->loop_enabled( ( ((Fl_Menu_*)o)->mvalue()->flags & FL_MENU_VALUE )) ;}
                  xywh {10 10 40 25} type Toggle
                }
                MenuItem {} {
                  label {Automatically Create Takes}
                  callback {transport->automatically_create_takes( ( ((Fl_Menu_*)o)->mvalue()->flags & FL_MENU_VALUE ));}
                  xywh {10 10 40 25} type Toggle
                }
              }
            }
          }
          Submenu {} {
            label {&Help} open
            xywh {5 5 74 25}
          } {
            MenuItem {} {
              label {&Manual}
              callback {show_help_dialog( "MANUAL" );}
              xywh {15 15 40 25} divider
            }
            MenuItem {} {
              label {&About}
              callback {About_Dialog ab( PIXMAP_PATH "/non-timeline/icon-256x256.png" );

            ab.logo_box->label( VERSION );

        ab.title->label( "Non Timeline" );

        ab.copyright->label( "Copyright (C) 2008-2013 Jonathan Moore Liles" );
        ab.credits->label( "Non Timeline was written from scratch by\\nJonathan Moore Liles for his own use\\n(see the manual).\\n\\nNobody planned. Nobody helped.\\nYou can help now by donating time, money,\\nand/or replacing the rest of Linux Audio\\nwith fast, light, reliable alternatives.\\n" );

        ab.website_url->label( "http://non.tuxfamily.org" );

ab.run();}
              xywh {5 5 40 25}
            }
          }
        }
        Fl_Pack {} {open
          xywh {1 27 584 46} type HORIZONTAL
          code0 {o->spacing( 10 );}
        } {
          Fl_Box {} {
            label {<Transport>}
            xywh {5 28 290 44} color 30
            code0 {transport = o;}
            code1 {o->labeltype( FL_NO_LABEL );}
            class Transport
          }
          Fl_Pack clocks_pack {open
            private xywh {295 30 290 41} type HORIZONTAL
            code0 {o->spacing( 2 );}
          } {
            Fl_Box {} {
              label PLAYHEAD
              private xywh {301 30 137 41} box FLAT_BOX color 47
              code0 {o->type( Clock::HMS );}
              code1 {o->run( &transport->frame );}
              class Clock
            }
            Fl_Box {} {
              label PLAYHEAD
              xywh {440 30 137 41} box FLAT_BOX color 47
              code0 {o->type( Clock::BBT );}
              code1 {o->run( &transport->frame );}
              class Clock
            }
          }
        }
        Fl_Box {} {
          label {<empty>}
          xywh {585 32 155 40} resizable
          code0 {o->labeltype( FL_NO_LABEL );}
        }
        Fl_Group {} {open
          xywh {850 23 175 50}
        } {
          Fl_Box {} {
            label {capture:}
            xywh {910 27 56 14} labelsize 10 align 24
          }
          Fl_Box {} {
            label {playback:}
            xywh {910 43 56 14} labelsize 10 align 24
          }
          Fl_Box {} {
            label {DSP:}
            xywh {910 57 56 14} labelsize 10 align 24
          }
          Fl_Box {} {
            label filesystem
            xywh {855 28 55 18} labelsize 10 align 16
          }
          Fl_Progress capture_buffer_progress {
            label {50%}
            private xywh {965 27 60 14} selection_color 0 labelsize 10
          }
          Fl_Progress cpu_load_progress {
            label {50%}
            private xywh {965 57 60 14} selection_color 0 labelsize 9
          }
          Fl_Progress playback_buffer_progress {
            label {50%}
            private xywh {965 42 60 14} selection_color 0 labelsize 10
          }
          Fl_Progress disk_usage_progress {
            label {50%}
            private xywh {855 43 55 28} selection_color 0 labelsize 10
            code0 {o->type( FL_VERTICAL );}
          }
        }
        Fl_Group {} {open
          xywh {740 31 115 40}
        } {
          Fl_Button solo_blinker {
            label SOLO
            xywh {800 33 50 15} box BORDER_BOX down_box BORDER_BOX color 74 selection_color 92 labelfont 1 labelsize 11 labelcolor 32
            code0 {\#include "FL/Fl_Blink_Button.H"}
            code1 {o->box( FL_ASYM_BOX );}
            code2 {o->down_box( FL_ASYM_BOX );}
            code3 {o->ignore_input( true );}
            class Fl_Blink_Button
          }
          Fl_Button rec_blinker {
            label REC
            xywh {800 53 50 15} box BORDER_BOX down_box BORDER_BOX color 72 selection_color 88 labelfont 1 labelsize 11 labelcolor 32
            code0 {\#include "FL/Fl_Blink_Button.H"}
            code1 {o->box( FL_ASYM_BOX );}
            code2 {o->down_box( FL_ASYM_BOX );}
            code3 {o->ignore_input( true );}
            class Fl_Blink_Button
          }
          Fl_Button selected_blinker {
            label SEL
            xywh {745 53 50 15} box BORDER_BOX down_box BORDER_BOX color 13 selection_color 5 labelfont 1 labelsize 11 labelcolor 32
            code0 {\#include "FL/Fl_Blink_Button.H"}
            code1 {o->box( FL_ASYM_BOX );}
            code2 {o->down_box( FL_ASYM_BOX );}
            code3 {o->ignore_input( true );}
            class Fl_Blink_Button
          }
          Fl_Button seek_blinker {
            label SEEK
            xywh {745 33 50 15} box BORDER_BOX down_box BORDER_BOX color 10 selection_color 2 labelfont 1 labelsize 11 labelcolor 32
            code0 {\#include "FL/Fl_Blink_Button.H"}
            code1 {o->box( FL_ASYM_BOX );}
            code2 {o->down_box( FL_ASYM_BOX );}
            code3 {o->ignore_input( true );}
            class Fl_Blink_Button
          }
        }
        Fl_Box stats_box {
          label {<stats>}
          xywh {745 0 235 25} labelsize 13 labelcolor 53 align 88
        }
        Fl_Button sm_blinker {
          label SM
          xywh {985 6 35 15} box ROUNDED_BOX down_box ROUNDED_BOX color 45 selection_color 93 labelfont 3 labelcolor 39 deactivate
          class Fl_Button
        }
      }
      Fl_Group progress_group {open
        xywh {295 352 450 79} hide
      } {
        Fl_Progress progress {
          label {0%}
          private xywh {295 394 450 37} box ROUNDED_BOX selection_color 55 labelfont 1 labelsize 22
        }
        Fl_Box {} {
          label {Loading...}
          xywh {295 362 450 31} labelfont 1 labelsize 17 align 18
        }
      }
      Fl_Box {} {
        label {<Timeline>}
        xywh {0 75 1025 692} box FLAT_BOX color 47 labeltype NO_LABEL labelsize 100 resizable
        code0 {timeline = o;}
        class Timeline
      }
      Fl_Box project_name {
        label {<project name>}
        private xywh {440 0 305 24} labeltype SHADOW_LABEL labelfont 2
        code0 {o->label( Project::name() );}
      }
    }
  }
  Function {menu_picked_value( const Fl_Menu_ *m )} {private return_type {static int}
  } {
    code {return m->menu()[ m->value() ].flags & FL_MENU_VALUE;} {}
  }
  Function {find_item( Fl_Menu_ *menu, const char *path )} {private return_type {static Fl_Menu_Item *}
  } {
    code {return const_cast<Fl_Menu_Item*>(menu->find_item( path ));} {}
  }
  decl {static void menubar_cb ( void *v )} {private local
  }
  decl {void menubar_cb ( void )} {private local
  }
  Function {update_menu()} {private
  } {
    code {Fl_Menu_Bar *m = menubar;

if ( ! Project::open() )
{
	find_item( m, "&Project/&Export" )->deactivate();
	find_item( m, "&Project/&Compact" )->deactivate();
	find_item( m, "&Project/&Info" )->deactivate();
	
 	find_item( m, "&Project/Se&ttings" )->deactivate();
 	find_item( m, "&Timeline" )->deactivate();

	timeline->deactivate();
	transport->deactivate();
}
else
{
	find_item( m, "&Project/&Export" )->activate();
	find_item( m, "&Project/&Compact" )->activate();
	find_item( m, "&Project/&Info" )->activate();

 	find_item( m, "&Project/Se&ttings" )->activate();
 	find_item( m, "&Timeline" )->activate();
	
	timeline->activate();
	transport->activate();	
}

m->redraw();
project_name->redraw();} {}
  }
  Function {update_progress( Fl_Progress *p, char *s, float v )} {private return_type {static void}
  } {
    code {if ( p->value() != v )
{
p->value( v );

snprintf( s, 5, "%d%%", (int)v );

p->label( s );

}} {}
  }
  Function {update_status()} {open private
  } {
    code {static char cbp[5], pbp[5], clp[5], dup[5];

update_progress( capture_buffer_progress, cbp, timeline->total_input_buffer_percent() );
update_progress( playback_buffer_progress, pbp, timeline->total_output_buffer_percent() );
update_progress( cpu_load_progress, clp, engine ? engine->cpu_load() : 0 );

if ( Project::open() )
   update_progress( disk_usage_progress, dup, percent_used( Project::path() ) );
else
   update_progress( disk_usage_progress, dup, 0 );

if ( timeline->total_capture_xruns() )
	capture_buffer_progress->selection_color( FL_RED );

if ( timeline->total_playback_xruns() )
	playback_buffer_progress->selection_color( FL_RED );

static char stats[100];

if ( engine && ! engine->zombified() )
{
snprintf( stats, sizeof( stats ), "latency: %.1fms, xruns: %d",
	engine->frames_to_milliseconds( engine->system_latency() ),
	engine->xruns() );
}
else
{
        snprintf( stats, sizeof( stats ), "%s", "DISCONNECTED" );
}

stats_box->label( stats );

static bool zombie = false;

if ( engine && engine->zombified() && ! zombie )
{
	zombie = true;
	fl_alert( "Disconnected from JACK!" );
}

solo_blinker->value( Track::soloing() );

if ( transport->punch_enabled() && timeline->range_start() != timeline->range_end() )
        rec_blinker->value( transport->rolling &&
                            transport->rec_enabled() &&
                            transport->frame >= timeline->range_start() &&
                            transport->frame <= timeline->range_end() );
else
        rec_blinker->value( transport->rolling && transport->rec_enabled() );

sm_blinker->value( timeline->session_manager_name() != NULL );
sm_blinker->tooltip( timeline->session_manager_name() );
selected_blinker->value( timeline->nselected() );
seek_blinker->value( timeline->seek_pending() );

if ( timeline->session_manager_name() != NULL )
{
	find_item( menubar, "&Project/&New" )->deactivate();
	find_item( menubar, "&Project/&Open" )->deactivate();
}

// project_name->redraw();} {}
  }
  Function {update_cb( void *v )} {open private return_type {static void}
  } {
    code {Fl::repeat_timeout( STATUS_UPDATE_FREQ, update_cb, v );

((TLE*)v)->update_status();} {}
  }
  Function {capture_format_cb( Fl_Widget *, void *v )} {private return_type {static void}
  } {
    code {((TLE*)v)->capture_format_cb();} {}
  }
  Function {capture_format_cb()} {private return_type void
  } {
    code {Fl_Menu_ *o = menubar;

Track::capture_format = o->menu()[ o->value() ].label();} {}
  }
  Function {progress_cb( int p, void *arg )} {private return_type {static void}
  } {
    code {((TLE*)arg)->progress_cb( p );} {}
  }
  Function {progress_cb( int p )} {private return_type void
  } {
    code {if ( ! progress_group->visible() )
{
	timeline->hide();
	progress_group->show();
}
else if ( 0 == p )
{
	timeline->show();
	progress_group->hide();
}

// never allow drawing timeline while loading, as this would cause lock recursion.
if ( timeline->visible() )
   return;

static int oldp;
static char pat[10];

if ( p != oldp )
{
        oldp = p;
        nsm_send_progress( nsm, p / 100.0f );
        update_progress( progress, pat, p );

        progress->redraw();

        Fl::check();
}} {}
  }
  Function {show_help_dialog( const char *file )} {open private return_type {static void}
  } {
    code {char pat[256];

snprintf( pat, 256, "file://%s/non-timeline/%s.html", DOCUMENT_PATH, file );

open_url( pat );} {}
  }
} 

Function {set_theme_dark()} {C return_type void
} {
  code {Fl::background2( 100, 100, 100 );
        Fl::background( 50, 50, 50 );
        Fl::foreground( 255, 255, 255 );} {}
} 

class Project_Info_Dialog {open
} {
  Function {Project_Info_Dialog()} {open
  } {
    code {make_window();} {}
  }
  Function {run()} {open return_type void
  } {
    code {window->show();

while ( window->shown() )
	Fl::wait();} {}
  }
  Function {make_window()} {open
  } {
    Fl_Window window {
      label {Project info}
      callback {o->hide();

if ( logo_box->image() )
{
	((Fl_Shared_Image*)logo_box->image())->release();
	logo_box->image( NULL );
}} open
      private xywh {1195 197 520 710} type Double modal visible
    } {
      Fl_Group {} {open
        xywh {25 30 470 75}
      } {
        Fl_Value_Output {} {
          label {Sample Rate}
          xywh {35 30 90 25} labeltype SHADOW_LABEL align 1
          code0 {o->value( timeline->sample_rate() );}
        }
        Fl_Output {} {
          label {Size of Journal}
          xywh {175 30 100 25} box UP_BOX labeltype SHADOW_LABEL align 1
          code0 {static char pat[40];}
          code1 {snprintf( pat, sizeof( pat ), "%.1fK", size( "history" ) / (float)1024 );}
          code2 {o->value( pat );}
          code3 {\#include "file.h"}
        }
        Fl_Output {} {
          label {Created On}
          xywh {315 30 180 25} box UP_BOX labeltype SHADOW_LABEL align 1 textfont 11 textsize 12
          code0 {o->value( Project::created_on() );}
        }
        Fl_Output {} {
          label Length
          xywh {25 80 115 25} box BORDER_BOX color 47 align 1 textcolor 71
          code0 {char pat[40];}
          code1 {Clock::frame_to_HMS( pat, sizeof( pat ), timeline->length() );}
          code2 {o->value( pat );}
        }
        Fl_Value_Output {} {
          label Tracks
          xywh {195 80 55 25} align 1
          code0 {o->value( timeline->ntracks() );}
        }
        Fl_Output {} {
          label {Last Modified On}
          xywh {315 80 180 25} box UP_BOX labeltype SHADOW_LABEL align 1 textfont 11 textsize 12
          code0 {time_t t = modification_time( "history" );}
          code1 {static char s[40];}
          code2 {ctime_r( &t, s ); s[ strlen( s ) - 1 ] = 0;}
          code3 {o->value( s );}
        }
      }
      Fl_Box logo_box {
        label {<LOGO>}
        private xywh {18 117 485 268} color 53 labelfont 1 labelsize 18 align 16
        code0 {o->image( Fl_Shared_Image::get( PIXMAP_PATH "/non-timeline/icon-256x256.png" ) );}
        code1 {o->label( NULL );}
      }
      Fl_Text_Editor notes_field {
        label {Notes:}
        private xywh {20 420 480 245} color 47 selection_color 31 textsize 18 textcolor 92
        code0 {o->buffer( new Fl_Text_Buffer() );}
        code1 {o->buffer()->loadfile( "notes" );}
      }
      Fl_Button {} {
        label {&Save}
        callback {notes_field->buffer()->savefile( "notes" );

window->do_callback();}
        xywh {422 676 74 25}
      }
      Fl_Button {} {
        label {&Discard}
        callback {window->do_callback();}
        xywh {332 676 74 25}
      }
    }
  }
} 
