-Gtrack added, denormals taken care of

main
Harry van Haaren 2013-04-20 12:20:46 +01:00
parent f5ebe24caf
commit e28afcd2cd
6 changed files with 197 additions and 3 deletions

116
src/avtk/avtk_button.h Normal file
View File

@ -0,0 +1,116 @@
#ifndef AVTK_BUTTON_H
#define AVTK_BUTTON_H
#include <FL/Fl_Button.H>
class AvtkButton : public Fl_Button
{
public:
AvtkButton(int _x, int _y, int _w, int _h, const char *_label=0):
Fl_Button(_x, _y, _w, _h, _label)
{
x = _x;
y = _y;
w = _w;
h = _h;
label = _label;
highlight = false;
mouseOver = false;
}
bool mouseOver;
bool highlight;
int x, y, w, h;
const char* label;
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
cairo_t *cr = Fl::cairo_cc();
cairo_save( cr );
cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
cairo_set_source_rgb( cr,28 / 255.f, 28 / 255.f , 28 / 255.f );
cairo_fill_preserve(cr);
cairo_set_line_width(cr, 1.5);
cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
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_stroke(cr);
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_PUSH:
highlight = 1;
redraw();
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:
if (highlight) {
highlight = 0;
redraw();
do_callback();
}
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
do_callback();
return 1;
}
return 0;
default:
return Fl_Widget::handle(event);
}
}
};
#endif // AVTK_BUTTON_H

34
src/denormals.hxx Normal file
View File

@ -0,0 +1,34 @@
#ifndef LUPPP_DENORMALS_H
#define LUPPP_DENORMALS_H
#include <iostream>
#ifdef __SSE__
/* On Intel set FZ (Flush to Zero) and DAZ (Denormals Are Zero)
flags to avoid costly denormals */
#ifdef __SSE3__
#include <pmmintrin.h>
inline void AVOIDDENORMALS()
{
//std::cout << "Denormals: FZ DAZ using SSE3" << std::endl;
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
}
#else
#include <xmmintrin.h>
inline void AVOIDDENORMALS()
{
//std::cout << "Denormals: FZ" << std::endl;
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
}
#endif //__SSE3__
#else
inline void AVOIDDENORMALS()
{
std::cout << "Denormals: Warning! No protection" << std::endl;
}
#endif //__SSE__
#endif // LUPPP_DENORMALS_H

32
src/gtrack.hxx Normal file
View File

@ -0,0 +1,32 @@
#ifndef LUPPP_G_TRACK_H
#define LUPPP_G_TRACK_H
#include <FL/Fl.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Slider.H>
#include "avtk/avtk_button.h"
class GTrack : public Fl_Group
{
public:
GTrack(int x, int y, int w, int h ) :
Fl_Group(x, y, w, h),
button(x + 5, y + 5, 100, 20,"Quit"),
button2(x + 5, y + 25, 100, 20,"2"),
button3(x + 5, y + 45, 100, 20,"3")
//slider(x, y + 50, w, 20)
{
end(); // close the group
}
private:
AvtkButton button;
AvtkButton button2;
AvtkButton button3;
};
#endif // LUPPP_G_TRACK_H

View File

@ -4,11 +4,16 @@
Gui::Gui()
{
window = new Fl_Window(340,180);
box = new Fl_Box(20,40,300,100,"Luppp 5");
window = new Fl_Window(640,280);
window->color(FL_BLACK);
box = new Fl_Box(5, 5, 200, 60, "Luppp 5");
box->box(FL_UP_BOX);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
track = new GTrack(5,80,200,200);
track2 = new GTrack(120,80,200,200);
window->end();
}

View File

@ -6,6 +6,8 @@
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include "gtrack.hxx"
class Gui
{
public:
@ -15,6 +17,8 @@ class Gui
private:
Fl_Window* window;
Fl_Box* box;
GTrack* track;
GTrack* track2;
};
#endif // LUPPP_GUI

View File

@ -10,6 +10,7 @@
#include "gui.hxx"
#include "jack.hxx"
#include "event.hxx"
#include "denormals.hxx"
char* processDspMem = 0;
@ -22,6 +23,9 @@ Jack* jack = 0;
int main()
{
// setup the environment
AVOIDDENORMALS();
// allocate data to read from
processDspMem = (char*)malloc( sizeof(EventBase) );
processOscMem = (char*)malloc( sizeof(EventBase) );
@ -31,7 +35,6 @@ int main()
jack = new Jack();
jack->activate();
Gui gui;