fix scrolling triggering zoom

This commit is contained in:
Edgar 2020-09-24 18:52:31 +02:00
parent af29d8da99
commit 76f3dbfe64
No known key found for this signature in database
GPG key ID: 8731E6C0166EAA85
3 changed files with 28 additions and 20 deletions

View file

@ -5899,26 +5899,6 @@ void CEditor::Render()
}
}
if(m_Dialog == DIALOG_NONE && UI()->MouseInside(&View))
{
// Determines in which direction to zoom.
int Zoom = 0;
if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP))
Zoom--;
if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN))
Zoom++;
if(Zoom != 0)
{
float OldLevel = m_ZoomLevel;
m_ZoomLevel = clamp(m_ZoomLevel + Zoom * 20, 50, 2000);
if(g_Config.m_EdZoomTarget)
ZoomMouseTarget((float)m_ZoomLevel / OldLevel);
}
}
m_ZoomLevel = clamp(m_ZoomLevel, 50, 2000);
m_WorldZoom = m_ZoomLevel/100.0f;
float Brightness = 0.25f;
if(m_GuiActive)
@ -6109,6 +6089,27 @@ void CEditor::Render()
UiDoPopupMenu();
if(m_Dialog == DIALOG_NONE && !m_MouseInsidePopup && UI()->MouseInside(&View))
{
// Determines in which direction to zoom.
int Zoom = 0;
if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP))
Zoom--;
if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN))
Zoom++;
if(Zoom != 0)
{
float OldLevel = m_ZoomLevel;
m_ZoomLevel = clamp(m_ZoomLevel + Zoom * 20, 50, 2000);
if(g_Config.m_EdZoomTarget)
ZoomMouseTarget((float)m_ZoomLevel / OldLevel);
}
}
m_ZoomLevel = clamp(m_ZoomLevel, 50, 2000);
m_WorldZoom = m_ZoomLevel/100.0f;
if(m_GuiActive)
RenderStatusbar(StatusBar);
@ -6147,6 +6148,8 @@ void CEditor::Render()
Graphics()->QuadsEnd();
Graphics()->WrapNormal();
}
m_MouseInsidePopup = false;
}
static int UndoStepsListdirCallback(const char *pName, int IsDir, int StorageType, void *pUser)

View file

@ -662,6 +662,7 @@ public:
m_PopupEventActivated = false;
m_PopupEventWasActivated = false;
m_MouseInsidePopup = false;
m_FileDialogStorageType = 0;
m_pFileDialogTitle = 0;
@ -818,6 +819,7 @@ public:
int m_PopupEventType;
int m_PopupEventActivated;
int m_PopupEventWasActivated;
bool m_MouseInsidePopup;
bool m_LargeLayerWasWarned;
bool m_PreventUnusedTilesWasWarned;
int m_AllowPlaceUnusedTiles;

View file

@ -52,6 +52,9 @@ void CEditor::UiDoPopupMenu()
bool Inside = UI()->MouseInside(&s_UiPopups[i].m_Rect);
UI()->SetHotItem(&s_UiPopups[i].m_pId);
if(Inside)
m_MouseInsidePopup = true;
if(UI()->ActiveItem() == &s_UiPopups[i].m_pId)
{
if(!UI()->MouseButton(0))