Exemple #1
0
        public static UIEventListenerContext Create(IUIEventListener listener)
        {
            UIEventListenerContext context = RecyclableObject.Create <UIEventListenerContext>();

            context.m_listener = listener;
            return(context);
        }
Exemple #2
0
        static void ForEachEventListenerBubbleUp(UIEventArgs e, HitChain hitPointChain, EventListenerAction listenerAction)
        {
            HitInfo hitInfo;

            for (int i = hitPointChain.Count - 1; i >= 0; --i)
            {
                hitInfo = hitPointChain.GetHitInfo(i);
                IUIEventListener listener = hitInfo.hitElement.GetController() as IUIEventListener;
                if (listener != null)
                {
                    if (e.SourceHitElement == null)
                    {
                        e.SourceHitElement = listener;
                    }

                    var hitPoint = hitInfo.point;
                    e.SetLocation(hitPoint.X, hitPoint.Y);
                    e.CurrentContextElement = listener;
                    if (listenerAction(listener))
                    {
                        return;
                    }
                }
            }
        }
        protected override void OnStartDemo(IViewport viewport)
        {
            IUIRootElement root         = viewport.Root;
            IUIBoxElement  sampleButton = (IUIBoxElement)root.CreateElement2(BasicUIElementKind.SimpleBox);

            root.AddContent(sampleButton);
            sampleButton.SetLocation(20, 20);

            IUIBoxElement textbox = (IUIBoxElement)root.CreateElement2(BasicUIElementKind.TextBox);

            root.AddContent(textbox);
            textbox.SetLocation(20, 60);
            textbox.SetSize(100, 24);

            IUIEventListener evListener = root.CreateEventListener();
            int count = 0;

            evListener.MouseDown += (e) =>
            {
                System.Console.WriteLine("click :" + (count++));
            };


            sampleButton.AttachEventListener(evListener);
        }
        public void MouseDown(UIMouseEventArgs e, CssBox startAt)
        {
            if (!_isBinded)
            {
                return;
            }
            if (startAt == null)
            {
                return;
            }
            //----------------------------------------------------
            ClearPreviousSelection();
            if (_latestMouseDownChain != null)
            {
                ReleaseHitChain(_latestMouseDownChain);
                _latestMouseDownChain = null;
            }
            this.lastDomLayoutVersion = this._htmlContainer.LayoutVersion;
            //----------------------------------------------------
            int x = e.X;
            int y = e.Y;

            this._mouseDownStartAt = startAt;
            this._mousedownX       = x;
            this._mousedownY       = y;
            CssBoxHitChain hitChain = GetFreeHitChain();

            hitChain.SetRootGlobalPosition(x, y);
            //1. hittest
            BoxHitUtils.HitTest(startAt, x, y, hitChain);
            //2. propagate events
            SetEventOrigin(e, hitChain);
            ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) =>
            {
                portal.PortalMouseDown(e);
                return(true);
            });
            if (!e.CancelBubbling)
            {
                var prevMouseDownElement = this.currentMouseDown;
                e.CurrentContextElement = this.currentMouseDown = null; //clear
                ForEachEventListenerBubbleUp(e, hitChain, () =>
                {
                    //TODO: check accept keyboard
                    this.currentMouseDown = e.CurrentContextElement;
                    e.CurrentContextElement.ListenMouseDown(e);
                    if (prevMouseDownElement != null &&
                        prevMouseDownElement != currentMouseDown)
                    {
                        prevMouseDownElement.ListenLostMouseFocus(e);
                    }

                    return(e.CancelBubbling);
                });
            }
            //----------------------------------
            //save mousedown hitchain
            this._latestMouseDownChain = hitChain;
        }
Exemple #5
0
        void IEventPortal.PortalMouseWheel(UIMouseEventArgs e)
        {
#if DEBUG
            if (this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEWHEEL");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
#endif
            HitChain hitPointChain = GetFreeHitChain();
#if DEBUG
            _dbugHitChainPhase = dbugHitChainPhase.MouseWheel;
#endif
            //find hit element
            HitTestCoreWithPrevChainHint(hitPointChain, _previousChain, e.X, e.Y);
            if (hitPointChain.Count > 0)
            {
                //------------------------------
                //1. origin object
                SetEventOrigin(e, hitPointChain);
                //------------------------------
                IUIEventListener currentMouseWheel = null;
                //portal
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, portal =>
                {
                    portal.PortalMouseWheel(e);
                    //*****
                    currentMouseWheel = e.CurrentContextElement;
                    return(true);
                });
                //------------------------------
                //use events
                if (!e.CancelBubbling)
                {
                    e.CurrentContextElement = currentMouseWheel = null; //clear
                    ForEachEventListenerBubbleUp(e, hitPointChain, listener =>
                    {
                        if (listener.BypassAllMouseEvents)
                        {
                            return(false);
                        }
                        currentMouseWheel = listener;
                        listener.ListenMouseWheel(e);
                        //-------------------------------------------------------
                        bool cancelMouseBubbling = e.CancelBubbling;
                        //-------------------------------------------------------
                        //retrun true to stop this loop (no further bubble up)
                        //return false to bubble this to upper control
                        return(e.CancelBubbling || !listener.BypassAllMouseEvents);
                    });
                }
            }

            SwapHitChain(hitPointChain);
            e.StopPropagation();
        }
