gui: PatternPassword: allow any N*N grid

Rather than only supporting a 3x3 grid, allow for multiple grid sizes
(using the CyanogenMod method of generating passphrases for non-3x3
grids). Also fix the detection of touches, as the old code was far too
sensitive for larger grids (and also didn't make much sense).

Change-Id: I343ef654e6d29ce0cb790a28281be7c7c9b171d9
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
diff --git a/gui/objects.hpp b/gui/objects.hpp
index ebf08a8..4e7ea29 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -1134,6 +1134,7 @@
 	virtual int Render(void);
 	virtual int Update(void);
 	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	virtual int NotifyVarChange(const std::string& varName, const std::string& value);
 	virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
 
 protected:
@@ -1141,9 +1142,10 @@
 	void ResetActiveDots();
 	void ConnectDot(int dot_idx);
 	void ConnectIntermediateDots(int dot_idx);
+	void Resize(size_t size);
 	int InDot(int x, int y);
 	bool DotUsed(int dot_idx);
-	static bool IsInRect(int x, int y, int rx, int ry, int rw, int rh);
+	std::string GeneratePassphrase();
 	void PatternDrawn();
 
 	struct Dot {
@@ -1152,8 +1154,11 @@
 		bool active;
 	};
 
-	Dot mDots[9];
-	int mConnectedDots[9];
+	std::string mSizeVar;
+	size_t mGridSize;
+
+	Dot* mDots;
+	int* mConnectedDots;
 	size_t mConnectedDotsLen;
 	int mCurLineX;
 	int mCurLineY;