mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Simplify
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -27,16 +27,7 @@ impl eframe::App for MyApp {
|
||||
self.allowed_to_close
|
||||
}
|
||||
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Try to close the window");
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
|
||||
use egui::mutex::Mutex;
|
||||
use std::sync::Arc;
|
||||
@@ -41,16 +41,7 @@ impl MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.spacing_mut().item_spacing.x = 0.0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -60,16 +60,7 @@ impl MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("egui using custom fonts");
|
||||
ui.text_edit_multiline(&mut self.text);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
use egui::{FontFamily, FontId, RichText, TextStyle};
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
@@ -64,16 +64,7 @@ impl MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -30,16 +30,7 @@ impl eframe::App for MyApp {
|
||||
egui::Rgba::TRANSPARENT.to_array() // Make sure we don't paint anything behind the rounded corners
|
||||
}
|
||||
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
custom_window_frame(ctx, frame, "egui with custom frame", |ui| {
|
||||
ui.label("This is just the contents of the window.");
|
||||
ui.horizontal(|ui| {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
use egui_extras::RetainedImage;
|
||||
use poll_promise::Promise;
|
||||
|
||||
@@ -21,16 +21,7 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
let promise = self.promise.get_or_insert_with(|| {
|
||||
// Begin download.
|
||||
// We download the image using `ehttp`, a library that works both in WASM and on native.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -23,16 +23,7 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.label("Drag-and-drop files onto the window!");
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -30,12 +30,7 @@ impl Default for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
_: Option<&ViewportRender>,
|
||||
) {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("My egui Application");
|
||||
ui.horizontal(|ui| {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use std::sync::mpsc;
|
||||
use std::thread::JoinHandle;
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -115,12 +115,7 @@ impl std::ops::Drop for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
_: Option<&ViewportRender>,
|
||||
) {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::Window::new("Main thread").show(ctx, |ui| {
|
||||
if ui.button("Spawn another thread").clicked() {
|
||||
self.spawn_thread();
|
||||
|
||||
@@ -19,16 +19,7 @@ struct Content {
|
||||
}
|
||||
|
||||
impl eframe::App for Content {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Press/Hold/Release example. Press A to test.");
|
||||
if ui.button("Clear").clicked() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui::{self};
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -17,16 +17,7 @@ fn main() -> Result<(), eframe::Error> {
|
||||
struct MyApp {}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Example of how to use the puffin profiler with egui");
|
||||
ui.separator();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui::{self};
|
||||
use egui_extras::RetainedImage;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
@@ -34,17 +34,7 @@ impl Default for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
let Self {
|
||||
image,
|
||||
rounding,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::ColorImage;
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui::{self};
|
||||
use egui_plot::{Legend, Line, Plot, PlotPoints};
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
@@ -24,16 +24,7 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
let mut plot_rect = None;
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
// these are just some dummy variables for the example,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ColorImage, ViewportRender};
|
||||
use eframe::egui::{self, ColorImage};
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -24,16 +24,7 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
if let Some(screenshot) = self.screenshot.take() {
|
||||
self.texture = Some(ui.ctx().load_texture(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui::{self};
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -46,16 +46,7 @@ struct MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
let label_text = if self.has_next {
|
||||
"When this window is closed the next will be opened after a short delay"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui::{self, ViewportRender};
|
||||
use eframe::egui;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -37,16 +37,7 @@ impl Default for MyApp {
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("SVG example");
|
||||
ui.label("The SVG is rasterized and displayed as a texture.");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use eframe::{
|
||||
egui::{Button, CentralPanel, Context, UserAttentionType, ViewportRender},
|
||||
egui::{Button, CentralPanel, Context, UserAttentionType},
|
||||
CreationContext, NativeOptions,
|
||||
};
|
||||
|
||||
@@ -54,16 +54,7 @@ impl Application {
|
||||
}
|
||||
|
||||
impl eframe::App for Application {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &Context,
|
||||
frame: &mut eframe::Frame,
|
||||
render: Option<&ViewportRender>,
|
||||
) {
|
||||
if let Some(render) = render {
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
fn update(&mut self, ctx: &Context, frame: &mut eframe::Frame) {
|
||||
if let Some(request_at) = self.request_at {
|
||||
if request_at < SystemTime::now() {
|
||||
self.request_at = None;
|
||||
|
||||
@@ -32,19 +32,7 @@ pub struct App {
|
||||
}
|
||||
|
||||
impl eframe::App for App {
|
||||
fn update(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &mut eframe::Frame,
|
||||
render_function: Option<&egui::ViewportRender>,
|
||||
) {
|
||||
// This needs to be like this to be able to show stuf on a async viewport
|
||||
if let Some(render) = render_function {
|
||||
// This is the render function for the current async viewport
|
||||
render(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui_info(ui);
|
||||
ui.label("Look at the \"Frame: \" will tell you, what viewport is rendering!");
|
||||
|
||||
Reference in New Issue
Block a user