diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/BubblingMouseButtonEventArgs.cs | 3 | ||||
| -rw-r--r-- | src/GraphicObjects/CheckBox.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 11 | ||||
| -rw-r--r-- | src/GraphicObjects/RadioButton.cs | 4 | ||||
| -rw-r--r-- | src/Interface.cs | 59 | ||||
| -rw-r--r-- | src/Measure.cs | 6 |
6 files changed, 60 insertions, 27 deletions
diff --git a/src/BubblingMouseButtonEventArgs.cs b/src/BubblingMouseButtonEventArgs.cs index 74939620..e81a6f74 100644 --- a/src/BubblingMouseButtonEventArgs.cs +++ b/src/BubblingMouseButtonEventArgs.cs @@ -35,6 +35,9 @@ namespace Crow { public GraphicObject Focused; public BubblingMouseButtonEventArg(MouseButtonEventArgs mbe) : base(mbe){} + public BubblingMouseButtonEventArg(int x, int y, MouseButton button, bool pressed) + : base (x,y,button,pressed){} + } } diff --git a/src/GraphicObjects/CheckBox.cs b/src/GraphicObjects/CheckBox.cs index 3a6b2b6a..646a8577 100644 --- a/src/GraphicObjects/CheckBox.cs +++ b/src/GraphicObjects/CheckBox.cs @@ -65,10 +65,10 @@ namespace Crow } } - public override void onMouseClick (object sender, MouseButtonEventArgs e) + public override void onMouseDown (object sender, MouseButtonEventArgs e) { IsChecked = !IsChecked; - base.onMouseClick (sender, e); + base.onMouseDown (sender, e); } } } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index f0e8a04d..aca7032e 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -1556,11 +1556,6 @@ namespace Crow #if DEBUG_FOCUS Debug.WriteLine("MOUSE DOWN => " + this.ToString()); #endif - if (CurrentInterface.eligibleForDoubleClick == this && CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick) - onMouseDoubleClick (this, e); - else - CurrentInterface.clickTimer.Restart(); - CurrentInterface.eligibleForDoubleClick = null; if (CurrentInterface.ActiveWidget == null) CurrentInterface.ActiveWidget = this; @@ -1603,12 +1598,6 @@ namespace Crow p.onMouseUp(sender,e); MouseUp.Raise (this, e); - - if (MouseIsIn (e.Position) && IsActive) { - if (CurrentInterface.clickTimer.ElapsedMilliseconds < Interface.DoubleClick) - CurrentInterface.eligibleForDoubleClick = this; - onMouseClick (this, e); - } } public virtual void onMouseClick(object sender, MouseButtonEventArgs e){ #if DEBUG_FOCUS diff --git a/src/GraphicObjects/RadioButton.cs b/src/GraphicObjects/RadioButton.cs index ead332ea..4c553481 100644 --- a/src/GraphicObjects/RadioButton.cs +++ b/src/GraphicObjects/RadioButton.cs @@ -43,7 +43,7 @@ namespace Crow public event EventHandler Unchecked; #region GraphicObject overrides - public override void onMouseClick (object sender, MouseButtonEventArgs e) + public override void onMouseDown (object sender, MouseButtonEventArgs e) { Group pg = Parent as Group; if (pg != null) { @@ -56,7 +56,7 @@ namespace Crow } else IsChecked = !IsChecked; - base.onMouseClick (sender, e); + base.onMouseDown (sender, e); } #endregion diff --git a/src/Interface.cs b/src/Interface.cs index 0142f96a..e1bd7533 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -114,7 +114,7 @@ namespace Crow /// <summary> delay before tooltip appear </summary> public static int ToolTipDelay = 500; /// <summary>Double click threshold in milisecond</summary> - public static int DoubleClick = 200;//max duration between two mouse_down evt for a dbl clk in milisec. + public static int DoubleClick = 250;//max duration between two mouse_down evt for a dbl clk in milisec. /// <summary> Time to wait in millisecond before starting repeat loop</summary> public static int DeviceRepeatDelay = 700; /// <summary> Time interval in millisecond between device event repeat</summary> @@ -143,7 +143,20 @@ namespace Crow /// </summary> protected static Interface CurrentInterface; internal Stopwatch clickTimer = new Stopwatch(); - internal GraphicObject eligibleForDoubleClick = null; + GraphicObject armedClickSender = null; + MouseButtonEventArgs armedClickEvtArgs = null; +// internal GraphicObject EligibleForDoubleClick { +// get { return eligibleForDoubleClick; } +// set { +// eligibleForDoubleClick = value; +// clickTimer.Restart (); +// } +// } + internal void armeClick (GraphicObject sender, MouseButtonEventArgs e){ + armedClickSender = sender; + armedClickEvtArgs = e; + clickTimer.Restart (); + } #endregion #region Events @@ -476,12 +489,18 @@ namespace Crow /// Result: the Interface bitmap is drawn in memory (byte[] bmp) and a dirtyRect and bitmap are available /// </summary> public void Update(){ + if (armedClickSender != null && clickTimer.ElapsedMilliseconds >= Interface.DoubleClick) { + armedClickSender.onMouseClick (armedClickSender, armedClickEvtArgs); + armedClickSender = null; + } + if (mouseRepeatCount > 0) { int mc = mouseRepeatCount; mouseRepeatCount -= mc; if (_focusedWidget != null) { + mouseRepeatTriggeredAtLeastOnce = true; for (int i = 0; i < mc; i++) { - _focusedWidget.onMouseClick (this, new MouseButtonEventArgs (Mouse.X, Mouse.Y, MouseButton.Left, true)); + _focusedWidget.onMouseDown (this, new BubblingMouseButtonEventArg(Mouse.X, Mouse.Y, MouseButton.Left, true)); } } } @@ -794,6 +813,10 @@ namespace Crow /// <returns>true if mouse is in the interface</returns> public virtual bool ProcessMouseMove(int x, int y) { + if (armedClickSender != null) { + armedClickSender.onMouseClick (armedClickSender, armedClickEvtArgs); + armedClickSender = null; + } int deltaX = x - Mouse.X; int deltaY = y - Mouse.Y; Mouse.X = x; @@ -890,13 +913,18 @@ namespace Crow mouseRepeatThread.Abort(); mouseRepeatThread.Join (); } - + if (!mouseRepeatTriggeredAtLeastOnce) { + if (_activeWidget.MouseIsIn (e.Position)) + armeClick (_activeWidget, e); + } + mouseRepeatTriggeredAtLeastOnce = false; _activeWidget.onMouseUp (_activeWidget, e); - GraphicObject lastActive = _activeWidget; + +// GraphicObject lastActive = _activeWidget; ActiveWidget = null; - if (!lastActive.MouseIsIn (Mouse.Position)) { - ProcessMouseMove (Mouse.X, Mouse.Y); - } +// if (!lastActive.MouseIsIn (Mouse.Position)) { +// ProcessMouseMove (Mouse.X, Mouse.Y); +// } return true; } /// <summary> @@ -912,6 +940,18 @@ namespace Crow if (HoverWidget == null) return false; + if (HoverWidget == armedClickSender) { + if (clickTimer.ElapsedMilliseconds < Interface.DoubleClick) { + armedClickSender.onMouseDoubleClick (armedClickSender, e); + armedClickSender = null; + return true; + } + + } + if (armedClickSender!=null) + armedClickSender.onMouseClick (armedClickSender, armedClickEvtArgs); + armedClickSender = null; + HoverWidget.onMouseDown(HoverWidget,new BubblingMouseButtonEventArg(e)); if (FocusedWidget == null) @@ -1062,13 +1102,14 @@ namespace Crow #endregion #region Device Repeat Events - volatile bool mouseRepeatOn, keyboardRepeatOn; + volatile bool mouseRepeatOn, keyboardRepeatOn, mouseRepeatTriggeredAtLeastOnce = false; volatile int mouseRepeatCount, keyboardRepeatCount; Thread mouseRepeatThread, keyboardRepeatThread; KeyboardKeyEventArgs lastKeyDownEvt; void mouseRepeatThreadFunc() { mouseRepeatOn = true; + mouseRepeatTriggeredAtLeastOnce = false; Thread.Sleep (Interface.DeviceRepeatDelay); while (mouseRepeatOn) { mouseRepeatCount++; diff --git a/src/Measure.cs b/src/Measure.cs index 352ce8ff..c88038c6 100644 --- a/src/Measure.cs +++ b/src/Measure.cs @@ -49,7 +49,7 @@ namespace Crow /// <summary> /// Fit on content, this special measure is defined as a fixed integer set to -1 pixel /// </summary> - public static Measure Fit = new Measure(-1); + public static Measure Fit = new Measure(-1,Unit.Percent); /// <summary> /// Stretched into parent client area. This special measure is defined as a proportional cote /// set to 100 Percents @@ -67,8 +67,8 @@ namespace Crow /// <summary> /// True is size is fixed in pixels, this means not proportional, stretched nor fit. /// </summary> - public bool IsFixed { get { return Value > 0 && Units == Unit.Pixel; }} - public bool IsFit { get { return Value == -1 && Units == Unit.Pixel; }} + public bool IsFixed { get { return Units == Unit.Pixel; }} + public bool IsFit { get { return Value == -1 && Units == Unit.Percent; }} #region Operators public static implicit operator int(Measure m){ return m.Value; |