<?xml version="1.0"?>
<CheckBox Caption="{./Caption}" IsChecked="{²./IsPopped}" Foreground="{./Foreground}" Background="{./Background}">
<Template>
- <Border Style="ControlBorder" Foreground="{./Foreground}" Background="{./Background}">
+ <Border Style="ControlBorder" Foreground="{./Foreground}" Background="{./Background}" ForwardMouseEvents="true">
<HorizontalStack Spacing="1">
<Image Style="Icon" Margin="1" Width="9" Height="9"
MouseEnter="{Background=White}" MouseLeave="{Background=Transparent}"
mName = "IsEnabled";
NotifyValueChanged (mName, e.NewValue);
}
- void onMI_Click (object sender, MouseButtonEventArgs e)
- {
- if (command != null) {
- command.Execute ();
- closeMenu ();
- }
- if(!IsOpened)
- (LogicalParent as Menu).AutomaticOpening = false;
- }
protected virtual void onOpen (object sender, EventArgs e){
Open.Raise (this, null);
}
IsOpened = false;
base.onMouseLeave (this, e);
}
+ public override void onMouseClick (object sender, MouseButtonEventArgs e)
+ {
+ if (command != null) {
+ command.Execute ();
+ closeMenu ();
+ }
+ if (hasClick)
+ base.onMouseClick (sender, e);
+ if (!IsOpened)
+ (LogicalParent as Menu).AutomaticOpening = false;
+ }
void closeMenu () {
MenuItem tmp = LogicalParent as MenuItem;
while (tmp != null) {
internal override void itemClick (object sender, MouseButtonEventArgs e)
{
Widget tmp = sender as Widget;
-// if (!tmp.HasFocus)
- //return;
/*if (selectedItemContainer != null) {
selectedItemContainer.Foreground = Color.Transparent;
selectedItemContainer.Background = Color.Transparent;
bool isActive;
bool isHover;
bool mouseRepeat;
+ bool forwardMouseEvents;
protected bool isVisible = true;
bool isEnabled = true;
VerticalAlignment verticalAlignment = VerticalAlignment.Center;
NotifyValueChanged ("MouseRepeat", mouseRepeat);
}
}
+ /// <summary>
+ /// forward mouse events even if an handle is bound
+ /// </summary>
+ [DesignCategory ("Behaviour")][DefaultValue (false)]
+ public bool ForwardMouseEvents {
+ get { return forwardMouseEvents; }
+ set {
+ if (forwardMouseEvents == value)
+ return;
+ forwardMouseEvents = value;
+ NotifyValueChanged ("ForwardMouseEvents", forwardMouseEvents);
+ }
+ }
bool clearBackground = false;
/// <summary>
/// background fill of the control, maybe solid color, gradient, image, or svg
else if (LastPaintedSlot.Width != Slot.Width || LastPaintedSlot.Height != Slot.Height)
bmp.SetSize (Slot.Width, Slot.Height);*/
bmp?.Dispose ();
+ //bmp = IFace.surf.CreateSimilar (Content.ColorAlpha, Slot.Width, Slot.Height);
bmp = new ImageSurface(Format.Argb32, Slot.Width, Slot.Height);
-
+
using (Context gr = new Context (bmp)) {
gr.Antialias = Interface.Antialias;
onDraw (gr);
IFace.ShowContextMenu (this);
}
}*/
- if (MouseDown == null)
- focusParent?.onMouseDown (sender, e);
- else
+ if (MouseDown != null)
MouseDown.Invoke (this, e);
+ if (MouseDown == null || forwardMouseEvents)
+ focusParent?.onMouseDown (sender, e);
}
public virtual void onMouseUp(object sender, MouseButtonEventArgs e){
- #if DEBUG_FOCUS
+#if DEBUG_FOCUS
Debug.WriteLine("MOUSE UP => " + this.ToString());
- #endif
+#endif
/*if (IFace.DragAndDropOperation != null){
if (IFace.DragAndDropOperation.DragSource == this) {
}
}*/
- if (MouseUp == null)
- focusParent?.onMouseUp (sender, e);
- else
+ if (MouseUp != null)
MouseUp.Invoke (this, e);
+ if (MouseUp == null || forwardMouseEvents)
+ focusParent?.onMouseUp (sender, e);
+
}
public virtual void onMouseClick(object sender, MouseButtonEventArgs e){
#if DEBUG_FOCUS
Debug.WriteLine("CLICK => " + this.ToString());
#endif
- if (MouseClick == null)
+ if (MouseClick != null)
+ MouseClick.Invoke (this, e);
+ if (MouseClick == null || forwardMouseEvents)
focusParent?.onMouseClick (sender, e);
- else
- MouseClick.Invoke(this, e);
}
public virtual void onMouseDoubleClick(object sender, MouseButtonEventArgs e){
#if DEBUG_FOCUS
Debug.WriteLine("DOUBLE CLICK => " + this.ToString());
#endif
- if (MouseDoubleClick == null)
- focusParent?.onMouseDoubleClick (sender, e);
- else
+ if (MouseDoubleClick != null)
MouseDoubleClick.Invoke (this, e);
+ if (MouseDoubleClick == null || forwardMouseEvents)
+ focusParent?.onMouseDoubleClick (sender, e);
}
public virtual void onMouseWheel(object sender, MouseWheelEventArgs e){
- if (MouseWheelChanged == null)
+ if (MouseWheelChanged != null)
+ MouseWheelChanged.Invoke (this, e);
+ if (MouseWheelChanged == null || forwardMouseEvents)
focusParent?.onMouseWheel (sender, e);
- else
- MouseWheelChanged.Invoke(this, e);
-
}
public virtual void onMouseEnter(object sender, MouseMoveEventArgs e)
{
protected bool running;
protected virtual void InitBackend () {
if (Environment.OSVersion.Platform == PlatformID.Unix)
- backend = new Crow.XLib.XLibBackend();
- else
- backend = new Crow.Win32.Win32Backend();
+ backend = new XLib.XLibBackend();
+ //backend = new Crow.XCB.XCBBackend();
+ else
+ backend = new Crow.Win32.Win32Backend();
- //backend = new Crow.XLib.XLibBackend ();
backend.Init (this);
-
- /*initTooltip ();
- initContextMenus ();*/
-
-
- /*Thread t = new Thread (interfaceThread);
- t.IsBackground = true;
- t.Start ();*/
}
public void Run () {
//load default main.crow if present
running = true;
+ int frameCount = 0;
+
while (running) {
Update ();
ProcessEvents ();
- }
- }
-
- void interfaceThread()
- {
- while (running) {
- Update ();
- Thread.Sleep (1);
+#if MEASURE_TIME
+ if (frameCount++ < 1000)
+ continue;
+ for (int i = 0; i < PerfMeasures.Count; i++) {
+ PerfMeasures [i].NotifyChanges ();
+ }
+ frameCount = 0;
+#endif
}
}
/// </summary>
protected static Interface CurrentInterface;
Stopwatch lastClickTime = new Stopwatch();
- Widget armedClick;//store widget with double click on first click
- MouseButtonEventArgs armedClickEventArgs;
+ internal Widget armedClick;//store widget with double click on first click
+ internal MouseButtonEventArgs armedClickEventArgs;
#endregion
lock (UpdateMutex) {
clientRectangle = bounds;
- /*surf.Dispose ();
- surf = new Cairo.XlibSurface (xHandle, xwinHnd, xDefaultVisual, clientRectangle.Width, clientRectangle.Height);*/
if (surf is XlibSurface)
(surf as XlibSurface).SetSize (clientRectangle.Width, clientRectangle.Height);
else if (surf is XcbSurface)
(surf as XcbSurface).SetSize (clientRectangle.Width, clientRectangle.Height);
-
foreach (Widget g in GraphicTree)
g.RegisterForLayouting (LayoutingType.All);
int deltaY = y - Mouse.Y;
Mouse.X = x;
Mouse.Y = y;
- MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY);
- e.Mouse = Mouse;
+ MouseMoveEventArgs e = new MouseMoveEventArgs (x, y, deltaX, deltaY) {
+ Mouse = Mouse
+ };
if (armedClick != null) {
armedClick.onMouseClick (armedClick, armedClickEventArgs);
} else
target = target.focusParent;
}
+ if (target == null)
+ _activeWidget?.onMouseClick (_activeWidget, e);
-// GraphicObject lastActive = _activeWidget;
+ // GraphicObject lastActive = _activeWidget;
ActiveWidget = null;
// if (!lastActive.MouseIsIn (Mouse.Position)) {
// ProcessMouseMove (Mouse.X, Mouse.Y);
lastMouseDown.Start ();
mouseRepeatCount = 0;
- lastMouseDownEvent = new MouseButtonEventArgs (button) { Mouse = Mouse };
-
- if (HoverWidget == null)
+ if (_hoverWidget == null)
return false;
- Widget hoverFocused = HoverWidget;
- while (!hoverFocused.Focusable) {
- hoverFocused = hoverFocused.focusParent;
- if (hoverFocused == null) {
- hoverFocused = HoverWidget;
- break;
- }
- }
-
- _hoverWidget.onMouseDown(_hoverWidget,lastMouseDownEvent);
+ lastMouseDownEvent = new MouseButtonEventArgs (button) { Mouse = Mouse };
- /*if (_focusedWidget == null)
- return true;*/
+ _hoverWidget.onMouseDown (_hoverWidget, lastMouseDownEvent);
ActiveWidget = _hoverWidget;
return true;
/// Forward the mouse wheel event from the host to the crow interface
/// </summary>
/// <returns>return true, if interface handled the event, false otherwise.</returns>
- /// <param name="button">Button index</param>
public bool ProcessMouseWheelChanged(float delta)
{
Mouse.SetScrollRelative (0, delta);
{
if (_focusedWidget != null)
_focusedWidget.onKeyUp (this, new KeyEventArgs (key, false));
- // if (keyboardRepeatThread != null) {
- // keyboardRepeatOn = false;
- // keyboardRepeatThread.Abort();
- // keyboardRepeatThread.Join ();
- // }
}
public void ProcessKeyDown (Key key)
{
- //Keyboard.SetKeyState((Crow.Key)Key,true);
lastKeyDownEvt = new KeyEventArgs (key, true);
if (_focusedWidget != null)
_focusedWidget.onKeyDown (this, new KeyEventArgs (key, false));
-
- // keyboardRepeatThread = new Thread (keyboardRepeatThreadFunc);
- // keyboardRepeatThread.IsBackground = true;
- // keyboardRepeatThread.Start ();
}
public bool Shift {
maximum = timer.ElapsedTicks;
}
void ResetStats(){
- Debug.WriteLine("reset measure cpt:{0}",cptMeasures);
cptMeasures = total = current = maximum = 0;
minimum = long.MaxValue;
}
public void SetCursor (MouseCursors newCur)
{
- throw new NotImplementedException ();
+ //throw new NotImplementedException ();
}
public void SetCursorPosition (int x, int y)
public void SetCursor (MouseCursors newCur)
{
- throw new NotImplementedException ();
+ //throw new NotImplementedException ();
}
public void SetCursorPosition (int x, int y)
[DllImport ("libXcursor.so.1")]
static extern IntPtr XcursorImageLoadCursor (IntPtr dpy, IntPtr image);
-
+ [DllImport ("X11-xcb")]
+ static extern IntPtr XGetXCBConnection (IntPtr dpy);
#endregion
IntPtr xDisp, xwinHnd, xDefaultRootWin, xDefaultVisual;
XErrorHandler errorHnd;
Interface iFace;
- X11Keyboard keyboard;
+ XKB.XCBKeyboard Keyboard;
IntPtr [] cursors = new IntPtr [(int)MouseCursors.MaxEnum];
if (xDisp == IntPtr.Zero)
throw new NotSupportedException("[XLib] Failed to open display.");
+ IntPtr xcbCon = XGetXCBConnection (xDisp);
+ Keyboard = new XKB.XCBKeyboard (xcbCon, iFace);
+
xScreen = XDefaultScreen(xDisp);
xDefaultRootWin = XDefaultRootWindow (xDisp);
XMapWindow (xDisp, xwinHnd);
- keyboard = new Crow.XLib.X11Keyboard (xDisp);
+ //keyboard = new Crow.XLib.X11Keyboard (xDisp);
iFace.surf = new Crow.Cairo.XlibSurface (xDisp, xwinHnd, xDefaultVisual, iFace.ClientRectangle.Width, iFace.ClientRectangle.Height);
public void CleanUp ()
{
- keyboard.Destroy ();
+ Keyboard.Destroy ();
XCloseDisplay (xDisp);
}
public void Flush () {
- XSync (xDisp, 1);
+ XSync (xDisp, 0);
}
public void ProcessEvents ()
{
iFace.ProcessResize (new Rectangle (0, 0, xevent.ExposeEvent.width, xevent.ExposeEvent.height));
break;
case XEventName.KeyPress:
- keyboard.HandleEvent ((uint)xevent.KeyEvent.keycode, true);
+ Keyboard.HandleEvent ((uint)xevent.KeyEvent.keycode, true);
break;
case XEventName.KeyRelease:
- keyboard.HandleEvent ((uint)xevent.KeyEvent.keycode, false);
+ Keyboard.HandleEvent ((uint)xevent.KeyEvent.keycode, false);
break;
case XEventName.MotionNotify:
//Debug.WriteLine ("motion: ({0},{1})", xevent.MotionEvent.x, xevent.MotionEvent.y);
}
}
}
- public bool IsDown (Key key) {
+ public bool IsDown (Key key)
+ {
return false;
}
public bool Shift {
- get {
- throw new NotImplementedException ();
- }
+ get { return Keyboard.Shift; }
}
public bool Ctrl {
- get {
- throw new NotImplementedException ();
- }
+ get { return Keyboard.Ctrl; }
}
public bool Alt {
- get {
- throw new NotImplementedException ();
- }
+ get { return Keyboard.Alt; }
}
public void SetCursor (MouseCursors newCur)
{
<?xml version="1.0"?>
<Popper Font="{./Font}" Caption="{./Caption}" Background="{./Background}" PopDirection="{./PopDirection}"
- Foreground = "{./Foreground}" CanPop="{./HasChildren}" MouseClick="./onMI_Click"
+ Foreground = "{./Foreground}" CanPop="{./HasChildren}"
IsPopped="{²./IsOpened}" PopWidth="{./PopWidth}" PopHeight="{./PopHeight}" IsEnabled="{./IsEnabled}">
<Template>
<CheckBox IsChecked="{²./IsPopped}" Caption="{./Caption}" Background="{./Background}" Foreground="{./Foreground}">
<Template>
- <Border Name="border1"
+ <Border Name="border1" ForwardMouseEvents="true"
MouseEnter="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
MouseLeave="{Foreground=Transparent}"
MouseDown="{Foreground=vgradient|0:Black|0.05:Grey|0.85:Grey|1:White}"