winit icon indicating copy to clipboard operation
winit copied to clipboard

Split max/min sizes constraints

Open amrbashir opened this issue 1 year ago • 1 comments

I think it is a valid use-case to only constrain the window width or height.

I think an implementation of this would be similar to LogicalSize and PhysicalSize

I couldn't think of a better names so these are subject to change ofc

#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)]
struct LogicalUnit<P>(P);
// conversion methods similar to `LogicalSize`

#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)]
struct PhysicalUnit<P>(P);
// conversion methods similar to `PhysicalSize`

#[derive(Debug, Copy, Clone, PartialEq)]
enum Unit {
    Physical(PhysicalUnit<u32>),
    Logical(LogicalUnit<f64>),
}
// conversion methods similar to `Size`


impl WindowBuilder {
  fn with_max_inner_size<S: Into<Unit>>(width: Option<U>, height: Option<U>);
}

amrbashir avatar Jul 25 '22 13:07 amrbashir

The implementation could build upon https://github.com/rust-windowing/winit/pull/2148

madsmtm avatar Jul 26 '22 18:07 madsmtm