Skip to content

Commit 14752c2

Browse files
authored
Merge pull request #69 from devmobasa/pr/presets-polish
Polish presets
2 parents 88f4db4 + 6108271 commit 14752c2

File tree

15 files changed

+588
-364
lines changed

15 files changed

+588
-364
lines changed

config.example.toml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -585,21 +585,21 @@ toggle_zoom_lock = ["Ctrl+Alt+L"]
585585
refresh_zoom_capture = ["Ctrl+Alt+R"]
586586

587587
# Preset slots (apply/save/clear).
588-
apply_preset_1 = ["Alt+1"]
589-
apply_preset_2 = ["Alt+2"]
590-
apply_preset_3 = ["Alt+3"]
591-
apply_preset_4 = ["Alt+4"]
592-
apply_preset_5 = ["Alt+5"]
593-
save_preset_1 = ["Ctrl+Alt+1"]
594-
save_preset_2 = ["Ctrl+Alt+2"]
595-
save_preset_3 = ["Ctrl+Alt+3"]
596-
save_preset_4 = ["Ctrl+Alt+4"]
597-
save_preset_5 = ["Ctrl+Alt+5"]
598-
clear_preset_1 = ["Ctrl+Alt+Shift+1"]
599-
clear_preset_2 = ["Ctrl+Alt+Shift+2"]
600-
clear_preset_3 = ["Ctrl+Alt+Shift+3"]
601-
clear_preset_4 = ["Ctrl+Alt+Shift+4"]
602-
clear_preset_5 = ["Ctrl+Alt+Shift+5"]
588+
apply_preset_1 = ["1"]
589+
apply_preset_2 = ["2"]
590+
apply_preset_3 = ["3"]
591+
apply_preset_4 = ["4"]
592+
apply_preset_5 = ["5"]
593+
save_preset_1 = ["Shift+1"]
594+
save_preset_2 = ["Shift+2"]
595+
save_preset_3 = ["Shift+3"]
596+
save_preset_4 = ["Shift+4"]
597+
save_preset_5 = ["Shift+5"]
598+
clear_preset_1 = []
599+
clear_preset_2 = []
600+
clear_preset_3 = []
601+
clear_preset_4 = []
602+
clear_preset_5 = []
603603

604604
# ───────────────────────────────────────────────────────────────────────────────
605605
# Keybinding Examples

configurator/src/models/fields.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl ToolbarLayoutModeOption {
195195
}
196196
}
197197

