예제 #1
0
파일: DockFrame.cs 프로젝트: ywscr/Pinta
        /// <summary>
        /// Gets the style for a dock object, which will inherit values from all region/style definitions
        /// </summary>
        internal DockVisualStyle GetRegionStyleForObject(DockObject obj)
        {
            DockVisualStyle mergedStyle = null;

            if (obj is DockGroupItem)
            {
                DockVisualStyle s;
                if (stylesById.TryGetValue(((DockGroupItem)obj).Id, out s))
                {
                    mergedStyle = DefaultVisualStyle.Clone();
                    mergedStyle.CopyValuesFrom(s);
                }
            }
            foreach (var e in regionStyles)
            {
                if (InRegion(e.Item1, obj))
                {
                    if (mergedStyle == null)
                    {
                        mergedStyle = DefaultVisualStyle.Clone();
                    }
                    mergedStyle.CopyValuesFrom(e.Item2);
                }
            }
            return(mergedStyle ?? DefaultVisualStyle);
        }
예제 #2
0
        public DockObject Clone()
        {
            DockObject ob = (DockObject)this.MemberwiseClone();

            ob.CopyFrom(this);
            return(ob);
        }
예제 #3
0
파일: DockFrame.cs 프로젝트: ywscr/Pinta
 internal bool InRegion(string location, DockObject obj)
 {
     if (obj.ParentGroup == null)
     {
         return(false);
     }
     return(InRegion(location, obj.ParentGroup, obj.ParentGroup.GetObjectIndex(obj), false));
 }
예제 #4
0
 public virtual void CopySizeFrom(DockObject obj)
 {
     size           = obj.size;
     allocSize      = obj.allocSize;
     defaultHorSize = obj.defaultHorSize;
     defaultVerSize = obj.defaultVerSize;
     prefSize       = obj.prefSize;
 }
예제 #5
0
        public override void CopyFrom(DockObject ob)
        {
            base.CopyFrom(ob);
            DockGroupItem it = (DockGroupItem)ob;

            item        = it.item;
            visibleFlag = it.visibleFlag;
            floatRect   = it.floatRect;
        }
예제 #6
0
            protected override bool OnButtonPressEvent(Gdk.EventButton ev)
            {
                dragging = true;
                dragPos  = (dockGroup.Type == DockGroupType.Horizontal) ? (int)ev.XRoot : (int)ev.YRoot;
                DockObject obj = dockGroup.VisibleObjects [dockIndex];

                dragSize = (dockGroup.Type == DockGroupType.Horizontal) ? obj.Allocation.Width : obj.Allocation.Height;
                return(base.OnButtonPressEvent(ev));
            }
예제 #7
0
 public virtual void CopyFrom(DockObject ob)
 {
     parentGroup    = null;
     frame          = ob.frame;
     rect           = ob.rect;
     size           = ob.size;
     allocSize      = ob.allocSize;
     defaultHorSize = ob.defaultHorSize;
     defaultVerSize = ob.defaultVerSize;
     prefSize       = ob.prefSize;
 }
예제 #8
0
 bool EstimateBarDocPosition(DockGroup grp, DockObject ignoreChild, out PositionType pos, out int size)
 {
     foreach (DockObject ob in grp.Objects)
     {
         if (ob == ignoreChild)
         {
             continue;
         }
         if (ob is DockGroup)
         {
             if (EstimateBarDocPosition((DockGroup)ob, null, out pos, out size))
             {
                 return(true);
             }
         }
         else if (ob is DockGroupItem)
         {
             DockGroupItem it = (DockGroupItem)ob;
             if (it.status == DockItemStatus.AutoHide)
             {
                 pos  = it.barDocPosition;
                 size = it.autoHideSize;
                 return(true);
             }
             if (!it.Allocation.IsEmpty)
             {
                 pos  = it.CalcBarDocPosition();
                 size = it.GetAutoHideSize(pos);
                 return(true);
             }
         }
     }
     pos  = PositionType.Bottom;
     size = 0;
     return(false);
 }
