Universal Zoom

GPSoftware notes (April 2020):

You probably don't need this script unless you're using an old version of Opus.

In Opus 12, these default hotkeys are already set up:

  • Ctrl + Mouse Wheel to increase/decrease the active tab's font size or thumbnail size (as appropriate).

  • Ctrl + Alt + Mouse Wheel to do the same, but affecting both sides of a dual-display lister.

  • Ctrl + 0 (Zero) to reset the zoom level in the active tab.

The script below may still be of interest just to see how it works and apply similar ideas to other things.

--Leo


How it works?

LMB or Zoom In hotkey will increase font size in Detail/Power mode or thumbnail size in Thumbnails mode. If lister set to dual mode, it will operate on active side only, so you can set zoom level for each side independently.

RMB or Zoom Out hotkey will decrease font size in Detail/Power mode or thumbnail size in Thumbnails mode. If lister set to dual mode, it will operate on active side only, so you can set zoom level for each side independently.

MMB or Zoom Reset hotkey will reset font size in Detail/Power mode or thumbnail size in Thumbnails mode. If lister set to dual mode, it will operate on active side only, so you can reset zoom level to default value for each side independently.

This attachment contains readme.txt, Zoom.dcf and zoom.png (designed like border buttons):

Universal Zoom.zip (1.33 KB)

See How to use buttons and scripts from this forum for how to use the contents of the zip. (But note that you probably don't need this if you're using Opus 12. See the top of the post.)

For reference, the code for everythign in the zip file is reproduced below:


Code for Zoom In hotkey

Option Explicit

Function OnClick(ByRef ClickData)
   If ClickData.Func.Command.IsSet("DUAL=off") Then
      Call Zoom("both")
   Else
      If ClickData.Func.Command.IsSet("SOURCE=left") Then
         Call Zoom("left")
      ElseIf ClickData.Func.Command.IsSet("SOURCE=right") Then
         Call Zoom("right")
      End If
   End If
End Function

Sub Zoom(Side)
   Dim OpusCmd
   Set OpusCmd = DOpus.NewCommand
   If OpusCmd.IsSet("VIEW=Thumbnails") Then
      OpusCmd.RunCommand("Show THUMBNAILSIZE=+16," & Side & "")
   Else
      OpusCmd.RunCommand("Set FONTSCALE=+10," & Side & "")
   End If
End Sub

Code for Zoom Out hotkey

Option Explicit

Function OnClick(ByRef ClickData)
   If ClickData.Func.Command.IsSet("DUAL=off") Then
      Call Zoom("both")
   Else
      If ClickData.Func.Command.IsSet("SOURCE=left") Then
         Call Zoom("left")
      ElseIf ClickData.Func.Command.IsSet("SOURCE=right") Then
         Call Zoom("right")
      End If
   End If
End Function

Sub Zoom(Side)
   Dim OpusCmd
   Set OpusCmd = DOpus.NewCommand
   If OpusCmd.IsSet("VIEW=Thumbnails") Then
      OpusCmd.RunCommand("Show THUMBNAILSIZE=-16," & Side & "")
   Else
      OpusCmd.RunCommand("Set FONTSCALE=-10," & Side & "")
   End If
End Sub

Code for Zoom Reset hotkey

Option Explicit

Function OnClick(ByRef ClickData)
   If ClickData.Func.Command.IsSet("DUAL=off") Then
      Call Zoom("both")
   Else
      If ClickData.Func.Command.IsSet("SOURCE=left") Then
         Call Zoom("left")
      ElseIf ClickData.Func.Command.IsSet("SOURCE=right") Then
         Call Zoom("right")
      End If
   End If
End Function

Sub Zoom(Side)
   Dim OpusCmd
   Set OpusCmd = DOpus.NewCommand
   If OpusCmd.IsSet("VIEW=Thumbnails") Then
      OpusCmd.RunCommand("Show THUMBNAILSIZE=reset," & Side & "")
   Else
      OpusCmd.RunCommand("Set FONTSCALE=reset," & Side & "")
   End If
End Sub

XML for toolbar button (How to use buttons and scripts from this forum)

