public virtual void SetBounds(float?x, float?z, float?width = null, float?height = null) { float parentX = Parent == null ? 0 : Parent.Absolute_X; float parentz = Parent == null ? 0 : Parent.Absolute_Y; if (x.HasValue) { location.X = Scale.hPosScale(x.Value) - parentX; } if (z.HasValue) { location.Y = Scale.vPosScale(z.Value) - parentz; } if (width.HasValue) { size.X = Scale.hSizeScale(width.Value); } if (height.HasValue) { size.Y = Scale.vSizeScale(height.Value); } Singleton <GUI> .INSTANCE.Dirty = true; }
public VerticalScrollbar(int id, float width, float height, float maxvalue) : base(id) { maxValue = maxvalue; fontHeight = (float)Scale.vSizeScale(Client.window.Qfont.fontData.maxGlyphHeight); SetBounds(null, null, width, height); AddAppearence(); gui = Singleton <GUI> .INSTANCE; }
void AddAppearence() { appearence.AddAppearence <PlainBackground>("background", new PlainBackground(Color4.DarkGray)); appearence.AddAppearence <PlainBorder>("border", new PlainBorder(1.5f, Color4.Yellow)); button = new Button(Color4.Gray, Color4.LightGray); button.handler = new WidgetEventHandler() { mousemovehandler = (widget, e) => { widget.location.Y += Scale.vSizeScale(e.YDelta) * -2f; if (widget.location.Y > widget.Parent.size.Y - widget.size.Y) { widget.location.Y = widget.Parent.size.Y - widget.size.Y; } else if (widget.Absolute_Y < widget.Parent.Absolute_Y) { widget.location.Y = 0; } float newvalue = Math.Abs((float)Scale.scale(widget.location.Y, 0, widget.Parent.size.Y - widget.size.Y, startValue, maxValue) - (startValue + (maxValue - maxTextShow))); gui.Dirty = true; if ((int)value != (int)newvalue && (int)newvalue != -2147483648) { lastvalue = value; value = newvalue; // todo broadcast messgae... maybe a handler HandleScrollbarChanged(); } } }; button.Parent = this; button.size.X = this.size.X * 1.3f; UpdateScrollbar(maxValue); }
public static float ScaleVerticlSize(this float value) { return(Scale.vSizeScale(value)); }
public void MatchTextureBounds(Widget widget) { widget.size.X = Scale.hSizeScale(texture.Width) * 2 * Singleton <GUI> .INSTANCE.scale; widget.size.Y = Scale.vSizeScale(texture.Height) * 2 * Singleton <GUI> .INSTANCE.scale; }