Skip to content

Commit d309d9c

Browse files
committed
merge: frome office git update
2 parents 911fed3 + 6607cd9 commit d309d9c

File tree

101 files changed

+3542
-2259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3542
-2259
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
**/target_wasm
55
**/tests/snapshots/**/*.diff.png
66
**/tests/snapshots/**/*.new.png
7+
**/tests/snapshots/**/*.old.png
78
/.*.json
89
/.vscode
910
/media/*

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ egui_extras::install_image_loaders(egui_ctx);
12301230
* [Tweaked the default visuals style](https://github.com/emilk/egui/pull/450).
12311231
* Plot: Renamed `Curve` to `Line`.
12321232
* `TopPanel::top` is now `TopBottomPanel::top`.
1233-
* `SidePanel::left` no longet takes the default width by argument, but by a builder call.
1233+
* `SidePanel::left` no longer takes the default width by argument, but by a builder call.
12341234
* `SidePanel::left` is resizable by default.
12351235

12361236
### 🐛 Fixed

CONTRIBUTING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ For small things, just go ahead an open a PR. For bigger things, please file an
3232
Browse through [`ARCHITECTURE.md`](ARCHITECTURE.md) to get a sense of how all pieces connects.
3333

3434
You can test your code locally by running `./scripts/check.sh`.
35-
There are snapshots test that might need to be updated.
35+
There are snapshots test that might need to be updated.
3636
Run the tests with `UPDATE_SNAPSHOTS=true cargo test --workspace --all-features` to update all of them.
3737
For more info about the tests see [egui_kittest](./crates/egui_kittest/README.md).
3838

@@ -102,6 +102,7 @@ While using an immediate mode gui is simple, implementing one is a lot more tric
102102
* Avoid double negatives
103103
* Flip `if !condition {} else {}`
104104
* Sets of things should be lexicographically sorted (e.g. crate dependencies in `Cargo.toml`)
105+
* Put each type in their own file, unless they are trivial (e.g. a `struct` with no `impl`)
105106
* Break the above rules when it makes sense
106107

107108

Cargo.lock

+2
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,7 @@ dependencies = [
13201320
"egui",
13211321
"egui_demo_lib",
13221322
"egui_extras",
1323+
"egui_kittest",
13231324
"ehttp",
13241325
"env_logger",
13251326
"image",
@@ -1411,6 +1412,7 @@ version = "0.30.0"
14111412
dependencies = [
14121413
"dify",
14131414
"document-features",
1415+
"eframe",
14141416
"egui",
14151417
"egui-wgpu",
14161418
"image",

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,10 @@ use_self = "warn"
269269
useless_transmute = "warn"
270270
verbose_file_reads = "warn"
271271
wildcard_dependencies = "warn"
272-
wildcard_imports = "warn"
273272
zero_sized_map_values = "warn"
274273

275274

276-
# TODO(emilk): enable more of these lints:
275+
# TODO(emilk): maybe enable more of these lints?
277276
iter_over_hash_type = "allow"
278277
missing_assert_message = "allow"
279278
should_panic_without_expect = "allow"
@@ -287,3 +286,4 @@ let_underscore_untyped = "allow"
287286
manual_range_contains = "allow" # this one is just worse imho
288287
self_named_module_files = "allow" # Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602
289288
significant_drop_tightening = "allow" # Too many false positives
289+
wildcard_imports = "allow" # `use crate::*` is useful to avoid merge conflicts when adding/removing imports

crates/eframe/src/epi.rs

+66-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ impl HasDisplayHandle for CreationContext<'_> {
109109
}
110110
}
111111

112+
impl CreationContext<'_> {
113+
/// Create a new empty [CreationContext] for testing [App]s in kittest.
114+
#[doc(hidden)]
115+
pub fn _new_kittest(egui_ctx: egui::Context) -> Self {
116+
Self {
117+
egui_ctx,
118+
integration_info: IntegrationInfo::mock(),
119+
storage: None,
120+
#[cfg(feature = "glow")]
121+
gl: None,
122+
#[cfg(feature = "glow")]
123+
get_proc_address: None,
124+
#[cfg(feature = "wgpu")]
125+
wgpu_render_state: None,
126+
#[cfg(not(target_arch = "wasm32"))]
127+
raw_window_handle: Err(HandleError::NotSupported),
128+
#[cfg(not(target_arch = "wasm32"))]
129+
raw_display_handle: Err(HandleError::NotSupported),
130+
}
131+
}
132+
}
133+
112134
// ----------------------------------------------------------------------------
113135

114136
/// Implement this trait to write apps that can be compiled for both web/wasm and desktop/native using [`eframe`](https://github.com/emilk/egui/tree/master/crates/eframe).
@@ -617,7 +639,8 @@ pub struct Frame {
617639

618640
/// Can be used to manage GPU resources for custom rendering with WGPU using [`egui::PaintCallback`]s.
619641
#[cfg(feature = "wgpu")]
620-
pub(crate) wgpu_render_state: Option<egui_wgpu::RenderState>,
642+
#[doc(hidden)]
643+
pub wgpu_render_state: Option<egui_wgpu::RenderState>,
621644

622645
/// Raw platform window handle
623646
#[cfg(not(target_arch = "wasm32"))]
@@ -651,6 +674,25 @@ impl HasDisplayHandle for Frame {
651674
}
652675

653676
impl Frame {
677+
/// Create a new empty [Frame] for testing [App]s in kittest.
678+
#[doc(hidden)]
679+
pub fn _new_kittest() -> Self {
680+
Self {
681+
#[cfg(feature = "glow")]
682+
gl: None,
683+
#[cfg(all(feature = "glow", not(target_arch = "wasm32")))]
684+
glow_register_native_texture: None,
685+
info: IntegrationInfo::mock(),
686+
#[cfg(not(target_arch = "wasm32"))]
687+
raw_display_handle: Err(HandleError::NotSupported),
688+
#[cfg(not(target_arch = "wasm32"))]
689+
raw_window_handle: Err(HandleError::NotSupported),
690+
storage: None,
691+
#[cfg(feature = "wgpu")]
692+
wgpu_render_state: None,
693+
}
694+
}
695+
654696
/// True if you are in a web environment.
655697
///
656698
/// Equivalent to `cfg!(target_arch = "wasm32")`
@@ -794,6 +836,29 @@ pub struct IntegrationInfo {
794836
pub cpu_usage: Option<f32>,
795837
}
796838

839+
impl IntegrationInfo {
840+
fn mock() -> Self {
841+
Self {
842+
#[cfg(target_arch = "wasm32")]
843+
web_info: WebInfo {
844+
user_agent: "kittest".to_owned(),
845+
location: Location {
846+
url: "http://localhost".to_owned(),
847+
protocol: "http:".to_owned(),
848+
host: "localhost".to_owned(),
849+
hostname: "localhost".to_owned(),
850+
port: "80".to_owned(),
851+
hash: String::new(),
852+
query: String::new(),
853+
query_map: Default::default(),
854+
origin: "http://localhost".to_owned(),
855+
},
856+
},
857+
cpu_usage: None,
858+
}
859+
}
860+
}
861+
797862
// ----------------------------------------------------------------------------
798863

799864
/// A place where you can store custom data in a way that persists when you restart the app.

crates/eframe/src/web/web_painter_wgpu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl WebPainterWgpu {
115115
let render_state = RenderState::create(
116116
&options.wgpu_options,
117117
&instance,
118-
&surface,
118+
Some(&surface),
119119
depth_format,
120120
1,
121121
options.dithering,

crates/egui-wgpu/src/lib.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub use wgpu;
2424
mod renderer;
2525

2626
pub use renderer::*;
27-
use wgpu::{Adapter, Device, Instance, Queue};
27+
use wgpu::{Adapter, Device, Instance, Queue, TextureFormat};
2828

2929
/// Helpers for capturing screenshots of the UI.
3030
pub mod capture;
@@ -91,7 +91,7 @@ impl RenderState {
9191
pub async fn create(
9292
config: &WgpuConfiguration,
9393
instance: &wgpu::Instance,
94-
surface: &wgpu::Surface<'static>,
94+
compatible_surface: Option<&wgpu::Surface<'static>>,
9595
depth_format: Option<wgpu::TextureFormat>,
9696
msaa_samples: u32,
9797
dithering: bool,
@@ -113,7 +113,7 @@ impl RenderState {
113113
instance
114114
.request_adapter(&wgpu::RequestAdapterOptions {
115115
power_preference,
116-
compatible_surface: Some(surface),
116+
compatible_surface,
117117
force_fallback_adapter: false,
118118
})
119119
.await
@@ -186,11 +186,14 @@ impl RenderState {
186186
} => (adapter, device, queue),
187187
};
188188

189-
let capabilities = {
189+
let surface_formats = {
190190
profiling::scope!("get_capabilities");
191-
surface.get_capabilities(&adapter).formats
191+
compatible_surface.map_or_else(
192+
|| vec![TextureFormat::Rgba8Unorm],
193+
|s| s.get_capabilities(&adapter).formats,
194+
)
192195
};
193-
let target_format = crate::preferred_framebuffer_format(&capabilities)?;
196+
let target_format = crate::preferred_framebuffer_format(&surface_formats)?;
194197

195198
let renderer = Renderer::new(
196199
&device,

crates/egui-wgpu/src/winit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl Painter {
212212
let render_state = RenderState::create(
213213
&self.configuration,
214214
&self.instance,
215-
&surface,
215+
Some(&surface),
216216
self.depth_format,
217217
self.msaa_samples,
218218
self.dithering,

crates/egui/src/containers/collapsing_header.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{
44
emath, epaint, pos2, remap, remap_clamp, vec2, Context, Id, InnerResponse, NumExt, Rect,
55
Response, Sense, Stroke, TextStyle, TextWrapMode, Ui, Vec2, WidgetInfo, WidgetText, WidgetType,
66
};
7+
use emath::GuiRounding as _;
78
use epaint::Shape;
89

910
#[derive(Clone, Copy, Debug)]
@@ -214,7 +215,7 @@ impl CollapsingState {
214215
10.0
215216
} else {
216217
let full_height = self.state.open_height.unwrap_or_default();
217-
remap_clamp(openness, 0.0..=1.0, 0.0..=full_height)
218+
remap_clamp(openness, 0.0..=1.0, 0.0..=full_height).round_ui()
218219
};
219220

220221
let mut clip_rect = child_ui.clip_rect();

0 commit comments

Comments
 (0)