Skip to content

Commit

Permalink
Egui 0.28 update fixes (#145)
Browse files Browse the repository at this point in the history
* Fix panic when selecting preset visuals in the preferences

* Fix blank lines at the bottom of the filesystem debug window

* Fix menu wrap modes

* Hide leftmost separator in the top bar in web builds

* Update `time` to 0.3.36

This fixes compiler errors when using very new Rust versions starting
from around May 2024.

(cherry picked from commit 9fd85e5)
  • Loading branch information
white-axe authored Jul 27, 2024
1 parent 19baad9 commit f67bfdd
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 45 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions assets/themes/catppuccin_frappe.ron
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ Visuals(
color: Color32((48, 52, 70, 255)),
),
resize_corner_size: 12.0,
text_cursor: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
text_cursor: TextCursorStyle(
stroke: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
),
preview: false,
blink: true,
on_duration: 0.5,
off_duration: 0.5,
),
text_cursor_preview: false,
clip_rect_margin: 3.0,
Expand All @@ -164,4 +170,4 @@ Visuals(
interact_cursor: None,
image_loading_spinners: true,
numeric_color_space: GammaByte,
)
)
14 changes: 10 additions & 4 deletions assets/themes/catppuccin_latte.ron
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ Visuals(
color: Color32((239, 241, 245, 255)),
),
resize_corner_size: 12.0,
text_cursor: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
text_cursor: TextCursorStyle(
stroke: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
),
preview: false,
blink: true,
on_duration: 0.5,
off_duration: 0.5,
),
text_cursor_preview: false,
clip_rect_margin: 3.0,
Expand All @@ -164,4 +170,4 @@ Visuals(
interact_cursor: None,
image_loading_spinners: true,
numeric_color_space: GammaByte,
)
)
14 changes: 10 additions & 4 deletions assets/themes/catppuccin_macchiato.ron
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ Visuals(
color: Color32((36, 39, 58, 255)),
),
resize_corner_size: 12.0,
text_cursor: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
text_cursor: TextCursorStyle(
stroke: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
),
preview: false,
blink: true,
on_duration: 0.5,
off_duration: 0.5,
),
text_cursor_preview: false,
clip_rect_margin: 3.0,
Expand All @@ -164,4 +170,4 @@ Visuals(
interact_cursor: None,
image_loading_spinners: true,
numeric_color_space: GammaByte,
)
)
12 changes: 9 additions & 3 deletions assets/themes/catppuccin_mocha.ron
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ Visuals(
color: Color32((30, 30, 46, 255)),
),
resize_corner_size: 12.0,
text_cursor: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
text_cursor: TextCursorStyle(
stroke: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
),
preview: false,
blink: true,
on_duration: 0.5,
off_duration: 0.5,
),
text_cursor_preview: false,
clip_rect_margin: 3.0,
Expand Down
12 changes: 9 additions & 3 deletions assets/themes/luminol.ron
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ Visuals(
color: Color32((0, 0, 0, 96)),
),
resize_corner_size: 12.0,
text_cursor: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
text_cursor: TextCursorStyle(
stroke: Stroke(
width: 2.0,
color: Color32((192, 222, 255, 255)),
),
preview: false,
blink: true,
on_duration: 0.5,
off_duration: 0.5,
),
text_cursor_preview: false,
clip_rect_margin: 3.0,
Expand Down
18 changes: 13 additions & 5 deletions crates/components/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ pub struct EnumComboBox<'a, H, T> {
reference: &'a mut T,

max_width: f32,
wrap_mode: egui::TextWrapMode,
}

impl<'a, H, T> EnumComboBox<'a, H, T>
Expand All @@ -180,11 +181,18 @@ where
id_source,
reference,
max_width: f32::INFINITY,
wrap_mode: egui::TextWrapMode::Wrap,
}
}

pub fn max_width(self, max_width: f32) -> Self {
Self { max_width, ..self }
pub fn max_width(mut self, max_width: f32) -> Self {
self.max_width = max_width;
self
}

pub fn wrap_mode(mut self, wrap_mode: egui::TextWrapMode) -> Self {
self.wrap_mode = wrap_mode;
self
}
}

Expand All @@ -202,7 +210,7 @@ where
.width(width)
.selected_text(self.reference.to_string())
.show_ui(ui, |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);
ui.style_mut().wrap_mode = Some(self.wrap_mode);

for (i, variant) in T::iter().enumerate() {
ui.with_stripe(i % 2 != 0, |ui| {
Expand Down Expand Up @@ -409,7 +417,7 @@ where
}
},
|this, ui, ids, first_row_is_faint, show_none| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);

if show_none
&& ui
Expand Down Expand Up @@ -465,7 +473,7 @@ where
ui,
|this| (this.formatter)(*this.reference),
|this, ui, ids, first_row_is_faint, _| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);

let mut is_faint = first_row_is_faint;

