README
1This is the FFFFLTK README
2
3FFFFLTK (forked forked forked fast and light tool kit) is a fork of AVTK which is (kind of) a fork of NTK (really its just a collection of NTK widgets) which is a fork of FLTK. The purpose of FFFFLTK is to allow users to generate widgets in inkscapeor any svg with as little coding as possible. This is accomplished through a program called svg2cairo. You can find a tutorial on drawing widgets in inkscape in my blogpost at http://mountainbikesandtrombones.blogspot.com/2014/07/creating-gui-in-inkscape.html If you are uninterested in inkscape and SVG files, you may find these widgets useful for drawing customized looking UIs directly in Cairo.
4
5Each of these widgets uses a function pointer called the draw function which gets assigned the the public member variable 'drawing_f'. This function is accompanied by 2 other member variables drawing_w and drawing_h which describe the width and height of the svg drawing. Once these 3 variables are set everything else is taken care of. The function will be called when it needs to be drawn and will be scaled and placed properly. On widgets that do not change there is actually no extra coding necessary outside of FLUID.
6
7Most useful widgets do change. The best example is a dial. As the dial value changes the dial should move to reflect the current value. Therefore many of the drawing functions require an argument to reflect the current state. Each widget is detailed below and examples are given throughout this repository.
8
9The widgets are all in the ffffltk namespace and are entirely contained as headers for easy addition to existing projects. Simply add ffffltk.h and then start using the classes decribed below. The widgets can be more or less treated as the built in widgets that come with FLTK, so you can set the size, step, tooltip etc all through FLUID or programmatically. The exception is labels aren't supported in any ffffltk widgets. The labels are frequently used to show values, but it is expected you will label your widgets using fancy cairo pictures.
10
11=====WIDGETS======
12each widget is described below with any members ffffltk adds over the fltk version.
13
14ffffltk::Aspect_Group
15int drawing_w;
16int drawing_h;
17void* (drawing_f)(cairo_t*);
18//notes: this was made for widgets/groups that should maintain aspect ratio. If only a background is used with stretch set to false the widgets on top of the background will be repositioned as the window changes shape. This widget is to correct that behavior. Look at stuck for an example of an aspect group and powercut for one that does change aspect ratio. You'll see when using much text its easier to just use an aspect group.
19
20ffffltk::Background
21int drawing_w;
22int drawing_h;
23void* (drawing_f)(cairo_t*);
24bool stretch; // flag that indicates if aspect ratio can be changed default is true (set to false for text or images).
25//notes: this is used for decorations or backgrounds. See also aspect group.
26
27ffffltk::Button
28int drawing_w;
29int drawing_h;
30void* (drawing_f)(cairo_t*,float);//2nd arg is a float 0 or 1 corresponding to the value of the button
31float floatvalue; //public float used to pass by reference into LV2 plugins (the main reason I did this project)
32//notes: for a toggle button after creating an instance of a Button call type(FL_TOGGLE_BUTTON);
33
34ffffltk::Dial
35int drawing_w;
36int drawing_h;
37void* (drawing_f)(cairo_t*,float);//2nd arg is a float [0,1] corresponding from min (0) to max (1)
38float floatvalue; //public float used to pass by reference into LV2 plugins (the main reason I did this project)
39char units[4]; //string appended to current value label to show what units are being displayed
40bool lock2int; //flag to limit displayed value and float val to appear as integers (though the actual value may not be) see the octave dial in hip2b for an example.
41//notes: this was the first widget I implemented. I also use it for sliders.
42
43fffltk::Display
44int drawing_w;
45int drawing_h;
46void *(drawing_f)(cairo_t*, char);// 2nd arg is character to display
47int nchars; // number of characters in the display
48bool periods; //flag whether periods are treaded as their own character
49//notes: this function was intended for skuomorphic 7/14/16 segment display widgets, but there is no reason it can't be used for any stylized text. You might find it's easier to use than saving every piece of text as separate backgrounds (I haven't tried). Because of its design intent (n segment displays) it requires apriori knowledge of the number of characters in nchars. For the same reason the periods member is provided. If periods is false it will skip any characters in the string of value '.' and instead pass into the previous character the MSB high. This is because the period on n segment displays is actually printed on the same unit as the character before. The text displayed is the value of the widget label, truncated to nchars, left justified, with each letter given an equal amount of space,
50
51ffffltk::Scope
52int drawing_w;
53int drawing_h;
54void *(drawing_f)(cairo_t*, float* data, int nframes, int start); //2nd arg is # samples added since last call, 3rd arg is start point of circular buffer
55float data[2048];
56void push_val(float val); //adds new value to data[]
57float max_val; //maximum number that fits on display
58float min_val; //minimum number that fits on display
59bool average; //flag to filter data so only 1 new value draw is called.
60//notes: Not yet implemented. This is intended to be a generic scope widget for drawing moving waveforms. It tracks the data and calls the draw function at 15 hz passing information on how many new data points have been added since the last time draw was called. This allows you to have flexibility in the display and also keeps consitency when data is added at different rates.
61
62======TODO=======
63I'm pretty sure that the efficiency could be improved. I frequently end up drawing the whole thing again when probably complicated sections could be saved and set again as the source surface. I'm no cairo master (which is why I went for converting from svg files).
64