Centralize color schemes.

Also, add new color scheme "Very Dark".
This commit is contained in:
Jonathan Moore Liles 2010-01-31 00:47:08 -06:00
parent 417497a368
commit b774ee3f50
5 changed files with 133 additions and 70 deletions

75
FL/color_scheme.C Normal file
View File

@ -0,0 +1,75 @@
/*******************************************************************************/
/* Copyright (C) 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; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
#include "color_scheme.H"
#include <FL/Fl.H>
#include <string.h>
static Fl_Color system_colors[3];
void
get_system_colors ( void )
{
Fl::get_system_colors();
system_colors[ 0 ] = (Fl_Color)Fl::get_color( FL_BACKGROUND_COLOR );
system_colors[ 1 ] = (Fl_Color)Fl::get_color( FL_FOREGROUND_COLOR );
system_colors[ 2 ] = (Fl_Color)Fl::get_color( FL_BACKGROUND2_COLOR );
}
void
color_scheme ( const char *name )
{
if ( !strcasecmp( name, "dark" ) )
{
Fl::background2( 100, 100, 100 );
Fl::background( 50, 50, 50 );
Fl::foreground( 255, 255, 255 );
}
else if ( !strcasecmp( name, "light" ))
{
Fl::background2( 192, 192, 192 );
Fl::background( 220, 220, 220 );
Fl::foreground( 0, 0, 0 );
}
if ( !strcasecmp( name, "very dark" ) )
{
Fl::background2( 100, 100, 100 );
Fl::background( 20, 20, 20 );
Fl::foreground( 240, 240, 240 );
}
else if ( !strcasecmp( name, "system" ) )
{
unsigned char r, g, b;
Fl::get_color( system_colors[ 0 ], r, g, b );
Fl::background( r, g, b );
Fl::get_color( system_colors[ 1 ], r, g, b );
Fl::foreground( r, g, b );
Fl::get_color( system_colors[ 2 ], r, g, b );
Fl::background2( r, g, b );
}
Fl::scheme( Fl::scheme() );
}

21
FL/color_scheme.H Normal file
View File

@ -0,0 +1,21 @@
/*******************************************************************************/
/* Copyright (C) 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; see the file COPYING. If not,write to the Free Software */
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
void color_scheme ( const char *name );
void get_system_colors ( void );

View File

