-Updated header Image to use newer Avtk::Image with fl_image_draw(). Image now compiled in

main
Harry van Haaren 2013-07-22 09:13:18 +01:00
parent 08debba6ba
commit 5a8fec9a05
2 changed files with 20 additions and 40 deletions

View File

@ -29,6 +29,8 @@
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#include <FL/fl_draw.H>
using namespace std; using namespace std;
namespace Avtk namespace Avtk
@ -47,53 +49,27 @@ class Image : public Fl_Widget
label = _label; label = _label;
imageSurf = 0; bits = -1;
imageDataPtr = 0;
if ( _label ) }
{
//cout << "creating image from label" << endl; void setPixbuf(const unsigned char* data, int b )
imageSurf = cairo_image_surface_create_from_png( label ); {
} bits = b;
imageDataPtr = data;
} }
int x, y, w, h; int x, y, w, h;
const char* label; const char* label;
cairo_surface_t* imageSurf; int bits;
const unsigned char* imageDataPtr;
void draw() void draw()
{ {
if (damage() & FL_DAMAGE_ALL) if ( damage() & FL_DAMAGE_ALL && imageDataPtr != 0 )
{ {
cairo_t *cr = Fl::cairo_cc(); fl_draw_image((const uchar*)imageDataPtr, x, y, w, h, bits, w*bits);
//cairo_save(cr);
if ( imageSurf == 0 )
{
// draw X
cairo_move_to( cr, x , y );
cairo_line_to( cr, x + w, y + h );
cairo_move_to( cr, x , y + h );
cairo_line_to( cr, x + w, y );
cairo_set_source_rgb ( cr, 0.2,0.2,0.2);
cairo_stroke(cr);
// draw text
cairo_move_to( cr, x + (w/2.f) - 65, y + (h/2.f) + 10 );
cairo_set_source_rgb ( cr, 0.6,0.6,0.6);
cairo_set_font_size( cr, 20 );
cairo_show_text( cr, "Image not loaded" );
return;
}
// draw the image to the context
cairo_set_source_surface(cr, imageSurf, x, y);
//cairo_rectangle( cr, x, y, w, h );
cairo_paint(cr);
//cairo_restore(cr);
} }
} }

View File

@ -6,6 +6,10 @@
#include "audiobuffer.hxx" #include "audiobuffer.hxx"
// include the header.c file in the planning dir:
// its the GIMP .c export of the LUPPP header image
#include "../planning/header.c"
// Hack, move to gtrack.cpp // Hack, move to gtrack.cpp
int GTrack::privateID = 0; int GTrack::privateID = 0;
int GMasterTrack::privateID = 0; int GMasterTrack::privateID = 0;
@ -34,8 +38,8 @@ Gui::Gui() :
window.label("Luppp 5"); window.label("Luppp 5");
//window.callback( close_cb, 0 ); //window.callback( close_cb, 0 );
Avtk::Image* header = new Avtk::Image(0,0,1200,36,"header.png"); Avtk::Image* headerImage = new Avtk::Image(0,0,1200,36,"header.png");
headerImage->setPixbuf( header.pixel_data, 4 );
int i = 0; int i = 0;
for (; i < NTRACKS; i++ ) for (; i < NTRACKS; i++ )