Skip to content

Commit e4e5719

Browse files
committed
Add configurable toolbar icon sizes
Introduce a toolbar_icon_size setting (1=XS..5=XL) with serde default and Default impl. Add UI in settings panel to pick XS/S/M/L/XL and save on change. Make toolbar height and toolbar button/icon sizes adapt to the selected preset (including small icon buttons). Bump package version to 0.4.2.
1 parent efe3337 commit e4e5719

5 files changed

Lines changed: 51 additions & 8 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sen"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
edition = "2021"
55
authors = ["Dawid Wasowski"]
66
description = "Secure Encrypted Notepad with keyfile-only auth"

src/app.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,18 @@ impl eframe::App for EditorApp {
393393
// Confirmation dialog
394394
self.render_confirmation_dialog(ctx);
395395

396-
// Toolbar
396+
// Toolbar — height adapts to icon size
397+
let toolbar_height = match self.settings.toolbar_icon_size {
398+
1 => 30.0,
399+
2 => 36.0,
400+
4 => 46.0,
401+
5 => 52.0,
402+
_ => 40.0, // 3 = Medium
403+
};
397404
egui::TopBottomPanel::top("toolbar")
398-
.min_height(50.0)
405+
.exact_height(toolbar_height)
399406
.show(ctx, |ui| {
400-
ui.add_space(4.0);
407+
ui.add_space(2.0);
401408
self.render_toolbar(ui);
402409
});
403410

src/settings.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ pub struct Settings {
8080
pub window_pos_x: f32,
8181
#[serde(default)]
8282
pub window_pos_y: f32,
83+
/// Toolbar icon size preset (1=XS, 2=S, 3=M, 4=L, 5=XL)
84+
#[serde(default = "default_toolbar_icon_size")]
85+
pub toolbar_icon_size: u8,
8386
}
8487

8588
fn default_window_width() -> f32 {
@@ -98,6 +101,10 @@ fn default_editor_font() -> String {
98101
"Monospace".to_string()
99102
}
100103

104+
fn default_toolbar_icon_size() -> u8 {
105+
3
106+
}
107+
101108
impl Default for Settings {
102109
fn default() -> Self {
103110
Self {
@@ -129,6 +136,7 @@ impl Default for Settings {
129136
window_height: 800.0,
130137
window_pos_x: -1.0, // -1 means "let OS decide" or "center"
131138
window_pos_y: -1.0,
139+
toolbar_icon_size: 3, // Medium
132140
}
133141
}
134142
}

src/ui_panels.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,19 @@ impl EditorApp {
181181
}
182182
});
183183

184+
// Toolbar icon size
185+
ui.horizontal(|ui| {
186+
ui.label("Icon Size:");
187+
let labels = ["XS", "S", "M", "L", "XL"];
188+
for (i, label) in labels.iter().enumerate() {
189+
let val = (i + 1) as u8;
190+
if ui.selectable_label(self.settings.toolbar_icon_size == val, *label).clicked() {
191+
self.settings.toolbar_icon_size = val;
192+
let _ = self.settings.save();
193+
}
194+
}
195+
});
196+
184197
ui.separator();
185198

186199
ui.horizontal(|ui| {

src/ui_toolbar.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ impl EditorApp {
66
pub(crate) fn render_toolbar(&mut self, ui: &mut egui::Ui) {
77
ui.horizontal(|ui| {
88
ui.spacing_mut().item_spacing.x = 4.0;
9-
let button_size = egui::vec2(32.0, 32.0);
10-
let icon_size = egui::vec2(24.0, 24.0);
9+
// Icon sizes based on setting (1=XS, 2=S, 3=M, 4=L, 5=XL)
10+
let (btn_s, ico_s) = match self.settings.toolbar_icon_size {
11+
1 => (22.0, 16.0),
12+
2 => (28.0, 20.0),
13+
4 => (38.0, 28.0),
14+
5 => (44.0, 34.0),
15+
_ => (32.0, 24.0), // 3 = Medium (default)
16+
};
17+
let button_size = egui::vec2(btn_s, btn_s);
18+
let icon_size = egui::vec2(ico_s, ico_s);
1119
let hover_tint = self.current_theme.colors.icon_hover_color();
1220
let default_tint = self.current_theme.colors.icon_color();
1321

@@ -72,8 +80,15 @@ impl EditorApp {
7280
ui.separator();
7381

7482
// Small icon buttons for keyfile operations
75-
let small_icon_size = egui::vec2(20.0, 20.0);
76-
let small_button_size = egui::vec2(28.0, 28.0);
83+
let (sm_btn_s, sm_ico_s) = match self.settings.toolbar_icon_size {
84+
1 => (18.0, 14.0),
85+
2 => (22.0, 16.0),
86+
4 => (32.0, 24.0),
87+
5 => (38.0, 28.0),
88+
_ => (28.0, 20.0), // 3 = Medium (default)
89+
};
90+
let small_icon_size = egui::vec2(sm_ico_s, sm_ico_s);
91+
let small_button_size = egui::vec2(sm_btn_s, sm_btn_s);
7792

7893
let small_icon_btn =
7994
|ui: &mut egui::Ui, icon: &egui::TextureHandle, tooltip: &str| -> egui::Response {

0 commit comments

Comments
 (0)