void IEventPortal.PortalMouseUp(UIMouseEventArgs e) { //find hit svg graphics.... SvgHitChain hitChain = GetFreeHitChain(); hitChain.SetRootGlobalPosition(e.X, e.Y); //1. hit test HitTestCore(this.SvgRoot.SvgSpec, hitChain, e.X, e.Y); SetEventOrigin(e, hitChain); //2. propagate event portal ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseUp(e); return(true); }); if (!e.CancelBubbling) { //2. propagate events ForEachEventListenerBubbleUp(e, hitChain, () => { e.CurrentContextElement.ListenMouseUp(e); return(true); }); } e.CancelBubbling = true; ReleaseHitChain(hitChain); }
void IEventPortal.PortalMouseDown(UIMouseEventArgs e) { //find hit svg graphics.... SvgHitChain hitChain = GetFreeHitChain(); hitChain.SetRootGlobalPosition(e.X, e.Y); //1. hit test HitTestCore(this.SvgRoot.SvgSpec, hitChain, e.X, e.Y); SetEventOrigin(e, hitChain); //2. propagate event portal ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseDown(e); return(true); }); if (!e.CancelBubbling) { //2. propagate events ForEachSvgElementBubbleUp(e, hitChain, () => { //------- //temp test only //------- var svgElement = e.ExactHitObject as SvgElement; if (svgElement is SvgRect) { ((SvgRect)svgElement).FillColor = Color.White; } return(true); }); } e.CancelBubbling = true; ReleaseHitChain(hitChain); }
static void SetEventOrigin(UIEventArgs e, SvgHitChain hitChain) { int count = hitChain.Count; if (count > 0) { var hitInfo = hitChain.GetHitInfo(count - 1); e.ExactHitObject = hitInfo; } }
//------------------------------------------------ public override bool HitTestCore(SvgHitChain svgChain, float x, float y) { if (y >= this.ActualY & y < (this.ActualY + this.ActualHeight)) { if (x >= this.ActualX && x < this.ActualX + this.ActualWidth) { svgChain.AddHit(this, x, y); return(true); } } return(false); }
static void ForEachSvgElementBubbleUp(UIEventArgs e, SvgHitChain hitChain, EventListenerAction listenerAction) { for (int i = hitChain.Count - 1; i >= 0; --i) { //propagate up var hitInfo = hitChain.GetHitInfo(i); //--------------------- //hit on element e.SetLocation((int)hitInfo.x, (int)hitInfo.y); if (listenerAction()) { return; } } }
public static void HitTestCore(SvgElement root, SvgHitChain chain, float x, float y) { //1. chain.AddHit(root, x, y); //2. find hit child var child = root.GetFirstNode(); while (child != null) { var node = child.Value; if (node.HitTestCore(chain, x, y)) { break; } child = child.Next; } }
static void ForEachEventListenerBubbleUp(UIEventArgs e, SvgHitChain hitChain, EventListenerAction listenerAction) { for (int i = hitChain.Count - 1; i >= 0; --i) { //propagate up var hitInfo = hitChain.GetHitInfo(i); IEventListener controller = SvgElement.UnsafeGetController(hitInfo.svg) as IEventListener; //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.CurrentContextElement = controller; e.SetLocation((int)hitInfo.x, (int)hitInfo.y); if (listenerAction()) { return; } } } }
static void ForEachOnlyEventPortalBubbleUp(UIEventArgs e, SvgHitChain hitPointChain, EventPortalAction eventPortalAction) { //only listener that need tunnel down for (int i = hitPointChain.Count - 1; i >= 0; --i) { //propagate up var hitInfo = hitPointChain.GetHitInfo(i); SvgElement svg = hitInfo.svg; if (svg != null) { var controller = SvgElement.UnsafeGetController(hitInfo.svg) as IEventPortal; if (controller != null) { e.SetLocation((int)hitInfo.x, (int)hitInfo.y); if (eventPortalAction(controller)) { return; } } } } }
public static void HitTestCore(SvgElement root, SvgHitChain chain, float x, float y) { //1. chain.AddHit(root, x, y); //2. find hit child var child = root.GetFirstNode(); //TODO: review here again! // throw new System.NotImplementedException(); //TODO: check hit test core on svg again! //while (child != null) //{ // //test hit text core again // var node = child.Value; // if (node.HitTestCore(chain, x, y)) // { // break; // } // child = child.Next; //} }
//------------------------------------------------ public override bool HitTestCore(SvgHitChain svgChain, float x, float y) { //is in circle area ? return false; }
//------------------------------------------------ public override bool HitTestCore(SvgHitChain svgChain, float x, float y) { //is in circle area ? return(false); }
public virtual bool HitTestCore(SvgHitChain svgChain, float x, float y) { return(false); }
void ReleaseHitChain(SvgHitChain hitChain) { hitChain.Clear(); this.hitChainPools.Push(hitChain); }
//------------------------------------------------ public override bool HitTestCore(SvgHitChain svgChain, float x, float y) { if (y >= this.ActualY & y < (this.ActualY + this.ActualHeight)) { if (x >= this.ActualX && x < this.ActualX + this.ActualWidth) { svgChain.AddHit(this, x, y); return true; } } return false; }
void IEventPortal.PortalMouseMove(UIMouseEventArgs e) { int x = e.X; int y = e.Y; if (e.IsDragging) { //dragging *** , if changed //handle mouse drag SvgHitChain hitChain = GetFreeHitChain(); hitChain.SetRootGlobalPosition(x, y); HitTestCore(this.SvgRoot.SvgSpec, hitChain, e.X, e.Y); SetEventOrigin(e, hitChain); //--------------------------------------------------------- //propagate mouse drag ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseMove(e); return(true); }); //--------------------------------------------------------- if (!e.CancelBubbling) { //clear previous svg selection ClearPreviousSelection(); //if (hitChain.Count > 0) //{ // //create selection range // this._htmlContainer.SetSelection(new SelectionRange( // _latestMouseDownChain, // hitChain, // this.ifonts)); //} //else //{ // this._htmlContainer.SetSelection(null); //} ForEachEventListenerBubbleUp(e, hitChain, () => { e.CurrentContextElement.ListenMouseMove(e); return(true); }); } //--------------------------------------------------------- ReleaseHitChain(hitChain); } else { //mouse move //--------------------------------------------------------- SvgHitChain hitChain = GetFreeHitChain(); hitChain.SetRootGlobalPosition(x, y); HitTestCore(this.SvgRoot.SvgSpec, hitChain, e.X, e.Y); SetEventOrigin(e, hitChain); //--------------------------------------------------------- ForEachOnlyEventPortalBubbleUp(e, hitChain, (portal) => { portal.PortalMouseMove(e); return(true); }); //--------------------------------------------------------- if (!e.CancelBubbling) { ForEachEventListenerBubbleUp(e, hitChain, () => { e.CurrentContextElement.ListenMouseMove(e); return(true); }); } ReleaseHitChain(hitChain); } }
public virtual bool HitTestCore(SvgHitChain svgChain, float x, float y) { return false; }