summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Gui/RenderArea.cpp44
-rw-r--r--src/Gui/RenderArea.h3
2 files changed, 20 insertions, 27 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;
diff --git a/src/Gui/RenderArea.h b/src/Gui/RenderArea.h
index 8ac72d7..a757467 100644
--- a/src/Gui/RenderArea.h
+++ b/src/Gui/RenderArea.h
@@ -74,9 +74,6 @@ class RenderArea : public Gtk::DrawingArea {
void zoom(int zoom, float x = 0.5f, float y = 0.5f);
- void updateViewport();
- void updateScrolling(float x = 0.5f, float y = 0.5f);
-
bool gdkGLBegin() {
GtkWidget *widget = GTK_WIDGET(gobj());