NewDesktopGeometryWithDeclared returns a geometry that preserves the native desktop size while using the provided declared model-facing dimensions.
( nativeWidth, nativeHeight, declaredWidth, declaredHeight int, )
| 69 | // NewDesktopGeometryWithDeclared returns a geometry that preserves the native |
| 70 | // desktop size while using the provided declared model-facing dimensions. |
| 71 | func NewDesktopGeometryWithDeclared( |
| 72 | nativeWidth, |
| 73 | nativeHeight, |
| 74 | declaredWidth, |
| 75 | declaredHeight int, |
| 76 | ) DesktopGeometry { |
| 77 | nativeWidth = sanitizeDesktopDimension(nativeWidth) |
| 78 | nativeHeight = sanitizeDesktopDimension(nativeHeight) |
| 79 | if declaredWidth <= 0 { |
| 80 | declaredWidth = nativeWidth |
| 81 | } |
| 82 | if declaredHeight <= 0 { |
| 83 | declaredHeight = nativeHeight |
| 84 | } |
| 85 | |
| 86 | return DesktopGeometry{ |
| 87 | NativeWidth: nativeWidth, |
| 88 | NativeHeight: nativeHeight, |
| 89 | DeclaredWidth: sanitizeDesktopDimension(declaredWidth), |
| 90 | DeclaredHeight: sanitizeDesktopDimension(declaredHeight), |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // DeclaredPointToNative maps a point from declared model-facing coordinates to |
| 95 | // native desktop coordinates using the existing pixel-center truncation rule. |