Skip to content

Commit 35da029

Browse files
committed
add label for show file path
1 parent 86741e1 commit 35da029

File tree

11 files changed

+209
-128
lines changed

11 files changed

+209
-128
lines changed

Cargo.lock

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ eframe = { version = "0.31.1", features = ["persistence"] }
3232
egui_extras = "0.31.1"
3333
egui_flex = "0.3.0"
3434

35+
egui_autocomplete = { version = "10.2.0", features = ["serde"] }
36+
3537
tokio = { version = "1.44.2", features = ["full"] }
3638
parking_lot = { version = "0.12.3", features = ["deadlock_detection"] }
3739

asm_egui/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ eframe = { workspace = true }
2020
egui_extras = { workspace = true }
2121
egui_flex = { workspace = true }
2222

23+
egui_autocomplete = { workspace = true }
24+
2325
fontdb = { workspace = true }
2426
rfd = { workspace = true }

asm_egui/src/app.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,6 @@ impl EguiApp {
3030
}
3131

3232
impl EguiApp {
33-
fn top_bar(&mut self, ctx: &Context) {
34-
egui::TopBottomPanel::top("top_bar").show(ctx, |ui| {
35-
let server_app = &self.server_app;
36-
// loading state
37-
let locked_top = server_app.top().lock();
38-
let loading_state = &locked_top.loading_state;
39-
if loading_state.in_loading {
40-
ui.horizontal(|ui| {
41-
ui.label(format!("Loading... {:.2}%", loading_state.loading_progress * 100.0));
42-
});
43-
}
44-
45-
// interaction area
46-
ui.horizontal(|ui| {
47-
if ui.button("📂 Open...").clicked() {
48-
AsmServer::dialog_to_open_file(
49-
self.server.clone(), server_app.clone(),
50-
);
51-
}
52-
});
53-
});
54-
}
55-
5633
fn left_bar(&mut self, ctx: &Context) {
5734
let available = ctx.available_rect().width();
5835
egui::SidePanel::left("left_bar")

asm_egui/src/file_tab.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
use std::ops::DerefMut;
21
use eframe::emath::Align;
32
use eframe::epaint::StrokeKind;
43
use egui::{Layout, Pos2, Rect, Response, Sense, TextStyle, Ui, Vec2, WidgetInfo, WidgetText, WidgetType};
54
use egui_flex::{item, Flex, FlexAlignContent};
65
use java_asm::StrRef;
7-
use java_asm_server::ui::{AppContainer, Tab};
6+
use java_asm_server::ui::{AppContainer, Tab, Top};
7+
use std::ops::DerefMut;
88

99
pub fn render_tabs(
1010
ui: &mut Ui, app_container: &AppContainer,
1111
) {
1212
let mut deleted_tab = None;
13+
let mut top = app_container.top().lock();
1314
let mut content_locked = app_container.content().lock();
1415
let content_ref = content_locked.deref_mut();
1516
let selected_tab_index = &mut content_ref.selected;
@@ -21,7 +22,7 @@ pub fn render_tabs(
2122
.show(ui, |flex| {
2223
for tab in opened_tabs.iter().enumerate() {
2324
flex.add_ui(item(), |ui: &mut Ui| {
24-
file_title(ui, selected_tab_index, &mut deleted_tab, tab)
25+
file_title(ui, &mut top, selected_tab_index, &mut deleted_tab, tab)
2526
});
2627
}
2728
});
@@ -31,10 +32,14 @@ pub fn render_tabs(
3132
}
3233
}
3334

34-
fn file_title(ui: &mut Ui, selected_tab_index: &mut Option<usize>, deleted_tab: &mut Option<usize>, tab: (usize, &Tab)) {
35+
fn file_title(
36+
ui: &mut Ui, top: &mut Top,
37+
selected_tab_index: &mut Option<usize>, deleted_tab: &mut Option<usize>, tab: (usize, &Tab)
38+
) {
3539
let (index, tab) = tab;
3640
let selected = selected_tab_index.map(|current| current == index).unwrap_or_default();
3741
let title = tab.title.clone();
42+
let title_cloned = title.clone();
3843
let selectable_label = SelectableClosableLabel { selected, title };
3944
let response = selectable_label.ui(ui);
4045
if response.closed {
@@ -49,6 +54,7 @@ fn file_title(ui: &mut Ui, selected_tab_index: &mut Option<usize>, deleted_tab:
4954
}
5055
} else if response.raw.clicked() {
5156
*selected_tab_index = Some(index);
57+
top.file_path = Some(title_cloned.to_string());
5258
}
5359
}
5460

asm_egui/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub(crate) mod file_tree;
66
pub(crate) mod util;
77
mod smali;
88
mod file_tab;
9+
mod top_bar;
910

1011
fn main() -> eframe::Result {
1112
let eframe_options = eframe::NativeOptions {

0 commit comments

Comments
 (0)