public void RegisterForGraphicUpdate () { IsDirty = true; if (Width.IsFit || Height.IsFit) RegisterForLayouting (LayoutingType.Sizing); else if (RegisteredLayoutings == LayoutingType.None) CurrentInterface.EnqueueForRepaint (this); }
public override bool UpdateLayout(LayoutingType layoutType) { RegisteredLayoutings &= (~layoutType); if (layoutType == LayoutingType.ArrangeChildren) { int curOffset = Spacing; for (int i = 0; i < Children.Count; i++) { if (!Children [i].Visible) { continue; } TabItem ti = Children [i] as TabItem; ti.TabOffset = curOffset; if (Orientation == Orientation.Horizontal) { if (ti.TabTitle.RegisteredLayoutings.HasFlag(LayoutingType.Width)) { return(false); } curOffset += ti.TabTitle.Slot.Width + Spacing; } else { if (ti.TabTitle.RegisteredLayoutings.HasFlag(LayoutingType.Height)) { return(false); } curOffset += ti.TabTitle.Slot.Height + Spacing; } } //if no layouting remains in queue for item, registre for redraw if (RegisteredLayoutings == LayoutingType.None && IsDirty) { CurrentInterface.EnqueueForRepaint(this); } return(true); } return(base.UpdateLayout(layoutType)); }
public override bool UpdateLayout(LayoutingType layoutType) { RegisteredLayoutings &= (~layoutType); if (layoutType == LayoutingType.ArrangeChildren) { ComputeChildrenPositions(); //if no layouting remains in queue for item, registre for redraw if (RegisteredLayoutings == LayoutingType.None && bmp == null) { CurrentInterface.EnqueueForRepaint(this); } return(true); } return(base.UpdateLayout(layoutType)); }
public override bool UpdateLayout(LayoutingType layoutType) { RegisteredLayoutings &= (~layoutType); if (layoutType == LayoutingType.ArrangeChildren) { //allow 1 child to have size to 0 if stack has fixed or streched size policy, //this child will occupy remaining space //if stack size policy is Fit, no child may have stretch enabled //in the direction of stacking. ComputeChildrenPositions(); //if no layouting remains in queue for item, registre for redraw if (RegisteredLayoutings == LayoutingType.None && bmp == null) { CurrentInterface.EnqueueForRepaint(this); } return(true); } return(base.UpdateLayout(layoutType)); }
/// <summary> Update layout component only one at a time, this is where the computation of alignement /// and size take place. /// The redrawing will only be triggered if final slot size has changed </summary> /// <returns><c>true</c>, if layouting was possible, <c>false</c> if conditions were not /// met and LQI has to be re-queued</returns> public virtual bool UpdateLayout (LayoutingType layoutType) { //unset bit, it would be reset if LQI is re-queued registeredLayoutings &= (~layoutType); switch (layoutType) { case LayoutingType.X: if (Left == 0) { if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) || RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; switch (HorizontalAlignment) { case HorizontalAlignment.Left: Slot.X = 0; break; case HorizontalAlignment.Right: Slot.X = Parent.ClientRectangle.Width - Slot.Width; break; case HorizontalAlignment.Center: Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2; break; } } else Slot.X = Left; if (LastSlots.X == Slot.X) break; IsDirty = true; OnLayoutChanges (layoutType); LastSlots.X = Slot.X; break; case LayoutingType.Y: if (Top == 0) { if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) || RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; switch (VerticalAlignment) { case VerticalAlignment.Top://this could be processed even if parent Height is not known Slot.Y = 0; break; case VerticalAlignment.Bottom: Slot.Y = Parent.ClientRectangle.Height - Slot.Height; break; case VerticalAlignment.Center: Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2; break; } } else Slot.Y = Top; if (LastSlots.Y == Slot.Y) break; IsDirty = true; OnLayoutChanges (layoutType); LastSlots.Y = Slot.Y; break; case LayoutingType.Width: if (Visible) { if (Width.IsFixed) Slot.Width = Width; else if (Width == Measure.Fit) { Slot.Width = measureRawSize (LayoutingType.Width); } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width)) return false; else if (Width == Measure.Stretched) Slot.Width = Parent.ClientRectangle.Width; else Slot.Width = (int)Math.Round ((double)(Parent.ClientRectangle.Width * Width) / 100.0); if (Slot.Width < 0) return false; //size constrain if (Slot.Width < MinimumSize.Width) { Slot.Width = MinimumSize.Width; //NotifyValueChanged ("WidthPolicy", Measure.Stretched); } else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0) { Slot.Width = MaximumSize.Width; //NotifyValueChanged ("WidthPolicy", Measure.Stretched); } } else Slot.Width = 0; if (LastSlots.Width == Slot.Width) break; IsDirty = true; OnLayoutChanges (layoutType); LastSlots.Width = Slot.Width; break; case LayoutingType.Height: if (Visible) { if (Height.IsFixed) Slot.Height = Height; else if (Height == Measure.Fit) { Slot.Height = measureRawSize (LayoutingType.Height); } else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height)) return false; else if (Height == Measure.Stretched) Slot.Height = Parent.ClientRectangle.Height; else Slot.Height = (int)Math.Round ((double)(Parent.ClientRectangle.Height * Height) / 100.0); if (Slot.Height < 0) return false; //size constrain if (Slot.Height < MinimumSize.Height) { Slot.Height = MinimumSize.Height; //NotifyValueChanged ("HeightPolicy", Measure.Stretched); } else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0) { Slot.Height = MaximumSize.Height; //NotifyValueChanged ("HeightPolicy", Measure.Stretched); } } else Slot.Height = 0; if (LastSlots.Height == Slot.Height) break; IsDirty = true; OnLayoutChanges (layoutType); LastSlots.Height = Slot.Height; break; } //if no layouting remains in queue for item, registre for redraw if (this.registeredLayoutings == LayoutingType.None && IsDirty) CurrentInterface.EnqueueForRepaint (this); return true; }
public void RegisterForRedraw () { IsDirty = true; if (RegisteredLayoutings == LayoutingType.None) CurrentInterface.EnqueueForRepaint (this); }