72 lines
2 KiB
Swift
72 lines
2 KiB
Swift
/// Window Management Protocol - Platform-agnostic window handling
|
|
/// This module contains ONLY protocol definitions with no platform-specific imports
|
|
|
|
import Foundation
|
|
|
|
// MARK: - Window Types
|
|
|
|
/// Window configuration
|
|
public struct WindowConfig: Sendable {
|
|
public var title: String
|
|
public var width: Int
|
|
public var height: Int
|
|
public var fullscreen: Bool
|
|
public var resizable: Bool
|
|
public var vsyncEnabled: Bool
|
|
|
|
public init(title: String = "SportsBallEngine", width: Int = 1920, height: Int = 1080,
|
|
fullscreen: Bool = false, resizable: Bool = true, vsyncEnabled: Bool = true) {
|
|
self.title = title
|
|
self.width = width
|
|
self.height = height
|
|
self.fullscreen = fullscreen
|
|
self.resizable = resizable
|
|
self.vsyncEnabled = vsyncEnabled
|
|
}
|
|
}
|
|
|
|
/// Window event types
|
|
public enum WindowEvent: Sendable {
|
|
case close
|
|
case resize(width: Int, height: Int)
|
|
case focus(focused: Bool)
|
|
case minimize
|
|
case maximize
|
|
case restore
|
|
}
|
|
|
|
// MARK: - Window Manager Protocol
|
|
|
|
/// Window system abstraction - all platform-specific window implementations must conform
|
|
public protocol WindowManager: Sendable {
|
|
/// Create and initialize a window with the given configuration
|
|
func createWindow(config: WindowConfig) async throws
|
|
|
|
/// Check if the window should close
|
|
func shouldClose() -> Bool
|
|
|
|
/// Process window events (called each frame)
|
|
func processEvents() -> [WindowEvent]
|
|
|
|
/// Get current window size
|
|
func getSize() -> (width: Int, height: Int)
|
|
|
|
/// Set window size
|
|
func setSize(width: Int, height: Int) throws
|
|
|
|
/// Set window title
|
|
func setTitle(_ title: String) throws
|
|
|
|
/// Toggle fullscreen mode
|
|
func setFullscreen(_ fullscreen: Bool) throws
|
|
|
|
/// Get native window handle (for renderer initialization)
|
|
func getNativeHandle() -> UnsafeMutableRawPointer?
|
|
|
|
/// Swap buffers / present frame
|
|
func swapBuffers() throws
|
|
|
|
/// Destroy the window and cleanup
|
|
func destroyWindow() async
|
|
}
|
|
|