Exemple #6
0
 public void SetMonitorElement(IUIEventListener elem)
 {
     if (_elem != elem)
     {
         //reset count
         _mouseMoveCounter = -1;//reset
         _elem             = elem;
     }
 }
Exemple #7
0
        void ITopWindowEventRoot.RootMouseMove(int x, int y, UIMouseButtons button)
        {
            int xdiff = x - prevLogicalMouseX;
            int ydiff = y - prevLogicalMouseY;

            this.prevLogicalMouseX = x;
            this.prevLogicalMouseY = y;
            if (xdiff == 0 && ydiff == 0)
            {
                return;
            }

            //-------------------------------------------------------
            //when mousemove -> reset hover!
            hoverMonitoringTask.Reset();
            hoverMonitoringTask.Enabled = true;
            UIMouseEventArgs e = GetFreeMouseEvent();

            SetUIMouseEventArgsInfo(e, x, y, button, 0);
            e.SetDiff(xdiff, ydiff);
            //-------------------------------------------------------
            e.IsDragging = this.isDragging = this.isMouseDown;
            if (this.isDragging)
            {
                if (draggingElement != null)
                {
                    //send this to dragging element first
                    int d_GlobalX, d_globalY;
                    draggingElement.GetGlobalLocation(out d_GlobalX, out d_globalY);
                    e.SetLocation(e.GlobalX - d_GlobalX, e.GlobalY - d_globalY);
                    e.CapturedMouseX = this.localMouseDownX;
                    e.CapturedMouseY = this.localMouseDownY;
                    var iportal = draggingElement as IEventPortal;
                    if (iportal != null)
                    {
                        iportal.PortalMouseMove(e);
                        if (!e.IsCanceled)
                        {
                            draggingElement.ListenMouseMove(e);
                        }
                    }
                    else
                    {
                        draggingElement.ListenMouseMove(e);
                    }
                }
            }
            else
            {
                iTopBoxEventPortal.PortalMouseMove(e);
                draggingElement = null;
            }
            //-------------------------------------------------------

            this.mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }
Exemple #8
0
        public bool AttachEventListener(IUIEventListener uiEventListener)
        {
            GeneralEventListener genEventListener = uiEventListener as GeneralEventListener;

            if (genEventListener != null)
            {
                genEventListener.uiElement = uiElem;
                uiElem.AttachExternalEventListener(genEventListener);
            }
            return(false);
        }
            /// <summary>
            /// set monitoed elem + invoke 1st mouse press event
            /// </summary>
            /// <param name="ui"></param>
            public void SetMonitoredElement(IUIEventListener ui)
            {
#if DEBUG
                if (ui == null)
                {
                    System.Diagnostics.Debugger.Break();
                }
#endif

                _currentMonitoredElem = ui;
                _mousePressCount      = 0;
                _mousePressEventArgs.CurrentContextElement = ui;
                _currentMonitoredElem.ListenMousePress(_mousePressEventArgs);
            }
        void IEventPortal.PortalMouseLeaveFromViewport()
        {
            //mouse out from viewport

            if (_latestMouseActive != null)
            {
                _mouseLeaveEventArgs.IsDragging = false;
                UIMouseLeaveEventArgs.SetDiff(_mouseLeaveEventArgs, 0, 0);
                _mouseLeaveEventArgs.SetCurrentContextElement(null);

                _latestMouseActive.ListenMouseLeave(_mouseLeaveEventArgs);
                _latestMouseActive = null;
            }
        }
        static void ForEachEventListenerBubbleUp(UIEventArgs e, CssBoxHitChain hitChain, System.Func <bool> listenerAction)
        {
            for (int i = hitChain.Count - 1; i >= 0; --i)
            {
                //propagate up
                var hitInfo = hitChain.GetHitInfo(i);
                IUIEventListener controller = null;
                switch (hitInfo.hitObjectKind)
                {
                default:
                {
                    continue;
                }

                case HitObjectKind.Run:
                {
                    CssRun run = (CssRun)hitInfo.hitObject;
                    controller = CssBox.UnsafeGetController(run.OwnerBox) as IUIEventListener;
                }
                break;

                case HitObjectKind.CssBox:
                {
                    CssBox box = (CssBox)hitInfo.hitObject;
                    controller = CssBox.UnsafeGetController(box) as IUIEventListener;
                }
                break;
                }

                //---------------------
                if (controller != null)
                {
                    //found controller
                    if (e.SourceHitElement == null)
                    {
                        e.SetSourceHitObject(controller);
                    }

                    e.SetCurrentContextElement(controller);
                    e.SetLocation(hitInfo.localX, hitInfo.localY);
                    if (listenerAction())
                    {
                        return;
                    }
                }
            }
        }
