From ec457e34c3b1b29f6beb3bf643f980992af8ca58 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 6 Jan 2009 16:16:03 +0000 Subject: [PATCH] From Sergey Leontyev, "Some minor(but important) bug fixes for osgWidget: 1. In WindowManager.cpp childRemoved method the second parameter "end" is misleading and should be named "numChildren" instead. It represents how many children to remove. As a result, the method was implemented incorrectly and failed to remove UI objects. So I fixed it. replaced this: void WindowManager::childRemoved(unsigned int start, unsigned int end) { while(start < end) { Window* window = getByIndex(start); if(!window) continue; if(_remove(window)) { window->_index = -1; window->unmanaged(this); } start++; } } with this: void WindowManager::childRemoved(unsigned int start, unsigned int numChildren) { for (unsigned int i = start; i < start+numChildren; i++) { Window* window = getByIndex(i); if(!window) continue; if(_remove(window)) { window->_index = -1; window->unmanaged(this); } } } 2. in Input.cpp The cursor in Input did not get positioned correctly, probably as a left over from the TOP LEFT origin system which is now BOTTOM LEFT. in method positioned() replaced this: _cursor->setOrigin(x + xoffset + 1.0f, y - _cursor->getHeight() + 1.0f); with this: _cursor->setOrigin(x + xoffset + 1.0f, y + 1.0f); Now it is placed correctly. " --- src/osgWidget/Input.cpp | 2 +- src/osgWidget/WindowManager.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/osgWidget/Input.cpp b/src/osgWidget/Input.cpp index 11cdc75cd..ceb62d6c4 100644 --- a/src/osgWidget/Input.cpp +++ b/src/osgWidget/Input.cpp @@ -113,7 +113,7 @@ void Input::positioned() { point_type xoffset = _index > 0 ? _offsets[_index - 1] : 0.0f; - _cursor->setOrigin(x + xoffset + 1.0f, y - _cursor->getHeight() + 1.0f); + _cursor->setOrigin(x + xoffset + 1.0f, y + 1.0f); _cursor->setZ(_calculateZ(LAYER_MIDDLE)); } diff --git a/src/osgWidget/WindowManager.cpp b/src/osgWidget/WindowManager.cpp index 1a3f1db45..334fce210 100644 --- a/src/osgWidget/WindowManager.cpp +++ b/src/osgWidget/WindowManager.cpp @@ -248,9 +248,10 @@ void WindowManager::childInserted(unsigned int i) { _styleManager->applyStyles(window); } -void WindowManager::childRemoved(unsigned int start, unsigned int end) { - while(start < end) { - Window* window = getByIndex(start); +void WindowManager::childRemoved(unsigned int start, unsigned int numChildren) { + for (unsigned int i = start; i < start+numChildren; i++) + { + Window* window = getByIndex(i); if(!window) continue; @@ -259,8 +260,6 @@ void WindowManager::childRemoved(unsigned int start, unsigned int end) { window->unmanaged(this); } - - start++; } }