void PanelControllers::notifySelectItem(MyGUI::ListBox* _sender, size_t _index) { destroyPropertyFields(); mIndexSelected = mList->getIndexSelected(); if (MyGUI::ITEM_NONE == mIndexSelected) return; std::string key = mList->getItemNameAt(mIndexSelected); mControllerName->setOnlyText(key); if (mControllersProperties.find(key) != mControllersProperties.end()) { ControllerInfo* controllerInfo = *mList->getItemDataAt<ControllerInfo*>(mIndexSelected); for (MyGUI::MapString::iterator iter = mControllersProperties[key].begin(); iter != mControllersProperties[key].end(); ++iter) { std::string value = ""; if (controllerInfo->mProperty.find(iter->first) != controllerInfo->mProperty.end()) value = controllerInfo->mProperty[iter->first]; IPropertyField* field = PropertyFieldManager::getInstance().createPropertyField(mWidgetClient, iter->second); field->setTarget(mCurrentWidget); field->setName(iter->first); field->setValue(value); field->eventAction = MyGUI::newDelegate(this, &PanelControllers::notifyAction); mFields.push_back(field); } } updateSize(); }
IPropertyField* PropertyFieldManager::createPropertyField(MyGUI::Widget* _window, const std::string& _type) { IPropertyField* result = nullptr; MapFactoryItem::iterator item = mFactories.find(_type); MYGUI_ASSERT(item != mFactories.end(), "Factory PropertyField '" << _type << "' not found."); (*item).second(result, _window); result->initialise(_type); return result; }
void PanelTemplateProperties::AddParametrs(WidgetStyle* widgetType, WidgetContainer* widgetContainer, MyGUI::Widget* _currentWidget) { if (widgetType != nullptr) { for (MyGUI::VectorStringPairs::iterator iter = widgetType->templateData.begin(); iter != widgetType->templateData.end(); ++iter) { std::string value = widgetContainer->getUserData(iter->first); IPropertyField* field = PropertyFieldManager::getInstance().createPropertyField(mWidgetClient, iter->second); field->setTarget(_currentWidget); field->setName(iter->first); field->setValue(value); field->eventAction = MyGUI::newDelegate(this, &PanelTemplateProperties::notifyAction); mFields.push_back(field); } } }
size_t PanelProperties::addParametrs(WidgetStyle* widgetType, WidgetContainer* widgetContainer, MyGUI::Widget* _currentWidget) { size_t result = 0; for (MyGUI::VectorStringPairs::iterator iter = widgetType->parameter.begin(); iter != widgetType->parameter.end(); ++iter) { std::string value = widgetContainer->getProperty(iter->first); IPropertyField* field = getPropertyField(mWidgetClient, iter->first, iter->second); field->setTarget(_currentWidget); field->setValue(value); result ++; } return result; }
IPropertyField* PanelProperties::getPropertyField(MyGUI::Widget* _client, const std::string& _name, const std::string& _type) { MapPropertyField::iterator item = mFields.find(_name); if (item != mFields.end()) { (*item).second->setVisible(true); return (*item).second; } IPropertyField* result = PropertyFieldManager::getInstance().createPropertyField(_client, _type); result->setName(_name); result->eventAction = MyGUI::newDelegate(this, &PanelProperties::notifyAction); mFields[_name] = result; return result; }
void PanelExtensionProperties::AddParametrs(WidgetStyle* widgetType, WidgetContainer* widgetContainer, MyGUI::Widget* _currentWidget) { if (widgetType != nullptr) { for (MyGUI::VectorStringPairs::iterator iter = widgetType->parameterData.begin(); iter != widgetType->parameterData.end(); ++iter) { std::string value = ""; for (MyGUI::VectorStringPairs::iterator iterProperty = widgetContainer->mUserString.begin(); iterProperty != widgetContainer->mUserString.end(); ++iterProperty) { if (iterProperty->first == iter->first) { value = iterProperty->second; break; } } IPropertyField* field = PropertyFieldManager::getInstance().createPropertyField(mWidgetClient, iter->second, _currentWidget); field->setName(iter->first); field->setValue(value); field->eventAction = MyGUI::newDelegate(this, &PanelExtensionProperties::notifyAction); mFields.push_back(field); } } }
void PanelMainProperties::update(MyGUI::Widget* _currentWidget) { hidePropertyFields(); mCurrentWidget = _currentWidget; if (mCurrentWidget == nullptr) return; WidgetStyle* widgetType = WidgetTypes::getInstance().findWidgetStyle(mCurrentWidget->getTypeName()); WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget); bool existTargetType = widgetContainer->existUserData(mUserDataTargetType); IPropertyField* field = getPropertyField(mWidgetClient, "Name", "Name"); field->setTarget(_currentWidget); field->setValue(widgetContainer->getName()); if (widgetType->resizeable) { field = getPropertyField(mWidgetClient, "Position", "Position"); field->setTarget(_currentWidget); field->setValue(widgetContainer->position()); } field = getPropertyField(mWidgetClient, "Type", "Type"); field->setTarget(_currentWidget); if (existTargetType) { std::string targetType = widgetContainer->getUserData(mUserDataTargetType); field->setValue(targetType); } else { field->setValue(widgetContainer->getType()); } field = getPropertyField(mWidgetClient, "Align", "Align"); field->setTarget(_currentWidget); field->setValue(widgetContainer->getAlign()); if (mCurrentWidget->isRootWidget()) { field = getPropertyField(mWidgetClient, "Layer", "Layer"); field->setTarget(_currentWidget); field->setValue(widgetContainer->getLayerName()); field = getPropertyField(mWidgetClient, "Template", "Bool"); field->setTarget(_currentWidget); field->setValue(existTargetType ? "true" : "false"); } field = getPropertyField(mWidgetClient, "Skin", "Skin"); field->setTarget(_currentWidget); field->setValue(widgetContainer->getSkin()); updateSize(); }