Exemple #12
0
        //
        void ITopWindowEventRoot.RootMouseDown(int x, int y, UIMouseButtons button)
        {
            _prevLogicalMouseX = x;
            _prevLogicalMouseY = y;
            _isMouseDown       = true;
            _isDragging        = false;
            UIMouseEventArgs e = GetFreeMouseEvent();

            SetUIMouseEventArgsInfo(e, x, y, button, 0);
            //
            e.Shift = _lastKeydownWithShift;
            e.Alt   = _lastKeydownWithAlt;
            e.Ctrl  = _lastKeydownWithControl;
            //
            e.PreviousMouseDown = _latestMouseDown;
            //
            _iTopBoxEventPortal.PortalMouseDown(e);
            //
            _currentMouseActiveElement = _latestMouseDown = e.CurrentContextElement;
            _localMouseDownX           = e.X;
            _localMouseDownY           = e.Y;
            if (e.DraggingElement != null)
            {
                if (e.DraggingElement != e.CurrentContextElement)
                {
                    //change captured element

                    e.DraggingElement.GetGlobalLocation(out int globalX, out int globalY);
                    //find new capture pos
                    _localMouseDownX = e.GlobalX - globalX;
                    _localMouseDownY = e.GlobalY - globalY;
                }
                _draggingElement = e.DraggingElement;
            }
            else
            {
                if (_currentMouseActiveElement != null &&
                    !_currentMouseActiveElement.BypassAllMouseEvents)
                {
                    _draggingElement = _currentMouseActiveElement;
                }
            }


            _mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }
        /// <summary>
        /// UI 리스너 제외
        /// </summary>
        /// <param name="protocol"></param>
        /// <param name="listener"></param>
        public void RemoveUIListener(Protocol protocol, IUIEventListener listener)
        {
            lock ( listenerLock ) {
                copyListeners.AddRange(uiListeners);

                foreach (UIListenerData data in copyListeners)
                {
                    if (data.Protocol != protocol)
                    {
                        continue;
                    }
                    if (data.Listener == listener)
                    {
                        uiListeners.Remove(data);
                    }
                }
                copyListeners.Clear();
            }
        }
Exemple #14
0
        void ITopWindowEventRoot.RootMouseDown(int x, int y, UIMouseButtons button)
        {
            this.prevLogicalMouseX = x;
            this.prevLogicalMouseY = y;
            this.isMouseDown       = true;
            this.isDragging        = false;
            UIMouseEventArgs e = GetFreeMouseEvent();

            SetUIMouseEventArgsInfo(e, x, y, button, 0);
            //
            e.Shift = lastKeydownWithShift;
            e.Alt   = lastKeydownWithAlt;
            e.Ctrl  = lastKeydownWithControl;
            //
            e.PreviousMouseDown = this.latestMouseDown;
            //
            iTopBoxEventPortal.PortalMouseDown(e);
            //
            this.currentMouseActiveElement = this.latestMouseDown = e.CurrentContextElement;
            this.localMouseDownX           = e.X;
            this.localMouseDownY           = e.Y;
            if (e.DraggingElement != null)
            {
                if (e.DraggingElement != e.CurrentContextElement)
                {
                    //change captured element
                    int globalX, globalY;
                    e.DraggingElement.GetGlobalLocation(out globalX, out globalY);
                    //find new capture pos
                    this.localMouseDownX = e.GlobalX - globalX;
                    this.localMouseDownY = e.GlobalY - globalY;
                }
                this.draggingElement = e.DraggingElement;
            }
            else
            {
                this.draggingElement = this.currentMouseActiveElement;
            }


            this.mouseCursorStyle = e.MouseCursorStyle;
            ReleaseMouseEvent(e);
        }
