/// <summary>Default constructor.</summary> /// <param name="UnderlyingGallery">The underlying gallery.</param> public GalleryPopupWindow (Gallery UnderlyingGallery) : base (WindowType.Popup) { this.underlyingGallery = UnderlyingGallery; this.tiles = new List<Tile> (); this.mapping = new Dictionary<Tile, Tile> (); foreach(Tile t in UnderlyingGallery.Tiles) { Tile copy = t.Copy (); tiles.Add (copy); if(t == UnderlyingGallery.SelectedTile) { copy.Selected = true; selectedTile = t; } mapping.Add (copy, t); } int width = UnderlyingGallery.Allocation.Width; columns = (uint)(width / underlyingGallery.TileWidth); rows = (uint)Math.Ceiling ((double)tiles.Count / columns); this.tileTable = new Table (rows, columns, true); this.tileTable.HeightRequest = (int)rows * UnderlyingGallery.TileHeight; this.tileTable.WidthRequest = (int)columns * UnderlyingGallery.TileWidth; Viewport vp = new Viewport (); vp.Child = tileTable; this.internalWindow = new ScrolledWindow (); this.internalWindow.Child = vp; this.internalWindow.HeightRequest = Math.Min (this.tileTable.HeightRequest, MAX_HEIGHT) + SCROLLBAR_SIZE; this.internalWindow.WidthRequest = this.tileTable.WidthRequest + SCROLLBAR_SIZE; uint x = 0, y = 0; foreach(Tile t in tiles) { ExtraEventBox box = new ExtraEventBox (); box.AddEvents ((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask)); box.Child = t; tileTable.Attach (box, x, x+1, y, y+1); t.Clicked += tile_Clicked; if(++x == columns) { x = 0; ++y; } } this.Child = internalWindow; }
private RibbonGroup CreateGroup2() { Gallery gallery = new Gallery (); gallery.AppendTile (new SampleTile ("1")); gallery.AppendTile (new SampleTile ("2")); gallery.AppendTile (new SampleTile ("3")); gallery.AppendTile (new SampleTile ("4")); gallery.AppendTile (new SampleTile ("5")); RibbonGroup group2 = new RibbonGroup (); group2.Label = "Gallery"; group2.Child = gallery; return group2; }
/// <summary>Draws a gallery.</summary> public void DrawGallery (Context cr, Rectangle bodyAllocation, Rectangle tilesAllocation, Gallery widget) { cr.Color = new Color (0, 0, 0, 0.3); cr.LineWidth = 1; cr.Rectangle (tilesAllocation.X - 0.5, tilesAllocation.Y - 0.5, tilesAllocation.Width + 1.0, tilesAllocation.Height + 1.0); cr.Stroke (); }