void PanelMainProperties::notifyActionSkin(const std::string& _type, const std::string& _value, bool _final)
	{
		if (_final)
		{
			WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget);

			widgetContainer->setSkin(_value);
			if (isSkinExist(widgetContainer->getSkin()) || widgetContainer->getSkin().empty())
			{
				WidgetSelectorManager::getInstance().saveSelectedWidget();

				MyGUI::xml::Document* savedDoc = EditorWidgets::getInstance().savexmlDocument();
				EditorWidgets::getInstance().clear();
				EditorWidgets::getInstance().loadxmlDocument(savedDoc);
				delete savedDoc;

				WidgetSelectorManager::getInstance().restoreSelectedWidget();
			}
			else
			{
				std::string mess = MyGUI::utility::toString("Skin '", widgetContainer->getSkin(), "' not found. This value will be saved.");
				GroupMessage::getInstance().addMessage(mess, MyGUI::LogLevel::Error);
			}

			UndoManager::getInstance().addValue(PR_PROPERTIES);
		}
	}
Exemple #2
0
void WidgetContainer::OnInputPointerMove(const EventInputPointer *ev)
{
	ASSERT_NULL(ev);

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();

	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		bEventConsumed = FALSE;

		if (w->IsDisabled())
			continue;

		if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
		{
			WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
			wc->OnInputPointerMove(ev);

			bEventConsumed = wc->IsEventConsumed();
			if (bEventConsumed)
				break;
		}

		bEventConsumed = this->UpdateStates(ev, w);
		//if (UpdateStates(ev, w))
		if (bEventConsumed)
			break;
	}
}
  void PropertyFieldPosition::onAction(const std::string& _value, bool _force)
  {
    EditorWidgets* ew = &EditorWidgets::getInstance();
    WidgetContainer* widgetContainer = ew->find(mCurrentWidget);

    bool goodData = onCheckValue();

    if (goodData)
    {
      if (widgetContainer->getRelativeMode())
      {
        std::istringstream str(_value);
        MyGUI::FloatCoord float_coord;
        str >> float_coord;
        float_coord.left = float_coord.left / 100;
        float_coord.top = float_coord.top / 100;
        float_coord.width = float_coord.width / 100;
        float_coord.height = float_coord.height / 100;
        MyGUI::IntCoord coord = MyGUI::CoordConverter::convertFromRelative(float_coord, mCurrentWidget->getParentSize());

        mCurrentWidget->setCoord(coord);
        EditorWidgets::getInstance().onSetWidgetCoord(mCurrentWidget, mCurrentWidget->getAbsoluteCoord(), "PropertiesPanelView");
      }
      else
      {
void WidgetCreatorManager::finishNewWidget(const MyGUI::IntPoint& _point)
{
    if (mNewWidget != nullptr)
    {
        MyGUI::IntCoord coord = getCoordNewWidget(_point);

        if (coord.width != 0 && coord.height != 0)
        {
            mNewWidget->setCoord(coord);

            // создали виджет, все счастливы
            WidgetContainer * widgetContainer = new WidgetContainer(mWidgetType, mWidgetSkin, mNewWidget);
            if (mPopupMode)
                widgetContainer->setStyle(mNewWidget->getWidgetStyle().print());
            mNewWidget = nullptr;

            EditorWidgets::getInstance().add(widgetContainer);
            UndoManager::getInstance().addValue();

            // чтобы выделился созданый виджет
            resetAllCreatorInfo();

            WidgetSelectorManager::getInstance().setSelectedWidget(widgetContainer->getWidget());
        }
        else
        {
            // не удалось создать, т.к. размер нулевой
            resetWidget();
        }
    }

    resetAllCreatorInfo();

    eventChangeSelector(false, MyGUI::IntCoord());
}
	void WidgetSelectorManager::saveSelectedWidget()
	{
		if (mCurrentWidget != nullptr)
		{
			WidgetContainer* container = EditorWidgets::getInstance().find(mCurrentWidget);
			if (container != nullptr)
				container->setUserData(mStoreWidgetTag, mStoreWidgetTag);
		}
	}
	void PanelMainProperties::notifyActionName(const std::string& _type, const std::string& _value, bool _final)
	{
		if (_final)
		{
			WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget);
			widgetContainer->setName(_value);

			UndoManager::getInstance().addValue(PR_PROPERTIES);
		}
	}
	void PanelTemplateProperties::notifyAction(const std::string& _name, const std::string& _value, bool _final)
	{
		if (_final)
		{
			WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget);
			widgetContainer->setUserData(_name, _value);

			UndoManager::getInstance().addValue(PR_PROPERTIES);
		}
	}
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 PanelUserData::notifyDeleteUserData(MyGUI::Widget* _sender)
  {
    size_t item = mMultilist->getIndexSelected();
    if (MyGUI::ITEM_NONE == item) return;

    WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget);
    widgetContainer->clearUserData(mMultilist->getItemNameAt(item));
    mMultilist->removeItemAt(item);
    UndoManager::getInstance().addValue();
  }
 void PanelUserData::notifyAddUserData(MyGUI::Widget* _sender)
 {
   std::string key = mEditKey->getOnlyText();
   std::string value = mEditValue->getOnlyText();
   WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget);
   if (!widgetContainer->existUserData(key))
   {
     mMultilist->addItem(key);
   }
   mMultilist->setSubItemNameAt(1, mMultilist->findSubItemWith(0, key), MyGUI::TextIterator::toTagsString(value));
   widgetContainer->setUserData(key, value);
   UndoManager::getInstance().addValue();
 }
	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();
	}
	std::string MainMenuControlLE::getDescriptionString(MyGUI::Widget* _widget, bool _print_name, bool _print_type, bool _print_skin)
	{
		WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(_widget);

		addUserTag("WidgetName", _print_name ? widgetContainer->getName() : "");
		addUserTag("WidgetType", _print_type ? _widget->getTypeName() : "");
		addUserTag("WidgetSkin", _print_skin ? widgetContainer->getSkin() : "");

		addUserTag("FormatWidgetName", (_print_name && !widgetContainer->getName().empty()) ? "#{PatternWidgetName}" : "");
		addUserTag("FormatWidgetType", _print_type ? "#{PatternWidgetType}" : "");
		addUserTag("FormatWidgetSkin", _print_skin ? "#{PatternWidgetSkin}" : "");

		return replaceTags("MenuItemWidgetInfo");
	}
	void PanelProperties::notifyAction(const std::string& _name, const std::string& _value, bool _final)
	{
		WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget);

		EditorWidgets::getInstance().tryToApplyProperty(widgetContainer->getWidget(), _name, _value);

		if (_final)
		{
			if (_value.empty())
				widgetContainer->clearProperty(_name);
			else
				widgetContainer->setProperty(_name, _value);

			UndoManager::getInstance().addValue(PR_PROPERTIES);
		}
	}
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);
}
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 PanelUserData::update(MyGUI::Widget* _currentWidget)
  {
    mCurrentWidget = _currentWidget;
    if (mCurrentWidget == nullptr)
      return;

    mMultilist->removeAllItems();

    WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(_currentWidget);
    WidgetContainer::UserDataEnumerator userData = widgetContainer->getUserDataEnumerator();
    while (userData.next())
    {
      if (checkUserData(widgetContainer, userData.current().first))
      {
        mMultilist->addItem(userData.current().first);
        mMultilist->setSubItemNameAt(1, mMultilist->getItemCount() - 1, MyGUI::TextIterator::toTagsString(userData.current().second));
      }
    }
  }
	void PanelMainProperties::notifyActionTemplate(const std::string& _type, const std::string& _value, bool _final)
	{
		if (_final)
		{
			WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget);
			if (_value == "true")
			{
				if (!widgetContainer->existUserData(mUserDataTargetType))
				{
					widgetContainer->setUserData(mUserDataTargetType, widgetContainer->getType());
					widgetContainer->setType(MyGUI::Widget::getClassTypeName());

					WidgetSelectorManager::getInstance().saveSelectedWidget();

					MyGUI::xml::Document* savedDoc = EditorWidgets::getInstance().savexmlDocument();
					EditorWidgets::getInstance().clear();
					EditorWidgets::getInstance().loadxmlDocument(savedDoc);
					delete savedDoc;

					WidgetSelectorManager::getInstance().restoreSelectedWidget();

					UndoManager::getInstance().addValue(PR_PROPERTIES);
				}
			}
			else
			{
				if (widgetContainer->existUserData(mUserDataTargetType))
				{
					std::string targetType = widgetContainer->getUserData(mUserDataTargetType);
					widgetContainer->clearUserData(mUserDataTargetType);
					widgetContainer->setType(targetType);

					WidgetSelectorManager::getInstance().saveSelectedWidget();

					MyGUI::xml::Document* savedDoc = EditorWidgets::getInstance().savexmlDocument();
					EditorWidgets::getInstance().clear();
					EditorWidgets::getInstance().loadxmlDocument(savedDoc);
					delete savedDoc;

					WidgetSelectorManager::getInstance().restoreSelectedWidget();

					UndoManager::getInstance().addValue(PR_PROPERTIES);
				}
			}
		}
	}
  void PanelUserData::notifyUpdateUserData(MyGUI::EditBox* _widget)
  {
    size_t item = mMultilist->getIndexSelected();
    if (MyGUI::ITEM_NONE == item)
    {
      notifyAddUserData();
      return;
    }
    std::string key = mEditKey->getOnlyText();
    std::string value = mEditValue->getOnlyText();
    std::string lastkey = mMultilist->getItemNameAt(item);

    WidgetContainer* widgetContainer = EditorWidgets::getInstance().find(mCurrentWidget);
    mMultilist->removeItemAt(mMultilist->findSubItemWith(0, lastkey));
    widgetContainer->clearUserData(lastkey);
    if (!widgetContainer->existUserData(key))
    {
      mMultilist->addItem(key);
    }
    mMultilist->setSubItemNameAt(1, mMultilist->findSubItemWith(0, key), MyGUI::TextIterator::toTagsString(value));
    mMultilist->setIndexSelected(mMultilist->findSubItemWith(0, key));
    widgetContainer->setUserData(key, value);
    UndoManager::getInstance().addValue();
  }
