Tweak themes for more color consistency.
[ntk.git] / src / Gleam_Theme.cxx
blobb8672671b51566a3e2f6c1fde5f1249a402a43ab
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)
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);
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,
144 FL_BACKGROUND_COLOR == c || FL_BACKGROUND2_COLOR == c
145 ? fl_darker(c)
146 : c );
147 down_frame(x, y, w, h, fl_darker(c));
148 //draw the inner rect.
149 //frame_rect(x + 1, y + 1, w - 3, h - 3, fl_color_average(c, FL_BLACK, .65));
153 static void border_box(int x, int y, int w, int h, Fl_Color c)
155 gleam_color(c);
156 fl_rectf(x,y,w,h);
157 gleam_color(fl_darker(c));
158 fl_rect(x+1,y+1,w-2,h-2);
161 static void
162 init_theme ( void )
164 /* replace the gtk+ boxes... (is there a better way?) */
165 Fl::set_boxtype( FL_UP_BOX, up_box, 2,2,4,4 );
166 Fl::set_boxtype( FL_DOWN_BOX, down_box, 2,2,3,3 );
167 Fl::set_boxtype( FL_THIN_UP_BOX, up_box, 2,2,3,3 );
168 Fl::set_boxtype( FL_THIN_DOWN_BOX, down_box, 2,2,3,3 );
169 Fl::set_boxtype( FL_UP_FRAME, up_frame, 2,2,3,3 );
170 Fl::set_boxtype( FL_DOWN_FRAME, down_frame, 2,2,3,3 );
171 Fl::set_boxtype( FL_ROUND_UP_BOX, up_box, 2,2,3,3 );
172 Fl::set_boxtype( FL_ROUND_DOWN_BOX, down_box, 2,2,3,3 );
173 Fl::set_boxtype( FL_BORDER_BOX, border_box, 1,1,2,2 );
176 void
177 init_gleam_theme ( void )
179 Fl_Theme *t = new Fl_Theme( "Gleam", "", "", init_theme );
181 Fl_Theme::add( t );