예제 #9
0
        void SetBarDocPosition()
        {
            // Determine the best position for docking the item

            if (Allocation.IsEmpty)
            {
                int uniqueTrue  = -1;
                int uniqueFalse = -1;
                for (int n = 0; n < 4; n++)
                {
                    bool inMargin = IsNextToMargin((PositionType)n, false);
                    if (inMargin)
                    {
                        if (uniqueTrue == -1)
                        {
                            uniqueTrue = n;
                        }
                        else
                        {
                            uniqueTrue = -2;
                        }
                    }
                    else
                    {
                        if (uniqueFalse == -1)
                        {
                            uniqueFalse = n;
                        }
                        else
                        {
                            uniqueFalse = -2;
                        }
                    }
                }

                if (uniqueTrue >= 0)
                {
                    barDocPosition = (PositionType)uniqueTrue;
                    autoHideSize   = 200;
                    return;
                }
                else if (uniqueFalse >= 0)
                {
                    barDocPosition = (PositionType)uniqueFalse;
                    switch (barDocPosition)
                    {
                    case PositionType.Left: barDocPosition = PositionType.Right; break;

                    case PositionType.Right: barDocPosition = PositionType.Left; break;

                    case PositionType.Top: barDocPosition = PositionType.Bottom; break;

                    case PositionType.Bottom: barDocPosition = PositionType.Top; break;
                    }
                    autoHideSize = 200;
                    return;
                }

                // If the item is in a group, use the dock location of other items
                DockObject current = this;
                do
                {
                    if (EstimateBarDocPosition(current.ParentGroup, current, out barDocPosition, out autoHideSize))
                    {
                        return;
                    }
                    current = current.ParentGroup;
                } while (current.ParentGroup != null);

                // Can't find a good location. Just guess.
                barDocPosition = PositionType.Bottom;
                autoHideSize   = 200;
                return;
            }
            barDocPosition = CalcBarDocPosition();
        }
예제 #10
0
파일: DockGroup.cs 프로젝트: msiyer/Pinta
		internal void UpdateVisible (DockObject child)
		{
			visibleObjects = null;
			bool visChanged;
			MarkForRelayout ();
			
			visChanged = child.Visible ? VisibleObjects.Count == 1 : VisibleObjects.Count == 0;
			
			if (visChanged && ParentGroup != null)
				ParentGroup.UpdateVisible (this);
		}
예제 #11
0
파일: DockGroup.cs 프로젝트: msiyer/Pinta
		public bool IsChildNextToMargin (Gtk.PositionType margin, DockObject obj, bool visibleOnly)
		{
			if (type == DockGroupType.Tabbed)
				return true;
			else if (type == DockGroupType.Horizontal) {
				if (margin == PositionType.Top || margin == PositionType.Bottom)
					return true;
				int i = visibleOnly ? VisibleObjects.IndexOf (obj) : Objects.IndexOf (obj);
				if (margin == PositionType.Left && i == 0)
					return true;
				if (margin == PositionType.Right && i == (visibleOnly ? VisibleObjects.Count - 1 : Objects.Count - 1))
					return true;
			}
			else if (type == DockGroupType.Vertical) {
				if (margin == PositionType.Left || margin == PositionType.Right)
					return true;
				int i = visibleOnly ? VisibleObjects.IndexOf (obj) : Objects.IndexOf (obj);
				if (margin == PositionType.Top && i == 0)
					return true;
				if (margin == PositionType.Bottom && i == (visibleOnly ? VisibleObjects.Count - 1 : Objects.Count - 1))
					return true;
			}
			return false;
		}
예제 #12
0
		bool EstimateBarDocPosition (DockGroup grp, DockObject ignoreChild, out PositionType pos, out int size)
		{
			foreach (DockObject ob in grp.Objects) {
				if (ob == ignoreChild)
					continue;
				if (ob is DockGroup) {
					if (EstimateBarDocPosition ((DockGroup)ob, null, out pos, out size))
						return true;
				} else if (ob is DockGroupItem) {
					DockGroupItem it = (DockGroupItem) ob;
					if (it.status == DockItemStatus.AutoHide) {
						pos = it.barDocPosition;
						size = it.autoHideSize;
						return true;
					}
					if (!it.Allocation.IsEmpty) {
						pos = it.CalcBarDocPosition ();
						size = it.GetAutoHideSize (pos);
						return true;
					}
				}
			}
			pos = PositionType.Bottom;
			size = 0;
			return false;
		}
예제 #13
0
파일: DockObject.cs 프로젝트: msiyer/Pinta
		public virtual void CopySizeFrom (DockObject obj)
		{
			size = obj.size;
			allocSize = obj.allocSize;
			defaultHorSize = obj.defaultHorSize;
			defaultVerSize = obj.defaultVerSize;
			prefSize = obj.prefSize;
		}
예제 #14
0
파일: DockFrame.cs 프로젝트: ywscr/Pinta
 internal void UpdateRegionStyle(DockObject obj)
 {
     obj.VisualStyle = GetRegionStyleForObject(obj);
 }
예제 #15
0
파일: DockFrame.cs 프로젝트: msiyer/Pinta
		bool ObjectHasAncestor (DockObject obj, DockGroup ancestorToFind)
		{
			return obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor (obj.ParentGroup, ancestorToFind));
		}
