+++ /dev/null
-//
-// GamePadButton.cs
-//
-// Author:
-// robert <${AuthorEmail}>
-//
-// Copyright (c) 2012 robert
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-using System;
-
-namespace Crow
-{
- /// <summary>
- /// Enumerates available buttons for a <c>GamePad</c> device.
- /// </summary>
- [Flags]
- public enum Buttons
- {
- /// <summary>
- /// DPad up direction button
- /// </summary>
- DPadUp = 1 << 0,
-
- /// <summary>
- /// DPad down direction button
- /// </summary>
- DPadDown = 1 << 1,
-
- /// <summary>
- /// DPad left direction button
- /// </summary>
- DPadLeft = 1 << 2,
-
- /// <summary>
- /// DPad right direction button
- /// </summary>
- DPadRight = 1 << 3,
-
- /// <summary>
- /// Start button
- /// </summary>
- Start = 1 << 4,
-
- /// <summary>
- /// Back button
- /// </summary>
- Back = 1 << 5,
-
- /// <summary>
- /// Left stick button
- /// </summary>
- LeftStick = 1 << 6,
-
- /// <summary>
- /// Right stick button
- /// </summary>
- RightStick = 1 << 7,
-
- /// <summary>
- /// Left shoulder button
- /// </summary>
- LeftShoulder = 1 << 8,
-
- /// <summary>
- /// Right shoulder button
- /// </summary>
- RightShoulder = 1 << 9,
-
- /// <summary>
- /// Home button
- /// </summary>
- Home = 1 << 11,
-
- /// <summary>
- /// Home button
- /// </summary>
- BigButton = Home,
-
- /// <summary>
- /// A button
- /// </summary>
- A = 1 << 12,
-
- /// <summary>
- /// B button
- /// </summary>
- B = 1 << 13,
-
- /// <summary>
- /// X button
- /// </summary>
- X = 1 << 14,
-
- /// <summary>
- /// Y button
- /// </summary>
- Y = 1 << 15,
-
- /// <summary>
- /// Left thumbstick left direction button
- /// </summary>
- LeftThumbstickLeft = 1 << 21,
-
- /// <summary>
- /// Right trigger button
- /// </summary>
- RightTrigger = 1 << 22,
-
- /// <summary>
- /// Left trigger button
- /// </summary>
- LeftTrigger = 1 << 23,
-
- /// <summary>
- /// Right thumbstick up direction button
- /// </summary>
- RightThumbstickUp = 1 << 24,
-
- /// <summary>
- /// Right thumbstick down direction button
- /// </summary>
- RightThumbstickDown = 1 << 25,
-
- /// <summary>
- /// Right stick right direction button
- /// </summary>
- RightThumbstickRight = 1 << 26,
-
- /// <summary>
- /// Right stick left direction button
- /// </summary>
- RightThumbstickLeft = 1 << 27,
-
- /// <summary>
- /// Left stick up direction button
- /// </summary>
- LeftThumbstickUp = 1 << 28,
-
- /// <summary>
- /// Left stick down direction button
- /// </summary>
- LeftThumbstickDown = 1 << 29,
-
- /// <summary>
- /// Left stick right direction button
- /// </summary>
- LeftThumbstickRight = 1 << 30,
- }
-}
--- /dev/null
+// Copyright (c) 2014-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+
+namespace Crow
+{
+ /// <summary>
+ /// Base class for Crow interface events.
+ /// </summary>
+ /// <remarks>
+ /// By default, device (mouse, keyboard) events are bubbled through the logical tree unless the `Handled` field
+ /// of the `CrowEventArgs` is set to `true`, or if an event handler is registered for the Event.
+ /// For example if you have a templated button that received a mouse
+ /// event in a `Label` widget inside its tempate, the event may be bubbled to the `Button` widget where a
+ /// `MouseClick` event may be registered which will cause the bubbling to stop at that level.
+ /// </remarks>
+ public class CrowEventArgs : EventArgs
+ {
+ /// <summary>
+ /// If `true`, bubbling of the event through the logical widget tree is stopped
+ /// </summary>
+ public bool Handled;
+ }
+}
-#region License
+// Copyright (c) 2006 - 2009 the Open Toolkit library.
+// Copyright (c) 2014-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
-// The Open Toolkit Library License
-//
-// Copyright (c) 2006 - 2009 the Open Toolkit library.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-// the Software, and to permit persons to whom the Software is furnished to do
-// so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-#endregion
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-using System;
-using System.Collections.Generic;
-using System.Text;
using Glfw;
namespace Crow
{
- public class KeyEventArgs : CrowEventArgs
+ public class KeyEventArgs : CrowEventArgs
{
int keyCode=0;
Key key;
-// #region License
-// //
-// // The Open Toolkit Library License
-// //
-// // Copyright (c) 2006 - 2009 the Open Toolkit library.
-// //
-// // Permission is hereby granted, free of charge, to any person obtaining a copy
-// // of this software and associated documentation files (the "Software"), to deal
-// // in the Software without restriction, including without limitation the rights to
-// // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-// // the Software, and to permit persons to whom the Software is furnished to do
-// // so, subject to the following conditions:
-// //
-// // The above copyright notice and this permission notice shall be included in all
-// // copies or substantial portions of the Software.
-// //
-// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// // OTHER DEALINGS IN THE SOFTWARE.
-// //
-// #endregion
-
+// Copyright (c) 2006 - 2009 the Open Toolkit library.
+// Copyright (c) 2014-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
namespace Crow
-#region License
+// Copyright (c) 2006-2014 Stefanos Apostolopoulos <stapostol@gmail.com>
+// Copyright (c) 2014-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
-// MouseEventArgs.cs
-//
-// Author:
-// Stefanos A. <stapostol@gmail.com>
-//
-// Copyright (c) 2006-2014 Stefanos Apostolopoulos
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-#endregion
-
-using System;
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using Glfw;
namespace Crow
{
- public class CrowEventArgs : EventArgs
- {
- public bool Handled;
- }
public class MouseEventArgs : CrowEventArgs
{
public readonly int X, Y;
+++ /dev/null
-#region License
-//
-// MouseWheel.cs
-//
-// Author:
-// Stefanos A. <stapostol@gmail.com>
-//
-// Copyright (c) 2006-2014 Stefanos Apostolopoulos
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-//
-#endregion
-
-using System;
-
-namespace Crow
-{
- /// <summary>
- /// Represents the state of a mouse wheel.
- /// </summary>
- public struct MouseScroll : IEquatable<MouseScroll>
- {
- #region Public Members
-
- /// <summary>
- /// Gets the absolute horizontal offset of the wheel,
- /// or 0 if no horizontal scroll wheel exists.
- /// </summary>
- /// <value>The x.</value>
- public float X { get; internal set; }
-
- /// <summary>
- /// Gets the absolute vertical offset of the wheel,
- /// or 0 if no vertical scroll wheel exists.
- /// </summary>
- /// <value>The y.</value>
- public float Y { get; internal set; }
-
- /// <param name="left">A <see cref="MouseScroll"/> instance to test for equality.</param>
- /// <param name="right">A <see cref="MouseScroll"/> instance to test for equality.</param>
- public static bool operator ==(MouseScroll left, MouseScroll right)
- {
- return left.Equals(right);
- }
-
- /// <param name="left">A <see cref="MouseScroll"/> instance to test for inequality.</param>
- /// <param name="right">A <see cref="MouseScroll"/> instance to test for inequality.</param>
- public static bool operator !=(MouseScroll left, MouseScroll right)
- {
- return !left.Equals(right);
- }
-
- /// <summary>
- /// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.MouseScroll"/>.
- /// </summary>
- /// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.MouseScroll"/>.</returns>
- public override string ToString()
- {
- return string.Format("[X={0:0.00}, Y={1:0.00}]", X, Y);
- }
-
- /// <summary>
- /// Serves as a hash function for a <see cref="OpenTK.Input.MouseScroll"/> object.
- /// </summary>
- /// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
- /// hash table.</returns>
- public override int GetHashCode()
- {
- return X.GetHashCode() ^ Y.GetHashCode();
- }
-
- /// <summary>
- /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OpenTK.Input.MouseScroll"/>.
- /// </summary>
- /// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="OpenTK.Input.MouseScroll"/>.</param>
- /// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
- /// <see cref="OpenTK.Input.MouseScroll"/>; otherwise, <c>false</c>.</returns>
- public override bool Equals(object obj)
- {
- return
- obj is MouseScroll &&
- Equals((MouseScroll)obj);
- }
-
- #endregion
-
- #region IEquatable Members
-
- /// <summary>
- /// Determines whether the specified <see cref="OpenTK.Input.MouseScroll"/> is equal to the current <see cref="OpenTK.Input.MouseScroll"/>.
- /// </summary>
- /// <param name="other">The <see cref="OpenTK.Input.MouseScroll"/> to compare with the current <see cref="OpenTK.Input.MouseScroll"/>.</param>
- /// <returns><c>true</c> if the specified <see cref="OpenTK.Input.MouseScroll"/> is equal to the current
- /// <see cref="OpenTK.Input.MouseScroll"/>; otherwise, <c>false</c>.</returns>
- public bool Equals(MouseScroll other)
- {
- return X == other.X && Y == other.Y;
- }
-
- #endregion
- }
-}
public event EventHandler<MouseButtonEventArgs> MouseDoubleClick;
/// <summary>Occurs when mouse mouve in this object. It bubbles to the root</summary>
public event EventHandler<MouseMoveEventArgs> MouseMove;
- /// <summary>Occurs when mouse enter this object</summary>
+ /// <summary>Occurs when mouse enter the bounding rectangle of this object</summary>
public event EventHandler<MouseMoveEventArgs> MouseEnter;
- /// <summary>Occurs when mouse leave this object</summary>
+ /// <summary>Occurs when mouse leave the bounds of this object</summary>
public event EventHandler<MouseMoveEventArgs> MouseLeave;
/// <summary>Occurs when key is pressed when this object is active</summary>
public event EventHandler<KeyEventArgs> KeyDown;
}
+ /// <summary>
+ /// Default mouse button press method. The `MouseDown` event is raised from withing it.
+ /// </summary>
+ /// <remarks>
+ /// See `CrowEventArgs` for details on interface event handling.
+ /// </remarks>
+ /// <param name="sender">Sender of the event</param>
+ /// <param name="e">mouse button pressed event arguments</param>
public virtual void onMouseDown(object sender, MouseButtonEventArgs e){
if (Focusable) {
IFace.FocusedWidget = this;
else if (!e.Handled)
FocusParent?.onMouseDown (sender, e);
}
+ /// <summary>
+ /// Default mouse button release method. The `MouseUp` event is raised from withing it.
+ /// </summary>
+ /// <remarks>
+ /// See `CrowEventArgs` for details on interface event handling.
+ /// </remarks>
+ /// <param name="sender">Sender of the event</param>
+ /// <param name="e">mouse button release event arguments</param>
public virtual void onMouseUp(object sender, MouseButtonEventArgs e){
if (IFace.DragAndDropOperation != null){
else if (!e.Handled)
FocusParent?.onMouseUp (sender, e);
}
+ /// <summary>
+ /// Default mouse click method. A click is a press and release without mouving combination.
+ /// </summary>
+ /// <param name="sender">The Sender of the event</param>
+ /// <param name="e">event arguments</param>
public virtual void onMouseClick(object sender, MouseButtonEventArgs e){
if (MouseClick != null)
MouseClick.Invoke (this, e);
else if (!e.Handled)
FocusParent?.onMouseClick (sender, e);
}
+ /// <summary>
+ /// Default mouse double click method. A double click is two consecutive press and release without mouving combination.
+ /// within a delay defined by `Interface.DOUBLECLICK_TRESHOLD`
+ /// </summary>
+ /// <param name="sender">The Sender of the event</param>
+ /// <param name="e">event arguments</param>
public virtual void onMouseDoubleClick(object sender, MouseButtonEventArgs e){
if (MouseDoubleClick != null)
MouseDoubleClick.Invoke (this, e);