aboutsummaryrefslogtreecommitdiff
path: root/Src/resources/skins/Big Bento/scripts/simplemaximize.m
blob: cc255edd4317b63c34ca643268127be8a0a3a55e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
 * simlple maximize script
 * 
 * doesn't require a registry store, so ideal for standardframes
 * required objects: maximize & restore as buttons
 * 
 * @author mpdeimos
 * @version 0.1
 */

#include <lib/std.mi>

Global Button restore, maximize;
Global Layout parent;

Global Int lx, ly, lw, lh;

System.onScriptLoaded ()
{
	restore = getScriptGroup().findObject("restore");
	maximize = getScriptGroup().findObject("maximize");
	parent = getScriptGroup().getParentLayout();

	lx = -1;
	ly = -1;
	lh = -1;
	lw = -1;
}

parent.onResize (int x, int y, int w, int h)
{
		double d = getScale();
		if (getLeft() == getViewPortLeftfromGuiObject(parent) && getTop() == getViewPortTopfromGuiObject(parent) && getWidth() == getViewPortWidthfromGuiObject(parent)/d && getHeight() == getViewPortHeightfromGuiObject(parent)/d)
		{
			restore.show();
			maximize.hide();
		}
		else
		{
			restore.hide();
			maximize.show();
		}
}

maximize.onLeftClick ()
{
	lx = parent.getLeft();
	ly = parent.getTop();
	lw = parent.getWidth();
	lh = parent.getHeight();

	double d = parent.getScale();
	parent.resize(getViewPortLeftfromGuiObject(parent), getViewPortTopfromGuiObject(parent), getViewPortWidthfromGuiObject(parent)/d, getViewPortHeightfromGuiObject(parent)/d);
}


restore.onLeftClick ()
{
	if (lx == -1)
		lx = parent.getLeft() - 75;
	if (ly == -1)
		ly = parent.getTop() - 75;
	if (lw == -1)
		lw = parent.getWidth() - 150;
	if (lh == -1)
		lh = parent.getHeight() - 150;

	parent.resize(lx,ly,lw,lh);
}


// TODO (mpdeimos) add scale recognizing