diff options
Diffstat (limited to 'Drawer.cpp')
-rw-r--r-- | Drawer.cpp | 44 |
1 files changed, 10 insertions, 34 deletions
@@ -1,7 +1,6 @@ #include "Drawer.h" #include "Window.h" #include "draw.h" -#include "edit.h" #include <GL/gl.h> #include <math.h> @@ -34,7 +33,7 @@ gboolean Drawer::eventHandler(GtkWidget *widget, GdkEvent *event, Drawer *drawer return TRUE; case GDK_EXPOSE: - drawTopView(widget, &event->expose, NULL); + drawTopView(widget, &event->expose, &drawer->window->getLevel(), &drawer->window->getEditManager()); return TRUE; case GDK_MOTION_NOTIFY: @@ -46,32 +45,11 @@ gboolean Drawer::eventHandler(GtkWidget *widget, GdkEvent *event, Drawer *drawer return TRUE; case GDK_LEAVE_NOTIFY: - setHoveredVertex(NULL); - drawer->window->update(); + drawer->window->getEditManager().setHoveredVertex(NULL); return TRUE; case GDK_BUTTON_PRESS: - switch(event->button.button) { - case 1: - if(!getHoveredVertex()) - break; - - switch(drawer->window->getEditManager().getMode()) { - case EditManager::VIEW: - setActiveRoom(getHoveredRoom()); - break; - - case EditManager::ADD: - if(isVertexOk(getHoveredVertex())) - drawer->window->getEditManager().addVertex(*getHoveredVertex()); - } - - drawer->window->update(); - break; - - default: - return FALSE; - } + drawer->window->getEditManager().buttonPress(event->button.button); return TRUE; case GDK_SCROLL: @@ -118,13 +96,13 @@ void Drawer::updateViewport() { } void Drawer::updateScrolling() { - if(getImageWidth() < getWidth()) - setXTranslate((getImageWidth()-getWidth())/2); + if(getImageWidth(&window->getLevel()) < getWidth()) + setXTranslate((getImageWidth(&window->getLevel())-getWidth())/2); else setXTranslate(gtk_adjustment_get_value(hAdjustment)); - if(getImageHeight() < getHeight()) - setYTranslate((getImageHeight()-getHeight())/2); + if(getImageHeight(&window->getLevel()) < getHeight()) + setYTranslate((getImageHeight(&window->getLevel())-getHeight())/2); else setYTranslate(gtk_adjustment_get_value(vAdjustment)); @@ -132,7 +110,7 @@ void Drawer::updateScrolling() { } void Drawer::updateScrollbars(float x, float y) { - const gdouble imageWidth = getImageWidth(), imageHeight = getImageHeight(); + const gdouble imageWidth = getImageWidth(&window->getLevel()), imageHeight = getImageHeight(&window->getLevel()); const gdouble width = getWidth(), height = getHeight(); gdouble upper, pageSize, value; @@ -165,10 +143,8 @@ void Drawer::updateScrollbars(float x, float y) { void Drawer::updateHoveredPoint(float x, float y) { Vertex v(x, y); - viewToImage(&v); - setHoveredVertex(&v); - - window->update(); + viewToImage(&window->getLevel(), &v); + window->getEditManager().setHoveredVertex(&v); } Drawer::Drawer(Window *window, GdkGLConfig *glconfig) { |