diff --git a/crates/egui/src/containers/resize.rs b/crates/egui/src/containers/resize.rs index dde100c26c9..94cfb638b01 100644 --- a/crates/egui/src/containers/resize.rs +++ b/crates/egui/src/containers/resize.rs @@ -1,400 +1,2564 @@ -use crate::*; - -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] -pub(crate) struct State { - /// This is the size that the user has picked by dragging the resize handles. - /// This may be smaller and/or larger than the actual size. - /// For instance, the user may have tried to shrink too much (not fitting the contents). - /// Or the user requested a large area, but the content don't need that much space. - pub(crate) desired_size: Vec2, - - /// Actual size of content last frame - pub(crate) last_content_size: Vec2, - - /// Externally requested size (e.g. by Window) for the next frame - pub(crate) requested_size: Option, +#![warn(missing_docs)] // Let's keep `Ui` well-documented. +#![allow(clippy::use_self)] + +use std::{any::Any, hash::Hash, sync::Arc}; + +use epaint::mutex::RwLock; + +use crate::{ + containers::*, ecolor::*, epaint::text::Fonts, layout::*, menu::MenuState, placer::Placer, + util::IdTypeMap, widgets::*, *, +}; + +// ---------------------------------------------------------------------------- + +/// This is what you use to place widgets. +/// +/// Represents a region of the screen with a type of layout (horizontal or vertical). +/// +/// ``` +/// # egui::__run_test_ui(|ui| { +/// ui.add(egui::Label::new("Hello World!")); +/// ui.label("A shorter and more convenient way to add a label."); +/// ui.horizontal(|ui| { +/// ui.label("Add widgets"); +/// if ui.button("on the same row!").clicked() { +/// /* … */ +/// } +/// }); +/// # }); +/// ``` +pub struct Ui { + /// ID of this ui. + /// + /// Generated based on id of parent ui together with + /// another source of child identity (e.g. window title). + /// Acts like a namespace for child uis. + /// Should be unique and persist predictably from one frame to next + /// so it can be used as a source for storing state (e.g. window position, or if a collapsing header is open). + id: Id, + + /// This is used to create a unique interact ID for some widgets. + /// + /// This value is based on where in the hierarchy of widgets this Ui is in, + /// and the value is increment with each added child widget. + /// This works as an Id source only as long as new widgets aren't added or removed. + /// They are therefore only good for Id:s that has no state. + next_auto_id_source: u64, + + /// Specifies paint layer, clip rectangle and a reference to [`Context`]. + painter: Painter, + + /// The [`Style`] (visuals, spacing, etc) of this ui. + /// Commonly many [`Ui`]:s share the same [`Style`]. + /// The [`Ui`] implements copy-on-write for this. + style: Arc