cleaner UI

This commit is contained in:
2025-12-02 19:50:12 +01:00
parent 75df916d97
commit c24d94ca2b
5 changed files with 194 additions and 66 deletions

View File

@@ -1,6 +1,7 @@
use eframe::egui;
use crate::file_tab::FileTab;
use crate::theme;
use crate::types::HighlightRule;
pub struct LogViewContext<'a> {
@@ -86,7 +87,7 @@ fn handle_scroll_to_line(
) {
if tab.scroll_to_main {
let target_row = tab.main_scroll_offset;
let adgusted_row_height = row_height + 3f32;
let adgusted_row_height = row_height + 6f32;
let scroll_offset = (target_row as f32) * adgusted_row_height;
eprintln!("=== SCROLL TO LINE ===");
@@ -110,7 +111,7 @@ fn handle_page_scroll(
total_lines: usize,
) {
if let Some(direction) = tab.page_scroll_direction.take() {
let row_height_offset = row_height + 3f32;
let row_height_offset = row_height + 6f32;
let viewport_height = ui.available_height();
let rows_per_page = (viewport_height / row_height_offset).floor().max(1.0);
let scroll_delta = direction * rows_per_page * row_height_offset;
@@ -192,49 +193,59 @@ fn render_line<F>(
) where
F: FnOnce(bool),
{
let palette = theme::get_palette();
let highlight_color = highlight_rules
.iter()
.find(|rule| rule.enabled && content.contains(&rule.pattern))
.map(|rule| egui::Color32::from_rgb(rule.color[0], rule.color[1], rule.color[2]));
// Improved color scheme with better visual hierarchy
let bg_color = if is_selected {
egui::Color32::from_rgb(70, 130, 180)
palette.selection
} else if let Some(color) = highlight_color {
color
} else {
egui::Color32::TRANSPARENT
};
// Better padding and margins for improved readability
let frame = egui::Frame::none()
.fill(bg_color)
.inner_margin(egui::Margin::symmetric(2.0, 1.0));
.inner_margin(egui::Margin::symmetric(8.0, 3.0));
frame.show(ui, |ui| {
ui.horizontal(|ui| {
let line_num_text = egui::RichText::new(format!("{:6} ", line_num + 1))
// Line numbers with better styling
let line_num_text = egui::RichText::new(format!("{:6}", line_num + 1))
.monospace()
.color(if is_selected {
egui::Color32::WHITE
palette.text_primary
} else {
egui::Color32::DARK_GRAY
palette.line_number
});
let line_num_response = ui.label(line_num_text);
// Separator between line number and content
ui.add_space(4.0);
ui.separator();
ui.add_space(4.0);
// Content text with improved styling
let text = egui::RichText::new(content).monospace().color(
if is_selected {
egui::Color32::WHITE
palette.text_primary
} else {
ui.style().visuals.text_color()
palette.text_primary
},
);
let text_response = ui
.scope(|ui| {
ui.style_mut().visuals.selection.bg_fill =
egui::Color32::from_rgb(255, 180, 50);
ui.style_mut().visuals.selection.stroke.color =
egui::Color32::from_rgb(200, 140, 30);
// Better text selection colors
ui.style_mut().visuals.selection.bg_fill = palette.accent_bright;
ui.style_mut().visuals.selection.stroke.color = palette.accent_primary;
ui.add(egui::Label::new(text).selectable(true))
})
.inner;

View File

@@ -1,6 +1,7 @@
use eframe::egui;
use crate::search::SearchState;
use crate::theme;
pub struct SearchPanelState {
pub query: String,
@@ -27,59 +28,87 @@ pub fn render_search_panel(
config_changed: false,
};
egui::TopBottomPanel::bottom("search_panel").show(ctx, |ui| {
ui.vertical(|ui| {
ui.horizontal(|ui| {
ui.label("🔍 Filter:");
let palette = theme::get_palette();
let text_edit_width = 200.0;
let text_response = ui.add_sized(
[text_edit_width, 20.0],
egui::TextEdit::singleline(&mut state.query),
);
egui::TopBottomPanel::bottom("search_panel")
.frame(egui::Frame::none()
.fill(palette.bg_secondary)
.inner_margin(egui::Margin::symmetric(12.0, 10.0)))
.show(ctx, |ui| {
ui.vertical(|ui| {
ui.horizontal(|ui| {
// Filter label with icon
let label = egui::RichText::new("🔍 Filter:")
.size(14.0)
.color(palette.text_primary);
ui.label(label);
let enter_pressed =
text_response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
ui.add_space(4.0);
if !state.history.is_empty() {
render_history_dropdown(ui, state);
}
// Text input with proper height matching buttons
let text_edit_width = 300.0;
let text_response = ui.add(
egui::TextEdit::singleline(&mut state.query)
.desired_width(text_edit_width)
.hint_text("Enter search query...")
);
let case_changed = ui
.checkbox(&mut state.case_sensitive, "Case sensitive")
.changed();
let regex_changed = ui.checkbox(&mut state.use_regex, "Regex").changed();
let enter_pressed =
text_response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
if case_changed || regex_changed {
actions.config_changed = true;
}
if ui.button("Search").clicked() || enter_pressed {
actions.execute_search = true;
actions.config_changed = true;
}
if !state.query.is_empty() {
if ui.button("✖ Clear").clicked() {
actions.clear_search = true;
if !state.history.is_empty() {
render_history_dropdown(ui, state);
}
ui.label(format!("({} matches)", match_count));
ui.add_space(8.0);
// Checkboxes
let case_changed = ui
.checkbox(&mut state.case_sensitive, "Case sensitive")
.changed();
let regex_changed = ui.checkbox(&mut state.use_regex, "Regex").changed();
if case_changed || regex_changed {
actions.config_changed = true;
}
ui.add_space(8.0);
// Search button
if ui.button("Search").clicked() || enter_pressed {
actions.execute_search = true;
actions.config_changed = true;
}
// Clear button and match count
if !state.query.is_empty() {
if ui.button("✖ Clear").clicked() {
actions.clear_search = true;
}
ui.add_space(8.0);
let count_text = egui::RichText::new(format!("{} matches", match_count))
.color(palette.accent_bright)
.size(13.0);
ui.label(count_text);
}
});
// Progress bar
if search_state.is_searching() {
ui.add_space(6.0);
let progress = search_state.get_progress();
ui.horizontal(|ui| {
ui.add(
egui::ProgressBar::new(progress)
.text(format!("Searching... {:.0}%", progress * 100.0))
.animate(true),
);
});
}
});
if search_state.is_searching() {
let progress = search_state.get_progress();
ui.horizontal(|ui| {
ui.add(
egui::ProgressBar::new(progress)
.text(format!("Searching... {:.0}%", progress * 100.0))
.animate(true),
);
});
}
});
});
actions
}