Skip to content

Commit

Permalink
Bump egui to 28.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger committed Jul 16, 2024
1 parent 7d5272d commit c5e762f
Show file tree
Hide file tree
Showing 35 changed files with 146 additions and 115 deletions.
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@ regex = "1.9.5"
directories = "5.0.1"
tokio = { version = "1.37.0", features = ["full"] }

egui = "0.27.2"
eframe = "0.27.2"
egui = "0.28.1"
eframe = "0.28.1"
# eframe = { version = "0.27.2", default-features = false, features = [
# "accesskit", # Make egui comptaible with screen readers. NOTE: adds a lot of dependencies.
# "default_fonts", # Embed the default egui fonts.
# "glow", # Use the glow rendering backend. Alternative: "wgpu".
# "persistence", # Enable restoring app state when restarting the app.
# ], optional = true }
egui_extras = { version="0.27.2", features = ["all_loaders", "svg", "image"] }
egui_extras = { version="0.28.1", features = ["all_loaders", "svg", "image"] }
# egui_extras = { version="0.27.2", features = [] }
egui_glow = "0.27.2"
egui_glow = "0.28.1"
glow = "0.13.0"
egui-modal = "0.3.6"
egui-bind = "0.12.0"
egui_file = "0.17.0"
egui-notify = "0.14.0"
egui-modal = "0.4.0"
egui-bind = "0.13.0"
egui_file = "0.18.0"
egui-notify = "0.15.0"

[profile.release]
opt-level = 'z' # Optimize for size
Expand Down
5 changes: 2 additions & 3 deletions crates/icy_draw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ egui_glow = { workspace = true }
egui-modal = { workspace = true }
glow = { workspace = true }
egui_file = { workspace = true }
egui_tiles = { git ="https://github.com/mkrueger/egui_tiles"}
#egui_tiles = { path = "../egui_tiles" }
egui_tiles = "0.9.0"
egui-bind = { workspace = true }
egui-notify = { workspace = true }
log = { workspace = true }
Expand All @@ -42,7 +41,7 @@ icy_sauce = { workspace = true }

bstr = { workspace = true }

egui_code_editor = "0.2.7"
egui_code_editor = "0.2.9"
mlua = { version = "0.9.1", features = ["lua54", "vendored"] }
regex = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion crates/icy_draw/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn main() {
}
window.open_file(&path, false);
}
Box::new(window)
Ok(Box::new(window))
}),
) {
log::error!("Error returned by run_native: {}", err);
Expand Down
2 changes: 1 addition & 1 deletion crates/icy_draw/src/model/tools/brush_imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Tool for BrushTool {

ui.horizontal(|ui| {
ui.label(fl!(crate::LANGUAGE_LOADER, "tool-size-label"));
ui.add(egui::DragValue::new(&mut self.size).clamp_range(1..=20).speed(1));
ui.add(egui::DragValue::new(&mut self.size).range(1..=20).speed(1));
});
/*
ui.radio_value(&mut self.brush_type, BrushType::Shade, fl!(crate::LANGUAGE_LOADER, "tool-shade"));
Expand Down
2 changes: 1 addition & 1 deletion crates/icy_draw/src/model/tools/erase_imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl Tool for EraseTool {
fn show_ui(&mut self, _ctx: &egui::Context, ui: &mut egui::Ui, _editor_opt: Option<&mut AnsiEditor>) -> Option<Message> {
ui.horizontal(|ui| {
ui.label(fl!(crate::LANGUAGE_LOADER, "tool-size-label"));
ui.add(egui::DragValue::new(&mut self.size).clamp_range(1..=20).speed(1));
ui.add(egui::DragValue::new(&mut self.size).range(1..=20).speed(1));
});
ui.radio_value(&mut self.brush_type, EraseType::Solid, fl!(crate::LANGUAGE_LOADER, "tool-solid"));
ui.radio_value(&mut self.brush_type, EraseType::Shade, fl!(crate::LANGUAGE_LOADER, "tool-shade"));
Expand Down
4 changes: 2 additions & 2 deletions crates/icy_draw/src/model/tools/pencil_imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct PencilTool {
undo_op: Option<AtomicUndoGuard>,
draw_mode: BrushMode,
color_mode: ColorMode,
pub attr: TextAttribute,
pub _attr: TextAttribute,

last_pos: Position,
cur_pos: Position,
Expand All @@ -32,7 +32,7 @@ impl Default for PencilTool {
char_code: Rc::new(RefCell::new('\u{00B0}')),
last_pos: Position::default(),
cur_pos: Position::default(),
attr: icy_engine::TextAttribute::default(),
_attr: icy_engine::TextAttribute::default(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/icy_draw/src/model/tools/tag_imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Tool for TagTool {

let font_id = FontId::new(14.0, FontFamily::Proportional);
let text: WidgetText = tag.replacement_value.clone().into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
ui.painter().galley_with_override_text_color(
egui::Align2::LEFT_TOP.align_size_within_rect(galley.size(), rect.shrink(4.0)).min,
galley,
Expand Down
6 changes: 4 additions & 2 deletions crates/icy_draw/src/ui/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,9 @@ impl CommandWrapper {
}

let response = ui.with_layout(ui.layout().with_cross_justify(true), |ui| {
ui.set_enabled(self.is_enabled);
if !self.is_enabled {
ui.disable();
}
if let Some((KeyOrPointer::Key(k), modifier)) = self.key {
let mut shortcut = k.name().to_string();

Expand All @@ -445,7 +447,7 @@ impl CommandWrapper {

button_with_shortcut(ui, true, &self.label, shortcut)
} else {
ui.add(egui::Button::new(&self.label).wrap(false))
ui.add(egui::Button::new(&self.label).wrap_mode(egui::TextWrapMode::Truncate))
}
});

Expand Down
5 changes: 4 additions & 1 deletion crates/icy_draw/src/ui/dialogs/edit_tag_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ impl ModalDialog for EditTagDialog {
self.tag.replacement_value = tag.tag.clone();
self.show_replacements = false;
}
ui.add(Label::new(RichText::new(&tag.description).font(FontId::new(font_size, FontFamily::Proportional))).wrap(false));
ui.add(
Label::new(RichText::new(&tag.description).font(FontId::new(font_size, FontFamily::Proportional)))
.wrap_mode(egui::TextWrapMode::Truncate),
);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/icy_draw/src/ui/dialogs/export_file_dialog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl ModalDialog for ExportFileDialog {
self.format_type = format_type;
}
}
if ui.add(egui::Button::new("…").wrap(false)).clicked() {
if ui.add(egui::Button::new("…").wrap_mode(egui::TextWrapMode::Truncate)).clicked() {
let mut initial_path = None;
crate::set_default_initial_directory_opt(&mut initial_path);
let mut dialog = FileDialog::save_file(initial_path);
Expand Down
8 changes: 4 additions & 4 deletions crates/icy_draw/src/ui/dialogs/font_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl crate::ModalDialog for FontManager {

let font_id = FontId::new(12.0, FontFamily::Monospace);
let text: WidgetText = format!("{i:-3}.").into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id.clone());
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id.clone());
let size = galley.size();
let mut title_rect = rect;
title_rect.set_left(title_rect.left() + 4.0);
Expand All @@ -81,7 +81,7 @@ impl crate::ModalDialog for FontManager {

let font_id = TextStyle::Button.resolve(ui.style());
let text: WidgetText = font.name.clone().into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
let mut title_rect = rect;
title_rect.set_left(title_rect.left() + 4.0 + size.x + 4.0);
ui.painter().galley_with_override_text_color(
Expand All @@ -92,7 +92,7 @@ impl crate::ModalDialog for FontManager {

let font_id = TextStyle::Button.resolve(ui.style());
let text: WidgetText = format!("{}x{}", font.size.width, font.size.height).into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
let mut title_rect = rect;
title_rect.set_left(title_rect.left() + 399.0);
ui.painter().galley_with_override_text_color(
Expand All @@ -108,7 +108,7 @@ impl crate::ModalDialog for FontManager {
fl!(crate::LANGUAGE_LOADER, "manage-font-not_used_label")
}
.into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
let mut title_rect = rect;
title_rect.set_left(title_rect.left() + 480.0);
ui.painter().galley_with_override_text_color(
Expand Down
4 changes: 2 additions & 2 deletions crates/icy_draw/src/ui/dialogs/font_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl FontSelector {

let font_id = FontId::new(14.0, FontFamily::Proportional);
let text: WidgetText = font.0.name.clone().into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
ui.painter().galley_with_override_text_color(
egui::Align2::LEFT_TOP.align_size_within_rect(galley.size(), rect.shrink(4.0)).min,
galley,
Expand Down Expand Up @@ -390,7 +390,7 @@ impl FontSelector {
fn print_source(font_type: String, ui: &egui::Ui, rect: Rect, text_color: Color32) -> f32 {
let font_id = FontId::new(12.0, FontFamily::Proportional);
let text: WidgetText = font_type.into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
let galley_size = galley.size();

let left_side = rect.right() - galley_size.x - 10.0;
Expand Down
4 changes: 2 additions & 2 deletions crates/icy_draw/src/ui/dialogs/new_file_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ impl crate::ModalDialog for NewFileDialog {

let font_id = FontId::new(20.0, eframe::epaint::FontFamily::Proportional);
let text: WidgetText = template.title().into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
let mut title_rect = rect;
title_rect.set_left(title_rect.left() + 40.0);
title_rect.set_top(title_rect.top() + 4.0);
Expand All @@ -517,7 +517,7 @@ impl crate::ModalDialog for NewFileDialog {

let font_id = FontId::new(14.0, eframe::epaint::FontFamily::Proportional);
let text: WidgetText = template.description().lines().next().unwrap_or_default().into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
let mut descr_rect = rect;
descr_rect.set_top(descr_rect.top() + 34.0);
ui.painter().galley_with_override_text_color(
Expand Down
4 changes: 2 additions & 2 deletions crates/icy_draw/src/ui/dialogs/select_palette_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl SelectPaletteDialog {

let font_id = FontId::new(14.0, FontFamily::Proportional);
let text: WidgetText = palette.0.title.clone().into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
ui.painter().galley_with_override_text_color(
egui::Align2::LEFT_TOP.align_size_within_rect(galley.size(), rect.shrink(4.0)).min,
galley,
Expand Down Expand Up @@ -236,7 +236,7 @@ impl SelectPaletteDialog {

let font_id = FontId::new(12.0, FontFamily::Proportional);
let text: WidgetText = font_type.into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);

let rect = Rect::from_min_size(
Pos2::new((rect.right() - galley.size().x - 10.0).floor(), (rect.top() + 8.0).floor()),
Expand Down
6 changes: 3 additions & 3 deletions crates/icy_draw/src/ui/dialogs/select_tdf_font_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl SelectFontDialog {

let font_id = TextStyle::Button.resolve(ui.style());
let text: WidgetText = font.name.clone().into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);
ui.painter().galley_with_override_text_color(
egui::Align2::LEFT_TOP.align_size_within_rect(galley.size(), rect.shrink(4.0)).min,
galley,
Expand All @@ -86,7 +86,7 @@ impl SelectFontDialog {
};
let text: WidgetText = ch.to_string().into();
let font_id = FontId::new(14.0, FontFamily::Monospace);
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);

let mut rect = rect.shrink(4.0);
rect.set_top(rect.top() + y);
Expand Down Expand Up @@ -159,7 +159,7 @@ impl SelectFontDialog {

let font_id = FontId::new(12.0, FontFamily::Proportional);
let text: WidgetText = font_type.into();
let galley = text.into_galley(ui, Some(false), f32::INFINITY, font_id);
let galley = text.into_galley(ui, Some(egui::TextWrapMode::Truncate), f32::INFINITY, font_id);

let rect = Rect::from_min_size(
Pos2::new((rect.right() - galley.size().x - 10.0).floor(), (rect.top() + 8.0).floor()),
Expand Down
10 changes: 5 additions & 5 deletions crates/icy_draw/src/ui/document_docking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl egui_tiles::Behavior<DocumentTab> for DocumentBehavior {
fn on_tab_button(&mut self, tiles: &Tiles<DocumentTab>, tile_id: TileId, button_response: eframe::egui::Response) -> Response {
let response_opt = button_response.context_menu(|ui| {
if ui.button(fl!(crate::LANGUAGE_LOADER, "tab-context-menu-close")).clicked() {
self.on_close_requested(tiles, tile_id);
// self.on_close_requested(tiles, tile_id);
ui.close_menu();
}
if ui.button(fl!(crate::LANGUAGE_LOADER, "tab-context-menu-close_others")).clicked() {
Expand Down Expand Up @@ -234,21 +234,21 @@ impl egui_tiles::Behavior<DocumentTab> for DocumentBehavior {
button_response
}
}

/*
fn on_close_requested(&mut self, _tiles: &Tiles<DocumentTab>, tile_id: TileId) {
self.request_close = Some(tile_id);
}
}*/

fn simplification_options(&self) -> egui_tiles::SimplificationOptions {
egui_tiles::SimplificationOptions {
all_panes_must_have_tabs: true,
..Default::default()
}
}

/*
fn has_close_buttons(&self) -> bool {
true
}
}*/

fn top_bar_right_ui(&mut self, tiles: &Tiles<DocumentTab>, ui: &mut Ui, _tile_id: TileId, tabs: &Tabs, _scroll_offset: &mut f32) {
if let Some(id) = tabs.active {
Expand Down
2 changes: 1 addition & 1 deletion crates/icy_draw/src/ui/editor/animation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Document for AnimationEditor {
.show_inside(ui, |ui| {
ui.horizontal(|ui| {
if !self.animator.lock().unwrap().error.is_empty() {
ui.set_enabled(false);
ui.disable();
}

if self.animator.lock().unwrap().success() {
Expand Down
5 changes: 3 additions & 2 deletions crates/icy_draw/src/ui/editor/ansi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ impl AnsiEditor {
self.output_string(text);
}

egui::Event::CompositionEnd(text) | egui::Event::Text(text) => {
/* egui::Event::CompositionEnd(text) |*/
egui::Event::Text(text) => {
if !ui.input(|i| i.modifiers.ctrl || i.modifiers.command || i.modifiers.alt) {
for c in text.chars() {
cur_tool.handle_key(self, MKey::Character(c as u16), MModifiers::None);
Expand Down Expand Up @@ -796,7 +797,7 @@ pub const DEFAULT_CHAR_SET_TABLE: [[u8; 10]; 15] = [
];

pub fn terminal_context_menu(editor: &AnsiEditor, commands: &Commands, ui: &mut egui::Ui) -> Option<Message> {
ui.style_mut().wrap = Some(false);
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);
let mut result = None;
ui.input_mut(|i| i.events.clear());

Expand Down
4 changes: 2 additions & 2 deletions crates/icy_draw/src/ui/editor/charfont/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl Document for CharFontEditor {

if self.selected_font < self.fonts.len() {
ScrollArea::vertical().show(ui, |ui| {
ui.style_mut().wrap = Some(false);
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);

for i in 0..self.fonts.len() {
if ui.selectable_value(&mut self.selected_font, i, &self.fonts[i].name).clicked() {
Expand Down Expand Up @@ -210,7 +210,7 @@ impl Document for CharFontEditor {
ui.label(fl!(crate::LANGUAGE_LOADER, "tdf-editor-spacing_label"));
});
if ui
.add(egui::DragValue::new(&mut self.fonts[self.selected_font].spaces).clamp_range(0.0..=40.0))
.add(egui::DragValue::new(&mut self.fonts[self.selected_font].spaces).range(0.0..=40.0))
.changed()
{
self.undostack_len += 1;
Expand Down
4 changes: 2 additions & 2 deletions crates/icy_draw/src/ui/tool_docking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ impl egui_tiles::Behavior<ToolTab> for ToolBehavior {
..Default::default()
}
}

/*
fn has_close_buttons(&self) -> bool {
false
}
}*/
}

pub trait ToolWindow {
Expand Down
Loading

0 comments on commit c5e762f

Please sign in to comment.