bool GUIManager::handleDSActivation ( CEGUI::EventArgs const & e ) { CEGUI::Window *tab = static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent(); CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0)); ListboxItem *item = static_cast<ListboxItem *>(lb->getFirstSelectedItem()); if (item != NULL) { DataManager *dm = static_cast<DataManager *>(item->getUserData()); CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2)); std::vector<unsigned int> const & dims = dm->getDimensions(); unsigned int dim = dims[int(sb->getScrollPosition()*(dims.size()-1))]; float scrollPos = sb->getScrollPosition(); dm->activate(dim); // Enable global scrollbar CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton(); sb = static_cast<CEGUI::Scrollbar *>(wm.getWindow("Sheet/DimensionSlider")); sb->enable(); CEGUI::WindowEventArgs w(sb); sb->fireEvent(CEGUI::Scrollbar::EventScrollPositionChanged, w); // Set the global scrollbar to the right position. sb->setScrollPosition(scrollPos); CEGUI::Window *desc = wm.getWindow("Sheet/DimensionText"); desc->show(); } // TODO handle else-error return true; }
bool GUIManager::handleDSDeactivation ( CEGUI::EventArgs const & e ) { CEGUI::Window *tab = static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent(); CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0)); ListboxItem *item = static_cast<ListboxItem *>(lb->getFirstSelectedItem()); if (item != NULL) { DataManager *dm = static_cast<DataManager *>(item->getUserData()); dm->deactivate(); // Enable global scrollbar CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton(); CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2)); sb = static_cast<CEGUI::Scrollbar *>(wm.getWindow("Sheet/DimensionSlider")); sb->disable(); CEGUI::Window *desc = wm.getWindow("Sheet/DimensionText"); desc->hide(); } // TODO handle else-error return true; }