Work on saving/loading of settings.
This commit is contained in:
parent
80d2466c6f
commit
e720a06ad0
|
@ -3,6 +3,7 @@ SRCS= \
|
|||
Waveform.C \
|
||||
Region.C \
|
||||
main.C \
|
||||
settings.C \
|
||||
TLE.C \
|
||||
Sequence.C \
|
||||
Audio_Sequence.C \
|
||||
|
|
|
@ -4,6 +4,8 @@ header_name {.H}
|
|||
code_name {.C}
|
||||
decl {const float STATUS_UPDATE_FREQ = 0.5f;} {}
|
||||
|
||||
decl {\#include "settings.H"} {}
|
||||
|
||||
decl {\#include "Timeline.H"} {}
|
||||
|
||||
decl {\#include "Engine.H"} {}
|
||||
|
@ -51,7 +53,7 @@ Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );} {}
|
|||
xywh {522 141 1024 768} type Double resizable xclass {Non-DAW} visible
|
||||
} {
|
||||
Fl_Menu_Bar menubar {
|
||||
label {capture:\\nfoo}
|
||||
label {capture:\\nfoo} open
|
||||
xywh {0 0 1024 25}
|
||||
} {
|
||||
Submenu {} {
|
||||
|
@ -94,6 +96,11 @@ Loggable::compact();}
|
|||
callback {exit( 0 );}
|
||||
xywh {40 40 40 25} shortcut 0x40071
|
||||
}
|
||||
MenuItem {} {
|
||||
label Dump
|
||||
callback {dump_to_file( menubar, options_menu, "foo.state" );} selected
|
||||
xywh {0 0 40 25}
|
||||
}
|
||||
}
|
||||
Submenu {} {
|
||||
label {&Edit} open
|
||||
|
@ -176,7 +183,7 @@ Loggable::compact();}
|
|||
}
|
||||
}
|
||||
}
|
||||
Submenu {} {
|
||||
Submenu options_menu {
|
||||
label {&Options} open
|
||||
xywh {0 0 74 25} divider
|
||||
} {
|
||||
|
@ -300,7 +307,7 @@ Fl::scheme( Fl::scheme() );}
|
|||
Fl_Group {} {open
|
||||
xywh {0 23 1024 48}
|
||||
} {
|
||||
Fl_Pack {} {open selected
|
||||
Fl_Pack {} {open
|
||||
xywh {0 23 473 46} type HORIZONTAL
|
||||
code0 {o->spacing( 10 );}
|
||||
} {
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
|
||||
/*******************************************************************************/
|
||||
/* Copyright (C) 2008 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; see the file COPYING. If not,write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
/*******************************************************************************/
|
||||
|
||||
#include "settings.H"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* code to dump and restore (portions of) an Fl_Menu_ */
|
||||
|
||||
void
|
||||
remove_ampersands ( char *str, int n )
|
||||
{
|
||||
char *d = str;
|
||||
char *s = str;
|
||||
|
||||
while ( n-- )
|
||||
{
|
||||
if ( *s == '&' )
|
||||
{
|
||||
++s;
|
||||
continue;
|
||||
}
|
||||
|
||||
*(d++) = *(s++);
|
||||
}
|
||||
|
||||
*d = '\0';
|
||||
}
|
||||
|
||||
int
|
||||
item_pathname_x ( Fl_Menu_ *menu, char *path, int n, Fl_Menu_Item *item )
|
||||
{
|
||||
menu->item_pathname( path, n, item );
|
||||
|
||||
remove_ampersands( path, n );
|
||||
}
|
||||
|
||||
void
|
||||
indent ( FILE *fp, int n )
|
||||
{
|
||||
while ( n-- )
|
||||
fprintf( fp, "\t" );
|
||||
}
|
||||
|
||||
/** dump options from submenu /menu/ of menubar /bar/ to file /fp/ */
|
||||
Fl_Menu_Item *
|
||||
dump ( Fl_Menu_Bar *bar, Fl_Menu_Item *menu, FILE *fp, int depth )
|
||||
{
|
||||
static char path[256];
|
||||
Fl_Menu_Item *m = menu;
|
||||
|
||||
for ( ; m->text; ++m )
|
||||
{
|
||||
bool is_radio = false;
|
||||
|
||||
if ( m->flags & FL_SUBMENU )
|
||||
{
|
||||
strcpy( path, m->text );
|
||||
remove_ampersands( path, sizeof( path ) - 1 );
|
||||
|
||||
indent( fp, depth );
|
||||
fprintf( fp, "%s\n", path );
|
||||
|
||||
/* recurse */
|
||||
m = dump( bar, ++m, fp, depth + 1 );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( m->flags & FL_MENU_RADIO )
|
||||
is_radio = true;
|
||||
|
||||
// bar->item_pathname( path, sizeof( path ) - 1, m );
|
||||
item_pathname_x( bar, path, sizeof( path ) - 1, m );
|
||||
|
||||
|
||||
if ( m->flags & FL_MENU_TOGGLE || m->flags & FL_MENU_RADIO )
|
||||
{
|
||||
if ( ! is_radio )
|
||||
{
|
||||
indent( fp, depth );
|
||||
|
||||
fprintf( fp, "%s\n", rindex( path, '/' ) + 1 );
|
||||
|
||||
indent( fp, depth + 1 );
|
||||
|
||||
fprintf( fp, "%s\n", m->flags & FL_MENU_VALUE ? "true" : "false" );
|
||||
}
|
||||
else if ( m->flags & FL_MENU_VALUE )
|
||||
{
|
||||
indent( fp, depth );
|
||||
|
||||
*rindex( path, '/' ) = '\0';
|
||||
|
||||
fprintf( fp, "%s\n", rindex( path, '/' ) + 1 );
|
||||
|
||||
indent( fp, depth + 1 );
|
||||
|
||||
fprintf( fp, "%s\n", path + strlen( path ) + 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
void
|
||||
dump_to_file ( Fl_Menu_Bar *bar, Fl_Menu_Item *menu, const char *name )
|
||||
{
|
||||
FILE *fp = fopen( name, "w" );
|
||||
|
||||
dump( bar, menu, fp, 0 );
|
||||
|
||||
fclose( fp );
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
/*******************************************************************************/
|
||||
/* Copyright (C) 2008 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; see the file COPYING. If not,write to the Free Software */
|
||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
/*******************************************************************************/
|
||||
|
||||
|
||||
#include <FL/Fl_Menu.H>
|
||||
#include <FL/Fl_Menu_Bar.H>
|
||||
#include <stdio.h>
|
||||
|
||||
Fl_Menu_Item * dump ( Fl_Menu_Bar *bar, Fl_Menu_Item *menu, FILE *fp );
|
||||
|
||||
void dump_to_file ( Fl_Menu_Bar *bar, Fl_Menu_Item *menu, const char *name );
|
Loading…
Reference in New Issue