Try to improve appearance with new 'crystal' boxtypes.

This commit is contained in:
Jonathan Moore Liles 2008-04-27 05:18:03 -05:00
parent 63ce948a8e
commit d7b8ecc591
7 changed files with 385 additions and 9 deletions

View File

@ -19,12 +19,13 @@
#include "Boxtypes.H" #include "Boxtypes.H"
#include <FL/fl_draw.H> #include <FL/fl_draw.H>
#include <string.h>
/** This simple box is suitable for use with knob-type widgets. It /** This simple box is suitable for use with knob-type widgets. It
* comprises a border with shadow, and a cap with glare-lines akin * comprises a border with shadow, and a cap with glare-lines akin
* to those seen on burnished aluminum knobs. */ * to those seen on burnished aluminum knobs. */
static void static void
draw_burnished_oval_box ( int x, int y, int w, int h, Fl_Color c ) burnished_oval_box ( int x, int y, int w, int h, Fl_Color c )
{ {
/* draw background */ /* draw background */
fl_color( fl_darker( c ) ); fl_color( fl_darker( c ) );
@ -58,10 +59,369 @@ draw_burnished_oval_box ( int x, int y, int w, int h, Fl_Color c )
} }
/* Crystal boxes, base (obviously) on the FLTK1 'plastic' boxes, but
* without the rude color blending and with a slightly enhanced
* appearance. */
extern uchar *fl_gray_ramp();
inline Fl_Color
shade_color ( uchar gc, Fl_Color bc )
{
return fl_color_average( ( Fl_Color ) gc, bc, 0.25f );
}
static void
frame_rect ( int x, int y, int w, int h, const char *c, Fl_Color bc )
{
uchar *g = fl_gray_ramp();
int b = strlen( c ) / 4 + 1;
for ( x += b, y += b, w -= 2 * b, h -= 2 * b; b > 1; b-- )
{
// Draw lines around the perimeter of the button, 4 colors per
// circuit.
fl_color( shade_color( g[*c++], bc ) );
fl_line( x, y + h + b, x + w - 1, y + h + b, x + w + b - 1, y + h );
fl_color( shade_color( g[*c++], bc ) );
fl_line( x + w + b - 1, y + h, x + w + b - 1, y, x + w - 1, y - b );
fl_color( shade_color( g[*c++], bc ) );
fl_line( x + w - 1, y - b, x, y - b, x - b, y );
fl_color( shade_color( g[*c++], bc ) );
fl_line( x - b, y, x - b, y + h, x, y + h + b );
}
}
static void
frame_round ( int x, int y, int w, int h, const char *c, Fl_Color bc )
{
uchar *g = fl_gray_ramp();
int b = strlen( c ) / 4 + 1;
if ( w == h )
{
for ( ; b > 1; b--, x++, y++, w -= 2, h -= 2 )
{
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y, w, h, 45.0, 135.0 );
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y, w, h, 315.0, 405.0 );
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y, w, h, 225.0, 315.0 );
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y, w, h, 135.0, 225.0 );
}
}
else if ( w > h )
{
int d = h / 2;
for ( ; b > 1; d--, b--, x++, y++, w -= 2, h -= 2 )
{
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y, h, h, 90.0, 135.0 );
fl_xyline( x + d, y, x + w - d );
fl_arc( x + w - h, y, h, h, 45.0, 90.0 );
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x + w - h, y, h, h, 315.0, 405.0 );
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x + w - h, y, h, h, 270.0, 315.0 );
fl_xyline( x + d, y + h - 1, x + w - d );
fl_arc( x, y, h, h, 225.0, 270.0 );
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y, h, h, 135.0, 225.0 );
}
}
else if ( w < h )
{
int d = w / 2;
for ( ; b > 1; d--, b--, x++, y++, w -= 2, h -= 2 )
{
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y, w, w, 45.0, 135.0 );
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y, w, w, 0.0, 45.0 );
fl_yxline( x + w - 1, y + d, y + h - d );
fl_arc( x, y + h - w, w, w, 315.0, 360.0 );
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y + h - w, w, w, 225.0, 315.0 );
fl_color( shade_color( g[*c++], bc ) );
fl_arc( x, y + h - w, w, w, 180.0, 225.0 );
fl_yxline( x, y + d, y + h - d );
fl_arc( x, y, w, w, 135.0, 180.0 );
}
}
}
static void
shade_rect ( int x, int y, int w, int h, const char *c, Fl_Color bc )
{
uchar *g = fl_gray_ramp();
int i, j;
int clen = strlen( c ) - 1;
int chalf = clen / 2;
int cstep = 1;
if ( h < ( w * 2 ) )
{
// Horizontal shading...
if ( clen >= h )
cstep = 2;
for ( i = 0, j = 0; j < chalf; i++, j += cstep )
{
// Draw the top line and points...
fl_color( shade_color( g[c[i]], bc ) );
fl_xyline( x + 1, y + i, x + w - 2 );
fl_color( shade_color( g[c[i] - 2], bc ) );
fl_point( x, y + i + 1 );
fl_point( x + w - 1, y + i + 1 );
// Draw the bottom line and points...
fl_color( shade_color( g[c[clen - i]], bc ) );
fl_xyline( x + 1, y + h - i, x + w - 2 );
fl_color( shade_color( g[c[clen - i] - 2], bc ) );
fl_point( x, y + h - i );
fl_point( x + w - 1, y + h - i );
}
// Draw the interior and sides...
i = chalf / cstep;
// fl_color( shade_color( g[c[chalf]], bc ) );
fl_color( bc );
fl_rectf( x + 1, y + i, w - 2, h - 2 * i + 1 );
fl_color( shade_color( g[c[chalf] - 2], bc ) );
fl_yxline( x, y + i, y + h - i );
fl_yxline( x + w - 1, y + i, y + h - i );
}
else
{
// Vertical shading...
if ( clen >= w )
cstep = 2;
for ( i = 0, j = 0; j < chalf; i++, j += cstep )
{
// Draw the left line and points...
fl_color( shade_color( g[c[i]], bc ) );
fl_yxline( x + i, y + 1, y + h - 1 );
fl_color( shade_color( g[c[i] - 2], bc ) );
fl_point( x + i + 1, y );
fl_point( x + i + 1, y + h );
// Draw the right line and points...
fl_color( shade_color( g[c[clen - i]], bc ) );
fl_yxline( x + w - 1 - i, y + 1, y + h - 1 );
fl_color( shade_color( g[c[clen - i] - 2], bc ) );
fl_point( x + w - 2 - i, y );
fl_point( x + w - 2 - i, y + h );
}
// Draw the interior, top, and bottom...
i = chalf / cstep;
fl_color( shade_color( g[c[chalf]], bc ) );
fl_rectf( x + i, y + 1, w - 2 * i, h - 1 );
fl_color( shade_color( g[c[chalf] - 2], bc ) );
fl_xyline( x + i, y, x + w - i );
fl_xyline( x + i, y + h, x + w - i );
}
}
static void
shade_round ( int x, int y, int w, int h, const char *c, Fl_Color bc )
{
uchar *g = fl_gray_ramp();
int i;
int clen = strlen( c ) - 1;
int chalf = clen / 2;
if ( w > h )
{
int d = h / 2;
const int na = 8;
for ( i = 0; i < chalf; i++, d--, x++, y++, w -= 2, h -= 2 )
{
fl_color( shade_color( g[c[i]], bc ) );
fl_pie( x, y, h, h, 90.0, 135.0 + i * na );
fl_xyline( x + d, y, x + w - d );
fl_pie( x + w - h, y, h, h, 45.0 + i * na, 90.0 );
fl_color( shade_color( g[c[i] - 2], bc ) );
fl_pie( x + w - h, y, h, h, 315.0 + i * na, 405.0 + i * na );
fl_color( shade_color( g[c[clen - i]], bc ) );
fl_pie( x + w - h, y, h, h, 270.0, 315.0 + i * na );
fl_xyline( x + d, y + h - 1, x + w - d );
fl_pie( x, y, h, h, 225.0 + i * na, 270.0 );
fl_color( shade_color( g[c[clen - i] - 2], bc ) );
fl_pie( x, y, h, h, 135.0 + i * na, 225.0 + i * na );
}
fl_color( shade_color( g[c[chalf]], bc ) );
fl_rectf( x + d, y, w - h + 1, h + 1 );
fl_pie( x, y, h, h, 90.0, 270.0 );
fl_pie( x + w - h, y, h, h, 270.0, 90.0 );
}
else
{
int d = w / 2;
const int na = 8;
for ( i = 0; i < chalf; i++, d--, x++, y++, w -= 2, h -= 2 )
{
fl_color( shade_color( g[c[i]], bc ) );
fl_pie( x, y, w, w, 45.0 + i * na, 135.0 + i * na );
fl_color( shade_color( g[c[i] - 2], bc ) );
fl_pie( x, y, w, w, 0.0, 45.0 + i * na );
fl_yxline( x + w - 1, y + d, y + h - d );
fl_pie( x, y + h - w, w, w, 315.0 + i * na, 360.0 );
fl_color( shade_color( g[c[clen - i]], bc ) );
fl_pie( x, y + h - w, w, w, 225.0 + i * na, 315.0 + i * na );
fl_color( shade_color( g[c[clen - i] - 2], bc ) );
fl_pie( x, y + h - w, w, w, 180.0, 225.0 + i * na );
fl_yxline( x, y + d, y + h - d );
fl_pie( x, y, w, w, 135.0 + i * na, 180.0 );
}
fl_color( shade_color( g[c[chalf]], bc ) );
fl_rectf( x, y + d, w + 1, h - w + 1 );
fl_pie( x, y, w, w, 0.0, 180.0 );
fl_pie( x, y + h - w, w, w, 180.0, 360.0 );
}
}
static void
up_frame ( int x, int y, int w, int h, Fl_Color c )
{
frame_rect( x, y, w, h - 1, "KLDIIJLM", c );
}
static void
narrow_thin_box ( int x, int y, int w, int h, Fl_Color c )
{
if ( h <= 0 || w <= 0 )
return;
uchar *g = fl_gray_ramp();
fl_color( shade_color( g['R'], c ) );
fl_rectf( x + 1, y + 1, w - 2, h - 2 );
fl_color( shade_color( g['I'], c ) );
if ( w > 1 )
{
fl_xyline( x + 1, y, x + w - 2 );
fl_xyline( x + 1, y + h - 1, x + w - 2 );
}
if ( h > 1 )
{
fl_yxline( x, y + 1, y + h - 2 );
fl_yxline( x + w - 1, y + 1, y + h - 2 );
}
}
static void
thin_up_box ( int x, int y, int w, int h, Fl_Color c )
{
if ( w > 4 && h > 4 )
{
shade_rect( x + 1, y + 1, w - 2, h - 3, "RQOQSUWQ", c );
frame_rect( x, y, w, h - 1, "IJLM", c );
}
else
narrow_thin_box( x, y, w, h, c );
}
static void
up_box ( int x, int y, int w, int h, Fl_Color c )
{
if ( w > 8 && h > 8 )
{
// shade_rect( x + 1, y + 1, w - 2, h - 3, "RVQNOPQRSTUVWVQ", c );
// shade_rect( x + 1, y + 1, w - 2, h - 3, "STUVWVQRWXVUVVQ", c );
shade_rect( x + 1, y + 1, w - 2, h - 3, "FISPPQQRSSTTUPJ", c );
/* stipple */
fl_color( fl_color_average( FL_GRAY, c, 0.10f ) );
for ( int i = y + 1; i < y + h - 8; i += 5 )
fl_line( x, i, x + w, i );
frame_rect( x, y, w, h - 1, "IJLM", c );
}
else
thin_up_box( x, y, w, h, c );
}
static void
up_round ( int x, int y, int w, int h, Fl_Color c )
{
shade_round( x, y, w, h, "RVQNOPQRSTUVWVQ", c );
frame_round( x, y, w, h, "IJLM", c );
}
static void
down_frame ( int x, int y, int w, int h, Fl_Color c )
{
frame_rect( x, y, w, h - 1, "LLLLTTRR", c );
}
static void
down_box ( int x, int y, int w, int h, Fl_Color c )
{
if ( w > 6 && h > 6 )
{
shade_rect( x + 2, y + 2, w - 4, h - 5, "STUVWWWVT", c );
down_frame( x, y, w, h, c );
}
else
{
narrow_thin_box( x, y, w, h, c );
}
}
static void
down_round ( int x, int y, int w, int h, Fl_Color c )
{
shade_round( x, y, w, h, "STUVWWWVT", c );
frame_round( x, y, w, h, "IJLM", c );
}
void void
init_boxtypes ( void ) init_boxtypes ( void )
{ {
Fl::set_boxtype( FL_BURNISHED_OVAL_BOX, draw_burnished_oval_box, 4, 4, 7, 7 ); Fl::set_boxtype( FL_BURNISHED_OVAL_BOX, burnished_oval_box, 4, 4, 7, 7 );
Fl::set_boxtype( FL_CRYSTAL_UP_BOX, up_box, 4,4,8,8 );
Fl::set_boxtype( FL_CRYSTAL_DOWN_BOX, down_box, 2,2,4,4 );
Fl::set_boxtype( FL_CRYSTAL_UP_FRAME, up_frame, 2,2,4,4 );
Fl::set_boxtype( FL_CRYSTAL_DOWN_FRAME, down_frame, 2,2,4,4 );
Fl::set_boxtype( FL_CRYSTAL_THIN_UP_BOX, thin_up_box, 1,1,2,2 );
Fl::set_boxtype( FL_CRYSTAL_THIN_DOWN_BOX, down_box, 1,1,2,2 );
/* replace the plastic boxes... (is there a better way?) */
Fl::set_boxtype( FL_PLASTIC_UP_BOX, up_box, 4,4,8,8 );
Fl::set_boxtype( FL_PLASTIC_DOWN_BOX, down_box, 2,2,4,4 );
Fl::set_boxtype( FL_PLASTIC_UP_FRAME, up_frame, 2,2,4,4 );
Fl::set_boxtype( FL_PLASTIC_DOWN_FRAME, down_frame, 2,2,4,4 );
Fl::set_boxtype( FL_PLASTIC_THIN_UP_BOX, thin_up_box, 1,1,2,2 );
Fl::set_boxtype( FL_PLASTIC_THIN_DOWN_BOX, down_box, 1,1,2,2 );
/* Fl::set_boxtype( FL_CRYSTAL_ROUND_UP_BOX, up_round ); */
/* Fl::set_boxtype( FL_CRYSTAL_ROUND_DOWN_BOX, down_round ); */
} }

