public virtual void Render(Image image, IntRect rectOffset, SUI_Element parentElement) { var offsetVec = new IntVector2(rectOffset.Left + positionRect.Left, rectOffset.Top + positionRect.Top); offset = new IntRect(offsetVec.X, offsetVec.Y, rectOffset.Right, rectOffset.Bottom); if (needUpdate) { if (imageElement.Width != positionRect.Bottom || imageElement.Height != positionRect.Right) { imageElement.Resize( positionRect.Right < minWidth ? minWidth : positionRect.Right, positionRect.Bottom < minHeight ? minHeight : positionRect.Bottom); imageElement.Clear(Color.Transparent); } Paint(parentElement); needUpdate = false; } if (!needUpdate) { CopyRectFromImage(imageElement, image, new IntRect(0, 0, imageElement.Width, imageElement.Height), offsetVec); } if (Node.GetNumChildren(false) > 0) { RenderChild(image); } }
public override void Paint(SUI_Element parentElement) { var UI = Icons.UI.GetImage(); var x = 0; positionRect.Right = parentElement.positionRect.Right - positionRect.Left; positionRect.Bottom = Icons.font2_glyph_height < minHeight ? minHeight : Icons.font2_glyph_height; imageElement.SetSize(parentElement.positionRect.Right, positionRect.Bottom, 4); clipRect = new IntRect(0, 0, imageElement.Width, imageElement.Height); simpleUI.app.LogInfo($"node:{Node.Name}, wh:{imageElement.Width},{imageElement.Height}"); if (isSelected || isHover) { imageElement.Clear(selectedColor); } else { imageElement.Clear(Color.Transparent); } if (Node.GetNumChildren(false) > 0) { if (isExpand) { CopyRectFromImage(UI, imageElement, new IntRect(10, 27, 9, 11), new IntVector2(0, 4)); } else { CopyRectFromImage(UI, imageElement, new IntRect(10, 16, 9, 11), new IntVector2(0, 4)); } x += 11 + 2; } x += DrawText(x, (imageElement.Height - Icons.font2_glyph_height) / 2, Node.Name, false); imageElement.SavePNG("cr_window.png"); }
public SUI_Element AddUI(SUI element, string name, int[] args = null, Node nn = null) { needUdate = true; SUI_Element result = null; Node n = null; if (nn == null) { n = Node.CreateChild(name); } else { n = nn.CreateChild(name); //nn.GetComponent<SUI_Element>().needUpdate = true; } switch (element) { default: result = n.CreateComponent <SUI_Element>(); break; case SUI.WINDOW: result = n.CreateComponent <SUI_Window>(); break; case SUI.NODE: result = n.CreateComponent <SUI_Node>(); break; } if (args != null) { result.SetArgs(args); } result.simpleUI = this; return(result); }
public virtual void Paint(SUI_Element parentElement) { }
public override void Paint(SUI_Element parentElement) { var UI = Icons.UI.GetImage(); var x = 0; var y = 0; var rc = 5; var w = positionRect.Right - rc; var h = positionRect.Bottom - rc; //top { CopyRectFromImage(UI, imageElement, new IntRect(0, 0, 16, 8), new IntVector2(x, y)); x += 16; var el_w = 50; int count = (int)Math.Floor(w / (double)el_w); for (int i = 0; i < count; i++) { CopyRectFromImage(UI, imageElement, new IntRect(16, 0, el_w, 8), new IntVector2(x, y)); x += el_w; } if (x < w) { var ww = w - x; CopyRectFromImage(UI, imageElement, new IntRect(16, 0, ww, 8), new IntVector2(x, y)); x += ww; } CopyRectFromImage(UI, imageElement, new IntRect(75, 0, rc, 8), new IntVector2(x, y)); } //height { y += 8; var el_w = 50; int count = (int)Math.Floor(w / (double)50d); int count2 = (int)Math.Floor(h / 4d); for (int j = 0; j < count2; j++) { x = 0; CopyRectFromImage(UI, imageElement, new IntRect(0, 8, 4, 4), new IntVector2(x, y)); x += 4; for (int i = 0; i < count; i++) { CopyRectFromImage(UI, imageElement, new IntRect(4, 8, el_w, 4), new IntVector2(x, y)); x += el_w; } if (x < w) { var ww = w - x; CopyRectFromImage(UI, imageElement, new IntRect(4, 8, ww, 4), new IntVector2(x, y)); x += ww; } CopyRectFromImage(UI, imageElement, new IntRect(75, 8, rc, 4), new IntVector2(x, y)); y += 4; } if (y < h) { var wh = h - y; // } } //bottom { x = 0; y = h; CopyRectFromImage(UI, imageElement, new IntRect(0, 11, 6, 5), new IntVector2(x, y)); x = 6; int count = (int)Math.Floor(w / 20d); for (int i = 0; i < count; i++) { CopyRectFromImage(UI, imageElement, new IntRect(6, 11, 20, 5), new IntVector2(x, y)); x += 20; } if (x < w) { var ww = w - x; CopyRectFromImage(UI, imageElement, new IntRect(6, 11, ww, 5), new IntVector2(x, y)); x += ww; } CopyRectFromImage(UI, imageElement, new IntRect(75, 11, rc, 5), new IntVector2(x, y)); } //imageElement.SavePNG("cr_window.png"); }