diff options
Diffstat (limited to '')
-rw-r--r-- | gui/action.cpp | 36 | ||||
-rw-r--r-- | gui/animation.cpp | 4 | ||||
-rw-r--r-- | gui/console.cpp | 11 | ||||
-rw-r--r-- | gui/fileselector.cpp | 4 | ||||
-rw-r--r-- | gui/fill.cpp | 2 | ||||
-rw-r--r-- | gui/gui.cpp | 16 | ||||
-rw-r--r-- | gui/input.cpp | 4 | ||||
-rw-r--r-- | gui/listbox.cpp | 4 | ||||
-rw-r--r-- | gui/mousecursor.cpp | 26 | ||||
-rw-r--r-- | gui/object.cpp | 6 | ||||
-rw-r--r-- | gui/objects.hpp | 2 | ||||
-rw-r--r-- | gui/pages.cpp | 22 | ||||
-rw-r--r-- | gui/partitionlist.cpp | 8 | ||||
-rw-r--r-- | gui/patternpassword.cpp | 82 | ||||
-rw-r--r-- | gui/progressbar.cpp | 6 | ||||
-rw-r--r-- | gui/resources.cpp | 8 | ||||
-rw-r--r-- | gui/scrolllist.cpp | 12 | ||||
-rw-r--r-- | gui/slider.cpp | 6 | ||||
-rw-r--r-- | gui/slidervalue.cpp | 32 | ||||
-rw-r--r-- | gui/terminal.cpp | 11 | ||||
-rw-r--r-- | gui/textbox.cpp | 2 | ||||
-rw-r--r-- | gui/theme/common/portrait.xml | 4 | ||||
-rw-r--r-- | gui/twmsg.cpp | 2 |
23 files changed, 157 insertions, 153 deletions
diff --git a/gui/action.cpp b/gui/action.cpp index 5ba749c81..8f85e16da 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -107,7 +107,7 @@ ActionThread::ActionThread() ActionThread::~ActionThread() { pthread_mutex_lock(&m_act_lock); - if(m_thread_running) { + if (m_thread_running) { pthread_mutex_unlock(&m_act_lock); pthread_join(m_thread, NULL); } else { @@ -262,7 +262,7 @@ GUIAction::GUIAction(xml_node<>* node) if (attr) { std::vector<std::string> keys = TWFunc::Split_String(attr->value(), "+"); - for(size_t i = 0; i < keys.size(); ++i) + for (size_t i = 0; i < keys.size(); ++i) { const int key = getKeyByName(keys[i]); mKeys[key] = false; @@ -297,7 +297,7 @@ int GUIAction::NotifyTouch(TOUCH_STATE state, int x __unused, int y __unused) int GUIAction::NotifyKey(int key, bool down) { std::map<int, bool>::iterator itr = mKeys.find(key); - if(itr == mKeys.end()) + if (itr == mKeys.end()) return 1; bool prevState = itr->second; @@ -307,20 +307,20 @@ int GUIAction::NotifyKey(int key, bool down) // doesn't trigger with multi-key actions. // Else, check if all buttons are pressed, then consume their release events // so they don't trigger one-button actions and reset mKeys pressed status - if(mKeys.size() == 1) { - if(!down && prevState) { + if (mKeys.size() == 1) { + if (!down && prevState) { doActions(); return 0; } - } else if(down) { - for(itr = mKeys.begin(); itr != mKeys.end(); ++itr) { - if(!itr->second) + } else if (down) { + for (itr = mKeys.begin(); itr != mKeys.end(); ++itr) { + if (!itr->second) return 1; } // Passed, all req buttons are pressed, reset them and consume release events HardwareKeyboard *kb = PageManager::GetHardwareKeyboard(); - for(itr = mKeys.begin(); itr != mKeys.end(); ++itr) { + for (itr = mKeys.begin(); itr != mKeys.end(); ++itr) { kb->ConsumeKeyRelease(itr->first); itr->second = false; } @@ -338,7 +338,7 @@ int GUIAction::NotifyVarChange(const std::string& varName, const std::string& va if (varName.empty() && !isConditionValid() && mKeys.empty() && !mActionW) doActions(); - else if((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue()) + else if ((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue()) doActions(); return 0; @@ -707,7 +707,7 @@ int GUIAction::compute(std::string arg) int divide_by = atoi(divide_by_str.c_str()); int value; - if(divide_by != 0) + if (divide_by != 0) { DataManager::GetValue(varName, value); DataManager::SetValue(varName, value/divide_by); @@ -855,7 +855,7 @@ int GUIAction::checkpartitionlist(std::string arg) } else { DataManager::SetValue("tw_check_partition_list", 0); } - return 0; + return 0; } int GUIAction::getpartitiondetails(std::string arg) @@ -943,19 +943,19 @@ int GUIAction::screenshot(std::string arg __unused) gid_t gid = -1; struct passwd *pwd = getpwnam("media_rw"); - if(pwd) { + if (pwd) { uid = pwd->pw_uid; gid = pwd->pw_gid; } const std::string storage = DataManager::GetCurrentStoragePath(); - if(PartitionManager.Is_Mounted_By_Path(storage)) { + if (PartitionManager.Is_Mounted_By_Path(storage)) { snprintf(path, sizeof(path), "%s/Pictures/Screenshots/", storage.c_str()); } else { strcpy(path, "/tmp/"); } - if(!TWFunc::Create_Dir_Recursive(path, 0775, uid, gid)) + if (!TWFunc::Create_Dir_Recursive(path, 0775, uid, gid)) return 0; tm = time(NULL); @@ -965,7 +965,7 @@ int GUIAction::screenshot(std::string arg __unused) strftime(path+path_len, sizeof(path)-path_len, "Screenshot_%Y-%m-%d-%H-%M-%S.png", localtime(&tm)); int res = gr_save_screenshot(path); - if(res == 0) { + if (res == 0) { chmod(path, 0666); chown(path, uid, gid); @@ -1388,7 +1388,7 @@ int GUIAction::terminalcommand(std::string arg) struct timeval timeout; fd_set fdset; - while(keep_going) + while (keep_going) { FD_ZERO(&fdset); FD_SET(fd, &fdset); @@ -1406,7 +1406,7 @@ int GUIAction::terminalcommand(std::string arg) keep_going = 0; } else { // Try to read output - if(fgets(line, sizeof(line), fp) != NULL) + if (fgets(line, sizeof(line), fp) != NULL) gui_print("%s", line); // Display output else keep_going = 0; // Done executing diff --git a/gui/animation.cpp b/gui/animation.cpp index d45373d81..37f0d0872 100644 --- a/gui/animation.cpp +++ b/gui/animation.cpp @@ -88,7 +88,7 @@ GUIAnimation::GUIAnimation(xml_node<>* node) : GUIObject(node) int GUIAnimation::Render(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; if (!mAnimation || !mAnimation->GetResource(mFrame)) return -1; @@ -99,7 +99,7 @@ int GUIAnimation::Render(void) int GUIAnimation::Update(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; if (!mAnimation) return -1; diff --git a/gui/console.cpp b/gui/console.cpp index 6f375ff28..b518e77dc 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -78,7 +78,7 @@ extern "C" void __gui_print(const char *color, char *buf) } // The text after last \n (or whole string if there is no \n) - if(*start) { + if (*start) { gConsole.push_back(start); gConsoleColor.push_back(color); } @@ -205,7 +205,10 @@ GUIConsole::GUIConsole(xml_node<>* node) : GUIScrollList(node) if (!node) { - mRenderX = 0; mRenderY = 0; mRenderW = gr_fb_width(); mRenderH = gr_fb_height(); + mRenderX = 0; + mRenderY = 0; + mRenderW = gr_fb_width(); + mRenderH = gr_fb_height(); } else { @@ -276,7 +279,7 @@ int GUIConsole::RenderConsole(void) int GUIConsole::Render(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; if (mSlideout && mSlideoutState == hidden) @@ -346,7 +349,7 @@ int GUIConsole::IsInRegion(int x, int y) // Return 0 on success, >0 to ignore remainder of touch, and <0 on error int GUIConsole::NotifyTouch(TOUCH_STATE state, int x, int y) { - if(!isConditionTrue()) + if (!isConditionTrue()) return -1; if (mSlideout && x >= mSlideoutX && x < mSlideoutX + mSlideoutW && y >= mSlideoutY && y < mSlideoutY + mSlideoutH) { diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp index 9275d976d..fa4ed8209 100644 --- a/gui/fileselector.cpp +++ b/gui/fileselector.cpp @@ -127,7 +127,7 @@ GUIFileSelector::~GUIFileSelector() int GUIFileSelector::Update(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; GUIScrollList::Update(); @@ -155,7 +155,7 @@ int GUIFileSelector::NotifyVarChange(const std::string& varName, const std::stri { GUIScrollList::NotifyVarChange(varName, value); - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; if (varName.empty()) { diff --git a/gui/fill.cpp b/gui/fill.cpp index d0a1cfda7..0fda4b430 100644 --- a/gui/fill.cpp +++ b/gui/fill.cpp @@ -42,7 +42,7 @@ GUIFill::GUIFill(xml_node<>* node) : GUIObject(node) int GUIFill::Render(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha); diff --git a/gui/gui.cpp b/gui/gui.cpp index df41939fb..17ed108fc 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -300,15 +300,15 @@ void InputHandler::process_EV_KEY(input_event& ev) // Handle key-press here LOGEVENT("TOUCH_KEY: %d\n", ev.code); // Left mouse button is treated as a touch - if(ev.code == BTN_LEFT) + if (ev.code == BTN_LEFT) { MouseCursor *cursor = PageManager::GetMouseCursor(); - if(ev.value == 1) + if (ev.value == 1) { cursor->GetPos(x, y); doTouchStart(); } - else if(touch_status) + else if (touch_status) { // Left mouse button was previously pressed and now is // being released so send a TOUCH_RELEASE @@ -323,9 +323,9 @@ void InputHandler::process_EV_KEY(input_event& ev) } } // side mouse button, often used for "back" function - else if(ev.code == BTN_SIDE) + else if (ev.code == BTN_SIDE) { - if(ev.value == 1) + if (ev.value == 1) kb->KeyDown(KEY_BACK); else kb->KeyUp(KEY_BACK); @@ -366,12 +366,12 @@ void InputHandler::process_EV_REL(input_event& ev) // Mouse movement MouseCursor *cursor = PageManager::GetMouseCursor(); LOGEVENT("EV_REL %d %d\n", ev.code, ev.value); - if(ev.code == REL_X) + if (ev.code == REL_X) cursor->Move(ev.value, 0); - else if(ev.code == REL_Y) + else if (ev.code == REL_Y) cursor->Move(0, ev.value); - if(touch_status) { + if (touch_status) { cursor->GetPos(x, y); LOGEVENT("Mouse TOUCH_DRAG: %d, %d\n", x, y); key_status = KS_NONE; diff --git a/gui/input.cpp b/gui/input.cpp index ec370abe5..8dd981c24 100644 --- a/gui/input.cpp +++ b/gui/input.cpp @@ -236,7 +236,7 @@ void GUIInput::HandleCursorByTouch(int x) { unsigned index = 0, displaySize = displayValue.size(); int prevX = mRenderX + scrollingX; - for(index = 0; index <= displaySize; index++) { + for (index = 0; index <= displaySize; index++) { cursorString = displayValue.substr(0, index); cursorX = gr_ttf_measureEx(cursorString.c_str(), fontResource) + mRenderX + scrollingX; if (cursorX > x) { @@ -263,7 +263,7 @@ void GUIInput::HandleCursorByTouch(int x) { } void GUIInput::HandleCursorByText() { -// Uses mCursorLocation to find cursorX +// Uses mCursorLocation to find cursorX if (!DrawCursor) return; diff --git a/gui/listbox.cpp b/gui/listbox.cpp index e10fee72a..05276e8ac 100644 --- a/gui/listbox.cpp +++ b/gui/listbox.cpp @@ -123,7 +123,7 @@ GUIListBox::~GUIListBox() int GUIListBox::Update(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; GUIScrollList::Update(); @@ -140,7 +140,7 @@ int GUIListBox::NotifyVarChange(const std::string& varName, const std::string& v { GUIScrollList::NotifyVarChange(varName, value); - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; // Check to see if the variable that we are using to store the list selected value has been updated diff --git a/gui/mousecursor.cpp b/gui/mousecursor.cpp index bd730df6b..cb5e11b75 100644 --- a/gui/mousecursor.cpp +++ b/gui/mousecursor.cpp @@ -52,15 +52,15 @@ void MouseCursor::LoadData(xml_node<>* node) xml_node<>* child; child = FindNode(node, "placement"); - if(child) + if (child) LoadPlacement(child, &mRenderX, &mRenderY, &mRenderW, &mRenderH); child = FindNode(node, "background"); - if(child) + if (child) { m_color = LoadAttrColor(child, "color", m_color); m_image = LoadAttrImage(child, "resource"); - if(m_image) + if (m_image) { mRenderW = m_image->GetWidth(); mRenderH = m_image->GetHeight(); @@ -68,20 +68,20 @@ void MouseCursor::LoadData(xml_node<>* node) } child = FindNode(node, "speed"); - if(child) + if (child) { attr = child->first_attribute("multiplier"); - if(attr) + if (attr) m_speedMultiplier = atof(attr->value()); } } int MouseCursor::Render(void) { - if(!m_present) + if (!m_present) return 0; - if(m_image) + if (m_image) { gr_blit(m_image->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY); } @@ -95,15 +95,15 @@ int MouseCursor::Render(void) int MouseCursor::Update(void) { - if(m_present != ev_has_mouse()) + if (m_present != ev_has_mouse()) { m_present = ev_has_mouse(); - if(m_present) + if (m_present) SetRenderPos(m_resX/2, m_resY/2); return 2; } - if(m_present && m_moved) + if (m_present && m_moved) { m_moved = false; return 2; @@ -113,7 +113,7 @@ int MouseCursor::Update(void) int MouseCursor::SetRenderPos(int x, int y, int w, int h) { - if(x == mRenderX && y == mRenderY) + if (x == mRenderX && y == mRenderY) m_moved = true; return RenderObject::SetRenderPos(x, y, w, h); @@ -121,7 +121,7 @@ int MouseCursor::SetRenderPos(int x, int y, int w, int h) void MouseCursor::Move(int deltaX, int deltaY) { - if(deltaX != 0) + if (deltaX != 0) { mRenderX += deltaX*m_speedMultiplier; mRenderX = (std::min)(mRenderX, m_resX); @@ -130,7 +130,7 @@ void MouseCursor::Move(int deltaX, int deltaY) m_moved = true; } - if(deltaY != 0) + if (deltaY != 0) { mRenderY += deltaY*m_speedMultiplier; mRenderY = (std::min)(mRenderY, m_resY); diff --git a/gui/object.cpp b/gui/object.cpp index e7d1bf99b..be831a778 100644 --- a/gui/object.cpp +++ b/gui/object.cpp @@ -159,7 +159,7 @@ bool GUIObject::UpdateConditions(std::vector<Condition>& conditions, const std:: std::vector<Condition>::iterator iter; for (iter = conditions.begin(); iter != conditions.end(); ++iter) { - if(varNameEmpty && iter->mCompareOp == "modified") + if (varNameEmpty && iter->mCompareOp == "modified") { string val; @@ -172,10 +172,10 @@ bool GUIObject::UpdateConditions(std::vector<Condition>& conditions, const std:: iter->mLastVal = val; } - if(varNameEmpty || iter->mVar1 == varName || iter->mVar2 == varName) + if (varNameEmpty || iter->mVar1 == varName || iter->mVar2 == varName) iter->mLastResult = isConditionTrue(&(*iter)); - if(!iter->mLastResult) + if (!iter->mLastResult) result = false; } return result; diff --git a/gui/objects.hpp b/gui/objects.hpp index 750627729..f1c9c49dd 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -1234,8 +1234,6 @@ COLOR LoadAttrColor(xml_node<>* element, const char* attrname, COLOR defaultvalu FontResource* LoadAttrFont(xml_node<>* element, const char* attrname); ImageResource* LoadAttrImage(xml_node<>* element, const char* attrname); AnimationResource* LoadAttrAnimation(xml_node<>* element, const char* attrname); - bool LoadPlacement(xml_node<>* node, int* x, int* y, int* w = NULL, int* h = NULL, Placement* placement = NULL); #endif // _OBJECTS_HEADER - diff --git a/gui/pages.cpp b/gui/pages.cpp index d7cb92d63..5c647c334 100644 --- a/gui/pages.cpp +++ b/gui/pages.cpp @@ -1009,7 +1009,7 @@ int PageSet::LoadVariables(xml_node<>* vars) name = child->first_attribute("name"); value = child->first_attribute("value"); persist = child->first_attribute("persist"); - if(name && value) + if (name && value) { if (strcmp(name->value(), "tw_x_offset") == 0) { tw_x_offset = atoi(value->value()); @@ -1193,7 +1193,7 @@ char* PageManager::LoadFileToBuffer(std::string filename, ZipArchive* package) { // We can try to load the XML directly... LOGINFO("PageManager::LoadFileToBuffer loading filename: '%s' directly\n", filename.c_str()); struct stat st; - if(stat(filename.c_str(),&st) != 0) { + if (stat(filename.c_str(),&st) != 0) { // This isn't always an error, sometimes we request files that don't exist. return NULL; } @@ -1471,7 +1471,7 @@ int PageManager::ReloadPackage(std::string name, std::string package) if (iter == mPageSets.end()) return -1; - if(mMouseCursor) + if (mMouseCursor) mMouseCursor->ResetData(gr_fb_width(), gr_fb_height()); PageSet* set = (*iter).second; @@ -1589,18 +1589,18 @@ int PageManager::IsCurrentPage(Page* page) int PageManager::Render(void) { - if(blankTimer.isScreenOff()) + if (blankTimer.isScreenOff()) return 0; int res = (mCurrentSet ? mCurrentSet->Render() : -1); - if(mMouseCursor) + if (mMouseCursor) mMouseCursor->Render(); return res; } HardwareKeyboard *PageManager::GetHardwareKeyboard() { - if(!mHardwareKeyboard) + if (!mHardwareKeyboard) mHardwareKeyboard = new HardwareKeyboard(); return mHardwareKeyboard; } @@ -1630,14 +1630,14 @@ xml_node<>* PageManager::FindStyle(std::string name) MouseCursor *PageManager::GetMouseCursor() { - if(!mMouseCursor) + if (!mMouseCursor) mMouseCursor = new MouseCursor(gr_fb_width(), gr_fb_height()); return mMouseCursor; } void PageManager::LoadCursorData(xml_node<>* node) { - if(!mMouseCursor) + if (!mMouseCursor) mMouseCursor = new MouseCursor(gr_fb_width(), gr_fb_height()); mMouseCursor->LoadData(node); @@ -1645,7 +1645,7 @@ void PageManager::LoadCursorData(xml_node<>* node) int PageManager::Update(void) { - if(blankTimer.isScreenOff()) + if (blankTimer.isScreenOff()) return 0; if (RunReload()) @@ -1653,10 +1653,10 @@ int PageManager::Update(void) int res = (mCurrentSet ? mCurrentSet->Update() : -1); - if(mMouseCursor) + if (mMouseCursor) { int c_res = mMouseCursor->Update(); - if(c_res > res) + if (c_res > res) res = c_res; } return res; diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp index ff207fa9a..dca390448 100644 --- a/gui/partitionlist.cpp +++ b/gui/partitionlist.cpp @@ -79,7 +79,7 @@ GUIPartitionList::~GUIPartitionList() int GUIPartitionList::Update(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; // Check for changes in mount points if the list type is mount and update the list and render if needed @@ -101,8 +101,8 @@ int GUIPartitionList::Update(void) if (updateList) { int listSize = 0; - // Completely update the list if needed -- Used primarily for - // restore as the list for restore will change depending on what + // Completely update the list if needed -- Used primarily for + // restore as the list for restore will change depending on what // partitions were backed up mList.clear(); PartitionManager.Get_Partition_List(ListType, &mList); @@ -126,7 +126,7 @@ int GUIPartitionList::NotifyVarChange(const std::string& varName, const std::str { GUIScrollList::NotifyVarChange(varName, value); - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; if (varName == mVariable && !mUpdate) 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(); } diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp index fc2a4976c..c40e63ea2 100644 --- a/gui/progressbar.cpp +++ b/gui/progressbar.cpp @@ -67,7 +67,7 @@ GUIProgressBar::GUIProgressBar(xml_node<>* node) : GUIObject(node) int GUIProgressBar::Render(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; // This handles making sure timing updates occur @@ -90,7 +90,7 @@ int GUIProgressBar::RenderInternal(void) int GUIProgressBar::Update(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; std::string str; @@ -165,7 +165,7 @@ int GUIProgressBar::NotifyVarChange(const std::string& varName, const std::strin { GUIObject::NotifyVarChange(varName, value); - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; static int nextPush = 0; diff --git a/gui/resources.cpp b/gui/resources.cpp index 8884dd796..000912d4e 100644 --- a/gui/resources.cpp +++ b/gui/resources.cpp @@ -124,7 +124,7 @@ void FontResource::LoadFont(xml_node<>* node, ZipArchive* pZip) file = attr->value(); - if(file.size() >= 4 && file.compare(file.size()-4, 4, ".ttf") == 0) + if (file.size() >= 4 && file.compare(file.size()-4, 4, ".ttf") == 0) { int font_size = 0; @@ -144,7 +144,7 @@ void FontResource::LoadFont(xml_node<>* node, ZipArchive* pZip) int dpi = 300; attr = node->first_attribute("dpi"); - if(attr) + if (attr) dpi = atoi(attr->value()); // we can't use TMP_RESOURCE_NAME here because the ttf subsystem is caching the name and scaling needs to reload the font @@ -166,10 +166,10 @@ void FontResource::LoadFont(xml_node<>* node, ZipArchive* pZip) } void FontResource::DeleteFont() { - if(mFont) + if (mFont) gr_ttf_freeFont(mFont); mFont = NULL; - if(origFont) + if (origFont) gr_ttf_freeFont(origFont); origFont = NULL; } diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp index 291b3820b..7540356bf 100644 --- a/gui/scrolllist.cpp +++ b/gui/scrolllist.cpp @@ -190,7 +190,7 @@ void GUIScrollList::SetVisibleListLocation(size_t list_index) int GUIScrollList::Render(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; // First step, fill background @@ -352,7 +352,7 @@ void GUIScrollList::RenderStdItem(int yPos, bool selected, ImageResource* icon, int GUIScrollList::Update(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; if (!mHeaderIsStatic) { @@ -421,7 +421,7 @@ size_t GUIScrollList::HitTestItem(int x __unused, int y) int GUIScrollList::NotifyTouch(TOUCH_STATE state, int x, int y) { - if(!isConditionTrue()) + if (!isConditionTrue()) return -1; switch (state) @@ -524,7 +524,7 @@ void GUIScrollList::HandleScrolling() { // handle dragging downward, scrolling upward // the offset should always be <= 0 and > -actualItemHeight, adjust the first display row and offset as needed - while(firstDisplayedItem && y_offset > 0) { + while (firstDisplayedItem && y_offset > 0) { firstDisplayedItem--; y_offset -= actualItemHeight; } @@ -569,7 +569,7 @@ int GUIScrollList::NotifyVarChange(const std::string& varName, const std::string { GUIObject::NotifyVarChange(varName, value); - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; if (!mHeaderIsStatic) { @@ -624,7 +624,7 @@ bool GUIScrollList::AddLines(std::vector<std::string>* origText, std::vector<std string curr_color; if (origColor) curr_color = origColor->at(i); - for(;;) { + for (;;) { size_t line_char_width = gr_ttf_maxExW(curr_line.c_str(), mFont->GetResource(), mRenderW); if (line_char_width < curr_line.size()) { //string left = curr_line.substr(0, line_char_width); diff --git a/gui/slider.cpp b/gui/slider.cpp index 59b295bd0..1a2f59e68 100644 --- a/gui/slider.cpp +++ b/gui/slider.cpp @@ -108,7 +108,7 @@ GUISlider::~GUISlider() int GUISlider::Render(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; if (!sSlider || !sSlider->GetResource()) @@ -136,7 +136,7 @@ int GUISlider::Render(void) int GUISlider::Update(void) { - if(!isConditionTrue()) + if (!isConditionTrue()) return 0; if (sUpdate) @@ -146,7 +146,7 @@ int GUISlider::Update(void) int GUISlider::NotifyTouch(TOUCH_STATE state, int x, int y) { - if(!isConditionTrue()) + if (!isConditionTrue()) return -1; static bool dragging = false; diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp index 088620a21..b53797b25 100644 --- a/gui/slidervalue.cpp +++ b/gui/slidervalue.cpp @@ -62,7 +62,7 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) } mLabel = new GUIText(node); - if(mLabel->Render() < 0) + if (mLabel->Render() < 0) { delete mLabel; mLabel = NULL; @@ -156,7 +156,7 @@ GUISliderValue::GUISliderValue(xml_node<>* node) : GUIObject(node) mFontHeight = mFont->GetHeight(); - if(mShowCurr) + if (mShowCurr) { int maxLen = std::max(strlen(mMinStr.c_str()), strlen(mMaxStr.c_str())); mValueStr = new char[maxLen+1]; @@ -182,10 +182,10 @@ GUISliderValue::~GUISliderValue() void GUISliderValue::loadValue(bool force) { - if(!mVariable.empty()) + if (!mVariable.empty()) { int value = DataManager::GetIntValue(mVariable); - if(mValue == value && !force) + if (mValue == value && !force) return; mValue = value; @@ -208,7 +208,7 @@ int GUISliderValue::SetRenderPos(int x, int y, int w, int h) } mRenderH = mSliderH; - if(mShowCurr) + if (mShowCurr) mRenderH += mFontHeight; if (mLabel) @@ -230,7 +230,7 @@ int GUISliderValue::SetRenderPos(int x, int y, int w, int h) mActionW = mRenderW; mActionH = mRenderH; - if(mBackgroundImage && mBackgroundImage->GetResource()) + if (mBackgroundImage && mBackgroundImage->GetResource()) { mLineW = mBackgroundImage->GetWidth(); mLineH = mBackgroundImage->GetHeight(); @@ -260,7 +260,7 @@ int GUISliderValue::Render(void) return 0; } - if(mLabel) + if (mLabel) { int w, h; mLabel->GetCurrentBounds(w, h); @@ -270,12 +270,12 @@ int GUISliderValue::Render(void) mLabel->SetRenderPos(textX, mRenderY); } int res = mLabel->Render(); - if(res < 0) + if (res < 0) return res; } // line - if(mBackgroundImage && mBackgroundImage->GetResource()) + if (mBackgroundImage && mBackgroundImage->GetResource()) { gr_blit(mBackgroundImage->GetResource(), 0, 0, mLineW, mLineH, mLineX, mLineY); } @@ -288,10 +288,10 @@ int GUISliderValue::Render(void) // slider uint32_t sliderX = mLineX + (mValuePct*(mLineW - mSliderW))/100; - if(mHandleImage && mHandleImage->GetResource()) + if (mHandleImage && mHandleImage->GetResource()) { gr_surface s = mHandleImage->GetResource(); - if(mDragging && mHandleHoverImage && mHandleHoverImage->GetResource()) + if (mDragging && mHandleHoverImage && mHandleHoverImage->GetResource()) s = mHandleHoverImage->GetResource(); gr_blit(s, 0, 0, mSliderW, mSliderH, sliderX, mLineY + (mLineH/2 - mSliderH/2)); } @@ -302,16 +302,16 @@ int GUISliderValue::Render(void) } void *fontResource = NULL; - if(mFont) fontResource = mFont->GetResource(); + if (mFont) fontResource = mFont->GetResource(); gr_color(mTextColor.red, mTextColor.green, mTextColor.blue, mTextColor.alpha); - if(mShowRange) + if (mShowRange) { int rangeY = (mLineY - mLineH/2) - mFontHeight/2; gr_textEx_scaleW(mRenderX + mPadding/2, rangeY, mMinStr.c_str(), fontResource, mRenderW, TOP_LEFT, 0); gr_textEx_scaleW(mLineX + mLineW + mPadding/2, rangeY, mMaxStr.c_str(), fontResource, mRenderW, TOP_LEFT, 0); } - if(mValueStr && mShowCurr) + if (mValueStr && mShowCurr) { sprintf(mValueStr, "%d", mValue); int textW = measureText(mValueStr); @@ -329,7 +329,7 @@ int GUISliderValue::Update(void) if (!mRendered) return 2; - if(mLabel) + if (mLabel) return mLabel->Update(); return 0; } @@ -406,7 +406,7 @@ int GUISliderValue::NotifyVarChange(const std::string& varName, const std::strin mLabel->NotifyVarChange(varName, value); if (varName == mVariable) { int newVal = atoi(value.c_str()); - if(newVal != mValue) { + if (newVal != mValue) { mValue = newVal; mValuePct = pctFromValue(mValue); mRendered = false; diff --git a/gui/terminal.cpp b/gui/terminal.cpp index b4194d0fb..fe80fb097 100644 --- a/gui/terminal.cpp +++ b/gui/terminal.cpp @@ -500,7 +500,7 @@ private: uint32_t u8state = 0, u8cp = 0; std::string& s = lines[y].text; unpackedLine.cells.clear(); - for(size_t i = 0; i < s.size(); ++i) { + for (size_t i = 0; i < s.size(); ++i) { uint32_t rc = utf8decode(&u8state, &u8cp, (unsigned char)s[i]); if (rc == UTF8_ACCEPT) unpackedLine.cells.push_back(Cell(u8cp)); @@ -776,7 +776,10 @@ GUITerminal::GUITerminal(xml_node<>* node) : GUIScrollList(node) lastCondition = false; if (!node) { - mRenderX = 0; mRenderY = 0; mRenderW = gr_fb_width(); mRenderH = gr_fb_height(); + mRenderX = 0; + mRenderY = 0; + mRenderW = gr_fb_width(); + mRenderH = gr_fb_height(); } engine = &gEngine; @@ -785,7 +788,7 @@ GUITerminal::GUITerminal(xml_node<>* node) : GUIScrollList(node) int GUITerminal::Update(void) { - if(!isConditionTrue()) { + if (!isConditionTrue()) { lastCondition = false; return 0; } @@ -816,7 +819,7 @@ int GUITerminal::Update(void) // Return 0 on success, >0 to ignore remainder of touch, and <0 on error int GUITerminal::NotifyTouch(TOUCH_STATE state, int x, int y) { - if(!isConditionTrue()) + if (!isConditionTrue()) return -1; // TODO: grab focus correctly diff --git a/gui/textbox.cpp b/gui/textbox.cpp index 2e2512c50..2c7d09f99 100644 --- a/gui/textbox.cpp +++ b/gui/textbox.cpp @@ -98,7 +98,7 @@ int GUITextBox::NotifyVarChange(const std::string& varName, const std::string& v { GUIScrollList::NotifyVarChange(varName, value); - if(!isConditionTrue() || mIsStatic) + if (!isConditionTrue() || mIsStatic) return 0; // Check to see if the variable exists in mText diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml index b36b5a615..80e358b77 100644 --- a/gui/theme/common/portrait.xml +++ b/gui/theme/common/portrait.xml @@ -386,9 +386,9 @@ </checkbox> <checkbox> - <placement x="%indent%" y="%row13a_y%" /> + <placement x="%indent%" y="%row13a_y%"/> <text>{@install_reboot_chk=Reboot after installation is complete}</text> - <data variable="tw_install_reboot" /> + <data variable="tw_install_reboot"/> </checkbox> <checkbox> diff --git a/gui/twmsg.cpp b/gui/twmsg.cpp index 57f192234..ebd6fc313 100644 --- a/gui/twmsg.cpp +++ b/gui/twmsg.cpp @@ -33,7 +33,7 @@ class LocalLookup : public StringLookup { const std::vector<std::string>& vars; const StringLookup& next; - public: +public: LocalLookup(const std::vector<std::string>& vars, const StringLookup& next) : vars(vars), next(next) {} virtual std::string operator()(const std::string& name) const { |