Browse Source

Misc code cleanup: use more ui.checkbox, ui.label, ui.button etc

pull/28/head
Emil Ernerfeldt 4 years ago
parent
commit
12afc356ee
  1. 57
      egui/src/context.rs
  2. 22
      egui/src/demos/app.rs
  3. 26
      egui/src/demos/demo_window.rs
  4. 4
      egui/src/demos/fractal_clock.rs
  5. 2
      egui/src/demos/sliders.rs
  6. 16
      egui/src/demos/widgets.rs
  7. 7
      egui/src/introspection.rs
  8. 2
      egui/src/menu.rs
  9. 2
      egui/src/paint/command.rs
  10. 29
      egui/src/style.rs
  11. 8
      egui/src/ui.rs

57
egui/src/context.rs

@ -536,23 +536,21 @@ impl Context {
.show(ui, |ui| ui.input().clone().ui(ui)); .show(ui, |ui| ui.input().clone().ui(ui));
ui.collapsing("Stats", |ui| { ui.collapsing("Stats", |ui| {
ui.add(label!( ui.label(format!(
"Screen size: {} x {} points, pixels_per_point: {:?}", "Screen size: {} x {} points, pixels_per_point: {:?}",
ui.input().screen_size.x, ui.input().screen_size.x,
ui.input().screen_size.y, ui.input().screen_size.y,
ui.input().pixels_per_point, ui.input().pixels_per_point,
)); ));
ui.add(label!("Painting:").text_style(TextStyle::Heading)); ui.heading("Painting:");
self.paint_stats.lock().ui(ui); self.paint_stats.lock().ui(ui);
}); });
} }
pub fn memory_ui(&self, ui: &mut crate::Ui) { pub fn memory_ui(&self, ui: &mut crate::Ui) {
use crate::widgets::*;
if ui if ui
.add(Button::new("Reset all")) .button("Reset all")
.on_hover_text("Reset all Egui state") .on_hover_text("Reset all Egui state")
.clicked .clicked
{ {
@ -560,50 +558,48 @@ impl Context {
} }
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.add(label!( ui.label(format!(
"{} areas (window positions)", "{} areas (window positions)",
self.memory().areas.count() self.memory().areas.count()
)); ));
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
self.memory().areas = Default::default(); self.memory().areas = Default::default();
} }
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.add(label!( ui.label(format!(
"{} collapsing headers", "{} collapsing headers",
self.memory().collapsing_headers.len() self.memory().collapsing_headers.len()
)); ));
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
self.memory().collapsing_headers = Default::default(); self.memory().collapsing_headers = Default::default();
} }
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.add(label!("{} menu bars", self.memory().menu_bar.len())); ui.label(format!("{} menu bars", self.memory().menu_bar.len()));
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
self.memory().menu_bar = Default::default(); self.memory().menu_bar = Default::default();
} }
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.add(label!("{} scroll areas", self.memory().scroll_areas.len())); ui.label(format!("{} scroll areas", self.memory().scroll_areas.len()));
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
self.memory().scroll_areas = Default::default(); self.memory().scroll_areas = Default::default();
} }
}); });
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.add(label!("{} resize areas", self.memory().resize.len())); ui.label(format!("{} resize areas", self.memory().resize.len()));
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
self.memory().resize = Default::default(); self.memory().resize = Default::default();
} }
}); });
ui.shrink_width_to_current(); // don't let the text below grow this window wider ui.shrink_width_to_current(); // don't let the text below grow this window wider
ui.add( ui.label("NOTE: the position of this window cannot be reset from within itself.");
label!("NOTE: the position of this window cannot be reset from within itself."), // .auto_shrink(),
);
} }
} }
@ -624,31 +620,24 @@ impl paint::PaintOptions {
debug_paint_clip_rects, debug_paint_clip_rects,
debug_ignore_clip_rects, debug_ignore_clip_rects,
} = self; } = self;
use crate::widgets::*; ui.checkbox(anti_alias, "Antialias");
ui.add(Checkbox::new(anti_alias, "Antialias")); ui.checkbox(
ui.add(Checkbox::new(
coarse_tessellation_culling, coarse_tessellation_culling,
"Do coarse culling in the tessellator", "Do coarse culling in the tessellator",
)); );
ui.add(Checkbox::new( ui.checkbox(debug_paint_clip_rects, "Paint clip rectangles (debug)");
debug_paint_clip_rects, ui.checkbox(debug_ignore_clip_rects, "Ignore clip rectangles (debug)");
"Paint clip rectangles (debug)",
));
ui.add(Checkbox::new(
debug_ignore_clip_rects,
"Ignore clip rectangles (debug)",
));
} }
} }
impl PaintStats { impl PaintStats {
pub fn ui(&self, ui: &mut Ui) { pub fn ui(&self, ui: &mut Ui) {
ui.add(label!("Jobs: {}", self.num_jobs)) ui.label(format!("Jobs: {}", self.num_jobs))
.on_hover_text("Number of separate clip rectangles"); .on_hover_text("Number of separate clip rectangles");
ui.add(label!("Primitives: {}", self.num_primitives)) ui.label(format!("Primitives: {}", self.num_primitives))
.on_hover_text("Boxes, circles, text areas etc"); .on_hover_text("Boxes, circles, text areas etc");
ui.add(label!("Vertices: {}", self.num_vertices)); ui.label(format!("Vertices: {}", self.num_vertices));
ui.add(label!("Triangles: {}", self.num_triangles)); ui.label(format!("Triangles: {}", self.num_triangles));
} }
} }

