Commit 6dcc191
authored
Make bevy_winit::converters module public (#22336)
# Objective
- Fixes: #5980
Some of these converters are useful to users. I found myself needing to
convert to a bevy KeyCode so i looked at all places its mentioned and
found `convert_physical_key_code`. Then i looked up why its not in a pub
module and found #5980 and #5986
In #5986 @mockersf expressed wanting these to be turned into From
implementations, which Cart later argued against and instead wanted as
Into implementations in bevy_winit. But the orphan rule disallows this,
as the releavant types are implemented in bevy_input, bevy_window,
bevy_math, etc.
Because of this, and the fact its been 3 years, i'm proposing just
leaving them as converter functions. The usecases are rare enough that
users can deal with some non-idiomatic code and unintuitive function
names.
## Solution
`use converters;` -> `pub use converters;`
I've also written basic docstrings.
## Testing
- cargo check
- cargo doc
---
## Showcase
`bevy_winit::converters` is now public, allowing access to the following
functions:
<details><summary>Newly exposed functions</summary>
<p>
- `convert_element_state`
Converts a `winit::event::ElementState` to a Bevy `ButtonState`
- `convert_enabled_buttons`
Converts a Bevy `EnabledButtons` to a `winit::window::WindowButtons`
- `convert_keyboard_input`
Converts a `winit::event::KeyEvent` and a window Entity to a Bevy
`KeyboardInput`
- `convert_logical_key`
Converts a `winit::keyboard::Key` to a Bevy `bevy_input`::keyboard::Key
- `convert_mouse_button`
Converts a `winit::event::MouseButton` to a Bevy `MouseButton`
- `convert_native_key`
Converts a `winit::keyboard::NativeKey` to a Bevy `NativeKey`
- `convert_physical_key_code`
Converts a `winit::keyboard::PhysicalKey` to a Bevy `KeyCode`
- `convert_physical_native_key_code`
Converts a `winit::keyboard::NativeKeyCode` to a Bevy `NativeKeyCode`
- `convert_resize_direction`
Converts a Bevy `CompassOctant` to a `winit::window::ResizeDirection`
- `convert_system_cursor_icon`
Converts a Bevy `SystemCursorIcon` to a `winit::window::CursorIcon.`
- `convert_touch_input`
Converts a `winit::event::Touch`, `winit::dpi::LogicalPosition<f64>` and
window `Entity` to a Bevy `TouchInput`
- `convert_window_level`
Converts a Bevy `WindowLevel` to a `winit::window::WindowLevel`
- `convert_window_theme`
Converts a Bevy `WindowTheme` to a `winit::window::Theme`
- `convert_winit_theme`
Converts a `winit::window::Theme` to a Bevy `WindowTheme`
</p>
</details>1 parent e4eb916 commit 6dcc191
2 files changed
+16
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| 52 | + | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
| |||
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| 83 | + | |
78 | 84 | | |
79 | 85 | | |
80 | 86 | | |
| |||
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
| 95 | + | |
89 | 96 | | |
90 | 97 | | |
91 | 98 | | |
| |||
291 | 298 | | |
292 | 299 | | |
293 | 300 | | |
| 301 | + | |
294 | 302 | | |
295 | 303 | | |
296 | 304 | | |
| |||
622 | 630 | | |
623 | 631 | | |
624 | 632 | | |
| 633 | + | |
625 | 634 | | |
626 | 635 | | |
627 | 636 | | |
| |||
633 | 642 | | |
634 | 643 | | |
635 | 644 | | |
636 | | - | |
| 645 | + | |
637 | 646 | | |
638 | 647 | | |
639 | 648 | | |
| |||
673 | 682 | | |
674 | 683 | | |
675 | 684 | | |
| 685 | + | |
676 | 686 | | |
677 | 687 | | |
678 | 688 | | |
| |||
681 | 691 | | |
682 | 692 | | |
683 | 693 | | |
| 694 | + | |
684 | 695 | | |
685 | 696 | | |
686 | 697 | | |
687 | 698 | | |
688 | 699 | | |
689 | 700 | | |
690 | 701 | | |
| 702 | + | |
691 | 703 | | |
692 | 704 | | |
693 | 705 | | |
694 | 706 | | |
695 | 707 | | |
696 | 708 | | |
697 | 709 | | |
| 710 | + | |
698 | 711 | | |
699 | 712 | | |
700 | 713 | | |
| |||
709 | 722 | | |
710 | 723 | | |
711 | 724 | | |
| 725 | + | |
712 | 726 | | |
713 | 727 | | |
714 | 728 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
0 commit comments