Skip to content

Commit

Permalink
Update egui to 0.29
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Sep 26, 2024
1 parent 0d0b4ca commit 945a8d3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 21 deletions.
20 changes: 12 additions & 8 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 @@ -17,8 +17,10 @@ xkbcommon = "0.7"

[dependencies.smithay]
version = "0.3"
git = "https://github.com/Smithay/smithay.git"
rev = "e27fd27ca"
#git = "https://github.com/Smithay/smithay.git"
#rev = "e27fd27ca"
git = "https://github.com/ids1024/smithay.git"
branch = "glow"
default-features = false
features = ["renderer_glow", "wayland_frontend"]

Expand All @@ -34,12 +36,14 @@ 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"
#git = "https://github.com/Smithay/smithay.git"
#rev = "e27fd27ca"
git = "https://github.com/ids1024/smithay.git"
branch = "glow"
default-features = false
features = ["backend_winit"]
48 changes: 35 additions & 13 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 @@ -609,6 +629,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 +655,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

0 comments on commit 945a8d3

Please sign in to comment.