Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7215fdfb7c | ||
![]() |
e2778d9d6a | ||
![]() |
38849fe381 | ||
![]() |
df7e5bd57a | ||
![]() |
e3e781ced8 | ||
![]() |
97756bc246 | ||
![]() |
f71d79a0ff | ||
![]() |
95247daa17 | ||
![]() |
530e9f667c | ||
![]() |
409fb968d3 | ||
![]() |
1581f0229e |
35 changed files with 172 additions and 33 deletions
6
.cargo/config.toml
Normal file
6
.cargo/config.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# clipboard api is still unstable, so web-sys requires the below flag to be passed for copy (ctrl + c) to work
|
||||||
|
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
|
||||||
|
# check status at https://developer.mozilla.org/en-US/docs/Web/API/Clipboard#browser_compatibility
|
||||||
|
# we don't use `[build]` because of rust analyzer's build cache invalidation https://github.com/emilk/eframe_template/issues/93
|
||||||
|
[target.wasm32-unknown-unknown]
|
||||||
|
rustflags = ["--cfg=web_sys_unstable_apis"]
|
12
.github/workflows/rust.yml
vendored
12
.github/workflows/rust.yml
vendored
|
@ -47,24 +47,30 @@ jobs:
|
||||||
with:
|
with:
|
||||||
crate: cargo-cranky
|
crate: cargo-cranky
|
||||||
|
|
||||||
- name: Check all features
|
- name: check --all-features
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: check
|
command: check
|
||||||
args: --locked --all-features --all-targets
|
args: --locked --all-features --all-targets
|
||||||
|
|
||||||
- name: Check default features
|
- name: check default features
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: check
|
command: check
|
||||||
args: --locked --all-targets
|
args: --locked --all-targets
|
||||||
|
|
||||||
- name: Check no default features
|
- name: check --no-default-features
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: check
|
command: check
|
||||||
args: --locked --no-default-features --lib --all-targets
|
args: --locked --no-default-features --lib --all-targets
|
||||||
|
|
||||||
|
- name: check eframe --no-default-features
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
args: --locked --no-default-features --lib --all-targets -p eframe
|
||||||
|
|
||||||
- name: Test doc-tests
|
- name: Test doc-tests
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
|
|
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1218,7 +1218,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "eframe"
|
name = "eframe"
|
||||||
version = "0.21.0"
|
version = "0.21.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"dark-light",
|
"dark-light",
|
||||||
|
@ -1279,7 +1279,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui-winit"
|
name = "egui-winit"
|
||||||
version = "0.21.0"
|
version = "0.21.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit_winit",
|
"accesskit_winit",
|
||||||
"android-activity",
|
"android-activity",
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
# ecolor - egui color library
|
# ecolor - egui color library
|
||||||
|
|
||||||
|
[](https://crates.io/crates/ecolor)
|
||||||
|
[](https://docs.rs/ecolor)
|
||||||
|
[](https://github.com/rust-secure-code/safety-dance/)
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
A simple color storage and conversion library.
|
A simple color storage and conversion library.
|
||||||
|
|
||||||
Made for [`egui`](https://github.com/emilk/egui/).
|
Made for [`egui`](https://github.com/emilk/egui/).
|
||||||
|
|
|
@ -7,6 +7,18 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
|
||||||
|
## 0.21.3 - 2023-02-15
|
||||||
|
* Fix typing the letter 'P' on web ([#2740](https://github.com/emilk/egui/pull/2740)).
|
||||||
|
|
||||||
|
|
||||||
|
## 0.21.2 - 2023-02-12
|
||||||
|
* Allow compiling `eframe` with `--no-default-features` ([#2728](https://github.com/emilk/egui/pull/2728)).
|
||||||
|
|
||||||
|
|
||||||
|
## 0.21.1 - 2023-02-12
|
||||||
|
* Fixed crash when native window position is in an invalid state, which could happen e.g. due to changes in monitor size or DPI ([#2722](https://github.com/emilk/egui/issues/2722)).
|
||||||
|
|
||||||
|
|
||||||
## 0.21.0 - 2023-02-08 - Update to `winit` 0.28
|
## 0.21.0 - 2023-02-08 - Update to `winit` 0.28
|
||||||
* ⚠️ BREAKING: `App::clear_color` now expects you to return a raw float array ([#2666](https://github.com/emilk/egui/pull/2666)).
|
* ⚠️ BREAKING: `App::clear_color` now expects you to return a raw float array ([#2666](https://github.com/emilk/egui/pull/2666)).
|
||||||
* The `screen_reader` feature has now been renamed `web_screen_reader` and only work on web. On other platforms, use the `accesskit` feature flag instead ([#2669](https://github.com/emilk/egui/pull/2669)).
|
* The `screen_reader` feature has now been renamed `web_screen_reader` and only work on web. On other platforms, use the `accesskit` feature flag instead ([#2669](https://github.com/emilk/egui/pull/2669)).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "eframe"
|
name = "eframe"
|
||||||
version = "0.21.0"
|
version = "0.21.3"
|
||||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||||
description = "egui framework - write GUI apps that compiles to web and/or natively"
|
description = "egui framework - write GUI apps that compiles to web and/or natively"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
@ -87,7 +87,7 @@ serde = { version = "1", optional = true, features = ["derive"] }
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# native:
|
# native:
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
egui-winit = { version = "0.21.0", path = "../egui-winit", default-features = false, features = [
|
egui-winit = { version = "0.21.1", path = "../egui-winit", default-features = false, features = [
|
||||||
"clipboard",
|
"clipboard",
|
||||||
"links",
|
"links",
|
||||||
] }
|
] }
|
||||||
|
|
|
@ -10,9 +10,11 @@
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
pub use crate::native::run::UserEvent;
|
pub use crate::native::run::UserEvent;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
pub use winit::event_loop::EventLoopBuilder;
|
pub use winit::event_loop::EventLoopBuilder;
|
||||||
|
|
||||||
/// Hook into the building of an event loop before it is run
|
/// Hook into the building of an event loop before it is run
|
||||||
|
@ -20,6 +22,7 @@ pub use winit::event_loop::EventLoopBuilder;
|
||||||
/// You can configure any platform specific details required on top of the default configuration
|
/// You can configure any platform specific details required on top of the default configuration
|
||||||
/// done by `EFrame`.
|
/// done by `EFrame`.
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
pub type EventLoopBuilderHook = Box<dyn FnOnce(&mut EventLoopBuilder<UserEvent>)>;
|
pub type EventLoopBuilderHook = Box<dyn FnOnce(&mut EventLoopBuilder<UserEvent>)>;
|
||||||
|
|
||||||
/// This is how your app is created.
|
/// This is how your app is created.
|
||||||
|
@ -317,6 +320,7 @@ pub struct NativeOptions {
|
||||||
pub hardware_acceleration: HardwareAcceleration,
|
pub hardware_acceleration: HardwareAcceleration,
|
||||||
|
|
||||||
/// What rendering backend to use.
|
/// What rendering backend to use.
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
pub renderer: Renderer,
|
pub renderer: Renderer,
|
||||||
|
|
||||||
/// Only used if the `dark-light` feature is enabled:
|
/// Only used if the `dark-light` feature is enabled:
|
||||||
|
@ -355,6 +359,7 @@ pub struct NativeOptions {
|
||||||
/// event loop before it is run.
|
/// event loop before it is run.
|
||||||
///
|
///
|
||||||
/// Note: A [`NativeOptions`] clone will not include any `event_loop_builder` hook.
|
/// Note: A [`NativeOptions`] clone will not include any `event_loop_builder` hook.
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
pub event_loop_builder: Option<EventLoopBuilderHook>,
|
pub event_loop_builder: Option<EventLoopBuilderHook>,
|
||||||
|
|
||||||
#[cfg(feature = "glow")]
|
#[cfg(feature = "glow")]
|
||||||
|
@ -381,9 +386,13 @@ impl Clone for NativeOptions {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
icon_data: self.icon_data.clone(),
|
icon_data: self.icon_data.clone(),
|
||||||
|
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
event_loop_builder: None, // Skip any builder callbacks if cloning
|
event_loop_builder: None, // Skip any builder callbacks if cloning
|
||||||
|
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
wgpu_options: self.wgpu_options.clone(),
|
wgpu_options: self.wgpu_options.clone(),
|
||||||
|
|
||||||
..*self
|
..*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,8 +406,10 @@ impl Default for NativeOptions {
|
||||||
maximized: false,
|
maximized: false,
|
||||||
decorated: true,
|
decorated: true,
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fullsize_content: false,
|
fullsize_content: false,
|
||||||
|
|
||||||
drag_and_drop_support: true,
|
drag_and_drop_support: true,
|
||||||
icon_data: None,
|
icon_data: None,
|
||||||
initial_window_pos: None,
|
initial_window_pos: None,
|
||||||
|
@ -413,14 +424,22 @@ impl Default for NativeOptions {
|
||||||
depth_buffer: 0,
|
depth_buffer: 0,
|
||||||
stencil_buffer: 0,
|
stencil_buffer: 0,
|
||||||
hardware_acceleration: HardwareAcceleration::Preferred,
|
hardware_acceleration: HardwareAcceleration::Preferred,
|
||||||
|
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
renderer: Renderer::default(),
|
renderer: Renderer::default(),
|
||||||
|
|
||||||
follow_system_theme: cfg!(target_os = "macos") || cfg!(target_os = "windows"),
|
follow_system_theme: cfg!(target_os = "macos") || cfg!(target_os = "windows"),
|
||||||
default_theme: Theme::Dark,
|
default_theme: Theme::Dark,
|
||||||
run_and_return: true,
|
run_and_return: true,
|
||||||
|
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
event_loop_builder: None,
|
event_loop_builder: None,
|
||||||
|
|
||||||
#[cfg(feature = "glow")]
|
#[cfg(feature = "glow")]
|
||||||
shader_version: None,
|
shader_version: None,
|
||||||
|
|
||||||
centered: false,
|
centered: false,
|
||||||
|
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
wgpu_options: egui_wgpu::WgpuConfiguration::default(),
|
wgpu_options: egui_wgpu::WgpuConfiguration::default(),
|
||||||
}
|
}
|
||||||
|
@ -559,6 +578,7 @@ pub enum WebGlContextOption {
|
||||||
/// What rendering backend to use.
|
/// What rendering backend to use.
|
||||||
///
|
///
|
||||||
/// You need to enable the "glow" and "wgpu" features to have a choice.
|
/// You need to enable the "glow" and "wgpu" features to have a choice.
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
||||||
|
@ -572,6 +592,7 @@ pub enum Renderer {
|
||||||
Wgpu,
|
Wgpu,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
impl Default for Renderer {
|
impl Default for Renderer {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
#[cfg(feature = "glow")]
|
#[cfg(feature = "glow")]
|
||||||
|
@ -587,6 +608,7 @@ impl Default for Renderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
impl std::fmt::Display for Renderer {
|
impl std::fmt::Display for Renderer {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
@ -599,6 +621,7 @@ impl std::fmt::Display for Renderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
impl std::str::FromStr for Renderer {
|
impl std::str::FromStr for Renderer {
|
||||||
type Err = String;
|
type Err = String;
|
||||||
|
|
||||||
|
@ -811,6 +834,7 @@ impl Frame {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// for integrations only: call once per frame
|
/// for integrations only: call once per frame
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
pub(crate) fn take_app_output(&mut self) -> backend::AppOutput {
|
pub(crate) fn take_app_output(&mut self) -> backend::AppOutput {
|
||||||
std::mem::take(&mut self.output)
|
std::mem::take(&mut self.output)
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,7 @@ pub async fn start_web(
|
||||||
// When compiling natively
|
// When compiling natively
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
mod native;
|
mod native;
|
||||||
|
|
||||||
/// This is how you start a native (desktop) app.
|
/// This is how you start a native (desktop) app.
|
||||||
|
@ -179,6 +180,7 @@ mod native;
|
||||||
/// This function can fail if we fail to set up a graphics context.
|
/// This function can fail if we fail to set up a graphics context.
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[allow(clippy::needless_pass_by_value)]
|
#[allow(clippy::needless_pass_by_value)]
|
||||||
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
pub fn run_native(
|
pub fn run_native(
|
||||||
app_name: &str,
|
app_name: &str,
|
||||||
native_options: NativeOptions,
|
native_options: NativeOptions,
|
||||||
|
@ -233,24 +235,28 @@ pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Profiling macro for feature "puffin"
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
macro_rules! profile_function {
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
|
mod profiling_scopes {
|
||||||
|
/// Profiling macro for feature "puffin"
|
||||||
|
macro_rules! profile_function {
|
||||||
($($arg: tt)*) => {
|
($($arg: tt)*) => {
|
||||||
#[cfg(feature = "puffin")]
|
#[cfg(feature = "puffin")]
|
||||||
puffin::profile_function!($($arg)*);
|
puffin::profile_function!($($arg)*);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
pub(crate) use profile_function;
|
||||||
pub(crate) use profile_function;
|
|
||||||
|
|
||||||
/// Profiling macro for feature "puffin"
|
/// Profiling macro for feature "puffin"
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
macro_rules! profile_scope {
|
||||||
macro_rules! profile_scope {
|
|
||||||
($($arg: tt)*) => {
|
($($arg: tt)*) => {
|
||||||
#[cfg(feature = "puffin")]
|
#[cfg(feature = "puffin")]
|
||||||
puffin::profile_scope!($($arg)*);
|
puffin::profile_scope!($($arg)*);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
pub(crate) use profile_scope;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub(crate) use profile_scope;
|
#[cfg(any(feature = "glow", feature = "wgpu"))]
|
||||||
|
pub(crate) use profiling_scopes::*;
|
||||||
|
|
|
@ -38,6 +38,7 @@ pub use epi::NativeOptions;
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum EventResult {
|
enum EventResult {
|
||||||
Wait,
|
Wait,
|
||||||
|
|
||||||
/// Causes a synchronous repaint inside the event handler. This should only
|
/// Causes a synchronous repaint inside the event handler. This should only
|
||||||
/// be used in special situations if the window must be repainted while
|
/// be used in special situations if the window must be repainted while
|
||||||
/// handling a specific event. This occurs on Windows when handling resizes.
|
/// handling a specific event. This occurs on Windows when handling resizes.
|
||||||
|
@ -45,20 +46,28 @@ enum EventResult {
|
||||||
/// `RepaintNow` creates a new frame synchronously, and should therefore
|
/// `RepaintNow` creates a new frame synchronously, and should therefore
|
||||||
/// only be used for extremely urgent repaints.
|
/// only be used for extremely urgent repaints.
|
||||||
RepaintNow,
|
RepaintNow,
|
||||||
|
|
||||||
/// Queues a repaint for once the event loop handles its next redraw. Exists
|
/// Queues a repaint for once the event loop handles its next redraw. Exists
|
||||||
/// so that multiple input events can be handled in one frame. Does not
|
/// so that multiple input events can be handled in one frame. Does not
|
||||||
/// cause any delay like `RepaintNow`.
|
/// cause any delay like `RepaintNow`.
|
||||||
RepaintNext,
|
RepaintNext,
|
||||||
|
|
||||||
RepaintAt(Instant),
|
RepaintAt(Instant),
|
||||||
|
|
||||||
Exit,
|
Exit,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait WinitApp {
|
trait WinitApp {
|
||||||
fn is_focused(&self) -> bool;
|
fn is_focused(&self) -> bool;
|
||||||
|
|
||||||
fn integration(&self) -> Option<&EpiIntegration>;
|
fn integration(&self) -> Option<&EpiIntegration>;
|
||||||
|
|
||||||
fn window(&self) -> Option<&winit::window::Window>;
|
fn window(&self) -> Option<&winit::window::Window>;
|
||||||
|
|
||||||
fn save_and_destroy(&mut self);
|
fn save_and_destroy(&mut self);
|
||||||
|
|
||||||
fn paint(&mut self) -> EventResult;
|
fn paint(&mut self) -> EventResult;
|
||||||
|
|
||||||
fn on_event(
|
fn on_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
event_loop: &EventLoopWindowTarget<UserEvent>,
|
event_loop: &EventLoopWindowTarget<UserEvent>,
|
||||||
|
|
|
@ -466,6 +466,7 @@ impl EventToUnsubscribe {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AppRunnerContainer {
|
pub struct AppRunnerContainer {
|
||||||
pub runner: AppRunnerRef,
|
pub runner: AppRunnerRef,
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,12 @@ pub fn install_document_events(runner_container: &mut AppRunnerContainer) -> Res
|
||||||
// egui wants to use tab to move to the next text field.
|
// egui wants to use tab to move to the next text field.
|
||||||
true
|
true
|
||||||
} else if egui_key == Some(Key::P) {
|
} else if egui_key == Some(Key::P) {
|
||||||
true // Prevent ctrl-P opening the print dialog. Users may want to use it for a command palette.
|
#[allow(clippy::needless_bool)]
|
||||||
|
if modifiers.ctrl || modifiers.command || modifiers.mac_cmd {
|
||||||
|
true // Prevent ctrl-P opening the print dialog. Users may want to use it for a command palette.
|
||||||
|
} else {
|
||||||
|
false // let normal P:s through
|
||||||
|
}
|
||||||
} else if egui_wants_keyboard {
|
} else if egui_wants_keyboard {
|
||||||
matches!(
|
matches!(
|
||||||
event.key().as_str(),
|
event.key().as_str(),
|
||||||
|
|
|
@ -105,11 +105,13 @@ pub enum WgpuError {
|
||||||
DeviceError(wgpu::RequestDeviceError),
|
DeviceError(wgpu::RequestDeviceError),
|
||||||
SurfaceError(wgpu::CreateSurfaceError),
|
SurfaceError(wgpu::CreateSurfaceError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for WgpuError {
|
impl std::fmt::Display for WgpuError {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Debug::fmt(self, f)
|
std::fmt::Debug::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::error::Error for WgpuError {
|
impl std::error::Error for WgpuError {
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||||
match self {
|
match self {
|
||||||
|
@ -118,11 +120,13 @@ impl std::error::Error for WgpuError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<wgpu::RequestDeviceError> for WgpuError {
|
impl From<wgpu::RequestDeviceError> for WgpuError {
|
||||||
fn from(e: wgpu::RequestDeviceError) -> Self {
|
fn from(e: wgpu::RequestDeviceError) -> Self {
|
||||||
Self::DeviceError(e)
|
Self::DeviceError(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<wgpu::CreateSurfaceError> for WgpuError {
|
impl From<wgpu::CreateSurfaceError> for WgpuError {
|
||||||
fn from(e: wgpu::CreateSurfaceError) -> Self {
|
fn from(e: wgpu::CreateSurfaceError) -> Self {
|
||||||
Self::SurfaceError(e)
|
Self::SurfaceError(e)
|
||||||
|
|
|
@ -5,6 +5,10 @@ All notable changes to the `egui-winit` integration will be noted in this file.
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
|
||||||
|
## 0.21.1 - 2023-02-12
|
||||||
|
* Fixed crash when window position is in an invalid state, which could happen e.g. due to changes in monitor size or DPI ([#2722](https://github.com/emilk/egui/issues/2722)).
|
||||||
|
|
||||||
|
|
||||||
## 0.21.0 - 2023-02-08
|
## 0.21.0 - 2023-02-08
|
||||||
* Fixed persistence of native window position on Windows OS ([#2583](https://github.com/emilk/egui/issues/2583)).
|
* Fixed persistence of native window position on Windows OS ([#2583](https://github.com/emilk/egui/issues/2583)).
|
||||||
* Update to `winit` 0.28, adding support for mac trackpad zoom ([#2654](https://github.com/emilk/egui/pull/2654)).
|
* Update to `winit` 0.28, adding support for mac trackpad zoom ([#2654](https://github.com/emilk/egui/pull/2654)).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "egui-winit"
|
name = "egui-winit"
|
||||||
version = "0.21.0"
|
version = "0.21.1"
|
||||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||||
description = "Bindings for using egui with winit"
|
description = "Bindings for using egui with winit"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
|
@ -60,6 +60,7 @@ pub struct State {
|
||||||
pointer_pos_in_points: Option<egui::Pos2>,
|
pointer_pos_in_points: Option<egui::Pos2>,
|
||||||
any_pointer_button_down: bool,
|
any_pointer_button_down: bool,
|
||||||
current_cursor_icon: Option<egui::CursorIcon>,
|
current_cursor_icon: Option<egui::CursorIcon>,
|
||||||
|
|
||||||
/// What egui uses.
|
/// What egui uses.
|
||||||
current_pixels_per_point: f32,
|
current_pixels_per_point: f32,
|
||||||
|
|
||||||
|
|
|
@ -128,15 +128,17 @@ impl WindowSettings {
|
||||||
active_monitor.position().x as f32,
|
active_monitor.position().x as f32,
|
||||||
active_monitor.position().y as f32,
|
active_monitor.position().y as f32,
|
||||||
);
|
);
|
||||||
let monitor_size = active_monitor.size();
|
let monitor_size = egui::Vec2::new(
|
||||||
*position = position.clamp(
|
active_monitor.size().width as f32,
|
||||||
monitor_position,
|
active_monitor.size().height as f32,
|
||||||
// To get the maximum position, we get the rightmost corner of the display, then subtract
|
|
||||||
// the size of the window to get the bottom right most value window.position can have.
|
|
||||||
monitor_position
|
|
||||||
+ egui::Vec2::new(monitor_size.width as f32, monitor_size.height as f32)
|
|
||||||
- inner_size_pixels,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Window size cannot be negative or the subsequent `clamp` will panic.
|
||||||
|
let window_size = (monitor_size - inner_size_pixels).max(egui::Vec2::ZERO);
|
||||||
|
// To get the maximum position, we get the rightmost corner of the display, then
|
||||||
|
// subtract the size of the window to get the bottom right most value window.position
|
||||||
|
// can have.
|
||||||
|
*position = position.clamp(monitor_position, monitor_position + window_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ pub(crate) struct AnimationManager {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct BoolAnim {
|
struct BoolAnim {
|
||||||
value: bool,
|
value: bool,
|
||||||
|
|
||||||
/// when did `value` last toggle?
|
/// when did `value` last toggle?
|
||||||
toggle_time: f64,
|
toggle_time: f64,
|
||||||
}
|
}
|
||||||
|
@ -16,7 +17,9 @@ struct BoolAnim {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct ValueAnim {
|
struct ValueAnim {
|
||||||
from_value: f32,
|
from_value: f32,
|
||||||
|
|
||||||
to_value: f32,
|
to_value: f32,
|
||||||
|
|
||||||
/// when did `value` last toggle?
|
/// when did `value` last toggle?
|
||||||
toggle_time: f64,
|
toggle_time: f64,
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,16 @@ use epaint::*;
|
||||||
pub struct Frame {
|
pub struct Frame {
|
||||||
/// Margin within the painted frame.
|
/// Margin within the painted frame.
|
||||||
pub inner_margin: Margin,
|
pub inner_margin: Margin,
|
||||||
|
|
||||||
/// Margin outside the painted frame.
|
/// Margin outside the painted frame.
|
||||||
pub outer_margin: Margin,
|
pub outer_margin: Margin,
|
||||||
|
|
||||||
pub rounding: Rounding,
|
pub rounding: Rounding,
|
||||||
|
|
||||||
pub shadow: Shadow,
|
pub shadow: Shadow,
|
||||||
|
|
||||||
pub fill: Color32,
|
pub fill: Color32,
|
||||||
|
|
||||||
pub stroke: Stroke,
|
pub stroke: Stroke,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct ContextImpl {
|
||||||
|
|
||||||
/// Written to during the frame.
|
/// Written to during the frame.
|
||||||
layer_rects_this_frame: ahash::HashMap<LayerId, Vec<(Id, Rect)>>,
|
layer_rects_this_frame: ahash::HashMap<LayerId, Vec<(Id, Rect)>>,
|
||||||
|
|
||||||
/// Read
|
/// Read
|
||||||
layer_rects_prev_frame: ahash::HashMap<LayerId, Vec<(Id, Rect)>>,
|
layer_rects_prev_frame: ahash::HashMap<LayerId, Vec<(Id, Rect)>>,
|
||||||
|
|
||||||
|
|
|
@ -447,8 +447,10 @@ impl InputState {
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub(crate) struct Click {
|
pub(crate) struct Click {
|
||||||
pub pos: Pos2,
|
pub pos: Pos2,
|
||||||
|
|
||||||
/// 1 or 2 (double-click) or 3 (triple-click)
|
/// 1 or 2 (double-click) or 3 (triple-click)
|
||||||
pub count: u32,
|
pub count: u32,
|
||||||
|
|
||||||
/// Allows you to check for e.g. shift-click
|
/// Allows you to check for e.g. shift-click
|
||||||
pub modifiers: Modifiers,
|
pub modifiers: Modifiers,
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,10 +96,14 @@ struct GestureState {
|
||||||
struct DynGestureState {
|
struct DynGestureState {
|
||||||
/// used for proportional zooming
|
/// used for proportional zooming
|
||||||
avg_distance: f32,
|
avg_distance: f32,
|
||||||
|
|
||||||
/// used for non-proportional zooming
|
/// used for non-proportional zooming
|
||||||
avg_abs_distance2: Vec2,
|
avg_abs_distance2: Vec2,
|
||||||
|
|
||||||
avg_pos: Pos2,
|
avg_pos: Pos2,
|
||||||
|
|
||||||
avg_force: f32,
|
avg_force: f32,
|
||||||
|
|
||||||
heading: f32,
|
heading: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -513,18 +513,30 @@ pub mod special_emojis {
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub enum WidgetType {
|
pub enum WidgetType {
|
||||||
Label, // TODO(emilk): emit Label events
|
Label, // TODO(emilk): emit Label events
|
||||||
|
|
||||||
/// e.g. a hyperlink
|
/// e.g. a hyperlink
|
||||||
Link,
|
Link,
|
||||||
|
|
||||||
TextEdit,
|
TextEdit,
|
||||||
|
|
||||||
Button,
|
Button,
|
||||||
|
|
||||||
Checkbox,
|
Checkbox,
|
||||||
|
|
||||||
RadioButton,
|
RadioButton,
|
||||||
|
|
||||||
SelectableLabel,
|
SelectableLabel,
|
||||||
|
|
||||||
ComboBox,
|
ComboBox,
|
||||||
|
|
||||||
Slider,
|
Slider,
|
||||||
|
|
||||||
DragValue,
|
DragValue,
|
||||||
|
|
||||||
ColorButton,
|
ColorButton,
|
||||||
|
|
||||||
ImageButton,
|
ImageButton,
|
||||||
|
|
||||||
CollapsingHeader,
|
CollapsingHeader,
|
||||||
|
|
||||||
/// If you cannot fit any of the above slots.
|
/// If you cannot fit any of the above slots.
|
||||||
|
|
|
@ -305,6 +305,7 @@ pub struct Spacing {
|
||||||
|
|
||||||
/// Margin between contents and scroll bar.
|
/// Margin between contents and scroll bar.
|
||||||
pub scroll_bar_inner_margin: f32,
|
pub scroll_bar_inner_margin: f32,
|
||||||
|
|
||||||
/// Margin between scroll bar and the outer container (e.g. right of a vertical scroll bar).
|
/// Margin between scroll bar and the outer container (e.g. right of a vertical scroll bar).
|
||||||
pub scroll_bar_outer_margin: f32,
|
pub scroll_bar_outer_margin: f32,
|
||||||
}
|
}
|
||||||
|
@ -491,6 +492,7 @@ pub struct Visuals {
|
||||||
pub resize_corner_size: f32,
|
pub resize_corner_size: f32,
|
||||||
|
|
||||||
pub text_cursor_width: f32,
|
pub text_cursor_width: f32,
|
||||||
|
|
||||||
/// show where the text cursor would be if you clicked
|
/// show where the text cursor would be if you clicked
|
||||||
pub text_cursor_preview: bool,
|
pub text_cursor_preview: bool,
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
[](https://crates.io/crates/egui_extras)
|
[](https://crates.io/crates/egui_extras)
|
||||||
[](https://docs.rs/egui_extras)
|
[](https://docs.rs/egui_extras)
|
||||||
|
[](https://github.com/rust-secure-code/safety-dance/)
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ links = ["egui-winit/links"]
|
||||||
egui = { version = "0.21.0", path = "../egui", default-features = false, features = [
|
egui = { version = "0.21.0", path = "../egui", default-features = false, features = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
] }
|
] }
|
||||||
egui-winit = { version = "0.21.0", path = "../egui-winit", default-features = false }
|
egui-winit = { version = "0.21.1", path = "../egui-winit", default-features = false }
|
||||||
|
|
||||||
ahash = { version = "0.8.1", default-features = false, features = [
|
ahash = { version = "0.8.1", default-features = false, features = [
|
||||||
"no-rng", # we don't need DOS-protection, so we let users opt-in to it instead
|
"no-rng", # we don't need DOS-protection, so we let users opt-in to it instead
|
||||||
|
|
|
@ -59,7 +59,7 @@ document-features = { version = "0.2", optional = true }
|
||||||
|
|
||||||
# Native:
|
# Native:
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
egui-winit = { version = "0.21.0", path = "../egui-winit", optional = true, default-features = false }
|
egui-winit = { version = "0.21.1", path = "../egui-winit", optional = true, default-features = false }
|
||||||
puffin = { version = "0.14", optional = true }
|
puffin = { version = "0.14", optional = true }
|
||||||
|
|
||||||
# Web:
|
# Web:
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
# emath - egui math library
|
# emath - egui math library
|
||||||
|
|
||||||
|
[](https://crates.io/crates/emath)
|
||||||
|
[](https://docs.rs/emath)
|
||||||
|
[](https://github.com/rust-secure-code/safety-dance/)
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
A bare-bones 2D math library with types and functions useful for GUI building.
|
A bare-bones 2D math library with types and functions useful for GUI building.
|
||||||
|
|
||||||
Made for [`egui`](https://github.com/emilk/egui/).
|
Made for [`egui`](https://github.com/emilk/egui/).
|
||||||
|
|
|
@ -15,6 +15,7 @@ use crate::*;
|
||||||
pub struct Pos2 {
|
pub struct Pos2 {
|
||||||
/// How far to the right.
|
/// How far to the right.
|
||||||
pub x: f32,
|
pub x: f32,
|
||||||
|
|
||||||
/// How far down.
|
/// How far down.
|
||||||
pub y: f32,
|
pub y: f32,
|
||||||
// implicit w = 1
|
// implicit w = 1
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
# epaint - egui paint library
|
# epaint - egui paint library
|
||||||
|
|
||||||
|
[](https://crates.io/crates/epaint)
|
||||||
|
[](https://docs.rs/epaint)
|
||||||
|
[](https://github.com/rust-secure-code/safety-dance/)
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
A bare-bones 2D graphics library for turning simple 2D shapes and text into textured triangles.
|
A bare-bones 2D graphics library for turning simple 2D shapes and text into textured triangles.
|
||||||
|
|
||||||
Made for [`egui`](https://github.com/emilk/egui/).
|
Made for [`egui`](https://github.com/emilk/egui/).
|
||||||
|
|
|
@ -973,12 +973,16 @@ pub struct Tessellator {
|
||||||
pixels_per_point: f32,
|
pixels_per_point: f32,
|
||||||
options: TessellationOptions,
|
options: TessellationOptions,
|
||||||
font_tex_size: [usize; 2],
|
font_tex_size: [usize; 2],
|
||||||
|
|
||||||
/// See [`TextureAtlas::prepared_discs`].
|
/// See [`TextureAtlas::prepared_discs`].
|
||||||
prepared_discs: Vec<PreparedDisc>,
|
prepared_discs: Vec<PreparedDisc>,
|
||||||
|
|
||||||
/// size of feathering in points. normally the size of a physical pixel. 0.0 if disabled
|
/// size of feathering in points. normally the size of a physical pixel. 0.0 if disabled
|
||||||
feathering: f32,
|
feathering: f32,
|
||||||
|
|
||||||
/// Only used for culling
|
/// Only used for culling
|
||||||
clip_rect: Rect,
|
clip_rect: Rect,
|
||||||
|
|
||||||
scratchpad_points: Vec<Pos2>,
|
scratchpad_points: Vec<Pos2>,
|
||||||
scratchpad_path: Path,
|
scratchpad_path: Path,
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,7 +224,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
||||||
function __wbg_adapter_28(arg0, arg1) {
|
function __wbg_adapter_28(arg0, arg1) {
|
||||||
try {
|
try {
|
||||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||||
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__he2ead792e86f6629(retptr, arg0, arg1);
|
wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h19340d09680f5ee3(retptr, arg0, arg1);
|
||||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||||
if (r1) {
|
if (r1) {
|
||||||
|
@ -236,7 +236,7 @@ function __wbg_adapter_28(arg0, arg1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function __wbg_adapter_31(arg0, arg1, arg2) {
|
function __wbg_adapter_31(arg0, arg1, arg2) {
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h37098c33fc6abd40(arg0, arg1, addHeapObject(arg2));
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9fbcfb319cb46254(arg0, arg1, addHeapObject(arg2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeClosure(arg0, arg1, dtor, f) {
|
function makeClosure(arg0, arg1, dtor, f) {
|
||||||
|
@ -393,10 +393,6 @@ async function load(module, imports) {
|
||||||
function getImports() {
|
function getImports() {
|
||||||
const imports = {};
|
const imports = {};
|
||||||
imports.wbg = {};
|
imports.wbg = {};
|
||||||
imports.wbg.__wbg_webhandle_new = function(arg0) {
|
|
||||||
const ret = WebHandle.__wrap(arg0);
|
|
||||||
return addHeapObject(ret);
|
|
||||||
};
|
|
||||||
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
||||||
takeObject(arg0);
|
takeObject(arg0);
|
||||||
};
|
};
|
||||||
|
@ -404,6 +400,10 @@ function getImports() {
|
||||||
const ret = getStringFromWasm0(arg0, arg1);
|
const ret = getStringFromWasm0(arg0, arg1);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
imports.wbg.__wbg_webhandle_new = function(arg0) {
|
||||||
|
const ret = WebHandle.__wrap(arg0);
|
||||||
|
return addHeapObject(ret);
|
||||||
|
};
|
||||||
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
||||||
const obj = takeObject(arg0).original;
|
const obj = takeObject(arg0).original;
|
||||||
if (obj.cnt-- == 1) {
|
if (obj.cnt-- == 1) {
|
||||||
|
|
Binary file not shown.
|
@ -4,3 +4,7 @@ All the examples in this folder uses [`eframe`](https://github.com/emilk/egui/tr
|
||||||
There are a lot more examples at <https://www.egui.rs>, and it has links to the source code of each example.
|
There are a lot more examples at <https://www.egui.rs>, and it has links to the source code of each example.
|
||||||
|
|
||||||
Also check out the official docs at <https://docs.rs/egui> and <https://docs.rs/eframe>.
|
Also check out the official docs at <https://docs.rs/egui> and <https://docs.rs/eframe>.
|
||||||
|
|
||||||
|
Note that all the examples on `master` are for the latest `master` version of `egui`.
|
||||||
|
|
||||||
|
If you want to look for examples for a specific version of egui, go to that tag, e.g. <https://github.com/emilk/egui/tree/latest/examples>.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use egui::*;
|
use egui::*;
|
||||||
|
|
||||||
fn main() -> Result<(), eframe::Error> {
|
fn main() -> Result<(), eframe::Error> {
|
||||||
// Log to stdout (if you run with `RUST_LOG=debug`).
|
// Log to stdout (if you run with `RUST_LOG=debug`).
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
|
@ -10,6 +10,7 @@ publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = { path = "../../crates/eframe", features = [
|
eframe = { path = "../../crates/eframe", features = [
|
||||||
|
"puffin",
|
||||||
"__screenshot", # __screenshot is so we can dump a screenshot using EFRAME_SCREENSHOT_TO
|
"__screenshot", # __screenshot is so we can dump a screenshot using EFRAME_SCREENSHOT_TO
|
||||||
] }
|
] }
|
||||||
puffin = "0.14"
|
puffin = "0.14"
|
||||||
|
|
Loading…
Reference in a new issue