198-
pub fn to_mode(&self) -> ToolbarLayoutMode {
198+
pub fn to_mode(self) -> ToolbarLayoutMode {
199199
match self {
200200
ToolbarLayoutModeOption::Simple => ToolbarLayoutMode::Simple,
201201
ToolbarLayoutModeOption::Regular => ToolbarLayoutMode::Regular,
@@ -262,6 +262,7 @@ impl std::fmt::Display for OverrideOption {
262262
}
263263

264264
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
265+
#[allow(clippy::enum_variant_names)]
265266
pub enum ToolbarOverrideField {
266267
ShowPresets,
267268
ShowActionsSection,

docs/CONFIG.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -570,21 +570,21 @@ toggle_zoom_lock = ["Ctrl+Alt+L"]
570570
refresh_zoom_capture = ["Ctrl+Alt+R"]
571571

572572
# Preset slots
573-
apply_preset_1 = ["Alt+1"]
574-
apply_preset_2 = ["Alt+2"]
575-
apply_preset_3 = ["Alt+3"]
576-
apply_preset_4 = ["Alt+4"]
577-
apply_preset_5 = ["Alt+5"]
578-
save_preset_1 = ["Ctrl+Alt+1"]
579-
save_preset_2 = ["Ctrl+Alt+2"]
580-
save_preset_3 = ["Ctrl+Alt+3"]
581-
save_preset_4 = ["Ctrl+Alt+4"]
582-
save_preset_5 = ["Ctrl+Alt+5"]
583-
clear_preset_1 = ["Ctrl+Alt+Shift+1"]
584-
clear_preset_2 = ["Ctrl+Alt+Shift+2"]
585-
clear_preset_3 = ["Ctrl+Alt+Shift+3"]
586-
clear_preset_4 = ["Ctrl+Alt+Shift+4"]
587-
clear_preset_5 = ["Ctrl+Alt+Shift+5"]
573+
apply_preset_1 = ["1"]
574+
apply_preset_2 = ["2"]
575+
apply_preset_3 = ["3"]
576+
apply_preset_4 = ["4"]
577+
apply_preset_5 = ["5"]
578+
save_preset_1 = ["Shift+1"]
579+
save_preset_2 = ["Shift+2"]
580+
save_preset_3 = ["Shift+3"]
581+
save_preset_4 = ["Shift+4"]
582+
save_preset_5 = ["Shift+5"]
583+
clear_preset_1 = []
584+
clear_preset_2 = []
585+
clear_preset_3 = []
586+
clear_preset_4 = []
587+
clear_preset_5 = []
588588

589589
# Help overlay (press F10 while drawing for a full reference)
590590
```

src/backend/wayland/toolbar/layout.rs

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl ToolbarLayoutSpec {
5555
pub(super) const SIDE_COLOR_PICKER_EXTRA_HEIGHT: f64 = 30.0;
5656
pub(super) const SIDE_SLIDER_ROW_OFFSET: f64 = 26.0;
5757
pub(super) const SIDE_NUDGE_SIZE: f64 = 24.0;
58-
pub(super) const SIDE_ACTION_BUTTON_HEIGHT_ICON: f64 = 42.0;
58+
pub(super) const SIDE_ACTION_BUTTON_HEIGHT_ICON: f64 = 32.0;
5959
pub(super) const SIDE_ACTION_BUTTON_HEIGHT_TEXT: f64 = 24.0;
6060
pub(super) const SIDE_ACTION_BUTTON_GAP: f64 = 6.0;
6161
pub(super) const SIDE_ACTION_CONTENT_GAP_TEXT: f64 = 5.0;
@@ -80,7 +80,7 @@ impl ToolbarLayoutSpec {
8080
pub(super) const SIDE_DELAY_SLIDER_HIT_PADDING: f64 = 4.0;
8181
pub(super) const SIDE_DELAY_SLIDER_UNDO_OFFSET_Y: f64 = 16.0;
8282
pub(super) const SIDE_DELAY_SLIDER_REDO_OFFSET_Y: f64 = 32.0;
83-
pub(super) const SIDE_ACTION_ICON_SIZE: f64 = 22.0;
83+
pub(super) const SIDE_ACTION_ICON_SIZE: f64 = 18.0;
8484
pub(super) const SIDE_STEP_SLIDER_TOP_PADDING: f64 = 4.0;
8585
pub(super) const SIDE_SLIDER_CARD_HEIGHT: f64 = 52.0;
8686
pub(super) const SIDE_ERASER_MODE_CARD_HEIGHT: f64 = 44.0;
@@ -90,14 +90,14 @@ impl ToolbarLayoutSpec {
9090
pub(super) const SIDE_TOGGLE_GAP: f64 = 6.0;
9191
pub(super) const SIDE_CUSTOM_SECTION_HEIGHT: f64 = 120.0;
9292
pub(super) const SIDE_STEP_HEADER_HEIGHT: f64 = 20.0;
93-
pub(super) const SIDE_PRESET_CARD_HEIGHT: f64 = 112.0;
93+
pub(super) const SIDE_PRESET_CARD_HEIGHT: f64 = 88.0;
9494
pub(super) const SIDE_PRESET_SLOT_SIZE: f64 = 30.0;
9595
pub(super) const SIDE_PRESET_SLOT_GAP: f64 = 6.0;
9696
pub(super) const SIDE_PRESET_ROW_OFFSET_Y: f64 = 24.0;
9797
pub(super) const SIDE_PRESET_ACTION_GAP: f64 = 6.0;
98-
pub(super) const SIDE_PRESET_ACTION_HEIGHT: f64 = 24.0;
98+
pub(super) const SIDE_PRESET_ACTION_HEIGHT: f64 = 20.0;
9999
pub(super) const SIDE_PRESET_ACTION_BUTTON_GAP: f64 = 4.0;
100-
pub(super) const SIDE_FOOTER_PADDING: f64 = 20.0;
100+
pub(super) const SIDE_FOOTER_PADDING: f64 = 10.0;
101101
pub(super) const SIDE_SETTINGS_BUTTON_HEIGHT: f64 = 24.0;
102102
pub(super) const SIDE_SETTINGS_BUTTON_GAP: f64 = 6.0;
103103

@@ -290,34 +290,29 @@ impl ToolbarLayoutSpec {
290290
return 0.0;
291291
}
292292

293-
let basic_count = if show_actions_section { 3 } else { 0 };
294-
let advanced_count = if show_actions_advanced { 9 } else { 0 };
295-
let gap_between = if show_actions_section && show_actions_advanced {
296-
Self::SIDE_ACTION_BUTTON_GAP
293+
let basic_count: usize = if show_actions_section { 3 } else { 0 };
294+
let show_delay_actions = snapshot.show_step_section && snapshot.show_delay_sliders;
295+
let advanced_count: usize = if show_actions_advanced {
296+
if show_delay_actions { 9 } else { 7 }
297297
} else {
298-
0.0
298+
0
299299
};
300300

301301
if self.use_icons {
302302
let icon_btn = Self::SIDE_ACTION_BUTTON_HEIGHT_ICON;
303303
let icon_gap = Self::SIDE_ACTION_BUTTON_GAP;
304-
let basic_rows = if basic_count > 0 { 1 } else { 0 };
305-
let basic_h = if basic_rows > 0 {
306-
icon_btn * basic_rows as f64
307-
} else {
308-
0.0
309-
};
310-
let advanced_rows = if advanced_count > 0 {
311-
((advanced_count + 4) / 5) as usize
304+
let total_icons = basic_count + advanced_count;
305+
let icons_per_row = 6usize;
306+
let rows = if total_icons > 0 {
307+
total_icons.div_ceil(icons_per_row)
312308
} else {
313309
0
314310
};
315-
let advanced_h = if advanced_rows > 0 {
316-
icon_btn * advanced_rows as f64 + icon_gap * (advanced_rows as f64 - 1.0)
311+
if rows > 0 {
312+
icon_btn * rows as f64 + icon_gap * (rows as f64 - 1.0)
317313
} else {
318314
0.0
319-
};
320-
basic_h + gap_between + advanced_h
315+
}
321316
} else {
322317
let action_h = Self::SIDE_ACTION_BUTTON_HEIGHT_TEXT;
323318
let action_gap = Self::SIDE_ACTION_CONTENT_GAP_TEXT;
@@ -327,7 +322,7 @@ impl ToolbarLayoutSpec {
327322
0.0
328323
};
329324
let advanced_rows = if advanced_count > 0 {
330-
((advanced_count + 1) / 2) as usize
325+
advanced_count.div_ceil(2)
331326
} else {
332327
0
333328
};
@@ -336,6 +331,11 @@ impl ToolbarLayoutSpec {
336331
} else {
337332
0.0
338333
};
334+
let gap_between = if show_actions_section && show_actions_advanced {
335+
Self::SIDE_ACTION_BUTTON_GAP
336+
} else {
337+
0.0
338+
};
339339
basic_h + gap_between + advanced_h
340340
}
341341
}
@@ -369,10 +369,11 @@ impl ToolbarLayoutSpec {
369369
pub(super) fn side_settings_height(&self, snapshot: &ToolbarSnapshot) -> f64 {
370370
let toggle_h = Self::SIDE_TOGGLE_HEIGHT;
371371
let toggle_gap = Self::SIDE_TOGGLE_GAP;
372-
let mut rows = 1; // Preset toasts
372+
let mut toggle_count = 1; // Preset toasts
373373
if snapshot.layout_mode == ToolbarLayoutMode::Advanced {
374-
rows += 5; // presets, actions, advanced actions, step section, text controls
374+
toggle_count += 5; // presets, actions, advanced actions, step section, text controls
375375
}
376+
let rows = (toggle_count + 1) / 2;
376377
let toggle_rows_h = if rows > 0 {
377378
toggle_h * rows as f64 + toggle_gap * (rows as f64 - 1.0)
378379
} else {
@@ -487,24 +488,25 @@ pub fn build_top_hits(
487488
fill_anchor = Some((rect_x, circle_end_x - rect_x));
488489
}
489490

490-
if fill_tool_active && !(is_simple && snapshot.shape_picker_open) {
491-
if let Some((fill_x, fill_w)) = fill_anchor {
492-
let fill_y = y + btn_size + ToolbarLayoutSpec::TOP_ICON_FILL_OFFSET;
493-
hits.push(HitRegion {
494-
rect: (
495-
fill_x,
496-
fill_y,
497-
fill_w,
498-
ToolbarLayoutSpec::TOP_ICON_FILL_HEIGHT,
499-
),
500-
event: ToolbarEvent::ToggleFill(!snapshot.fill_enabled),
501-
kind: HitKind::Click,
502-
tooltip: Some(super::format_binding_label(
503-
"Fill",
504-
snapshot.binding_hints.fill.as_deref(),
505-
)),
506-
});
507-
}
491+
if fill_tool_active
492+
&& !(is_simple && snapshot.shape_picker_open)
493+
&& let Some((fill_x, fill_w)) = fill_anchor
494+
{
495+
let fill_y = y + btn_size + ToolbarLayoutSpec::TOP_ICON_FILL_OFFSET;
496+
hits.push(HitRegion {
497+
rect: (
498+
fill_x,
499+
fill_y,
500+
fill_w,
501+
ToolbarLayoutSpec::TOP_ICON_FILL_HEIGHT,
502+
),
503+
event: ToolbarEvent::ToggleFill(!snapshot.fill_enabled),
504+
kind: HitKind::Click,
505+
tooltip: Some(super::format_binding_label(
506+
"Fill",
507+
snapshot.binding_hints.fill.as_deref(),
508+
)),
509+
});
508510
}
509511

510512
hits.push(HitRegion {
@@ -790,7 +792,7 @@ pub fn build_side_hits(
790792
let slot_row_y = y + ToolbarLayoutSpec::SIDE_PRESET_ROW_OFFSET_Y;
791793
let action_row_y = slot_row_y + slot_size + ToolbarLayoutSpec::SIDE_PRESET_ACTION_GAP;
792794
let action_gap = ToolbarLayoutSpec::SIDE_PRESET_ACTION_BUTTON_GAP;
793-
let action_w = slot_size;
795+
let action_w = (slot_size - action_gap) / 2.0;
794796
for slot_index in 0..slot_count {
795797
let slot = slot_index + 1;
796798
let slot_x = x + slot_index as f64 * (slot_size + slot_gap);
@@ -821,8 +823,8 @@ pub fn build_side_hits(
821823
if preset_exists {
822824
hits.push(HitRegion {
823825
rect: (
824-
slot_x,
825-
action_row_y + ToolbarLayoutSpec::SIDE_PRESET_ACTION_HEIGHT + action_gap,
826+
slot_x + action_w + action_gap,
827+
action_row_y,
826828
action_w,
827829
ToolbarLayoutSpec::SIDE_PRESET_ACTION_HEIGHT,
828830
),

0 commit comments

Comments
 (0)