summaryrefslogtreecommitdiffstats
path: root/src/Gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/Gui')
-rw-r--r--src/Gui/RenderArea.cpp56
-rw-r--r--src/Gui/RenderArea.h9
-rw-r--r--src/Gui/Window.cpp8
-rw-r--r--src/Gui/Window.h2
4 files changed, 37 insertions, 38 deletions
diff --git a/src/Gui/RenderArea.cpp b/src/Gui/RenderArea.cpp
index b6686f5..41f76a6 100644
--- a/src/Gui/RenderArea.cpp
+++ b/src/Gui/RenderArea.cpp
@@ -52,35 +52,45 @@ RenderArea::RenderArea(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade:
gtk_widget_set_gl_capability(GTK_WIDGET(cobject), glconfig, 0, TRUE, GDK_GL_RGBA_TYPE);
}
+void RenderArea::setView(View::View *view0) {
+ view = view0;
+
+ if(viewUpdate)
+ viewUpdate.disconnect();
+
+ if(view) {
+ viewUpdate = view->signalUpdate().connect(sigc::mem_fun(this, &RenderArea::queue_draw));
+
+ if(is_realized()) {
+ if(!gdkGLBegin())
+ return;
+
+ view->init();
+ view->resize(get_width(), get_height());
+
+ gdkGLEnd();
+
+ queue_draw();
+ }
+ }
+}
+
void RenderArea::onRealize() {
if(!gdkGLBegin())
return;
- glClearColor(0, 0, 0, 0);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_POINT_SMOOTH);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ if(view)
+ view->init();
gdkGLEnd();
}
-bool RenderArea::onConfigureEvent(GdkEventConfigure*) {
+bool RenderArea::onConfigureEvent(GdkEventConfigure *event) {
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);
+ if(view)
+ view->resize(event->width, event->height);
gdkGLEnd();
@@ -94,7 +104,7 @@ bool RenderArea::onExposeEvent(GdkEventExpose*) {
return false;
if(view)
- view->render(this);
+ view->render();
gdkSwapBuffers();
gdkGLEnd();
@@ -106,10 +116,10 @@ bool RenderArea::onScrollEvent(GdkEventScroll *event) {
if(view) {
switch(event->direction) {
case GDK_SCROLL_UP:
- view->zoom(this, 1, event->x - get_width()/2, event->y - get_height()/2);
+ view->zoom(1, event->x - get_width()/2, event->y - get_height()/2);
return true;
case GDK_SCROLL_DOWN:
- view->zoom(this, -1, event->x - get_width()/2, event->y - get_height()/2);
+ view->zoom(-1, event->x - get_width()/2, event->y - get_height()/2);
return true;
default:
return false;
@@ -121,7 +131,7 @@ bool RenderArea::onScrollEvent(GdkEventScroll *event) {
bool RenderArea::onButtonPressEvent(GdkEventButton *event) {
if(view && event->button == 1)
- view->click(this, event->x, event->y);
+ view->click(event->x, event->y);
return true;
}
@@ -150,7 +160,7 @@ bool RenderArea::onMotionNotifyEvent(GdkEventMotion *event) {
}
if(view)
- view->move(this, xHover - event->x, yHover - event->y, event->state);
+ view->move(xHover - event->x, yHover - event->y, event->state);
xHover = event->x;
yHover = event->y;
diff --git a/src/Gui/RenderArea.h b/src/Gui/RenderArea.h
index 6aa66df..d42a352 100644
--- a/src/Gui/RenderArea.h
+++ b/src/Gui/RenderArea.h
@@ -38,21 +38,20 @@ class RenderArea : public Gtk::DrawingArea {
RenderArea(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade::Xml>&);
View::View* getView() const {return view;}
- void setView(View::View *view0) {
- view = view0;
- queue_draw();
- }
+ void setView(View::View *view0);
private:
static GdkGLConfig *glconfig;
View::View *view;
+ sigc::connection viewUpdate;
+
bool inWindow;
gdouble xHover, yHover;
void onRealize();
- bool onConfigureEvent(GdkEventConfigure*);
+ bool onConfigureEvent(GdkEventConfigure *event);
bool onExposeEvent(GdkEventExpose*);
bool onScrollEvent(GdkEventScroll *event);
bool onButtonPressEvent(GdkEventButton *event);
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index df20876..f33edf0 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -29,9 +29,6 @@ Window::Window(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade::Xml> &x
xml->get_widget_derived("RenderArea", renderArea);
xml->get_widget_derived("MapArea", mapArea);
-
- if(renderArea)
- renderArea->signal_expose_event().connect_notify(sigc::mem_fun(this, &Window::updateMap));
}
Window::~Window() {
@@ -42,10 +39,5 @@ Window::~Window() {
delete mapArea;
}
-void Window::updateMap(GdkEventExpose*) {
- if(mapArea)
- mapArea->queue_draw();
-}
-
}
}
diff --git a/src/Gui/Window.h b/src/Gui/Window.h
index 9b4f4ef..d2bd7aa 100644
--- a/src/Gui/Window.h
+++ b/src/Gui/Window.h
@@ -32,8 +32,6 @@ class Window : public Gtk::Window {
private:
RenderArea *renderArea, *mapArea;
- void updateMap(GdkEventExpose*);
-
public:
Window(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade::Xml> &xml);
virtual ~Window();