Example #1
0
        public QbModelTab(QbModel model)
            : base()
        {
            this.model = model;
            height     = Client.window.Qfont.fontData.maxGlyphHeight;
            height     = height.ScaleVerticlSize();

            vBorderOffset = -(3f).ScaleVerticlSize();
            hBorderOffset = (3f).ScaleHorizontalSize();

            label       = new Label(GetNextAvailableID(), model.name, System.Drawing.Color.White, true);
            closeButton = new Label(GetNextAvailableID(), "x", System.Drawing.Color.DarkRed, true);
            var size = label.MeasureText(label.text + "    ");

            closeButton.Parent = this;
            label.Parent       = this;

            closeButton.handler = new WidgetEventHandler()
            {
                mouseenter = (e) =>
                {
                    closeButton.color = Color.Red;
                },
                mouseleave = (e) =>
                {
                    closeButton.color = Color.DarkRed;
                },
                mousedownhandler = (e, mouse) =>
                {
                    if (mouse.IsPressed && mouse.Button == OpenTK.Input.MouseButton.Left)
                    {
                        var result = MessageBox.Show("There might be unsaved changes to this model. Are you sure you want to close it?", "StoneVox : Closing Model", MessageBoxButtons.OKCancel);

                        if (result == DialogResult.Cancel || result == DialogResult.Abort)
                        {
                            return;
                        }

                        Singleton <QbManager> .INSTANCE.RemoveModel(this.model);
                    }
                }
            };

            SetBounds(null, null, size.Width, height.UnScaleVerticlSize() * borderscale * 1.5f);
            closeButton.SetBoundsNoScaling(Absolute_X + this.size.X - closeButton.size.X * 1.5f, Absolute_Y + closeButton.size.Y * .9f);

            background = appearence.AddAppearence("background", new PlainBackground(new Color4(100 - 10, 87 - 10, 61 - 10, 255)));
            border     = appearence.AddAppearence("border", new PlainBorder(4, new Color4(122 - 10, 106 - 10, 70 - 10, 255)));
        }
Example #2
0
        public QbModelTab(QbModel model)
            : base()
        {
            this.model = model;
            height = Client.window.Qfont.fontData.maxGlyphHeight;
            height = height.ScaleVerticlSize();

            vBorderOffset = -(3f).ScaleVerticlSize();
            hBorderOffset = (3f).ScaleHorizontalSize();

            label = new Label(GetNextAvailableID(), model.name, System.Drawing.Color.White, true);
            closeButton = new Label(GetNextAvailableID(), "x", System.Drawing.Color.DarkRed, true);
            var size = label.MeasureText(label.text + "    ");

            closeButton.Parent = this;
            label.Parent = this;

            closeButton.handler = new WidgetEventHandler()
            {
                mouseenter = (e) =>
                {
                    closeButton.color = Color.Red;
                },
                mouseleave= (e) =>
                {
                    closeButton.color = Color.DarkRed;
                },
                mousedownhandler = (e, mouse) =>
                {
                    if (mouse.IsPressed && mouse.Button == OpenTK.Input.MouseButton.Left)
                    {
                        var result = MessageBox.Show("There might be unsaved changes to this model. Are you sure you want to close it?", "StoneVox : Closing Model", MessageBoxButtons.OKCancel);

                        if (result == DialogResult.Cancel || result == DialogResult.Abort)
                            return;

                        Singleton<QbManager>.INSTANCE.RemoveModel(this.model);
                    }
                }
            };

            SetBounds(null, null, size.Width, height.UnScaleVerticlSize() * borderscale * 1.5f);
            closeButton.SetBoundsNoScaling(Absolute_X + this.size.X - closeButton.size.X * 1.5f, Absolute_Y + closeButton.size.Y * .9f);

            background = appearence.AddAppearence("background", new PlainBackground(new Color4(100 - 10, 87 - 10, 61 - 10, 255)));
            border = appearence.AddAppearence("border", new PlainBorder(4, new Color4(122 - 10, 106 - 10, 70 - 10, 255)));
        }
