Added position to mouse methods

This commit is contained in:
Jaex 2017-12-10 13:49:16 +03:00
parent 5ce01cd2be
commit 4085e5a5e4
2 changed files with 27 additions and 20 deletions

View file

@ -625,8 +625,30 @@ private new void Update()
UpdateCoordinates();
UpdateDrawableObjects();
if (ShapeManager.IsPanning)
{
Pan(InputManager.MouseVelocity);
UpdateCenterOffset();
}
borderDotPen.DashOffset = (float)timerStart.Elapsed.TotalSeconds * -15;
ShapeManager.Update();
if (scrollbarManager != null)
{
scrollbarManager.Update();
}
}
private void UpdateDrawableObjects()
{
DrawableObject[] objects = DrawableObjects.OrderByDescending(x => x.Order).ToArray();
Point position = InputManager.ClientMousePosition;
if (objects.All(x => !x.IsDragging))
{
for (int i = 0; i < objects.Count(); i++)
@ -635,13 +657,13 @@ private new void Update()
if (obj.Visible)
{
obj.IsCursorHover = obj.Rectangle.Contains(InputManager.ClientMousePosition);
obj.IsCursorHover = obj.Rectangle.Contains(position);
if (obj.IsCursorHover)
{
if (InputManager.IsMousePressed(MouseButtons.Left))
{
obj.OnMousePressed();
obj.OnMousePressed(position);
}
for (int y = i + 1; y < objects.Count(); y++)
@ -662,26 +684,11 @@ private new void Update()
{
if (obj.IsDragging)
{
obj.OnMouseReleased();
obj.OnMouseReleased(position);
}
}
}
}
if (ShapeManager.IsPanning)
{
Pan(InputManager.MouseVelocity);
UpdateCenterOffset();
}
borderDotPen.DashOffset = (float)timerStart.Elapsed.TotalSeconds * -15;
ShapeManager.Update();
if (scrollbarManager != null)
{
scrollbarManager.Update();
}
}
protected override void OnPaintBackground(PaintEventArgs e)

View file

@ -47,12 +47,12 @@ public virtual void OnDraw(Graphics g)
}
}
public virtual void OnMousePressed()
public virtual void OnMousePressed(Point position)
{
IsDragging = true;
}
public virtual void OnMouseReleased()
public virtual void OnMouseReleased(Point position)
{
IsDragging = false;
}