mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 08:18:20 -04:00
* Add Qt-Advanced-Docking-System 5.0 * Bind new CDockManager, dock areas * Use Valve's CSS & images for ADS as a baseline, load stuff from disk instead of embedded in c++ * dockmanager.css in tool styles, auto loads and hotloads * Rewrite DockManager * delete toolwindowmanager * Delete the 50 different ways to create/add/register a dock, you just add a dock, that's all u need * More dockmanager rejigging * restore all editor dock layouts and asset browser on the new docking system * remove last toolwindowmanager remnants, add ADS to third party legal notice * build classic default layout in code for main editor reset/first-run, add relative area AddDock overload * relativeTo placement API, restore correct default layouts for all tool windows, register [Dock] types closed instead of eagerly docking * styling pass * disable ADS built-in stylesheet load, styling comes from editor stylesheet * lock picker browser tabs against closing/dragging, make ActionGraph reset layout actually reposition docks * add DockManager.OpenDock, dedupe layout code in EditorMainWindow/ActionGraph * CloseDockWidget internal * add "Close Tabs to the Left/Right" to dock tab context menu * expose dock MinimumSizeFromContent * only offer close left/right tab options when open tabs exist on that side * move "Close Tabs to the Left/Right" out of the ADS lib into a components factory * guard dock tab context menu against pinned docks with no dock area * fix crash when pinned tab is destroyed before delayed auto hide timer fires * recreate scene widget swapchains when Qt recreates their native window on dock reparent * wrap all sbox changes to the dock lib in #ifdef SBOX * save a plain window rect as fallback for when Qt rejects saved geometry on mixed-DPI monitors * expose DockWidget Float/IsFloating * always restore window geometry from a plain saved rect instead of Qt's DPI fragile geometry blob * route all window centering through one screen aware helper that handles mixed DPI monitors * restore window geometry onto the screen it was saved on * don't close live docks when a dock type unregisters, hotload substitutes them in place --------- Co-authored-by: Layla <1667289+aylaylay@users.noreply.github.com>
74 lines
1.4 KiB
C#
74 lines
1.4 KiB
C#
using System;
|
|
|
|
namespace Editor;
|
|
|
|
public partial class BaseWindow : Widget
|
|
{
|
|
/// <summary>
|
|
/// Position the window at the centre of the screen (or main editor window if one is present) by default.
|
|
/// </summary>
|
|
public bool StartCentered { get; set; } = true;
|
|
|
|
public Action OnWindowClosed { get; set; }
|
|
|
|
public override void SetWindowIcon( string name )
|
|
{
|
|
var icon = new Pixmap( 128, 128 );
|
|
icon.Clear( Color.Transparent );
|
|
|
|
|
|
using ( Paint.ToPixmap( icon ) )
|
|
{
|
|
var r = new Rect( 0, 0, 128, 128 );
|
|
|
|
Paint.ClearPen();
|
|
Paint.SetBrush( Theme.Primary );
|
|
Paint.DrawRect( r, 16 );
|
|
|
|
Paint.SetPen( Theme.Text );
|
|
Paint.DrawIcon( r, name, 120 );
|
|
}
|
|
|
|
base.SetWindowIcon( icon );
|
|
}
|
|
|
|
public BaseWindow() : base( null, true )
|
|
{
|
|
IsWindow = true;
|
|
DeleteOnClose = true;
|
|
}
|
|
|
|
protected override void OnClosed()
|
|
{
|
|
OnWindowClosed?.Invoke();
|
|
}
|
|
|
|
protected override void OnPaint()
|
|
{
|
|
Paint.Antialiasing = true;
|
|
|
|
Paint.SetPen( Theme.Primary.WithAlpha( 0.2f ), 3 );
|
|
Paint.SetBrush( Theme.WindowBackground );
|
|
Paint.DrawRect( LocalRect.Shrink( 1 ), 3 );
|
|
|
|
Paint.SetPen( Theme.WindowBackground.WithAlpha( 0.9f ), 1 );
|
|
Paint.ClearBrush();
|
|
Paint.DrawRect( LocalRect.Shrink( 0 ), 1 );
|
|
|
|
var l = LocalRect.Shrink( 1 );
|
|
|
|
Paint.SetBrush( Theme.WidgetBackground );
|
|
Paint.DrawRect( l, 1 );
|
|
}
|
|
|
|
public override void Show()
|
|
{
|
|
if ( StartCentered )
|
|
{
|
|
CenterWindow();
|
|
}
|
|
|
|
base.Show();
|
|
}
|
|
}
|