Example #3
0
        void AddAppearenceColored(Color4 backgroundColor, Color4 highlightBackgroundColor)
        {
            if (backgroundImage != null)
            {
                backgroundImage.Enabled          = false;
                highlightBackgroundImage.Enabled = false;
            }

            if (highlightBackground != null)
            {
                highlightBackground.color = highlightBackgroundColor;
                background.color          = backgroundColor;
                background.Enabled        = true;
                return;
            }

            highlightBackground         = appearence.AddAppearence <PlainBackground>("highlightbackground", new PlainBackground(highlightBackgroundColor));
            highlightBackground.Enabled = false;

            background = appearence.AddAppearence <PlainBackground>("background", new PlainBackground(backgroundColor));
        }
Example #4
0
        void AddAppearenceColored(Color4 backgroundColor, Color4 highlightBackgroundColor)
        {
            if (backgroundImage != null)
            {
                backgroundImage.Enabled = false;
                highlightBackgroundImage.Enabled = false;
            }

            if (highlightBackground != null)
            {
                highlightBackground.color = highlightBackgroundColor;
                background.color = backgroundColor;
                background.Enabled = true;
                return;
            }

            highlightBackground = appearence.AddAppearence<PlainBackground>("highlightbackground", new PlainBackground(highlightBackgroundColor));
            highlightBackground.Enabled = false;

            background = appearence.AddAppearence<PlainBackground>("background", new PlainBackground(backgroundColor));
        }
