Mixer: Fix receiving of direct OSC messages.
[nondaw.git] / FL / Gleam_Theme.C
blobed94e453e3330b79e143a9f0fc55fdb5aef7c753
2 /*******************************************************************************/
3 /* Copyright (C) 2012 Jonathan Moore Liles                                     */
4 /* Copyright (C) 2001-2005 by Colin Jones                                      */
5 /*                                                                             */
6 /* This program is free software; you can redistribute it and/or modify it     */
7 /* under the terms of the GNU General Public License as published by the       */
8 /* Free Software Foundation; either version 2 of the License, or (at your      */
9 /* option) any later version.                                                  */
10 /*                                                                             */
11 /* This program is distributed in the hope that it will be useful, but WITHOUT */
12 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       */
13 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   */
14 /* more details.                                                               */
15 /*                                                                             */
16 /* You should have received a copy of the GNU General Public License along     */
17 /* with This program; see the file COPYING.  If not,write to the Free Software */
18 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
19 /*******************************************************************************/
21 /* Taken from the "Gleam" FLTK scheme, as modified by prodatum */
23 #include <FL/Fl.H>
24 #include <FL/fl_draw.H>
26 #include "FL/Fl_Theme.H"
28 static void gleam_color(Fl_Color c)
30         if (Fl::draw_box_active())
31                 fl_color(c);
32         else
33                 fl_color(fl_inactive(c));
35 static void frame_rect(int x, int y, int w, int h, Fl_Color bc)
38         // Draw the outline around the perimeter of the box
39         fl_color(fl_color_average(FL_BLACK, FL_BACKGROUND_COLOR, .1));
40         fl_line(x, y, x + w, y);
41         fl_line(x + w, y, x + w, y + h);
42         fl_line(x + w, y + h, x, y + h);
43         fl_line(x, y + h, x, y);
47 static void shade_rect_up(int x, int y, int w, int h, Fl_Color bc)
49         // Draws the shiny
50         float third = (float) h / 3;
51         gleam_color(bc);
52         fl_rectf(x, y, w, third + 1);
54         //gleam_color(fl_color_average(bc, FL_WHITE, .90f));
55         //fl_rectf(x, y, w, half + 1);
57         float step_size = 0.10 / ((float) h - third);
58         int j = 0;
59         //step_size = (.1 / (float) half);
60         //printf("1 / %i = %f \n", half, (1.0/half));
62         /**
63          * This loop generates the nice gradient at the bottom of the
64          * widget
65          **/
66         for (float k = 1; k >= .90; k -= step_size)
67         {
68                 j++;
69                 gleam_color(fl_color_average(bc, FL_WHITE, k));
70                 fl_line(x, y + j + third - 1, x + w - 1, y + j + third - 1);
71         }
75 static void frame_rect_up(int x, int y, int w, int h, Fl_Color bc)
78         // Draw the outline around the perimeter of the box
79         gleam_color(bc);
80         fl_line(x, y, x + w, y); //Go across.
81         fl_line(x, y + (h / 2), x, y + 1); //Go to top
82         fl_line(x + w, y + (h / 2), x + w, y + 1); //Go to top
84         gleam_color(fl_darker(bc));
85         fl_line(x, y + h, x + w, y + h); //Go across again!
86         fl_line(x, y + (h / 2), x, y + h - 1); //Go to top
87         fl_line(x + w, y + (h / 2), x + w, y + h - 1); //Go to top
91 static void frame_rect_down(int x, int y, int w, int h, Fl_Color bc)
94         // Draw the outline around the perimeter of the box
95         gleam_color(fl_darker(bc));
96         fl_line(x, y, x + w, y); //Go across.
97         fl_line(x, y + (h / 2), x, y + 1); //Go to top
98         fl_line(x + w, y + (h / 2), x + w, y + 1); //Go to top
100         //gleam_color(bc);
101         fl_line(x, y + h, x + w, y + h); //Go across again!
102         fl_line(x, y + (h / 2), x, y + h - 1); //Go to top
103         fl_line(x + w, y + (h / 2), x + w, y + h - 1); //Go to top
107 static void shade_rect_down(int x, int y, int w, int h, Fl_Color bc)
110         gleam_color(bc);
111         Fl_Color color = fl_color();
112         fl_rectf(x, y, w, h);
113         gleam_color(fl_color_average(bc, fl_darker(color), 0.65));
114         fl_line(x, y + 1, x + w, y + 1);
115         fl_line(x, y + 1, x, y + h - 2);
116         gleam_color(fl_color_average(bc, fl_darker(color), 0.85));
117         fl_line(x + 1, y + 2, x + w, y + 2);
118         fl_line(x + 1, y + 2, x + 1, y + h - 2);
122 static void up_frame(int x, int y, int w, int h, Fl_Color c)
124         frame_rect_up(x, y, w - 1, h - 1, fl_darker(c));
127 static void up_box(int x, int y, int w, int h, Fl_Color c)
129         shade_rect_up(x + 1, y, w - 2, h - 1, c);
130         frame_rect_up(x, y, w - 1, h - 1, fl_darker(c));
131         //draw the inner rect.
132         frame_rect(x + 1, y + 1, w - 3, h - 3, fl_color_average(c, FL_WHITE, .25f));
136 static void down_frame(int x, int y, int w, int h, Fl_Color c)
138         frame_rect_down(x, y, w - 1, h - 1, fl_darker(c));
141 static void down_box(int x, int y, int w, int h, Fl_Color c)
143         shade_rect_down(x + 1, y, w - 2, h, c);
144         down_frame(x, y, w, h, fl_darker(c));
145         //draw the inner rect.
146         //frame_rect(x + 1, y + 1, w - 3, h - 3, fl_color_average(c, FL_BLACK, .65));
149 static void
150 init_theme ( void )
152     /* replace the gtk+ boxes... (is there a better way?) */
153     Fl::set_boxtype(  FL_UP_BOX,         up_box,           2,2,4,4 );
154     Fl::set_boxtype(  FL_DOWN_BOX,       down_box,         2,2,3,3 );
155     Fl::set_boxtype(  FL_THIN_UP_BOX,         up_box,           2,2,3,3 );
156     Fl::set_boxtype(  FL_THIN_DOWN_BOX,       down_box,         2,2,3,3 );
157     Fl::set_boxtype(  FL_UP_FRAME,       up_frame,         2,2,3,3 );
158     Fl::set_boxtype(  FL_DOWN_FRAME,     down_frame,       2,2,3,3 );
159     Fl::set_boxtype(  FL_ROUND_UP_BOX,   up_box,           2,2,3,3 );
160     Fl::set_boxtype(  FL_ROUND_DOWN_BOX, down_box,         2,2,3,3 );
163 void
164 init_gleam_theme ( void )
166     Fl_Theme *t = new Fl_Theme( "Gleam", "", "", init_theme );
168     Fl_Theme::add( t );