fix being able to change between box/line/flood fill while drawing (by releasing keys), a bunch of other extremely obscure fixes
This commit is contained in:
parent
13a71b611a
commit
a81a41b67f
@ -482,6 +482,9 @@ public:
|
|||||||
}
|
}
|
||||||
void MouseEnterCallback(ui::Button * sender)
|
void MouseEnterCallback(ui::Button * sender)
|
||||||
{
|
{
|
||||||
|
// don't immediately change the active menu, the actual set is done inside GameView::OnMouseMove
|
||||||
|
// if we change it here it causes components to be removed, which causes the window to stop sending events
|
||||||
|
// and then the previous menusection button never gets sent the OnMouseLeave event and is never unhighlighted
|
||||||
if(!needsClick && !v->GetMouseDown())
|
if(!needsClick && !v->GetMouseDown())
|
||||||
v->SetActiveMenuDelayed(menuID);
|
v->SetActiveMenuDelayed(menuID);
|
||||||
}
|
}
|
||||||
@ -1083,6 +1086,7 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
|||||||
}
|
}
|
||||||
mouseInZoom = newMouseInZoom;
|
mouseInZoom = newMouseInZoom;
|
||||||
|
|
||||||
|
// set active menu (delayed)
|
||||||
if (delayedActiveMenu)
|
if (delayedActiveMenu)
|
||||||
{
|
{
|
||||||
c->SetActiveMenu(delayedActiveMenu);
|
c->SetActiveMenu(delayedActiveMenu);
|
||||||
@ -1092,7 +1096,7 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
|||||||
|
|
||||||
void GameView::OnMouseDown(int x, int y, unsigned button)
|
void GameView::OnMouseDown(int x, int y, unsigned button)
|
||||||
{
|
{
|
||||||
ui::Point mouseDownPoint = ui::Point(x, y);
|
currentMouse = ui::Point(x, y);
|
||||||
if (altBehaviour && !shiftBehaviour && !ctrlBehaviour)
|
if (altBehaviour && !shiftBehaviour && !ctrlBehaviour)
|
||||||
button = BUTTON_MIDDLE;
|
button = BUTTON_MIDDLE;
|
||||||
if (!(zoomEnabled && !zoomCursorFixed))
|
if (!(zoomEnabled && !zoomCursorFixed))
|
||||||
@ -1101,12 +1105,12 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
|
|||||||
{
|
{
|
||||||
if (button == BUTTON_LEFT && selectPoint1.X == -1)
|
if (button == BUTTON_LEFT && selectPoint1.X == -1)
|
||||||
{
|
{
|
||||||
selectPoint1 = c->PointTranslate(mouseDownPoint);
|
selectPoint1 = c->PointTranslate(currentMouse);
|
||||||
selectPoint2 = selectPoint1;
|
selectPoint2 = selectPoint1;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mouseDownPoint.X >= 0 && mouseDownPoint.X < XRES && mouseDownPoint.Y >= 0 && mouseDownPoint.Y < YRES)
|
if (currentMouse.X >= 0 && currentMouse.X < XRES && currentMouse.Y >= 0 && currentMouse.Y < YRES)
|
||||||
{
|
{
|
||||||
if (button == BUTTON_LEFT)
|
if (button == BUTTON_LEFT)
|
||||||
toolIndex = 0;
|
toolIndex = 0;
|
||||||
@ -1118,11 +1122,11 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
|
|||||||
c->HistorySnapshot();
|
c->HistorySnapshot();
|
||||||
if (drawMode == DrawRect || drawMode == DrawLine)
|
if (drawMode == DrawRect || drawMode == DrawLine)
|
||||||
{
|
{
|
||||||
drawPoint1 = c->PointTranslate(mouseDownPoint);
|
drawPoint1 = c->PointTranslate(currentMouse);
|
||||||
}
|
}
|
||||||
if (drawMode == DrawPoints)
|
if (drawMode == DrawPoints)
|
||||||
{
|
{
|
||||||
lastPoint = currentPoint = c->PointTranslate(mouseDownPoint);
|
lastPoint = currentPoint = c->PointTranslate(currentMouse);
|
||||||
c->DrawPoints(toolIndex, lastPoint, currentPoint, false);
|
c->DrawPoints(toolIndex, lastPoint, currentPoint, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1131,6 +1135,7 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
|
|||||||
|
|
||||||
void GameView::OnMouseUp(int x, int y, unsigned button)
|
void GameView::OnMouseUp(int x, int y, unsigned button)
|
||||||
{
|
{
|
||||||
|
currentMouse = ui::Point(x, y);
|
||||||
if (zoomEnabled && !zoomCursorFixed)
|
if (zoomEnabled && !zoomCursorFixed)
|
||||||
{
|
{
|
||||||
zoomCursorFixed = true;
|
zoomCursorFixed = true;
|
||||||
@ -1184,7 +1189,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
|
|||||||
if (isMouseDown)
|
if (isMouseDown)
|
||||||
{
|
{
|
||||||
isMouseDown = false;
|
isMouseDown = false;
|
||||||
ui::Point finalDrawPoint2 = c->PointTranslate(ui::Point(x, y));
|
ui::Point finalDrawPoint2 = c->PointTranslate(currentMouse);
|
||||||
if (drawMode == DrawRect || drawMode == DrawLine)
|
if (drawMode == DrawRect || drawMode == DrawLine)
|
||||||
{
|
{
|
||||||
drawPoint2 = finalDrawPoint2;
|
drawPoint2 = finalDrawPoint2;
|
||||||
@ -1590,15 +1595,9 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
|
|
||||||
void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||||
{
|
{
|
||||||
if(ctrl && shift && drawMode != DrawPoints)
|
if (!isMouseDown)
|
||||||
drawMode = DrawFill;
|
|
||||||
else if (ctrl && drawMode != DrawPoints)
|
|
||||||
drawMode = DrawRect;
|
|
||||||
else if (shift && drawMode != DrawPoints)
|
|
||||||
drawMode = DrawLine;
|
|
||||||
else if(!isMouseDown)
|
|
||||||
drawMode = DrawPoints;
|
drawMode = DrawPoints;
|
||||||
else
|
else if (drawMode == DrawPoints)
|
||||||
drawModeReset = true;
|
drawModeReset = true;
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,12 @@ void ToolButton::OnMouseUnclick(int x, int y, unsigned int button)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolButton::OnMouseUp(int x, int y, unsigned int button)
|
||||||
|
{
|
||||||
|
// mouse was unclicked, reset variables in case the unclick happened outside
|
||||||
|
isButtonDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ToolButton::Draw(const ui::Point& screenPos)
|
void ToolButton::Draw(const ui::Point& screenPos)
|
||||||
{
|
{
|
||||||
Graphics * g = ui::Engine::Ref().g;
|
Graphics * g = ui::Engine::Ref().g;
|
||||||
|
@ -9,6 +9,7 @@ class ToolButton: public ui::Button
|
|||||||
public:
|
public:
|
||||||
ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolTip = "");
|
ToolButton(ui::Point position, ui::Point size, std::string text_, std::string toolTip = "");
|
||||||
virtual void OnMouseUnclick(int x, int y, unsigned int button);
|
virtual void OnMouseUnclick(int x, int y, unsigned int button);
|
||||||
|
virtual void OnMouseUp(int x, int y, unsigned int button);
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
virtual void Draw(const ui::Point& screenPos);
|
virtual void Draw(const ui::Point& screenPos);
|
||||||
void SetSelectionState(int state);
|
void SetSelectionState(int state);
|
||||||
|
@ -85,20 +85,17 @@ void Button::Draw(const Point& screenPos)
|
|||||||
|
|
||||||
if (Enabled)
|
if (Enabled)
|
||||||
{
|
{
|
||||||
if (isMouseInside)
|
if (isButtonDown || (isTogglable && toggle))
|
||||||
{
|
{
|
||||||
if (isButtonDown || (isTogglable && toggle))
|
textColour = Appearance.TextActive;
|
||||||
{
|
borderColour = Appearance.BorderActive;
|
||||||
textColour = Appearance.TextActive;
|
backgroundColour = Appearance.BackgroundActive;
|
||||||
borderColour = Appearance.BorderActive;
|
}
|
||||||
backgroundColour = Appearance.BackgroundActive;
|
else if (isMouseInside)
|
||||||
}
|
{
|
||||||
else
|
textColour = Appearance.TextHover;
|
||||||
{
|
borderColour = Appearance.BorderHover;
|
||||||
textColour = Appearance.TextHover;
|
backgroundColour = Appearance.BackgroundHover;
|
||||||
borderColour = Appearance.BorderHover;
|
|
||||||
backgroundColour = Appearance.BackgroundHover;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -166,6 +163,13 @@ void Button::OnMouseUnclick(int x, int y, unsigned int button)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Button::OnMouseUp(int x, int y, unsigned int button)
|
||||||
|
{
|
||||||
|
// mouse was unclicked, reset variables in case the unclick happened outside
|
||||||
|
isButtonDown = false;
|
||||||
|
isAltButtonDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
void Button::OnMouseClick(int x, int y, unsigned int button)
|
void Button::OnMouseClick(int x, int y, unsigned int button)
|
||||||
{
|
{
|
||||||
if(!Enabled)
|
if(!Enabled)
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
|
|
||||||
virtual void OnMouseClick(int x, int y, unsigned int button);
|
virtual void OnMouseClick(int x, int y, unsigned int button);
|
||||||
virtual void OnMouseUnclick(int x, int y, unsigned int button);
|
virtual void OnMouseUnclick(int x, int y, unsigned int button);
|
||||||
//virtual void OnMouseUp(int x, int y, unsigned int button);
|
virtual void OnMouseUp(int x, int y, unsigned int button);
|
||||||
|
|
||||||
virtual void OnMouseEnter(int x, int y);
|
virtual void OnMouseEnter(int x, int y);
|
||||||
virtual void OnMouseHover(int x, int y);
|
virtual void OnMouseHover(int x, int y);
|
||||||
|
Reference in New Issue
Block a user