S&box Wiki

Revision Difference

Widget_Docking#548353

<cat>Code.Editor</cat>⤶ <title>Widget Docking</title>⤶ ⤶ # Docking⤶ The s&box editor has removable and movable secondary windows that surround the main game viewport.⤶ ⤶ If you're using a Tools.Window (internally QMainWindow) you can implement this too.⤶ ⤶ <upload src="b2951/8dac68b39cc7fad.png" size="70016" name="docking.png" />⤶ ⤶ # How?⤶ ```csharp⤶ // in the constructor of your Window...⤶ // create your canvas!⤶ // the canvas widget will be the middle, with your DockWidgets surrounding it⤶ // for this example we'll use an empty widget.⤶ Canvas = new Widget( null );⤶ ⤶ // now the fun part... creating a DockWidget!⤶ // we will use FindOrCreateDock, which takes the title, icon and DockArea⤶ // the DockArea is where the DockWidget will sit (note the image above)⤶ DockWidget dockWidget = FindOrCreateDock("My Dock Widget", "bar_chart", DockArea.Bottom);⤶ dockWidget.MinimumSize = 200; // for testing! you should have content inside it though⤶ // finally, show the DockWidget!⤶ dockWidget.Show();⤶ ```⤶ ⤶ <upload src="b2951/8dac68c74fd8ced.png" size="24117" name="image.png" />⤶ ⤶ The Window class wraps a QMainWindow instance. To learn more about QT docking, check out https://doc.qt.io/qt-6/qtwidgets-mainwindows-dockwidgets-example.html and https://doc.qt.io/qt-6/qdockwidget.html