Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/backend/wayland/state/toolbar/events/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::config::ToolbarLayoutMode;
use crate::draw::{Color, FontDescriptor};
use crate::input::state::test_support::make_test_input_state;
use crate::input::{EraserMode, Tool};
use crate::ui::toolbar::ToolbarSideSection;
use anyhow::anyhow;
use std::fs;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -77,6 +78,7 @@ fn runtime_toolbar_events_do_not_directly_save_config() {
ToolbarEvent::SaveSessionAsCancel,
ToolbarEvent::SessionInfo,
ToolbarEvent::ClearSession,
ToolbarEvent::ToggleSideSectionCollapsed(ToolbarSideSection::Session, true),
];

for event in events {
Expand Down
9 changes: 9 additions & 0 deletions src/backend/wayland/toolbar/layout/side/actions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{HitKind, HitRegion, SideLayoutContext, ToolbarLayoutSpec, format_binding_label};
use crate::backend::wayland::toolbar::rows::{centered_grid_layout, grid_layout, row_item_width};
use crate::ui::toolbar::ToolbarSideSection;
use crate::ui::toolbar::model::{
ToolbarActionsModel, ToolbarCommandGroup, ToolbarCommandGroupKind,
};
Expand All @@ -14,6 +15,14 @@ pub(super) fn push_actions_hits(
};

let actions_card_h = ctx.spec.side_actions_height(ctx.snapshot);
super::section_header::push_collapsible_header_hit(ctx, y, ToolbarSideSection::Actions, hits);
if ctx
.snapshot
.side_section_collapsed(ToolbarSideSection::Actions)
{
return y + actions_card_h + ctx.section_gap;
}

let mut action_y = y + ToolbarLayoutSpec::SIDE_SECTION_TOGGLE_OFFSET_Y;
let mut has_group = false;
for group in model.groups() {
Expand Down
97 changes: 88 additions & 9 deletions src/backend/wayland/toolbar/layout/side/arrow.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,95 @@
use super::{SideLayoutContext, ToolbarLayoutSpec};
use crate::ui::toolbar::ToolContext;
use super::{HitKind, HitRegion, SideLayoutContext, ToolbarEvent, ToolbarLayoutSpec};
use crate::ui::toolbar::{ToolContext, ToolbarSideSection};

// Arrow hit regions are built in render to avoid duplicate registrations.
pub(super) fn advance_arrow_section(ctx: &SideLayoutContext<'_>, y: f64) -> f64 {
pub(super) fn push_arrow_section_hits(
ctx: &SideLayoutContext<'_>,
y: f64,
hits: &mut Vec<HitRegion>,
) -> f64 {
if !ToolContext::from_snapshot(ctx.snapshot).show_arrow_labels {
return y;
}

let card_h = if ctx.snapshot.arrow_label_enabled {
ToolbarLayoutSpec::SIDE_TOGGLE_CARD_HEIGHT_WITH_RESET
} else {
ToolbarLayoutSpec::SIDE_TOGGLE_CARD_HEIGHT
};
let card_h = ctx.spec.side_arrow_labels_height(ctx.snapshot);
super::section_header::push_collapsible_header_hit(
ctx,
y,
ToolbarSideSection::ArrowLabels,
hits,
);
if ctx
.snapshot
.side_section_collapsed(ToolbarSideSection::ArrowLabels)
{
return y + card_h + ctx.section_gap;
}

let toggle_y = y + ToolbarLayoutSpec::SIDE_SECTION_TOGGLE_OFFSET_Y;
hits.push(HitRegion {
rect: (
ctx.x,
toggle_y,
ctx.content_width,
ToolbarLayoutSpec::SIDE_TOGGLE_HEIGHT,
),
event: ToolbarEvent::ToggleArrowLabels(!ctx.snapshot.arrow_label_enabled),
kind: HitKind::Click,
tooltip: Some("Auto-number arrows 1, 2, 3.".to_string()),
});
if ctx.snapshot.arrow_label_enabled {
let reset_y =
toggle_y + ToolbarLayoutSpec::SIDE_TOGGLE_HEIGHT + ToolbarLayoutSpec::SIDE_TOGGLE_GAP;
hits.push(HitRegion {
rect: (
ctx.x,
reset_y,
ctx.content_width,
ToolbarLayoutSpec::SIDE_TOGGLE_HEIGHT,
),
event: ToolbarEvent::ResetArrowLabelCounter,
kind: HitKind::Click,
tooltip: Some("Reset numbering to 1.".to_string()),
});
}

y + card_h + ctx.section_gap
}

pub(super) fn push_step_marker_hits(
ctx: &SideLayoutContext<'_>,
y: f64,
hits: &mut Vec<HitRegion>,
) -> f64 {
if !ToolContext::from_snapshot(ctx.snapshot).show_step_counter {
return y;
}

let card_h = ctx.spec.side_step_markers_height(ctx.snapshot);
super::section_header::push_collapsible_header_hit(
ctx,
y,
ToolbarSideSection::StepMarkers,
hits,
);
if ctx
.snapshot
.side_section_collapsed(ToolbarSideSection::StepMarkers)
{
return y + card_h + ctx.section_gap;
}

let reset_y = y + ToolbarLayoutSpec::SIDE_SECTION_TOGGLE_OFFSET_Y;
hits.push(HitRegion {
rect: (
ctx.x,
reset_y,
ctx.content_width,
ToolbarLayoutSpec::SIDE_TOGGLE_HEIGHT,
),
event: ToolbarEvent::ResetStepMarkerCounter,
kind: HitKind::Click,
tooltip: Some("Reset numbering to 1.".to_string()),
});

y + card_h + ctx.section_gap
}
9 changes: 9 additions & 0 deletions src/backend/wayland/toolbar/layout/side/boards.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::{HitKind, HitRegion, SideLayoutContext, ToolbarLayoutSpec, format_binding_label};
use crate::backend::wayland::toolbar::rows::{capped_grid_columns, grid_layout, row_item_width};
use crate::ui::toolbar::ToolbarSideSection;
use crate::ui::toolbar::model::toolbar_boards_model;

pub(super) fn push_boards_hits(
Expand All @@ -12,6 +13,14 @@ pub(super) fn push_boards_hits(
};

let boards_card_h = ctx.spec.side_boards_height(ctx.snapshot);
super::section_header::push_collapsible_header_hit(ctx, y, ToolbarSideSection::Boards, hits);
if ctx
.snapshot
.side_section_collapsed(ToolbarSideSection::Boards)
{
return y + boards_card_h + ctx.section_gap;
}

let boards_y = y + ToolbarLayoutSpec::SIDE_SECTION_TOGGLE_OFFSET_Y;
let btn_h = if ctx.use_icons {
ToolbarLayoutSpec::SIDE_ACTION_BUTTON_HEIGHT_ICON
Expand Down
12 changes: 11 additions & 1 deletion src/backend/wayland/toolbar/layout/side/colors.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
use super::{HitKind, HitRegion, SideLayoutContext, ToolbarEvent, ToolbarLayoutSpec};
use crate::ui::toolbar::ToolbarSideSection;

pub(super) fn push_color_picker_hits(
ctx: &SideLayoutContext<'_>,
y: f64,
hits: &mut Vec<HitRegion>,
) -> f64 {
let card_h = ctx.spec.side_colors_height(ctx.snapshot);
super::section_header::push_collapsible_header_hit(ctx, y, ToolbarSideSection::Colors, hits);
if ctx
.snapshot
.side_section_collapsed(ToolbarSideSection::Colors)
{
return y + card_h + ctx.section_gap;
}

let picker_y = y + ToolbarLayoutSpec::SIDE_COLOR_PICKER_OFFSET_Y;
let picker_h = ctx.spec.side_color_picker_height(ctx.snapshot);
hits.push(HitRegion {
Expand All @@ -19,5 +29,5 @@ pub(super) fn push_color_picker_hits(
tooltip: None,
});

y + ctx.spec.side_colors_height(ctx.snapshot) + ctx.section_gap
y + card_h + ctx.section_gap
}
127 changes: 77 additions & 50 deletions src/backend/wayland/toolbar/layout/side/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,92 @@ use super::{
HitKind, HitRegion, SideLayoutContext, ToolbarEvent, ToolbarLayoutSpec, delay_secs_from_t,
delay_t_from_ms,
};
use crate::ui::toolbar::ToolbarSideSection;

pub(super) fn push_delay_hits(
ctx: &SideLayoutContext<'_>,
y: f64,
hits: &mut Vec<HitRegion>,
) -> f64 {
if ctx.snapshot.show_step_section
&& ctx.snapshot.show_delay_sliders
&& ctx.snapshot.drawer_open
&& ctx.snapshot.drawer_tab == crate::input::ToolbarDrawerTab::App
if !ctx.snapshot.show_step_section
|| !ctx.snapshot.drawer_open
|| ctx.snapshot.drawer_tab != crate::input::ToolbarDrawerTab::App
{
let undo_t = delay_t_from_ms(ctx.snapshot.undo_all_delay_ms);
let redo_t = delay_t_from_ms(ctx.snapshot.redo_all_delay_ms);
let toggles_h =
ToolbarLayoutSpec::SIDE_TOGGLE_HEIGHT * 2.0 + ToolbarLayoutSpec::SIDE_TOGGLE_GAP;
let custom_h = if ctx.snapshot.custom_section_enabled {
ToolbarLayoutSpec::SIDE_CUSTOM_SECTION_HEIGHT
} else {
0.0
};
let slider_start_y = y
+ ToolbarLayoutSpec::SIDE_STEP_HEADER_HEIGHT
+ toggles_h
+ custom_h
+ ToolbarLayoutSpec::SIDE_STEP_SLIDER_TOP_PADDING;
let slider_hit_h = ToolbarLayoutSpec::SIDE_DELAY_SLIDER_HEIGHT
+ ToolbarLayoutSpec::SIDE_DELAY_SLIDER_HIT_PADDING * 2.0;
let undo_y = slider_start_y + ToolbarLayoutSpec::SIDE_DELAY_SLIDER_UNDO_OFFSET_Y;
hits.push(HitRegion {
rect: (
ctx.x,
undo_y - ToolbarLayoutSpec::SIDE_DELAY_SLIDER_HIT_PADDING,
ctx.content_width,
slider_hit_h,
),
event: ToolbarEvent::SetUndoDelay(delay_secs_from_t(undo_t)),
kind: HitKind::DragUndoDelay,
tooltip: None,
});
let redo_y = slider_start_y + ToolbarLayoutSpec::SIDE_DELAY_SLIDER_REDO_OFFSET_Y;
hits.push(HitRegion {
rect: (
ctx.x,
redo_y - ToolbarLayoutSpec::SIDE_DELAY_SLIDER_HIT_PADDING,
ctx.content_width,
slider_hit_h,
),
event: ToolbarEvent::SetRedoDelay(delay_secs_from_t(redo_t)),
kind: HitKind::DragRedoDelay,
tooltip: None,
});
return y;
}

if ctx.snapshot.show_step_section
&& ctx.snapshot.drawer_open
&& ctx.snapshot.drawer_tab == crate::input::ToolbarDrawerTab::App
let card_h = ctx.spec.side_step_height(ctx.snapshot);
super::section_header::push_collapsible_header_hit(ctx, y, ToolbarSideSection::StepUndo, hits);
if ctx
.snapshot
.side_section_collapsed(ToolbarSideSection::StepUndo)
{
y + ctx.spec.side_step_height(ctx.snapshot) + ctx.section_gap
} else {
y
return y + card_h + ctx.section_gap;
}

let toggle_h = ToolbarLayoutSpec::SIDE_TOGGLE_HEIGHT;
let toggle_gap = ToolbarLayoutSpec::SIDE_TOGGLE_GAP;
let custom_toggle_y = y + ToolbarLayoutSpec::SIDE_SECTION_TOGGLE_OFFSET_Y;
hits.push(HitRegion {
rect: (ctx.x, custom_toggle_y, ctx.content_width, toggle_h),
event: ToolbarEvent::ToggleCustomSection(!ctx.snapshot.custom_section_enabled),
kind: HitKind::Click,
tooltip: Some("Step controls: multi-step undo/redo.".to_string()),
});
let delay_toggle_y = custom_toggle_y + toggle_h + toggle_gap;
hits.push(HitRegion {
rect: (ctx.x, delay_toggle_y, ctx.content_width, toggle_h),
event: ToolbarEvent::ToggleDelaySliders(!ctx.snapshot.show_delay_sliders),
kind: HitKind::Click,
tooltip: Some("Delay sliders: undo/redo delays.".to_string()),
});

if ctx.snapshot.show_delay_sliders {
push_delay_slider_hits(ctx, y, hits);
}

y + card_h + ctx.section_gap
}

fn push_delay_slider_hits(ctx: &SideLayoutContext<'_>, y: f64, hits: &mut Vec<HitRegion>) {
let undo_t = delay_t_from_ms(ctx.snapshot.undo_all_delay_ms);
let redo_t = delay_t_from_ms(ctx.snapshot.redo_all_delay_ms);
let toggles_h =
ToolbarLayoutSpec::SIDE_TOGGLE_HEIGHT * 2.0 + ToolbarLayoutSpec::SIDE_TOGGLE_GAP;
let custom_h = if ctx.snapshot.custom_section_enabled {
ToolbarLayoutSpec::SIDE_CUSTOM_SECTION_HEIGHT
} else {
0.0
};
let slider_start_y = y
+ ToolbarLayoutSpec::SIDE_STEP_HEADER_HEIGHT
+ toggles_h
+ custom_h
+ ToolbarLayoutSpec::SIDE_STEP_SLIDER_TOP_PADDING;
let slider_hit_h = ToolbarLayoutSpec::SIDE_DELAY_SLIDER_HEIGHT
+ ToolbarLayoutSpec::SIDE_DELAY_SLIDER_HIT_PADDING * 2.0;
let undo_y = slider_start_y + ToolbarLayoutSpec::SIDE_DELAY_SLIDER_UNDO_OFFSET_Y;
hits.push(HitRegion {
rect: (
ctx.x,
undo_y - ToolbarLayoutSpec::SIDE_DELAY_SLIDER_HIT_PADDING,
ctx.content_width,
slider_hit_h,
),
event: ToolbarEvent::SetUndoDelay(delay_secs_from_t(undo_t)),
kind: HitKind::DragUndoDelay,
tooltip: None,
});
let redo_y = slider_start_y + ToolbarLayoutSpec::SIDE_DELAY_SLIDER_REDO_OFFSET_Y;
hits.push(HitRegion {
rect: (
ctx.x,
redo_y - ToolbarLayoutSpec::SIDE_DELAY_SLIDER_HIT_PADDING,
ctx.content_width,
slider_hit_h,
),
event: ToolbarEvent::SetRedoDelay(delay_secs_from_t(redo_t)),
kind: HitKind::DragRedoDelay,
tooltip: None,
});
}
Loading
Loading