// Resizes the sprite to accomidate the gui component public void resize(Point2i pt, Size2i size) { vertices[0]= new Point3f(pt.x, pt.y, 0f); vertices[1]= new Point3f(pt.x, pt.y+size.height, 0f); vertices[2]= new Point3f(pt.x+size.width, pt.y+size.height, 0f); vertices[3]= new Point3f(pt.x+size.width, pt.y, 0f); bvolume= new BVBox(pt.toPoint3f(), (pt+size).toPoint3f()); }
internal MouseHelper(Viewport pmViewport) { viewport= pmViewport; held= new bool[]{false, false, false, false, false}; lastPosition= Point2f.ORIGIN; currPosition= Point2f.ORIGIN; movement= Vector2.ZERO; bLockToCenter= false; bPrevLock= false; tick= 0; mouseWheel= 0; viewport.LostFocus+= onLostFocus; viewport.MouseDown+= onMouseDown; viewport.MouseUp+= onMouseUp; viewport.MouseLeave+= onMouseLeave; viewport.MouseHover+= onMouseHover; viewport.MouseWheel+= onMouseWheelMoved; viewport.GotFocus+= onGotFocus; }
// Subtracts the two points to get a vector pointing in between both public Vector3 subtract(Point2i pt) { return new Vector3(x-(float)pt.x, y-(float)pt.y, z); }
// Finds if the given 2d point is inside the volume public override bool contains(ref Point2i pt) { return contains((float)pt.x, (float)pt.y); }
// Adds the point with the size to get another point public Point2i add(Point2i pt) { return new Point2i((int)width+pt.x, (int)height+pt.y); }
// Gets the maximum value of the point public static Point2i max(Point2i value, Point2i max) { // Variables Point2i temp= value; if(value.x> max.x) temp.x= max.x; if(value.y> max.y) temp.y= max.y; return temp; }
// Clamps the point to the given min and max bounds public static Point2i clamp(Point2i value, Point2i min, Point2i max) { // Variables Point2i temp= value; if(value.x< min.x) temp.x= min.x; else if(value.x> max.x) temp.x= max.x; if(value.y< min.y) temp.y= min.y; else if(value.y> max.y) temp.y= max.y; return temp; }
// Subtracts the two points to get a vector pointing in between both public Vector2 subtract(Point2i pt) { return new Vector2((float)(x-pt.x), (float)(y-pt.y)); }
public virtual bool contains(Point2i pt) { return contains(ref pt); }
// Finds if the given 2d point is inside the volume public abstract bool contains(ref Point2i pt);
// Updates the mouse movement internal void updateMouseMovement() { mouseWheel= 0; currPosition= (Point2i)(viewport.PointToClient(Cursor.Position)); if(pLockToCenter && tick> 4) { // Variables int hw= viewport.Size.Width/2; int hh= viewport.Size.Height/2; tick= 0; movement.x= currPosition.x-hw; movement.y= hh-currPosition.y; Cursor.Position= viewport.PointToScreen(new Sdx.Point(hw, hh)); } else if(bLockToCenter) tick++; else if(tick!= 24) tick= 24; else if(!bLockToCenter) { movement= currPosition-lastPosition; movement.y*= -1; lastPosition.x= currPosition.x; lastPosition.y= currPosition.y; } }
// Sets the position of the mouse public void setPosition(Point2i pt) { Cursor.Position= pt.toSysPoint(); }
// Multiplies a 2d point to affect it public Point2i multiply(Point2i pt) { return new Point2i ( (int)(xx*pt.x+yx*pt.y+ox), (int)(xy*pt.x+yy*pt.y+oy) ); }
// Finds if the two points are equal public bool equals(Point2i pt) { return (x== pt.x && y== pt.y); }
// Adds the point with the vector to get a new point public Point2i add(Point2i pt) { return new Point2i((int)x+pt.x, (int)y+pt.y); }
// Gets the midpoint of the two points public Point2f getMidpoint(Point2i pt) { return new Point2f((float)(x+pt.x)/2f, (float)(y+pt.y)/2f); }
// Subtracts the point with the vector to get a new point public Point2i subtract(Point2i pt) { return new Point2i((int)x-pt.x, (int)y-pt.y); }
// Cuts off part the rendering screen public void startScissorCut(Point2i location, Size2i size) { Gl.glEnable(Gl.GL_SCISSOR_TEST); Gl.glScissor(location.x, location.y+size.height, size.width, size.height); }
// Subtracts the two points to get a vector pointing in between both public Vector3 subtract(Point2i pt) { return new Vector3((float)(x-pt.x), (float)(y-pt.y), (float)z); }
// Gets the most minimum point of the two given points public static Point2i getMostMin(Point2i val1, Point2i val2) { // Variables Point2i pt= Point2i.ORIGIN; if(val1.x< val2.x) pt.x= val1.x; else pt.x= val2.x; if(val1.y< val2.y) pt.y= val1.y; else pt.y= val2.y; return pt; }
// Finds if the two points are equal public bool equals(Point2i pt) { return ((int)x== pt.x && (int)y== pt.y); }
// Gets the minimum value of the point public static Point2i min(Point2i value, Point2i min) { // Variables Point2i temp= value; if(value.x< min.x) temp.x= min.x; if(value.y< min.y) temp.y= min.y; return temp; }
// Subtracts the two points to get a vector pointing in between both public Vector2 subtract(Point2i pt) { return new Vector2(x-(float)pt.x, y-(float)pt.y); }
// Subtracts the point with the size to get another point public Point2i subtract(Point2i pt) { return new Point2i((int)width-pt.x, (int)height-pt.y); }
// Gets the midpoint of the two points public Point3f getMidpoint(Point2i pt) { return new Point3f((x+(float)pt.x)/2f, (y+(float)pt.y)/2f, z/2f); }
public Rectangle(Point2i pmPos, Size2i pmSize) : this((Point2f)pmPos, (Size2f)pmSize) { }
public Circle(Point2i pmPos, float r) : this((Point2f)pmPos, r) { }