internal bool m_Alt; // for alternate coloring /// <summary> /// Initializes a new instance of the <see cref="CategoryButton"/> class. /// </summary> /// <param name="parent">Parent control.</param> public CategoryButton(Controls.ControlBase parent) : base(parent) { Alignment = Pos.Left | Pos.CenterV; m_Alt = false; IsToggle = true; TextPadding = new Padding(3, 0, 3, 0); }
/// <summary> /// Initializes a new instance of the <see cref="TreeToggleButton"/> class. /// </summary> /// <param name="parent">Parent control.</param> public TreeToggleButton(Controls.ControlBase parent) : base(parent) { AutoSizeToContents = false; IsToggle = true; IsTabable = false; }
public virtual void DrawPanel(Controls.ControlBase control, byte panelapha) { Renderer.DrawColor = Color.FromArgb(panelapha, Colors.Background); Renderer.DrawFilledRect(control.RenderBounds); Renderer.DrawColor = Color.FromArgb(panelapha, Colors.BackgroundHighlight); Renderer.DrawLinedRect(control.RenderBounds); }
public override void DrawScrollButton(Controls.ControlBase control, Pos direction, bool depressed, bool hovered, bool disabled) { DrawButton(control, depressed, false, false); m_Renderer.DrawColor = Color.FromArgb(240, 0, 0, 0); Rectangle r = new Rectangle(control.Width / 2 - 2, control.Height / 2 - 2, 5, 5); if (direction == Pos.Top) { DrawArrowUp(r); } else if (direction == Pos.Bottom) { DrawArrowDown(r); } else if (direction == Pos.Left) { DrawArrowLeft(r); } else { DrawArrowRight(r); } }
public override void DrawButton(Controls.ControlBase control, bool depressed, bool hovered, bool disabled) { int w = control.Width; int h = control.Height; DrawButton(w, h, depressed, hovered); }
public virtual void DrawDebugOutlines(Controls.ControlBase control) { m_Renderer.DrawColor = control.PaddingOutlineColor; Rectangle inner = new Rectangle(control.Bounds.Left + control.Padding.Left, control.Bounds.Top + control.Padding.Top, control.Bounds.Width - control.Padding.Right - control.Padding.Left, control.Bounds.Height - control.Padding.Bottom - control.Padding.Top); m_Renderer.DrawLinedRect(inner); m_Renderer.DrawColor = control.MarginOutlineColor; Rectangle outer = new Rectangle(control.Bounds.Left - control.Margin.Left, control.Bounds.Top - control.Margin.Top, control.Bounds.Width + control.Margin.Right + control.Margin.Left, control.Bounds.Height + control.Margin.Bottom + control.Margin.Top); m_Renderer.DrawLinedRect(outer); m_Renderer.DrawColor = control.BoundsOutlineColor; m_Renderer.DrawLinedRect(control.Bounds); if (control is Controls.Label label) { m_Renderer.DrawColor = control.PaddingOutlineColor; inner = new Rectangle(control.Bounds.Left + label.TextPadding.Left, control.Bounds.Top + label.TextPadding.Top, control.Bounds.Width - label.TextPadding.Right - label.TextPadding.Left, control.Bounds.Height - label.TextPadding.Bottom - label.TextPadding.Top); m_Renderer.DrawLinedRect(inner); } }
public override void DrawHighlight(Controls.ControlBase control) { Rectangle rect = control.RenderBounds; m_Renderer.DrawColor = Color.FromArgb(255, 255, 100, 255); m_Renderer.DrawFilledRect(rect); }
public override void DrawGroupBox(Controls.ControlBase control, int textStart, int textHeight, int textWidth) { Rectangle rect = control.RenderBounds; rect.Y += (int)(textHeight * 0.5f); rect.Height -= (int)(textHeight * 0.5f); Color m_colDarker = Color.FromArgb(50, 0, 50, 60); Color m_colLighter = Color.FromArgb(150, 255, 255, 255); m_Renderer.DrawColor = m_colLighter; m_Renderer.DrawFilledRect(new Rectangle(rect.X + 1, rect.Y + 1, textStart - 3, 1)); m_Renderer.DrawFilledRect(new Rectangle(rect.X + 1 + textStart + textWidth, rect.Y + 1, rect.Width - textStart + textWidth - 2, 1)); m_Renderer.DrawFilledRect(new Rectangle(rect.X + 1, (rect.Y + rect.Height) - 1, rect.Width - 2, 1)); m_Renderer.DrawFilledRect(new Rectangle(rect.X + 1, rect.Y + 1, 1, rect.Height)); m_Renderer.DrawFilledRect(new Rectangle((rect.X + rect.Width) - 2, rect.Y + 1, 1, rect.Height - 1)); m_Renderer.DrawColor = m_colDarker; m_Renderer.DrawFilledRect(new Rectangle(rect.X + 1, rect.Y, textStart - 3, 1)); m_Renderer.DrawFilledRect(new Rectangle(rect.X + 1 + textStart + textWidth, rect.Y, rect.Width - textStart - textWidth - 2, 1)); m_Renderer.DrawFilledRect(new Rectangle(rect.X + 1, (rect.Y + rect.Height) - 1, rect.Width - 2, 1)); m_Renderer.DrawFilledRect(new Rectangle(rect.X, rect.Y + 1, 1, rect.Height - 1)); m_Renderer.DrawFilledRect(new Rectangle((rect.X + rect.Width) - 1, rect.Y + 1, 1, rect.Height - 1)); }
public override void DrawTabButton(Controls.ControlBase control, bool active, Pos dir) { Rectangle rect = control.RenderBounds; bool bHovered = control.IsHovered; if (bHovered) { m_Renderer.DrawColor = m_colControlBright; } else { m_Renderer.DrawColor = m_colControl; } m_Renderer.DrawFilledRect(new Rectangle(1, 1, rect.Width - 2, rect.Height - 1)); if (bHovered) { m_Renderer.DrawColor = m_colControl; } else { m_Renderer.DrawColor = m_colControlDark; } m_Renderer.DrawFilledRect(Util.FloatRect(1, rect.Height * 0.5f, rect.Width - 2, rect.Height * 0.5f - 1)); m_Renderer.DrawColor = m_colControlBright; m_Renderer.DrawShavedCornerRect(new Rectangle(1, 1, rect.Width - 2, rect.Height)); m_Renderer.DrawColor = m_colBorderColor; m_Renderer.DrawShavedCornerRect(new Rectangle(0, 0, rect.Width, rect.Height)); }
public static void ControlDeleted(Controls.ControlBase control) { if (SourceControl == control) { SourceControl = null; CurrentPackage = null; HoveredControl = null; m_LastPressedControl = null; } if (m_LastPressedControl == control) { m_LastPressedControl = null; } if (HoveredControl == control) { HoveredControl = null; } if (m_NewHoveredControl == control) { m_NewHoveredControl = null; } }
private static void UpdateHoveredControl(Controls.ControlBase inCanvas) { Controls.ControlBase hovered = inCanvas.GetControlAt(MousePosition.X, MousePosition.Y); if (hovered != HoveredControl) { if (HoveredControl != null) { var oldHover = HoveredControl; HoveredControl = null; oldHover.InputMouseLeft(); } HoveredControl = hovered; if (HoveredControl != null) { HoveredControl.InputMouseEntered(); } } if (MouseFocus != null && MouseFocus.GetCanvas() == inCanvas) { if (HoveredControl != null) { var oldHover = HoveredControl; HoveredControl = null; oldHover.Redraw(); } HoveredControl = MouseFocus; } }
public override void DrawKeyboardHighlight(Controls.ControlBase control, Rectangle r, int iOffset) { Rectangle rect = r; rect.X += iOffset; rect.Y += iOffset; rect.Width -= iOffset * 2; rect.Height -= iOffset * 2; //draw the top and bottom bool skip = true; for (int i = 0; i < rect.Width * 0.5; i++) { m_Renderer.DrawColor = Color.FromArgb(255, 0, 0, 0); if (!skip) { m_Renderer.DrawPixel(rect.X + (i * 2), rect.Y); m_Renderer.DrawPixel(rect.X + (i * 2), rect.Y + rect.Height - 1); } else { skip = false; } } for (int i = 0; i < rect.Height * 0.5; i++) { m_Renderer.DrawColor = Color.FromArgb(255, 0, 0, 0); m_Renderer.DrawPixel(rect.X, rect.Y + i * 2); m_Renderer.DrawPixel(rect.X + rect.Width - 1, rect.Y + i * 2); } }
public static void OnMouseMoved(Controls.ControlBase hoveredControl, int x, int y) { // Always keep these up to date, they're used to draw the dragged control. m_MouseX = x; m_MouseY = y; // If we're not carrying anything, then check to see if we should // pick up from a control that we're holding down. If not, then forget it. if (CurrentPackage == null && !ShouldStartDraggingControl(x, y)) { return; } // Swap to this new hovered control and notify them of the change. UpdateHoveredControl(hoveredControl, x, y); if (HoveredControl == null) { return; } // Update the hovered control every mouse move, so it can show where // the dropped control will land etc.. HoveredControl.DragAndDrop_Hover(CurrentPackage, x, y); // Override the cursor - since it might have been set my underlying controls // Ideally this would show the 'being dragged' control. TODO Platform.Neutral.SetCursor(Cursors.Default); hoveredControl.Redraw(); }
public static bool OnMouseButton(Controls.ControlBase hoveredControl, int x, int y, bool down) { if (!down) { m_LastPressedControl = null; // Not carrying anything, allow normal actions if (CurrentPackage == null) { return(false); } // We were carrying something, drop it. onDrop(x, y); return(true); } if (hoveredControl == null) { return(false); } if (!hoveredControl.DragAndDrop_Draggable()) { return(false); } // Store the last clicked on control. Don't do anything yet, // we'll check it in OnMouseMoved, and if it moves further than // x pixels with the mouse down, we'll start to drag. m_LastPressedPos = new Point(x, y); m_LastPressedControl = hoveredControl; return(false); }
/// <summary> /// Initializes a new instance of the <see cref="CategoryHeaderButton"/> class. /// </summary> /// <param name="parent">Parent control.</param> public CategoryHeaderButton(Controls.ControlBase parent) : base(parent) { ShouldDrawBackground = false; IsToggle = true; Alignment = Pos.Center; TextPadding = new Padding(3, 0, 3, 0); }
/// <summary> /// Initializes a new instance of the <see cref="Modal"/> class. /// </summary> /// <param name="parent">Parent control.</param> public Modal(Controls.ControlBase parent) : base(parent) { KeyboardInputEnabled = true; MouseInputEnabled = true; ShouldDrawBackground = true; SetBounds(0, 0, GetCanvas().Width, GetCanvas().Height); }
public static void Cancel(Controls.ControlBase control) { if (m_Animations.ContainsKey(control)) { m_Animations[control].Clear(); m_Animations.Remove(control); } }
/// <summary> /// Initializes a new instance of the <see cref="TreeNodeLabel"/> class. /// </summary> /// <param name="parent">Parent control.</param> public TreeNodeLabel(Controls.ControlBase parent) : base(parent) { Alignment = Pos.Left | Pos.CenterV; ShouldDrawBackground = false; Height = 16; TextPadding = new Padding(3, 0, 3, 0); }
/// <summary> /// Initializes a new instance of the <see cref="Resizer"/> class. /// </summary> /// <param name="parent">Parent control.</param> public Resizer(Controls.ControlBase parent) : base(parent) { m_ResizeDir = Pos.Left; MouseInputEnabled = true; SetSize(6, 6); Target = parent; }
/// <summary> /// Initializes a new instance of the <see cref="TreeNodeLabel"/> class. /// </summary> /// <param name="parent">Parent control.</param> public TreeNodeLabel(Controls.ControlBase parent) : base(parent) { Alignment = Pos.Left | Pos.CenterV; ShouldDrawBackground = false; AutoSizeToContents = true; TextPadding = new Padding(3, 0, 3, 0); }
/// <summary> /// Initializes a new instance of the <see cref="Modal"/> class. /// </summary> /// <param name="parent">Parent control.</param> public Modal(Controls.ControlBase parent) : base(parent) { KeyboardInputEnabled = true; MouseInputEnabled = true; ShouldDrawBackground = true; Invalidate(); }
/// <summary> /// Mouse moved handler. /// </summary> /// <param name="canvas">Canvas.</param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="dx"></param> /// <param name="dy"></param> public static void OnMouseMoved(Controls.ControlBase canvas, int x, int y, int dx, int dy) { // Send input to canvas for study MousePosition.X = x; MousePosition.Y = y; UpdateHoveredControl(canvas); }
public override void DrawDropDownArrow(Controls.ControlBase control, bool hovered, bool depressed, bool open, bool disabled) { m_Renderer.DrawColor = Color.FromArgb(240, 0, 0, 0); Rectangle r = new Rectangle(control.Width / 2 - 2, control.Height / 2 - 2, 5, 5); DrawArrowDown(r); }
public override void DrawCheckBox(Controls.ControlBase control, bool selected, bool depressed) { Rectangle rect = control.RenderBounds; // Inside colour if (control.IsHovered) { m_Renderer.DrawColor = Color.FromArgb(255, 220, 242, 254); } else { m_Renderer.DrawColor = m_colControlBright; } m_Renderer.DrawFilledRect(rect); // Border if (control.IsHovered) { m_Renderer.DrawColor = Color.FromArgb(255, 85, 130, 164); } else { m_Renderer.DrawColor = m_colControlOutlineLight; } m_Renderer.DrawLinedRect(rect); m_Renderer.DrawColor = Color.FromArgb(15, 0, 50, 60); m_Renderer.DrawFilledRect(new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height - 4)); m_Renderer.DrawFilledRect(Util.FloatRect(rect.X + 2, rect.Y + 2, rect.Width * 0.3f, rect.Height - 4)); m_Renderer.DrawFilledRect(Util.FloatRect(rect.X + 2, rect.Y + 2, rect.Width - 4, rect.Height * 0.3f)); if (control.IsHovered) { m_Renderer.DrawColor = Color.FromArgb(255, 121, 198, 249); } else { m_Renderer.DrawColor = Color.FromArgb(50, 0, 50, 60); } m_Renderer.DrawFilledRect(new Rectangle(rect.X + 2, rect.Y + 2, 1, rect.Height - 4)); m_Renderer.DrawFilledRect(new Rectangle(rect.X + 2, rect.Y + 2, rect.Width - 4, 1)); if (depressed) { m_Renderer.DrawColor = Color.FromArgb(255, 100, 100, 100); Rectangle r = new Rectangle(control.Width / 2 - 2, control.Height / 2 - 2, 5, 5); DrawCheck(r); } else if (selected) { m_Renderer.DrawColor = Color.FromArgb(255, 0, 0, 0); Rectangle r = new Rectangle(control.Width / 2 - 2, control.Height / 2 - 2, 5, 5); DrawCheck(r); } }
/// <summary> /// Initializes a new instance of the <see cref="Text"/> class. /// </summary> /// <param name="parent">Parent control.</param> public Text(Controls.ControlBase parent) : base(parent) { m_Font = Skin.DefaultFont; m_String = String.Empty; TextColor = Skin.Colors.Label.Default; MouseInputEnabled = false; TextColorOverride = Color.FromArgb(0, 255, 255, 255); // A==0, override disabled }
public virtual void DrawPropertyTreeNode(Controls.ControlBase control, int BorderLeft, int BorderTop) { Rectangle rect = control.RenderBounds; m_Renderer.DrawColor = Colors.ForegroundHighlight; m_Renderer.DrawFilledRect(new Rectangle(rect.X, rect.Y, BorderLeft, rect.Height)); m_Renderer.DrawFilledRect(new Rectangle(rect.X + BorderLeft, rect.Y, rect.Width - BorderLeft, BorderTop)); }
private static void UpdateHoveredControl(Controls.ControlBase control, int x, int y) { // // We use this global variable to represent our hovered control // That way, if the new hovered control gets deleted in one of the // Hover callbacks, we won't be left with a hanging pointer. // This isn't ideal - but it's minimal. // m_NewHoveredControl = control; // Nothing to change.. if (HoveredControl == m_NewHoveredControl) { return; } // We changed - tell the old hovered control that it's no longer hovered. if (HoveredControl != null && HoveredControl != m_NewHoveredControl) { HoveredControl.DragAndDrop_HoverLeave(CurrentPackage); } // If we're hovering where the control came from, just forget it. // By changing it to null here we're not going to show any error cursors // it will just do nothing if you drop it. if (m_NewHoveredControl == SourceControl) { m_NewHoveredControl = null; } // Check to see if the new potential control can accept this type of package. // If not, ignore it and show an error cursor. while (m_NewHoveredControl != null && !m_NewHoveredControl.DragAndDrop_CanAcceptPackage(CurrentPackage)) { // We can't drop on this control, so lets try to drop // onto its parent.. m_NewHoveredControl = m_NewHoveredControl.Parent; // Its parents are dead. We can't drop it here. // Show the NO WAY cursor. if (m_NewHoveredControl == null) { Platform.Neutral.SetCursor(Cursors.No); } } // Become out new hovered control HoveredControl = m_NewHoveredControl; // If we exist, tell us that we've started hovering. if (HoveredControl != null) { HoveredControl.DragAndDrop_HoverEnter(CurrentPackage, x, y); } m_NewHoveredControl = null; }
public static void Add(Controls.ControlBase control, Animation animation) { animation.m_Control = control; if (!m_Animations.ContainsKey(control)) { m_Animations[control] = new List <Animation>(); } m_Animations[control].Add(animation); }
public override void DrawModalControl(Controls.ControlBase control) { if (control.ShouldDrawBackground) { Rectangle rect = control.RenderBounds; Renderer.DrawColor = m_colModal; Renderer.DrawFilledRect(rect); } }
public override void DrawMenuDivider(Controls.ControlBase control) { Rectangle rect = control.RenderBounds; Renderer.DrawColor = m_colBGDark; Renderer.DrawFilledRect(rect); Renderer.DrawColor = m_colControlDarker; Renderer.DrawLinedRect(rect); }