예제 #16
0
파일: DockFrame.cs 프로젝트: msiyer/Pinta
		bool InRegion (DockGroup grp, DockPosition pos, DockObject refObject, DockGroup objToFindParent, int objToFindIndex, bool insertingPosition)
		{
			if (grp == null)
				return false;

			if (grp.Type == DockGroupType.Tabbed) {
				if (pos != DockPosition.Center &&  pos != DockPosition.CenterBefore)
					return InRegion (grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition);
			}
			if (grp.Type == DockGroupType.Horizontal) {
				if (pos != DockPosition.Left && pos != DockPosition.Right)
					return InRegion (grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition);
			}
			if (grp.Type == DockGroupType.Vertical) {
				if (pos != DockPosition.Top && pos != DockPosition.Bottom)
					return InRegion (grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition);
			}

			bool foundAtLeftSide = true;
			bool findingLeft = pos == DockPosition.Left || pos == DockPosition.Top || pos == DockPosition.CenterBefore;

			if (objToFindParent == grp) {
				// Check positions beyond the current range of items
				if (objToFindIndex < 0 && findingLeft)
					return true;
				if (objToFindIndex >= grp.Objects.Count && !findingLeft)
					return true;
			}

			for (int n=0; n<grp.Objects.Count; n++) {
				var ob = grp.Objects[n];

				bool foundRefObject = ob == refObject;
				bool foundTargetObject = objToFindParent == grp && objToFindIndex == n;

				if (foundRefObject) {
					// Found the reference object, but if insertingPosition=true it is in the position that the new item will have,
					// so this position still has to be considered to be at the left side
					if (foundTargetObject && insertingPosition)
						return foundAtLeftSide == findingLeft;
					foundAtLeftSide = false;
				}
				else if (foundTargetObject)
					return foundAtLeftSide == findingLeft;
				else if (ob is DockGroup) {
					DockGroup gob = (DockGroup)ob;
					if (gob == objToFindParent || ObjectHasAncestor (objToFindParent, gob))
						return foundAtLeftSide == findingLeft;
				}
			}
			return InRegion (grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition);
		}
예제 #17
0
파일: DockFrame.cs 프로젝트: msiyer/Pinta
		internal bool InRegion (string location, DockObject obj)
		{
			if (obj.ParentGroup == null)
				return false;
			return InRegion (location, obj.ParentGroup, obj.ParentGroup.GetObjectIndex (obj), false);
		}
예제 #18
0
파일: DockFrame.cs 프로젝트: msiyer/Pinta
		/// <summary>
		/// Gets the style for a dock object, which will inherit values from all region/style definitions
		/// </summary>
		internal DockVisualStyle GetRegionStyleForObject (DockObject obj)
		{
			DockVisualStyle mergedStyle = null;
			if (obj is DockGroupItem) {
				DockVisualStyle s;
				if (stylesById.TryGetValue (((DockGroupItem)obj).Id, out s)) {
					mergedStyle = DefaultVisualStyle.Clone ();
					mergedStyle.CopyValuesFrom (s);
				}
			}
			foreach (var e in regionStyles) {
				if (InRegion (e.Item1, obj)) {
					if (mergedStyle == null)
						mergedStyle = DefaultVisualStyle.Clone ();
					mergedStyle.CopyValuesFrom (e.Item2);
				}
			}
			return mergedStyle ?? DefaultVisualStyle;
		}
예제 #19
0
파일: DockFrame.cs 프로젝트: msiyer/Pinta
		internal void UpdateRegionStyle (DockObject obj)
		{
			obj.VisualStyle = GetRegionStyleForObject (obj);
		}
예제 #20
0
파일: DockGroup.cs 프로젝트: msiyer/Pinta
		public void AddObject (DockObject obj)
		{
			obj.ParentGroup = this;
			dockObjects.Add (obj);
			ResetVisibleGroups ();
		}
예제 #21
0
파일: DockObject.cs 프로젝트: msiyer/Pinta
		public virtual void CopyFrom (DockObject ob)
		{
			parentGroup = null;
			frame = ob.frame;
			rect = ob.rect;
			size = ob.size;
			allocSize = ob.allocSize;
			defaultHorSize = ob.defaultHorSize;
			defaultVerSize = ob.defaultVerSize;
			prefSize = ob.prefSize;
		}
예제 #22
0
파일: DockGroup.cs 프로젝트: msiyer/Pinta
		public int GetObjectIndex (DockObject obj)
		{
			for (int n=0; n<dockObjects.Count; n++) {
				if (dockObjects [n] == obj)
					return n;
			}
			return -1;
		}
