Skip to content

Commit 2b7207b

Browse files
committed
fix top-panel ui
1 parent 0371320 commit 2b7207b

5 files changed

Lines changed: 105 additions & 53 deletions

File tree

assets/icons/tabler/layout.svg

Lines changed: 16 additions & 0 deletions
Loading

assets/icons/tabler/zoom-scan.svg

Lines changed: 19 additions & 0 deletions
Loading

src/app.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ use self::formula::{formula_svg_bytes, formula_svg_uri};
3030
use self::i18n::{
3131
center_origin_icon_image, clear_icon_image, family_label, fit_icon_image,
3232
fit_to_content_icon_image, github_mark_image, language_flag_image, model_choice_label,
33-
optimization_loss_metric_label, param_init_method_disabled_label, param_init_method_label,
34-
param_init_method_name_en, redo_icon_image, replay_pause_icon_image, replay_play_icon_image,
35-
reset_icon_image, spline_extrapolation_label, spline_knot_strategy_label, spray_brush_label,
36-
stop_icon_image, tool_icon_image, tool_label, tr, undo_icon_image,
33+
optimization_loss_metric_label, panels_icon_image, param_init_method_disabled_label,
34+
param_init_method_label, param_init_method_name_en, redo_icon_image, replay_pause_icon_image,
35+
replay_play_icon_image, reset_icon_image, spline_extrapolation_label,
36+
spline_knot_strategy_label, spray_brush_label, stop_icon_image, tool_icon_image, tool_label,
37+
tr, undo_icon_image, view_icon_image,
3738
};
3839
use self::optimizer::{
3940
LbfgsInputState, NelderMeadInputState, OptimizerPreset, OptimizerUiMode,

src/app/i18n.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ pub(super) fn center_origin_icon_image(tint: egui::Color32) -> egui::Image<'stat
4848
tabler_icon!("../../assets/icons/tabler/focus-2.svg", tint)
4949
}
5050

51+
pub(super) fn view_icon_image(tint: egui::Color32) -> egui::Image<'static> {
52+
tabler_icon!("../../assets/icons/tabler/zoom-scan.svg", tint)
53+
}
54+
55+
pub(super) fn panels_icon_image(tint: egui::Color32) -> egui::Image<'static> {
56+
tabler_icon!("../../assets/icons/tabler/layout.svg", tint)
57+
}
58+
5159
pub(super) fn undo_icon_image(tint: egui::Color32) -> egui::Image<'static> {
5260
tabler_icon!("../../assets/icons/tabler/arrow-back-up.svg", tint)
5361
}

src/app/ui.rs

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -283,57 +283,65 @@ impl CurveFitApp {
283283
.auto_shrink([false; 2])
284284
.show(ui, |ui| {
285285
ui.horizontal(|ui| {
286-
ui.menu_button(tr(language, "View", "Вид"), |ui| {
287-
if ui
288-
.add(egui::Button::image_and_text(
289-
fit_to_content_icon_image(icon_tint),
290-
tr(language, "Fit to content", "Подогнать по содержимому"),
291-
))
292-
.clicked()
293-
{
294-
self.fit_to_content_requested = true;
295-
ui.close();
296-
}
297-
if ui
298-
.add(egui::Button::image_and_text(
299-
center_origin_icon_image(icon_tint),
300-
tr(language, "Center to 0,0", "Центр к 0,0"),
301-
))
302-
.clicked()
303-
{
304-
self.center_origin_requested = true;
305-
self.origin_bottom_left_requested = false;
306-
ui.close();
307-
}
308-
if ui
309-
.add(egui::Button::new(tr(
310-
language,
311-
"Set 0,0 to bottom-left",
312-
"0,0 в левый нижний угол",
313-
)))
314-
.clicked()
315-
{
316-
self.origin_bottom_left_requested = true;
317-
self.center_origin_requested = false;
318-
ui.close();
319-
}
320-
});
286+
ui.menu_image_text_button(
287+
view_icon_image(icon_tint),
288+
tr(language, "View", "Вид"),
289+
|ui| {
290+
if ui
291+
.add(egui::Button::image_and_text(
292+
fit_to_content_icon_image(icon_tint),
293+
tr(language, "Fit to content", "Подогнать по содержимому"),
294+
))
295+
.clicked()
296+
{
297+
self.fit_to_content_requested = true;
298+
ui.close();
299+
}
300+
if ui
301+
.add(egui::Button::image_and_text(
302+
center_origin_icon_image(icon_tint),
303+
tr(language, "Center to 0,0", "Центр к 0,0"),
304+
))
305+
.clicked()
306+
{
307+
self.center_origin_requested = true;
308+
self.origin_bottom_left_requested = false;
309+
ui.close();
310+
}
311+
if ui
312+
.add(egui::Button::new(tr(
313+
language,
314+
"Set 0,0 to bottom-left",
315+
"0,0 в левый нижний угол",
316+
)))
317+
.clicked()
318+
{
319+
self.origin_bottom_left_requested = true;
320+
self.center_origin_requested = false;
321+
ui.close();
322+
}
323+
},
324+
);
321325

322326
ui.separator();
323-
ui.menu_button(tr(language, "Panels", "Панели"), |ui| {
324-
ui.toggle_value(
325-
&mut self.show_left_panel,
326-
tr(language, "Left panel", "Левая панель"),
327-
);
328-
ui.toggle_value(
329-
&mut self.show_right_panel,
330-
tr(language, "Right panel", "Правая панель"),
331-
);
332-
ui.toggle_value(
333-
&mut self.show_diagnostics_panel,
334-
tr(language, "Diagnostics", "Диагностика"),
335-
);
336-
});
327+
ui.menu_image_text_button(
328+
panels_icon_image(icon_tint),
329+
tr(language, "Panels", "Панели"),
330+
|ui| {
331+
ui.checkbox(
332+
&mut self.show_left_panel,
333+
tr(language, "Left panel", "Левая панель"),
334+
);
335+
ui.checkbox(
336+
&mut self.show_right_panel,
337+
tr(language, "Right panel", "Правая панель"),
338+
);
339+
ui.checkbox(
340+
&mut self.show_diagnostics_panel,
341+
tr(language, "Diagnostics", "Диагностика"),
342+
);
343+
},
344+
);
337345

338346
ui.separator();
339347
let (min_iteration, max_iteration) =

0 commit comments

Comments
 (0)