public override void Update(GameTime gameTime) { if (MouseManager.MouseClicked) { CheckAlive(); } Form MouseForm = null; RelativeMousePosition = MouseManager.MousePosition - OffsetPosition; RelativeMousePoint = new Point((int)RelativeMousePosition.X, (int)RelativeMousePosition.Y); if (FormChildren != null) { float BestDistance = 100000; if (ContainsMouse) { for (int i = 0; i < FormChildren.Count(); i++) { if (FormChildren[i] != null && FormChildren[i].Active) { FormChildren[i].ContainsMouse = false; float Dist = Vector2.Distance(FormChildren[i].Position + new Vector2(0, FormChildren[i].Size.Y / 2), RelativeMousePosition); if (Dist < BestDistance) { BestDistance = Dist; MouseForm = FormChildren[i]; } } } if (MouseForm != null) { MouseForm.ContainsMouse = true; } } else { for (int i = 0; i < FormChildren.Count(); i++) { if (FormChildren[i] != null && FormChildren[i].Active) { FormChildren[i].ContainsMouse = false; } } } for (int i = 0; i < FormChildren.Count(); i++) { if (FormChildren[i] != null && FormChildren[i].Active) { FormChildren[i].Update(gameTime, this); } } } }
public virtual void DrawAdditiveChildren() { if (FormChildren != null) { for (int i = 0; i < FormChildren.Count(); i++) { if (FormChildren[i] != null && FormChildren[i].Active) { FormChildren[i].DrawAdditive(); } } } }
public override void Create(Editor ParentEditor) { { Vector2 PlacePosition = Vector2.Zero; AddForm(new DropDownButton("File", Render.BasicFont, new FileWindow(), new Vector2(0, 1), PlacePosition)); PlacePosition.X += FormChildren[FormChildren.Count() - 1].Size.X + 2; AddForm(new DropDownButton("Edit", Render.BasicFont, new EditWindow(), new Vector2(0, 1), PlacePosition)); PlacePosition.X += FormChildren[FormChildren.Count() - 1].Size.X + 2; AddForm(new DropDownButton("Object", Render.BasicFont, new ObjectWindow(), new Vector2(0, 1), PlacePosition)); PlacePosition.X += FormChildren[FormChildren.Count() - 1].Size.X + 2; AddForm(new DropDownButton("Run", Render.BasicFont, new LevelWindow(), new Vector2(0, 1), PlacePosition)); } base.Create(ParentEditor); }
public override void DrawChildren() { if (FormChildren != null) { for (int i = 0; i < FormChildren.Count(); i++) { if (FormChildren[i] != null) { FormChildren[i].Draw(); } } } if (HasScrollbar) { if (ScrollBarHorizontal.Active) { ScrollBarHorizontal.Draw(); } if (ScrollBarVertical.Active) { ScrollBarVertical.Draw(); } } }
public virtual void Update(GameTime gameTime) { if (HasScrollbar) { Rectangle bounds = GetBounds(); if (bounds.Right > MyRectangle.Width) { ScrollBarHorizontal.SetActive(true); ScrollBarHorizontal.pixelToCover = bounds.Right - MyRectangle.Width; } else { ScrollBarHorizontal.SetActive(false); ScrollBarHorizontal.self.X = 0; } if (bounds.Bottom > MyRectangle.Height) { ScrollBarVertical.SetActive(true); ScrollBarVertical.pixelToCover = bounds.Bottom - MyRectangle.Height; } else { ScrollBarVertical.SetActive(false); ScrollBarVertical.self.Y = 0; } } //added scrollbar code Vector2 offset = new Vector2((int)(ScrollBarHorizontal.self.X * ScrollBarHorizontal.difference), (int)(ScrollBarVertical.self.Y * ScrollBarVertical.difference)); RelativeMousePosition = MouseManager.MousePosition - OffsetPosition + offset; RelativeMousePoint = new Point((int)RelativeMousePosition.X, (int)RelativeMousePosition.Y); if (HasScrollbar) { if (ScrollBarHorizontal.Active) { ScrollBarHorizontal.Update(gameTime, this); ScrollBarHorizontal.Offset = offset; } if (ScrollBarVertical.Active) { ScrollBarVertical.Update(gameTime, this); ScrollBarVertical.Offset = offset; } } MouseOverForm = false; if (FormChildren != null) { for (int i = 0; i < FormChildren.Count(); i++) { if (FormChildren[i] != null && FormChildren[i].Active) { FormChildren[i].Update(gameTime, this); FormChildren[i].Offset.X = offset.X; FormChildren[i].Offset.Y = offset.Y; } } } }