/// <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;
		}
Beispiel #2
0
 /// <summary>Fires the SelectedTile event.</summary>
 /// <param name="SelectedTile">The Tile that has been selected.</param>
 protected void OnTileSelected(Tile SelectedTile)
 {
     if(TileSelected != null) TileSelected (this, new TileSelectedEventArgs (SelectedTile));
 }
Beispiel #3
0
 /// <summary>Adds a tile before all existing tiles.</summary>
 /// <param name="t">The tile to add.</param>
 public void PrependTile(Tile t)
 {
     InsertTile (t, 0);
 }
Beispiel #4
0
        /// <summary>Inserts a tile at the specified location.</summary>
        /// <param name="t">The tile to add.</param>
        /// <param name="TileIndex">The index (starting at 0) at which the tile must be inserted, or -1 to insert the tile after all existing tiles.</param>
        public void InsertTile(Tile t, int TileIndex)
        {
            if(TileIndex == -1 || TileIndex == tiles.Count)
            {
                tiles.Add (t);
            }
            else
            {
                tiles.Insert (TileIndex, t);
            }

            if (tiles.Count == 1)
                SelectedTile = t;

            //t.Parent = this;
            t.Visible = true;
            t.Clicked += Tile_Clicked;
        }
Beispiel #5
0
 /// <summary>Adds a tile after all existing tiles.</summary>
 /// <param name="t">The tile to add.</param>
 public void AppendTile(Tile t)
 {
     InsertTile (t, -1);
 }
		private void tile_Clicked (object Sender, EventArgs e)
		{
			if(selectedTile != null) selectedTile.Selected = false;
			selectedTile = (Tile)Sender;
			selectedTile.Selected = true;
			
			underlyingGallery.SelectedTile = mapping[selectedTile];
			
			Hide ();
		}
		public TileSelectedEventArgs (Tile SelectedTile)
		{
			selTile = SelectedTile;
		}
Beispiel #8
0
		/// <summary>Draws a tile.</summary>
		public void DrawTile (Context cr, Rectangle bodyAllocation, Rectangle contentAllocation, Tile widget)
		{
			if(widget.Selected)
			{
				LinearGradient grad = new LinearGradient (bodyAllocation.X, bodyAllocation.Y, bodyAllocation.X, bodyAllocation.Y + bodyAllocation.Height);
				grad.AddColorStop (0.00, new Color (0.9922, 0.7373, 0.4353));
				grad.AddColorStop (0.27, new Color (0.9961, 0.8039, 0.5569));
				grad.AddColorStop (0.33, new Color (0.9961, 0.7255, 0.4078));
				grad.AddColorStop (1.00, new Color (0.9843, 0.8980, 0.6313));
				cr.Rectangle (bodyAllocation);
				cr.Pattern = grad;
				cr.Fill ();
			}
			
			cr.Color = new Color (1, 1, 1);
			cr.Rectangle (contentAllocation);
			cr.Fill ();
		}
Beispiel #9
0
		private void Tile_Clicked(object Sender, EventArgs e)
		{
			if(selectedTile != null) selectedTile.Selected = false;
			selectedTile = (Tile)Sender;
			selectedTile.Selected = true;
			OnTileSelected (selectedTile);
		}
Beispiel #10
0
		/// <summary>Removes the tile at the specified index.</summary>
		/// <param name="TileIndex">Index of the tile to remove.</param>
		public void RemoveTile (int TileIndex)
		{
			Tile t = tiles[TileIndex];
			t.Clicked -= Tile_Clicked;
			t.Unparent ();
			if(selectedTile == t) selectedTile = null;
			
			tiles.RemoveAt (TileIndex);
		}