GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Store/Recall Lister Size

Occasionally I want to temporarily resize a Lister but revert back to the previous size. To make this simpler (not having to manually resize) I've written a couple of very basic script buttons to assist.

The first button copies the current Lister's dimensions (storing the data as a global variable) and the second resizes the last active Lister to those stored dimensions.

Because these scripts work on the last active Lister and the dimensions are stored globally within Opus you could also use them to copy the dimensions of one Lister and change the size of another Lister to match it.

The first button sends the Width and Height to the Script Log - in case you just want to see the results.

Store Lister Size

function OnClick(clickData)
{
	listers = DOpus.Listers;

	lister = listers.lastactive;
	left = lister.left;
	right = lister.right;
	top = lister.top;
	bottom = lister.bottom;
	width = right - left;
	height = bottom - top;

	DOpus.ClearOutput();
	DOpus.Output('Width  : ' + width);
	DOpus.Output('Height : ' + height);

	DOpus.Vars.Set('width') = width;
	DOpus.Vars.Set('height') = height;
}

Recall Lister Size

function OnClick(clickData)
{
	if (!DOpus.Vars.Exists('width') || !DOpus.Vars.Exists('height'))
	{
		mtVariables();
        return;
		}

	cmd = clickData.func.command;
	width = DOpus.Vars.Get('width');
	height = DOpus.Vars.Get('height');
	cmd.RunCommand('Set LISTERSIZE=' + width + ',' + height);
		
}

function mtVariables()
{
	listers = DOpus.Listers;
	lister = listers.lastactive;
		
	dlg = DOpus.Dlg;
	dlg.window = lister;
	dlg.message = "You need to run the Store Lister Size button first!";
	dlg.title = "No Stored Lister Size";
	dlg.Buttons = "Ok";

	dlg.Show;
}

Store Lister Size.dcf (1.3 KB)
Recall Lister Size.dcf (1.7 KB)

3 Likes

This additional script may be of use to some. Add it to Prefs/Toolbars/Scripts. Then open the Script Log - whenever you resize the Lister the dimensions will be shown in the Log.

Show Lister Size.js.txt (832 Bytes)

Updated the first post. The Recall Lister Size button now does some simple error checking and prompts if you haven't yet stored any Lister sizes.

Thank you Steve, very useful :+1:

Do you know if there is a possibility to also recall the position of the lister on the screen?

Thanks
Vitor

This button will give you the top, bottom, left and right coordinates of the source lister:

Edges.dcf (1.0 KB)

The results will show in the Script Log.

<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="right" textcol="none">
	<label>Edges</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(clickData)</instruction>
		<instruction>{</instruction>
		<instruction>var top = clickData.func.sourcetab.lister.top;</instruction>
		<instruction>var bottom = clickData.func.sourcetab.lister.bottom</instruction>
		<instruction>var left = clickData.func.sourcetab.lister.left</instruction>
		<instruction>var right = clickData.func.sourcetab.lister.right</instruction>
		<instruction />
		<instruction>DOpus.Output(&quot;Top Edge Coordinate: &quot; + top);</instruction>
		<instruction>DOpus.Output(&quot;Bottom Edge Coordinate: &quot; + bottom);</instruction>
		<instruction>DOpus.Output(&quot;Left Edge Coordinate: &quot; + left);</instruction>
		<instruction>DOpus.Output(&quot;Right Edge Coordinate: &quot; + right);	</instruction>
		<instruction>}</instruction>
	</function>
</button>

Just re-read your reply and I think I misunderstood what you wanted. It's possible to store the lister location and set another lister to that location I think. Will have a play later.

Here are two new copies of the buttons which should do what you want. As before, the first button stores the Lister (now with position) and the second will resize and relocate the current Lister.

Store Lister Size/Pos

function OnClick(clickData)
{
	lister = DOpus.Listers.lastactive;
	
	width = lister.right - lister.left;
	height = lister.bottom - lister.top;

	DOpus.Vars.Set('width') = width;
	DOpus.Vars.Set('height') = height;
	DOpus.Vars.Set('top') = lister.top;
	DOpus.Vars.Set('left') = lister.left;

	DOpus.Output('Lister Size/Pos Stored.', false, true);
	DOpus.Output(' Width :   ' + width, false, true);
	DOpus.Output(' Height:   ' + height, false, true);
	DOpus.Output(' Position: ' + lister.left + ',' + lister.top, false, true);
}

Recall Lister Size/Pos

function OnClick(clickData)
{
	if (!DOpus.Vars.Exists('width') || !DOpus.Vars.Exists('height') || !DOpus.Vars.Exists('top') || !DOpus.Vars.Exists('left')) {
		mtVar();
		return;
	}
		cmd = clickData.func.command;
		cmd.RunCommand('Set LISTERSIZE=' + DOpus.Vars.Get('width') + ',' + DOpus.Vars.Get('height'));
		cmd.RunCommand('Set LISTERPOS=' + DOpus.Vars.Get('left') + ',' + DOpus.Vars.Get('top'));
}

function mtVar()
{
		listers = DOpus.Listers;
		
		dlg = DOpus.Dlg;
		dlg.window = listers.lastactive;
		dlg.message = "You need to run the Store Lister Size/Pos button first!";
		dlg.title = "No Stored Lister Size";
		dlg.Buttons = "Ok";
		dlg.Show;
}

Hi Steve,
This is awesome !
Working perfectly, many many thanks to you :pray:

Vitor

1 Like

Hello Steve,

May I ask if there is a possibility for Dopus to retain the "store lister" script at shutdown?
Form the moment I have to run it every time I shutdown Dopus or the computer.
Thanks
Vitor

Not sure why you'd need that, doesn't the normal saving of default listers and layouts do that for you?

I'm curious, could you explain why it's needed to survive a reboot? My thought was that it's occasionally useful to copy/reuse a listers dimensions temporarily but for anything permanent a saved layout is much better.

Here's a replacement for the store button which will survive a reboot:

Store Lister Size/Pos

function OnClick(clickData)
{
	lister = DOpus.Listers.lastactive;
	
	width = lister.right - lister.left;
	height = lister.bottom - lister.top;

	DOpus.Vars.Set('width') = width;
	DOpus.Vars.Set('height') = height;
	DOpus.Vars.Set('top') = lister.top;
	DOpus.Vars.Set('left') = lister.left;

	DOpus.Vars("width").persist = true;
	DOpus.Vars("height").persist = true;
	DOpus.Vars("top").persist = true;
	DOpus.Vars("left").persist = true;

	DOpus.Output('Lister Size/Pos Stored.', false, true);
	DOpus.Output(' Width :   ' + width, false, true);
	DOpus.Output(' Height:   ' + height, false, true);
	DOpus.Output(' Position: ' + lister.left + ',' + lister.top, false, true);
}

Hi there Steve,

Well, I've tried recalling a layout but couldn't find a way ... it always opens a new lister and not resizing the active one.

The button in my previous post should solve this for you by saving the variables permanently.

Thanks Steve,
Indeed, it solved my problems :+1: