Example #1
0
        public void AddToolPanel(Panel p)
        {
            p.SetParent(this);
            p.SetHeight(this.Height);

            if (this.Children.Count > 1)
            {
                p.RightOf(this.Children[this.Children.Count-2]); //Align ourselves to the right of the last panel over
            }
        }
Example #2
0
        public void AddToolPanel(Panel p)
        {
            p.SetParent(this.contextPanel);
            p.ShouldPassInput = true;
            p.SetWidth(contextPanel.Width);

            if (this.contextPanel.Children.Count > 1)
            {
                p.Below(this.contextPanel.Children[this.contextPanel.Children.Count - 2], ElementSpacing );//Align ourselves below the last panel over
            }
        }
Example #3
0
        public override void Init()
        {
            this.Material = Resource.GetMaterial("engine/depth");
            this.drawMode = OpenTK.Graphics.OpenGL.BeginMode.Triangles;
            this.Model = Resource.GetMesh("engine/quad.obj");

            DepthScreen = GUIManager.Create<Panel>();
            DepthScreen.SetMaterial(Resource.GetMaterial("engine/depth"));
            DepthScreen.SetWidth(Utilities.engine.Width / Size);
            DepthScreen.SetHeight(Utilities.engine.Height / Size);
            DepthScreen.SetPos(new Vector2(0, Utilities.engine.Height - DepthScreen.Height));
            DepthScreen.AlphaBlendmode = false;

            Utilities.engine.Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
        }
Example #4
0
        public void AddPanel(Panel p)
        {
            p.SetParent(this.ScrollPanel);

            if (this.Panels.Count > 0 && this.Panels[this.Panels.Count - 1])
            {
                p.Below(this.Panels[this.Panels.Count - 1], 3);
            }

            Panels.Add(p);

            p.SetWidth(this.ScrollPanel.Width);
            p.SetAnchorStyle(Anchors.Left | Anchors.Top | Anchors.Right);

            this.ScrollPanel.SetHeight(p.Position.Y + p.Height);
        }
Example #5
0
        public override void Init()
        {
            base.Init();

            ScrollPanel = GUIManager.Create<Panel>(this);
            ScrollPanel.SetMaterial(Utilities.White);
            ScrollPanel.SetWidth(this.Width);
            ScrollPanel.SetHeight(this.Height);
            ScrollPanel.SetAnchorStyle(Anchors.Left | Anchors.Right);

            Grip = GUIManager.Create<Panel>(this);
            Grip.SetColor(200, 201, 200);
            Grip.SetWidth(20);
            Grip.Dock(DockStyle.RIGHT);
            Grip.IsVisible = false; //We'll be drawing it manually
            Grip.OnMouseDown += new Action<Panel,OpenTK.Input.MouseButtonEventArgs>(Grip_OnMouseDown);
            this.OnMouseMove += new Action<Panel,OpenTK.Input.MouseMoveEventArgs>(ScrollBar_OnMouseMove);

            Utilities.engine.Mouse.ButtonUp += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonUp);
        }
Example #6
0
        public override void Init()
        {
            base.Init();

            contextPanel = GUIManager.Create<Panel>();
            contextPanel.ShouldPassInput = true;
            contextPanel.SetWidth(150);
            contextPanel.SetPos(this.Position.X, this.Position.Y + this.Height);

            //Create our text label
            TextLabel = GUIManager.Create<Label>();
            TextLabel.SetParent(this);
            TextLabel.Autosize = false;
            TextLabel.Dock(DockStyle.FILL);
            TextLabel.SetAlignment(Label.TextAlign.MiddleCenter);

            this.SetButtonState(State.Idle);

            Utilities.engine.Mouse.ButtonDown += new EventHandler<MouseButtonEventArgs>(Mouse_ButtonDown);
        }
Example #7
0
 void Title_OnMouseUp(Panel sender, OpenTK.Input.MouseButtonEventArgs e)
 {
     if (dragging)
     {
         dragging = false;
         Offset = Vector2.Zero;
     }
 }
Example #8
0
 void Title_OnMouseDown(Panel sender, OpenTK.Input.MouseButtonEventArgs e)
 {
     this.dragging = true;
     Offset = new Vector2(Utilities.engine.Mouse.X - this.Position.X, Utilities.engine.Mouse.Y - this.Position.Y);
     this.SendToFront();
     Title.SendToFront();
 }
