init, basic glogg clone
This commit is contained in:
49
src/ui/top_menu.rs
Normal file
49
src/ui/top_menu.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use eframe::egui;
|
||||
|
||||
use crate::highlight::HighlightManager;
|
||||
use crate::tab_manager::IndexingState;
|
||||
|
||||
pub fn render_top_menu(
|
||||
ctx: &egui::Context,
|
||||
highlight_manager: &mut HighlightManager,
|
||||
indexing_state: &IndexingState,
|
||||
on_open_file: &mut bool,
|
||||
) {
|
||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("📂 Open File").clicked() {
|
||||
*on_open_file = true;
|
||||
}
|
||||
|
||||
if ui.button("🎨 Highlights").clicked() {
|
||||
highlight_manager.toggle_editor();
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
|
||||
let mut to_toggle = None;
|
||||
for (idx, rule) in highlight_manager.rules.iter().enumerate() {
|
||||
let color = egui::Color32::from_rgb(rule.color[0], rule.color[1], rule.color[2]);
|
||||
let button_text = egui::RichText::new(&rule.pattern)
|
||||
.background_color(color)
|
||||
.color(egui::Color32::BLACK);
|
||||
|
||||
if ui.selectable_label(rule.enabled, button_text).clicked() {
|
||||
to_toggle = Some(idx);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(idx) = to_toggle {
|
||||
highlight_manager.toggle_rule(idx);
|
||||
// Signal that config should be saved
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
|
||||
if indexing_state.is_indexing() {
|
||||
ui.spinner();
|
||||
ui.label("Indexing...");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user