#include "MiniMap.h" #include <QPainter> MiniMap::MiniMap(void) { drawVeil = false; veilColor = QColor( 0, 0, 0 ); v_x = v_y = v_w = v_h = 0.0; } MiniMap::~MiniMap(void) { } void MiniMap::setView( double x, double y, double width, double height ) { v_x = x; v_y = y; v_w = width; v_h = height; update(); } void MiniMap::mouseMoveEvent( QMouseEvent* e ) { ImageProjector::mouseMoveEvent( e ); double x = e->pos().x() - ( width() - displayWidth ) / 2; double y = e->pos().y() - ( height() - displayHeight ) / 2; emit mouseAt( x / displayWidth, y / displayHeight ); } void MiniMap::mousePressEvent( QMouseEvent* e ) { emit pressed(); mouseMoveEvent( e ); } void MiniMap::paintEvent( QPaintEvent* e ) { ImageProjector::paintEvent( e ); if ( !drawVeil ) return; int w = v_w * displayWidth; int h = v_h * displayHeight; int x1 = v_x * ( displayWidth - w ); int x2 = x1 + w; int y1 = v_y * ( displayHeight - h ); int y2 = y1 + h; QPainter p( this ); p.translate( ( width() - displayWidth ) / 2, ( height() - displayHeight ) / 2 ); p.setClipRect( 0, 0, displayWidth, displayHeight ); p.setPen( QPen( veilColor ) ); p.drawRect( x1, y1, w, h ); QColor veil = veilColor; veil.setAlpha( 100 ); p.setBrush( veil ); p.setPen( Qt::NoPen ); p.drawRect( 0, 0, displayWidth, y1 ); p.drawRect( 0, y1, x1, h ); p.drawRect( x2, y1, displayWidth - x2, h ); p.drawRect( 0, y2, displayWidth, displayHeight - y2 ); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 5516 | Sam Stafford | The M is for Merge. | ||
#1 | 5501 | Sam Stafford |
Codename CALAMARI. Built with Qt 4.1.3 - needs QtCore4.dll and QtGui4.dll to run. |