22
egui/src/demos/app.rs

@ -331,8 +331,8 @@ impl DemoApp {
ui.hyperlink("https://github.com/emilk/egui"); ui.hyperlink("https://github.com/emilk/egui");
}); });
} else { } else {
ui.add(label!("Egui").text_style(TextStyle::Heading)); ui.heading("Egui");
if ui.add(Button::new("Quit")).clicked { if ui.button("Quit").clicked {
backend.quit(); backend.quit();
return; return;
} }
@ -466,11 +466,11 @@ impl OpenWindows {
fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows, env: &DemoEnvironment) { fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows, env: &DemoEnvironment) {
menu::bar(ui, |ui| { menu::bar(ui, |ui| {
menu::menu(ui, "File", |ui| { menu::menu(ui, "File", |ui| {
if ui.add(Button::new("Reorganize windows")).clicked { if ui.button("Reorganize windows").clicked {
ui.ctx().memory().reset_areas(); ui.ctx().memory().reset_areas();
} }
if ui if ui
.add(Button::new("Clear entire Egui memory")) .button("Clear entire Egui memory")
.on_hover_text("Forget scroll, collapsibles etc") .on_hover_text("Forget scroll, collapsibles etc")
.clicked .clicked
{ {
@ -486,16 +486,16 @@ fn show_menu_bar(ui: &mut Ui, windows: &mut OpenWindows, env: &DemoEnvironment)
memory, memory,
resize, resize,
} = windows; } = windows;
ui.add(Checkbox::new(demo, "Demo")); ui.checkbox(demo, "Demo");
ui.add(Checkbox::new(fractal_clock, "Fractal Clock")); ui.checkbox(fractal_clock, "Fractal Clock");
ui.separator(); ui.separator();
ui.add(Checkbox::new(settings, "Settings")); ui.checkbox(settings, "Settings");
ui.add(Checkbox::new(inspection, "Inspection")); ui.checkbox(inspection, "Inspection");
ui.add(Checkbox::new(memory, "Memory")); ui.checkbox(memory, "Memory");
ui.add(Checkbox::new(resize, "Resize examples")); ui.checkbox(resize, "Resize examples");
}); });
menu::menu(ui, "About", |ui| { menu::menu(ui, "About", |ui| {
ui.add(label!("This is Egui")); ui.label("This is Egui");
ui.add(Hyperlink::new("https://github.com/emilk/egui").text("Egui home page")); ui.add(Hyperlink::new("https://github.com/emilk/egui").text("Egui home page"));
}); });

26
egui/src/demos/demo_window.rs

@ -32,9 +32,7 @@ impl Default for DemoWindow {
impl DemoWindow { impl DemoWindow {
pub fn ui(&mut self, ui: &mut Ui) { pub fn ui(&mut self, ui: &mut Ui) {
ui.collapsing("About Egui", |ui| { ui.collapsing("About Egui", |ui| {
ui.add(label!( ui.label("Egui is an experimental immediate mode GUI written in Rust.");
"Egui is an experimental immediate mode GUI written in Rust."
));
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Project home page:"); ui.label("Project home page:");
@ -67,7 +65,7 @@ impl DemoWindow {
ui.columns(self.num_columns, |cols| { ui.columns(self.num_columns, |cols| {
for (i, col) in cols.iter_mut().enumerate() { for (i, col) in cols.iter_mut().enumerate() {
col.add(label!("Column {} out of {}", i + 1, self.num_columns)); col.add(label!("Column {} out of {}", i + 1, self.num_columns));
if i + 1 == self.num_columns && col.add(Button::new("Delete this")).clicked { if i + 1 == self.num_columns && col.button("Delete this").clicked {
self.num_columns -= 1; self.num_columns -= 1;
} }
} }
@ -94,8 +92,8 @@ impl DemoWindow {
.default_open(false) .default_open(false)
.show(ui, |ui| { .show(ui, |ui| {
Resize::default().default_height(100.0).show(ui, |ui| { Resize::default().default_height(100.0).show(ui, |ui| {
ui.add(label!("This ui can be resized!")); ui.label("This ui can be resized!");
ui.add(label!("Just pull the handle on the bottom right")); ui.label("Just pull the handle on the bottom right");
}); });
}); });
@ -139,8 +137,8 @@ impl DemoWindow {
ui.label("\ ui.label("\
Most widgets don't need unique names, but are tracked \ Most widgets don't need unique names, but are tracked \
based on their position on screen. For instance, buttons:"); based on their position on screen. For instance, buttons:");
ui.add(Button::new("Button")); let _ = ui.button("Button");
ui.add(Button::new("Button")); let _ = ui.button("Button");
}); });
} }
} }
@ -292,7 +290,7 @@ impl Painting {
ui.horizontal(|ui| { ui.horizontal(|ui| {
self.stroke.ui(ui, "Stroke"); self.stroke.ui(ui, "Stroke");
if ui.add(Button::new("Clear")).clicked { if ui.button("Clear").clicked {
self.lines.clear(); self.lines.clear();
} }
}); });
@ -381,12 +379,12 @@ impl LayoutDemo {
} }
pub fn content_ui(&mut self, ui: &mut Ui) { pub fn content_ui(&mut self, ui: &mut Ui) {
// ui.add(label!("Available space: {:?}", ui.available().size())); // ui.label(format!("Available space: {:?}", ui.available().size()));
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
*self = Default::default(); *self = Default::default();
} }
ui.separator(); ui.separator();
ui.add(label!("Direction:")); ui.label("Direction:");
// TODO: enum iter // TODO: enum iter
@ -399,11 +397,11 @@ impl LayoutDemo {
} }
} }
ui.add(Checkbox::new(&mut self.reversed, "Reversed")); ui.checkbox(&mut self.reversed, "Reversed");
ui.separator(); ui.separator();
ui.add(label!("Align:")); ui.label("Align:");
for &align in &[Align::Min, Align::Center, Align::Max] { for &align in &[Align::Min, Align::Center, Align::Max] {
if ui if ui

4
egui/src/demos/fractal_clock.rs

@ -82,14 +82,14 @@ impl FractalClock {
)); ));
}; };
ui.add(Checkbox::new(&mut self.paused, "Paused")); ui.checkbox(&mut self.paused, "Paused");
ui.add(Slider::f32(&mut self.zoom, 0.0..=1.0).text("zoom")); ui.add(Slider::f32(&mut self.zoom, 0.0..=1.0).text("zoom"));
ui.add(Slider::f32(&mut self.start_line_width, 0.0..=5.0).text("Start line width")); ui.add(Slider::f32(&mut self.start_line_width, 0.0..=5.0).text("Start line width"));
ui.add(Slider::usize(&mut self.depth, 0..=14).text("depth")); ui.add(Slider::usize(&mut self.depth, 0..=14).text("depth"));
ui.add(Slider::f32(&mut self.length_factor, 0.0..=1.0).text("length factor")); ui.add(Slider::f32(&mut self.length_factor, 0.0..=1.0).text("length factor"));
ui.add(Slider::f32(&mut self.luminance_factor, 0.0..=1.0).text("luminance factor")); ui.add(Slider::f32(&mut self.luminance_factor, 0.0..=1.0).text("luminance factor"));
ui.add(Slider::f32(&mut self.width_factor, 0.0..=1.0).text("width factor")); ui.add(Slider::f32(&mut self.width_factor, 0.0..=1.0).text("width factor"));
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
*self = Default::default(); *self = Default::default();
} }

2
egui/src/demos/sliders.rs

@ -69,7 +69,7 @@ impl Sliders {
ui.label("Sliders will automatically figure out how many decimals to show."); ui.label("Sliders will automatically figure out how many decimals to show.");
if ui.add(Button::new("Assign PI")).clicked { if ui.button("Assign PI").clicked {
self.value = std::f64::consts::PI; self.value = std::f64::consts::PI;
} }
} }

16
egui/src/demos/widgets.rs

@ -51,13 +51,13 @@ impl Widgets {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.style_mut().spacing.item_spacing.x = 0.0; ui.style_mut().spacing.item_spacing.x = 0.0;
ui.add(label!("Text can have ").text_color(srgba(110, 255, 110, 255))); ui.add(Label::new("Text can have ").text_color(srgba(110, 255, 110, 255)));
ui.add(label!("color ").text_color(srgba(128, 140, 255, 255))); ui.add(Label::new("color ").text_color(srgba(128, 140, 255, 255)));
ui.add(label!("and tooltips.")).on_hover_text( ui.add(Label::new("and tooltips.")).on_hover_text(
"This is a multiline tooltip that demonstrates that you can easily add tooltips to any element.\nThis is the second line.\nThis is the third.", "This is a multiline tooltip that demonstrates that you can easily add tooltips to any element.\nThis is the second line.\nThis is the third.",
); );
}); });
ui.add(label!("Tooltips can be more than just simple text.")) ui.label("Tooltips can be more than just simple text.")
.on_hover_ui(|ui| { .on_hover_ui(|ui| {
ui.heading("The name of the tooltip"); ui.heading("The name of the tooltip");
ui.horizontal(|ui| { ui.horizontal(|ui| {
@ -67,7 +67,7 @@ impl Widgets {
let _ = ui.button("A button you can never press"); let _ = ui.button("A button you can never press");
}); });
ui.add(label!("Ευρηκα! τ = 2×π")) ui.label("Ευρηκα! τ = 2×π")
.on_hover_text("The current font supports only a few non-latin characters and Egui does not currently support right-to-left text."); .on_hover_text("The current font supports only a few non-latin characters and Egui does not currently support right-to-left text.");
ui.horizontal(|ui| { ui.horizontal(|ui| {
@ -82,7 +82,7 @@ impl Widgets {
ui.radio_value(&mut self.radio, Enum::Third, "Third"); ui.radio_value(&mut self.radio, Enum::Third, "Third");
}); });
ui.add(Checkbox::new(&mut self.button_enabled, "Button enabled")); ui.checkbox(&mut self.button_enabled, "Button enabled");
ui.horizontal(|ui| { ui.horizontal(|ui| {
if ui if ui
@ -133,7 +133,7 @@ impl Widgets {
ui.separator(); ui.separator();
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.add(label!("Single line text input:")); ui.label("Single line text input:");
ui.add( ui.add(
TextEdit::new(&mut self.single_line_text_input) TextEdit::new(&mut self.single_line_text_input)
.multiline(false) .multiline(false)
@ -141,7 +141,7 @@ impl Widgets {
); );
}); // TODO: .on_hover_text("Enter text to edit me") }); // TODO: .on_hover_text("Enter text to edit me")
ui.add(label!("Multiline text input:")); ui.label("Multiline text input:");
ui.add(TextEdit::new(&mut self.multiline_text_input).id_source("multiline")); ui.add(TextEdit::new(&mut self.multiline_text_input).id_source("multiline"));
ui.separator(); ui.separator();

7
egui/src/introspection.rs

@ -8,10 +8,9 @@ use crate::{
impl Texture { impl Texture {
pub fn ui(&self, ui: &mut Ui) { pub fn ui(&self, ui: &mut Ui) {
ui.add(label!( ui.label(format!(
"Texture size: {} x {} (hover to zoom)", "Texture size: {} x {} (hover to zoom)",
self.width, self.width, self.height
self.height
)); ));
if self.width <= 1 || self.height <= 1 { if self.width <= 1 || self.height <= 1 {
return; return;
@ -65,7 +64,7 @@ impl paint::FontDefinitions {
.text(format!("{:?}", text_style)), .text(format!("{:?}", text_style)),
); );
} }
if ui.add(Button::new("Reset fonts")).clicked { if ui.button("Reset fonts").clicked {
*self = paint::FontDefinitions::with_pixels_per_point(self.pixels_per_point); *self = paint::FontDefinitions::with_pixels_per_point(self.pixels_per_point);
} }
} }

2
egui/src/menu.rs

@ -7,7 +7,7 @@
//! //!
//! menu::bar(ui, |ui| { //! menu::bar(ui, |ui| {
//! menu::menu(ui, "File", |ui| { //! menu::menu(ui, "File", |ui| {
//! if ui.add(Button::new("Open")).clicked { //! if ui.button("Open").clicked {
//! // ... //! // ...
//! } //! }
//! }); //! });

2
egui/src/paint/command.rs

@ -110,7 +110,7 @@ impl PaintCmd {
} }
} }
#[derive(Clone, Copy, Debug, Default)] #[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Stroke { pub struct Stroke {
pub width: f32, pub width: f32,

29
egui/src/style.rs

@ -8,7 +8,7 @@ use crate::{
}; };
/// Specifies the look and feel of a `Ui`. /// Specifies the look and feel of a `Ui`.
#[derive(Clone, Debug)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Style { pub struct Style {
/// Default `TextStyle` for normal text (i.e. for `Label` and `TextEdit`). /// Default `TextStyle` for normal text (i.e. for `Label` and `TextEdit`).
@ -37,7 +37,7 @@ impl Style {
} }
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Spacing { pub struct Spacing {
/// Horizontal and vertical spacing between widgets /// Horizontal and vertical spacing between widgets
@ -86,7 +86,7 @@ impl Spacing {
} }
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Interaction { pub struct Interaction {
/// Mouse must be the close to the side of a window to resize /// Mouse must be the close to the side of a window to resize
@ -96,7 +96,7 @@ pub struct Interaction {
pub resize_grab_radius_corner: f32, pub resize_grab_radius_corner: f32,
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Visuals { pub struct Visuals {
pub widgets: Widgets, pub widgets: Widgets,
@ -132,7 +132,7 @@ impl Visuals {
} }
} }
#[derive(Clone, Copy, Debug)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Widgets { pub struct Widgets {
/// For an interactive widget that is being interacted with /// For an interactive widget that is being interacted with
@ -162,7 +162,7 @@ impl Widgets {
} }
/// bg = background, fg = foreground. /// bg = background, fg = foreground.
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct WidgetVisuals { pub struct WidgetVisuals {
/// Background color of widget /// Background color of widget
@ -291,7 +291,7 @@ use crate::{widgets::*, Ui};
impl Style { impl Style {
pub fn ui(&mut self, ui: &mut crate::Ui) { pub fn ui(&mut self, ui: &mut crate::Ui) {
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
*self = Default::default(); *self = Default::default();
} }
@ -317,7 +317,7 @@ impl Style {
impl Spacing { impl Spacing {
pub fn ui(&mut self, ui: &mut crate::Ui) { pub fn ui(&mut self, ui: &mut crate::Ui) {
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
*self = Default::default(); *self = Default::default();
} }
@ -346,7 +346,7 @@ impl Spacing {
impl Interaction { impl Interaction {
pub fn ui(&mut self, ui: &mut crate::Ui) { pub fn ui(&mut self, ui: &mut crate::Ui) {
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
*self = Default::default(); *self = Default::default();
} }
@ -364,7 +364,7 @@ impl Interaction {
impl Widgets { impl Widgets {
pub fn ui(&mut self, ui: &mut crate::Ui) { pub fn ui(&mut self, ui: &mut crate::Ui) {
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
*self = Default::default(); *self = Default::default();
} }
@ -404,7 +404,7 @@ impl WidgetVisuals {
impl Visuals { impl Visuals {
pub fn ui(&mut self, ui: &mut crate::Ui) { pub fn ui(&mut self, ui: &mut crate::Ui) {
if ui.add(Button::new("Reset")).clicked { if ui.button("Reset").clicked {
*self = Default::default(); *self = Default::default();
} }
@ -428,11 +428,8 @@ impl Visuals {
ui.add(Slider::f32(text_cursor_width, 0.0..=2.0).text("text_cursor_width")); ui.add(Slider::f32(text_cursor_width, 0.0..=2.0).text("text_cursor_width"));
ui.add(Slider::f32(clip_rect_margin, 0.0..=20.0).text("clip_rect_margin")); ui.add(Slider::f32(clip_rect_margin, 0.0..=20.0).text("clip_rect_margin"));
ui.add(Checkbox::new( ui.checkbox(debug_widget_rects, "Paint debug rectangles around widgets");
debug_widget_rects, ui.checkbox(debug_resize, "Debug Resize");
"Paint debug rectangles around widgets",
));
ui.add(Checkbox::new(debug_resize, "Debug Resize"));
} }
} }

8
egui/src/ui.rs

@ -146,18 +146,26 @@ impl Ui {
self.painter().layer() self.painter().layer()
} }
/// The `Input` of the `Context` associated with the `Ui`.
/// Equivalent to `.ctx().input()`.
pub fn input(&self) -> &InputState { pub fn input(&self) -> &InputState {
self.ctx().input() self.ctx().input()
} }
/// The `Memory` of the `Context` associated with the `Ui`.
/// Equivalent to `.ctx().memory()`.
pub fn memory(&self) -> parking_lot::MutexGuard<'_, Memory> { pub fn memory(&self) -> parking_lot::MutexGuard<'_, Memory> {
self.ctx().memory() self.ctx().memory()
} }
/// The `Output` of the `Context` associated with the `Ui`.
/// Equivalent to `.ctx().output()`.
pub fn output(&self) -> parking_lot::MutexGuard<'_, Output> { pub fn output(&self) -> parking_lot::MutexGuard<'_, Output> {
self.ctx().output() self.ctx().output()
} }
/// The `Fonts` of the `Context` associated with the `Ui`.
/// Equivalent to `.ctx().fonts()`.
pub fn fonts(&self) -> &Fonts { pub fn fonts(&self) -> &Fonts {
self.ctx().fonts() self.ctx().fonts()
} }

Loading…
Cancel
Save