From 9e9bc275d8c6740dcf34e0fdb0804667afadddeb Mon Sep 17 00:00:00 2001 From: Erlend Simonsen Date: Mon, 17 Mar 2008 22:32:48 +0100 Subject: [PATCH] Increase size of image on hover --- src/inputs/digg.cpp | 7 +------ src/textured_element.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/inputs/digg.cpp b/src/inputs/digg.cpp index f8ecf5f..f892592 100644 --- a/src/inputs/digg.cpp +++ b/src/inputs/digg.cpp @@ -98,10 +98,7 @@ void Digg::run( void ) { fetchDiggs(); forever { - cout << "http: " << http->hasPendingRequests() << endl; - cout << "httpImages: " << httpImages->hasPendingRequests() << endl; - - if( duggQueue.size() > 0 && curDate > 20) { + if( duggQueue.size() > 0 && curDate > 5) { cout << duggQueue.size() << " pending diggs" << endl; Dugg d = duggQueue.first(); @@ -119,8 +116,6 @@ void Digg::run( void ) { } else { if( images[d.image] == NULL ) cout << "Adding rel with MISSING image[" << d.image.toStdString() << "]" << endl; - else - cout << "Adding rel with image[" << d.image.toStdString() << "]" << endl; gl->addRelation(this, d.story, d.user, true, images[d.image] ); } diff --git a/src/textured_element.cpp b/src/textured_element.cpp index 50e6a39..fbd377f 100644 --- a/src/textured_element.cpp +++ b/src/textured_element.cpp @@ -44,16 +44,40 @@ TexturedElement::~TexturedElement() } void TexturedElement::render(GLWidget *gl) { + GLfloat r = 0.004 + (size - 1.0) / 100; + bool hover = fabs(gl->getX() - x) <= r*1.5f && fabs(gl->getY() - y) <= r * 1.5f; + + if(hover) { + if( gl->getSelected() == NULL ) + gl->setSelected(this); + glColor4f(1.0, 1.0, 1.0, 1.0); + size = 5.0; + r = 0.004 + (10.0 - 1.0) / 100; + } else { + if( activities.size() > 0 ) { + glColor4f(1.0, 1.0, 1.0, 1.0); + } else { + glColor4f(0.75, 0.75, 0.75, 0.75); + } + } + + + if( texId == 0 && image != NULL ) { cout << "Binding TexturedElement[" << image->width() << "x" << image->height() << "]" << endl; - texId = gl->bindTexture(*image); - cout << "Binding as " << texId << endl; + + if( image->width() == 0 || image->height() == 0 ) { + texId = -1; + cout << "Ignored"; + } else { + texId = gl->bindTexture(*image); + cout << "Binding as " << texId << endl; + } } if( texId > 0 ) { - glColor4f(1.0, 1.0, 1.0, 1.0); glBindTexture(GL_TEXTURE_2D, texId); glBegin(GL_QUADS); @@ -71,6 +95,15 @@ void TexturedElement::render(GLWidget *gl) { glEnd(); + if( showInfo > 0 || hover ) { + QString info = QString("[%1] %2").arg( QString::number(realSize).left(5) ).arg(name().left(50)); + glColor4f(1.0, 1.0, 1.0, 1.0); + int xi = (int) ((1.0 + x) / 2.0 * gl->getWidth()) - info.length() * 3; + int xy = (int) (( gl->getAspect() - y) / (2 * gl->getAspect()) * gl->getHeight() - gl->getHeight() * 0.05 ); + + gl->renderText(xi,xy, info ); + } + if( activity_queue.size() > 0 && rand() % (60/activity_queue.size()) == 0 ) { Activity *a = activity_queue.takeFirst();