Example #9
0
 void closeButton_OnButtonPress(Panel sender)
 {
     this.Remove();
 }
Example #10
0
        public void SetTopParent(Panel parent)
        {
            this.TopParent = parent;

            //Tell each of our children who the new top parent is
            foreach (Panel child in Children) child.SetTopParent(this.TopParent);
        }
Example #11
0
 static void slider_OnValueChanged(Panel sender, float newval)
 {
     if (sender.Userdata is Label)
     {
         Label l = (Label)sender.Userdata;
         l.SetText(newval.ToString());
     }
 }
Example #12
0
        static void help_OnButtonPress(Panel sender)
        {
            Window w = GUIManager.Create<Window>();
            w.SetTitle("So you need help?");
            w.ClipChildren = true;
            w.SetHeight(200);

            Button button = GUIManager.Create<Button>();
            button.SetText("Clip test!");
            button.SizeToText(15);
            button.SetParent(w);
            button.SetPos(new Vector2((w.Width / 2) - (button.Width / 2), w.Height - 50));
            button.DockPadding(20, 20, 20, 20);
            button.SetHeight(70);
            button.Dock(Panel.DockStyle.TOP);

            Slider slider = GUIManager.Create<Slider>(w);
            slider.SetMinMax(-10, 100);
            slider.SetValue(40);
            slider.SetWidthHeight(w.Width - 60, 20);
            slider.SetPos(40, 0);
            slider.Below(button, 5);
            slider.SetAnchorStyle(Panel.Anchors.Left | Panel.Anchors.Right);
            slider.OnValueChanged += new Action<Panel, float>(slider_OnValueChanged);

            Label l = GUIManager.Create<Label>(w);
            l.SetText("0");
            l.SetPos(10, slider.Position.Y);
            l.SetWidthHeight(25, 20);
            l.SetAlignment(Label.TextAlign.MiddleLeft);
            slider.Userdata = l;

            Button disabled = GUIManager.Create<Button>(w);
            disabled.SetText("I'm disabled :(");
            disabled.SetWidthHeight(slider.Width, slider.Height);
            disabled.Below(slider, 5);
            disabled.DockPadding(20, 20, 20, 20);
            disabled.Dock(Panel.DockStyle.BOTTOM);
            disabled.SetEnabled(false);
        }
Example #13
0
        static void exit_OnButtonPress(Panel sender)
        {
            Window exitMessageBox = GUIManager.Create<Window>();
            exitMessageBox.SetTitle("Hold the f*****g phone");
            exitMessageBox.ClipChildren = true;
            exitMessageBox.SetPos((Utilities.engine.Width / 2) - (exitMessageBox.Width / 2), (Utilities.engine.Height / 2) - (exitMessageBox.Height / 2));
            exitMessageBox.SetWidth(205);
            exitMessageBox.SetHeight(75);

            Label label = GUIManager.Create<Label>(exitMessageBox);
            label.Autosize = true;
            label.SetText("Are you sure you'd like to leave?");
            label.SetPos(15, 10);

            Button button = GUIManager.Create<Button>(exitMessageBox);
            button.SetText("Yes");
            button.SizeToText(15);
            button.DockPadding(20, 20, 20, 20);
            button.SetHeight(20);
            button.SetPos(20, 40);
            button.SetAnchorStyle(Panel.Anchors.Bottom);
            button.OnButtonPress += new Button.OnButtonPressDel(button_OnYesButtonPress);

            button = GUIManager.Create<Button>(exitMessageBox);
            button.SetText("Cancel");
            button.SizeToText(15);
            button.DockPadding(20, 20, 20, 20);
            button.SetHeight(20);
            button.SetPos(exitMessageBox.Width - button.Width - 20, 40);
            button.SetAnchorStyle(Panel.Anchors.Right | Panel.Anchors.Bottom );
            button.OnButtonPress += new Button.OnButtonPressDel(button_OnNoButtonPress);
        }
Example #14
0
 static void button_OnYesButtonPress(Panel sender)
 {
     Utilities.engine.Exit();
 }
