Esempio n. 1
0
        public override bool DragAndDrop_HandleDrop(Package p, int x, int y)
        {
            Point LocalPos = CanvasPosToLocal(new Point(x, y));

            TabButton  button     = DragAndDrop.SourceControl as TabButton;
            TabControl tabControl = Parent as TabControl;

            if (tabControl != null && button != null)
            {
                if (button.TabControl != tabControl)
                {
                    // We've moved tab controls!
                    tabControl.AddPage(button);
                }
            }

            Base droppedOn = GetControlAt(LocalPos.X, LocalPos.Y);

            if (droppedOn != null)
            {
                Point dropPos = droppedOn.CanvasPosToLocal(new Point(x, y));
                DragAndDrop.SourceControl.BringNextToControl(droppedOn, dropPos.X > droppedOn.Width / 2);
            }
            else
            {
                DragAndDrop.SourceControl.BringToFront();
            }
            return(true);
        }
Esempio n. 2
0
        internal static ControlBase XmlElementHandler(Xml.Parser parser, Type type, ControlBase parent)
        {
            TabControl element = new TabControl(parent);

            parser.ParseAttributes(element);
            if (parser.MoveToContent())
            {
                foreach (string elementName in parser.NextElement())
                {
                    if (elementName == "TabPage")
                    {
                        string pageLabel = parser.GetAttribute("Text");
                        if (pageLabel == null)
                        {
                            pageLabel = "";
                        }

                        string pageName = parser.GetAttribute("Name");
                        if (pageName == null)
                        {
                            pageName = "";
                        }

                        TabButton button = element.AddPage(pageLabel);
                        button.Name = pageName;

                        ControlBase page = button.Page;
                        parser.ParseContainerContent(page);
                    }
                }
            }
            return(element);
        }
Esempio n. 3
0
	//public ref int testRef(ref int param) { return ref param; }
	protected void OnGlwidget1Initialized(object sender, EventArgs e)
	{
		Console.WriteLine("init");
		//if (GLinit)
		//return;
		GLinit = true;
		MainEditorView.editorBackendRenderer = new SharpSL.BackendRenderers.OpenGL.EditorOpenGLRenderer();
		SceneView.backendRenderer = new SharpSL.BackendRenderers.OpenGL.OpenGLRenderer();
		mainEditorView.Initialize();
		mainEditorView.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);

		Sharp.InputHandler.input.Initialize(MainEditorView.canvas);


		var assets = new AssetsView();


		Sharp.InputHandler.OnMouseDown += (args) =>
		{
			Console.WriteLine("click: " + focusedView);
			if (focusedView == null)
				foreach (var view in View.views)
				{

					if (view.panel != null && view.panel.IsChild(Gwen.Input.InputHandler.HoveredControl, true))
					{
						view.OnMouseDown(args);
						break;
					}
				}
			else
				focusedView.OnMouseDown(args);
		};
		Sharp.InputHandler.OnMouseUp += (args) =>
		{
			if (focusedView == null)
				foreach (var view in View.views)
				{
					if (view.panel != null && view.panel.IsChild(Gwen.Input.InputHandler.HoveredControl, true))
					{
						view.OnMouseUp(args);
						break;
					}
				}
			else
				focusedView.OnMouseUp(args);
		};
		Sharp.InputHandler.OnMouseMove += (args) =>
		{
			if (focusedView == null)
				foreach (var view in View.views)
				{
					if (view.panel != null && view.panel.IsChild(Gwen.Input.InputHandler.HoveredControl, true))
					{
						view.OnMouseMove(args);
						break;
					}
				}
			else
				focusedView.OnMouseMove(args);
		};

		var scene = new SceneView();
		var structure = new SceneStructureView();
		var inspector = new InspectorView();

		var tab = new Gwen.Control.TabControl(mainEditorView.splitter);
		mainEditorView.splitter.OnSplitMoved += (o, args) =>
		{
			scene.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
			//assets.OnResize(glwidget1.Allocation.Width,glwidget1.Allocation.Height);
		};
		var btn = tab.AddPage("scene");
		var page = btn.Page;
		page.Margin = new Gwen.Margin(3, 3, 3, 3);
		scene.panel = btn.Page; //make GLControl for gwen

		var tab1 = new Gwen.Control.TabControl(mainEditorView.splitter);
		btn = tab1.AddPage("Assets");
		page = btn.Page;
		page.Margin = new Gwen.Margin(3, 3, 3, 3);
		page.HoverEnter += (item, args) => { Console.WriteLine("hover"); };
		assets.panel = page;

		var tab2 = new Gwen.Control.TabControl(mainEditorView.splitter);
		btn = tab2.AddPage("Structure");
		page = btn.Page;
		page.Margin = new Gwen.Margin(3, 3, 3, 3);
		structure.panel = btn.Page;

		var tab3 = new Gwen.Control.TabControl(mainEditorView.splitter);
		btn = tab3.AddPage("Inspector");
		page = btn.Page;
		page.Margin = new Gwen.Margin(3, 3, 3, 3);
		inspector.panel = btn.Page;

		scene.Initialize();
		structure.Initialize();

		inspector.Initialize();
		assets.Initialize();

		inspector.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
		scene.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
		structure.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
		assets.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);

		mainEditorView.splitter.SetPanel(1, tab);
		mainEditorView.splitter.SetPanel(0, tab1);
		mainEditorView.splitter.SetPanel(2, tab2);
		mainEditorView.splitter.SetPanel(3, tab3);


		foreach (var view in View.views)
			view.OnContextCreated(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
		QueueResize();
	}
