Skip to content

Commit 80cfa9a

Browse files
committed
Toolbar: compact actions/presets and hide delay actions
1 parent 8136545 commit 80cfa9a

File tree

2 files changed

+183
-167
lines changed

2 files changed

+183
-167
lines changed

src/backend/wayland/toolbar/layout.rs

Lines changed: 27 additions & 26 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

@@ -291,33 +291,28 @@ impl ToolbarLayoutSpec {
291291
}
292292

293293
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
294+
let show_delay_actions = snapshot.show_step_section && snapshot.show_delay_sliders;
295+
let advanced_count = 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 + icons_per_row - 1) / 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;
@@ -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 {
@@ -790,7 +791,7 @@ pub fn build_side_hits(
790791
let slot_row_y = y + ToolbarLayoutSpec::SIDE_PRESET_ROW_OFFSET_Y;
791792
let action_row_y = slot_row_y + slot_size + ToolbarLayoutSpec::SIDE_PRESET_ACTION_GAP;
792793
let action_gap = ToolbarLayoutSpec::SIDE_PRESET_ACTION_BUTTON_GAP;
793-
let action_w = slot_size;
794+
let action_w = (slot_size - action_gap) / 2.0;
794795
for slot_index in 0..slot_count {
795796
let slot = slot_index + 1;
796797
let slot_x = x + slot_index as f64 * (slot_size + slot_gap);
@@ -821,8 +822,8 @@ pub fn build_side_hits(
821822
if preset_exists {
822823
hits.push(HitRegion {
823824
rect: (
824-
slot_x,
825-
action_row_y + ToolbarLayoutSpec::SIDE_PRESET_ACTION_HEIGHT + action_gap,
825+
slot_x + action_w + action_gap,
826+
action_row_y,
826827
action_w,
827828
ToolbarLayoutSpec::SIDE_PRESET_ACTION_HEIGHT,
828829
),

0 commit comments

Comments
 (0)