Skip to content

Revamp toolbar UI and enhance annotation workflows#11

Merged
JaviLendi merged 10 commits into
masterfrom
UI-Improvements
May 21, 2026
Merged

Revamp toolbar UI and enhance annotation workflows#11
JaviLendi merged 10 commits into
masterfrom
UI-Improvements

Conversation

@JaviLendi

Copy link
Copy Markdown
Owner

This pull request introduces several improvements and refactorings across the UI, documentation, and error handling in the codebase. The most significant changes are the migration of the web UI from Font Awesome to Material Icons, improved keyboard shortcut handling on the home page, updated annotation colors for better visual consistency, and enhanced error suppression for MuPDF stack warnings. Below are the most important changes grouped by theme:

Web UI Modernization and Accessibility:

  • Migrated the web UI from Font Awesome to Material Symbols Rounded for all icons, including updating the asset download script (download-webui-assets.ps1), HTML references, and icon usage in home.html. This reduces bundle size and improves visual consistency. [1] [2] [3] [4]
  • Changed the home page language and UI text from Spanish to English, updating all labels, placeholders, and instructions for broader accessibility. [1] [2]
  • Removed the generic post helper and now use direct host invocation for commands, simplifying integration with the host application. [1] [2]

Keyboard Shortcut Handling:

  • Added robust, early monkeypatching of addEventListener to neutralize global keyboard shortcuts on the home page, preventing accidental triggering of actions like open, print, or search when not in an editable field. Also implemented custom handling for Ctrl+F and F3 to focus or trigger search appropriately. [1] [2]

Annotation Color Updates:

  • Updated the default annotation colors for highlight, underline, squiggly, and strikeout in the advanced options documentation for improved visual clarity and alignment with modern color palettes.

Error Handling and Logging:

  • Improved error handling in Annotation.cpp by suppressing noisy MuPDF "draw-device stack" warnings and logging them as informational, while still reporting other errors. This prevents unnecessary error logs for benign conditions. [1] [2] [3]

Other Improvements:

  • Enhanced the Inter font asset download to include more weights for better typographic flexibility.

These changes collectively improve the user interface, accessibility, and developer experience, while also enhancing error reporting and documentation.

JaviLendi and others added 10 commits May 13, 2026 17:47
Large UI refresh and host-integration changes: update home.html to remove the legacy post() helper and inline direct window.external.invoke() JSON command calls for actions (openFile, reopenLast, searchFiles, openRecent, homePageReady). Add DOCTYPE and perform a comprehensive rewrite of toolbar.html styles and structure — modernized CSS variables, theme switch, search/pagination controls, responsive behavior, native context menu, dropdowns, skeleton loader and an edit-mode for toolbar customization. Backend bridge and core files (SearchAndDDE.cpp/h, SumatraPDF.cpp, BridgeDispatcher.cpp) were updated accordingly to align with the new messaging/integration changes. These changes modernize the web UI, improve responsiveness and desktop integration with the host messaging protocol.
Introduce an inline highlighter color picker to the toolbar (UI, CSS and JS) with selectable color chips, open/close behavior, and sending color-aware highlight commands to the native app. BridgeDispatcher was extended to accept color payloads, store a pending highlight color, and dispatch highlight commands from the web UI; a GetPendingHighlightColor() accessor was added to consume that color when creating highlight annotations. Native changes include using the pending bridge color when creating highlight annotations, adding a user-facing notification when highlighting requires a text selection, adjusting toolbar height breakpoints, and small fixes (annotation hit-testing in context menu command handling, escape-to-exit edit mode, removal of redundant dropdown calls, and minor CSS/HTML tweaks). Files changed: prettysumatra/webui/toolbar.html, src/prettysumatra/BridgeDispatcher.{cpp,h}, src/SumatraPDF.cpp, src/WindowTab.h.
Major frontend and UX updates for the toolbar and annotation workflows, plus several native-side robustness and notification UI improvements.

Key changes:
- Toolbar HTML/CSS: compacted pagination input with dynamic width, added page meta display, responsive sizing tweaks, new compact inline color picker and common color palette, new annotation tool buttons (highlight/underline/strikeout) with swatches and improved styling.
- Toolbar JS: dynamic page input sizing and page meta updates, resize handler, refactored color picker logic (shared palette, per-tool saved colors persisted to localStorage), active annotation tool state, send selected color with execCommand payload for color-aware commands, improved click handling and deterministic theme/document-invert commands.
- Docs and defaults: updated default annotation colors in docs and Settings.h to new palette values.
- Native C++ robustness: suppresses spurious MuPDF "items left on stack in draw device" warnings by checking fz_caught_message in Annotation.cpp and EngineMupdf.cpp (logs suppressed warnings instead of always calling fz_report_error).
- Notifications UI: rewrote notification painting to use rounded card paths, accent bar, improved progress track rendering, DPI-aware layout constants and helper to draw rounded rectangles; adjusted close button positioning and smoothing settings.

Other small cleanups and accessibility/state handling improvements across toolbar code.
Several improvements to the toolbar UI, search functionality, reload icon and a lot more.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add protections to prevent WebView/web UI scripts from stealing app-level shortcuts and harden document loading to avoid races and use-after-free. HTML/JS: add an example toolbar and inject early monkeypatches/shortcut-guards into home.html and toolbar.html to wrap addEventListener for keyboard events and route Ctrl+F/F3 to the host search UI. C++: make ReplaceDocumentInCurrentTab return a bool and add validity/isBeingClosed checks to bail out safely; snapshot gWindows in SaveSettings to avoid concurrent mutation; post an asynchronous SaveSettings after document load completion. WebView: add webview2_accel_handler to intercept accelerator keys at the control level, mark them handled and repost them to the top-level window so host accelerators run. Misc: minor formatting and Eval string adjustments. These changes reduce conflicts between web UI handlers and native accelerators and prevent lifecycle-related crashes during loads.
Copilot AI review requested due to automatic review settings May 21, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@JaviLendi
JaviLendi merged commit a7e55ce into master May 21, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants