File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919 "focused" ,
2020 "pixel_width" ,
2121 "pixel_height" ,
22- "pixel_density" ,
2322)
2423_DYNAMIC_FUNCTIONS = (
2524 "mouse_x" ,
Original file line number Diff line number Diff line change @@ -1658,9 +1658,24 @@ mod mewnala {
16581658 }
16591659
16601660 #[ pyfunction]
1661- #[ pyo3( pass_module) ]
1662- fn pixel_density ( module : & Bound < ' _ , PyModule > , density : f32 ) -> PyResult < ( ) > {
1663- graphics ! ( module) . surface . set_pixel_density ( density)
1661+ #[ pyo3( pass_module, signature = ( density=None ) ) ]
1662+ fn pixel_density < ' py > (
1663+ module : & Bound < ' py , PyModule > ,
1664+ density : Option < f32 > ,
1665+ ) -> PyResult < Py < PyAny > > {
1666+ let py = module. py ( ) ;
1667+ match density {
1668+ Some ( d) => {
1669+ graphics ! ( module) . surface . set_pixel_density ( d) ?;
1670+ Ok ( py. None ( ) )
1671+ }
1672+ None => {
1673+ let graphics = get_graphics ( module) ?
1674+ . ok_or_else ( || PyRuntimeError :: new_err ( "call size() first" ) ) ?;
1675+ let current = graphics. surface . pixel_density ( ) ?;
1676+ Ok ( current. into_pyobject ( py) ?. into_any ( ) . unbind ( ) )
1677+ }
1678+ }
16641679 }
16651680
16661681 #[ pyfunction]
You can’t perform that action at this time.
0 commit comments