summaryrefslogtreecommitdiffstats
path: root/gui/patternpassword.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/patternpassword.cpp')
-rw-r--r--gui/patternpassword.cpp82
1 files changed, 41 insertions, 41 deletions
diff --git a/gui/patternpassword.cpp b/gui/patternpassword.cpp
index ab446b9f0..4bce37a0c 100644
--- a/gui/patternpassword.cpp
+++ b/gui/patternpassword.cpp
@@ -54,7 +54,7 @@ GUIPatternPassword::GUIPatternPassword(xml_node<>* node)
mAction = new GUIAction(node);
child = FindNode(node, "dot");
- if(child)
+ if (child)
{
mDotColor = LoadAttrColor(child, "color", mDotColor);
mActiveDotColor = LoadAttrColor(child, "activecolor", mActiveDotColor);
@@ -65,18 +65,18 @@ GUIPatternPassword::GUIPatternPassword(xml_node<>* node)
}
child = FindNode(node, "line");
- if(child)
+ if (child)
{
mLineColor = LoadAttrColor(child, "color", mLineColor);
mLineWidth = LoadAttrIntScaleX(child, "width", mLineWidth);
}
child = FindNode(node, "data");
- if(child)
+ if (child)
mPassVar = LoadAttrString(child, "name", "");
child = FindNode(node, "size");
- if(child) {
+ if (child) {
mSizeVar = LoadAttrString(child, "name", "");
// Use the configured default, if set.
@@ -84,7 +84,7 @@ GUIPatternPassword::GUIPatternPassword(xml_node<>* node)
Resize(size);
}
- if(!mDotImage || !mDotImage->GetResource() || !mActiveDotImage || !mActiveDotImage->GetResource())
+ if (!mDotImage || !mDotImage->GetResource() || !mActiveDotImage || !mActiveDotImage->GetResource())
{
mDotCircle = gr_render_circle(mDotRadius, mDotColor.red, mDotColor.green, mDotColor.blue, mDotColor.alpha);
mActiveDotCircle = gr_render_circle(mDotRadius/2, mActiveDotColor.red, mActiveDotColor.green, mActiveDotColor.blue, mActiveDotColor.alpha);
@@ -104,10 +104,10 @@ GUIPatternPassword::~GUIPatternPassword()
delete[] mDots;
delete[] mConnectedDots;
- if(mDotCircle)
+ if (mDotCircle)
gr_free_surface(mDotCircle);
- if(mActiveDotCircle)
+ if (mActiveDotCircle)
gr_free_surface(mActiveDotCircle);
}
@@ -115,7 +115,7 @@ void GUIPatternPassword::ResetActiveDots()
{
mConnectedDotsLen = 0;
mCurLineX = mCurLineY = -1;
- for(size_t i = 0; i < mGridSize * mGridSize; ++i)
+ for (size_t i = 0; i < mGridSize * mGridSize; ++i)
mDots[i].active = false;
}
@@ -155,9 +155,9 @@ void GUIPatternPassword::CalculateDotPositions(void)
* n*n-1
*/
- for(size_t r = 0; r < mGridSize; ++r)
+ for (size_t r = 0; r < mGridSize; ++r)
{
- for(size_t c = 0; c < mGridSize; ++c)
+ for (size_t c = 0; c < mGridSize; ++c)
{
mDots[mGridSize*r + c].x = x;
mDots[mGridSize*r + c].y = y;
@@ -170,29 +170,29 @@ void GUIPatternPassword::CalculateDotPositions(void)
int GUIPatternPassword::Render(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
gr_color(mLineColor.red, mLineColor.green, mLineColor.blue, mLineColor.alpha);
- for(size_t i = 1; i < mConnectedDotsLen; ++i) {
+ for (size_t i = 1; i < mConnectedDotsLen; ++i) {
const Dot& dp = mDots[mConnectedDots[i-1]];
const Dot& dc = mDots[mConnectedDots[i]];
gr_line(dp.x + mDotRadius, dp.y + mDotRadius, dc.x + mDotRadius, dc.y + mDotRadius, mLineWidth);
}
- if(mConnectedDotsLen > 0 && mTrackingTouch) {
+ if (mConnectedDotsLen > 0 && mTrackingTouch) {
const Dot& dc = mDots[mConnectedDots[mConnectedDotsLen-1]];
gr_line(dc.x + mDotRadius, dc.y + mDotRadius, mCurLineX, mCurLineY, mLineWidth);
}
- for(size_t i = 0; i < mGridSize * mGridSize; ++i) {
- if(mDotCircle) {
+ for (size_t i = 0; i < mGridSize * mGridSize; ++i) {
+ if (mDotCircle) {
gr_blit(mDotCircle, 0, 0, gr_get_width(mDotCircle), gr_get_height(mDotCircle), mDots[i].x, mDots[i].y);
- if(mDots[i].active) {
+ if (mDots[i].active) {
gr_blit(mActiveDotCircle, 0, 0, gr_get_width(mActiveDotCircle), gr_get_height(mActiveDotCircle), mDots[i].x + mDotRadius/2, mDots[i].y + mDotRadius/2);
}
} else {
- if(mDots[i].active) {
+ if (mDots[i].active) {
gr_blit(mActiveDotImage->GetResource(), 0, 0, mActiveDotImage->GetWidth(), mActiveDotImage->GetHeight(),
mDots[i].x + (mDotRadius - mActiveDotImage->GetWidth()/2), mDots[i].y + (mDotRadius - mActiveDotImage->GetHeight()/2));
} else {
@@ -205,7 +205,7 @@ int GUIPatternPassword::Render(void)
int GUIPatternPassword::Update(void)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
int res = mNeedRender ? 2 : 1;
@@ -214,7 +214,7 @@ int GUIPatternPassword::Update(void)
}
void GUIPatternPassword::Resize(size_t n) {
- if(mGridSize == n)
+ if (mGridSize == n)
return;
delete[] mDots;
@@ -247,8 +247,8 @@ static bool IsInCircle(int x, int y, int ox, int oy, int r)
int GUIPatternPassword::InDot(int x, int y)
{
- for(size_t i = 0; i < mGridSize * mGridSize; ++i) {
- if(IsInCircle(x, y, mDots[i].x + mDotRadius, mDots[i].y + mDotRadius, mDotRadius*3))
+ for (size_t i = 0; i < mGridSize * mGridSize; ++i) {
+ if (IsInCircle(x, y, mDots[i].x + mDotRadius, mDots[i].y + mDotRadius, mDotRadius*3))
return i;
}
return -1;
@@ -256,8 +256,8 @@ int GUIPatternPassword::InDot(int x, int y)
bool GUIPatternPassword::DotUsed(int dot_idx)
{
- for(size_t i = 0; i < mConnectedDotsLen; ++i) {
- if(mConnectedDots[i] == dot_idx)
+ for (size_t i = 0; i < mConnectedDotsLen; ++i) {
+ if (mConnectedDots[i] == dot_idx)
return true;
}
return false;
@@ -265,7 +265,7 @@ bool GUIPatternPassword::DotUsed(int dot_idx)
void GUIPatternPassword::ConnectDot(int dot_idx)
{
- if(mConnectedDotsLen >= mGridSize * mGridSize)
+ if (mConnectedDotsLen >= mGridSize * mGridSize)
{
LOGERR("mConnectedDots in GUIPatternPassword has overflown!\n");
return;
@@ -277,7 +277,7 @@ void GUIPatternPassword::ConnectDot(int dot_idx)
void GUIPatternPassword::ConnectIntermediateDots(int next_dot_idx)
{
- if(mConnectedDotsLen == 0)
+ if (mConnectedDotsLen == 0)
return;
const int prev_dot_idx = mConnectedDots[mConnectedDotsLen-1];
@@ -311,15 +311,15 @@ void GUIPatternPassword::ConnectIntermediateDots(int next_dot_idx)
int Dy = (ny > py) ? 1 : -1;
// Vertical lines.
- if(px == nx)
+ if (px == nx)
Dx = 0;
// Horizontal lines.
- else if(py == ny)
+ else if (py == ny)
Dy = 0;
// Diagonal lines (|∆x| = |∆y|).
- else if(abs(px - nx) == abs(py - ny))
+ else if (abs(px - nx) == abs(py - ny))
;
// No valid intermediate dots.
@@ -327,19 +327,19 @@ void GUIPatternPassword::ConnectIntermediateDots(int next_dot_idx)
return;
// Iterate along axis, adding dots in the correct order.
- while((Dy == 0 || y != ny - Dy) && (Dx == 0 || x != nx - Dx)) {
+ while ((Dy == 0 || y != ny - Dy) && (Dx == 0 || x != nx - Dx)) {
x += Dx;
y += Dy;
int idx = mGridSize * y + x;
- if(!DotUsed(idx))
+ if (!DotUsed(idx))
ConnectDot(idx);
}
}
int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return -1;
switch (state)
@@ -347,7 +347,7 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
case TOUCH_START:
{
const int dot_idx = InDot(x, y);
- if(dot_idx == -1)
+ if (dot_idx == -1)
break;
mTrackingTouch = true;
@@ -361,11 +361,11 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
}
case TOUCH_DRAG:
{
- if(!mTrackingTouch)
+ if (!mTrackingTouch)
break;
const int dot_idx = InDot(x, y);
- if(dot_idx != -1 && !DotUsed(dot_idx))
+ if (dot_idx != -1 && !DotUsed(dot_idx))
{
ConnectIntermediateDots(dot_idx);
ConnectDot(dot_idx);
@@ -379,7 +379,7 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
}
case TOUCH_RELEASE:
{
- if(!mTrackingTouch)
+ if (!mTrackingTouch)
break;
mNeedRender = true;
@@ -396,10 +396,10 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
int GUIPatternPassword::NotifyVarChange(const std::string& varName, const std::string& value)
{
- if(!isConditionTrue())
+ if (!isConditionTrue())
return 0;
- if(varName == mSizeVar) {
+ if (varName == mSizeVar) {
Resize(atoi(value.c_str()));
mUpdate = true;
}
@@ -420,8 +420,8 @@ static unsigned int getSDKVersion(void) {
std::string GUIPatternPassword::GeneratePassphrase()
{
char pattern[mConnectedDotsLen];
- for(size_t i = 0; i < mConnectedDotsLen; i++) {
- pattern[i] = (char) mConnectedDots[i];
+ for (size_t i = 0; i < mConnectedDotsLen; i++) {
+ pattern[i] = (char) mConnectedDots[i];
}
std::stringstream pass;
@@ -461,9 +461,9 @@ std::string GUIPatternPassword::GeneratePassphrase()
void GUIPatternPassword::PatternDrawn()
{
- if(!mPassVar.empty() && mConnectedDotsLen > 0)
+ if (!mPassVar.empty() && mConnectedDotsLen > 0)
DataManager::SetValue(mPassVar, GeneratePassphrase());
- if(mAction)
+ if (mAction)
mAction->doActions();
}