mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 23:00:04 -04:00
Is creating a window
This commit is contained in:
@@ -6,7 +6,7 @@ use epaint::*;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Hash, PartialEq, Clone, Default)]
|
||||
#[derive(Hash, PartialEq, Clone)]
|
||||
pub struct WindowBuilder {
|
||||
pub title: String,
|
||||
pub name: Option<String>,
|
||||
@@ -28,6 +28,31 @@ pub struct WindowBuilder {
|
||||
pub drag_and_drop: bool,
|
||||
}
|
||||
|
||||
impl Default for WindowBuilder {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
title: "Dummy EGUI Window".into(),
|
||||
name: None,
|
||||
position: None,
|
||||
inner_size: Some((600, 500)),
|
||||
fullscreen: false,
|
||||
maximized: false,
|
||||
resizable: true,
|
||||
transparent: false,
|
||||
decorations: true,
|
||||
icon: None,
|
||||
active: true,
|
||||
visible: true,
|
||||
title_hidden: false,
|
||||
titlebar_transparent: false,
|
||||
fullsize_content_view: false,
|
||||
min_inner_size: None,
|
||||
max_inner_size: None,
|
||||
drag_and_drop: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowBuilder {
|
||||
pub fn with_title(mut self, title: impl Into<String>) -> Self {
|
||||
self.title = title.into();
|
||||
@@ -396,8 +421,8 @@ impl<'open> Window<'open> {
|
||||
ctx: &Context,
|
||||
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
|
||||
) -> Option<InnerResponse<Option<R>>> {
|
||||
let window_id =
|
||||
ctx.data_mut(|data| *data.get_temp_mut_or(self.area.id.with("window_id"), 0));
|
||||
let window_id = ctx.create_window(WindowBuilder::default().with_title(self.title.text()));
|
||||
println!("Window id: {}", window_id);
|
||||
let Window {
|
||||
title,
|
||||
open,
|
||||
|
||||
@@ -1268,10 +1268,10 @@ impl Context {
|
||||
let repaint_after = self.write(|ctx| ctx.repaint.end_frame());
|
||||
let shapes = self.drain_paint_lists();
|
||||
|
||||
let windows = self.write(|ctx| {
|
||||
let windows = self.read(|ctx| {
|
||||
ctx.windows
|
||||
.drain()
|
||||
.map(|(_, (builder, id, _))| (id, builder))
|
||||
.iter()
|
||||
.map(|(_, (builder, id, _))| (*id, builder.clone()))
|
||||
.collect()
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user