author | zecke <zecke> | 2004-04-07 23:33:48 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-07 23:33:48 (UTC) |
commit | 61cb9c9ad238e5aec6aaa1384549e0aab99d14bf (patch) (side-by-side diff) | |
tree | b96da732386aa45060bd80890cd7466cbcf77afb | |
parent | 0a21abab4eed64d17c4b1475569194117dab709c (diff) | |
download | opie-61cb9c9ad238e5aec6aaa1384549e0aab99d14bf.zip opie-61cb9c9ad238e5aec6aaa1384549e0aab99d14bf.tar.gz opie-61cb9c9ad238e5aec6aaa1384549e0aab99d14bf.tar.bz2 |
First version of the zoomer placement still needs some work though
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 36 | ||||
-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, 51 insertions, 6 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 @@ -61,4 +61,19 @@ 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); setFocusPolicy(QWidget::StrongFocus); @@ -252,4 +267,15 @@ 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(); } @@ -261,4 +287,10 @@ void ImageScrollView::resizeEvent(QResizeEvent * e) generateImage(); first_resize_done = true; + emit viewportSizeChanged( viewport()->size() ); + + /* + * move scrollbar + */ + _zoomer->setGeometry( viewport()->width()-100, viewport()->height()-50, 100, 50 ); } @@ -321,4 +353,5 @@ void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) { + odebug << "Move X and Y " << e->x() << " " << e->y() << oendl; int mx, my; mx = e->x(); @@ -347,6 +380,7 @@ 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 the geometry values here may real differ from that set in MoveEvent (I don't know 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 @@ -2,4 +2,6 @@ #define _IMAGE_SCROLL_VIEW_H +#include <lib/oimagezoomer.h> + #include <qscrollview.h> #include <qimage.h> @@ -8,4 +10,6 @@ #include <qdialog.h> + + class QPainter; @@ -35,4 +39,6 @@ public: signals: void sig_return(); + void imageSizeChanged( const QSize& ); + void viewportSizeChanged( const QSize& ); protected: @@ -40,4 +46,5 @@ protected: void init(); + Opie::MM::OImageZoomer *_zoomer; QImage _image_data; QImage _original_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 @@ -27,4 +27,8 @@ OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par } +OImageZoomer::~OImageZoomer() { + +} + void OImageZoomer::init() { setFrameStyle( Panel | Sunken ); @@ -94,5 +98,5 @@ void OImageZoomer::drawContents( QPainter* p ) { void OImageZoomer::mousePressEvent( QMouseEvent* ) { - + m_mouseX = m_mouseY = -1; } @@ -103,8 +107,8 @@ 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 ); } m_mouseX = mx; |