Exemple #15
0
        protected override void OnMouseDown(UIMouseEventArgs e)
        {
            //check if cell content
            //find grid item
            GridLayer layer   = _gridViewRenderE.GridLayer;
            GridCell  hitCell = layer.GetGridItemByPosition(e.X, e.Y);

            if (hitCell != null)
            {
                var box = hitCell.ContentElement as RenderBoxBase;
                if (box != null)
                {
                    if (box.ContainPoint(e.X - hitCell.X, e.Y - hitCell.Y))
                    {
                        IUIEventListener evenListener = box.GetController() as IUIEventListener;
                        if (evenListener != null)
                        {
                            int tmpX = e.X;
                            int tmpY = e.Y;
                            e.SetLocation(tmpX - hitCell.X, tmpY - hitCell.Y);
                            evenListener.ListenMouseDown(e);
                            e.SetLocation(tmpX, tmpY);
                        }
                    }
                }
                //
                //move _dragController to the selected cell?
                //
                if (EnableGridCellSelection)
                {
                    //--------
                    if (_gridSelectionSession == null)
                    {
                        _gridSelectionSession = new GridSelectionSession();
                        _gridSelectionSession.SetTargetGridView(this);
                    }
                    _gridSelectionSession.StartAt(hitCell);
                }
            }

            base.OnMouseDown(e);
        }
        static void ForEachEventListenerBubbleUp(UIEventArgs e, VgHitChain hitChain, System.Func <bool> listenerAction)
        {
            for (int i = hitChain.Count - 1; i >= 0; --i)
            {
                //propagate up
                VgHitInfo hitInfo = hitChain.GetHitInfo(i);

                IUIEventListener controller = SvgElement.UnsafeGetController(hitInfo.GetSvgElement()) as IUIEventListener;
                //switch (hitInfo.hitObjectKind)
                //{
                //    default:
                //        {
                //            continue;
                //        }
                //    case HitObjectKind.Run:
                //        {
                //            CssRun run = (CssRun)hitInfo.hitObject;
                //            controller = CssBox.UnsafeGetController(run.OwnerBox) as IEventListener;

                //        } break;
                //    case HitObjectKind.CssBox:
                //        {
                //            CssBox box = (CssBox)hitInfo.hitObject;
                //            controller = CssBox.UnsafeGetController(box) as IEventListener;
                //        } break;
                //}

                //---------------------
                if (controller != null)
                {
                    //found controller

                    e.SetCurrentContextElement(controller);
                    e.SetLocation((int)hitInfo.x, (int)hitInfo.y);
                    if (listenerAction())
                    {
                        return;
                    }
                }
            }
        }
Exemple #17
0
        public void NotifyUI(int event_type, System.Object event_data)
        {
            List <UIEventListenerContext> listeners;

            if (!m_all_listeners.TryGetValue(event_type, out listeners))
            {
                return;
            }
            int listener_cnt = listeners.Count;

            if (listener_cnt == 0)
            {
                return;
            }
            int index = 0;

            while (index < listener_cnt)
            {
                UIEventListenerContext context  = listeners[index];
                IUIEventListener       listener = context.m_listener;
                if (listener == null)
                {
                    listeners.RemoveAt(index);
                }
                else
                {
                    listener.ReceiveEvent(event_type, event_data);
                }

                int new_count = listeners.Count;
                if (new_count < listener_cnt)
                {
                    listener_cnt = new_count;
                }
                else
                {
                    ++index;
                }
            }
        }
            public MousePressMonitorHelper(int intervalMs)
            {
                _intervalMs           = intervalMs;
                _mousePressCount      = 0;
                _currentMonitoredElem = null;
                _mousePressEventArgs  = new UIMousePressEventArgs();

                _mousePressMonitor = new UITimerTask(t =>
                {
                    if (_currentMonitoredElem != null)
                    {
                        //invoke mouse press event
                        if (_mousePressCount > 0)
                        {
                            _currentMonitoredElem.ListenMousePress(_mousePressEventArgs);
                        }
                        _mousePressCount++;
                    }
                });
                _mousePressMonitor.Enabled  = true;
                _mousePressMonitor.Interval = intervalMs; //interval for mouse press monitor
                UIPlatform.RegisterTimerTask(_mousePressMonitor);
            }
