summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2008-05-03 15:05:01 +0200
committerneoraider <devnull@localhost>2008-05-03 15:05:01 +0200
commit1d6f52984dfef698516ae3fef142c80c2029fc7b (patch)
tree079f955dc1605d1f9b8426b5e178e42b03d0fbf5 /src
parenteb096e97d63c3bdbb2913dc0bb8abacef5ee3bf1 (diff)
downloadzoomedit-1d6f52984dfef698516ae3fef142c80c2029fc7b.tar
zoomedit-1d6f52984dfef698516ae3fef142c80c2029fc7b.zip
zoomedit:
* Some MapView improvements
Diffstat (limited to 'src')
-rw-r--r--src/Gui/RenderArea.cpp4
-rw-r--r--src/View/MapView.cpp28
-rw-r--r--src/View/MapView.h2
-rw-r--r--src/View/TopView.cpp5
-rw-r--r--src/View/TopView.h2
-rw-r--r--src/View/View.h2
6 files changed, 38 insertions, 5 deletions
diff --git a/src/Gui/RenderArea.cpp b/src/Gui/RenderArea.cpp
index 2611102..b6686f5 100644
--- a/src/Gui/RenderArea.cpp
+++ b/src/Gui/RenderArea.cpp
@@ -149,8 +149,8 @@ bool RenderArea::onMotionNotifyEvent(GdkEventMotion *event) {
return true;
}
- if(event->state & GDK_BUTTON3_MASK && view)
- view->move(this, xHover - event->x, yHover - event->y);
+ if(view)
+ view->move(this, xHover - event->x, yHover - event->y, event->state);
xHover = event->x;
yHover = event->y;
diff --git a/src/View/MapView.cpp b/src/View/MapView.cpp
index 69c9d2f..5727c86 100644
--- a/src/View/MapView.cpp
+++ b/src/View/MapView.cpp
@@ -30,6 +30,34 @@
namespace ZoomEdit {
namespace View {
+void MapView::zoom(Gui::RenderArea*, int zoom, float, float) {
+ if(!mainArea)
+ return;
+
+ TopView *mainView = dynamic_cast<TopView*>(mainArea->getView());
+ if(!mainView)
+ return;
+
+ mainView->zoom(mainArea, zoom, 0, 0);
+}
+
+void MapView::move(Gui::RenderArea*, float x, float y, unsigned int state) {
+ if(!mainArea)
+ return;
+
+ TopView *mainView = dynamic_cast<TopView*>(mainArea->getView());
+ if(!mainView)
+ return;
+
+ if(!(state & GDK_BUTTON1_MASK))
+ return;
+
+ mainView->setXCenter(mainView->getXCenter() - x/scale);
+ mainView->setYCenter(mainView->getYCenter() - y/scale);
+
+ mainArea->queue_draw();
+}
+
void MapView::click(Gui::RenderArea *renderArea, float x, float y) {
if(!mainArea)
return;
diff --git a/src/View/MapView.h b/src/View/MapView.h
index b60304b..2fb0df4 100644
--- a/src/View/MapView.h
+++ b/src/View/MapView.h
@@ -52,6 +52,8 @@ class MapView : public View {
Gui::RenderArea* getMainArea() {return mainArea;}
void setMainArea(Gui::RenderArea *mainArea0) {mainArea = mainArea0;}
+ virtual void zoom(Gui::RenderArea*, int zoom, float, float);
+ virtual void move(Gui::RenderArea*, float x, float y, unsigned int state);
virtual void click(Gui::RenderArea *renderArea, float x, float y);
virtual void render(Gui::RenderArea *renderArea);
diff --git a/src/View/TopView.cpp b/src/View/TopView.cpp
index e0004fb..29fc242 100644
--- a/src/View/TopView.cpp
+++ b/src/View/TopView.cpp
@@ -152,7 +152,10 @@ void TopView::zoom(Gui::RenderArea *renderArea, int zoom, float x, float y) {
renderArea->queue_draw();
}
-void TopView::move(Gui::RenderArea *renderArea, float x, float y) {
+void TopView::move(Gui::RenderArea *renderArea, float x, float y, unsigned int state) {
+ if(!(state & GDK_BUTTON3_MASK))
+ return;
+
xCenter += x/scale;
yCenter += y/scale;
diff --git a/src/View/TopView.h b/src/View/TopView.h
index b6221f9..1fa81ad 100644
--- a/src/View/TopView.h
+++ b/src/View/TopView.h
@@ -66,7 +66,7 @@ class TopView : public View {
void setLevel(Data::Level *level0) {level = level0;}
virtual void zoom(Gui::RenderArea *renderArea, int zoom, float x, float y);
- virtual void move(Gui::RenderArea *renderArea, float x, float y);
+ virtual void move(Gui::RenderArea *renderArea, float x, float y, unsigned int state);
virtual void render(Gui::RenderArea *renderArea);
diff --git a/src/View/View.h b/src/View/View.h
index f6a8606..446a4f6 100644
--- a/src/View/View.h
+++ b/src/View/View.h
@@ -35,7 +35,7 @@ class View {
virtual void render(Gui::RenderArea *renderArea) = 0;
virtual void zoom(Gui::RenderArea*, int, float, float) {}
- virtual void move(Gui::RenderArea*, float, float) {}
+ virtual void move(Gui::RenderArea*, float, float, unsigned int) {}
virtual void click(Gui::RenderArea*, float, float) {}
};