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); } }
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); } }
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; }
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(); }
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(); }