Exemple #19
0
        protected override void OnStart(AppHost host)
        {
            int x_pos = 0;

            GeneralEventListener evListener = new GeneralEventListener();

            evListener.MouseEnter += (s, e) =>
            {
                IUIEventListener             ctx = e.CurrentContextElement;
                LayoutFarm.CustomWidgets.Box box = (LayoutFarm.CustomWidgets.Box)ctx;
                box.BackColor = Color.Red;
#if DEBUG
                System.Diagnostics.Debug.WriteLine("mouse_enter:" + box.dbugId);
#endif
            };
            evListener.MouseLeave += (s, e) =>
            {
                IUIEventListener             ctx = e.CurrentContextElement;
                LayoutFarm.CustomWidgets.Box box = (LayoutFarm.CustomWidgets.Box)ctx;
                box.BackColor = Color.Blue;
#if DEBUG
                System.Diagnostics.Debug.WriteLine("mouse_leave:" + box.dbugId);
#endif
            };

            for (int i = 0; i < 10; ++i)
            {
                var sampleButton = new LayoutFarm.CustomWidgets.Box(30, 30);
                sampleButton.BackColor = Color.Blue;
                sampleButton.SetLocation(x_pos, 10);
                sampleButton.AttachExternalEventListener(evListener);

                host.AddChild(sampleButton);

                x_pos += 30 + 5;
            }
        }
        public void MouseDown(UIMouseDownEventArgs e, CssBox startAt)
        {
            if (!_isBinded)
            {
                return;
            }
            if (startAt == null)
            {
                return;
            }
            //----------------------------------------------------
            if (!e.Shift)
            {
                ClearPreviousSelection();
            }

            if (_latestMouseDownChain != null)
            {
                ReleaseHitChain(_latestMouseDownChain);
                _latestMouseDownChain = null;
            }
            _lastDomLayoutVersion = _htmlVisualRoot.LayoutVersion;
            //----------------------------------------------------
            int x = e.X;
            int y = e.Y;

            _mouseDownStartAt = startAt;
            _mousedownX       = x;
            _mousedownY       = y;
            CssBoxHitChain hitChain = GetFreeHitChain();

#if DEBUG
            hitChain.debugEventPhase = CssBoxHitChain.dbugEventPhase.MouseDown;
#endif
            hitChain.SetRootGlobalPosition(x, y);
            //1. hittest
            BoxHitUtils.HitTest(startAt, x, y, hitChain);
            //2. propagate events
            SetEventOrigin(e, hitChain);
            ForEachOnlyEventPortalBubbleUp(e, hitChain, portal =>
            {
                portal.PortalMouseDown(e);
                return(true);
            });
            if (!e.CancelBubbling)
            {
                IUIEventListener prevMouseDownElement = _currentMouseDown;
                _currentMouseDown = null; //clear
                e.SetCurrentContextElement(null);
                ForEachEventListenerBubbleUp(e, hitChain, () =>
                {
                    //TODO: check accept keyboard
                    _currentMouseDown = e.CurrentContextElement;
                    e.CurrentContextElement.ListenMouseDown(e);
                    if (prevMouseDownElement != null &&
                        prevMouseDownElement != _currentMouseDown)
                    {
                        prevMouseDownElement.ListenLostMouseFocus(_mouseLostFocus);
                    }

                    return(e.CancelBubbling);
                });
            }
            //----------------------------------
            //save mousedown hitchain
            _latestMouseDownChain = hitChain;
        }
 public void SetTargetUISprite(IUIEventListener ui)
 {
     _ui = ui;
 }
Exemple #22
0
 public void SetMouseCapture(IUIEventListener listener)
 {
     this.DraggingElement = listener;
 }
