1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

add Deref for Ui

This commit is contained in:
obellish
2024-02-19 07:12:53 -05:00
parent 68b3ef7f6b
commit 38991de6b1
2 changed files with 10 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ use epaint::{
#[derive(Clone)] #[derive(Clone)]
pub struct Painter { pub struct Painter {
/// Source of fonts and destination of shapes /// Source of fonts and destination of shapes
ctx: Context, pub(crate) ctx: Context,
/// Where we paint /// Where we paint
layer_id: LayerId, layer_id: LayerId,

View File

@@ -1,7 +1,7 @@
#![warn(missing_docs)] // Let's keep `Ui` well-documented. #![warn(missing_docs)] // Let's keep `Ui` well-documented.
#![allow(clippy::use_self)] #![allow(clippy::use_self)]
use std::{any::Any, hash::Hash, sync::Arc}; use std::{any::Any, hash::Hash, ops::Deref, sync::Arc};
use epaint::mutex::RwLock; use epaint::mutex::RwLock;
@@ -2320,6 +2320,14 @@ impl Ui {
} }
} }
impl Deref for Ui {
type Target = Context;
fn deref(&self) -> &Self::Target {
self.ctx()
}
}
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
impl Drop for Ui { impl Drop for Ui {
fn drop(&mut self) { fn drop(&mut self) {