cancel drawing when the mouse moves in / out of the zoom window, fixes #228
This commit is contained in:
parent
c325543402
commit
1a2e3a11fc
@ -379,6 +379,20 @@ void GameController::AdjustZoomSize(int direction, bool logarithmic)
|
|||||||
gameModel->SetZoomFactor(newZoomFactor);
|
gameModel->SetZoomFactor(newZoomFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GameController::MouseInZoom(ui::Point position)
|
||||||
|
{
|
||||||
|
if(position.X >= XRES)
|
||||||
|
position.X = XRES-1;
|
||||||
|
if(position.Y >= YRES)
|
||||||
|
position.Y = YRES-1;
|
||||||
|
if(position.Y < 0)
|
||||||
|
position.Y = 0;
|
||||||
|
if(position.X < 0)
|
||||||
|
position.X = 0;
|
||||||
|
|
||||||
|
return gameModel->MouseInZoom(position);
|
||||||
|
}
|
||||||
|
|
||||||
ui::Point GameController::PointTranslate(ui::Point point)
|
ui::Point GameController::PointTranslate(ui::Point point)
|
||||||
{
|
{
|
||||||
if(point.X >= XRES)
|
if(point.X >= XRES)
|
||||||
|
@ -141,6 +141,7 @@ public:
|
|||||||
void FrameStep();
|
void FrameStep();
|
||||||
void TranslateSave(ui::Point point);
|
void TranslateSave(ui::Point point);
|
||||||
void TransformSave(matrix2d transform);
|
void TransformSave(matrix2d transform);
|
||||||
|
bool MouseInZoom(ui::Point position);
|
||||||
ui::Point PointTranslate(ui::Point point);
|
ui::Point PointTranslate(ui::Point point);
|
||||||
ui::Point NormaliseBlockCoord(ui::Point point);
|
ui::Point NormaliseBlockCoord(ui::Point point);
|
||||||
std::string ElementResolve(int type, int ctype);
|
std::string ElementResolve(int type, int ctype);
|
||||||
|
@ -691,6 +691,20 @@ ui::Point GameModel::GetZoomPosition()
|
|||||||
return ren->zoomScopePosition;
|
return ren->zoomScopePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GameModel::MouseInZoom(ui::Point position)
|
||||||
|
{
|
||||||
|
if (!GetZoomEnabled())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int zoomFactor = GetZoomFactor();
|
||||||
|
ui::Point zoomWindowPosition = GetZoomWindowPosition();
|
||||||
|
ui::Point zoomWindowSize = ui::Point(GetZoomSize()*zoomFactor, GetZoomSize()*zoomFactor);
|
||||||
|
|
||||||
|
if (position.X >= zoomWindowPosition.X && position.X >= zoomWindowPosition.Y && position.X <= zoomWindowPosition.X+zoomWindowSize.X && position.Y <= zoomWindowPosition.Y+zoomWindowSize.Y)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ui::Point GameModel::AdjustZoomCoords(ui::Point position)
|
ui::Point GameModel::AdjustZoomCoords(ui::Point position)
|
||||||
{
|
{
|
||||||
if (!GetZoomEnabled())
|
if (!GetZoomEnabled())
|
||||||
|
@ -181,6 +181,7 @@ public:
|
|||||||
int GetZoomFactor();
|
int GetZoomFactor();
|
||||||
void SetZoomPosition(ui::Point position);
|
void SetZoomPosition(ui::Point position);
|
||||||
ui::Point GetZoomPosition();
|
ui::Point GetZoomPosition();
|
||||||
|
bool MouseInZoom(ui::Point position);
|
||||||
ui::Point AdjustZoomCoords(ui::Point position);
|
ui::Point AdjustZoomCoords(ui::Point position);
|
||||||
void SetZoomWindowPosition(ui::Point position);
|
void SetZoomWindowPosition(ui::Point position);
|
||||||
ui::Point GetZoomWindowPosition();
|
ui::Point GetZoomWindowPosition();
|
||||||
|
@ -158,6 +158,7 @@ GameView::GameView():
|
|||||||
toolIndex(0),
|
toolIndex(0),
|
||||||
zoomEnabled(false),
|
zoomEnabled(false),
|
||||||
zoomCursorFixed(false),
|
zoomCursorFixed(false),
|
||||||
|
mouseInZoom(false),
|
||||||
drawPoint1(0, 0),
|
drawPoint1(0, 0),
|
||||||
drawPoint2(0, 0),
|
drawPoint2(0, 0),
|
||||||
drawMode(DrawPoints),
|
drawMode(DrawPoints),
|
||||||
@ -1040,6 +1041,7 @@ void GameView::setToolButtonOffset(int offset)
|
|||||||
|
|
||||||
void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
||||||
{
|
{
|
||||||
|
bool newMouseInZoom = c->MouseInZoom(ui::Point(x, y));
|
||||||
mousePosition = c->PointTranslate(ui::Point(x, y));
|
mousePosition = c->PointTranslate(ui::Point(x, y));
|
||||||
currentMouse = ui::Point(x, y);
|
currentMouse = ui::Point(x, y);
|
||||||
if (selectMode != SelectNone)
|
if (selectMode != SelectNone)
|
||||||
@ -1048,13 +1050,21 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
|||||||
selectPoint1 = c->PointTranslate(ui::Point(x, y));
|
selectPoint1 = c->PointTranslate(ui::Point(x, y));
|
||||||
if (selectPoint1.X != -1)
|
if (selectPoint1.X != -1)
|
||||||
selectPoint2 = c->PointTranslate(ui::Point(x, y));
|
selectPoint2 = c->PointTranslate(ui::Point(x, y));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (isMouseDown && drawMode == DrawPoints)
|
else if (isMouseDown)
|
||||||
{
|
{
|
||||||
pointQueue.push(ui::Point(c->PointTranslate(ui::Point(x-dx, y-dy))));
|
if (newMouseInZoom == mouseInZoom)
|
||||||
pointQueue.push(ui::Point(c->PointTranslate(ui::Point(x, y))));
|
{
|
||||||
|
if (drawMode == DrawPoints)
|
||||||
|
{
|
||||||
|
pointQueue.push(ui::Point(c->PointTranslate(ui::Point(x-dx, y-dy))));
|
||||||
|
pointQueue.push(ui::Point(c->PointTranslate(ui::Point(x, y))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (drawMode == DrawPoints || drawMode == DrawFill)
|
||||||
|
isMouseDown = false;
|
||||||
}
|
}
|
||||||
|
mouseInZoom = newMouseInZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::OnMouseDown(int x, int y, unsigned button)
|
void GameView::OnMouseDown(int x, int y, unsigned button)
|
||||||
|
@ -43,6 +43,7 @@ private:
|
|||||||
bool isMouseDown;
|
bool isMouseDown;
|
||||||
bool zoomEnabled;
|
bool zoomEnabled;
|
||||||
bool zoomCursorFixed;
|
bool zoomCursorFixed;
|
||||||
|
bool mouseInZoom;
|
||||||
bool drawSnap;
|
bool drawSnap;
|
||||||
bool shiftBehaviour;
|
bool shiftBehaviour;
|
||||||
bool ctrlBehaviour;
|
bool ctrlBehaviour;
|
||||||
|
Reference in New Issue
Block a user