Skip to content

Commit

Permalink
Make console resizable and horizontally scrollable
Browse files Browse the repository at this point in the history
This also fixes issue #43
  • Loading branch information
ergrelet committed Mar 9, 2024
1 parent 441ddc9 commit 22cb549
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion resym/src/resym_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ impl ResymApp {

fn update_bottom_panel(&mut self, ctx: &egui::Context) {
egui::TopBottomPanel::bottom("bottom_panel")
.default_height(100.0)
.min_height(100.0)
.resizable(true)
.show(ctx, |ui| {
// Console panel
ui.vertical(|ui| {
Expand Down
18 changes: 10 additions & 8 deletions resym/src/ui_components/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,27 @@ impl ConsoleComponent {
}

pub fn update(&mut self, ui: &mut egui::Ui) {
// Update console
// Update console content
self.content
.extend(self.logger.read().lines().map(|s| s.to_string()));
self.logger.clear();

const TEXT_STYLE: TextStyle = TextStyle::Monospace;
let row_height = ui.text_style_height(&TEXT_STYLE);
let num_rows = self.content.len();
ScrollArea::vertical()
.auto_shrink([false, false])
.stick_to_bottom(true)
.show_rows(ui, row_height, num_rows, |ui, row_range| {
ScrollArea::both().stick_to_bottom(true).show_rows(
ui,
row_height,
num_rows,
|ui, row_range| {
for row_index in row_range {
ui.add(
egui::TextEdit::singleline(&mut self.content[row_index].as_str())
.font(egui::TextStyle::Monospace)
.desired_width(f32::INFINITY),
.font(TEXT_STYLE)
.clip_text(false),
);
}
});
},
);
}
}

0 comments on commit 22cb549

Please sign in to comment.