<?xml version="1.0"?>
<button 3dborders="no" backcol="none" display="both" textcol="none" type="three_button">
	<label>Zoom</label>
	<icon1>zoom.png,0</icon1>
	<button backcol="none" display="both" textcol="none">
		<label>Zoom In</label>
		<icon1>zoom.png,0</icon1>
		<function type="script">
			<instruction>Option Explicit</instruction>
			<instruction />
			<instruction>Function OnClick(ByRef ClickData)</instruction>
			<instruction>   If ClickData.Func.Command.IsSet(&quot;DUAL=off&quot;) Then</instruction>
			<instruction>      Call Zoom(&quot;both&quot;)</instruction>
			<instruction>   Else</instruction>
			<instruction>      If ClickData.Func.Command.IsSet(&quot;SOURCE=left&quot;) Then</instruction>
			<instruction>         Call Zoom(&quot;left&quot;)</instruction>
			<instruction>      ElseIf ClickData.Func.Command.IsSet(&quot;SOURCE=right&quot;) Then</instruction>
			<instruction>         Call Zoom(&quot;right&quot;)</instruction>
			<instruction>      End If</instruction>
			<instruction>   End If</instruction>
			<instruction>End Function</instruction>
			<instruction />
			<instruction>Sub Zoom(Side)</instruction>
			<instruction>   Dim OpusCmd</instruction>
			<instruction>   Set OpusCmd = DOpus.NewCommand</instruction>
			<instruction>   If OpusCmd.IsSet(&quot;VIEW=Thumbnails&quot;) Then</instruction>
			<instruction>      OpusCmd.RunCommand(&quot;Show THUMBNAILSIZE=+16,&quot; &amp; Side &amp; &quot;&quot;)</instruction>
			<instruction>   Else</instruction>
			<instruction>      OpusCmd.RunCommand(&quot;Set FONTSCALE=+10,&quot; &amp; Side &amp; &quot;&quot;)</instruction>
			<instruction>   End If</instruction>
			<instruction>End Sub</instruction>
		</function>
	</button>
	<button backcol="none" display="both" textcol="none">
		<label>Zoom Out</label>
		<icon1>zoom.png,0</icon1>
		<function type="script">
			<instruction>Option Explicit</instruction>
			<instruction />
			<instruction>Function OnClick(ByRef ClickData)</instruction>
			<instruction>   If ClickData.Func.Command.IsSet(&quot;DUAL=off&quot;) Then</instruction>
			<instruction>      Call Zoom(&quot;both&quot;)</instruction>
			<instruction>   Else</instruction>
			<instruction>      If ClickData.Func.Command.IsSet(&quot;SOURCE=left&quot;) Then</instruction>
			<instruction>         Call Zoom(&quot;left&quot;)</instruction>
			<instruction>      ElseIf ClickData.Func.Command.IsSet(&quot;SOURCE=right&quot;) Then</instruction>
			<instruction>         Call Zoom(&quot;right&quot;)</instruction>
			<instruction>      End If</instruction>
			<instruction>   End If</instruction>
			<instruction>End Function</instruction>
			<instruction />
			<instruction>Sub Zoom(Side)</instruction>
			<instruction>   Dim OpusCmd</instruction>
			<instruction>   Set OpusCmd = DOpus.NewCommand</instruction>
			<instruction>   If OpusCmd.IsSet(&quot;VIEW=Thumbnails&quot;) Then</instruction>
			<instruction>      OpusCmd.RunCommand(&quot;Show THUMBNAILSIZE=-16,&quot; &amp; Side &amp; &quot;&quot;)</instruction>
			<instruction>   Else</instruction>
			<instruction>      OpusCmd.RunCommand(&quot;Set FONTSCALE=-10,&quot; &amp; Side &amp; &quot;&quot;)</instruction>
			<instruction>   End If</instruction>
			<instruction>End Sub</instruction>
		</function>
	</button>
	<button backcol="none" display="both" textcol="none">
		<label>Zoom Reset</label>
		<icon1>zoom.png,0</icon1>
		<function type="script">
			<instruction>Option Explicit</instruction>
			<instruction />
			<instruction>Function OnClick(ByRef ClickData)</instruction>
			<instruction>   If ClickData.Func.Command.IsSet(&quot;DUAL=off&quot;) Then</instruction>
			<instruction>      Call Zoom(&quot;both&quot;)</instruction>
			<instruction>   Else</instruction>
			<instruction>      If ClickData.Func.Command.IsSet(&quot;SOURCE=left&quot;) Then</instruction>
			<instruction>         Call Zoom(&quot;left&quot;)</instruction>
			<instruction>      ElseIf ClickData.Func.Command.IsSet(&quot;SOURCE=right&quot;) Then</instruction>
			<instruction>         Call Zoom(&quot;right&quot;)</instruction>
			<instruction>      End If</instruction>
			<instruction>   End If</instruction>
			<instruction>End Function</instruction>
			<instruction />
			<instruction>Sub Zoom(Side)</instruction>
			<instruction>   Dim OpusCmd</instruction>
			<instruction>   Set OpusCmd = DOpus.NewCommand</instruction>
			<instruction>   If OpusCmd.IsSet(&quot;VIEW=Thumbnails&quot;) Then</instruction>
			<instruction>      OpusCmd.RunCommand(&quot;Show THUMBNAILSIZE=reset,&quot; &amp; Side &amp; &quot;&quot;)</instruction>
			<instruction>   Else</instruction>
			<instruction>      OpusCmd.RunCommand(&quot;Set FONTSCALE=reset,&quot; &amp; Side &amp; &quot;&quot;)</instruction>
			<instruction>   End If</instruction>
			<instruction>End Sub</instruction>
		</function>
	</button>
</button>