Skip to content

Commit

Permalink
Increase size of image on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
Fudge committed Mar 17, 2008
1 parent 6fb00e7 commit 9e9bc27
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/inputs/digg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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] );
}
Expand Down
39 changes: 36 additions & 3 deletions src/textured_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
Expand Down

0 comments on commit 9e9bc27

Please sign in to comment.