-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 38 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.h | 7 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/oimagezoomer.cpp | 14 |
3 files changed, 52 insertions, 7 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp index ad19219..5b12258 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp @@ -62,2 +62,17 @@ void ImageScrollView::init() odebug << "init " << oendl; + + /* + * create the zoomer + * and connect ther various signals + */ + _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); + connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), + this, SLOT(scrollBy(int,int)) ); + connect(this,SIGNAL(contentsMoving(int,int)), + _zoomer, (SLOT(setVisiblePoint(int,int))) ); + connect(this,SIGNAL(imageSizeChanged(const QSize&)), + _zoomer, SLOT(setImageSize(const QSize&)) ); + connect(this,SIGNAL(viewportSizeChanged(const QSize&)), + _zoomer, SLOT(setViewPortSize(const QSize&)) ); + viewport()->setBackgroundColor(white); @@ -253,2 +268,13 @@ void ImageScrollView::generateImage() _pdata.convertFromImage(_image_data); + + /* + * update the zoomer + */ + emit imageSizeChanged( _image_data.size() ); + rescaleImage( 128, 128 ); + _zoomer->setImage( _image_data ); + + /* + * invalidate + */ _image_data=QImage(); @@ -262,2 +288,8 @@ void ImageScrollView::resizeEvent(QResizeEvent * e) first_resize_done = true; + emit viewportSizeChanged( viewport()->size() ); + + /* + * move scrollbar + */ + _zoomer->setGeometry( viewport()->width()-100, viewport()->height()-50, 100, 50 ); } @@ -322,2 +354,3 @@ void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) { + odebug << "Move X and Y " << e->x() << " " << e->y() << oendl; int mx, my; @@ -348,4 +381,5 @@ void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) -void ImageScrollView::contentsMousePressEvent ( QMouseEvent * ) +void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) { + odebug << " X and Y " << e->x() << " " << e->y() << oendl; /* this marks the beginning of a possible mouse move. Due internal reasons of QT @@ -353,3 +387,3 @@ void ImageScrollView::contentsMousePressEvent ( QMouseEvent * ) why). For getting them in real context, we use the first move-event to set the start - position ;) + position ;) */ diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h index eb91dbd..1b25103 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.h +++ b/noncore/graphics/opie-eye/gui/imagescrollview.h @@ -3,2 +3,4 @@ +#include <lib/oimagezoomer.h> + #include <qscrollview.h> @@ -9,2 +11,4 @@ + + class QPainter; @@ -36,2 +40,4 @@ signals: void sig_return(); + void imageSizeChanged( const QSize& ); + void viewportSizeChanged( const QSize& ); @@ -41,2 +47,3 @@ protected: + Opie::MM::OImageZoomer *_zoomer; QImage _image_data; diff --git a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp index 178fbd4..ffa3c0c 100644 --- a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp +++ b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp @@ -28,2 +28,6 @@ OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par +OImageZoomer::~OImageZoomer() { + +} + void OImageZoomer::init() { @@ -95,3 +99,3 @@ void OImageZoomer::drawContents( QPainter* p ) { void OImageZoomer::mousePressEvent( QMouseEvent* ) { - + m_mouseX = m_mouseY = -1; } @@ -104,6 +108,6 @@ void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { if ( m_mouseX != -1 && m_mouseY != -1 ) { - int diffx = m_mouseX-mx; - int diffy = m_mouseY-my; -// emit zoomAreaRel( diffx, diffy ); -// emit zoomArea( + int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); + int diffy = ( my - m_mouseY ) * m_imgSize.height() / height(); + emit zoomAreaRel( diffx, diffy ); + emit zoomArea(m_visPt.x()+diffx, m_visPt.y()+diffy ); } |