summaryrefslogtreecommitdiffstats
path: root/src/Gui/RenderArea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Gui/RenderArea.cpp')
-rw-r--r--src/Gui/RenderArea.cpp44
1 files changed, 20 insertions, 24 deletions
diff --git a/src/Gui/RenderArea.cpp b/src/Gui/RenderArea.cpp
index eb1f3eb..f27e009 100644
--- a/src/Gui/RenderArea.cpp
+++ b/src/Gui/RenderArea.cpp
@@ -76,7 +76,24 @@ void RenderArea::onRealize() {
}
bool RenderArea::onConfigureEvent(GdkEventConfigure*) {
- updateViewport();
+ if(!gdkGLBegin())
+ return false;
+
+ glViewport(0, 0, get_width(), get_height());
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+
+ if(get_width() != 0 && get_height() != 0)
+ glScalef(2.0f/get_width(), -2.0f/get_height(), 1);
+
+ gdkGLEnd();
+
+ viewWidth = get_width()/scale;
+ viewHeight = get_height()/scale;
+
+ queue_draw();
+
return true;
}
@@ -121,31 +138,10 @@ void RenderArea::zoom(int zoom, float x, float y) {
zoomLevel = std::max(std::min(zoomLevel + zoom, 50), -100);
scale = 100*std::pow(1.1f, zoomLevel);
- updateScrolling(x, y);
-}
-
-void RenderArea::updateViewport() {
- if(!gdkGLBegin())
- return;
-
- glViewport(0, 0, get_width(), get_height());
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-
- if(get_width() != 0 && get_height() != 0)
- glScalef(2.0f/get_width(), -2.0f/get_height(), 1);
-
- gdkGLEnd();
-
- updateScrolling();
-}
-
-void RenderArea::updateScrolling(float x, float y) {
const float newWidth = get_width()/scale, newHeight = get_height()/scale;
- xCenter += (x-0.5)*(viewWidth-newWidth);
- yCenter += (y-0.5)*(viewHeight-newHeight);
+ xCenter += (x-0.5f)*(viewWidth-newWidth);
+ yCenter += (y-0.5f)*(viewHeight-newHeight);
viewWidth = newWidth;
viewHeight = newHeight;