-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to highlight any widget (#2632)
* Add ability to highlight any widget * Add line to changelog * Demote the demo to a test
- Loading branch information
Showing
10 changed files
with
99 additions
and
4 deletions.
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
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,37 @@ | ||
#[derive(Default)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] | ||
#[cfg_attr(feature = "serde", serde(default))] | ||
pub struct Highlighting {} | ||
|
||
impl super::Demo for Highlighting { | ||
fn name(&self) -> &'static str { | ||
"Highlighting" | ||
} | ||
|
||
fn show(&mut self, ctx: &egui::Context, open: &mut bool) { | ||
egui::Window::new(self.name()) | ||
.default_width(320.0) | ||
.open(open) | ||
.show(ctx, |ui| { | ||
use super::View as _; | ||
self.ui(ui); | ||
}); | ||
} | ||
} | ||
|
||
impl super::View for Highlighting { | ||
fn ui(&mut self, ui: &mut egui::Ui) { | ||
ui.label("This demo demonstrates highlighting a widget."); | ||
ui.add_space(4.0); | ||
let label_response = ui.label("Hover me to highlight the button!"); | ||
ui.add_space(4.0); | ||
let mut button_response = ui.button("Hover the button to highlight the label!"); | ||
|
||
if label_response.hovered() { | ||
button_response = button_response.highlight(); | ||
} | ||
if button_response.hovered() { | ||
label_response.highlight(); | ||
} | ||
} | ||
} |
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