@ -41,6 +41,8 @@
#include <string.h> #include <string.h>
#include "debug.h" #include "debug.h"
#include "FL/color_scheme.H"
const double STATUS_UPDATE_FREQ = 0.2f; const double STATUS_UPDATE_FREQ = 0.2f;
extern char *user_config_dir; extern char *user_config_dir;
@ -155,39 +157,19 @@ void Mixer::cb_menu(Fl_Widget* o) {
} }
else if (! strcmp( picked, "&Options/&Display/&Colors/&System") ) else if (! strcmp( picked, "&Options/&Display/&Colors/&System") )
{ {
//Fl::get_system_colors(); color_scheme( "system" );
unsigned char r, g, b;
Fl::get_color( system_colors[ 0 ], r, g, b );
Fl::background( r, g, b );
Fl::get_color( system_colors[ 1 ], r, g, b );
Fl::foreground( r, g, b );
Fl::get_color( system_colors[ 2 ], r, g, b );
Fl::background2( r, g, b );
Fl::scheme( Fl::scheme() );
} }
else if (! strcmp( picked, "&Options/&Display/&Colors/&Dark") ) else if (! strcmp( picked, "&Options/&Display/&Colors/&Dark") )
{ {
Fl::background2( 100, 100, 100 ); color_scheme( "dark" );
Fl::background( 50, 50, 50 ); }
Fl::foreground( 255, 255, 255 ); else if (! strcmp( picked, "&Options/&Display/&Colors/&Very Dark") )
{
Fl::scheme( Fl::scheme() ); color_scheme( "very dark" );
} }
else if (! strcmp( picked, "&Options/&Display/&Colors/&Light") ) else if (! strcmp( picked, "&Options/&Display/&Colors/&Light") )
{ {
Fl::background2( 192, 192, 192 ); color_scheme( "light" );
Fl::background( 220, 220, 220 );
Fl::foreground( 0, 0, 0 );
Fl::scheme( Fl::scheme() );
} }
else if ( ! strcmp( picked, "&Help/&About" ) ) else if ( ! strcmp( picked, "&Help/&About" ) )
{ {
@ -214,13 +196,10 @@ void Mixer::cb_menu(Fl_Widget* o, void* v) {
Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) : Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
Fl_Group( X, Y, W, H, L ) Fl_Group( X, Y, W, H, L )
{ {
get_system_colors();
Fl::get_system_colors();
Fl::scheme( "plastic" ); Fl::scheme( "plastic" );
color_scheme( "dark" );
system_colors[ 0 ] = (Fl_Color)Fl::get_color( FL_BACKGROUND_COLOR );
system_colors[ 1 ] = (Fl_Color)Fl::get_color( FL_FOREGROUND_COLOR );
system_colors[ 2 ] = (Fl_Color)Fl::get_color( FL_BACKGROUND2_COLOR );
_rows = 1; _rows = 1;
box( FL_NO_BOX ); box( FL_NO_BOX );
@ -237,9 +216,10 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
o->add( "&Mixer/&Rows/Three", '3', 0, 0 ); o->add( "&Mixer/&Rows/Three", '3', 0, 0 );
o->add( "_&Options/&Display/&Style/&Default", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE ); o->add( "_&Options/&Display/&Style/&Default", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE );
o->add( "_&Options/&Display/&Style/&Flat", 0, 0, 0, FL_MENU_RADIO ); o->add( "_&Options/&Display/&Style/&Flat", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Colors/&System", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE ); o->add( "_&Options/&Display/&Colors/&Dark", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE );
o->add( "_&Options/&Display/&Colors/&Dark", 0, 0, 0, FL_MENU_RADIO ); o->add( "_&Options/&Display/&Colors/&Very Dark", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Colors/&Light", 0, 0, 0, FL_MENU_RADIO ); o->add( "_&Options/&Display/&Colors/&Light", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Colors/&System", 0, 0, 0, FL_MENU_RADIO );
o->add( "&Help/&Manual" ); o->add( "&Help/&Manual" );
o->add( "&Help/&About" ); o->add( "&Help/&About" );
o->callback( cb_menu, this ); o->callback( cb_menu, this );

View File

@ -303,7 +303,7 @@ Mixer_Strip::init ( )
// box(FL_THIN_UP_BOX); // box(FL_THIN_UP_BOX);
box( FL_RFLAT_BOX ); box( FL_RFLAT_BOX );
Fl_Group::color( fl_darker( FL_BACKGROUND_COLOR ) ); Fl_Group::color( FL_BACKGROUND_COLOR );
clip_children( 1 ); clip_children( 1 );
@ -461,7 +461,7 @@ Mixer_Strip::draw ( void )
if ( damage() != FL_DAMAGE_USER1 ) if ( damage() != FL_DAMAGE_USER1 )
Fl_Group::draw(); Fl_Group::draw();
Fl_Group::draw_box( FL_ROUNDED_FRAME, x(), y(), w(), h(), _focused ? Fl_Group::selection_color() : Fl_Group::color() ); Fl_Group::draw_box( FL_ROUNDED_FRAME, x(), y(), w(), h(), _focused ? Fl_Group::selection_color() : FL_BLACK );
} }

View File

@ -26,6 +26,8 @@ decl {const float STATUS_UPDATE_FREQ = 0.1f;} {}
decl {\#include "Fl_Menu_Settings.H"} {} decl {\#include "Fl_Menu_Settings.H"} {}
decl {\#include "color_scheme.H"} {}
decl {\#include "Timeline.H"} {} decl {\#include "Timeline.H"} {}
decl {\#include "Transport.H"} {} decl {\#include "Transport.H"} {}
@ -148,14 +150,11 @@ make_window();
Fl::visible_focus( 0 ); Fl::visible_focus( 0 );
Fl::get_system_colors(); get_system_colors();
Fl::scheme( "plastic" ); Fl::scheme( "plastic" );
system_colors[ 0 ] = (Fl_Color)Fl::get_color( FL_BACKGROUND_COLOR ); color_scheme( "dark" );
system_colors[ 1 ] = (Fl_Color)Fl::get_color( FL_FOREGROUND_COLOR );
system_colors[ 2 ] = (Fl_Color)Fl::get_color( FL_BACKGROUND2_COLOR );
set_theme_dark();
// constrain window to size of screen. // constrain window to size of screen.
{ {
@ -554,43 +553,31 @@ timeline->redraw();}
label {C&olors} open label {C&olors} open
xywh {10 10 74 25} xywh {10 10 74 25}
} { } {
MenuItem {} {
label System
callback {//Fl::get_system_colors();
unsigned char r, g, b;
Fl::get_color( system_colors[ 0 ], r, g, b );
Fl::background( r, g, b );
Fl::get_color( system_colors[ 1 ], r, g, b );
Fl::foreground( r, g, b );
Fl::get_color( system_colors[ 2 ], r, g, b );
Fl::background2( r, g, b );
Fl::scheme( Fl::scheme() );}
xywh {10 10 40 25} type Radio
}
MenuItem {} { MenuItem {} {
label Dark label Dark
callback { callback {
color_scheme( "dark" ); }
set_theme_dark(); }
xywh {20 20 40 25} type Radio value 1 xywh {20 20 40 25} type Radio value 1
} }
MenuItem {} {
label {Very Dark}
callback {
color_scheme( "very dark" ); }
xywh {20 20 40 25} type Radio
}
MenuItem {} { MenuItem {} {
label Light label Light
callback {Fl::background2( 192, 192, 192 ); callback {
Fl::background( 220, 220, 220 ); color_scheme( "light" ); }
Fl::foreground( 0, 0, 0 );
Fl::scheme( Fl::scheme() );}
xywh {30 30 40 25} type Radio xywh {30 30 40 25} type Radio
} }
MenuItem {} {
label System
callback {
color_scheme( "system" ); }
xywh {10 10 40 25} type Radio
}
} }
} }
Submenu {} { Submenu {} {