Esempio n. 4
0
    protected void OnGlwidget1Initialized(object sender, EventArgs e)
    {
        Console.WriteLine("init");
        //if (GLinit)
        //return;
        GLinit = true;
        MainEditorView.editorBackendRenderer = new SharpSL.BackendRenderers.OpenGL.EditorOpenGLRenderer();
        SceneView.backendRenderer            = new SharpSL.BackendRenderers.OpenGL.OpenGLRenderer();
        mainEditorView.Initialize();
        mainEditorView.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);

        Sharp.InputHandler.input.Initialize(MainEditorView.canvas);


        var assets = new AssetsView();


        Sharp.InputHandler.OnMouseDown += (args) => {
            Console.WriteLine("click: " + focusedView);
            if (focusedView == null)
            {
                foreach (var view in View.views)
                {
                    if (view.panel != null && view.panel.IsChild(Gwen.Input.InputHandler.HoveredControl, true))
                    {
                        view.OnMouseDown(args);
                        break;
                    }
                }
            }
            else
            {
                focusedView.OnMouseDown(args);
            }
        };
        Sharp.InputHandler.OnMouseUp += (args) => {
            if (focusedView == null)
            {
                foreach (var view in View.views)
                {
                    if (view.panel != null && view.panel.IsChild(Gwen.Input.InputHandler.HoveredControl, true))
                    {
                        view.OnMouseUp(args);
                        break;
                    }
                }
            }
            else
            {
                focusedView.OnMouseUp(args);
            }
        };
        Sharp.InputHandler.OnMouseMove += (args) => {
            if (focusedView == null)
            {
                foreach (var view in View.views)
                {
                    if (view.panel != null && view.panel.IsChild(Gwen.Input.InputHandler.HoveredControl, true))
                    {
                        view.OnMouseMove(args);
                        break;
                    }
                }
            }
            else
            {
                focusedView.OnMouseMove(args);
            }
        };

        var scene     = new SceneView();
        var structure = new SceneStructureView();
        var inspector = new InspectorView();

        var tab = new Gwen.Control.TabControl(mainEditorView.splitter);

        mainEditorView.splitter.OnSplitMoved += (o, args) => {
            scene.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
            //assets.OnResize(glwidget1.Allocation.Width,glwidget1.Allocation.Height);
        };
        var btn  = tab.AddPage("scene");
        var page = btn.Page;

        page.Margin = new Gwen.Margin(3, 3, 3, 3);
        scene.panel = btn.Page;         //make GLControl for gwen

        var tab1 = new Gwen.Control.TabControl(mainEditorView.splitter);

        btn              = tab1.AddPage("Assets");
        page             = btn.Page;
        page.Margin      = new Gwen.Margin(3, 3, 3, 3);
        page.HoverEnter += (item, args) => { Console.WriteLine("hover"); };
        assets.panel     = page;

        var tab2 = new Gwen.Control.TabControl(mainEditorView.splitter);

        btn             = tab2.AddPage("Structure");
        page            = btn.Page;
        page.Margin     = new Gwen.Margin(3, 3, 3, 3);
        structure.panel = btn.Page;

        var tab3 = new Gwen.Control.TabControl(mainEditorView.splitter);

        btn             = tab3.AddPage("Inspector");
        page            = btn.Page;
        page.Margin     = new Gwen.Margin(3, 3, 3, 3);
        inspector.panel = btn.Page;

        scene.Initialize();
        structure.Initialize();

        inspector.Initialize();
        assets.Initialize();

        inspector.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
        scene.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
        structure.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
        assets.OnResize(glwidget1.Allocation.Width, glwidget1.Allocation.Height);

        mainEditorView.splitter.SetPanel(1, tab);
        mainEditorView.splitter.SetPanel(0, tab1);
        mainEditorView.splitter.SetPanel(2, tab2);
        mainEditorView.splitter.SetPanel(3, tab3);


        foreach (var view in View.views)
        {
            view.OnContextCreated(glwidget1.Allocation.Width, glwidget1.Allocation.Height);
        }
        QueueResize();
    }