internal virtual void DoLayout() { ProcessDocking(); for (int i = 0; i < children.Count; i++) { var control = children[i]; control.SetPosition( Calc.Clamp(control.X, this.Padding, this.W - this.Padding - control.W), Calc.Clamp(control.Y, this.Padding, this.H - this.Padding - control.H) ); int newW = control.W; int newH = control.H; if (control.X + control.W > this.W - Padding) { newW = this.W - control.X - Padding; } if (control.Y + control.H > this.H - Padding) { newH = this.H - control.Y - Padding; } control.Resize(newW, newH); } }
public override void DrawSlider(Canvas canvas, GuiSlider slider) { int x = slider.GlobalX; int y = slider.GlobalY; int w = slider.W; int h = slider.H; float valueFactor = (float)slider.Value / (slider.MaxValue - slider.MinValue); if (slider.Orientation == Orientation.Horizontal) { DrawFrame( canvas, x, y, w, h, ControlBorder, ControlFill); int indicatorSize = (int)(valueFactor * w); indicatorSize = Calc.Clamp(indicatorSize, 0, w - 4); canvas.FillRect(x + 2, y + 2, indicatorSize, h - 4, AccentColor); var label_x = x + w / 2 - 4; var label_y = y + h / 2 - 4; canvas.DrawText(font, label_x, label_y, slider.Value.ToString(), Color.White, 0.25f); } else { DrawFrame( canvas, x, y, w, h, ControlBorder, ControlFill); int indicatorSize = (int)((float)slider.Value / (slider.MaxValue - slider.MinValue) * h); indicatorSize = Calc.Clamp(indicatorSize, 0, h - 4); canvas.FillRect(x + 2, y + 2, w - 3, indicatorSize, AccentColor); var label_x = x + w / 2 - 4; var label_y = y + h / 2 - 4; canvas.DrawText(font, label_x, label_y, slider.Value.ToString(), Color.White, 0.25f); } }
public Color(Color color, int alpha) { if ((alpha & 0xFFFFFF00) != 0) { var clampedA = (uint)Calc.Clamp(alpha, Byte.MinValue, Byte.MaxValue); abgr = (color.abgr & 0x00FFFFFF) | (clampedA << 24); } else { abgr = (color.abgr & 0x00FFFFFF) | ((uint)alpha << 24); } }
public Color(int r, int g, int b, int alpha) { if (((r | g | b | alpha) & 0xFFFFFF00) != 0) { var clampedR = (uint)Calc.Clamp(r, Byte.MinValue, Byte.MaxValue); var clampedG = (uint)Calc.Clamp(g, Byte.MinValue, Byte.MaxValue); var clampedB = (uint)Calc.Clamp(b, Byte.MinValue, Byte.MaxValue); var clampedA = (uint)Calc.Clamp(alpha, Byte.MinValue, Byte.MaxValue); abgr = (clampedA << 24) | (clampedB << 16) | (clampedG << 8) | (clampedR); } else { abgr = ((uint)alpha << 24) | ((uint)b << 16) | ((uint)g << 8) | (uint)r; } }
public Color(int r, int g, int b) { abgr = 0xFF000000; // A = 255 if (((r | g | b) & 0xFFFFFF00) != 0) { var clampedR = (uint)Calc.Clamp(r, Byte.MinValue, Byte.MaxValue); var clampedG = (uint)Calc.Clamp(g, Byte.MinValue, Byte.MaxValue); var clampedB = (uint)Calc.Clamp(b, Byte.MinValue, Byte.MaxValue); abgr |= (clampedB << 16) | (clampedG << 8) | clampedR; } else { abgr |= ((uint)b << 16) | ((uint)g << 8) | (uint)r; } }
private void ApplySquareClamp() { Left = new Vector2(Calc.Clamp(Left.X, -1f, 1f), Calc.Clamp(Left.Y, -1f, 1f)); Right = new Vector2(Calc.Clamp(Right.X, -1f, 1f), Calc.Clamp(Right.Y, -1f, 1f)); }