Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update egui to 0.29 #16

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ license = "MIT"

[dependencies]
cgmath = "0.18"
egui = "0.23"
egui_glow = "0.23"
egui_extras = { version = "0.23", optional = true }
egui = "0.29"
egui_glow = "0.29"
egui_extras = { version = "0.29", optional = true }
img = { version = "0.24", default-features = false, optional = true, package = "image" }
memoffset = "0.9"
lazy_static = { version = "1.4.0", optional = true }
Expand All @@ -18,7 +18,7 @@ xkbcommon = "0.7"
[dependencies.smithay]
version = "0.3"
git = "https://github.com/Smithay/smithay.git"
rev = "e27fd27ca"
rev = "3b0ecce"
default-features = false
features = ["renderer_glow", "wayland_frontend"]

Expand All @@ -34,12 +34,12 @@ jpg = ["image", "egui_extras/image", "img/jpeg"]

[dev-dependencies]
anyhow = "1.0"
egui_demo_lib = "0.23"
egui_demo_lib = "0.29"
tracing-subscriber = "0.3"

[dev-dependencies.smithay]
version = "0.3"
git = "https://github.com/Smithay/smithay.git"
rev = "e27fd27ca"
rev = "3b0ecce"
default-features = false
features = ["backend_winit"]
58 changes: 41 additions & 17 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ impl EguiState {
let key = if let Some(key) = convert_key(handle.raw_syms().iter().copied()) {
inner.events.push(Event::Key {
key,
physical_key: None,
pressed,
repeat: false,
modifiers: convert_modifiers(modifiers),
Expand Down Expand Up @@ -247,10 +248,16 @@ impl EguiState {
/// instead of normal clients, check [`EguiState::wants_pointer`] to figure out,
/// if there is an egui-element below your pointer.
pub fn handle_pointer_axis(&self, x_amount: f64, y_amount: f64) {
self.inner.lock().unwrap().events.push(Event::Scroll(Vec2 {
x: x_amount as f32,
y: y_amount as f32,
}))
let mut inner = self.inner.lock().unwrap();
let modifiers = convert_modifiers(inner.last_modifiers);
inner.events.push(Event::MouseWheel {
unit: egui::MouseWheelUnit::Point,
delta: Vec2 {
x: x_amount as f32,
y: y_amount as f32,
},
modifiers,
})
}

/// Set if this [`EguiState`] should consider itself focused
Expand All @@ -271,7 +278,7 @@ impl EguiState {
/// - `modifiers` should be the current state of modifiers pressed on the keyboards.
pub fn render(
&self,
ui: impl FnOnce(&Context),
ui: impl FnMut(&Context),
renderer: &mut GlowRenderer,
area: Rectangle<i32, Logical>,
scale: f64,
Expand All @@ -286,7 +293,7 @@ impl EguiState {
smithay::utils::Transform::Normal,
)?;
frame
.with_context(|context| Painter::new(context.clone(), "", None))?
.with_context(|context| Painter::new(context.clone(), "", None, false))?
.map_err(|_| GlesError::ShaderCompileError)?
};
renderer.egl_context().user_data().insert_if_missing(|| {
Expand Down Expand Up @@ -339,15 +346,12 @@ impl EguiState {
y: screen_size.h as f32,
},
}),
pixels_per_point: Some(int_scale as f32),
time: Some(self.start_time.elapsed().as_secs_f64()),
predicted_dt: 1.0 / 60.0,
modifiers: convert_modifiers(inner.last_modifiers),
events: inner.events.drain(..).collect(),
hovered_files: Vec::with_capacity(0),
dropped_files: Vec::with_capacity(0),
focused: inner.focused,
max_texture_side: Some(painter.max_texture_side()), // TODO query from GlState somehow
..Default::default()
};

let FullOutput {
Expand Down Expand Up @@ -387,16 +391,32 @@ impl EguiState {
painter.paint_and_update_textures(
[physical_area.size.w as u32, physical_area.size.h as u32],
int_scale as f32,
&self.ctx.tessellate(shapes),
&self.ctx.tessellate(shapes, int_scale as f32),
&textures_delta,
);
}
renderer.unbind()?;

let used = self.ctx.used_rect();
let margin = self.ctx.style().visuals.clip_rect_margin.ceil() as i32;
let window_shadow = self.ctx.style().visuals.window_shadow.extrusion.ceil() as i32;
let popup_shadow = self.ctx.style().visuals.popup_shadow.extrusion.ceil() as i32;
let window_shadow = self
.ctx
.style()
.visuals
.window_shadow
.margin()
.sum()
.max_elem()
.ceil() as i32;
let popup_shadow = self
.ctx
.style()
.visuals
.popup_shadow
.margin()
.sum()
.max_elem()
.ceil() as i32;
let offset = margin + Ord::max(window_shadow, popup_shadow);
Result::<_, GlesError>::Ok(vec![Rectangle::<i32, Logical>::from_extemities(
(
Expand Down Expand Up @@ -435,8 +455,9 @@ impl EguiState {
.render((1, 1).into(), smithay::utils::Transform::Normal)
.map_err(|err| format!("{}", err))?;
frame
.with_context(|context| Painter::new(context.clone(), "", None))
.map_err(|err| format!("{}", err))??
.with_context(|context| Painter::new(context.clone(), "", None, false))
.map_err(|err| format!("{}", err))?
.map_err(|err| format!("{}", err))?
};
renderer.egl_context().user_data().insert_if_missing(|| {
UserDataType::new(RefCell::new(GlState {
Expand Down Expand Up @@ -476,8 +497,9 @@ impl EguiState {
.render((1, 1).into(), smithay::utils::Transform::Normal)
.map_err(|err| format!("{}", err))?;
frame
.with_context(|context| Painter::new(context.clone(), "", None))
.map_err(|err| format!("{}", err))??
.with_context(|context| Painter::new(context.clone(), "", None, false))
.map_err(|err| format!("{}", err))?
.map_err(|err| format!("{}", err))?
};
renderer.egl_context().user_data().insert_if_missing(|| {
UserDataType::new(RefCell::new(GlState {
Expand Down Expand Up @@ -609,6 +631,7 @@ impl<D: SeatHandler> KeyboardTarget<D> for EguiState {
let modifiers = convert_modifiers(inner.last_modifiers);
inner.events.push(Event::Key {
key,
physical_key: None,
pressed: true,
repeat: false,
modifiers,
Expand All @@ -634,6 +657,7 @@ impl<D: SeatHandler> KeyboardTarget<D> for EguiState {
let modifiers = convert_modifiers(inner.last_modifiers);
inner.events.push(Event::Key {
key,
physical_key: None,
pressed: false,
repeat: false,
modifiers,
Expand Down