private void CreateListElement(ISpray spray) { spray.OrderChanged += Spray_OrderChanged; GameObject go = Instantiate(listElementPrefab); go.name = "Photo Id " + spray.Id; go.SetActive(false); LibraryListElement elem = go.GetComponent <LibraryListElement>(); elem.spray = spray; elem.libraryController = this; // use the ScrollRect as the vertical drag handler LockedDragHandler lockedDragHandler = elem.GetComponent <LockedDragHandler>(); lockedDragHandler.verticalEventReceiver = scrollRect.GetComponent <LockedDragForwarder>(); int x = PhotoIO.GetThumbnailX(spray.Id); int y = PhotoIO.GetThumbnailY(spray.Id); // we need to deal with the half texel offset, but this creates a 1 pixel discontinuity, since the atan2 edge should overlap Vector4 texParams = new Vector4(x * PhotoIO.ThumbnailSizeX + PhotoIO.HalfPixel, y * PhotoIO.ThumbnailSizeY + PhotoIO.HalfPixel, PhotoIO.PanoScalingX * PhotoIO.ThumbnailSizeX, PhotoIO.PanoScalingY * PhotoIO.ThumbnailSizeY); // set the spray texture elem.sprayCanvas.material = Instantiate(elem.sprayCanvas.material); // clone material for unique _TexParams elem.sprayCanvas.material.SetVector("_TexParams", texParams); elem.sprayCanvas.texture = PhotoIO.thumbnails; // set the label text elem.labelText.text = spray.Label; // anchor the list element to the content rect elem.scrollTransform.SetParent(contentRoot); elem.scrollTransform.offsetMin = new Vector2(0, elem.scrollTransform.offsetMin.y); elem.scrollTransform.offsetMax = new Vector2(0, elem.scrollTransform.offsetMax.y); elem.scrollTransform.anchoredPosition = new Vector2(0, 0); elem.scrollTransform.localScale = Vector3.one; elem.DrawerPeeked += LibraryListElement_DrawerPeeked; elem.DrawerOpened += LibraryListElement_DrawerOpened; elementLookup[spray.Id] = elem; }
private void LibraryListElement_DrawerPeeked(LibraryListElement elem) { scrollRect.StopMovement(); for (int i = 0; i < contentRoot.childCount; i++) { var childTransform = contentRoot.GetChild(i); if (childTransform == elem.transform) { continue; } else if (childTransform.gameObject.activeSelf) { // TODO looped component access could be sped up by keeping list elements in a List object var childListElement = childTransform.GetComponent <LibraryListElement>(); childListElement.CloseDrawers(); } } }
public void ShareElement(LibraryListElement element) { viewManager.ShowShareChoice(element.spray); }
public void DeleteElement(LibraryListElement element) { sprayCam.DeleteSpray(element.spray); }
public void ClickElement(LibraryListElement element) { // TODO: make sure wip is saved before loading the new image... sprayCam.PreviewSpray(element.spray); viewManager.ShowPreview(); }
private void LibraryListElement_DrawerOpened(LibraryListElement elem) { }