mirror of
https://github.com/hinto-janai/gupax.git
synced 2024-11-18 02:07:40 +00:00
p2pool: add sized, scrollable, selectable but not mutable console
This replaces the old mutable [TextEdit] with an immutable one with a scroll area wrapped in a [Frame]. Passing a [&str] instead of a [String] to [TextEdit] makes it auto-select only and not mutable by the user. The background color is changed because the immutable [TextEdit] has a hardcoded light gray color (same as the general ui background).
This commit is contained in:
parent
9576a94498
commit
aff46a96d0
2 changed files with 19 additions and 1 deletions
|
@ -443,6 +443,7 @@ fn init_text_styles(ctx: &egui::Context, width: f32) {
|
|||
style.spacing.icon_width_inner = width / 35.0;
|
||||
style.spacing.icon_width = width / 25.0;
|
||||
style.spacing.icon_spacing = 20.0;
|
||||
style.spacing.scroll_bar_width = width / 150.0;
|
||||
ctx.set_style(style);
|
||||
ctx.set_pixels_per_point(1.0);
|
||||
ctx.request_repaint();
|
||||
|
|
|
@ -38,7 +38,24 @@ impl P2pool {
|
|||
let height = height / 10.0;
|
||||
let width = width - SPACE;
|
||||
ui.style_mut().override_text_style = Some(Monospace);
|
||||
ui.add_sized([width, height*3.5], TextEdit::multiline(&mut "".to_string()));
|
||||
//ui.add_sized([width, height*3.5], TextEdit::multiline(&mut "asdf"));
|
||||
egui::Frame::none()
|
||||
.fill(Color32::from_rgb(18, 18, 18))
|
||||
.show(ui, |ui| {
|
||||
let text_style = egui::TextStyle::Monospace;
|
||||
let row_height = ui.text_style_height(&text_style);
|
||||
let total_rows = 10_000;
|
||||
let width = width-(SPACE*2.0);
|
||||
egui::ScrollArea::vertical().max_width(width).max_height(height*3.5).auto_shrink([false; 2]).show_rows(ui, row_height, total_rows, |ui, row_range| {
|
||||
let mut text = "".to_string();
|
||||
for row in row_range {
|
||||
text = format!("{}Row {}/{}\n", text, row + 1, total_rows);
|
||||
// ui.label(text);
|
||||
}
|
||||
ui.add_sized([width, height*3.5], TextEdit::multiline(&mut text.as_str()));
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
ui.add_sized([width, text_edit], TextEdit::hint_text(TextEdit::singleline(&mut "".to_string()), r#"Type a command (e.g "help" or "status") and press Enter"#));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue