public GetGlobalLocation ( float &globalX, float &globalY ) : |
||
globalX | float | |
globalY | float | |
리턴 |
void dbugAddToProperContainer(CssBox box) { var rectChild = new RectangleF(box.LocalX, box.LocalY, box.InnerContentWidth, box.InnerContentHeight); CssBox parent = box.ParentBox; bool found = false; while (parent != null) { var rectParent = new RectangleF(0, 0, parent.VisualWidth, parent.VisualHeight); if (rectParent.Contains(rectChild)) { found = true; //add to here float bfx, bfy; box.GetGlobalLocation(out bfx, out bfy); float rfx, rfy; parent.GetGlobalLocation(out rfx, out rfy); //diff float nx = bfx - rfx; float ny = bfy - rfy; box.SetLocation(nx, ny); parent.AppendToAbsoluteLayer(box); break; } else { rectChild.Offset(parent.LocalX, parent.LocalY); parent = parent.ParentBox; } } if (!found) { //add to root top float bfx, bfy; box.GetGlobalLocation(out bfx, out bfy); float rfx, rfy; this._rootBox.GetGlobalLocation(out rfx, out rfy); //diff float nx = bfx - rfx; float ny = bfy - rfy; box.SetLocation(nx, ny); this._rootBox.AppendToAbsoluteLayer(box); } }
static CssLineBox FindNearestLine(CssBox startBox, int globalY, int yRange) { CssLineBox latestLine = null; CssBox latestLineBoxOwner = null; float latestLineBoxGlobalYPos = 0; foreach (CssLineBox lineBox in BoxHitUtils.GetDeepDownLineBoxIter(startBox)) { if (lineBox.CacheLineHeight == 0) { continue; } if (latestLineBoxOwner != lineBox.OwnerBox) { //find global position of box latestLineBoxOwner = lineBox.OwnerBox; //TODO: review here , duplicate GetGlobalLocation float gx, gy; latestLineBoxOwner.GetGlobalLocation(out gx, out gy); latestLineBoxGlobalYPos = gy; } float lineGlobalBottom = lineBox.CachedLineBottom + latestLineBoxGlobalYPos; if (lineGlobalBottom <= globalY) { latestLine = lineBox; } else { latestLine = lineBox; break; } } return(latestLine); }
public void PerformLayout(LayoutVisitor lay) { if (this._rootBox == null) { return; } //----------------------- //reset _actualWidth = _actualHeight = 0; // if width is not restricted we set it to large value to get the actual later _rootBox.SetLocation(0, 0); _rootBox.SetVisualSize(this._maxWidth > 0 ? this._maxWidth : MAX_WIDTH, 0); CssBox.ValidateComputeValues(_rootBox); //----------------------- //LayoutVisitor layoutArgs = new LayoutVisitor(this.GraphicsPlatform, this); lay.PushContaingBlock(_rootBox); //----------------------- _rootBox.PerformLayout(lay); if (this._maxWidth <= 0.1) { // in case the width is not restricted we need to double layout, first will find the width so second can layout by it (center alignment) _rootBox.SetVisualWidth((int)Math.Ceiling(this._actualWidth)); _actualWidth = _actualHeight = 0; _rootBox.PerformLayout(lay); } lay.PopContainingBlock(); //----------------------- //TODO: review here again FloatingContextStack floatStack = lay.GetFloatingContextStack(); List <FloatingContext> totalContexts = floatStack.GetTotalContexts(); int j = totalContexts.Count; for (int i = 0; i < j; ++i) { FloatingContext floatingContext = totalContexts[i]; int floatBoxCount = floatingContext.FloatBoxCount; if (floatBoxCount == 0) { continue; } CssBox floatingOwner = floatingContext.Owner; float rfx, rfy; floatingOwner.GetGlobalLocation(out rfx, out rfy); CssBox prevParent = null; //TODO: review here again float extraAdjustX = 0; //temp fixed for (int n = 0; n < floatBoxCount; ++n) { float bfx, bfy; CssBox box = floatingContext.GetBox(n); box.GetGlobalLocation(out bfx, out bfy); //diff float nx = bfx - rfx; float ny = bfy - rfy; if (prevParent != null && prevParent != box.ParentBox) { if (n > 0) { CssBox prevFloatChild = floatingContext.GetBox(n - 1); //TODO: review here again //temp fix extraAdjustX = prevFloatChild.ActualMarginRight + box.ActualMarginLeft; ny += box.ActualMarginTop; } } box.SetLocation(nx + extraAdjustX, ny); prevParent = box.ParentBox; floatingOwner.AppendToAbsoluteLayer(box); } } OnLayoutFinished(); //----------------------- unchecked { layoutVersion++; } //----------------------- }
void dbugAddToProperContainer(CssBox box) { var rectChild = new RectangleF(box.LocalX, box.LocalY, box.InnerContentWidth, box.InnerContentHeight); CssBox parent = box.ParentBox; bool found = false; while (parent != null) { var rectParent = new RectangleF(0, 0, parent.VisualWidth, parent.VisualHeight); if (rectParent.Contains(rectChild)) { found = true; //add to here float bfx, bfy; box.GetGlobalLocation(out bfx, out bfy); float rfx, rfy; parent.GetGlobalLocation(out rfx, out rfy); //diff float nx = bfx - rfx; float ny = bfy - rfy; box.SetLocation(nx, ny); parent.AppendToAbsoluteLayer(box); break; } else { rectChild.Offset(parent.LocalX, parent.LocalY); parent = parent.ParentBox; } } if (!found) { //add to root top float bfx, bfy; box.GetGlobalLocation(out bfx, out bfy); float rfx, rfy; this._rootBox.GetGlobalLocation(out rfx, out rfy); //diff float nx = bfx - rfx; float ny = bfy - rfy; box.SetLocation(nx, ny); this._rootBox.AppendToAbsoluteLayer(box); } }