Revamp toolbar UI and enhance annotation workflows#11
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
download-webui-assets.ps1), HTML references, and icon usage inhome.html. This reduces bundle size and improves visual consistency. [1] [2] [3] [4]posthelper and now use direct host invocation for commands, simplifying integration with the host application. [1] [2]Keyboard Shortcut Handling:
addEventListenerto 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:
Error Handling and Logging:
Annotation.cppby 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:
These changes collectively improve the user interface, accessibility, and developer experience, while also enhancing error reporting and documentation.