Update to egui 0.17

This commit is contained in:
Lukas Wirth 2022-04-02 14:05:16 +02:00
parent 8408503866
commit bf86623866
4 changed files with 13 additions and 12 deletions

View File

@ -15,7 +15,7 @@ workspace = ".."
persistence = ["serde", "slotmap/serde", "smallvec/serde", "egui/persistence"] persistence = ["serde", "slotmap/serde", "smallvec/serde", "egui/persistence"]
[dependencies] [dependencies]
egui = { version = "0.16" } egui = { version = "0.17" }
slotmap = { version = "1.0" } slotmap = { version = "1.0" }
smallvec = { version = "1.7.0" } smallvec = { version = "1.7.0" }
serde = { version = "1.0", optional = true, features = ["derive"] } serde = { version = "1.0", optional = true, features = ["derive"] }

View File

@ -60,7 +60,7 @@ where
#[must_use] #[must_use]
pub fn draw_graph_editor( pub fn draw_graph_editor(
&mut self, &mut self,
ctx: &CtxRef, ctx: &Context,
all_kinds: impl NodeTemplateIter<Item = NodeTemplate>, all_kinds: impl NodeTemplateIter<Item = NodeTemplate>,
) -> GraphResponse<UserResponse> { ) -> GraphResponse<UserResponse> {
let mouse = &ctx.input().pointer; let mouse = &ctx.input().pointer;
@ -467,25 +467,26 @@ where
// does not support drawing rectangles with asymmetrical round corners. // does not support drawing rectangles with asymmetrical round corners.
let (shape, outline) = { let (shape, outline) = {
let corner_radius = 4.0; let rounding_radius = 4.0;
let rounding = Rounding::same(rounding_radius);
let titlebar_height = title_height + margin.y; let titlebar_height = title_height + margin.y;
let titlebar_rect = let titlebar_rect =
Rect::from_min_size(outer_rect.min, vec2(outer_rect.width(), titlebar_height)); Rect::from_min_size(outer_rect.min, vec2(outer_rect.width(), titlebar_height));
let titlebar = Shape::Rect(RectShape { let titlebar = Shape::Rect(RectShape {
rect: titlebar_rect, rect: titlebar_rect,
corner_radius, rounding,
fill: titlebar_color, fill: titlebar_color,
stroke: Stroke::none(), stroke: Stroke::none(),
}); });
let body_rect = Rect::from_min_size( let body_rect = Rect::from_min_size(
outer_rect.min + vec2(0.0, titlebar_height - corner_radius), outer_rect.min + vec2(0.0, titlebar_height - rounding_radius),
vec2(outer_rect.width(), outer_rect.height() - titlebar_height), vec2(outer_rect.width(), outer_rect.height() - titlebar_height),
); );
let body = Shape::Rect(RectShape { let body = Shape::Rect(RectShape {
rect: body_rect, rect: body_rect,
corner_radius: 0.0, rounding: Rounding::none(),
fill: background_color, fill: background_color,
stroke: Stroke::none(), stroke: Stroke::none(),
}); });
@ -496,7 +497,7 @@ where
); );
let bottom_body = Shape::Rect(RectShape { let bottom_body = Shape::Rect(RectShape {
rect: bottom_body_rect, rect: bottom_body_rect,
corner_radius, rounding,
fill: background_color, fill: background_color,
stroke: Stroke::none(), stroke: Stroke::none(),
}); });
@ -507,7 +508,7 @@ where
.union(body_rect) .union(body_rect)
.union(bottom_body_rect) .union(bottom_body_rect)
.expand(1.0), .expand(1.0),
corner_radius: 4.0, rounding,
fill: Color32::WHITE.lighten(0.8), fill: Color32::WHITE.lighten(0.8),
stroke: Stroke::none(), stroke: Stroke::none(),
}) })

View File

@ -9,7 +9,7 @@ rust-version = "1.56"
crate-type = ["cdylib", "rlib"] crate-type = ["cdylib", "rlib"]
[dependencies] [dependencies]
eframe = "0.16.0" eframe = "0.17.0"
egui_node_graph = { path = "../egui_node_graph" } egui_node_graph = { path = "../egui_node_graph" }
anyhow = "1.0" anyhow = "1.0"

View File

@ -1,7 +1,7 @@
use std::collections::HashMap; use std::collections::HashMap;
use eframe::{ use eframe::{
egui::{self, DragValue}, egui::{self, DragValue, TextStyle},
epi, epi,
}; };
use egui_node_graph::*; use egui_node_graph::*;
@ -359,7 +359,7 @@ impl epi::App for NodeGraphExample {
/// Called each time the UI needs repainting, which may be many times per second. /// Called each time the UI needs repainting, which may be many times per second.
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`. /// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
fn update(&mut self, ctx: &egui::CtxRef, _frame: &epi::Frame) { fn update(&mut self, ctx: &egui::Context, _frame: &epi::Frame) {
let graph_response = self.state.draw_graph_editor(ctx, AllMyNodeTemplates); let graph_response = self.state.draw_graph_editor(ctx, AllMyNodeTemplates);
for node_response in graph_response.node_responses { for node_response in graph_response.node_responses {
// Here, we ignore all other graph events. But you may find // Here, we ignore all other graph events. But you may find
@ -384,7 +384,7 @@ impl epi::App for NodeGraphExample {
egui::pos2(10.0, 10.0), egui::pos2(10.0, 10.0),
egui::Align2::LEFT_TOP, egui::Align2::LEFT_TOP,
text, text,
egui::TextStyle::Button, TextStyle::Button.resolve(&ctx.style()),
egui::Color32::WHITE, egui::Color32::WHITE,
); );
} }