예제 #1
0
    private void SetupOpenWindowsList(ITopLevel topLevel)
    {
        mOpenWindowsList = topLevel;
        ((Window)mOpenWindowsList).InFront = true;
        mWindowListFrame = mOpenWindowsList.SelectSingleElement <IGuiFrame>("MainFrame/WindowList");
        Button hideShowButton = mOpenWindowsList.SelectSingleElement <Button>("MainFrame/HideShowButton");

        hideShowButton.AddOnPressedAction(delegate()
        {
            Vector2 currentPosition = mManager.GetTopLevelPosition(mOpenWindowsList).GetPosition(mOpenWindowsList);
            float shiftAmount       = mWindowListFrame.ExternalSize.x - (hideShowButton.ExternalSize.x * 0.5f);
            if (!mOpenWindowsListShowing)
            {
                shiftAmount *= -1.0f;
            }

            mManager.SetTopLevelPosition
            (
                mOpenWindowsList,
                new FixedPosition
                (
                    currentPosition - new Vector2(shiftAmount, 0.0f)
                )
            );

            mOpenWindowsListShowing = !mOpenWindowsListShowing;
        });

        mWindowListingPrototype = mWindowListFrame.SelectSingleElement <Button>("WindowListingPrototype");
        mWindowListFrame.RemoveChildWidget(mWindowListingPrototype);
    }
예제 #2
0
        public void GetWidgetPositionVerification()
        {
            RuntimeGuiManager manager = new RuntimeGuiManager(false, new Logger());
            IDictionary <IWidget, IGuiPosition> widgets = new Dictionary <IWidget, IGuiPosition>();
            Button testWidget = new Button
                                (
                "Button01",
                new FixedSize(new Vector2(10.0f, 10.0f)),
                null,
                null,
                "OK"
                                );

            widgets.Add(testWidget, new FixedPosition(new Vector2(10.0f, 10.0f)));

            IGuiFrame testFrame = new GuiFrame
                                  (
                "TestFrame",
                new FillParent(),
                widgets,
                null
                                  );

            ITopLevel testWindow = new Window
                                   (
                "TestWindow",
                new FixedSize(new Vector2(400.0f, 400.0f)),
                manager,
                new KeyValuePair <IGuiFrame, IGuiPosition>
                (
                    testFrame,
                    new FixedPosition(10.0f, 10.0f)
                ),
                null
                                   );

            manager.SetTopLevelPosition(testWindow, new FixedPosition(10.0f, 10.0f));

            UnityAssert.AreClose(Vector2.zero, testFrame.GetWidgetPosition(new Vector2(20.0f, Screen.height - 20.0f)), 0.0001f);
            UnityAssert.AreClose(Vector2.zero, testWidget.GetWidgetPosition(new Vector2(30.0f, Screen.height - 30.0f)), 0.0001f);

            UnityAssert.AreClose(new Vector2(0.0f, 5.0f), testFrame.GetWidgetPosition(new Vector2(20.0f, Screen.height - 25.0f)), 0.0001f);
            UnityAssert.AreClose(new Vector2(5.0f, 0.0f), testWidget.GetWidgetPosition(new Vector2(35.0f, Screen.height - 30.0f)), 0.0001f);
        }