public void RemChild(Gadget gadget) { if (children.Remove(gadget)) { gadget.parent = null; } }
public bool MouseButtonUp(int x, int y, MouseButton button) { bool result = false; Point pos = new Point(x, y); Gadget gadget = null; Window window = FindWindow(pos); if (window != null) { window.ClearDraggingAndSizing(); gadget = window.FindGadget(pos); } dragging = false; dragGadget = null; dragWindow = null; if (selectedGadget != null) { if (!selectedGadget.RelVerify || (selectedGadget == gadget)) { result = selectedGadget.HandleMouseButtonUp(selectedGadget.ScreenToGadget(pos), button); } } SetSelectedWindow(null); SetSelectedGadget(null); mousePos = pos; mouseButton &= ~button; engine.GUIUseseMouse = !result; return(result); }
public ScrollbarGadget(Gadget parent, Orientation orientation = Orientation.Horizontal) : base(parent) { arrowPlace = ArrowPlace.RightBottom; overlap = 1; increment = 1; this.orientation = orientation; bool vert = orientation == Orientation.Vertical; prop = new PropGadget(this) { FreeHoriz = !vert, FreeVert = vert, Borderless = true }; prop.PropChanged += Prop_PropChanged; arrowInc = new ButtonGadget(this, vert ? theme.ArrowDown : theme.ArrowRight) { Width = 20, Height = 20, Repeat = true, Borderless = false }; arrowInc.GadgetUp += ArrowInc_GadgetUp; arrowDec = new ButtonGadget(this, vert ? theme.ArrowUp : theme.ArrowLeft) { Height = 20, Width = 20, Repeat = true, Borderless = false }; arrowDec.GadgetUp += ArrowDec_GadgetUp; }
public bool MouseMove(int x, int y) { bool result = false; Hover = true; Point pos = new Point(x, y); Gadget gadget = null; Window window = FindWindow(pos); if (dragging && dragGadget != null) { result = dragGadget.HandleMouseDrag(dragGadget.ScreenToGadget(pos), pos - mousePos, mouseButton); } if (!result && dragging && dragWindow != null) { result = dragWindow.HandleMouseDrag(dragWindow.ScreenToGadget(pos), pos - mousePos, mouseButton); } if (window != null) { gadget = window.FindGadget(pos); } if (!result && gadget != null) { result = gadget.HandleMouseMove(gadget.ScreenToGadget(pos), mouseButton); } SetHoverWindow(window); SetHoverGadget(gadget); mousePos = pos; return(result); }
public override Point GetPreferredSize(IGraphics gfx, Gadget gadget) { Point size = new Point(2 * margin, 2 * margin); int xOffset = gadget.BorderLeft + gadget.BorderRight; int yOffset = gadget.BorderTop + gadget.BorderBottom; bool first = true; int axis1 = (int)orientation; int axis2 = (((int)orientation) + 1) % 2; foreach (var w in gadget.Children) { if (!w.Visible) { continue; } if (first) { first = false; } else { size[axis1] += spacing; } Point ps = w.GetPreferredSize(gfx); Point fs = w.FixedSize; Point targetSize = GetValidSize(ps, fs);// new Vector2(fs.X != 0 ? fs.X : ps.X, fs.Y != 0 ? fs.Y : ps.Y); size[axis1] += targetSize[axis1]; size[axis2] = Math.Max(size[axis2], targetSize[axis2] + 2 * margin); first = false; } return(size + new Point(xOffset, yOffset)); }
public StrGadget(Gadget parent, string label = "") : base(parent, label) { buffer = ""; textTabWidth = 4 * 24; lineSkip = 24; }
public PopupWindow(Gadget parent) : base(parent.Screen) { layout = new BoxLayout(Orientation.Vertical, Alignment.Fill); parentGadget = parent; parentWindow = parent.Window; ThinBorder = true; }
public ChooserGadget(Gadget parent) : base(parent) { RelVerify = false; selectedIndex = -1; items = new List <object>(); Size = new Point(64 + 24, 24); }
public SliderGadget(Gadget parent, Orientation orientation) : base(parent) { labelFormat = "{0}"; increment = 1; this.orientation = orientation; FreeHoriz = orientation == Orientation.Horizontal; FreeVert = orientation == Orientation.Vertical; }
public FileGadget(Gadget parent, IFileResolver fileResolver) : base(parent) { this.fileResolver = fileResolver; layout = new BoxLayout(Orientation.Vertical, Alignment.Fill); table = new TableGadget(this) { EvenColumns = false, SelectedCellChangedEvent = (o, i) => { TableSelectedChanged(); } }; table.AddColumn("Name", -1); table.AddColumn("Size", 64); table.AddColumn("Date", 130); table.AddColumn("Comment", 140); var dirBox = new BoxGadget(this, Orientation.Horizontal, Alignment.Fill); new LabelGadget(dirBox, "Drawer") { FixedWidth = 100 }; dirName = new StrGadget(dirBox) { FixedWidth = 300 }; var fileBox = new BoxGadget(this, Orientation.Horizontal, Alignment.Fill); new LabelGadget(fileBox, "File") { FixedWidth = 100 }; fileName = new StrGadget(fileBox) { FixedWidth = 300 }; var buttonBox = new BoxGadget(this, Orientation.Horizontal, Alignment.Fill, 0, 100); butOk = new ButtonGadget(buttonBox, "Open") { GadgetUpEvent = (o, i) => { Ok(); } }; butVolumes = new ButtonGadget(buttonBox, "Volumes") { GadgetUpEvent = (o, i) => { Volumes(); } }; butParent = new ButtonGadget(buttonBox, "Parent") { GadgetUpEvent = (o, i) => { GoToParent(); } }; butCancel = new ButtonGadget(buttonBox, "Cancel") { GadgetUpEvent = (o, i) => { Cancel(); } }; }
public TableGadget(Gadget parent) : base(parent) { evenColumns = true; showHeader = true; rowHeight = 20; headerHeight = 24; columns = new List <TableColumn>(); rows = new List <TableRow>(); vScroll = new ScrollbarGadget(this, Orientation.Vertical); }
public Gadget(Gadget parent, string label = "", Icons icon = Icons.NONE) { visible = true; enabled = true; relVerify = true; this.label = label; this.icon = icon; children = new List <Gadget>(); if (parent != null) { parent.AddChild(this); } }
public void RenderTooltip(IGraphics gfx, Gadget gadget) { if (gadget.Hover && !string.IsNullOrEmpty(gadget.TooltipText)) { var frame = gadget.Bounds; var pos = gadget.TooltipPos; var color = TextPen; Point tPos = new Point(frame.X, frame.Y); tPos += pos; gfx.RenderText(gadget.Font, gadget.TooltipText, tPos.X + 1, tPos.Y + 1, Color.Black, HorizontalTextAlign.Center, VerticalTextAlign.Bottom); gfx.RenderText(gadget.Font, gadget.TooltipText, tPos.X - 1, tPos.Y - 1, Color.Black, HorizontalTextAlign.Center, VerticalTextAlign.Bottom); gfx.RenderText(gadget.Font, gadget.TooltipText, tPos.X, tPos.Y, color, HorizontalTextAlign.Center, VerticalTextAlign.Bottom); } }
public bool MouseButtonDown(int x, int y, MouseButton button) { bool result = false; Point pos = new Point(x, y); Gadget gadget = null; Window window = FindWindow(pos); if (window != null) { window.ClearDraggingAndSizing(); gadget = window.FindGadget(pos); if (button == MouseButton.Left) { dragGadget = gadget; if (dragGadget == this) { dragGadget = null; } dragging = dragGadget != null; if (dragging) { dragWindow = dragGadget.Window; } SetFocusedWindow(window); SetFocusedGadget(gadget); } else { dragging = false; dragGadget = null; dragWindow = null; } } else { SetFocusedWindow(null); SetFocusedGadget(null); } if (gadget != null) { result = gadget.HandleMouseButtonDown(gadget.ScreenToGadget(pos), button); } SetSelectedWindow(window); SetSelectedGadget(gadget); mousePos = pos; mouseButton |= button; engine.GUIUseseMouse = result; return(result); }
public void SetHoverGadget(Gadget gadget) { if (gadget is Window) { return; } if (gadget != hoverGadget) { if (hoverGadget != null) { hoverGadget.Hover = false; } hoverGadget = gadget; if (hoverGadget != null) { hoverGadget.Hover = true; } } }
public void SetFocusedGadget(Gadget gadget) { if (gadget is Window) { return; } if (gadget != null && !gadget.Enabled) { return; } if (gadget != focusedGadget) { if (focusedGadget != null) { focusedGadget.Focused = false; } focusedGadget = gadget; if (focusedGadget != null) { focusedGadget.Focused = true; } } }
private void SetSelectedGadget(Gadget gadget) { if (gadget is Window) { return; } if (gadget != null && !gadget.Enabled) { return; } if (gadget != selectedGadget) { if (selectedGadget != null) { selectedGadget.MouseSelected = false; } selectedGadget = gadget; if (selectedGadget != null) { selectedGadget.MouseSelected = true; } } }
public NumericalGadget(Gadget parent) : base(parent) { increment = 0.1; strGadget = new StrGadget(this) { Flags = StrFlags.Double, GadgetUpEvent = (o, i) => { OnGadgetUp(); } }; upGadget = new ButtonGadget(this, Icons.ENTYPO_ICON_PLUS) { Repeat = true, Width = BUT_SIZE, Height = BUT_SIZE, GadgetUpEvent = (o, i) => { IncValue(); } }; downGadget = new ButtonGadget(this, Icons.ENTYPO_ICON_MINUS) { Repeat = true, Width = BUT_SIZE, Height = BUT_SIZE, GadgetUpEvent = (o, i) => { DecValue(); } }; }
public ButtonGadget(Gadget parent, string label, Icons icon = Icons.NONE) : base(parent, label, icon) { Size = new Point(64, 24); }
public TabPanelGadget(Gadget parent) : base(parent) { tabs = new List <TabGadget>(); tabHeaders = new List <TabHeaderGadget>(); }
public ImageGadget(Gadget parent) : base(parent) { frame = true; }
public CheckBoxGadget(Gadget parent, string label) : base(parent, label) { Size = new Point(64, 24); }
public BoxGadget(Gadget parent, Orientation orientation, Alignment alignment = Alignment.Middle, int margin = 0, int spacing = 0) : base(parent) { layout = new BoxLayout(orientation, alignment, margin, spacing); }
public SeparatorGadget(Gadget parent, Orientation orientation = Orientation.Vertical) : base(parent) { padding = 8; this.orientation = orientation; }
public virtual void AddChild(int index, Gadget gadget) { children.Insert(index, gadget); gadget.parent = this; gadget.theme = theme; }
public TabHeaderGadget(Gadget parent, string label) : base(parent, label) { Sticky = true; }
public ProgressbarGadget(Gadget parent) : base(parent) { }
public ButtonGadget(Gadget parent, Icons icon = Icons.NONE) : base(parent, "", icon) { Size = new Point(24, 24); }
public ItemGadget(Gadget parent, string label) : base(parent, label) { items = new List <ItemGadget>(); }
public void AddChild(Gadget gadget) { AddChild(children.Count, gadget); }