Example #15
0
 static void button_OnNoButtonPress(Panel sender)
 {
     sender.Parent.Remove();
 }
Example #16
0
 /// <summary>
 /// Align the panel to the right of a given panel
 /// </summary>
 /// <param name="p">The panel to move to the right of</param>
 /// <param name="offset">The offset away from the panel</param>
 public void RightOf(Panel p, int offset = 0)
 {
     this.Position = new Vector2(p.Position.X + p.Width + offset, this.Position.Y);
 }
Example #17
0
        /// <summary>
        /// Parent this panel to the given panel. Position will be relative to the parent's location.
        /// </summary>
        /// <param name="parent"></param>
        public void SetParent(Panel parent)
        {
            if (parent)
                parent.Children.Add(this);
            if (this.Parent) //If the parent we're being set to and we have a parent, remove us from its list of children
                this.Parent.Children.Remove(this);

            this.Parent = parent;
            UpdateTopParent();
        }
Example #18
0
        static void tests_OnButtonPress(Panel sender)
        {
            Window mainwin = GUIManager.Create<Window>();
            mainwin.SetPos(300, 200);
            mainwin.SetWidth(500);
            mainwin.SetHeight(450);
            mainwin.SetTitle(Utilities.Time.ToString());

            Window subWin = GUIManager.Create<Window>(mainwin);
            subWin.SetPos(20, 30);
            subWin.SetWidth(330);
            subWin.SetTitle("I'm a window within a window!");

            subWin = GUIManager.Create<Window>(subWin);
            subWin.SetPos(20, 30);
            subWin.SetHeight(180);
            subWin.SetWidth(120);
            subWin.SetTitle("I'm another!");

            subWin = GUIManager.Create<Window>(subWin);
            subWin.SetPos(20, 30);
            subWin.SetHeight(40);
            subWin.SetWidth(80);
            subWin.SetTitle("Budding!");
        }
Example #19
0
        void Button_OnEnableChange(Panel panel, bool enabled)
        {
            CheckButtonState();

            TextLabel.SetEnabled(this.Enabled);
        }
Example #20
0
 /// <summary>
 /// Align the panel above a given panel
 /// </summary>
 /// <param name="p">The panel to move above</param>
 /// <param name="offset">The offset away from the panel</param>
 public void Above(Panel p, int offset = 0)
 {
     this.Position = new Vector2(this.Position.X, p.Position.Y - offset - this.Height);
 }
Example #21
0
 void ScrollBar_OnMouseMove(Panel sender, OpenTK.Input.MouseMoveEventArgs e)
 {
     if (this.Enabled && sender.IsMouseOver() && IsMouseDownGrabber)
     {
         System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Hand;
         Grip.SetPos(new Vector2(Grip.Position.X, Utilities.Clamp(e.Y - GrabOffset.Y, this.Height - Grip.Height, 0 )));
         SetScroll((int)((Grip.Position.Y) / (this.Height / this.ScrollPanel.Height)));
     }
 }
Example #22
0
 /// <summary>
 /// Align the panel below a given panel
 /// </summary>
 /// <param name="p">The panel to move below</param>
 /// <param name="offset">The offset away from the panel</param>
 public void Below(Panel p, int offset = 0)
 {
     this.Position = new Vector2(this.Position.X, p.Position.Y + p.Height + offset);
 }
Example #23
0
 void Grip_OnMouseDown(Panel arg1, OpenTK.Input.MouseButtonEventArgs e)
 {
     if (Grip.IsMouseOver())
     {
         IsMouseDownGrabber = true;
         GrabOffset = new Vector2(e.Position.X, e.Position.Y - Grip.Position.Y );
     }
 }
Example #24
0
 /// <summary>
 /// Return if this panel is in a higher layer than a given panel (Drawn last = higher layer)
 /// </summary>
 /// <param name="p">The panel to check against</param>
 /// <returns>Whether this panel is in a higher layer than the given panel</returns>
 public bool IsOverPanel(Panel p)
 {
     return GUIManager.GetHigherPanel(this, p) == this;
 }
