From d7b8ecc59170005d2e673f72d8dc6f1d67c6d112 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 27 Apr 2008 05:18:03 -0500 Subject: [PATCH] Try to improve appearance with new 'crystal' boxtypes. --- FL/Boxtypes.C | 364 +++++++++++++++++++++++++++++++++++++++++++- FL/Boxtypes.H | 9 +- Timeline/Makefile | 2 +- Timeline/Region.C | 5 +- Timeline/Sequence.C | 5 +- Timeline/TLE.fl | 6 +- Timeline/main.C | 3 + 7 files changed, 385 insertions(+), 9 deletions(-) diff --git a/FL/Boxtypes.C b/FL/Boxtypes.C index 436bfa2..4273bf4 100644 --- a/FL/Boxtypes.C +++ b/FL/Boxtypes.C @@ -19,12 +19,13 @@ #include "Boxtypes.H" #include +#include /** This simple box is suitable for use with knob-type widgets. It * comprises a border with shadow, and a cap with glare-lines akin * to those seen on burnished aluminum knobs. */ 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 */ 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 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 ); */ + } diff --git a/FL/Boxtypes.H b/FL/Boxtypes.H index 2b81280..6ad1940 100644 --- a/FL/Boxtypes.H +++ b/FL/Boxtypes.H @@ -19,6 +19,13 @@ #include -#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 ); diff --git a/Timeline/Makefile b/Timeline/Makefile index d29d855..c95dffb 100644 --- a/Timeline/Makefile +++ b/Timeline/Makefile @@ -43,7 +43,7 @@ include ../make.inc timeline: $(OBJS) echo $(SRCS) >/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: rm -f $(OBJS) timeline makedepend diff --git a/Timeline/Region.C b/Timeline/Region.C index 1886596..a9c8098 100644 --- a/Timeline/Region.C +++ b/Timeline/Region.C @@ -41,10 +41,13 @@ using namespace std; extern Timeline *timeline; +#include "../FL/Boxtypes.H" 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; diff --git a/Timeline/Sequence.C b/Timeline/Sequence.C index 831c7c3..ab9681a 100644 --- a/Timeline/Sequence.C +++ b/Timeline/Sequence.C @@ -26,6 +26,8 @@ #include "Track.H" +#include "../FL/Boxtypes.H" + queue Sequence::_delete_queue; 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 ) */ /* track->add( this ); */ - box( FL_DOWN_BOX ); +// box( FL_DOWN_BOX ); + box( FL_CRYSTAL_DOWN_BOX ); color( fl_darker( FL_GRAY ) ); align( FL_ALIGN_LEFT ); diff --git a/Timeline/TLE.fl b/Timeline/TLE.fl index e18da8d..3e26ded 100644 --- a/Timeline/TLE.fl +++ b/Timeline/TLE.fl @@ -161,7 +161,7 @@ exit( 0 );} } } Submenu {} { - label {&Edit} open selected + label {&Edit} open xywh {0 0 74 25} } { MenuItem {} { @@ -367,7 +367,7 @@ timeline->redraw();} } MenuItem {} { label Flat - callback {Fl::scheme( "gtk+" );} + callback {Fl::scheme( "gtk+" );} selected xywh {10 10 40 25} type Radio } } @@ -408,7 +408,7 @@ Fl::scheme( Fl::scheme() );} MenuItem {} { label Light callback {Fl::background2( 255, 255, 255 ); -Fl::background( 172, 172, 172 ); +Fl::background( 192, 192, 192 ); Fl::foreground( 0, 0, 0 ); Fl::scheme( Fl::scheme() );} diff --git a/Timeline/main.C b/Timeline/main.C index c8a138e..402f3db 100644 --- a/Timeline/main.C +++ b/Timeline/main.C @@ -59,6 +59,7 @@ #include "TLE.H" +#include "../FL/Boxtypes.H" #include #include @@ -96,6 +97,8 @@ main ( int argc, char **argv ) LOG_REGISTER_CREATE( Control_Sequence ); + init_boxtypes(); + if ( ! ensure_dirs() ) /* error */;