Пример #1
0
        public void ScrollToMakeVisible(RectangleD rect)
        {
            RectangleD visible = VisibleArea;

            if (visible.Contains(rect))
            {
                return;
            }

            Hadjustment.Lower = Math.Min(Hadjustment.Lower, rect.X);
            Hadjustment.Upper = Math.Max(Hadjustment.Upper, rect.X2);
            Hadjustment.Change();

            Vadjustment.Lower = Math.Min(Vadjustment.Lower, rect.Y);
            Vadjustment.Upper = Math.Max(Vadjustment.Upper, rect.Y2);
            Vadjustment.Change();

            if (rect.X < visible.X)
            {
                Hadjustment.Value = Math.Round(rect.X, 0);
            }
            if (rect.X2 > visible.X2)
            {
                Hadjustment.Value = Math.Round(rect.X2 - visible.Width, 0);
            }

            if (rect.Y < visible.Y)
            {
                Vadjustment.Value = Math.Round(rect.Y, 0);
            }
            if (rect.Y2 > visible.Y2)
            {
                Vadjustment.Value = Math.Round(rect.Y2 - visible.Height, 0);
            }
        }
Пример #2
0
        public void ScrollToMakeVisible(PointD point)
        {
            RectangleD visible = VisibleArea;

            if (visible.Contains(point.X, point.Y))
            {
                return;
            }

            Hadjustment.Lower = Math.Min(Hadjustment.Lower, point.X);
            Hadjustment.Upper = Math.Max(Hadjustment.Upper, point.X);
            Hadjustment.Change();

            Vadjustment.Lower = Math.Min(Vadjustment.Lower, point.Y);
            Vadjustment.Upper = Math.Max(Vadjustment.Upper, point.Y);
            Vadjustment.Change();

            if (point.X < visible.X)
            {
                Hadjustment.Value = Math.Round(point.X, 0);
            }
            else if (point.X > visible.X2)
            {
                Hadjustment.Value = Math.Round(point.X - visible.Width, 0);
            }

            if (point.Y < visible.Y)
            {
                Vadjustment.Value = Math.Round(point.Y, 0);
            }
            else if (point.Y > visible.Y2)
            {
                Vadjustment.Value = Math.Round(point.Y - visible.Height, 0);
            }
        }
Пример #3
0
        public void ScrollCanvas(int dx, int dy)
        {
            double hadjustment = Hadjustment.Value + dx;
            double vadjustment = Vadjustment.Value + dy;

            Hadjustment.Lower = Math.Min(Hadjustment.Lower, hadjustment);
            Hadjustment.Upper = Math.Max(Hadjustment.Upper, hadjustment);
            Hadjustment.Change();

            Vadjustment.Lower = Math.Min(Vadjustment.Lower, vadjustment);
            Vadjustment.Upper = Math.Max(Vadjustment.Upper, vadjustment);
            Vadjustment.Change();

            Hadjustment.Value = hadjustment;
            Vadjustment.Value = vadjustment;
        }
Пример #4
0
        protected override void UpdateLayout()
        {
            System.Console.WriteLine("in update layout {0}", Allocation.ToString());

            int num_thumbnails;

            if (collection != null)
            {
                num_thumbnails = collection.Count;
            }
            else
            {
                num_thumbnails = 0;
            }

            cells_per_row = System.Math.Max(num_thumbnails, 1);

            int num_rows = 1;
            int num_cols = num_thumbnails;

            int available_height = Allocation.Height - 2 * BORDER_SIZE;

            if (DisplayTags)
            {
                available_height -= tag_icon_size + tag_icon_vspacing;
            }

            if (DisplayDates && this.Style != null)
            {
                Pango.FontMetrics metrics = this.PangoContext.GetMetrics(this.Style.FontDescription,
                                                                         Pango.Language.FromString("en_US"));
                available_height -= PangoPixels(metrics.Ascent + metrics.Descent);
            }

            thumbnail_width = (int)(available_height / thumbnail_ratio);

            cell_width  = ThumbnailWidth + 2 * cell_border_width;
            cell_height = ThumbnailHeight + 2 * cell_border_width;

            SetSize(System.Math.Max(((uint)(num_cols * cell_width + 2 * BORDER_SIZE)), (uint)Allocation.Width), (uint)(num_rows * cell_height + 2 * BORDER_SIZE));

            Vadjustment.StepIncrement = cell_height;
            Vadjustment.Change();

            Hadjustment.StepIncrement = cell_width;
            Hadjustment.Change();
        }
Пример #5
0
        protected override void OnMouseScrolled(MouseScrolledEventArgs args)
        {
            var alloc = Bounds;

            if ((args.Direction == ScrollDirection.Left ||
                 args.Direction == ScrollDirection.Right) &&
                hScrollBar.Visible)
            {
                Hadjustment.AddValueClamped(args.Direction == ScrollDirection.Right ? 10 : -10);
            }

            if ((args.Direction == ScrollDirection.Up ||
                 args.Direction == ScrollDirection.Down) && vScrollBar.Visible)
            {
                Vadjustment.AddValueClamped(args.Direction == ScrollDirection.Down ? 10 : -10);
            }

            base.OnMouseScrolled(args);
        }
Пример #6
0
        private void SetSize(int x, int y, int width, int height)
        {
            Hadjustment.Upper = Math.Max(Allocation.Width, width);
            Vadjustment.Upper = Math.Max(Allocation.Height, height);

            bool xchange = scroll && (int)(Hadjustment.Value) != x;
            bool ychange = scroll && (int)(Vadjustment.Value) != y;

            // reset scroll
            scroll = false;

            if (IsRealized)
            {
                BinWindow.FreezeUpdates();
            }

            if (xchange || ychange)
            {
                if (IsRealized)
                {
                    BinWindow.MoveResize(-x, -y, (int)(Hadjustment.Upper), (int)(Vadjustment.Upper));
                }
                Vadjustment.Value = y;
                Hadjustment.Value = x;
            }

            if (this.Width != Allocation.Width || this.Height != Allocation.Height)
            {
                SetSize((uint)Allocation.Width, (uint)height);
            }

            if (xchange || ychange)
            {
                Vadjustment.ChangeValue();
                Hadjustment.ChangeValue();
            }

            if (IsRealized)
            {
                BinWindow.ThawUpdates();
                BinWindow.ProcessUpdates(true);
            }
        }
Пример #7
0
        private void UpdateAdjustments()
        {
            RectangleD drawing_box = Drawing.DisplayBox;

            drawing_box.Add(VisibleArea);

            Hadjustment.PageSize      = Allocation.Width;
            Hadjustment.PageIncrement = Allocation.Width * 0.9;
            Hadjustment.StepIncrement = 1.0;
            Hadjustment.Lower         = drawing_box.X;
            Hadjustment.Upper         = drawing_box.X2;
            Hadjustment.Change();

            Vadjustment.PageSize      = Allocation.Height;
            Vadjustment.PageIncrement = Allocation.Height * 0.9;
            Vadjustment.StepIncrement = 1.0;
            Vadjustment.Lower         = drawing_box.Y;
            Vadjustment.Upper         = drawing_box.Y2;
            Vadjustment.Change();
        }