Exemple #23
0
        void IEventPortal.PortalMouseDown(UIMouseEventArgs e)
        {
#if DEBUG
            if (this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEDOWN");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
            dbugMsgChainVersion = 1;
            int local_msgVersion = 1;
#endif


            HitChain hitPointChain = GetFreeHitChain();
            HitTestCoreWithPrevChainHint(hitPointChain, this._previousChain, e.X, e.Y);
            int           hitCount   = hitPointChain.Count;
            RenderElement hitElement = hitPointChain.TopMostElement;
            if (hitCount > 0)
            {
                //------------------------------
                //1. origin object
                SetEventOrigin(e, hitPointChain);
                //------------------------------
                var prevMouseDownElement          = e.PreviousMouseDown;
                IUIEventListener currentMouseDown = null;
                //portal
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (portal) =>
                {
                    portal.PortalMouseDown(e);
                    //*****
                    currentMouseDown = e.CurrentContextElement;
                    return(true);
                });
                //------------------------------
                //use events
                if (!e.CancelBubbling)
                {
                    e.CurrentContextElement = currentMouseDown = null; //clear
                    ForEachEventListenerBubbleUp(e, hitPointChain, (listener) =>
                    {
                        currentMouseDown = listener;
                        listener.ListenMouseDown(e);
                        //-------------------------------------------------------
                        bool cancelMouseBubbling = e.CancelBubbling;
                        if (prevMouseDownElement != null &&
                            prevMouseDownElement != listener)
                        {
                            prevMouseDownElement.ListenLostMouseFocus(e);
                            prevMouseDownElement = null;//clear
                        }
                        //-------------------------------------------------------
                        return(e.CancelBubbling || !listener.BypassAllMouseEvents);
                    });
                }

                if (prevMouseDownElement != currentMouseDown &&
                    prevMouseDownElement != null)
                {
                    prevMouseDownElement.ListenLostMouseFocus(e);
                    prevMouseDownElement = null;
                }
            }
            //---------------------------------------------------------------

#if DEBUG
            RootGraphic visualroot = this.dbugRootGraphics;
            if (visualroot.dbug_RecordHitChain)
            {
                visualroot.dbug_rootHitChainMsg.Clear();
                HitInfo hitInfo;
                for (int tt = hitPointChain.Count - 1; tt >= 0; --tt)
                {
                    hitInfo = hitPointChain.GetHitInfo(tt);
                    RenderElement ve = hitInfo.hitElement;
                    if (ve != null)
                    {
                        ve.dbug_WriteOwnerLayerInfo(visualroot, tt);
                        ve.dbug_WriteOwnerLineInfo(visualroot, tt);
                        string hit_info = new string('.', tt) + " [" + tt + "] "
                                          + "(" + hitInfo.point.X + "," + hitInfo.point.Y + ") "
                                          + ve.dbug_FullElementDescription();
                        visualroot.dbug_rootHitChainMsg.AddLast(new dbugLayoutMsg(ve, hit_info));
                    }
                }
            }
#endif
            SwapHitChain(hitPointChain);
            e.StopPropagation();
#if DEBUG
            if (local_msgVersion != dbugMsgChainVersion)
            {
                return;
            }
            visualroot.dbugHitTracker.Write("stop-mousedown");
            visualroot.dbugHitTracker.Play = false;
#endif
        }
 /// <summary>
 /// UI 리스너 등록
 /// </summary>
 /// <param name="protocol"></param>
 /// <param name="listener"></param>
 public void AddUIListener(Protocol protocol, IUIEventListener listener)
 {
     lock ( listenerLock ) {
         uiListeners.Add(new UIListenerData(protocol, listener));
     }
 }
        void IEventPortal.PortalMouseMove(UIMouseMoveEventArgs e)
        {
            HitChain hitPointChain = GetFreeHitChain();

#if DEBUG
            _dbugHitChainPhase = dbugHitChainPhase.MouseMove;
#endif
            HitTestCoreWithPrevChainHint(hitPointChain, _previousChain, e.X, e.Y);
            _previousChain.Reset();
            SetEventOrigin(e, hitPointChain);
            //-------------------------------------------------------
            ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (e1, portal) =>
            {
                //please ensure=> no local var/pararmeter capture inside lambda
                portal.PortalMouseMove(e1);
                return(true);
            });
            //-------------------------------------------------------
            if (!e.CancelBubbling)
            {
                _mouseMoveFoundSomeHit         = false;
                _mouseMoveFoundLastMouseActive = false;
                ForEachEventListenerBubbleUp(e, hitPointChain, (e1, listener) =>
                {
                    //please ensure=> no local var/pararmeter capture inside lambda
                    _mouseMoveFoundSomeHit = true;

#if DEBUG
                    if (_dbugEnableDebugMark && e.Ctrl && e1.X <= 10 && e1.Y <= 10)
                    {
                        //show dbug info
                        listener.dbugDevWriteInfo();
                    }
#endif



                    bool _bubble = true; //temp fix
                    if (_latestMouseActive != listener && !_mouseMoveFoundLastMouseActive)
                    {
                        //----------
                        e1.CancelBubbling = _bubble; //temp fix
                        listener.ListenMouseEnter(e1);
                        _bubble = e1.CancelBubbling;
                        //----------

                        if (_latestMouseActive != null)
                        {
                            _mouseLeaveEventArgs.SetCurrentContextElement(_latestMouseActive);
                            UIMouseLeaveEventArgs.SetDiff(_mouseLeaveEventArgs, e1.XDiff, e1.YDiff);
                            _latestMouseActive.ListenMouseLeave(_mouseLeaveEventArgs);
                        }

                        _latestMouseActive = listener;
                    }


                    if (!e1.IsCanceled)
                    {
                        //TODO: review here
                        e1.CancelBubbling = _bubble; //temp fix
                        listener.ListenMouseMove(e1);

                        if (!_mouseMoveFoundLastMouseActive)
                        {
                            _latestMouseActive = e1.CurrentContextElement;
                        }
                    }

                    if (!e1.CancelBubbling)
                    {
                        _mouseMoveFoundLastMouseActive = true;
                    }
                    return(e1.CancelBubbling);
                });

                if (!_mouseMoveFoundSomeHit)
                {
                    if (_latestMouseActive != null)
                    {
                        _mouseLeaveEventArgs.IsDragging = e.IsDragging;
                        UIMouseLeaveEventArgs.SetDiff(_mouseLeaveEventArgs, e.XDiff, e.YDiff);
                        _mouseLeaveEventArgs.SetCurrentContextElement(_latestMouseActive);

                        _latestMouseActive.ListenMouseLeave(_mouseLeaveEventArgs);
                        _latestMouseActive = null;
                    }
                }
            }
            SwapHitChain(hitPointChain);
            e.StopPropagation();
        }
 public void Reset()
 {
     _currentMonitoredElem = null;
     _mousePressCount      = 0;
 }
 /// <summary>
 /// UI 리스너 등록
 /// </summary>
 /// <param name="protocol"></param>
 /// <param name="listener"></param>
 public void AddUIListener(Protocol protocol, IUIEventListener listener) {
     lock( listenerLock ) {
         uiListeners.Add(new UIListenerData(protocol, listener));
     }
 }
        void IEventPortal.PortalMouseDown(UIMouseDownEventArgs e)
        {
#if DEBUG
            if (this.dbugRootGraphics != null && this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEDOWN");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
            dbugMsgChainVersion = 1;
            int local_msgVersion = 1;
#endif
            HitChain hitPointChain = GetFreeHitChain();
#if DEBUG
            _dbugHitChainPhase = dbugHitChainPhase.MouseDown;
#endif
            HitTestCoreWithPrevChainHint(hitPointChain, _previousChain, e.X, e.Y);

            if (hitPointChain.Count > 0)
            {
                //------------------------------
                //1. origin object
                SetEventOrigin(e, hitPointChain);
                //------------------------------

                _currentMouseDown = null;
                //portal
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (e1, portal) =>
                {
                    //please ensure=> no local var/pararmeter capture inside lambda
                    portal.PortalMouseDown(e1);
                    //*****
                    _currentMouseDown = e1.CurrentContextElement;
                    return(true);
                });
                //------------------------------
                //use events
                if (!e.CancelBubbling)
                {
                    _currentMouseDown = null; //clear
                    e.SetCurrentContextElement(null);

                    ForEachEventListenerBubbleUp(e, hitPointChain, (e1, listener) =>
                    {
                        //please ensure=> no local var/pararmeter capture inside lambda
                        if (listener.BypassAllMouseEvents)
                        {
                            return(false);
                        }
                        _currentMouseDown = listener;

                        listener.ListenMouseDown(e1);

                        //-------------------------------------------------------
                        //auto begin monitor mouse press
                        _mousePressMonitor.AddMousePressInformation(e1);
                        _mousePressMonitor.SetMonitoredElement(listener);
                        //-------------------------------------------------------
                        bool cancelMouseBubbling = e1.CancelBubbling;
                        if (_prevMouseDownElement != null &&
                            _prevMouseDownElement != listener)
                        {
                            _prevMouseDownElement.ListenLostMouseFocus(_mouseLostFocusArgs);
                            _prevMouseDownElement = null;//clear
                        }
                        //-------------------------------------------------------
                        //retrun true to stop this loop (no further bubble up)
                        //return false to bubble this to upper control
                        return(e1.CancelBubbling || !listener.BypassAllMouseEvents);
                    });

                    if (_currentMouseDown == null)
                    {
                        _mousePressMonitor.Reset();
                    }
                }

                if (_prevMouseDownElement != _currentMouseDown &&
                    _prevMouseDownElement != null)
                {
                    //TODO: review here, auto or manual
                    _prevMouseDownElement.ListenLostMouseFocus(_mouseLostFocusArgs);
                    _prevMouseDownElement = null;
                }
            }
            //---------------------------------------------------------------

#if DEBUG
            RootGraphic dbug_visualroot = this.dbugRootGraphics;
            if (dbug_visualroot != null && dbug_visualroot.dbug_RecordHitChain)
            {
                dbug_visualroot.dbug_rootHitChainMsg.Clear();
                HitInfo hitInfo;
                for (int tt = hitPointChain.Count - 1; tt >= 0; --tt)
                {
                    hitInfo = hitPointChain.GetHitInfo(tt);
                    RenderElement ve = hitInfo.HitElemAsRenderElement;
                    if (ve != null)
                    {
                        ve.dbug_WriteOwnerLayerInfo(dbug_visualroot, tt);
                        ve.dbug_WriteOwnerLineInfo(dbug_visualroot, tt);
                        string hit_info = new string('.', tt) + " [" + tt + "] "
                                          + "(" + hitInfo.point.X + "," + hitInfo.point.Y + ") "
                                          + ve.dbug_FullElementDescription();
                        dbug_visualroot.dbug_rootHitChainMsg.AddLast(new dbugLayoutMsg(ve, hit_info));
                    }
                }
            }
#endif

            SwapHitChain(hitPointChain);

            e.StopPropagation(); //TODO: review this again
#if DEBUG
            if (local_msgVersion != dbugMsgChainVersion)
            {
                return;
            }
            dbug_visualroot.dbugHitTracker.Write("stop-mousedown");
            dbug_visualroot.dbugHitTracker.Play = false;
#endif
        }
