aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GUI
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-07-17 14:34:59 -0400
committerMichael <[email protected]>2017-07-17 14:34:59 -0400
commita0ee79dbcd26a8f07d493a7e993cbaf0d02e44db (patch)
treed974220621e6cfcfe745c2825149ca370e3a7aab /ShiftOS.Frontend/GUI
parente929a9f5105c00b0a3a2b4e75a876bbb95bbfa7b (diff)
downloadshiftos_thereturn-a0ee79dbcd26a8f07d493a7e993cbaf0d02e44db.tar.gz
shiftos_thereturn-a0ee79dbcd26a8f07d493a7e993cbaf0d02e44db.tar.bz2
shiftos_thereturn-a0ee79dbcd26a8f07d493a7e993cbaf0d02e44db.zip
Hacking, barebones fskimmer, double clicking
Diffstat (limited to 'ShiftOS.Frontend/GUI')
-rw-r--r--ShiftOS.Frontend/GUI/Control.cs7
-rw-r--r--ShiftOS.Frontend/GUI/ListBox.cs27
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);