View File

@ -21,4 +21,11 @@
#define FL_BURNISHED_OVAL_BOX FL_FREE_BOXTYPE #define FL_BURNISHED_OVAL_BOX FL_FREE_BOXTYPE
#define FL_CRYSTAL_UP_BOX (Fl_Boxtype)(FL_FREE_BOXTYPE+1)
#define FL_CRYSTAL_DOWN_BOX (Fl_Boxtype)(FL_FREE_BOXTYPE+2)
#define FL_CRYSTAL_UP_FRAME (Fl_Boxtype)(FL_FREE_BOXTYPE+3)
#define FL_CRYSTAL_DOWN_FRAME (Fl_Boxtype)(FL_FREE_BOXTYPE+4)
#define FL_CRYSTAL_THIN_UP_BOX (Fl_Boxtype)(FL_FREE_BOXTYPE+5)
#define FL_CRYSTAL_THIN_DOWN_BOX (Fl_Boxtype)(FL_FREE_BOXTYPE+6)
void init_boxtypes ( void ); void init_boxtypes ( void );

View File

@ -43,7 +43,7 @@ include ../make.inc
timeline: $(OBJS) timeline: $(OBJS)
echo $(SRCS) >/dev/stderr echo $(SRCS) >/dev/stderr
echo $(OBJS) >/dev/stderr echo $(OBJS) >/dev/stderr
$(CXX) $(CXXFLAGS) $(INCLUDES) $(LIBS) -ljack -lpthread $(OBJS) -o $@ $(CXX) $(CXXFLAGS) $(INCLUDES) $(LIBS) -ljack -lpthread $(OBJS) -o $@ -L../FL -lfl_widgets
clean: clean:
rm -f $(OBJS) timeline makedepend rm -f $(OBJS) timeline makedepend

