diff options
author | neoraider <devnull@localhost> | 2008-05-03 15:05:01 +0200 |
---|---|---|
committer | neoraider <devnull@localhost> | 2008-05-03 15:05:01 +0200 |
commit | 1d6f52984dfef698516ae3fef142c80c2029fc7b (patch) | |
tree | 079f955dc1605d1f9b8426b5e178e42b03d0fbf5 /src/View | |
parent | eb096e97d63c3bdbb2913dc0bb8abacef5ee3bf1 (diff) | |
download | zoomedit-1d6f52984dfef698516ae3fef142c80c2029fc7b.tar zoomedit-1d6f52984dfef698516ae3fef142c80c2029fc7b.zip |
zoomedit:
* Some MapView improvements
Diffstat (limited to 'src/View')
-rw-r--r-- | src/View/MapView.cpp | 28 | ||||
-rw-r--r-- | src/View/MapView.h | 2 | ||||
-rw-r--r-- | src/View/TopView.cpp | 5 | ||||
-rw-r--r-- | src/View/TopView.h | 2 | ||||
-rw-r--r-- | src/View/View.h | 2 |
5 files changed, 36 insertions, 3 deletions
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) {} }; |