void PropertiesPanelView::notifyWindowChangeCoord(MyGUI::WindowPtr _sender)
{
	const MyGUI::IntSize & size = _sender->getSize();
	if (size != mOldSize) {
		mOldSize = size;
		mPanelView->setNeedUpdate();
	}
}
PropertiesPanelView::PropertiesPanelView() : BaseLayout("PropertiesPanelView.layout")
{
	DEFAULT_VALUE = localise("ColourDefault") + DEFAULT_STRING;
	ERROR_VALUE = localise("ColourError");

	assignBase(mPanelView, "scroll_View");

	MyGUI::WindowPtr window = mMainWidget->castType<MyGUI::Window>(false);
	if (window != nullptr) {
		window->eventWindowChangeCoord = MyGUI::newDelegate(this, &PropertiesPanelView::notifyWindowChangeCoord);
		mOldSize = window->getSize();
	}

	mPanelMainProperties = new PanelMainProperties();
	mPanelView->addItem(mPanelMainProperties);
	mPanelMainProperties->eventCreatePair = MyGUI::newDelegate(this, &PropertiesPanelView::createPropertiesWidgetsPair);
	mPanelMainProperties->eventSetPositionText = MyGUI::newDelegate(this, &PropertiesPanelView::setPositionText);

	mPanelTypeProperties = new PanelProperties();
	mPanelView->addItem(mPanelTypeProperties);
	mPanelTypeProperties->eventCreatePair = MyGUI::newDelegate(this, &PropertiesPanelView::createPropertiesWidgetsPair);

	mPanelGeneralProperties = new PanelProperties();
	mPanelView->addItem(mPanelGeneralProperties);
	mPanelGeneralProperties->eventCreatePair = MyGUI::newDelegate(this, &PropertiesPanelView::createPropertiesWidgetsPair);

	mPanelEvents = new PanelProperties();
	mPanelView->addItem(mPanelEvents);
	mPanelEvents->eventCreatePair = MyGUI::newDelegate(this, &PropertiesPanelView::createPropertiesWidgetsPair);

	mPanelItems = new PanelItems();
	mPanelView->addItem(mPanelItems);

	mPanelUserData = new PanelUserData();
	mPanelView->addItem(mPanelUserData);

	mPanels.push_back(mPanelMainProperties);
	mPanels.push_back(mPanelTypeProperties);
	mPanels.push_back(mPanelGeneralProperties);
	mPanels.push_back(mPanelEvents);
	mPanels.push_back(mPanelItems);
	mPanels.push_back(mPanelUserData);

	current_widget = nullptr;

	// create widget rectangle
	current_widget_rectangle = MyGUI::Gui::getInstance().createWidget<MyGUI::Window>("StretchRectangle", MyGUI::IntCoord(), MyGUI::Align::Default, "LayoutEditor_Rectangle");
	current_widget_rectangle->eventWindowChangeCoord = newDelegate(this, &PropertiesPanelView::notifyRectangleResize);
	current_widget_rectangle->eventMouseButtonDoubleClick = newDelegate(mPanelItems, &PanelItems::notifyRectangleDoubleClick);
	current_widget_rectangle->eventKeyButtonPressed = newDelegate(this, &PropertiesPanelView::notifyRectangleKeyPressed);

	arrow_move = false;
}