public static GUILayerItem AlignItem(GUILayerItem item, LayoutRules.Positioning xPos, LayoutRules.Positioning yPos) { item.LayoutRules.XAxisPositionRule = xPos; item.LayoutRules.YAxisPositionRule = yPos; return(item); }
public void AddItem(GUILayerItem item) { layoutManager.PlaceItem(item, this); item.Init(device); itemsList.Add(item); itemsLayout.Insert(item); }
public void PlaceItem(GUILayerItem item, ILayer layer) { LayoutRules rules = item.LayoutRules; // position int xValue = 0; switch (rules.XAxisPositionRule) { case LayoutRules.Positioning.Near: case LayoutRules.Positioning.Absolute: xValue = rules.XAxisPositionValue; break; case LayoutRules.Positioning.Far: if (rules.XAxisPositionValueType == LayoutRules.ValueType.Percentage) xValue = 100 - rules.XAxisPositionValue; else xValue = layer.Dimensions.Width + rules.XAxisPositionValue - item.Dimensions.Width; break; case LayoutRules.Positioning.Center: if (rules.XAxisPositionValueType == LayoutRules.ValueType.Percentage) xValue = 50 + rules.XAxisPositionValue; else xValue = (layer.Dimensions.Width / 2) + rules.XAxisPositionValue; break; } if (rules.XAxisPositionValueType == LayoutRules.ValueType.Percentage) xValue = (int)(100f * (xValue / (float)layer.Dimensions.Width)); xValue += layer.Position.X; int yValue = 0; switch (rules.YAxisPositionRule) { case LayoutRules.Positioning.Near: case LayoutRules.Positioning.Absolute: yValue = rules.YAxisPositionValue; break; case LayoutRules.Positioning.Far: if (rules.YAxisPositionValueType == LayoutRules.ValueType.Percentage) yValue = 100 - rules.YAxisPositionValue; else yValue = layer.Dimensions.Height + rules.YAxisPositionValue - item.Dimensions.Height; break; case LayoutRules.Positioning.Center: if (rules.YAxisPositionValueType == LayoutRules.ValueType.Percentage) yValue = 50 + rules.YAxisPositionValue; else yValue = (layer.Dimensions.Height / 2) + rules.YAxisPositionValue; break; } if (rules.YAxisPositionValueType == LayoutRules.ValueType.Percentage) yValue = (int)(100f * (yValue / (float)layer.Dimensions.Height)); yValue += layer.Position.Y; item.Origin = new Point(xValue, yValue); item.Center = new Point(xValue + (item.Dimensions.Width / 2), yValue + (item.Dimensions.Height / 2)); }
public GUILayerItem TraceCollisionPointer(Point location) { List <GUILayerItem> items = null; itemsLayout.CheckRadius(location.X, location.Y, ref items); if (items != null && items.Count > 0) { // choose last item found as it's drawn above any overlapping items in this layer GUILayerItem item = items[items.Count - 1]; items.Clear(); return(item); } return(null); }
public void AddItem(GUILayerItem item, EventHandler mouseEnter, EventHandler mouseLeave, MouseEventHandler mouseClick) { layoutManager.PlaceItem(item, this); item.Init(device); itemsList.Add(item); itemsLayout.Insert(item); if (mouseEnter != null) item.MouseEnter += mouseEnter; if (mouseLeave != null) item.MouseLeave += mouseLeave; if (mouseClick != null) { item.MouseClick += mouseClick; item.WantMouseClicks = true; } }
public void AddItem(GUILayerItem item, EventHandler mouseEnter, EventHandler mouseLeave, MouseEventHandler mouseClick) { layoutManager.PlaceItem(item, this); item.Init(device); itemsList.Add(item); itemsLayout.Insert(item); if (mouseEnter != null) { item.MouseEnter += mouseEnter; } if (mouseLeave != null) { item.MouseLeave += mouseLeave; } if (mouseClick != null) { item.MouseClick += mouseClick; item.WantMouseClicks = true; } }
public void PlaceItem(GUILayerItem item, ILayer layer) { LayoutRules rules = item.LayoutRules; // position int xValue = 0; switch (rules.XAxisPositionRule) { case LayoutRules.Positioning.Near: case LayoutRules.Positioning.Absolute: xValue = rules.XAxisPositionValue; break; case LayoutRules.Positioning.Far: if (rules.XAxisPositionValueType == LayoutRules.ValueType.Percentage) { xValue = 100 - rules.XAxisPositionValue; } else { xValue = layer.Dimensions.Width + rules.XAxisPositionValue - item.Dimensions.Width; } break; case LayoutRules.Positioning.Center: if (rules.XAxisPositionValueType == LayoutRules.ValueType.Percentage) { xValue = 50 + rules.XAxisPositionValue; } else { xValue = (layer.Dimensions.Width / 2) + rules.XAxisPositionValue; } break; } if (rules.XAxisPositionValueType == LayoutRules.ValueType.Percentage) { xValue = (int)(100f * (xValue / (float)layer.Dimensions.Width)); } xValue += layer.Position.X; int yValue = 0; switch (rules.YAxisPositionRule) { case LayoutRules.Positioning.Near: case LayoutRules.Positioning.Absolute: yValue = rules.YAxisPositionValue; break; case LayoutRules.Positioning.Far: if (rules.YAxisPositionValueType == LayoutRules.ValueType.Percentage) { yValue = 100 - rules.YAxisPositionValue; } else { yValue = layer.Dimensions.Height + rules.YAxisPositionValue - item.Dimensions.Height; } break; case LayoutRules.Positioning.Center: if (rules.YAxisPositionValueType == LayoutRules.ValueType.Percentage) { yValue = 50 + rules.YAxisPositionValue; } else { yValue = (layer.Dimensions.Height / 2) + rules.YAxisPositionValue; } break; } if (rules.YAxisPositionValueType == LayoutRules.ValueType.Percentage) { yValue = (int)(100f * (yValue / (float)layer.Dimensions.Height)); } yValue += layer.Position.Y; item.Origin = new Point(xValue, yValue); item.Center = new Point(xValue + (item.Dimensions.Width / 2), yValue + (item.Dimensions.Height / 2)); }
public void RemoveItem(GUILayerItem item) { itemsList.Remove(item); itemsLayout.Remove(item); item.Dispose(); }
public static GUILayerItem AlignItem(GUILayerItem item, LayoutRules.Positioning xPos, LayoutRules.Positioning yPos) { item.LayoutRules.XAxisPositionRule = xPos; item.LayoutRules.YAxisPositionRule = yPos; return item; }
public bool OnLayerMouseMove(MouseEventArgs e) { // TODO: Needs to use persistent markers for mouse pos in each layer // try each layer from top to bottom foreach (ILayer layer in layers) { if (layer.Enabled && layer is SimpleGUILayer) { SimpleGUILayer guiLayer = (SimpleGUILayer)layer; GUILayerItem item; if ((item = guiLayer.TraceCollisionPointer(e.Location)) != null && item.Visible/* && item.Enabled*/) { if (item.WantMouseOver && layerMouseOverItem != item) { item.OnMouseEnter(); if (layerMouseOverItem != null && layerMouseOverItem.WantMouseOver) layerMouseOverItem.OnMouseLeave(); layerMouseOverItem = item; } return true; } } } if (layerMouseOverItem != null) { layerMouseOverItem.OnMouseLeave(); layerMouseOverItem = null; return true; } return false; }
public bool OnLayerMouseUp(MouseEventArgs e) { // find new item (that does not want mouseover) // try each layer from top to bottom foreach (ILayer layer in layers) { if (layer.Enabled && layer is SimpleGUILayer) { SimpleGUILayer guiLayer = (SimpleGUILayer)layer; GUILayerItem item; if ((item = guiLayer.TraceCollisionPointer(e.Location)) != null && item.Visible/* && item.Enabled*/) { if (item == layerMouseDownItem) layerMouseDownItem.OnMouseUp(e); else if (layerMouseDownItem != null) layerMouseDownItem.OnMouseUp(null); layerMouseDownItem = null; return true; } } } if (layerMouseOverItem != null) layerMouseOverItem.OnMouseUp(e); return false; }
public bool OnLayerMouseDown(MouseEventArgs e) { if (layerMouseOverItem != null) { // use existing found item if (layerMouseOverItem.WantMouseClicks) layerMouseOverItem.OnMouseDown(e); layerMouseDownItem = layerMouseOverItem; return true; } else { // find new item (that does not want mouseover) // try each layer from top to bottom foreach (ILayer layer in layers) { if (layer.Enabled && layer is SimpleGUILayer) { SimpleGUILayer guiLayer = (SimpleGUILayer)layer; GUILayerItem item; if ((item = guiLayer.TraceCollisionPointer(e.Location)) != null && item.Visible/* && item.Enabled*/) { if (item.WantMouseClicks) { item.OnMouseDown(e); layerMouseDownItem = item; } return true; } } } } return false; }