diff --git a/src/avtk/avtk_clip_selector.h b/src/avtk/avtk_clip_selector.h new file mode 100644 index 0000000..6bdf3ab --- /dev/null +++ b/src/avtk/avtk_clip_selector.h @@ -0,0 +1,171 @@ +/* + * Author: Harry van Haaren 2013 + * harryhaaren@gmail.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + */ + + +#ifndef AVTK_CLIP_SELECTOR_H +#define AVTK_CLIP_SELECTOR_H + +#include + +namespace Avtk +{ + +class ClipSelector : public Fl_Button +{ + public: + ClipSelector(int _x, int _y, int _w, int _h, const char *_label): + Fl_Button(_x, _y, _w, _h, _label), + numClips(10) + { + x = _x; + y = _y; + w = _w; + h = _h; + + label = _label; + + highlight = false; + mouseOver = false; + } + + const int numClips; + + bool mouseOver; + bool highlight; + int x, y, w, h; + const char* label; + + void draw() + { + if (damage() & FL_DAMAGE_ALL) + { + if ( value() ) + { + highlight = true; + } + else + { + highlight = false; + } + + cairo_t *cr = Fl::cairo_cc(); + + cairo_save( cr ); + + int clipWidth = w - 2; + int clipHeight = (h / numClips); + + int drawY = y + 1; + for( int i = 0; i < numClips; i++) // draw each clip + { + cairo_rectangle( cr, x+1, drawY, clipWidth, clipHeight - 2 ); + if ( false )// playing: green + cairo_set_source_rgba(cr, 1.0, 0.48, 0, 0.4); + else if ( false ) // loaded: orange + cairo_set_source_rgba(cr, 1.0, 0.48, 0, 0.4); + else // empty: grey + cairo_set_source_rgba(cr, 0.11, 0.11, 0.11, 0.8); + + cairo_fill_preserve(cr); + + //cairo_set_source_rgb( cr,28 / 255.f, 28 / 255.f , 28 / 255.f ); + if ( highlight ) + { + cairo_set_source_rgba(cr, 1.0, 0.48, 0, 0.4); + cairo_fill_preserve(cr); + } + + float alpha = 0.7; + if (mouseOver) { alpha = 1; } + cairo_set_source_rgba(cr, 1.0, 0.48, 0, alpha); + cairo_set_line_width( cr, 1.4); + cairo_stroke(cr); + + drawY += clipHeight + 2; + } + + cairo_restore( cr ); + + draw_label(); + } + } + + void resize(int X, int Y, int W, int H) + { + Fl_Widget::resize(X,Y,W,H); + x = X; + y = Y; + w = W; + h = H; + redraw(); + } + + + + int handle(int event) + { + switch(event) { + case FL_ACTIVATE: + { + } + case FL_DEACTIVATE: + { + } + return 1; + case FL_PUSH: + highlight = 1; + do_callback(); + return 1; + case FL_DRAG: { + int t = Fl::event_inside(this); + if (t != highlight) { + highlight = t; + redraw(); + } + } + return 1; + case FL_ENTER: + mouseOver = true; + redraw(); + return 1; + case FL_LEAVE: + mouseOver = false; + redraw(); + return 1; + case FL_RELEASE: + return 1; + case FL_SHORTCUT: + if ( test_shortcut() ) + { + do_callback(); + return 1; + } + return 0; + default: + return Fl_Widget::handle(event); + } + } +}; + +} // Avtk + +#endif // AVTK_CLIP_SELECTOR_H + diff --git a/src/gtrack.hxx b/src/gtrack.hxx index 565a129..6852cbc 100644 --- a/src/gtrack.hxx +++ b/src/gtrack.hxx @@ -13,6 +13,7 @@ #include "avtk/avtk_dial.h" #include "avtk/avtk_button.h" #include "avtk/avtk_background.h" +#include "avtk/avtk_clip_selector.h" #include "worker.hxx" @@ -100,6 +101,8 @@ class GTrack : public Fl_Group title( strdup(l) ), bg( x, y , w, h, title ), + clipSel(x + 5, y + 26, 100, 278,"Clips"), + button1(x + 5, y + 324, 100, 18,"Rec"), button2(x + 5, y + 344, 100, 18,"Play"), button3(x + 5, y + 364, 100, 18,"Stop"), @@ -129,9 +132,7 @@ class GTrack : public Fl_Group progress.maximum(1.0f); progress.minimum(0.0f); - progress.color( fl_color_cube(0.2 * (FL_NUM_RED - 1) / 255, - 0.2 * (FL_NUM_GREEN - 1) / 255, - 0.2 * (FL_NUM_BLUE - 1) / 255) ); + progress.color( FL_BLACK ); progress.selection_color( FL_BLUE ); /* 00366 Fl_Color color() const {return color_;} @@ -161,6 +162,8 @@ class GTrack : public Fl_Group Avtk::Background bg; + Avtk::ClipSelector clipSel; + Avtk::Button button1; Avtk::Button button2; Avtk::Button button3; @@ -168,6 +171,7 @@ class GTrack : public Fl_Group Avtk::Button button5; Avtk::Button button6; + Avtk::Dial volume; Avtk::Dial dial1;