Exemple #19
0
void WidgetContainer::OnInputPointerRelease(const EventInputPointer *ev)
{
	ASSERT_NULL(ev);

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();

	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		//BOOL consumed = FALSE;

		bEventConsumed = FALSE;

		ASSERT_NULL(w);

		if (w->IsDisabled())
			continue;

		if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
		{
			WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
			wc->OnInputPointerRelease(ev);

			bEventConsumed = wc->IsEventConsumed();
			if (bEventConsumed)
				break;
		}

		//f32 cX = ev->GetX();
		//f32 cY = ev->GetY();
		u32 j = ev->GetJoystick();

		if (!(w->GetTrigger() & ev->GetReleased()))
			continue;

		if (w->GetState() == Seed::WidgetStateDrag)
		{
			//LOG("> STOP DRAG [%d, %f, %f]", j, cX, cY);
			bEventConsumed = this->DoDrop(ev, w);
		}
		else
		{
			if (w->GetPlayerState(j) == Seed::WidgetStatePressedOver)
			{
				//LOG("> RELEASE [%d, %f, %f]", j, cX, cY);
				//consumed = this->DoRelease(ev, w);
				bEventConsumed = this->DoRelease(ev, w);
			}
			else if (w->GetPlayerState(j) == Seed::WidgetStatePressedOut)
			{
				//LOG("> RELEASE OUT [%d, %f, %f]", j, cX, cY);
				//consumed = this->DoReleaseOut(ev, w);
				bEventConsumed = this->DoReleaseOut(ev, w);
			}
		}

		//if (consumed)
		if (bEventConsumed)
			break;
	}
}
Exemple #20
0
void WidgetContainer::OnInputPointerPress(const EventInputPointer *ev)
{
	ASSERT_NULL(ev);

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();

	f32 cX = ev->GetX();
	f32 cY = ev->GetY();
	BOOL found = FALSE;
	
	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		bEventConsumed = FALSE;

		if (w->IsDisabled())
			continue;

		if (!w->ContainsPoint(cX, cY))
			continue;

		if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
		{
			WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
			wc->OnInputPointerPress(ev);

			bEventConsumed = wc->IsEventConsumed();
			if (bEventConsumed)
				break;
		}

		if (!(w->GetTrigger() & ev->GetPressed()))
			continue;

		u32 j = ev->GetJoystick();

		//LOG("> PRESS [%d, %f, %f]", j, cX, cY);

		if (w->GetState() == Seed::WidgetStateDrag)
		{
			continue;
		}
		
		found = TRUE;

		const EventWidget newEvent(w, NULL, WidgetEventPressed, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());

		LOG(">PRESSED_OVER [id: %d]", w->GetId());
		// GetState eh o baseado em prioridade a partir de todos os inputs.
		if (w->GetState() != Seed::WidgetStatePressedOver && w->GetPlayerState(j) != Seed::WidgetStatePressedOver)
		{
			// muda apenas o estado interno do widget
			LOG("\tEstado WIDGET");
			w->OnWidgetPress(&newEvent);
		}

		w->SetState(Seed::WidgetStatePressed);
		w->SetPlayerState(Seed::WidgetStatePressedOver, j);
		LOG("\tEstado PLAYER");

		w->SendOnPress(&newEvent);
		LOG("\tEvento");
		//if (newEvent.IsConsumed())
		bEventConsumed = newEvent.IsConsumed();
		if (bEventConsumed)
			break;
	}

	if (!found) // avoid call
	{
		// If no widget have collision, then we try distance based input;
		f32 maxDist = pConfiguration->GetInputDistanceRadius();
		if (maxDist)
		{
			IWidget *nearest = this->FindNearestByRadius(maxDist, ev);
			if (nearest)
			{
				IWidget *w = nearest;
				if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
				{
					WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
					wc->OnInputPointerPress(ev);

					bEventConsumed = wc->IsEventConsumed();
					if (bEventConsumed)
						return;
				}

				u32 j = ev->GetJoystick();

				const EventWidget newEvent(w, NULL, WidgetEventPressed, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());

				LOG(">PRESSED_OVER [id: %d]", w->GetId());
				// GetState eh o baseado em prioridade a partir de todos os inputs.
				if (w->GetState() != Seed::WidgetStatePressedOver && w->GetPlayerState(j) != Seed::WidgetStatePressedOver)
				{
					// muda apenas o estado interno do widget
					LOG("\tEstado WIDGET");
					w->OnWidgetPress(&newEvent);
				}

				w->SetState(Seed::WidgetStatePressed);
				w->SetPlayerState(Seed::WidgetStatePressedOver, j);
				LOG("\tEstado PLAYER");

				w->SendOnPress(&newEvent);
				LOG("\tEvento");
				bEventConsumed = newEvent.IsConsumed();
				if (bEventConsumed)
					return;
			}
		}
	}
}
Exemple #21
0
void WidgetContainer::OnInputPointerPress(const EventInputPointer *ev)
{
	ASSERT_NULL(ev);

	WidgetIterator it = vWidget.begin();
	WidgetIterator end = vWidget.end();

	for (; it != end; ++it)
	{
		IWidget *w = (*it);
		ASSERT_NULL(w);

		bEventConsumed = FALSE;

		if (w->IsDisabled())
			continue;

		f32 cX = ev->GetX();
		f32 cY = ev->GetY();

		if (!w->ContainsPoint(cX, cY))
			continue;

		if (w->GetObjectType() == Seed::ObjectGuiWidgetContainer)
		{
			WidgetContainer *wc = reinterpret_cast<WidgetContainer *>(w);
			wc->OnInputPointerPress(ev);

			bEventConsumed = wc->IsEventConsumed();
			if (bEventConsumed)
				break;
		}

		if (!(w->GetTrigger() & ev->GetPressed()))
			continue;

		u32 j = ev->GetJoystick();

		//LOG("> PRESS [%d, %f, %f]", j, cX, cY);

		if (w->GetState() == Seed::WidgetStateDrag)
		{
			continue;
		}

		const EventWidget newEvent(w, NULL, WidgetEventPressed, j, cX, cY, ev->GetPressed(), ev->GetHold(), ev->GetReleased());

		LOG(">PRESSED_OVER [id: %d]", w->GetId());
		// GetState eh o baseado em prioridade a partir de todos os inputs.
		if (w->GetState() != Seed::WidgetStatePressedOver && w->GetPlayerState(j) != Seed::WidgetStatePressedOver)
		{
			// muda apenas o estado interno do widget
			LOG("\tEstado WIDGET");
			w->OnWidgetPress(&newEvent);
		}

		w->SetState(Seed::WidgetStatePressed);
		w->SetPlayerState(Seed::WidgetStatePressedOver, j);
		LOG("\tEstado PLAYER");

		w->SendOnPress(&newEvent);
		LOG("\tEvento");
		//if (newEvent.IsConsumed())
		bEventConsumed = newEvent.IsConsumed();
		if (bEventConsumed)
			break;
	}
}