Example #25
0
 void closeButton_PreDraw(Panel btn, Vector2 ScreenPos, DrawEventArgs e)
 {
     Surface.SetDrawColor(48, 55, 71);
     Surface.DrawRect(ScreenPos.X + 2, ScreenPos.Y + 2, btn.Width - 4, btn.Height - 4);
 }
Example #26
0
        public bool IsParent(Panel parent)
        {
            Panel p = this.Parent;
            while (p != null)
            {
                if (p == parent) return true;
                p = p.Parent;
            }

            return false;
        }
Example #27
0
 void Title_OnMouseMove(Panel sender, OpenTK.Input.MouseMoveEventArgs e)
 {
     if (dragging)
     {
         this.Title.SetPos(new Vector2(Utilities.engine.Mouse.X, Utilities.engine.Mouse.Y - Title.Height) - Offset);
         this.SetPos(new Vector2(Utilities.engine.Mouse.X, Utilities.engine.Mouse.Y) - Offset);
     }
 }
Example #28
0
 /// <summary>
 /// Align the panel to the left of a given panel
 /// </summary>
 /// <param name="p">The panel to move to the left of</param>
 /// <param name="offset">The offset away from the panel</param>
 public void LeftOf(Panel p, int offset = 0)
 {
     this.Position = new Vector2(p.Position.X - offset - this.Width, this.Position.Y);
 }
Example #29
0
        public override void Init()
        {
            this.Position = new Vector2(200, 480);
            this.WindowTitle = "Untitled";
            this.Width = 200;
            this.Height = 150;
            this.SetMaterial(Resource.GetTexture("gui/window.png"));
            this.SetColor(20, 24, 33);

            //Create the grabbable title section of the window
            Title = GUIManager.Create<Panel>( this.Parent );
            Title.SetMaterial(Resource.GetTexture("gui/title.png"));
            Title.SetWidthHeight(this.Width, 25);
            Title.SetPos(this.Position - new Vector2(0, Title.Height));
            Title.OnMouseDown += new Action<Panel,OpenTK.Input.MouseButtonEventArgs>(Title_OnMouseDown);
            Title.OnMouseMove += new Action<Panel,OpenTK.Input.MouseMoveEventArgs>(Title_OnMouseMove);
            Title.OnMouseUp += new Action<Panel,OpenTK.Input.MouseButtonEventArgs>(Title_OnMouseUp);
            Title.SetColor(135, 36, 31);

            //Create the text that is overlayed upon the title section
            TitleText = GUIManager.Create<Label>(Title);
            TitleText.SetFont("defaultTitle");
            TitleText.SetPos(0, 0);
            TitleText.SetWidthHeight(this.Width, Title.Height);
            TitleText.SetColor(255, 255, 255);
            TitleText.SetText(this.WindowTitle);
            TitleText.Dock(DockStyle.LEFT);
            TitleText.SetAlignment(Label.TextAlign.MiddleLeft);
            TitleText.DockPadding(10, 10, 0, 0);

            //Create the close button
            closeButton = GUIManager.Create<Button>(Title);
            closeButton.SetImage(Resource.GetTexture("gui/close.png"));
            closeButton.SetWidthHeight(25, 25);
            closeButton.SetColor(26, 30, 38);
            closeButton.Dock(DockStyle.RIGHT);
            closeButton.AlignRight();
            closeButton.OnButtonPress += new Button.OnButtonPressDel(closeButton_OnButtonPress);
            closeButton.PreDraw += new Action<Panel, Vector2, DrawEventArgs>(closeButton_PreDraw);
        }
Example #30
0
        void Slider_PreDraw(Panel arg1, Vector2 arg2, DrawEventArgs e)
        {
            var realPos = this.GetScreenPos();

            Surface.SetDrawColor(33/3, 36/ 3, 45/ 3);
            Surface.DrawRect(realPos.X, realPos.Y + this.Height / 2, this.Width, 1);

            Surface.SetDrawColor(33 * 2, 36 * 2, 45 * 2);
            Surface.DrawRect(realPos.X, realPos.Y + this.Height / 2 + 1, this.Width, 2);

            Surface.SetDrawColor(33*3, 36*3, 45*3);
            Surface.DrawRect(realPos.X, realPos.Y + this.Height / 2 + 3, this.Width, 1);

            e.OverrideDraw = true;
        }