Exemple #29
0
 public ScrollBarButton(int w, int h, IUIEventListener owner)
     : base(w, h)
 {
     this.OwnerScrollBar = owner;
 }
        void IEventPortal.PortalMouseWheel(UIMouseWheelEventArgs e)
        {
#if DEBUG
            if (dbugRootGraphics != null && this.dbugRootGraphics.dbugEnableGraphicInvalidateTrace)
            {
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("MOUSEWHEEL");
                this.dbugRootGraphics.dbugGraphicInvalidateTracer.WriteInfo("================");
            }
#endif
            HitChain hitPointChain = GetFreeHitChain();
#if DEBUG
            _dbugHitChainPhase = dbugHitChainPhase.MouseWheel;
#endif
            //find hit element
            HitTestCoreWithPrevChainHint(hitPointChain, _previousChain, e.X, e.Y);
            if (hitPointChain.Count > 0)
            {
                //------------------------------
                //1. origin object
                SetEventOrigin(e, hitPointChain);
                //------------------------------

                //portal
                ForEachOnlyEventPortalBubbleUp(e, hitPointChain, (e1, portal) =>
                {
                    //please ensure=> no local var/pararmeter capture inside lambda
                    portal.PortalMouseWheel(e1);
                    //*****
                    _currentMouseWheel = e1.CurrentContextElement;
                    return(true);
                });
                //------------------------------
                //use events
                if (!e.CancelBubbling)
                {
                    _currentMouseWheel = null;
                    e.SetCurrentContextElement(null);//clear

                    ForEachEventListenerBubbleUp(e, hitPointChain, (e1, listener) =>
                    {
                        //please ensure=> no local var/pararmeter capture inside lambda
                        if (listener.BypassAllMouseEvents)
                        {
                            return(false);
                        }
                        _currentMouseWheel = listener;
                        listener.ListenMouseWheel(e1);

#if DEBUG
                        if (e1.CancelBubbling)
                        {
                        }
#endif

                        //retrun true to stop this loop (no further bubble up)
                        //return false to bubble this to upper control
                        return(e1.CancelBubbling || !listener.BypassAllMouseEvents);
                    });
                }
            }

            SwapHitChain(hitPointChain);
            e.StopPropagation();
        }
Exemple #31
0
 public UIListenerData(Protocol protocol, IUIEventListener listener)
 {
     this.Protocol = protocol;
     this.Listener = listener;
 }
        /// <summary>
        /// UI 리스너 제외
        /// </summary>
        /// <param name="protocol"></param>
        /// <param name="listener"></param>
        public void RemoveUIListener(Protocol protocol, IUIEventListener listener) {
            lock( listenerLock ) {
                copyListeners.AddRange(uiListeners);

                foreach( UIListenerData data in copyListeners ) {
                    if( data.Protocol != protocol ) continue;
                    if( data.Listener == listener ) {
                        uiListeners.Remove(data);
                    }
                }
                copyListeners.Clear();
            }
        }
 public UIListenerData(Protocol protocol, IUIEventListener listener) {
     this.Protocol = protocol;
     this.Listener = listener;
 }