Expand Down
39 changes: 24 additions & 15 deletions crates/filesystem/src/path_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,25 +171,34 @@ impl Cache {
.file_stem()
.unwrap_or(entry.file_name())
.to_lowercase();

let entry_extension = camino::Utf8Path::new(entry.file_name())
.extension()
.unwrap_or_default()
.to_lowercase();
let index = self.cactus.insert(CactusNode {
value: entry.file_name().to_string(),
next: cactus_index,
len,
});
self.trie
.get_or_create_file_with_mut(
if lower_string.is_empty() {
with_trie_suffix(&entry_name)
} else {
format!("{lower_string}/{entry_name}/{TRIE_SUFFIX}").into()
},
Default::default,
)
.insert_str(&entry_extension, index);

let extension_trie = self.trie.get_or_create_file_with_mut(
if lower_string.is_empty() {
with_trie_suffix(&entry_name)
} else {
format!("{lower_string}/{entry_name}/{TRIE_SUFFIX}").into()
},
Default::default,
);

let index = extension_trie
.get_str(&entry_extension)
.copied()
.unwrap_or_else(|| {
let index = self.cactus.insert(CactusNode {
value: entry.file_name().to_string(),
next: cactus_index,
len,
});
extension_trie.insert_str(&entry_extension, index);
index
});

if entry_name == name {
original_name = Some(entry.file_name().to_string());
new_cactus_index = index;
Expand Down
4 changes: 4 additions & 0 deletions crates/ui/src/tabs/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ impl luminol_core::Tab for Tab {
}
},
|ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

// TODO: Add layer enable button
// Display all layers.
egui::Grid::new(self.id().with("layer_select"))
Expand Down Expand Up @@ -305,6 +307,8 @@ impl luminol_core::Tab for Tab {
ui.separator();

ui.menu_button("Display options ⏷", |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

ui.checkbox(&mut self.view.visible_display, "Display visible area")
.on_hover_text("Display the visible area in-game (640x480)");
ui.checkbox(&mut self.view.move_preview, "Preview event move routes")
Expand Down
2 changes: 2 additions & 0 deletions crates/ui/src/windows/command_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ impl luminol_core::window::Window for CommandGeneratorWindow {
ui.menu_button(
format!("{} ⏷", <&str>::from(&command.kind)),
|ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

for kind in CommandKind::iter() {
let text =<&str>::from(&kind);
ui.selectable_value(
Expand Down
4 changes: 4 additions & 0 deletions crates/ui/src/windows/command_gen/parameter_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub fn parameter_ui(
) {
ui.horizontal(|ui| {
ui.menu_button(format!("{} ⏷", <&str>::from(&*parameter)), |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

for iter_kind in Parameter::iter() {
if let Parameter::Group {ref mut guid , ..}
| Parameter::Selection { ref mut guid, .. } = parameter {
Expand Down Expand Up @@ -164,6 +166,8 @@ pub fn parameter_ui(
ui.horizontal(|ui| {
ui.label("Type: ");
ui.menu_button(format!("{} ⏷", <&str>::from(&*kind)), |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

for iter_kind in ParameterKind::iter() {
let text: &str = (&iter_kind).into();
ui.selectable_value(kind, iter_kind, text);
Expand Down
4 changes: 4 additions & 0 deletions crates/ui/src/windows/command_gen/ui_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ impl UiExample {
ParameterKind::Enum { ref variants } => {
let (first_name, mut first_id) = variants.first().unwrap();
ui.menu_button(format!("{first_name} ⏷"), |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

for (name, id) in variants.iter() {
ui.selectable_value(&mut first_id, *id, name);
}
});
}
ParameterKind::SelfSwitch => {
ui.menu_button("A ⏷", |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

for char in ['A', 'B', 'C', 'D'] {
ui.selectable_value(&mut 'A', char, char.to_string());
}
Expand Down
3 changes: 2 additions & 1 deletion crates/ui/src/windows/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ impl luminol_core::Window for Window {
"luminol_term_config_ui_cursor_blinking",
&mut config.cursor_blinking,
)
.max_width(12.),
.max_width(12.)
.wrap_mode(egui::TextWrapMode::Extend),
)
.ui(ui);
ui.add_space(6.);
Expand Down
16 changes: 14 additions & 2 deletions src/app/top_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ impl TopBar {
.ctx
.send_viewport_cmd(egui::ViewportCommand::Fullscreen(self.fullscreen));
}

ui.separator();
}

let mut open_project = ui.input(|i| i.modifiers.command && i.key_pressed(egui::Key::O))
Expand All @@ -58,9 +60,9 @@ impl TopBar {
.add_window(luminol_ui::windows::new_project::Window::default());
}

ui.separator();

ui.menu_button("File", |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

// Hide this menu if the unsaved changes modal or a file/folder picker is open
if update_state.project_manager.is_modal_open()
|| update_state.project_manager.is_picker_open()
Expand Down Expand Up @@ -115,6 +117,8 @@ impl TopBar {
ui.separator();

ui.menu_button("Edit", |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

// Hide this menu if the unsaved changes modal or a file/folder picker is open
if update_state.project_manager.is_modal_open()
|| update_state.project_manager.is_picker_open()
Expand Down Expand Up @@ -147,6 +151,8 @@ impl TopBar {
ui.separator();

ui.menu_button("Data", |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

// Hide this menu if the unsaved changes modal or a file/folder picker is open
if update_state.project_manager.is_modal_open()
|| update_state.project_manager.is_picker_open()
Expand Down Expand Up @@ -260,6 +266,8 @@ impl TopBar {
ui.separator();

ui.menu_button("Tools", |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

// Hide this menu if the unsaved changes modal or a file/folder picker is open
if update_state.project_manager.is_modal_open()
|| update_state.project_manager.is_picker_open()
Expand All @@ -283,6 +291,8 @@ impl TopBar {
ui.separator();

ui.menu_button("Help", |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

// Hide this menu if the unsaved changes modal or a file/folder picker is open
if update_state.project_manager.is_modal_open()
|| update_state.project_manager.is_picker_open()
Expand All @@ -300,6 +310,8 @@ impl TopBar {
});

ui.menu_button("Debug", |ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

// Hide this menu if the unsaved changes modal or a file/folder picker is open
if update_state.project_manager.is_modal_open()
|| update_state.project_manager.is_picker_open()
Expand Down

0 comments on commit f67bfdd

Please sign in to comment.