-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak documentation for readability #787
Open
PoignardAzur
wants to merge
5
commits into
main
Choose a base branch
from
doc4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
92a39d7
Tweak documentation for readability
PoignardAzur dfa3a13
Document conventions in WidgetState doc
PoignardAzur ab246cf
Tweak pass comments
PoignardAzur 67a9586
Tweak BoxConstraints
PoignardAzur 1f29d95
Various changes to comments and documentation
PoignardAzur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,7 +181,6 @@ impl From<PointerButton> for PointerButtons { | |
// TODO - How can RenderRoot express "I started a drag-and-drop op"? | ||
// TODO - Touchpad, Touch, AxisMotion | ||
// TODO - How to handle CursorEntered? | ||
// Note to self: Events like "pointerenter", "pointerleave" are handled differently at the Widget level. But that's weird because WidgetPod can distribute them. Need to think about this again. | ||
#[derive(Debug, Clone)] | ||
pub enum PointerEvent { | ||
PointerDown(PointerButton, PointerState), | ||
|
@@ -313,6 +312,7 @@ pub enum Update { | |
} | ||
|
||
impl PointerEvent { | ||
/// Create a [`PointerEvent::PointerLeave`] event with dummy values. | ||
pub fn new_pointer_leave() -> Self { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this method should be at the bottom, as something most users won't need (which users would need this?) |
||
// TODO - The fact we're creating so many dummy values might be | ||
// a sign we should refactor that struct | ||
|
@@ -328,6 +328,7 @@ impl PointerEvent { | |
PointerEvent::PointerLeave(pointer_state) | ||
} | ||
|
||
/// Returns the [`PointerState`] of the event. | ||
pub fn pointer_state(&self) -> &PointerState { | ||
match self { | ||
PointerEvent::PointerDown(_, state) | ||
|
@@ -343,13 +344,17 @@ impl PointerEvent { | |
} | ||
} | ||
|
||
/// Returns the position of the pointer event, except for [`PointerEvent::PointerLeave`] and [`PointerEvent::HoverFileCancel`]. | ||
pub fn position(&self) -> Option<LogicalPosition<f64>> { | ||
match self { | ||
PointerEvent::PointerLeave(_) | PointerEvent::HoverFileCancel(_) => None, | ||
_ => Some(self.pointer_state().position), | ||
} | ||
} | ||
|
||
/// Short name, for debug logging. | ||
/// | ||
/// Returns the enum variant name. | ||
pub fn short_name(&self) -> &'static str { | ||
match self { | ||
PointerEvent::PointerDown(_, _) => "PointerDown", | ||
|
@@ -365,6 +370,10 @@ impl PointerEvent { | |
} | ||
} | ||
|
||
/// Returns true if the event is likely to occur every frame. | ||
/// | ||
/// Developers should avoid logging during high-density events to avoid | ||
/// cluttering the console. | ||
pub fn is_high_density(&self) -> bool { | ||
match self { | ||
PointerEvent::PointerDown(_, _) => false, | ||
|
@@ -382,20 +391,25 @@ impl PointerEvent { | |
} | ||
|
||
impl TextEvent { | ||
/// Short name, for debug logging. | ||
pub fn short_name(&self) -> &'static str { | ||
match self { | ||
TextEvent::KeyboardKey(KeyEvent { repeat: true, .. }, _) => "KeyboardKey (repeat)", | ||
TextEvent::KeyboardKey(KeyEvent { repeat: true, .. }, _) => "KeyboardKey(repeat)", | ||
TextEvent::KeyboardKey(_, _) => "KeyboardKey", | ||
TextEvent::Ime(Ime::Disabled) => "Ime::Disabled", | ||
TextEvent::Ime(Ime::Enabled) => "Ime::Enabled", | ||
TextEvent::Ime(Ime::Commit(_)) => "Ime::Commit", | ||
TextEvent::Ime(Ime::Preedit(s, _)) if s.is_empty() => "Ime::Preedit(\"\")", | ||
TextEvent::Ime(Ime::Preedit(_, _)) => "Ime::Preedit", | ||
TextEvent::Ime(Ime::Preedit(_, _)) => "Ime::Preedit(\"...\")", | ||
TextEvent::ModifierChange(_) => "ModifierChange", | ||
TextEvent::FocusChange(_) => "FocusChange", | ||
} | ||
} | ||
|
||
/// Returns true if the event is likely to occur every frame. | ||
/// | ||
/// Developers should avoid logging during high-density events to avoid | ||
/// cluttering the console. | ||
pub fn is_high_density(&self) -> bool { | ||
match self { | ||
TextEvent::KeyboardKey(_, _) => false, | ||
|
@@ -408,6 +422,9 @@ impl TextEvent { | |
} | ||
|
||
impl AccessEvent { | ||
/// Short name, for debug logging. | ||
/// | ||
/// Returns the enum variant name. | ||
pub fn short_name(&self) -> &'static str { | ||
match self.action { | ||
accesskit::Action::Click => "Click", | ||
|
@@ -442,15 +459,6 @@ impl AccessEvent { | |
|
||
impl PointerState { | ||
pub fn empty() -> Self { | ||
#[cfg(FALSE)] | ||
#[allow(unsafe_code)] | ||
// SAFETY: Uuuuh, unclear. Winit says the dummy id should only be used in | ||
// tests and should never be passed to winit. In principle, we're never | ||
// passing this id to winit, but it's still visible to custom widgets which | ||
// might do so if they tried really hard. | ||
// It would be a lot better if winit could just make this constructor safe. | ||
let device_id = unsafe { DeviceId::dummy() }; | ||
|
||
PointerState { | ||
physical_position: PhysicalPosition::new(0.0, 0.0), | ||
position: LogicalPosition::new(0.0, 0.0), | ||
|
@@ -466,7 +474,7 @@ impl PointerState { | |
impl Update { | ||
/// Short name, for debug logging. | ||
/// | ||
/// Essentially returns the enum variant name. | ||
/// Returns the enum variant name. | ||
pub fn short_name(&self) -> &str { | ||
match self { | ||
Update::WidgetAdded => "WidgetAdded", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't use all caps here for the pass names