Example #5
0
        public QbModelMatrixListbox(float width, float height)
            : base(-1)
        {
            //input = Singleton<ClientInput>.INSTANCE;

            ID = GetNextAvailableID();
            appearence.AddAppearence("border", new PlainBorder(6, new Color4(122f / 256f, 106f / 256f, 70f / 256f, 1f)));
            appearence.AddAppearence("background", new PlainBackground(new Color4(66, 63, 63, 255)));

            float realheight = Client.window.Qfont.fontData.maxGlyphHeight;
            float fontheight = (float)realheight * 2f;

            linecount = (int)((height.UnScaleVerticlSize()) / fontheight);

            //float labelspacing = 25f;

            textbox         = new TextBox(100000000, "", Color4.Wheat.ToSystemDrawingColor(), 1000);
            textbox.focused = true;

            fontheight = fontheight.ScaleVerticlSize();

            labels  = new List <Label>();
            buttons = new List <ToggleButton>();
            size.X  = width;
            size.Y  = linecount * fontheight;// + linecount * (labelspacing).ScaleVerticlSize();

            QbModel model    = null;
            bool    hasmodel = Singleton <QbManager> .INSTANCE.HasModel;

            if (hasmodel)
            {
                model = Singleton <QbManager> .INSTANCE.ActiveModel;
            }

            float previouseY = Absolute_Y + size.Y - realheight.ScaleVerticlSize() * 2f;

            background        = new EmptyWidget();
            background.Parent = this;
            PlainBackground bg = new PlainBackground(Color4.Black);

            background.appearence.AddAppearence("background", bg);

            for (int i = 0; i < linecount; i++)
            {
                string labeltext = "";

                if (hasmodel)
                {
                    labeltext = i < model.matrices.Count ? model.matrices[i].name : "";
                }

                Label label = new Label(GetNextAvailableID(), labeltext, System.Drawing.Color.White, true);
                label.Parent = this;
                label.SetBoundsNoScaling(Absolute_X + size.X * .08f, previouseY);

                Boolean editing = false;
                label.customData.Add("edit", editing);

                label.handler = new WidgetEventHandler()
                {
                    mousedownhandler = (e, mouse) =>
                    {
                        if (!mouse.IsPressed || mouse.Button != OpenTK.Input.MouseButton.Left)
                        {
                            return;
                        }

                        background.Enable = true;
                        bg.color          = Color4.Black;
                        background.SetBoundsNoScaling(Absolute_X, label.Absolute_Y, size.X, label.size.Y - (4f).ScaleVerticlSize());

                        QbModel m      = Singleton <QbManager> .INSTANCE.ActiveModel;
                        int     index  = labels.IndexOf(label);
                        int     offset = index + offsetindex;

                        Singleton <QbManager> .INSTANCE.ActiveMatrixIndex = offset;

                        lastActiveIndex = labels.ToList().IndexOf(label);
                    },
                    mousedoubleclick = (e, mouse) =>
                    {
                        if (!mouse.IsPressed || mouse.Button != OpenTK.Input.MouseButton.Left)
                        {
                            return;
                        }

                        QbModel m      = Singleton <QbManager> .INSTANCE.ActiveModel;
                        int     index  = labels.IndexOf(label);
                        int     offset = index + offsetindex;

                        Singleton <QbManager> .INSTANCE.ActiveMatrixIndex = offset;
                        Singleton <Camera> .INSTANCE.TransitionToMatrix();
                    },
                    mouseenter = (e) =>
                    {
                        //lastover = label;

                        int index  = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        QbModel m = Singleton <QbManager> .INSTANCE.ActiveModel;

                        m.matrices[offset].highlight = new Colort(1.5f, 1.5f, 1.5f);
                    },
                    mouseleave = (e) =>
                    {
                        int index  = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        QbModel m = Singleton <QbManager> .INSTANCE.ActiveModel;

                        m.matrices[offset].highlight = new Colort(1f, 1f, 1f);
                    },
                    Keydownhandler = (e, k) =>
                    {
                        if (!edit && k.Key == Key.F2)
                        {
                            previousText = label.text;
                            editinglable = label;
                            textbox.Text = label.text;
                            textbox.HandleFocusedGained();
                            label.text += "|";
                            editing     = true;
                            edit        = true;
                            Singleton <GUI> .INSTANCE.Dirty = true;
                        }
                        else if (edit && k.Key == Key.Enter || k.Key == Key.KeypadEnter)
                        {
                            editing = false;
                            edit    = false;

                            label.text = textbox.Text;
                            if (string.IsNullOrEmpty(label.text))
                            {
                                label.text = previousText;
                                MessageBox.Show("Matrix names MUST contain at least one character", "Matrix Name Limits");
                            }

                            Singleton <GUI> .INSTANCE.Dirty = true;

                            int index  = labels.IndexOf(label);
                            int offset = index + offsetindex;

                            QbModel m = Singleton <QbManager> .INSTANCE.ActiveModel;

                            m.matrices[offset].name = label.text;
                            Singleton <GUI> .INSTANCE.Get <TextBox>(GUIID.ACTIVE_MATRIX_NAME).Text = label.text;
                        }
                        else if (edit && k.Key == Key.Escape)
                        {
                            label.text = previousText.Replace("|", "");
                            edit       = false;
                            editing    = false;
                            Singleton <GUI> .INSTANCE.Get <TextBox>(GUIID.ACTIVE_MATRIX_NAME).Text = label.text;

                            Singleton <GUI> .INSTANCE.Dirty = true;
                        }
                        else if (editing)
                        {
                            textbox.HandleKeyDown(k);
                            label.text = textbox.Text;
                        }
                    },
                    Keypresshandler = (e, k) =>
                    {
                        if (editing)
                        {
                            textbox.HandleKeyPress(k);
                            label.text = textbox.Text;
                        }
                    },
                    focuslost = (e) =>
                    {
                        if (editing)
                        {
                            editing = false;
                            edit    = false;

                            label.text = textbox.Text;
                            if (string.IsNullOrEmpty(label.text))
                            {
                                label.text = previousText;
                                MessageBox.Show("Matrix names MUST contain at least one character", "Matrix Name Limits");
                            }

                            label.color = System.Drawing.Color.White;
                            Singleton <GUI> .INSTANCE.Dirty = true;

                            int index  = labels.IndexOf(label);
                            int offset = index + offsetindex;

                            QbModel m = Singleton <QbManager> .INSTANCE.ActiveModel;

                            m.matrices[offset].name = label.text;
                            Singleton <GUI> .INSTANCE.Get <TextBox>(GUIID.ACTIVE_MATRIX_NAME).Text = label.text;
                        }
                    }
                };

                if (i == 0)
                {
                    background.Enable = true;
                    bg.color          = Color4.Black;
                    background.SetBoundsNoScaling(Absolute_X, label.Absolute_Y, size.X, label.size.Y - (4f).ScaleVerticlSize());
                }

                label.StatusText = stonevox.StatusText.label_matrixlistbox;

                labels.Add(label);

                ToggleButton button = new ToggleButton("./data/images/qb_matrix_visibility_on.png",
                                                       "./data/images/qb_matrix_visibility_off.png");
                button.Parent = this;
                button.SetBoundsNoScaling(Absolute_X + size.X * .01f, previouseY + fontheight * .02f, size.X * .05f, fontheight);

                button.handler = new WidgetEventHandler()
                {
                    mousedownhandler = (e, mouse) =>
                    {
                        if (mouse.IsPressed && mouse.Button == MouseButton.Left)
                        {
                            int index  = buttons.IndexOf(button);
                            int offset = index + offsetindex;

                            QbModel m = Singleton <QbManager> .INSTANCE.ActiveModel;
                            m.matrices[offset].Visible = !m.matrices[offset].Visible;
                        }
                    },
                    mouseenter = (e) =>
                    {
                        int index  = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        QbModel m = Singleton <QbManager> .INSTANCE.ActiveModel;

                        m.matrices[offset].highlight = new Colort(1.5f, 1.5f, 1.5f);
                    },
                    mouseleave = (e) =>
                    {
                        int index  = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        QbModel m = Singleton <QbManager> .INSTANCE.ActiveModel;

                        m.matrices[offset].highlight = new Colort(1f, 1f, 1f);
                    }
                };

                button.StatusText = stonevox.StatusText.button_matrixvisibiliy;

                buttons.Add(button);
                previouseY -= fontheight; // + (labelspacing).ScaleVerticlSize();

                if (hasmodel)
                {
                    if (labeltext == "")
                    {
                        label.Enable           = false;
                        button.Enable          = false;
                        button.MaintainEnabled = true;
                    }
                    else
                    {
                        if (model.matrices[i].Visible)
                        {
                            button.Toggle(0);
                        }
                        else
                        {
                            button.Toggle(1);
                        }
                    }
                }
                else
                {
                    label.Enable           = false;
                    button.Enable          = false;
                    button.MaintainEnabled = true;
                }
            }

            int matrixcount = 10;

            if (hasmodel)
            {
                matrixcount = model.matrices.Count;
            }

            scrollbar = new VerticalScrollbar((size.X * .055f).UnScaleHorizontalSize(),
                                              size.Y.UnScaleVerticlSize(),
                                              matrixcount);
            scrollbar.fontHeight = size.Y / linecount;
            scrollbar.UpdateScrollbar();
            scrollbar.Parent = this;
            scrollbar.SetBoundsNoScaling(Absolute_X + size.X - scrollbar.size.X, Absolute_Y);

            scrollbar.handler = new WidgetEventHandler()
            {
                scrollbarchanged = (e, value, delta) =>
                {
                    offsetindex = (int)value;
                    UpdateWidgets();

                    if (delta > 0)
                    {
                        background.location.Y += (fontheight /*+ (labelspacing).ScaleVerticlSize()*/) * (int)delta;
                    }
                    else
                    {
                        background.location.Y -= (fontheight /* + (labelspacing).ScaleVerticlSize()*/) * -(int)delta;
                    }

                    bool backgroundOutofBounds = true;
                    if (background.Absolute_Y > Absolute_Y + size.Y - fontheight * .5f)
                    {
                        backgroundOutofBounds = false;
                    }
                    else if (background.Absolute_Y < Absolute_Y)
                    {
                        backgroundOutofBounds = false;
                    }
                    background.Enable = backgroundOutofBounds;
                }
            };
        }
