Merge remote-tracking branch 'egui/master' into dynamic-grid
This commit is contained in:
commit
67ebb6bde6
8 changed files with 133 additions and 110 deletions
14
.github/workflows/rust.yml
vendored
14
.github/workflows/rust.yml
vendored
|
@ -56,6 +56,20 @@ jobs:
|
||||||
command: check
|
command: check
|
||||||
args: -p egui_demo_app --lib --target wasm32-unknown-unknown
|
args: -p egui_demo_app --lib --target wasm32-unknown-unknown
|
||||||
|
|
||||||
|
check_wasm_eframe_with_features:
|
||||||
|
name: cargo check wasm eframe
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: 1.56.0
|
||||||
|
override: true
|
||||||
|
- run: rustup target add wasm32-unknown-unknown
|
||||||
|
- name: check
|
||||||
|
run: cargo check -p eframe --lib --no-default-features --features egui_glow,persistence --target wasm32-unknown-unknown
|
||||||
|
|
||||||
check_web_all_features:
|
check_web_all_features:
|
||||||
name: cargo check web --all-features
|
name: cargo check web --all-features
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -5,7 +5,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
|
||||||
|
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
* Fixed ComboBoxes always being rendered left-aligned ([1304](https://github.com/emilk/egui/pull/1304))
|
||||||
|
|
||||||
## 0.17.0 - 2022-02-22 - Improved font selection and image handling
|
## 0.17.0 - 2022-02-22 - Improved font selection and image handling
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ NOTE: [`egui_web`](../egui_web/CHANGELOG.md), [`egui-winit`](../egui-winit/CHANG
|
||||||
|
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
* Change default for `NativeOptions::drag_and_drop_support` to `true` ([#1329](https://github.com/emilk/egui/pull/1329))
|
||||||
|
|
||||||
|
|
||||||
## 0.17.0 - 2022-02-22
|
## 0.17.0 - 2022-02-22
|
||||||
|
|
|
@ -231,7 +231,7 @@ fn button_frame(
|
||||||
outer_rect.set_height(outer_rect.height().at_least(interact_size.y));
|
outer_rect.set_height(outer_rect.height().at_least(interact_size.y));
|
||||||
|
|
||||||
let inner_rect = outer_rect.shrink2(margin);
|
let inner_rect = outer_rect.shrink2(margin);
|
||||||
let mut content_ui = ui.child_ui(inner_rect, Layout::left_to_right());
|
let mut content_ui = ui.child_ui(inner_rect, *ui.layout());
|
||||||
add_contents(&mut content_ui);
|
add_contents(&mut content_ui);
|
||||||
|
|
||||||
let mut outer_rect = content_ui.min_rect().expand2(margin);
|
let mut outer_rect = content_ui.min_rect().expand2(margin);
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
This is a crate that adds some features on top top of [`egui`](https://github.com/emilk/egui). This crate are for experimental features, and features that require big dependencies that does not belong in `egui`.
|
This is a crate that adds some features on top top of [`egui`](https://github.com/emilk/egui). This crate is for experimental features, and features that require big dependencies that do not belong in `egui`.
|
||||||
|
|
|
@ -88,114 +88,27 @@
|
||||||
#![allow(clippy::manual_range_contains)]
|
#![allow(clippy::manual_range_contains)]
|
||||||
|
|
||||||
pub mod painter;
|
pub mod painter;
|
||||||
#[cfg(feature = "winit")]
|
|
||||||
use egui_winit::winit;
|
|
||||||
pub use glow;
|
pub use glow;
|
||||||
pub use painter::Painter;
|
pub use painter::Painter;
|
||||||
#[cfg(feature = "winit")]
|
|
||||||
mod epi_backend;
|
|
||||||
mod misc_util;
|
mod misc_util;
|
||||||
mod post_process;
|
mod post_process;
|
||||||
mod shader_version;
|
mod shader_version;
|
||||||
mod vao_emulate;
|
mod vao_emulate;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(all(not(target_arch = "wasm32"), feature = "winit"))]
|
||||||
#[cfg(feature = "egui_winit")]
|
pub mod winit;
|
||||||
pub use egui_winit;
|
#[cfg(all(not(target_arch = "wasm32"), feature = "winit"))]
|
||||||
|
pub use winit::*;
|
||||||
|
|
||||||
#[cfg(all(feature = "epi", feature = "winit"))]
|
#[cfg(all(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
feature = "persistence",
|
||||||
|
feature = "winit"
|
||||||
|
))]
|
||||||
|
mod epi_backend;
|
||||||
|
#[cfg(all(
|
||||||
|
not(target_arch = "wasm32"),
|
||||||
|
feature = "persistence",
|
||||||
|
feature = "winit"
|
||||||
|
))]
|
||||||
pub use epi_backend::{run, NativeOptions};
|
pub use epi_backend::{run, NativeOptions};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/// Use [`egui`] from a [`glow`] app.
|
|
||||||
#[cfg(feature = "winit")]
|
|
||||||
pub struct EguiGlow {
|
|
||||||
pub egui_ctx: egui::Context,
|
|
||||||
pub egui_winit: egui_winit::State,
|
|
||||||
pub painter: crate::Painter,
|
|
||||||
|
|
||||||
shapes: Vec<egui::epaint::ClippedShape>,
|
|
||||||
textures_delta: egui::TexturesDelta,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "winit")]
|
|
||||||
impl EguiGlow {
|
|
||||||
pub fn new(window: &winit::window::Window, gl: &glow::Context) -> Self {
|
|
||||||
let painter = crate::Painter::new(gl, None, "")
|
|
||||||
.map_err(|error| {
|
|
||||||
tracing::error!("error occurred in initializing painter:\n{}", error);
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
Self {
|
|
||||||
egui_ctx: Default::default(),
|
|
||||||
egui_winit: egui_winit::State::new(painter.max_texture_side(), window),
|
|
||||||
painter,
|
|
||||||
shapes: Default::default(),
|
|
||||||
textures_delta: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `true` if egui wants exclusive use of this event
|
|
||||||
/// (e.g. a mouse click on an egui window, or entering text into a text field).
|
|
||||||
/// For instance, if you use egui for a game, you want to first call this
|
|
||||||
/// and only when this returns `false` pass on the events to your game.
|
|
||||||
///
|
|
||||||
/// Note that egui uses `tab` to move focus between elements, so this will always return `true` for tabs.
|
|
||||||
pub fn on_event(&mut self, event: &winit::event::WindowEvent<'_>) -> bool {
|
|
||||||
self.egui_winit.on_event(&self.egui_ctx, event)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns `true` if egui requests a repaint.
|
|
||||||
///
|
|
||||||
/// Call [`Self::paint`] later to paint.
|
|
||||||
pub fn run(
|
|
||||||
&mut self,
|
|
||||||
window: &winit::window::Window,
|
|
||||||
run_ui: impl FnMut(&egui::Context),
|
|
||||||
) -> bool {
|
|
||||||
let raw_input = self.egui_winit.take_egui_input(window);
|
|
||||||
let egui::FullOutput {
|
|
||||||
platform_output,
|
|
||||||
needs_repaint,
|
|
||||||
textures_delta,
|
|
||||||
shapes,
|
|
||||||
} = self.egui_ctx.run(raw_input, run_ui);
|
|
||||||
|
|
||||||
self.egui_winit
|
|
||||||
.handle_platform_output(window, &self.egui_ctx, platform_output);
|
|
||||||
|
|
||||||
self.shapes = shapes;
|
|
||||||
self.textures_delta.append(textures_delta);
|
|
||||||
needs_repaint
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Paint the results of the last call to [`Self::run`].
|
|
||||||
pub fn paint(&mut self, window: &winit::window::Window, gl: &glow::Context) {
|
|
||||||
let shapes = std::mem::take(&mut self.shapes);
|
|
||||||
let mut textures_delta = std::mem::take(&mut self.textures_delta);
|
|
||||||
|
|
||||||
for (id, image_delta) in textures_delta.set {
|
|
||||||
self.painter.set_texture(gl, id, &image_delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
let clipped_meshes = self.egui_ctx.tessellate(shapes);
|
|
||||||
let dimensions: [u32; 2] = window.inner_size().into();
|
|
||||||
self.painter.paint_meshes(
|
|
||||||
gl,
|
|
||||||
dimensions,
|
|
||||||
self.egui_ctx.pixels_per_point(),
|
|
||||||
clipped_meshes,
|
|
||||||
);
|
|
||||||
|
|
||||||
for id in textures_delta.free.drain(..) {
|
|
||||||
self.painter.free_texture(gl, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Call to release the allocated graphics resources.
|
|
||||||
pub fn destroy(&mut self, gl: &glow::Context) {
|
|
||||||
self.painter.destroy(gl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
92
egui_glow/src/winit.rs
Normal file
92
egui_glow/src/winit.rs
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
pub use egui_winit;
|
||||||
|
use egui_winit::winit;
|
||||||
|
|
||||||
|
/// Use [`egui`] from a [`glow`] app.
|
||||||
|
pub struct EguiGlow {
|
||||||
|
pub egui_ctx: egui::Context,
|
||||||
|
pub egui_winit: egui_winit::State,
|
||||||
|
pub painter: crate::Painter,
|
||||||
|
|
||||||
|
shapes: Vec<egui::epaint::ClippedShape>,
|
||||||
|
textures_delta: egui::TexturesDelta,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EguiGlow {
|
||||||
|
pub fn new(window: &winit::window::Window, gl: &glow::Context) -> Self {
|
||||||
|
let painter = crate::Painter::new(gl, None, "")
|
||||||
|
.map_err(|error| {
|
||||||
|
tracing::error!("error occurred in initializing painter:\n{}", error);
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
Self {
|
||||||
|
egui_ctx: Default::default(),
|
||||||
|
egui_winit: egui_winit::State::new(painter.max_texture_side(), window),
|
||||||
|
painter,
|
||||||
|
shapes: Default::default(),
|
||||||
|
textures_delta: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if egui wants exclusive use of this event
|
||||||
|
/// (e.g. a mouse click on an egui window, or entering text into a text field).
|
||||||
|
/// For instance, if you use egui for a game, you want to first call this
|
||||||
|
/// and only when this returns `false` pass on the events to your game.
|
||||||
|
///
|
||||||
|
/// Note that egui uses `tab` to move focus between elements, so this will always return `true` for tabs.
|
||||||
|
pub fn on_event(&mut self, event: &winit::event::WindowEvent<'_>) -> bool {
|
||||||
|
self.egui_winit.on_event(&self.egui_ctx, event)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if egui requests a repaint.
|
||||||
|
///
|
||||||
|
/// Call [`Self::paint`] later to paint.
|
||||||
|
pub fn run(
|
||||||
|
&mut self,
|
||||||
|
window: &winit::window::Window,
|
||||||
|
run_ui: impl FnMut(&egui::Context),
|
||||||
|
) -> bool {
|
||||||
|
let raw_input = self.egui_winit.take_egui_input(window);
|
||||||
|
let egui::FullOutput {
|
||||||
|
platform_output,
|
||||||
|
needs_repaint,
|
||||||
|
textures_delta,
|
||||||
|
shapes,
|
||||||
|
} = self.egui_ctx.run(raw_input, run_ui);
|
||||||
|
|
||||||
|
self.egui_winit
|
||||||
|
.handle_platform_output(window, &self.egui_ctx, platform_output);
|
||||||
|
|
||||||
|
self.shapes = shapes;
|
||||||
|
self.textures_delta.append(textures_delta);
|
||||||
|
needs_repaint
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Paint the results of the last call to [`Self::run`].
|
||||||
|
pub fn paint(&mut self, window: &winit::window::Window, gl: &glow::Context) {
|
||||||
|
let shapes = std::mem::take(&mut self.shapes);
|
||||||
|
let mut textures_delta = std::mem::take(&mut self.textures_delta);
|
||||||
|
|
||||||
|
for (id, image_delta) in textures_delta.set {
|
||||||
|
self.painter.set_texture(gl, id, &image_delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
let clipped_meshes = self.egui_ctx.tessellate(shapes);
|
||||||
|
let dimensions: [u32; 2] = window.inner_size().into();
|
||||||
|
self.painter.paint_meshes(
|
||||||
|
gl,
|
||||||
|
dimensions,
|
||||||
|
self.egui_ctx.pixels_per_point(),
|
||||||
|
clipped_meshes,
|
||||||
|
);
|
||||||
|
|
||||||
|
for id in textures_delta.free.drain(..) {
|
||||||
|
self.painter.free_texture(gl, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Call to release the allocated graphics resources.
|
||||||
|
pub fn destroy(&mut self, gl: &glow::Context) {
|
||||||
|
self.painter.destroy(gl);
|
||||||
|
}
|
||||||
|
}
|
|
@ -221,10 +221,13 @@ pub struct NativeOptions {
|
||||||
/// If false it will be difficult to move and resize the app.
|
/// If false it will be difficult to move and resize the app.
|
||||||
pub decorated: bool,
|
pub decorated: bool,
|
||||||
|
|
||||||
/// On Windows: enable drag and drop support.
|
/// On Windows: enable drag and drop support. Drag and drop can
|
||||||
/// Default is `false` to avoid issues with crates such as [`cpal`](https://github.com/RustAudio/cpal) which
|
/// not be disabled on other platforms.
|
||||||
/// will hang when combined with drag-and-drop.
|
///
|
||||||
/// See <https://github.com/rust-windowing/winit/issues/1255>.
|
/// See [winit's documentation][drag_and_drop] for information on why you
|
||||||
|
/// might want to disable this on windows.
|
||||||
|
///
|
||||||
|
/// [drag_and_drop]: https://docs.rs/winit/latest/x86_64-pc-windows-msvc/winit/platform/windows/trait.WindowBuilderExtWindows.html#tymethod.with_drag_and_drop
|
||||||
pub drag_and_drop_support: bool,
|
pub drag_and_drop_support: bool,
|
||||||
|
|
||||||
/// The application icon, e.g. in the Windows task bar etc.
|
/// The application icon, e.g. in the Windows task bar etc.
|
||||||
|
@ -257,7 +260,7 @@ impl Default for NativeOptions {
|
||||||
always_on_top: false,
|
always_on_top: false,
|
||||||
maximized: false,
|
maximized: false,
|
||||||
decorated: true,
|
decorated: true,
|
||||||
drag_and_drop_support: false,
|
drag_and_drop_support: true,
|
||||||
icon_data: None,
|
icon_data: None,
|
||||||
initial_window_pos: None,
|
initial_window_pos: None,
|
||||||
initial_window_size: None,
|
initial_window_size: None,
|
||||||
|
|
Loading…
Reference in a new issue