View File

@ -41,10 +41,13 @@ using namespace std;
extern Timeline *timeline; extern Timeline *timeline;
#include "../FL/Boxtypes.H"
bool Region::inherit_track_color = true; bool Region::inherit_track_color = true;
Fl_Boxtype Region::_box = FL_UP_BOX; // Fl_Boxtype Region::_box = FL_UP_BOX;
Fl_Boxtype Region::_box = FL_CRYSTAL_UP_BOX;
Fl_Color Region::_selection_color = FL_MAGENTA; Fl_Color Region::_selection_color = FL_MAGENTA;

View File

@ -26,6 +26,8 @@
#include "Track.H" #include "Track.H"
#include "../FL/Boxtypes.H"
queue <Sequence_Widget *> Sequence::_delete_queue; queue <Sequence_Widget *> Sequence::_delete_queue;
Sequence::Sequence ( int X, int Y, int W, int H, Track *track ) : Fl_Widget( X, Y, W, H ) Sequence::Sequence ( int X, int Y, int W, int H, Track *track ) : Fl_Widget( X, Y, W, H )
@ -36,7 +38,8 @@ Sequence::Sequence ( int X, int Y, int W, int H, Track *track ) : Fl_Widget( X,
/* if ( track ) */ /* if ( track ) */
/* track->add( this ); */ /* track->add( this ); */
box( FL_DOWN_BOX ); // box( FL_DOWN_BOX );
box( FL_CRYSTAL_DOWN_BOX );
color( fl_darker( FL_GRAY ) ); color( fl_darker( FL_GRAY ) );
align( FL_ALIGN_LEFT ); align( FL_ALIGN_LEFT );

View File

@ -161,7 +161,7 @@ exit( 0 );}
} }
} }
Submenu {} { Submenu {} {
label {&Edit} open selected label {&Edit} open
xywh {0 0 74 25} xywh {0 0 74 25}
} { } {
MenuItem {} { MenuItem {} {
@ -367,7 +367,7 @@ timeline->redraw();}
} }
MenuItem {} { MenuItem {} {
label Flat label Flat
callback {Fl::scheme( "gtk+" );} callback {Fl::scheme( "gtk+" );} selected
xywh {10 10 40 25} type Radio xywh {10 10 40 25} type Radio
} }
} }
@ -408,7 +408,7 @@ Fl::scheme( Fl::scheme() );}
MenuItem {} { MenuItem {} {
label Light label Light
callback {Fl::background2( 255, 255, 255 ); callback {Fl::background2( 255, 255, 255 );
Fl::background( 172, 172, 172 ); Fl::background( 192, 192, 192 );
Fl::foreground( 0, 0, 0 ); Fl::foreground( 0, 0, 0 );
Fl::scheme( Fl::scheme() );} Fl::scheme( Fl::scheme() );}

View File

@ -59,6 +59,7 @@
#include "TLE.H" #include "TLE.H"
#include "../FL/Boxtypes.H"
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -96,6 +97,8 @@ main ( int argc, char **argv )
LOG_REGISTER_CREATE( Control_Sequence ); LOG_REGISTER_CREATE( Control_Sequence );
init_boxtypes();
if ( ! ensure_dirs() ) if ( ! ensure_dirs() )
/* error */; /* error */;