示例#1
0
        public RiderFlowSceneToolbarRoot()
        {
            SetRootStyleProperties();
            var startupLabel = new Label("Initializing...");

            Add(startupLabel);
            ContainerReadyRequirement.Instance.IsReady.WhenTrue(myDefinition.Lifetime, (b) =>
            {
                Remove(startupLabel);
                myRiderFlowToolbarElements = new List <VisualElement>()
                {
                    ComponentContainer.GetComponent <SceneSearchPopupTool>().MakeVisualElement(myDefinition.Lifetime),
                    ComponentContainer.GetComponent <CameraPresetCreationTool>().MakeVisualElement(),
                    ComponentContainer.GetComponent <CameraPresetExplorerTool>().MakeVisualElement(),
                    ComponentContainer.GetComponent <BookmarkExplorerTool>().MakeVisualElement(),
                };
                foreach (var toolbarElement in myRiderFlowToolbarElements)
                {
                    Add(toolbarElement);
                }
                RegisterCallback <GeometryChangedEvent>(OnGeometryChanged);
                myParentSet.Advise(myDefinition.Lifetime, SetUpChildElements);
                mySceneOccurrenceExplorerTool = ComponentContainer.GetComponent <SceneOccurrenceExplorerTool>();
                mySceneOccurrenceExplorerTool.Session.Advise(myDefinition.Lifetime, session =>
                {
                    if (!myShowingFindUsages)
                    {
                        AddFindUsages();
                    }
                });

                RegisterCallback <DetachFromPanelEvent>(OnDestroy);
            });
        }
示例#2
0
        public ShowUsagesExplorerButton(Lifetime lifetime, SceneOccurrenceExplorerTool tool, bool isHorizontal)
        {
            myTool  = tool;
            text    = isHorizontal ?  "Waiting for usages..." : "";
            tooltip = "Explore usages";

            SetOnClick(() =>
            {
                var windowPosition = this.CalculateDropdownPosition();
                tool.ShowOccurrencesInListView(windowPosition);
            });
            myCounter = new Label("")
            {
                style =
                {
                    display        = isHorizontal ? DisplayStyle.Flex : DisplayStyle.None,
                    unityTextAlign = TextAnchor.MiddleRight
                }
            };
            Add(myCounter);

            tool.Session.Value.IsCompletedViewable.WhenTrue(lifetime, _ =>
            {
                RefreshPresentation();
            });
        }
 public SceneOccurrenceEffectToggle(SceneOccurrenceExplorerTool tool)
 {
     myTool   = tool;
     name     = "EffectToggle";
     icon     = myTool.EffectIcon;
     tooltip  = myTool.EffectTooltip;
     rawValue = myTool.OccurrencesHighLighted;
 }
        public static IEnumerable <VisualElement> MakeVisualElements(this SceneOccurrenceExplorerTool tool, Lifetime lifetime, bool isHorizontal)
        {
            var popupButton = new ShowUsagesExplorerButton(lifetime, tool, isHorizontal);

            yield return(popupButton);

            var prevButton = new RiderFlowEditorToolbarButton()
            {
                name    = "PrevOccurrence",
                icon    = tool.PreviousIcon,
                tooltip = tool.PreviousTooltip,
            };

            prevButton.SetOnClick(() =>
            {
                tool.SelectPrevious();
                popupButton.RefreshPresentation();
            });

            yield return(prevButton);

            var nextButton = new RiderFlowEditorToolbarButton()
            {
                name    = "NextOccurrence",
                icon    = tool.NextIcon,
                tooltip = tool.NextTooltip,
            };

            nextButton.SetOnClick(() =>
            {
                tool.SelectNext();
                popupButton.RefreshPresentation();
            });
            yield return(nextButton);

            var effectToggle = new SceneOccurrenceEffectToggle(tool);

            yield return(effectToggle);
        }
示例#5
0
        public void RefreshPresentation()
        {
            if (myCaption == null)
            {
                myCaption = ElementAt(1);
            }

            var isHorizontal = parent?.style.flexDirection == FlexDirection.Row;
            var content      = myTool.GetUsageContentWithIcon();

            text = content.text;
            icon = (Texture2D)content.image;
            if (isHorizontal)
            {
                var guiStyle = new GUIStyle("label");
                var width    = guiStyle.CalcSize(content).x;
                if (myTool.Session.HasValue() && myTool.Session.Value.IsCompleted)
                {
                    foreach (var occurrence in myTool.Session.Value.Occurrences)
                    {
                        var pair = SceneOccurrenceExplorerTool.GetUsageContentFor(occurrence);
                        var occurrenceContent = new GUIContent(pair.Item2.text, pair.Item1);
                        var newWidth          = guiStyle.CalcSize(occurrenceContent).x;
                        if (width < newWidth)
                        {
                            width = newWidth;
                        }
                    }
                }
                myCaption.style.width = width;
            }

            myCounter.text          = myTool?.Counter;
            myCounter.style.display = isHorizontal ? DisplayStyle.Flex : DisplayStyle.None;
            myCaption.style.display = isHorizontal ? DisplayStyle.Flex : DisplayStyle.None;
        }