changeset 139:2d883a374b79

Zoom with the mouse wheel, for the SDLWidget.
author benoitrigolleau
date Fri, 09 Nov 2007 13:21:34 +0000
parents 3b2b790e47e5
children 90b84d5a387f
files data/model/SDLWidget.cpp data/model/SDLWidget.h data/svdata.vcproj sv/main/MainWindow.cpp
diffstat 4 files changed, 58 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/SDLWidget.cpp	Fri Nov 09 12:58:47 2007 +0000
+++ b/data/model/SDLWidget.cpp	Fri Nov 09 13:21:34 2007 +0000
@@ -5,13 +5,17 @@
 extern int Videow;
 extern int Videoh;
 
+#define MIN_WIDTH 320
+#define MIN_HEIGHT 240
+
 SDLWidget::SDLWidget()
 	:windowInitialized(false), screen(0)
 	{
 		setAttribute(Qt::WA_PaintOnScreen);
 		setAttribute(Qt::WA_NoSystemBackground);
-		setMinimumSize(720,576);
-		resize(Videow, Videoh);
+		zoomFactor = 1;
+		setMinimumSize( MIN_WIDTH*zoomFactor,MIN_HEIGHT*zoomFactor );
+
 	}
 
 SDLWidget::~SDLWidget()
@@ -19,6 +23,39 @@
 		SDL_Quit();
 	}
 
+void SDLWidget::setZoomFactor( float f )
+{
+	int w, h;
+	
+	if( f == zoomFactor )
+		return;
+
+	zoomFactor = f;
+
+	w = MIN_WIDTH*zoomFactor;
+	h = MIN_HEIGHT*zoomFactor;
+	setMinimumSize( w, h );
+	emit(sizeChanged(w,h));
+	
+	/*QWidget *p = dynamic_cast<QWidget*>( parent() );
+	if( p ){
+		resize( p->width(), p->height() );
+	}*/
+}
+
+void SDLWidget::wheelEvent( QWheelEvent *event )
+{
+	float f;
+
+	f = zoomFactor + 0.001*event->delta();
+	if( f < 32.0/MIN_WIDTH ){
+		f = 32.0/MIN_WIDTH;
+	}
+
+	setZoomFactor( f );
+}
+
+
 void SDLWidget::showEvent(QShowEvent *e)
 	{
 		(void)e;
@@ -40,4 +77,5 @@
 			//screen = SDL_SetVideoMode(width(), height(), 32, SDL_SWSURFACE);
 			windowInitialized = true;
 		}
-	}
\ No newline at end of file
+	}
+
--- a/data/model/SDLWidget.h	Fri Nov 09 12:58:47 2007 +0000
+++ b/data/model/SDLWidget.h	Fri Nov 09 13:21:34 2007 +0000
@@ -20,12 +20,22 @@
 	SDLWidget();
 	virtual ~SDLWidget();
 
+signals:
+	void sizeChanged(int w, int h);
+
+public slots:
+  void setZoomFactor( float );
+  void wheelEvent( QWheelEvent* );
+
 protected:
 
 	bool windowInitialized;
 	SDL_Surface *screen;
 
 	virtual void showEvent(QShowEvent *e);
+
+private:
+  float zoomFactor;
 };
 
 
--- a/data/svdata.vcproj	Fri Nov 09 12:58:47 2007 +0000
+++ b/data/svdata.vcproj	Fri Nov 09 13:21:34 2007 +0000
@@ -930,7 +930,7 @@
 						<Tool
 							Name="VCCustomBuildTool"
 							Description="MOC $(InputFileName)"
-							CommandLine="$(QTDIR)\bin\moc.exe -DNDEBUG -DBUILD_RELEASE -DUSE_VC -D_WINDOWS -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DHAVE_BZ2 -DHAVE_PORTAUDIO -DHAVE_PORTAUDIO_V18 -DHAVE_OGGZ -DHAVE_FISHSOUND -DHAVE_FFTW3F -DHAVE_VAMP -DHAVE_VAMP_HOSTSDK -DHAVE_SNDFILE -DHAVE_SAMPLERATE -DQT_THREAD_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB  -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include&quot; -I &quot;.&quot; -I &quot;..&quot; -I &quot;$(QTDIR)\include\ActiveQt&quot; -I &quot;tmp_moc&quot; -I &quot;.&quot; -I&quot;$(QTDIR)\mkspecs\win32-msvc2005&quot; $(InputPath) -o tmp_moc\moc_$(InputName).cpp"
+							CommandLine="$(QTDIR)\bin\moc.exe -DNDEBUG -DBUILD_RELEASE -DUSE_VC -D_WINDOWS -DUNICODE -DQT_LARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DHAVE_BZ2 -DHAVE_PORTAUDIO -DHAVE_PORTAUDIO_V18 -DHAVE_OGGZ -DHAVE_FISHSOUND -DHAVE_FFTW3F -DHAVE_VAMP -DHAVE_VAMP_HOSTSDK -DHAVE_SNDFILE -DHAVE_SAMPLERATE -DQT_THREAD_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB  -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtCore&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include\QtGui&quot; -I &quot;$(QTDIR)\include&quot; -I &quot;.&quot; -I &quot;..&quot; -I &quot;$(QTDIR)\include\ActiveQt&quot; -I &quot;tmp_moc&quot; -I &quot;.&quot; -I&quot;$(QTDIR)\mkspecs\win32-msvc2005&quot; $(InputPath) -o tmp_moc\moc_$(InputName).cpp&#x0D;&#x0A;"
 							AdditionalDependencies="$(QTDIR)\bin\moc.exe"
 							Outputs="tmp_moc\moc_$(InputName).cpp"
 						/>
--- a/sv/main/MainWindow.cpp	Fri Nov 09 12:58:47 2007 +0000
+++ b/sv/main/MainWindow.cpp	Fri Nov 09 13:21:34 2007 +0000
@@ -329,11 +329,12 @@
 
 	QWidget *ttaux = new QWidget;
 	ttaux->setLayout(videoVLayout);
-	QPalette palette;
-	palette.setColor(QPalette::Background,palette.color(QPalette::Dark));
-	ttaux->setPalette(palette);
-
-	m_qtabwidget->addTab(ttaux, tr("Video"));
+
+	QScrollArea *sa = new QScrollArea();
+	sa->setWidgetResizable( true );
+	sa->setWidget( ttaux );
+
+	m_qtabwidget->addTab(sa, tr("Video"));
 
 	/****************************/