void Listbox::Layout() { int w, h, y = 0, index = 0; GetClientSize(w, h); w--; std::vector<Control*>::iterator i; /*for (i=childs.begin(); i!=childs.end(); i++) { ListboxItem *child = (ListboxItem*)(*i); if ((int)child->minimumWidth > w) w = child->minimumWidth; }*/ for (i=childs.begin(); i!=childs.end(); i++) { ListboxItem *child = (ListboxItem*)(*i); child->index = index++; child->Place(0, y, w, y + child->itemHeight - 1); y += child->itemHeight; } //if (!active) // active = (ListboxItem*)*(childs.begin()); Scrollbox::Layout(); }
void GameSettings::setOption(const ConfigOptionMap& configuration, const Ogre::String& option, Combobox* combobox) { ConfigOptionMap::const_iterator cfi = configuration.find(option); if (cfi != configuration.end()) { ConfigOption curOption = cfi->second; int delta = curOption.possibleValues.size() - combobox->getItemCount(); if (delta > 0) { for (int i = 0; i < delta; ++i) { combobox->addItem(new ListboxTextItem("")); } } else if (delta < 0) { for (int i = 0; i < -delta; ++i) { ListboxItem* item = combobox->getListboxItemFromIndex(combobox->getItemCount() - 1); combobox->removeItem(item); delete item; } } for (unsigned int i = 0; i < combobox->getItemCount(); ++i) { ListboxItem* item = combobox->getListboxItemFromIndex(i); item->setText(curOption.possibleValues[i]); } } }
/************************************************************************* Set whether the list should allow multiple selections or just a single selection *************************************************************************/ void Listbox::setMultiselectEnabled(bool setting) { // only react if the setting is changed if (d_multiselect != setting) { d_multiselect = setting; // if we change to single-select, deselect all except the first selected item. WindowEventArgs args(this); if ((!d_multiselect) && (getSelectedCount() > 1)) { ListboxItem* itm = getFirstSelectedItem(); while ((itm = getNextSelected(itm))) { itm->setSelected(false); } onSelectionChanged(args); } onMultiselectModeChanged(args); } }
/************************************************************************* Handler for mouse movement *************************************************************************/ void Listbox::onMouseMove(MouseEventArgs& e) { if (d_itemTooltips) { static ListboxItem* lastItem = 0; ListboxItem* item = getItemAtPoint(e.position); if (item != lastItem) { if (item) { setTooltipText(item->getTooltipText()); } else { setTooltipText(""); } lastItem = item; } // must check the result from getTooltip(), as the tooltip object could // be 0 at any time for various reasons. Tooltip* tooltip = getTooltip(); if (tooltip) { if (tooltip->getTargetWindow() != this) tooltip->setTargetWindow(this); else tooltip->positionSelf(); } } Window::onMouseMove(e); }
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; }
/************************************************************************* Handler for selections made in the drop-list *************************************************************************/ bool Combobox::droplist_SelectionAcceptedHandler(const EventArgs& e) { // copy the text from the selected item into the edit box ListboxItem* item = ((ComboDropList*)((WindowEventArgs&)e).window)->getFirstSelectedItem(); if (item != NULL) { // Put the text from the list item into the edit box d_editbox->setText(item->getText()); // select text if it's editable, and move carat to end if (!isReadOnly()) { d_editbox->setSelection(0, item->getText().length()); d_editbox->setCaratIndex(item->getText().length()); } d_editbox->setCaratIndex(0); // fire off an event of our own WindowEventArgs args(this); onListSelectionAccepted(args); // finally, activate the edit box d_editbox->activate(); } return true; }
void FalagardListbox::render() { Listbox* lb = (Listbox*)d_window; // render frame and stuff before we handle the items cacheListboxBaseImagery(); // // Render list items // Vector3 itemPos; Size itemSize; Rect itemClipper, itemRect; float widest = lb->getWidestItemWidth(); // calculate position of area we have to render into Rect itemsArea(getListRenderArea()); // set up some initial positional details for items itemPos.d_x = itemsArea.d_left - lb->getHorzScrollbar()->getScrollPosition(); itemPos.d_y = itemsArea.d_top - lb->getVertScrollbar()->getScrollPosition(); itemPos.d_z = System::getSingleton().getRenderer()->getZLayer(3) - System::getSingleton().getRenderer()->getCurrentZ(); float alpha = lb->getEffectiveAlpha(); // loop through the items size_t itemCount = lb->getItemCount(); for (size_t i = 0; i < itemCount; ++i) { ListboxItem* listItem = lb->getListboxItemFromIndex(i); itemSize.d_height = listItem->getPixelSize().d_height; // allow item to have full width of box if this is wider than items itemSize.d_width = ceguimax(itemsArea.getWidth(), widest); // calculate destination area for this item. itemRect.d_left = itemPos.d_x; itemRect.d_top = itemPos.d_y; itemRect.setSize(itemSize); itemClipper = itemRect.getIntersection(itemsArea); // skip this item if totally clipped if (itemClipper.getWidth() == 0) { itemPos.d_y += itemSize.d_height; continue; } // draw this item listItem->draw(lb->getRenderCache(), itemRect, itemPos.d_z, alpha, &itemClipper); // update position ready for next item itemPos.d_y += itemSize.d_height; } }
/************************************************************************* Handler for when mouse button is pressed *************************************************************************/ void Listbox::onMouseButtonDown(MouseEventArgs& e) { // base class processing Window::onMouseButtonDown(e); if (e.button == LeftButton) { bool modified = false; // clear old selections if no control key is pressed or if multi-select is off if (!(e.sysKeys & Control) || !d_multiselect) { modified = clearAllSelections_impl(); } Point localPos(screenToWindow(e.position)); if (getMetricsMode() == Relative) { localPos = relativeToAbsolute(localPos); } ListboxItem* item = getItemAtPoint(localPos); if (item != NULL) { modified = true; // select range or item, depending upon keys and last selected item if (((e.sysKeys & Shift) && (d_lastSelected != NULL)) && d_multiselect) { selectRange(getItemIndex(item), getItemIndex(d_lastSelected)); } else { item->setSelected(item->isSelected() ^ true); } // update last selected item d_lastSelected = item->isSelected() ? item : NULL; } // fire event if needed if (modified) { WindowEventArgs args(this); onSelectionChanged(args); } e.handled = true; } }
bool BookmarkSelect(const CEGUI::EventArgs& event) { using namespace CEGUI; dbg(0,"1\n"); MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Bookmarks/Listbox")); dbg(0,"2\n"); ListboxItem * item = mcl->getFirstSelectedItem(); if(item){ dbg(0,"item %s is at row %i\n",item->getText().c_str(),mcl->getItemRowIndex(item)); BookmarkGo(item->getText().c_str()); } WindowManager::getSingleton().getWindow("BookmarkSelection")->hide(); }
/************************************************************************* Set the select state of an attached ListboxItem. *************************************************************************/ void Combobox::setItemSelectState(size_t item_index, bool state) { ComboDropList* droplist = getDropList(); ListboxItem* item = (droplist->getItemCount() > item_index) ? droplist->getListboxItemFromIndex(item_index) : 0; bool was_selected = (item && item->isSelected()); droplist->setItemSelectState(item_index, state); itemSelectChangeTextUpdate(item, state, was_selected); }
void GameSettings::update() { Root* root = Ogre::Root::getSingletonPtr(); Ogre::RenderSystem* renderer = root->getRenderSystem(); #if OGRE_VERSION_MINOR == 7 || OGRE_VERSION_MINOR == 8 const RenderSystemList& renderers = root->getAvailableRenderers(); #else const RenderSystemList renderers = *root->getAvailableRenderers(); #endif createElements(mVideoRenderer, renderers.size()); for (unsigned int i = 0; i < renderers.size(); ++i) { Ogre::RenderSystem* cur = renderers[i]; ListboxItem* item = mVideoRenderer->getListboxItemFromIndex(i); item->setText(cur->getName()); if (cur == renderer) { mVideoRenderer->setItemSelectState(item, true); } } ConfigOptionMap config = renderer->getConfigOptions(); setOption(config, "Full Screen", mVideoFullscreen); std::vector<RadioButton*> videoColorDepth; videoColorDepth.push_back(mVideoColorDepth32); videoColorDepth.push_back(mVideoColorDepth16); setOption(config, "Colour Depth", videoColorDepth); std::vector<RadioButton*> videoAntiAliasing; videoAntiAliasing.push_back(mVideoFsaa0); videoAntiAliasing.push_back(mVideoFsaa2); videoAntiAliasing.push_back(mVideoFsaa4); videoAntiAliasing.push_back(mVideoFsaa8); setOption(config, "FSAA", videoAntiAliasing); std::vector<RadioButton*> videoRttMode; videoRttMode.push_back(mVideoRttModeFBO); videoRttMode.push_back(mVideoRttModePBuffer); videoRttMode.push_back(mVideoRttModeCopy); setOption(config, "RTT Preferred Mode", videoRttMode); setOption(config, "Video Mode", mVideoResolution); }
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; }
void GUIManager::populateDatalists ( std::vector<DataManager *> const & list ) { CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton(); auto populate = [&]( std::string const & name, DataManagerType const & type ) { CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(wm.getWindow( "Sheet/DatasetFrame/TabControl/"+name+"/Listbox")); unsigned int i = 0; for (DataManager *p : list) { if (p != NULL && p->type == type) { ListboxItem *item = new ListboxItem(p->name, i); item->setUserData(p); lb->addItem(item); } i++; } }; populate("HTab", DM_Height); populate("PTab", DM_Pattern); populate("CTab", DM_Color); }
bool handleItemSelect(int r) { using namespace CEGUI; MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("AdressSearch/Listbox")); ListboxItem * item = mcl->getItemAtGridReference(MCLGridRef(r,0)); ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1)); ListboxItem * item_assoc = mcl->getItemAtGridReference(MCLGridRef(r,2)); Window* country_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/CountryEditbox")); Window* twn_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/TownEditbox")); Window* street_edit = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/StreetEditbox")); if(SDL_dest.current_search==SRCH_COUNTRY){ country_edit->setText(item->getText()); twn_edit->activate(); SDL_dest.current_search=SRCH_TOWN; WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText(""); } else if(SDL_dest.current_search==SRCH_TOWN){ twn_edit->setText(item->getText()); ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); Window* Dest_x = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_x")); Dest_x->setText(itemx->getText().c_str()); Window* Dest_y = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_y")); Dest_y->setText(itemy->getText().c_str()); mcl->resetList(); SDL_dest.current_search=SRCH_STREET; street_edit->activate(); WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText(""); } else if(SDL_dest.current_search==SRCH_STREET){ street_edit->setText(item->getText()); WindowManager::getSingleton().getWindow("Navit/Keyboard")->hide(); ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); Window* Dest_x = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_x")); Dest_x->setText(itemx->getText().c_str()); Window* Dest_y = static_cast<Window*>(WindowManager::getSingleton().getWindow("AdressSearch/Dest_y")); Dest_y->setText(itemy->getText().c_str()); mcl->resetList(); SDL_dest.current_search=SRCH_STREET; WindowManager::getSingleton().getWindow("Navit/Keyboard/Input")->setText(""); } else if (SDL_dest.current_search==SRCH_NUMBER){ struct coord pos; ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); pos.x=atoi(itemx->getText().c_str()); pos.y=atoi(itemy->getText().c_str()); route_to(pos.x,pos.y); } return true; }
bool Demo6Sample::handleSelectModeChanged(const CEGUI::EventArgs& e) { using namespace CEGUI; // get access to list MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Demo6/MainList")); // get access to the combobox Combobox* combo = static_cast<Combobox*>(WindowManager::getSingleton().getWindow("Demo6/ControlPanel/SelModeBox")); // find the selected item in the combobox ListboxItem* item = combo->findItemWithText(combo->getText(), 0); // set new selection mode according to ID of selected ListboxItem if (item) { switch (item->getID()) { case 0: mcl->setSelectionMode(MultiColumnList::RowSingle); break; case 1: mcl->setSelectionMode(MultiColumnList::RowMultiple); break; case 2: mcl->setSelectionMode(MultiColumnList::ColumnSingle); break; case 3: mcl->setSelectionMode(MultiColumnList::ColumnMultiple); break; case 4: mcl->setSelectionMode(MultiColumnList::CellSingle); break; case 5: mcl->setSelectionMode(MultiColumnList::CellMultiple); break; case 6: mcl->setSelectionMode(MultiColumnList::NominatedColumnSingle); break; case 7: mcl->setSelectionMode(MultiColumnList::NominatedColumnMultiple); break; case 8: mcl->setSelectionMode(MultiColumnList::NominatedRowSingle); break; case 9: mcl->setSelectionMode(MultiColumnList::NominatedRowMultiple); break; default: mcl->setSelectionMode(MultiColumnList::RowSingle); break; } } // event was handled. return true; }
bool handleItemSelect(int r) { using namespace CEGUI; extern CEGUI::Window* myRoot; MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("DestinationWindow/Listbox")); ListboxItem * item = mcl->getItemAtGridReference(MCLGridRef(r,0)); ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1)); ListboxItem * item_assoc = mcl->getItemAtGridReference(MCLGridRef(r,2)); Window* country_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/CountryEditbox")); Window* twn_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/TownEditbox")); Window* street_edit = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/StreetEditbox")); if(SDL_dest.current_search==SRCH_COUNTRY){ country_edit->setText(item->getText()); // Need to record the country here twn_edit->activate(); SDL_dest.current_search=SRCH_TOWN; myRoot->getChild("Navit/Keyboard")->getChild("Navit/Keyboard/Input")->setText(""); } else if(SDL_dest.current_search==SRCH_TOWN){ twn_edit->setText(item->getText()); // SDL_dest.town_street_assoc=atoi(item_assoc->getText().c_str()); // SDL_dest.town=atoi(itemid->getText().c_str()); // printf(" town %s , id=%lx, assoc=%li\n",item->getText().c_str(),SDL_dest.town_street_assoc,SDL_dest.town_street_assoc); ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); Window* Dest_x = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_x")); Dest_x->setText(itemx->getText().c_str()); Window* Dest_y = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_y")); Dest_y->setText(itemy->getText().c_str()); mcl->resetList(); SDL_dest.current_search=SRCH_STREET; street_edit->activate(); myRoot->getChild("Navit/Keyboard")->getChild("Navit/Keyboard/Input")->setText(""); } else if(SDL_dest.current_search==SRCH_STREET){ street_edit->setText(item->getText()); myRoot->getChild("Navit/Keyboard")->hide(); ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); Window* Dest_x = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_x")); Dest_x->setText(itemx->getText().c_str()); Window* Dest_y = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_y")); Dest_y->setText(itemy->getText().c_str()); mcl->resetList(); SDL_dest.current_search=SRCH_STREET; myRoot->getChild("Navit/Keyboard")->getChild("Navit/Keyboard/Input")->setText(""); /* ListboxItem * itemid = mcl->getItemAtGridReference(MCLGridRef(r,1)); int segment_id=atoi(itemid->getText().c_str()); printf("street seg id : %li\n",segment_id); extern struct container *co; struct block_info res_blk_inf; struct street_str *res_str; street_get_by_id(co->map_data, 33, segment_id,&res_blk_inf,&res_str ); struct street_coord * streetcoord; streetcoord=street_coord_get(&res_blk_inf,res_str); printf("Street coordinates : %i,%i\n",streetcoord->c->x,streetcoord->c->y); char xbuff [256]; sprintf(xbuff,"%li",streetcoord->c->x); char ybuff [256]; sprintf(ybuff,"%li",streetcoord->c->y); Window* Dest_x = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_x")); Dest_x->setText(xbuff); Window* Dest_y = static_cast<Window*>(myRoot->getChild("DestinationWindow")->getChild("DestinationWindow/Dest_y")); Dest_y->setText(ybuff); struct street_name name; // printf("street_name_get_by_id returns : %i\n",street_name_get_by_id(&name, res_blk_inf.mdata, res_str->nameid)); street_name_get_by_id(&name, res_blk_inf.mdata, res_str->nameid); // printf("name1:%s / name2%s\n",name.name1,name.name2); struct street_name_number_info num; struct street_name_info inf; SDL_dest.current_search=SRCH_NUMBER; mcl->resetList(); while (street_name_get_info(&inf, &name)) { while(street_name_get_number_info(&num,&inf)){ // printf(" House Number : %i -> %i\n",num.first,num.last); for(int i=num.first;i<=num.last;i+=2){ add_number_to_list(i,num.c->x,num.c->y); } } } */ // route_to(streetcoord->c->x,streetcoord->c->y); } else if (SDL_dest.current_search==SRCH_NUMBER){ struct coord pos; ListboxItem * itemx = mcl->getItemAtGridReference(MCLGridRef(r,3)); ListboxItem * itemy = mcl->getItemAtGridReference(MCLGridRef(r,4)); pos.x=atoi(itemx->getText().c_str()); pos.y=atoi(itemy->getText().c_str()); route_to(pos.x,pos.y); } return true; }
bool ListboxNumberItem::operator > ( const ListboxItem& rhs ) const { return atoi ( d_itemText.c_str () ) > atoi ( rhs.getText ().c_str () ); }
void FalagardMultiColumnList::render() { MultiColumnList* w = (MultiColumnList*)d_window; const ListHeader* header = w->getListHeader(); const Scrollbar* vertScrollbar = w->getVertScrollbar(); const Scrollbar* horzScrollbar = w->getHorzScrollbar(); // render general stuff before we handle the items cacheListboxBaseImagery(); // // Render list items // Vector3f itemPos; Sizef itemSize; Rectf itemClipper, itemRect; // calculate position of area we have to render into Rectf itemsArea(getListRenderArea()); // set up initial positional details for items itemPos.d_y = itemsArea.top() - vertScrollbar->getScrollPosition(); itemPos.d_z = 0.0f; const float alpha = w->getEffectiveAlpha(); // loop through the items for (uint i = 0; i < w->getRowCount(); ++i) { // set initial x position for this row. itemPos.d_x = itemsArea.left() - horzScrollbar->getScrollPosition(); // calculate height for this row. itemSize.d_height = w->getHighestRowItemHeight(i); // loop through the columns in this row for (uint j = 0; j < w->getColumnCount(); ++j) { // allow item to use full width of the column itemSize.d_width = CoordConverter::asAbsolute(header->getColumnWidth(j), header->getPixelSize().d_width); ListboxItem* item = w->getItemAtGridReference(MCLGridRef(i,j)); // is the item for this column set? if (item) { // calculate destination area for this item. itemRect.left(itemPos.d_x); itemRect.top(itemPos.d_y); itemRect.setSize(itemSize); itemClipper = itemRect.getIntersection(itemsArea); // skip this item if totally clipped if (itemClipper.getWidth() == 0) { itemPos.d_x += itemSize.d_width; continue; } // draw this item item->draw(w->getGeometryBuffer(), itemRect, alpha, &itemClipper); } // update position for next column. itemPos.d_x += itemSize.d_width; } // update position ready for next row itemPos.d_y += itemSize.d_height; } }
vis_settings_panel_impl::vis_settings_panel_impl( const app::zones_t &zones, const app::settings_t& s ) { GUIContext& context = System::getSingleton().getDefaultGUIContext(); CEGUI::Window* root = context.getRootWindow(); WindowManager& winMgr = WindowManager::getSingleton(); FrameWindow* mainWindow = static_cast<FrameWindow*>( CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", "MainWindow") ); mainWindow->setPosition(UVector2(cegui_reldim(0.01f), cegui_reldim(0.5f))); //demoWindow->setSize(USize(cegui_reldim(0.3f), cegui_reldim(0.3f))); mainWindow->setMinSize(USize(cegui_reldim(0.1f), cegui_reldim(0.1f))); mainWindow->setText( "Choose Zone" ); auto fn_exit = [=](const CEGUI::EventArgs& args)->bool { CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext(); CEGUI::Window* root = context.getRootWindow(); root->getChild("MainWindow")->setVisible(false); return true; }; mainWindow->subscribeEvent( CEGUI::FrameWindow::EventCloseClicked,Event::Subscriber(fn_exit)); #if 0 PushButton* btnExit = static_cast<PushButton*>( WindowManager::getSingleton().createWindow("TaharezLook/Button", btn_exit_name) ); root->addChild(btnExit); btnExit->setPosition(UVector2(cegui_reldim(0.95f), cegui_reldim(0.95f))); btnExit->setSize( USize(cegui_reldim(0.04f), cegui_reldim(0.02f)) ); btnExit->setText( "Exit" ); btnExit->subscribeEvent(PushButton::EventClicked, Event::Subscriber([=](const CEGUI::EventArgs& args)->bool { exit_app_signal_(); return true; }) ); #endif Combobox* cbbo = static_cast<Combobox*>( CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Combobox", combo_name)); cbbo->setPosition(UVector2(cegui_reldim(0.15f), cegui_reldim( 0.1f))); //cbbo->setSize(USize(cegui_reldim(0.66f), cegui_reldim( 0.33f))); mainWindow->addChild(cbbo); root->addChild( mainWindow ); mainWindow->setVisible(false); ListboxTextItem* itm; CEGUI::Win32StringTranscoder stc; const CEGUI::Image* sel_img = &ImageManager::getSingleton().get("TaharezLook/MultiListSelectionBrush"); for (auto it = zones.begin(); it!=zones.end();++it) { itm = new ListboxTextItem(stc.stringFromStdWString(it->second), it->first); itm->setSelectionBrushImage(sel_img); cbbo->addItem(itm); } cbbo->subscribeEvent(Combobox::EventListSelectionAccepted, Event::Subscriber([=](const CEGUI::EventArgs& args)->bool { Combobox* combo = static_cast<Combobox*>(static_cast<const WindowEventArgs&>(args).window->getRootWindow()->getChild("MainWindow/" + combo_name)); ListboxItem* item = combo->findItemWithText(combo->getText(), 0); if (item) { zone_changed_signal_( item->getID()); } return true; }) ); cbbo->setReadOnly(true); cbbo->setSortingEnabled(false); //cbbo->handleUpdatedListItemData(); CEGUI::ToggleButton* checkbox = static_cast<ToggleButton*>( CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Checkbox", tb_name)); checkbox->setSelected(true); checkbox->setText( "Lights" ); mainWindow->addChild(checkbox); auto settingsWindow = winMgr.loadLayoutFromFile("vis_settings.layout"); root->addChild(settingsWindow); subscribeEvent(setting_dlg + "/Settings/chkLights", ToggleButton::EventSelectStateChanged, Event::Subscriber([=](const CEGUI::EventArgs& args)->bool { bool wrap = isCheckboxSelected(setting_dlg + "/Settings/chkLights"); set_lights_signal_(wrap); return true; })); settingsWindow->setVisible(false); subscribeEvent(setting_dlg + "/LWeather/edtGrassMap", CEGUI::Editbox::EventTextAccepted, Event::Subscriber([=](const CEGUI::EventArgs& args)->bool { std::string param = getEditboxText(setting_dlg + "/LWeather/edtGrassMap"); set_map_signal_(boost::lexical_cast<float>(param.empty()?"0":param)); return true; })); subscribeEvent(setting_dlg + "/LWeather/btnApply", PushButton::EventClicked, Event::Subscriber([=](const CEGUI::EventArgs& args)->bool { std::string param = getEditboxText(setting_dlg + "/LWeather/edtGrassMap"); set_map_signal_(boost::lexical_cast<float>(param.empty()?"0":param)); return true; })); subscribeEvent(setting_dlg + "/Settings/chkShadows", ToggleButton::EventSelectStateChanged, Event::Subscriber([=](const CEGUI::EventArgs& args)->bool { bool wrap = isCheckboxSelected(setting_dlg + "/Settings/chkShadows"); set_shadows_signal_(wrap); return true; })); subscribeEvent(setting_dlg + "/Settings/chkShadowsParticles", ToggleButton::EventSelectStateChanged, Event::Subscriber([=](const CEGUI::EventArgs& args)->bool { bool wrap = isCheckboxSelected(setting_dlg + "/Settings/chkShadowsParticles"); set_shadows_part_signal_(wrap); return true; })); setItemText(setting_dlg + "/LWeather/edtRadX" , boost::str(boost::format("%.2f") % s.clouds[0].radius_x)); setItemText(setting_dlg + "/LWeather/edtRadY" , boost::str(boost::format("%.2f") % s.clouds[0].radius_y)); setItemText(setting_dlg + "/LWeather/edtX" , boost::str(boost::format("%.2f") % s.clouds[0].x)); setItemText(setting_dlg + "/LWeather/edtY" , boost::str(boost::format("%.2f") % s.clouds[0].y)); setItemText(setting_dlg + "/LWeather/edtHeight" , boost::str(boost::format("%.2f") % s.clouds[0].height)); setItemText(setting_dlg + "/LWeather/edtIntensity", boost::str(boost::format("%.2f") % s.clouds[0].intensity)); setItemText(setting_dlg + "/GWeather/edtIntensity", boost::str(boost::format("%.2f") % s.intensity)); auto cloud_settings_callback = [=](const CEGUI::EventArgs& args)->bool { app::cloud_params_t s; std::string edtRadX = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtRadX")); s.radius_x = boost::lexical_cast<float>(edtRadX.empty()?"0":edtRadX); std::string edtRadY = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtRadY")); s.radius_y = boost::lexical_cast<float>(edtRadY.empty()?"0":edtRadY); std::string edtX = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtX")); s.x = boost::lexical_cast<float>(edtX.empty()?"0":edtX); std::string edtY = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtY")); s.y = boost::lexical_cast<float>(edtY.empty()?"0":edtY); std::string edtHeight = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtHeight")); s.height = boost::lexical_cast<float>(edtHeight.empty()?"0":edtHeight); std::string edtIntensity = boost::trim_copy(getEditboxText(setting_dlg + "/LWeather/edtIntensity")); s.intensity = boost::lexical_cast<float>(edtIntensity.empty()?"0":edtIntensity); s.p_type = 1; set_cloud_param_signal_(s); return true; }; subscribeEvent(setting_dlg + "/LWeather/edtRadX", Editbox::EventTextAccepted, Event::Subscriber(cloud_settings_callback)); subscribeEvent(setting_dlg + "/LWeather/edtRadY", Editbox::EventTextAccepted, Event::Subscriber(cloud_settings_callback)); subscribeEvent(setting_dlg + "/LWeather/edtX" , Editbox::EventTextAccepted, Event::Subscriber(cloud_settings_callback)); subscribeEvent(setting_dlg + "/LWeather/edtY" , Editbox::EventTextAccepted, Event::Subscriber(cloud_settings_callback)); subscribeEvent(setting_dlg + "/LWeather/edtHeight", Editbox::EventTextAccepted, Event::Subscriber(cloud_settings_callback)); subscribeEvent(setting_dlg + "/LWeather/edtIntensity", Editbox::EventTextAccepted, Event::Subscriber(cloud_settings_callback)); subscribeEvent(setting_dlg + "/GWeather/edtIntensity", Editbox::EventTextAccepted, Event::Subscriber([=](const CEGUI::EventArgs& args)->bool { std::string param = boost::trim_copy(getEditboxText(setting_dlg + "/GWeather/edtIntensity")); set_global_intensity_signal_ (boost::lexical_cast<float>(param.empty()?"0":param)); return true; })); }