Skip to content

Commit e7e1e91

Browse files
kjkclaude
andcommitted
Add "Fit by Orientation" zoom mode (fixes #702)
New zoom level that fits width when the viewport is landscape and fits page when portrait, re-evaluated on every relayout so it tracks window resize and screen rotation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4786619 commit e7e1e91

12 files changed

Lines changed: 194 additions & 156 deletions

cmd/gen-commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const commands = [
8181
"CmdZoomFitPage", "Zoom: Fit Page",
8282
"CmdZoomActualSize", "Zoom: Actual Size",
8383
"CmdZoomFitWidth", "Zoom: Fit Width",
84+
"CmdZoomFitByOrientation", "Zoom: Fit Page or Width by Orientation",
8485
"CmdZoom6400", "Zoom: 6400%",
8586
"CmdZoom3200", "Zoom: 3200%",
8687
"CmdZoom1600", "Zoom: 1600%",

cmd/gen-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,7 @@ constexpr float kZoomFitPage = -1.F;
11801180
constexpr float kZoomFitWidth = -2.F;
11811181
constexpr float kZoomFitContent = -3.F;
11821182
constexpr float kZoomShrinkToFit = -4.F;
1183+
constexpr float kZoomFitByOrientation = -5.F;
11831184
constexpr float kZoomActualSize = 100.0F;
11841185
constexpr float kZoomMax = 6400.F; /* max zoom in % */
11851186
constexpr float kZoomMin = 8.33F; /* min zoom in % */

docs/md/Commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ CmdZoomShrinkToFit,,Zoom: Shrink To Fit,"Shows at 100% if page is smaller than v
191191
CmdZoomFitPage,Ctrl + 0,Zoom: Fit Page,
192192
CmdZoomFitPageAndSinglePage,,Zoom: Fit Page and Single Page,
193193
CmdZoomFitWidth,Ctrl + 2,Zoom: Fit Width,
194+
CmdZoomFitByOrientation,,Zoom: Fit Page or Width by Orientation,"Fit width when the view is wider than tall (landscape), fit page otherwise (portrait); re-evaluated as the window/screen is resized or rotated"
194195
CmdZoomFitWidthAndContinuous,,Zoom: Fit Width And Continuous,
195196
CmdZoomIn,Ctrl + Add,Zoom In,
196197
CmdZoomOut,Ctrl + Subtract,Zoom Out,

docs/md/Version-history.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Available in [pre-release](https://www.sumatrapdfreader.org/prerelease) builds.
99
- in the Favorites pane and menu, a favorite for a file with a long name now shows your favorite's name first, then the file name, so the name you gave it is no longer pushed out of view (fixes #829, #2236)
1010
- case-insensitive search now treats German ß as equivalent to `ss`, so searching `Strasse` finds `Straße` and vice versa (fixes #933)
1111
- hovering a thumbnail on the Frequently Read home page now shows a ✕ button in its top-right corner to remove that document from the list, without going through the right-click menu (fixes #283)
12+
- new zoom mode `Fit by Orientation` (`CmdZoomFitByOrientation`, in the View / Zoom menu) that automatically fits width when the view is landscape and fits page when portrait, updating as you resize the window or rotate the screen (fixes #702)
1213
- add cmd-line tools `sumatrapdf-tool.exe <tool> <args>`. Tools: draw, convert, audit, bake, clean, create, extract, info, merge, pages, poster, recolor, show, trim, grep, trace
1314
- [command palette](Command-Palette.md) has a new `*` mode (`CmdCommandPalette *`, also `CmdCommandPaletteTOC` bound to `Shift + F12`) that jumps to a table of contents entry of the current document. Shows the fully expanded outline, indented by nesting level, with the entry closest to the current page pre-selected (fixes #5676)
1415
- [command palette](Command-Palette.md) has a new `$` mode (`CmdCommandPalette $`) that jumps to a favorite, listing the current document's favorites first, then favorites of other documents

src/Commands.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static SeqStrings gCommandNames =
9292
"CmdZoomFitPage\0"
9393
"CmdZoomActualSize\0"
9494
"CmdZoomFitWidth\0"
95+
"CmdZoomFitByOrientation\0"
9596
"CmdZoom6400\0"
9697
"CmdZoom3200\0"
9798
"CmdZoom1600\0"
@@ -327,6 +328,7 @@ static i32 gCommandIds[] = {
327328
CmdZoomFitPage,
328329
CmdZoomActualSize,
329330
CmdZoomFitWidth,
331+
CmdZoomFitByOrientation,
330332
CmdZoom6400,
331333
CmdZoom3200,
332334
CmdZoom1600,
@@ -562,6 +564,7 @@ SeqStrings gCommandDescriptions =
562564
"Zoom: Fit Page\0"
563565
"Zoom: Actual Size\0"
564566
"Zoom: Fit Width\0"
567+
"Zoom: Fit Page or Width by Orientation\0"
565568
"Zoom: 6400%\0"
566569
"Zoom: 3200%\0"
567570
"Zoom: 1600%\0"

src/Commands.h

Lines changed: 155 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -87,160 +87,161 @@ enum {
8787
CmdZoomFitPage = 276,
8888
CmdZoomActualSize = 277,
8989
CmdZoomFitWidth = 278,
90-
CmdZoom6400 = 279,
91-
CmdZoom3200 = 280,
92-
CmdZoom1600 = 281,
93-
CmdZoom800 = 282,
94-
CmdZoom400 = 283,
95-
CmdZoom200 = 284,
96-
CmdZoom150 = 285,
97-
CmdZoom125 = 286,
98-
CmdZoom100 = 287,
99-
CmdZoom50 = 288,
100-
CmdZoom25 = 289,
101-
CmdZoom12_5 = 290,
102-
CmdZoom8_33 = 291,
103-
CmdZoomFitContent = 292,
104-
CmdZoomShrinkToFit = 293,
105-
CmdZoomCustom = 294,
106-
CmdZoomIn = 295,
107-
CmdZoomOut = 296,
108-
CmdZoomFitWidthAndContinuous = 297,
109-
CmdZoomFitPageAndSinglePage = 298,
110-
CmdContributeTranslation = 299,
111-
CmdOpenWithKnownExternalViewerFirst = 300,
112-
CmdOpenWithExplorer = 301,
113-
CmdOpenWithDirectoryOpus = 302,
114-
CmdOpenWithTotalCommander = 303,
115-
CmdOpenWithDoubleCommander = 304,
116-
CmdOpenWithAcrobat = 305,
117-
CmdOpenWithFoxIt = 306,
118-
CmdOpenWithFoxItPhantom = 307,
119-
CmdOpenWithPdfXchange = 308,
120-
CmdOpenWithXpsViewer = 309,
121-
CmdOpenWithHtmlHelp = 310,
122-
CmdOpenWithPdfDjvuBookmarker = 311,
123-
CmdOpenWithKnownExternalViewerLast = 312,
124-
CmdOpenSelectedDocument = 313,
125-
CmdPinSelectedDocument = 314,
126-
CmdForgetSelectedDocument = 315,
127-
CmdExpandAll = 316,
128-
CmdCollapseAll = 317,
129-
CmdSaveEmbeddedFile = 318,
130-
CmdOpenEmbeddedPDF = 319,
131-
CmdSaveAttachment = 320,
132-
CmdOpenAttachment = 321,
133-
CmdOptions = 322,
134-
CmdAdvancedOptions = 323,
135-
CmdAdvancedSettings = 324,
136-
CmdChangeLanguage = 325,
137-
CmdCheckUpdate = 326,
138-
CmdHelpOpenManual = 327,
139-
CmdHelpOpenManualOnWebsite = 328,
140-
CmdHelpOpenKeyboardShortcuts = 329,
141-
CmdHelpVisitWebsite = 330,
142-
CmdHelpAbout = 331,
143-
CmdMoveFrameFocus = 332,
144-
CmdFavoriteAdd = 333,
145-
CmdFavoriteDel = 334,
146-
CmdFavoriteToggle = 335,
147-
CmdToggleLinks = 336,
148-
CmdToggleShowAnnotations = 337,
149-
CmdShowAnnotations = 338,
150-
CmdHideAnnotations = 339,
151-
CmdCreateAnnotText = 340,
152-
CmdCreateAnnotLink = 341,
153-
CmdCreateAnnotFreeText = 342,
154-
CmdCreateAnnotLine = 343,
155-
CmdCreateAnnotSquare = 344,
156-
CmdCreateAnnotCircle = 345,
157-
CmdCreateAnnotPolygon = 346,
158-
CmdCreateAnnotPolyLine = 347,
159-
CmdCreateAnnotHighlight = 348,
160-
CmdCreateAnnotUnderline = 349,
161-
CmdCreateAnnotSquiggly = 350,
162-
CmdCreateAnnotStrikeOut = 351,
163-
CmdCreateAnnotRedact = 352,
164-
CmdCreateAnnotStamp = 353,
165-
CmdCreateAnnotCaret = 354,
166-
CmdCreateAnnotInk = 355,
167-
CmdCreateAnnotPopup = 356,
168-
CmdCreateAnnotFileAttachment = 357,
169-
CmdInvertColors = 358,
170-
CmdTogglePageInfo = 359,
171-
CmdToggleZoom = 360,
172-
CmdNavigateBack = 361,
173-
CmdNavigateForward = 362,
174-
CmdToggleCursorPosition = 363,
175-
CmdOpenNextFileInFolder = 364,
176-
CmdOpenPrevFileInFolder = 365,
177-
CmdCommandPalette = 366,
178-
CmdShowLog = 367,
179-
CmdShowErrors = 368,
180-
CmdClearHistory = 369,
181-
CmdReopenLastClosedFile = 370,
182-
CmdNextTab = 371,
183-
CmdPrevTab = 372,
184-
CmdNextTabSmart = 373,
185-
CmdPrevTabSmart = 374,
186-
CmdMoveTabLeft = 375,
187-
CmdMoveTabRight = 376,
188-
CmdSelectNextTheme = 377,
189-
CmdToggleFrequentlyRead = 378,
190-
CmdInvokeInverseSearch = 379,
191-
CmdExec = 380,
192-
CmdViewWithExternalViewer = 381,
193-
CmdSelectionHandler = 382,
194-
CmdSetTheme = 383,
195-
CmdToggleInverseSearch = 384,
196-
CmdDebugCorruptMemory = 385,
197-
CmdDebugCrashMe = 386,
198-
CmdDebugDownloadSymbols = 387,
199-
CmdDebugTestApp = 388,
200-
CmdDebugShowNotif = 389,
201-
CmdDebugStartStressTest = 390,
202-
CmdDebugTogglePredictiveRender = 391,
203-
CmdDebugToggleRtl = 392,
204-
CmdToggleAntiAlias = 393,
205-
CmdToggleSmoothScroll = 394,
206-
CmdToggleScrollbarInSinglePage = 395,
207-
CmdToggleLazyLoading = 396,
208-
CmdToggleEscToExit = 397,
209-
CmdListPrinters = 398,
210-
CmdToggleWindowsPreviewer = 399,
211-
CmdToggleWindowsSearchFilter = 400,
212-
CmdScreenshot = 401,
213-
CmdCropImage = 402,
214-
CmdResizeImage = 403,
215-
CmdSaveImage = 404,
216-
CmdPasteClipboardImage = 405,
217-
CmdTabGroupSave = 406,
218-
CmdTabGroupRestore = 407,
219-
CmdToggleTips = 408,
220-
CmdChangeBackgroundColor = 409,
221-
CmdSetTabColor = 410,
222-
CmdPdfCompress = 411,
223-
CmdPdfDecompress = 412,
224-
CmdPdfDeletePages = 413,
225-
CmdPdfExtractPages = 414,
226-
CmdPdfEncrypt = 415,
227-
CmdPdfDecrypt = 416,
228-
CmdPdfBake = 417,
229-
CmdPdShowInfo = 418,
230-
CmdDocumentExtractText = 419,
231-
CmdDocumentShowOutline = 420,
232-
CmdSetScreenshotHotkey = 421,
233-
CmdToggleReuseInstance = 422,
234-
CmdToggleChmUI = 423,
235-
CmdReadAloud = 424,
236-
CmdPauseReadAloud = 425,
237-
CmdContinueReadAloud = 426,
238-
CmdToggleHoverPreview = 427,
239-
CmdRemoveDeletedFilesFromHistory = 428,
240-
CmdCommandPaletteTOC = 429,
241-
CmdDebugToggleRenderInfo = 430,
242-
CmdConvertImageToPdf = 431,
243-
CmdNone = 432,
90+
CmdZoomFitByOrientation = 279,
91+
CmdZoom6400 = 280,
92+
CmdZoom3200 = 281,
93+
CmdZoom1600 = 282,
94+
CmdZoom800 = 283,
95+
CmdZoom400 = 284,
96+
CmdZoom200 = 285,
97+
CmdZoom150 = 286,
98+
CmdZoom125 = 287,
99+
CmdZoom100 = 288,
100+
CmdZoom50 = 289,
101+
CmdZoom25 = 290,
102+
CmdZoom12_5 = 291,
103+
CmdZoom8_33 = 292,
104+
CmdZoomFitContent = 293,
105+
CmdZoomShrinkToFit = 294,
106+
CmdZoomCustom = 295,
107+
CmdZoomIn = 296,
108+
CmdZoomOut = 297,
109+
CmdZoomFitWidthAndContinuous = 298,
110+
CmdZoomFitPageAndSinglePage = 299,
111+
CmdContributeTranslation = 300,
112+
CmdOpenWithKnownExternalViewerFirst = 301,
113+
CmdOpenWithExplorer = 302,
114+
CmdOpenWithDirectoryOpus = 303,
115+
CmdOpenWithTotalCommander = 304,
116+
CmdOpenWithDoubleCommander = 305,
117+
CmdOpenWithAcrobat = 306,
118+
CmdOpenWithFoxIt = 307,
119+
CmdOpenWithFoxItPhantom = 308,
120+
CmdOpenWithPdfXchange = 309,
121+
CmdOpenWithXpsViewer = 310,
122+
CmdOpenWithHtmlHelp = 311,
123+
CmdOpenWithPdfDjvuBookmarker = 312,
124+
CmdOpenWithKnownExternalViewerLast = 313,
125+
CmdOpenSelectedDocument = 314,
126+
CmdPinSelectedDocument = 315,
127+
CmdForgetSelectedDocument = 316,
128+
CmdExpandAll = 317,
129+
CmdCollapseAll = 318,
130+
CmdSaveEmbeddedFile = 319,
131+
CmdOpenEmbeddedPDF = 320,
132+
CmdSaveAttachment = 321,
133+
CmdOpenAttachment = 322,
134+
CmdOptions = 323,
135+
CmdAdvancedOptions = 324,
136+
CmdAdvancedSettings = 325,
137+
CmdChangeLanguage = 326,
138+
CmdCheckUpdate = 327,
139+
CmdHelpOpenManual = 328,
140+
CmdHelpOpenManualOnWebsite = 329,
141+
CmdHelpOpenKeyboardShortcuts = 330,
142+
CmdHelpVisitWebsite = 331,
143+
CmdHelpAbout = 332,
144+
CmdMoveFrameFocus = 333,
145+
CmdFavoriteAdd = 334,
146+
CmdFavoriteDel = 335,
147+
CmdFavoriteToggle = 336,
148+
CmdToggleLinks = 337,
149+
CmdToggleShowAnnotations = 338,
150+
CmdShowAnnotations = 339,
151+
CmdHideAnnotations = 340,
152+
CmdCreateAnnotText = 341,
153+
CmdCreateAnnotLink = 342,
154+
CmdCreateAnnotFreeText = 343,
155+
CmdCreateAnnotLine = 344,
156+
CmdCreateAnnotSquare = 345,
157+
CmdCreateAnnotCircle = 346,
158+
CmdCreateAnnotPolygon = 347,
159+
CmdCreateAnnotPolyLine = 348,
160+
CmdCreateAnnotHighlight = 349,
161+
CmdCreateAnnotUnderline = 350,
162+
CmdCreateAnnotSquiggly = 351,
163+
CmdCreateAnnotStrikeOut = 352,
164+
CmdCreateAnnotRedact = 353,
165+
CmdCreateAnnotStamp = 354,
166+
CmdCreateAnnotCaret = 355,
167+
CmdCreateAnnotInk = 356,
168+
CmdCreateAnnotPopup = 357,
169+
CmdCreateAnnotFileAttachment = 358,
170+
CmdInvertColors = 359,
171+
CmdTogglePageInfo = 360,
172+
CmdToggleZoom = 361,
173+
CmdNavigateBack = 362,
174+
CmdNavigateForward = 363,
175+
CmdToggleCursorPosition = 364,
176+
CmdOpenNextFileInFolder = 365,
177+
CmdOpenPrevFileInFolder = 366,
178+
CmdCommandPalette = 367,
179+
CmdShowLog = 368,
180+
CmdShowErrors = 369,
181+
CmdClearHistory = 370,
182+
CmdReopenLastClosedFile = 371,
183+
CmdNextTab = 372,
184+
CmdPrevTab = 373,
185+
CmdNextTabSmart = 374,
186+
CmdPrevTabSmart = 375,
187+
CmdMoveTabLeft = 376,
188+
CmdMoveTabRight = 377,
189+
CmdSelectNextTheme = 378,
190+
CmdToggleFrequentlyRead = 379,
191+
CmdInvokeInverseSearch = 380,
192+
CmdExec = 381,
193+
CmdViewWithExternalViewer = 382,
194+
CmdSelectionHandler = 383,
195+
CmdSetTheme = 384,
196+
CmdToggleInverseSearch = 385,
197+
CmdDebugCorruptMemory = 386,
198+
CmdDebugCrashMe = 387,
199+
CmdDebugDownloadSymbols = 388,
200+
CmdDebugTestApp = 389,
201+
CmdDebugShowNotif = 390,
202+
CmdDebugStartStressTest = 391,
203+
CmdDebugTogglePredictiveRender = 392,
204+
CmdDebugToggleRtl = 393,
205+
CmdToggleAntiAlias = 394,
206+
CmdToggleSmoothScroll = 395,
207+
CmdToggleScrollbarInSinglePage = 396,
208+
CmdToggleLazyLoading = 397,
209+
CmdToggleEscToExit = 398,
210+
CmdListPrinters = 399,
211+
CmdToggleWindowsPreviewer = 400,
212+
CmdToggleWindowsSearchFilter = 401,
213+
CmdScreenshot = 402,
214+
CmdCropImage = 403,
215+
CmdResizeImage = 404,
216+
CmdSaveImage = 405,
217+
CmdPasteClipboardImage = 406,
218+
CmdTabGroupSave = 407,
219+
CmdTabGroupRestore = 408,
220+
CmdToggleTips = 409,
221+
CmdChangeBackgroundColor = 410,
222+
CmdSetTabColor = 411,
223+
CmdPdfCompress = 412,
224+
CmdPdfDecompress = 413,
225+
CmdPdfDeletePages = 414,
226+
CmdPdfExtractPages = 415,
227+
CmdPdfEncrypt = 416,
228+
CmdPdfDecrypt = 417,
229+
CmdPdfBake = 418,
230+
CmdPdShowInfo = 419,
231+
CmdDocumentExtractText = 420,
232+
CmdDocumentShowOutline = 421,
233+
CmdSetScreenshotHotkey = 422,
234+
CmdToggleReuseInstance = 423,
235+
CmdToggleChmUI = 424,
236+
CmdReadAloud = 425,
237+
CmdPauseReadAloud = 426,
238+
CmdContinueReadAloud = 427,
239+
CmdToggleHoverPreview = 428,
240+
CmdRemoveDeletedFilesFromHistory = 429,
241+
CmdCommandPaletteTOC = 430,
242+
CmdDebugToggleRenderInfo = 431,
243+
CmdConvertImageToPdf = 432,
244+
CmdNone = 433,
244245

245246
/* range for file history */
246247
CmdFileHistoryFirst,

0 commit comments

Comments
 (0)