Editor: Add feature to zoom to the current mouse position

This commit is contained in:
BeaR 2014-07-31 12:56:07 +02:00 committed by oy
parent b34e455e4c
commit 90617421eb
3 changed files with 20 additions and 0 deletions

View file

@ -4074,10 +4074,18 @@ void CEditor::Render()
if(m_Dialog == DIALOG_NONE && UI()->MouseInside(&View))
{
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP))
{
m_ZoomLevel -= 20;
if(g_Config.m_EdZoomTarget)
ZoomMouseTarget((float)m_ZoomLevel/(m_ZoomLevel+20));
}
if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN))
{
m_ZoomLevel += 20;
if(g_Config.m_EdZoomTarget)
ZoomMouseTarget((float)m_ZoomLevel/(m_ZoomLevel-20));
}
}
m_ZoomLevel = clamp(m_ZoomLevel, 50, 2000);
m_WorldZoom = m_ZoomLevel/100.0f;
@ -4233,6 +4241,16 @@ int CEditor::GetLineDistance()
return LineDistance;
}
void CEditor::ZoomMouseTarget(float ZoomFactor)
{
// zoom to the current mouse position
float mx = UI()->MouseWorldX();
float my = UI()->MouseWorldY();
m_EditorOffsetX += (mx-m_EditorOffsetX) * (1-ZoomFactor);
m_EditorOffsetY += (my-m_EditorOffsetY) * (1-ZoomFactor);
}
void CEditorMap::DeleteEnvelope(int Index)
{
if(Index < 0 || Index >= m_lEnvelopes.size())

View file

@ -837,6 +837,7 @@ public:
}
int GetLineDistance();
void ZoomMouseTarget(float ZoomFactor);
};
// make sure to inline this function

View file

@ -28,6 +28,7 @@ MACRO_CONFIG_INT(ClMouseMaxDistance, cl_mouse_max_distance, 800, 0, 0, CFGFLAG_C
MACRO_CONFIG_INT(ClCustomizeSkin, cl_customize_skin, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
MACRO_CONFIG_INT(EdZoomTarget, ed_zoom_target, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Zoom to the current mouse target")
MACRO_CONFIG_INT(EdShowkeys, ed_showkeys, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
//MACRO_CONFIG_INT(ClFlow, cl_flow, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")