Skip to content

Commit c3de2ee

Browse files
authored
Merge pull request #87 from devmobasa/help-menu-rework
Help menu rework
2 parents 6b793cd + a2f638b commit c3de2ee

File tree

24 files changed

+1689
-458
lines changed

24 files changed

+1689
-458
lines changed

config.example.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ show_preset_toasts = true
299299
# Show cursor tool preview bubble near the pointer
300300
show_tool_preview = false
301301

302+
# Filter help overlay sections based on enabled features
303+
help_overlay_context_filter = true
304+
302305
# Initial toolbar offsets (layer-shell/inline)
303306
# Horizontal offset for the top toolbar
304307
top_offset = 0.0
@@ -315,7 +318,10 @@ side_offset_x = 0.0
315318

316319
[ui.help_overlay_style]
317320
# Font size for help overlay text
318-
font_size = 16.0
321+
font_size = 14.0
322+
323+
# Font family for help overlay text (comma-separated fallback list)
324+
font_family = "Noto Sans, DejaVu Sans, Liberation Sans, Sans"
319325

320326
# Line height for help text
321327
line_height = 22.0

configurator/src/app.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,6 +1775,12 @@ impl ConfiguratorApp {
17751775
fn ui_help_overlay_tab(&self) -> Element<'_, Message> {
17761776
let column = column![
17771777
text("Help Overlay Style").size(18),
1778+
toggle_row(
1779+
"Filter sections by enabled features",
1780+
self.draft.help_context_filter,
1781+
self.defaults.help_context_filter,
1782+
ToggleField::UiHelpOverlayContextFilter,
1783+
),
17781784
color_quad_editor(
17791785
"Background RGBA (0-1)",
17801786
&self.draft.help_bg_color,
@@ -1793,6 +1799,12 @@ impl ConfiguratorApp {
17931799
&self.defaults.help_text_color,
17941800
QuadField::HelpText,
17951801
),
1802+
labeled_input(
1803+
"Font family",
1804+
&self.draft.help_font_family,
1805+
&self.defaults.help_font_family,
1806+
TextField::HelpFontFamily,
1807+
),
17961808
row![
17971809
labeled_input(
17981810
"Font size",

configurator/src/models/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ pub struct ConfigDraft {
9191
pub click_highlight_fill_color: ColorQuadInput,
9292
pub click_highlight_outline_color: ColorQuadInput,
9393

94+
pub help_font_family: String,
9495
pub help_font_size: String,
9596
pub help_line_height: String,
9697
pub help_padding: String,
9798
pub help_bg_color: ColorQuadInput,
9899
pub help_border_color: ColorQuadInput,
99100
pub help_border_width: String,
100101
pub help_text_color: ColorQuadInput,
102+
pub help_context_filter: bool,
101103

102104
pub board_enabled: bool,
103105
pub board_default_mode: BoardModeOption,
@@ -512,13 +514,15 @@ impl ConfigDraft {
512514
config.ui.click_highlight.outline_color,
513515
),
514516

517+
help_font_family: config.ui.help_overlay_style.font_family.clone(),
515518
help_font_size: format_float(config.ui.help_overlay_style.font_size),
516519
help_line_height: format_float(config.ui.help_overlay_style.line_height),
517520
help_padding: format_float(config.ui.help_overlay_style.padding),
518521
help_bg_color: ColorQuadInput::from(config.ui.help_overlay_style.bg_color),
519522
help_border_color: ColorQuadInput::from(config.ui.help_overlay_style.border_color),
520523
help_border_width: format_float(config.ui.help_overlay_style.border_width),
521524
help_text_color: ColorQuadInput::from(config.ui.help_overlay_style.text_color),
525+
help_context_filter: config.ui.help_overlay_context_filter,
522526

523527
board_enabled: config.board.enabled,
524528
board_default_mode: BoardModeOption::from_str(&config.board.default_mode)
@@ -812,6 +816,7 @@ impl ConfigDraft {
812816
Err(err) => errors.push(err),
813817
}
814818

819+
config.ui.help_overlay_style.font_family = self.help_font_family.trim().to_string();
815820
parse_field(
816821
&self.help_font_size,
817822
"ui.help_overlay_style.font_size",
@@ -857,6 +862,7 @@ impl ConfigDraft {
857862
Ok(values) => config.ui.help_overlay_style.text_color = values,
858863
Err(err) => errors.push(err),
859864
}
865+
config.ui.help_overlay_context_filter = self.help_context_filter;
860866

861867
config.board.enabled = self.board_enabled;
862868
config.board.default_mode = self.board_default_mode.as_str().to_string();
@@ -1007,6 +1013,7 @@ impl ConfigDraft {
10071013
ToggleField::PerformanceVsync => self.performance_enable_vsync = value,
10081014
ToggleField::UiShowStatusBar => self.ui_show_status_bar = value,
10091015
ToggleField::UiShowFrozenBadge => self.ui_show_frozen_badge = value,
1016+
ToggleField::UiHelpOverlayContextFilter => self.help_context_filter = value,
10101017
ToggleField::UiContextMenuEnabled => self.ui_context_menu_enabled = value,
10111018
ToggleField::UiXdgFullscreen => self.ui_xdg_fullscreen = value,
10121019
ToggleField::UiToolbarTopPinned => self.ui_toolbar_top_pinned = value,
@@ -1114,6 +1121,7 @@ impl ConfigDraft {
11141121
TextField::HighlightRadius => self.click_highlight_radius = value,
11151122
TextField::HighlightOutlineThickness => self.click_highlight_outline_thickness = value,
11161123
TextField::HighlightDurationMs => self.click_highlight_duration_ms = value,
1124+
TextField::HelpFontFamily => self.help_font_family = value,
11171125
TextField::HelpFontSize => self.help_font_size = value,
11181126
TextField::HelpLineHeight => self.help_line_height = value,
11191127
TextField::HelpPadding => self.help_padding = value,

configurator/src/models/fields.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ pub enum ToggleField {
544544
PerformanceVsync,
545545
UiShowStatusBar,
546546
UiShowFrozenBadge,
547+
UiHelpOverlayContextFilter,
547548
UiContextMenuEnabled,
548549
UiXdgFullscreen,
549550
UiToolbarTopPinned,
@@ -620,6 +621,7 @@ pub enum TextField {
620621
HighlightRadius,
621622
HighlightOutlineThickness,
622623
HighlightDurationMs,
624+
HelpFontFamily,
623625
HelpFontSize,
624626
HelpLineHeight,
625627
HelpPadding,

docs/CONFIG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ show_status_bar = true
166166
# Show a small "FROZEN" badge when frozen mode is active
167167
show_frozen_badge = true
168168

169+
# Filter help overlay sections based on enabled features
170+
help_overlay_context_filter = true
171+
169172
# Status bar position
170173
# Options: "top-left", "top-right", "bottom-left", "bottom-right"
171174
status_bar_position = "bottom-left"
@@ -180,7 +183,8 @@ dot_radius = 4.0
180183

181184
# Help overlay styling
182185
[ui.help_overlay_style]
183-
font_size = 16.0
186+
font_size = 14.0
187+
font_family = "Noto Sans, DejaVu Sans, Liberation Sans, Sans"
184188
line_height = 22.0
185189
padding = 20.0
186190
bg_color = [0.0, 0.0, 0.0, 0.85] # Darker background

src/backend/wayland/backend.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ fn process_tray_action(state: &mut WaylandState) {
108108
}
109109
}
110110
"toggle_help" => {
111-
state.input_state.show_help = !state.input_state.show_help;
112-
state.input_state.dirty_tracker.mark_full();
113-
state.input_state.needs_redraw = true;
111+
state.input_state.toggle_help_overlay();
114112
}
115113
other => warn!("Unknown tray action '{}'", other),
116114
}

src/backend/wayland/handlers/pointer.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,36 @@ impl PointerHandler for WaylandState {
357357
self.input_state.needs_redraw = true;
358358
}
359359
PointerEventKind::Axis { vertical, .. } => {
360-
if on_toolbar || self.pointer_over_toolbar() {
361-
continue;
362-
}
363360
let scroll_direction = if vertical.discrete != 0 {
364361
vertical.discrete
365362
} else if vertical.absolute.abs() > 0.1 {
366363
if vertical.absolute > 0.0 { 1 } else { -1 }
367364
} else {
368365
0
369366
};
367+
if self.input_state.show_help {
368+
if scroll_direction != 0 {
369+
let delta = if scroll_direction > 0 { 1.0 } else { -1.0 };
370+
let scroll_step = 48.0;
371+
let max_scroll = self.input_state.help_overlay_scroll_max;
372+
let mut next =
373+
self.input_state.help_overlay_scroll + delta * scroll_step;
374+
if max_scroll > 0.0 {
375+
next = next.clamp(0.0, max_scroll);
376+
} else {
377+
next = next.max(0.0);
378+
}
379+
if (next - self.input_state.help_overlay_scroll).abs() > f64::EPSILON {
380+
self.input_state.help_overlay_scroll = next;
381+
self.input_state.dirty_tracker.mark_full();
382+
self.input_state.needs_redraw = true;
383+
}
384+
}
385+
continue;
386+
}
387+
if on_toolbar || self.pointer_over_toolbar() {
388+
continue;
389+
}
370390
if self.input_state.modifiers.ctrl && self.input_state.modifiers.alt {
371391
if scroll_direction != 0 {
372392
let zoom_in = scroll_direction < 0;

src/backend/wayland/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ mod session;
88
mod state;
99
mod surface;
1010
mod toolbar;
11-
mod toolbar_icons;
1211
mod toolbar_intent;
1312
mod zoom;
1413

src/backend/wayland/state/render.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::*;
2-
use crate::backend::wayland::toolbar_icons;
2+
use crate::toolbar_icons;
33

44
impl WaylandState {
55
pub(in crate::backend::wayland) fn render(&mut self, qh: &QueueHandle<Self>) -> Result<bool> {
@@ -420,13 +420,31 @@ impl WaylandState {
420420

421421
// Render help overlay if toggled
422422
if self.input_state.show_help {
423-
crate::ui::render_help_overlay(
423+
let page_prev_label = self
424+
.input_state
425+
.action_binding_label(crate::config::Action::PagePrev);
426+
let page_next_label = self
427+
.input_state
428+
.action_binding_label(crate::config::Action::PageNext);
429+
let scroll_max = crate::ui::render_help_overlay(
424430
&ctx,
425431
&self.config.ui.help_overlay_style,
426432
width,
427433
height,
428434
self.frozen_enabled(),
435+
self.input_state.help_overlay_view,
436+
self.input_state.help_overlay_page,
437+
page_prev_label.as_str(),
438+
page_next_label.as_str(),
439+
self.input_state.help_overlay_search.as_str(),
440+
self.config.ui.help_overlay_context_filter,
441+
self.input_state.board_config.enabled,
442+
self.config.capture.enabled,
443+
self.input_state.help_overlay_scroll,
429444
);
445+
self.input_state.help_overlay_scroll_max = scroll_max;
446+
self.input_state.help_overlay_scroll =
447+
self.input_state.help_overlay_scroll.clamp(0.0, scroll_max);
430448
}
431449

432450
crate::ui::render_ui_toast(&ctx, &self.input_state, width, height);

src/backend/wayland/toolbar/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
use anyhow::Result;
44

55
use crate::backend::wayland::toolbar::format_binding_label;
6-
use crate::backend::wayland::toolbar_icons;
76
use crate::draw::{
87
BLACK, BLUE, Color, EraserKind, FontDescriptor, GREEN, ORANGE, PINK, RED, WHITE, YELLOW,
98
};
109
use crate::input::state::PresetFeedbackKind;
1110
use crate::input::{EraserMode, Tool};
11+
use crate::toolbar_icons;
1212
use crate::ui::toolbar::{ToolbarEvent, ToolbarSnapshot};
1313
use crate::util::color_to_name;
1414

0 commit comments

Comments
 (0)