zoomedit:
* Some MapView improvements
This commit is contained in:
parent
eb096e97d6
commit
1d6f52984d
6 changed files with 38 additions and 5 deletions
|
@ -149,8 +149,8 @@ bool RenderArea::onMotionNotifyEvent(GdkEventMotion *event) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event->state & GDK_BUTTON3_MASK && view)
|
if(view)
|
||||||
view->move(this, xHover - event->x, yHover - event->y);
|
view->move(this, xHover - event->x, yHover - event->y, event->state);
|
||||||
|
|
||||||
xHover = event->x;
|
xHover = event->x;
|
||||||
yHover = event->y;
|
yHover = event->y;
|
||||||
|
|
|
@ -30,6 +30,34 @@
|
||||||
namespace ZoomEdit {
|
namespace ZoomEdit {
|
||||||
namespace View {
|
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) {
|
void MapView::click(Gui::RenderArea *renderArea, float x, float y) {
|
||||||
if(!mainArea)
|
if(!mainArea)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -52,6 +52,8 @@ class MapView : public View {
|
||||||
Gui::RenderArea* getMainArea() {return mainArea;}
|
Gui::RenderArea* getMainArea() {return mainArea;}
|
||||||
void setMainArea(Gui::RenderArea *mainArea0) {mainArea = mainArea0;}
|
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 click(Gui::RenderArea *renderArea, float x, float y);
|
||||||
|
|
||||||
virtual void render(Gui::RenderArea *renderArea);
|
virtual void render(Gui::RenderArea *renderArea);
|
||||||
|
|
|
@ -152,7 +152,10 @@ void TopView::zoom(Gui::RenderArea *renderArea, int zoom, float x, float y) {
|
||||||
renderArea->queue_draw();
|
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;
|
xCenter += x/scale;
|
||||||
yCenter += y/scale;
|
yCenter += y/scale;
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class TopView : public View {
|
||||||
void setLevel(Data::Level *level0) {level = level0;}
|
void setLevel(Data::Level *level0) {level = level0;}
|
||||||
|
|
||||||
virtual void zoom(Gui::RenderArea *renderArea, int zoom, float x, float y);
|
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);
|
virtual void render(Gui::RenderArea *renderArea);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class View {
|
||||||
virtual void render(Gui::RenderArea *renderArea) = 0;
|
virtual void render(Gui::RenderArea *renderArea) = 0;
|
||||||
|
|
||||||
virtual void zoom(Gui::RenderArea*, int, float, float) {}
|
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) {}
|
virtual void click(Gui::RenderArea*, float, float) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Reference in a new issue