void PropertiesPanelView::update(MyGUI::WidgetPtr _current_widget) { current_widget = _current_widget; if (nullptr == current_widget) current_widget_rectangle->setVisible(false); else { MyGUI::LayerManager::getInstance().upLayerItem(current_widget); MyGUI::IntCoord coord = current_widget->getCoord(); MyGUI::WidgetPtr parent = current_widget->getParent(); if (nullptr != parent) { // если выбрали виджет на табе, то подн¤ть лист таба if (parent->getTypeName() == "Sheet" || parent->getTypeName() == MyGUI::TabItem::getClassTypeName()) { MyGUI::TabPtr tab = parent->getParent()->castType<MyGUI::Tab>(); MyGUI::SheetPtr sheet = parent->castType<MyGUI::Sheet>(); tab->setItemSelected(sheet); } // если выбрали лист таба, то подн¤ть лист таба if (current_widget->getTypeName() == "Sheet" || current_widget->getTypeName() == MyGUI::TabItem::getClassTypeName()) { MyGUI::TabPtr tab = parent->castType<MyGUI::Tab>(); MyGUI::SheetPtr sheet = current_widget->castType<MyGUI::Sheet>(); tab->setItemSelected(sheet); } coord = current_widget->getAbsoluteCoord(); } current_widget_rectangle->setVisible(true); current_widget_rectangle->setCoord(coord); MyGUI::InputManager::getInstance().setKeyFocusWidget(current_widget_rectangle); } // delete all previous properties for (std::vector<MyGUI::StaticTextPtr>::iterator iter = propertiesText.begin(); iter != propertiesText.end(); ++iter) (*iter)->setVisible(false); for (MyGUI::VectorWidgetPtr::iterator iter = propertiesElement.begin(); iter != propertiesElement.end(); ++iter) (*iter)->setVisible(false); if (nullptr == _current_widget) { mMainWidget->setVisible(false); } else { mMainWidget->setVisible(true); pairs_counter = 0; mPanelMainProperties->update(_current_widget); mPanelTypeProperties->update(_current_widget, PanelProperties::TYPE_PROPERTIES); mPanelGeneralProperties->update(_current_widget, PanelProperties::WIDGET_PROPERTIES); mPanelEvents->update(_current_widget, PanelProperties::EVENTS); mPanelItems->update(_current_widget); mPanelUserData->update(_current_widget); } }
void EditorWidgets::remove(MyGUI::WidgetPtr _widget) { // дети вперед MyGUI::VectorWidgetPtr childs = _widget->getChilds(); for (MyGUI::VectorWidgetPtr::iterator iter = childs.begin(); iter != childs.end(); ++iter) { if (null != find(*iter)) remove(*iter); } WidgetContainer * _container = find(_widget); MyGUI::WidgetPtr parent = _widget->getParent(); // FIXME у таба все не как у людей if ((null != parent) && (parent->getWidgetType() == "Tab")) MyGUI::castWidget<MyGUI::Tab>(parent)->removeSheet(MyGUI::castWidget<MyGUI::Sheet>(_widget)); else MyGUI::Gui::getInstance().destroyWidget(_widget); if (null != _container) { widgets.erase(std::find(widgets.begin(), widgets.end(), _container)); delete _container; } }
void EditorWidgets::serialiseWidget(WidgetContainer * _container, MyGUI::xml::xmlNodePtr _node) { MyGUI::xml::xmlNodePtr node = _node->createChild("Widget"); node->addAttributes("type", _container->type); if ("" != _container->skin) node->addAttributes("skin", _container->skin); if ("" != _container->position) node->addAttributes("position", _container->position); if ("" != _container->position_real) node->addAttributes("position_real", _container->position_real); if ("" != _container->align) node->addAttributes("align", _container->align); if ("" != _container->layer) node->addAttributes("layer", _container->layer); if ("" != _container->name) node->addAttributes("name", _container->name); for (StringPairs::iterator iter = _container->mProperty.begin(); iter != _container->mProperty.end(); ++iter) { MyGUI::xml::xmlNodePtr nodeProp = node->createChild("Property"); nodeProp->addAttributes("key", iter->first); nodeProp->addAttributes("value", iter->second); } for (MapString::iterator iter = _container->mUserString.begin(); iter != _container->mUserString.end(); ++iter) { MyGUI::xml::xmlNodePtr nodeProp = node->createChild("UserString"); nodeProp->addAttributes("key", iter->first); nodeProp->addAttributes("value", iter->second); } // метод медленный, т.к. квадратичная сложность for (std::vector<WidgetContainer*>::iterator iter = widgets.begin(); iter != widgets.end(); ++iter) { MyGUI::WidgetPtr parent = (*iter)->widget->getParent(); // сынок - это ты? if (_container->widget->getWidgetType() == "Window"){ if (null != parent) if (_container->widget == parent->getParent()) serialiseWidget(*iter, node); }else if (_container->widget == parent) serialiseWidget(*iter, node); } }