Example #6
0
        public QbModelMatrixListbox(float width, float height)
            : base(-1)
        {
            //input = Singleton<ClientInput>.INSTANCE;

            ID = GetNextAvailableID();
            appearence.AddAppearence("border", new PlainBorder(6, new Color4(122f / 256f, 106f / 256f, 70f / 256f, 1f)));
            appearence.AddAppearence("background", new PlainBackground(new Color4(66, 63, 63, 255)));

            float realheight = Client.window.Qfont.fontData.maxGlyphHeight;
            float fontheight = (float)realheight*2f;
            linecount = (int)((height.UnScaleVerticlSize()) / fontheight);

            //float labelspacing = 25f;

            textbox = new TextBox(100000000, "", Color4.Wheat.ToSystemDrawingColor(), 1000);
            textbox.focused = true;

            fontheight = fontheight.ScaleVerticlSize();

            labels = new List<Label>();
            buttons = new List<ToggleButton>();
            size.X = width;
            size.Y = linecount * fontheight;// + linecount * (labelspacing).ScaleVerticlSize();

            QbModel model = null;
            bool hasmodel = Singleton<QbManager>.INSTANCE.HasModel;

            if (hasmodel)
                model = Singleton<QbManager>.INSTANCE.ActiveModel;

            float previouseY = Absolute_Y + size.Y - realheight.ScaleVerticlSize() * 2f;

            background = new EmptyWidget();
            background.Parent = this;
            PlainBackground bg = new PlainBackground(Color4.Black);
            background.appearence.AddAppearence("background", bg);

            for (int i = 0; i < linecount; i++)
            {
                string labeltext = "";

                if (hasmodel)
                    labeltext = i < model.matrices.Count ? model.matrices[i].name : "";

                Label label = new Label(GetNextAvailableID(), labeltext, System.Drawing.Color.White, true);
                label.Parent = this;
                label.SetBoundsNoScaling(Absolute_X + size.X * .08f, previouseY);

                Boolean editing = false;
                label.customData.Add("edit", editing);

                label.handler = new WidgetEventHandler()
                {
                    mousedownhandler = (e, mouse) =>
                    {
                        if (!mouse.IsPressed || mouse.Button != OpenTK.Input.MouseButton.Left) return;

                        background.Enable = true;
                        bg.color = Color4.Black;
                        background.SetBoundsNoScaling(Absolute_X, label.Absolute_Y, size.X, label.size.Y - (4f).ScaleVerticlSize());

                        QbModel m = Singleton<QbManager>.INSTANCE.ActiveModel;
                        int index = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        Singleton<QbManager>.INSTANCE.ActiveMatrixIndex = offset;

                        lastActiveIndex = labels.ToList().IndexOf(label);
                    },
                    mousedoubleclick = (e, mouse) =>
                    {
                        if (!mouse.IsPressed || mouse.Button != OpenTK.Input.MouseButton.Left) return;

                        QbModel m = Singleton<QbManager>.INSTANCE.ActiveModel;
                        int index = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        Singleton<QbManager>.INSTANCE.ActiveMatrixIndex = offset;
                        Singleton<Camera>.INSTANCE.TransitionToMatrix();
                    },
                    mouseenter =  (e) =>
                    {
                        //lastover = label;

                        int index = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        QbModel m = Singleton<QbManager>.INSTANCE.ActiveModel;

                        m.matrices[offset].highlight = new Colort(1.5f, 1.5f, 1.5f);
                    },
                    mouseleave = (e) =>
                    {
                        int index = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        QbModel m = Singleton<QbManager>.INSTANCE.ActiveModel;

                        m.matrices[offset].highlight = new Colort(1f, 1f, 1f);
                    },
                    Keydownhandler = (e, k) =>
                    {
                        if (!edit && k.Key == Key.F2)
                        {
                            previousText = label.text;
                            editinglable = label;
                            textbox.Text = label.text;
                            textbox.HandleFocusedGained();
                            label.text += "|";
                            editing = true;
                            edit = true;
                            Singleton<GUI>.INSTANCE.Dirty = true;
                        }
                        else if (edit && k.Key == Key.Enter || k.Key == Key.KeypadEnter)
                        {
                            editing = false;
                            edit = false;

                            label.text = textbox.Text;
                            if (string.IsNullOrEmpty(label.text))
                            {
                                label.text = previousText;
                                MessageBox.Show("Matrix names MUST contain at least one character", "Matrix Name Limits");
                            }

                            Singleton<GUI>.INSTANCE.Dirty = true;

                            int index = labels.IndexOf(label);
                            int offset = index + offsetindex;

                            QbModel m = Singleton<QbManager>.INSTANCE.ActiveModel;

                            m.matrices[offset].name = label.text;
                            Singleton<GUI>.INSTANCE.Get<TextBox>(GUIID.ACTIVE_MATRIX_NAME).Text = label.text;
                        }
                        else if (edit && k.Key == Key.Escape)
                        {
                            label.text = previousText.Replace("|", "");
                            edit = false;
                            editing = false;
                            Singleton<GUI>.INSTANCE.Get<TextBox>(GUIID.ACTIVE_MATRIX_NAME).Text = label.text;
                            Singleton<GUI>.INSTANCE.Dirty = true;
                        }
                        else if (editing)
                        {
                            textbox.HandleKeyDown(k);
                            label.text = textbox.Text;
                        }
                    },
                    Keypresshandler  = (e, k) =>
                    {
                        if (editing)
                        {
                            textbox.HandleKeyPress(k);
                            label.text = textbox.Text;
                        }
                    },
                    focuslost = (e) =>
                    {
                        if (editing)
                        {
                            editing = false;
                            edit = false;

                            label.text = textbox.Text;
                            if (string.IsNullOrEmpty(label.text))
                            {
                                label.text = previousText;
                                MessageBox.Show("Matrix names MUST contain at least one character", "Matrix Name Limits");
                            }

                            label.color = System.Drawing.Color.White;
                            Singleton<GUI>.INSTANCE.Dirty = true;

                            int index = labels.IndexOf(label);
                            int offset = index + offsetindex;

                            QbModel m = Singleton<QbManager>.INSTANCE.ActiveModel;

                            m.matrices[offset].name = label.text;
                            Singleton<GUI>.INSTANCE.Get<TextBox>(GUIID.ACTIVE_MATRIX_NAME).Text = label.text;
                        }

                    }
                };

                if (i == 0)
                {
                    background.Enable = true;
                    bg.color = Color4.Black;
                    background.SetBoundsNoScaling(Absolute_X, label.Absolute_Y, size.X, label.size.Y - (4f).ScaleVerticlSize());

                }

                label.StatusText = stonevox.StatusText.label_matrixlistbox;

                labels.Add(label);

                ToggleButton button = new ToggleButton("./data/images/qb_matrix_visibility_on.png", 
                                                       "./data/images/qb_matrix_visibility_off.png");
                button.Parent = this;
                button.SetBoundsNoScaling(Absolute_X + size.X * .01f, previouseY+fontheight*.02f, size.X*.05f, fontheight);

                button.handler = new WidgetEventHandler()
                {
                    mousedownhandler = (e, mouse) =>
                    {
                        if (mouse.IsPressed && mouse.Button == MouseButton.Left)
                        {
                            int index = buttons.IndexOf(button);
                            int offset = index + offsetindex;

                            QbModel m = Singleton<QbManager>.INSTANCE.ActiveModel;
                            m.matrices[offset].Visible = !m.matrices[offset].Visible;
                        }
                    },
                    mouseenter = (e) =>
                    {
                        int index = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        QbModel m = Singleton<QbManager>.INSTANCE.ActiveModel;

                        m.matrices[offset].highlight = new Colort(1.5f, 1.5f, 1.5f);
                    },
                    mouseleave = (e) =>
                    {
                        int index = labels.IndexOf(label);
                        int offset = index + offsetindex;

                        QbModel m = Singleton<QbManager>.INSTANCE.ActiveModel;

                        m.matrices[offset].highlight = new Colort(1f, 1f, 1f);
                    }
                };

                button.StatusText = stonevox.StatusText.button_matrixvisibiliy;

                buttons.Add(button);
                previouseY -= fontheight; // + (labelspacing).ScaleVerticlSize();

                if (hasmodel)
                {
                    if (labeltext == "")
                    {
                        label.Enable = false;
                        button.Enable = false;
                        button.MaintainEnabled = true;
                    }
                    else
                    {
                        if (model.matrices[i].Visible)
                            button.Toggle(0);
                        else
                            button.Toggle(1);
                    }
                }
                else
                {
                    label.Enable = false;
                    button.Enable = false;
                    button.MaintainEnabled = true;
                }
            }

            int matrixcount = 10;
            if (hasmodel)
                matrixcount = model.matrices.Count;

            scrollbar = new VerticalScrollbar((size.X * .055f).UnScaleHorizontalSize(),
                                               size.Y.UnScaleVerticlSize(),
                                               matrixcount);
            scrollbar.fontHeight = size.Y / linecount;
            scrollbar.UpdateScrollbar();
            scrollbar.Parent = this;
            scrollbar.SetBoundsNoScaling(Absolute_X + size.X - scrollbar.size.X, Absolute_Y);

            scrollbar.handler = new WidgetEventHandler()
            {
                scrollbarchanged = (e, value, delta) =>
                {
                    offsetindex = (int)value;
                    UpdateWidgets();

                    if (delta > 0)
                    {
                        background.location.Y += (fontheight /*+ (labelspacing).ScaleVerticlSize()*/) * (int)delta;
                    }
                    else
                    {
                        background.location.Y -= (fontheight /* + (labelspacing).ScaleVerticlSize()*/) * -(int)delta;
                    }

                    bool backgroundOutofBounds = true;
                    if (background.Absolute_Y > Absolute_Y + size.Y- fontheight*.5f)
                        backgroundOutofBounds = false;
                    else if (background.Absolute_Y < Absolute_Y)
                        backgroundOutofBounds = false;
                    background.Enable = backgroundOutofBounds;
                }
            };
        }