diff options
Diffstat (limited to 'ShiftOS.Frontend/GUI')
| -rw-r--r-- | ShiftOS.Frontend/GUI/Control.cs | 7 | ||||
| -rw-r--r-- | ShiftOS.Frontend/GUI/ListBox.cs | 27 |
2 files changed, 29 insertions, 5 deletions
diff --git a/ShiftOS.Frontend/GUI/Control.cs b/ShiftOS.Frontend/GUI/Control.cs index f253903..d34a97a 100644 --- a/ShiftOS.Frontend/GUI/Control.cs +++ b/ShiftOS.Frontend/GUI/Control.cs @@ -509,7 +509,7 @@ namespace ShiftOS.Frontend.GUI } } - public virtual bool ProcessMouseState(MouseState state) + public virtual bool ProcessMouseState(MouseState state, double lastLeftClickMS) { //If we aren't rendering the control, we aren't accepting input. if (_visible == false) @@ -548,7 +548,7 @@ namespace ShiftOS.Frontend.GUI var nstate = new MouseState(coords.X, coords.Y, state.ScrollWheelValue, state.LeftButton, state.MiddleButton, state.RightButton, state.XButton1, state.XButton2); //pass that state to the process method, and set the _requiresMoreWork value to the opposite of the return value - _requiresMoreWork = !control.ProcessMouseState(nstate); + _requiresMoreWork = !control.ProcessMouseState(nstate, lastLeftClickMS); //If it's false, break the loop. if (_requiresMoreWork == false) break; @@ -575,6 +575,8 @@ namespace ShiftOS.Frontend.GUI } if (_leftState == false && ld == true) { + if (lastLeftClickMS <= 500 & lastLeftClickMS > 0) + DoubleClick?.Invoke(); var focused = UIManager.FocusedControl; UIManager.FocusedControl = this; focused?.InvalidateTopLevel(); @@ -642,6 +644,7 @@ namespace ShiftOS.Frontend.GUI KeyEvent?.Invoke(e); } + public event Action DoubleClick; public event Action<Point> MouseMove; public event Action MouseEnter; public event Action MouseLeave; diff --git a/ShiftOS.Frontend/GUI/ListBox.cs b/ShiftOS.Frontend/GUI/ListBox.cs index 29d3712..2fe5fc4 100644 --- a/ShiftOS.Frontend/GUI/ListBox.cs +++ b/ShiftOS.Frontend/GUI/ListBox.cs @@ -17,6 +17,27 @@ namespace ShiftOS.Frontend.GUI private int itemOffset = 0; private int itemsPerPage = 1; + public ListBox() + { + Click += () => + { + //loop through the list of items on the screen + for(int i = itemOffset; i < itemOffset + itemsPerPage && i < items.Count; i++) + { + int screeni = i - itemOffset; + int loc = 1+screeni * fontheight; + int height = 1+(screeni + 1) * fontheight; + if(MouseY >= loc && MouseY <= height) + { + SelectedIndex = i; + RecalculateItemsPerPage(); + return; + } + } + }; + } + + public int SelectedIndex { get @@ -73,7 +94,7 @@ namespace ShiftOS.Frontend.GUI public void RecalculateItemsPerPage() { itemsPerPage = 0; - while(itemsPerPage * fontheight < Height && itemsPerPage < items.Count - 1) + while(itemsPerPage * fontheight < Height && itemsPerPage < items.Count) { itemsPerPage++; } @@ -102,7 +123,7 @@ namespace ShiftOS.Frontend.GUI { if(e.Key== Microsoft.Xna.Framework.Input.Keys.Down) { - if(selectedIndex < items.Count - 2) + if(selectedIndex < items.Count - 1) { selectedIndex++; RecalculateItemsPerPage(); @@ -126,7 +147,7 @@ namespace ShiftOS.Frontend.GUI { gfx.Clear(LoadedSkin.ControlTextColor.ToMonoColor()); gfx.DrawRectangle(1, 1, Width - 2, Height - 2, UIManager.SkinTextures["ControlColor"]); - for(int i = itemOffset; i < items.Count - 1 && i < itemsPerPage; i++) + for(int i = itemOffset; i < items.Count && i < itemsPerPage; i++) { int x = 1; int y = fontheight * (i - itemOffset); |
