From b25a18395e666bbe13506651d5de84054aae0fcc Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Thu, 31 Dec 2015 17:36:00 +0100 Subject: 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 --- gui/objects.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gui/objects.hpp') diff --git a/gui/objects.hpp b/gui/objects.hpp index ebf08a8db..4e7ea29f4 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -1134,6 +1134,7 @@ public: 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 @@ protected: 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 @@ protected: 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; -- cgit v1.2.3