mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 22:41:46 +00:00
added view panning control
This commit is contained in:
parent
d514c8837a
commit
7426b77dc4
2 changed files with 58 additions and 0 deletions
|
@ -61,6 +61,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
|
|
||||||
// Mouse status
|
// Mouse status
|
||||||
protected Vector2D mousepos;
|
protected Vector2D mousepos;
|
||||||
|
protected Vector2D mouselastpos;
|
||||||
protected Vector2D mousemappos;
|
protected Vector2D mousemappos;
|
||||||
protected Vector2D mousedownpos;
|
protected Vector2D mousedownpos;
|
||||||
protected Vector2D mousedownmappos;
|
protected Vector2D mousedownmappos;
|
||||||
|
@ -73,6 +74,9 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
private Vector2D selectstart;
|
private Vector2D selectstart;
|
||||||
protected RectangleF selectionrect;
|
protected RectangleF selectionrect;
|
||||||
|
|
||||||
|
// View panning
|
||||||
|
protected bool panning;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
@ -186,6 +190,21 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
General.MainWindow.UpdateCoordinates(mousemappos);
|
General.MainWindow.UpdateCoordinates(mousemappos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This sets the view to be centered at x,y
|
||||||
|
private void ScrollTo(float x, float y)
|
||||||
|
{
|
||||||
|
// Scroll now
|
||||||
|
renderer2d.PositionView(x, y);
|
||||||
|
this.OnViewChanged();
|
||||||
|
|
||||||
|
// Redraw
|
||||||
|
General.MainWindow.RedrawDisplay();
|
||||||
|
|
||||||
|
// Determine new unprojected mouse coordinates
|
||||||
|
mousemappos = renderer2d.GetMapCoordinates(mousepos);
|
||||||
|
General.MainWindow.UpdateCoordinates(mousemappos);
|
||||||
|
}
|
||||||
|
|
||||||
// This zooms
|
// This zooms
|
||||||
private void ZoomBy(float deltaz)
|
private void ZoomBy(float deltaz)
|
||||||
{
|
{
|
||||||
|
@ -327,6 +346,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
|
|
||||||
// Record last position
|
// Record last position
|
||||||
mouseinside = true;
|
mouseinside = true;
|
||||||
|
mouselastpos = mousepos;
|
||||||
mousepos = new Vector2D(e.X, e.Y);
|
mousepos = new Vector2D(e.X, e.Y);
|
||||||
mousemappos = renderer2d.GetMapCoordinates(mousepos);
|
mousemappos = renderer2d.GetMapCoordinates(mousepos);
|
||||||
mousebuttons = e.Button;
|
mousebuttons = e.Button;
|
||||||
|
@ -355,6 +375,9 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
// Selecting?
|
// Selecting?
|
||||||
if(selecting) OnUpdateMultiSelection();
|
if(selecting) OnUpdateMultiSelection();
|
||||||
|
|
||||||
|
// Panning?
|
||||||
|
if (panning) OnUpdateViewPanning();
|
||||||
|
|
||||||
// Let the base class know
|
// Let the base class know
|
||||||
base.OnMouseMove(e);
|
base.OnMouseMove(e);
|
||||||
}
|
}
|
||||||
|
@ -521,10 +544,35 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
General.Colors.Highlight.WithAlpha(SELECTION_ALPHA), true);
|
General.Colors.Highlight.WithAlpha(SELECTION_ALPHA), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is called automatically when the mouse is moved while panning
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void OnUpdateViewPanning()
|
||||||
|
{
|
||||||
|
// Get the map coordinates of the last mouse posision (before it moved)
|
||||||
|
Vector2D lastmappos;
|
||||||
|
lastmappos = renderer2d.GetMapCoordinates(mouselastpos);
|
||||||
|
|
||||||
|
// Do the scroll
|
||||||
|
ScrollBy(lastmappos.x - mousemappos.x, lastmappos.y - mousemappos.y);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Actions
|
#region ================== Actions
|
||||||
|
|
||||||
|
[BeginAction("pan_view", BaseAction = true)]
|
||||||
|
protected virtual void BeginViewPan()
|
||||||
|
{
|
||||||
|
panning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[EndAction("pan_view", BaseAction = true)]
|
||||||
|
protected virtual void EndViewPan()
|
||||||
|
{
|
||||||
|
panning = false;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,6 +228,16 @@ scrollsouth
|
||||||
repeat = true;
|
repeat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pan_view
|
||||||
|
{
|
||||||
|
title = "Pan View";
|
||||||
|
category = "classic";
|
||||||
|
description = "Pans the map in the direction of the mouse while held down.";
|
||||||
|
allowkeys = true;
|
||||||
|
allowmouse = true;
|
||||||
|
allowscroll = false;
|
||||||
|
}
|
||||||
|
|
||||||
zoomin
|
zoomin
|
||||||
{
|
{
|
||||||
title = "Zoom In";
|
title = "Zoom In";
|
||||||
|
|
Loading…
Reference in a new issue