예제 #23
0
		public override void CopyFrom (DockObject ob)
		{
			base.CopyFrom (ob);
			DockGroupItem it = (DockGroupItem)ob;
			item = it.item;
			visibleFlag = it.visibleFlag;
			floatRect = it.floatRect;
		}
예제 #24
0
파일: DockGroup.cs 프로젝트: msiyer/Pinta
		public override void CopyFrom (DockObject other)
		{
			base.CopyFrom (other);
			DockGroup grp = (DockGroup) other;
			dockObjects = new List<DockObject> ();
			foreach (DockObject ob in grp.dockObjects) {
				DockObject cob = ob.Clone ();
				cob.ParentGroup = this;
				dockObjects.Add (cob);
			}
			type = grp.type;
			ResetVisibleGroups ();
			boundTabStrip = null;
			tabFocus = null;
		}
예제 #25
0
파일: DockFrame.cs 프로젝트: ywscr/Pinta
        bool InRegion(DockGroup grp, DockPosition pos, DockObject refObject, DockGroup objToFindParent, int objToFindIndex, bool insertingPosition)
        {
            if (grp == null)
            {
                return(false);
            }

            if (grp.Type == DockGroupType.Tabbed)
            {
                if (pos != DockPosition.Center && pos != DockPosition.CenterBefore)
                {
                    return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition));
                }
            }
            if (grp.Type == DockGroupType.Horizontal)
            {
                if (pos != DockPosition.Left && pos != DockPosition.Right)
                {
                    return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition));
                }
            }
            if (grp.Type == DockGroupType.Vertical)
            {
                if (pos != DockPosition.Top && pos != DockPosition.Bottom)
                {
                    return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition));
                }
            }

            bool foundAtLeftSide = true;
            bool findingLeft     = pos == DockPosition.Left || pos == DockPosition.Top || pos == DockPosition.CenterBefore;

            if (objToFindParent == grp)
            {
                // Check positions beyond the current range of items
                if (objToFindIndex < 0 && findingLeft)
                {
                    return(true);
                }
                if (objToFindIndex >= grp.Objects.Count && !findingLeft)
                {
                    return(true);
                }
            }

            for (int n = 0; n < grp.Objects.Count; n++)
            {
                var ob = grp.Objects[n];

                bool foundRefObject    = ob == refObject;
                bool foundTargetObject = objToFindParent == grp && objToFindIndex == n;

                if (foundRefObject)
                {
                    // Found the reference object, but if insertingPosition=true it is in the position that the new item will have,
                    // so this position still has to be considered to be at the left side
                    if (foundTargetObject && insertingPosition)
                    {
                        return(foundAtLeftSide == findingLeft);
                    }
                    foundAtLeftSide = false;
                }
                else if (foundTargetObject)
                {
                    return(foundAtLeftSide == findingLeft);
                }
                else if (ob is DockGroup)
                {
                    DockGroup gob = (DockGroup)ob;
                    if (gob == objToFindParent || ObjectHasAncestor(objToFindParent, gob))
                    {
                        return(foundAtLeftSide == findingLeft);
                    }
                }
            }
            return(InRegion(grp.ParentGroup, pos, grp, objToFindParent, objToFindIndex, insertingPosition));
        }
예제 #26
0
파일: DockFrame.cs 프로젝트: ywscr/Pinta
 bool ObjectHasAncestor(DockObject obj, DockGroup ancestorToFind)
 {
     return(obj != null && (obj.ParentGroup == ancestorToFind || ObjectHasAncestor(obj.ParentGroup, ancestorToFind)));
 }
예제 #27
0
파일: DockGroup.cs 프로젝트: msiyer/Pinta
		public void ReplaceItem (DockObject ob1, DockObject ob2)
		{
			int i = dockObjects.IndexOf (ob1);
			dockObjects [i] = ob2;
			ob2.ParentGroup = this;
			ob2.ResetDefaultSize ();
			ob2.Size = ob1.Size;
			ob2.DefaultSize = ob1.DefaultSize;
			ob2.AllocSize = ob1.AllocSize;
			ResetVisibleGroups ();
		}
예제 #28
0
파일: DockGroup.cs 프로젝트: msiyer/Pinta
		public void Remove (DockObject obj)
		{
			dockObjects.Remove (obj);
			Reduce ();
			obj.ParentGroup = null;
			visibleObjects = null;
			
			if (VisibleObjects.Count > 0) {
				CalcNewSizes ();
				MarkForRelayout ();
			} else
				ParentGroup.UpdateVisible (this);
		}