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(); }
void PanelMainProperties::notifyToggleRelativeMode(MyGUI::WidgetPtr _sender) { if (current_widget) { WidgetContainer * widgetContainer = EditorWidgets::getInstance().find(current_widget); if (widgetContainer->relative_mode) mButtonRelativePosition->setCaption(localise("to_percents")); else mButtonRelativePosition->setCaption(localise("to_pixels")); widgetContainer->relative_mode = !widgetContainer->relative_mode; eventSetPositionText(widgetContainer->position()); } }
void PropertiesPanelView::notifyRectangleResize(MyGUI::WindowPtr _sender) { if (!_sender->isVisible()) return; // найдем соответствующий контейнер виджета и переместим/раст¤нем WidgetContainer * widgetContainer = EditorWidgets::getInstance().find(current_widget); if (WidgetTypes::getInstance().find(current_widget->getTypeName())->resizeable) { MyGUI::IntCoord coord = convertCoordToParentCoord(_sender->getCoord(), current_widget); MyGUI::IntCoord old_coord = current_widget->getCoord(); // align to grid if (!MyGUI::InputManager::getInstance().isShiftPressed() && !arrow_move){ if ((old_coord.width == coord.width) && (old_coord.height == coord.height)) // если только перемещаем { coord.left = toGrid(coord.left + grid_step-1 - old_coord.left) + old_coord.left; coord.top = toGrid(coord.top + grid_step-1 - old_coord.top) + old_coord.top; } else // если раст¤гиваем { if (old_coord.left != coord.left){ coord.left = toGrid(coord.left + grid_step-1); coord.width = old_coord.right() - coord.left; }else if (old_coord.width != coord.width){ coord.width = toGrid(coord.width + old_coord.left) - old_coord.left; } if (old_coord.top != coord.top){ coord.top = toGrid(coord.top + grid_step-1); coord.height = old_coord.bottom() - coord.top; }else if (old_coord.height != coord.height){ coord.height = toGrid(coord.height + old_coord.top) - old_coord.top; } } } arrow_move = false; current_widget->setCoord(coord); // update coord because of current_widget can have MinMax size coord = current_widget->getCoord(); setPositionText(widgetContainer->position()); UndoManager::getInstance().addValue(PR_POSITION); } current_widget_rectangle->setCoord(current_widget->getAbsoluteCoord()); }
void PanelMainProperties::update(MyGUI::Widget* _currentWidget) { int y = 0; mCurrentWidget = _currentWidget; WidgetStyle* widgetType = WidgetTypes::getInstance().findWidgetStyle(mCurrentWidget->getTypeName()); WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget); eventCreatePair(mWidgetClient, "Name", widgetContainer->name, "Name", y); y += mPropertyItemHeight; if (widgetType->resizeable) { // update caption of LayoutEditor_buttonRelativePosition mButtonRelativePosition->setVisible(true); if (widgetContainer->relative_mode) mButtonRelativePosition->setCaption(replaceTags("to_pixels")); else mButtonRelativePosition->setCaption(replaceTags("to_percents")); eventCreatePair(mWidgetClient, "Position", widgetContainer->position(), "Position", y); y += mPropertyItemHeight; } else { mButtonRelativePosition->setVisible(false); } eventCreatePair(mWidgetClient, "Align", widgetContainer->align, "Align", y); y += mPropertyItemHeight; if (nullptr == mCurrentWidget->getParent()) { eventCreatePair(mWidgetClient, "Layer", widgetContainer->layer, "Layer", y); y += mPropertyItemHeight; } if (widgetType->skin.size() > 1) { eventCreatePair(mWidgetClient, "Skin", widgetContainer->skin, "Skin", y); y += mPropertyItemHeight; } mWidgetClient->_forcePeek(mButtonRelativePosition); mPanelCell->setClientHeight(y); }