-
Notifications
You must be signed in to change notification settings - Fork 373
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
Nicer (& fixed up) help texts for space views #2070
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c6c62cd
Nicer (& fixed) help texts for space views
Wumpf 69061ff
centralize constants for space view controls
Wumpf 9a82b50
Merge remote-tracking branch 'origin/main' into andreas/nicer-help-text
Wumpf 340bb34
fix calling primary mouse button right
Wumpf 7f1500b
update egui for modifiers.contains support
Wumpf 459cabf
formatting
Wumpf 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/// Utility for building layout jobs. | ||
pub struct LayoutJobBuilder<'a> { | ||
pub layout_job: egui::text::LayoutJob, | ||
pub re_ui: &'a crate::ReUi, | ||
} | ||
|
||
impl<'a> LayoutJobBuilder<'a> { | ||
pub fn new(re_ui: &'a crate::ReUi) -> Self { | ||
Self { | ||
layout_job: egui::text::LayoutJob::default(), | ||
re_ui, | ||
} | ||
} | ||
|
||
/// Append a generic text block. | ||
pub fn add<'b, T: Into<LayoutJobBuilderBuildingBlock<'b>>>(&mut self, text_block: T) { | ||
let text_block: LayoutJobBuilderBuildingBlock<'_> = text_block.into(); | ||
match text_block { | ||
LayoutJobBuilderBuildingBlock::Body(text) => self.add_body(text), | ||
LayoutJobBuilderBuildingBlock::Key(key) => self.add_key(key), | ||
LayoutJobBuilderBuildingBlock::Modifier(modifier) => self.add_modifier(modifier), | ||
LayoutJobBuilderBuildingBlock::MouseButton(button) => self.add_mouse_button(button), | ||
}; | ||
} | ||
|
||
/// Append body text. | ||
pub fn add_body(&mut self, text: &str) { | ||
self.layout_job | ||
.append(text, 0.0, self.re_ui.text_format_body()); | ||
} | ||
|
||
/// Append text that has special formatting for a button. | ||
pub fn add_button_text(&mut self, text: &str) { | ||
self.layout_job | ||
.append(&text.to_lowercase(), 0.0, self.re_ui.text_format_key()); | ||
} | ||
|
||
/// Append text for a keyboard key. | ||
pub fn add_key(&mut self, key: egui::Key) { | ||
self.add_button_text(key.name()); | ||
} | ||
|
||
/// Append text for one or more modifier keys. | ||
pub fn add_modifier(&mut self, modifier: egui::Modifiers) { | ||
let is_mac = matches!( | ||
self.re_ui.egui_ctx.os(), | ||
egui::os::OperatingSystem::Mac | egui::os::OperatingSystem::IOS | ||
); | ||
let text = egui::ModifierNames::NAMES.format(&modifier, is_mac); | ||
self.add_button_text(&text); | ||
} | ||
|
||
/// Append text for a mouse button. | ||
pub fn add_mouse_button(&mut self, button: egui::PointerButton) { | ||
self.add_button_text(match button { | ||
egui::PointerButton::Primary => "right mouse button", | ||
egui::PointerButton::Secondary => "left mouse button", | ||
egui::PointerButton::Middle => "middle mouse button", | ||
egui::PointerButton::Extra1 => "extra mouse button 1", | ||
egui::PointerButton::Extra2 => "extra mouse button 2", | ||
}); | ||
} | ||
} | ||
|
||
/// Generic building block that the layout job builder can consume. | ||
/// | ||
/// Not meant to be used directly, use [`LayoutJobBuilder::add`] instead. | ||
pub enum LayoutJobBuilderBuildingBlock<'a> { | ||
Body(&'a str), | ||
Key(egui::Key), | ||
Modifier(egui::Modifiers), | ||
MouseButton(egui::PointerButton), | ||
} | ||
|
||
impl<'a> From<&'a str> for LayoutJobBuilderBuildingBlock<'a> { | ||
fn from(text: &'a str) -> Self { | ||
Self::Body(text) | ||
} | ||
} | ||
|
||
impl From<egui::Key> for LayoutJobBuilderBuildingBlock<'_> { | ||
fn from(key: egui::Key) -> Self { | ||
Self::Key(key) | ||
} | ||
} | ||
|
||
impl From<egui::Modifiers> for LayoutJobBuilderBuildingBlock<'_> { | ||
fn from(modifier: egui::Modifiers) -> Self { | ||
Self::Modifier(modifier) | ||
} | ||
} | ||
|
||
impl From<egui::PointerButton> for LayoutJobBuilderBuildingBlock<'_> { | ||
fn from(button: egui::PointerButton) -> Self { | ||
Self::MouseButton(button) | ||
} | ||
} |
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
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
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.
Would be nice if these semantic constants were shared with the values used here:
rerun/crates/re_viewer/src/ui/view_spatial/eye.rs
Lines 298 to 317 in 78c9936
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.
was too lazy to go that extra mile, but yeah at least some of those are pretty easy. Let's put them somewhere central!
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.
that would be nice
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.
done that now. Sadly lots of controls are hidden inside other egui constructs like scrollview or plot