@@ -110,6 +110,7 @@ fn main() {
110
110
Ok ( profiler) => {
111
111
* GlobalProfiler :: lock ( ) = profiler;
112
112
PuffinViewer {
113
+ profiler_ui : Default :: default ( ) ,
113
114
source : Source :: File ( path) ,
114
115
error : None ,
115
116
}
@@ -121,6 +122,7 @@ fn main() {
121
122
}
122
123
} else {
123
124
PuffinViewer {
125
+ profiler_ui : Default :: default ( ) ,
124
126
source : Source :: Http ( puffin_http:: Client :: new ( opt. url ) ) ,
125
127
error : None ,
126
128
}
@@ -153,6 +155,7 @@ impl Source {
153
155
}
154
156
155
157
pub struct PuffinViewer {
158
+ profiler_ui : puffin_egui:: ProfilerUi ,
156
159
source : Source ,
157
160
error : Option < String > ,
158
161
}
@@ -166,14 +169,15 @@ impl epi::App for PuffinViewer {
166
169
egui:: TopBottomPanel :: top ( "menu_bar" ) . show ( ctx, |ui| {
167
170
egui:: menu:: bar ( ui, |ui| {
168
171
egui:: menu:: menu ( ui, "File" , |ui| {
169
- if ui. button ( "Load …" ) . clicked ( ) {
172
+ if ui. button ( "Open …" ) . clicked ( ) {
170
173
if let Some ( path) = rfd:: FileDialog :: new ( )
171
174
. add_filter ( "puffin" , & [ "puffin" ] )
172
175
. pick_file ( )
173
176
{
174
177
match GlobalProfiler :: load_path ( & path) {
175
178
Ok ( profiler) => {
176
179
* GlobalProfiler :: lock ( ) = profiler;
180
+ self . profiler_ui . reset ( ) ;
177
181
self . source = Source :: File ( path) ;
178
182
self . error = None ;
179
183
}
@@ -185,7 +189,7 @@ impl epi::App for PuffinViewer {
185
189
}
186
190
}
187
191
188
- if ui. button ( "Save…" ) . clicked ( ) {
192
+ if ui. button ( "Save as …" ) . clicked ( ) {
189
193
if let Some ( path) = rfd:: FileDialog :: new ( )
190
194
. add_filter ( "puffin" , & [ "puffin" ] )
191
195
. save_file ( )
@@ -214,6 +218,8 @@ impl epi::App for PuffinViewer {
214
218
self . source . ui ( ui) ;
215
219
} ) ;
216
220
217
- egui:: CentralPanel :: default ( ) . show ( ctx, puffin_egui:: profiler_ui) ;
221
+ egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
222
+ self . profiler_ui . ui ( ui) ;
223
+ } ) ;
218
224
}
219
225
}
0 commit comments