Beispiel #1
0
        int GetBarReduction(DockToolbar bar, int sizeToReduce, int currentReduction)
        {
            Gtk.Widget[] children  = bar.Children;
            int          w         = bar.DefaultSize;
            int          arrowSize = 0;

            bar.Forall(delegate(Gtk.Widget wa) {
                if (wa is ToggleButton)
                {
                    arrowSize = bar.Orientation == Orientation.Horizontal ? wa.SizeRequest().Width : wa.SizeRequest().Height;
                }
            });
            for (int n = children.Length - 1; n >= 1; n--)
            {
                if (!children [n].Visible)
                {
                    continue;
                }
                int x;
                if (bar.Orientation == Orientation.Horizontal)
                {
                    x = children [n].Allocation.X - bar.Allocation.X;
                }
                else
                {
                    x = children [n].Allocation.Y - bar.Allocation.Y;
                }
                int rightSize = w - x - 1;
                if (rightSize > currentReduction)
                {
                    int prevRequest = Orientation == Orientation.Horizontal ? children [n - 1].SizeRequest().Width : children [n - 1].SizeRequest().Height;
                    if (prevRequest > arrowSize * 2)
                    {
                        continue;
                    }
                    int newReduction = rightSize - currentReduction;
                    if (newReduction > sizeToReduce)
                    {
                        newReduction = sizeToReduce;
                    }

                    int minSize = Orientation == Orientation.Horizontal ? children[0].SizeRequest().Width : children[0].SizeRequest().Height;
                    minSize += arrowSize + 6;
                    if (bar.DefaultSize - (currentReduction + newReduction) < minSize)
                    {
                        newReduction = (bar.DefaultSize - minSize) - currentReduction;
                    }

                    return(newReduction);
                }
            }
            return(0);
        }
Beispiel #2
0
        int GetBarReduction(DockToolbar bar, int sizeToReduce, int currentReduction)
        {
            Gtk.Widget[] children = bar.Children;
            int w = bar.DefaultSize;
            int arrowSize = 0;
            bar.Forall (delegate (Gtk.Widget wa) {
                if (wa is ToggleButton) {
                    arrowSize = bar.Orientation == Orientation.Horizontal ? wa.SizeRequest ().Width : wa.SizeRequest ().Height;
                }
            });
            for (int n=children.Length - 1; n >= 1; n--) {
                if (!children [n].Visible)
                    continue;
                int x;
                if (bar.Orientation == Orientation.Horizontal)
                    x = children [n].Allocation.X - bar.Allocation.X;
                else
                    x = children [n].Allocation.Y - bar.Allocation.Y;
                int rightSize = w - x - 1;
                if (rightSize > currentReduction) {
                    int prevRequest = Orientation == Orientation.Horizontal ? children [n-1].SizeRequest ().Width : children [n-1].SizeRequest ().Height;
                    if (prevRequest > arrowSize*2)
                        continue;
                    int newReduction = rightSize - currentReduction;
                    if (newReduction > sizeToReduce)
                        newReduction = sizeToReduce;

                    int minSize = Orientation == Orientation.Horizontal ? children[0].SizeRequest ().Width : children[0].SizeRequest ().Height;
                    minSize += arrowSize + 6;
                    if (bar.DefaultSize - (currentReduction + newReduction) < minSize)
                        newReduction = (bar.DefaultSize - minSize) - currentReduction;

                    return newReduction;
                }
            }
            return 0;
        }