public static void LayoutControl(UI.Control ctrl, int x, int y, int w, int h, IntRect screenrect) { // x,y,w,h are relative to 1280x720 ctrl.X = (int)((x / 1280.0f) * screenrect.Width); ctrl.Y = (int)((y / 720.0f) * screenrect.Height); ctrl.Width = (int)((w / 1280.0f) * screenrect.Width); ctrl.Height = (int)((h / 720.0f) * screenrect.Height); }
public void MouseMove(int absx, int absy) { CheckState(); int mx = absx - X; int my = absy - Y; Control h = null; if (modelfocus != null) { mx -= modelfocus.AbsX; my -= modelfocus.AbsY; h = modelfocus.TraceRelative(mx, my); } else h = TraceRelative(mx, my); if (h != hovered) { bool pressed = false; if (hovered != null) { if (hovered.Pressed) { hovered.SetPressed(false, true); pressed = true; } hovered.SetHovered(false); } hovered = h; if (hovered != null) { hovered.SetHovered(true); if (pressed) hovered.SetPressed(true, true); } } }
private void CheckState() { if (hovered != null && hovered.Removed) hovered = null; if (modelfocus != null && modelfocus.Removed) modelfocus = null; if (focus != null && focus.Removed) focus = null; }
public static void LayoutControl(UI.Control ctrl, Vector2u pos, int width, int height, IntRect screenrect) { LayoutControl(ctrl, (int)pos.X, (int)pos.Y, width, height, screenrect); }
public static void LayoutControl(UI.Control ctrl, int x, int y, Vector2u size, IntRect screenrect) { LayoutControl(ctrl, x, y, (int)size.X, (int)size.Y, screenrect); }
public static void LayoutControl(UI.Control ctrl, Vector2u pos, Vector2u size, IntRect screenrect) { LayoutControl(ctrl, (int)pos.X, (int)pos.Y, (int)size.X, (int)size.Y, screenrect); }